aboutsummaryrefslogtreecommitdiff
path: root/i386-gen.c
diff options
context:
space:
mode:
authorgrischka <grischka>2016-12-19 00:27:08 +0100
committergrischka <grischka>2016-12-19 00:33:01 +0100
commit559ee1e940c22a49ac8a39f6053917533e71243a (patch)
tree1baa77ed7650f1f72d59b8a9907b185954fa284b /i386-gen.c
parentd2332396e43914ae8239cbc53ae7b0f1f3bb614c (diff)
downloadtinycc-559ee1e940c22a49ac8a39f6053917533e71243a.tar.gz
tinycc-559ee1e940c22a49ac8a39f6053917533e71243a.tar.bz2
i386-gen: fix USE_EBX
Restore ebx from *ebp because alloca might change esp. Also disable USE_EBX for upcoming release. Actually the benefit is less than one would expect, it appears that tcc can't do much with more than 3 registers except with extensive use of long longs where the disassembly looks much prettier (and shorter also). Also: tccgen/expr_cond() : fix wrong gv/save_regs order
Diffstat (limited to 'i386-gen.c')
-rw-r--r--i386-gen.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/i386-gen.c b/i386-gen.c
index 3a26f7a..946e42d 100644
--- a/i386-gen.c
+++ b/i386-gen.c
@@ -79,7 +79,7 @@ enum {
#include "tcc.h"
/* define to 1/0 to [not] have EBX as 4th register */
-#define USE_EBX 1
+#define USE_EBX 0
ST_DATA const int reg_classes[NB_REGS] = {
/* eax */ RC_INT | RC_EAX,
@@ -636,7 +636,15 @@ ST_FUNC void gfunc_epilog(void)
o(0x585a); /* restore returned value, if any */
}
#endif
- o(0x5b * USE_EBX); /* pop ebx */
+
+ /* align local size to word & save local variables */
+ v = (-loc + 3) & -4;
+
+#if USE_EBX
+ o(0x8b);
+ gen_modrm(TREG_EBX, VT_LOCAL, NULL, -(v+4));
+#endif
+
o(0xc9); /* leave */
if (func_ret_sub == 0) {
o(0xc3); /* ret */
@@ -645,9 +653,6 @@ ST_FUNC void gfunc_epilog(void)
g(func_ret_sub);
g(func_ret_sub >> 8);
}
- /* align local size to word & save local variables */
-
- v = (-loc + 3) & -4;
saved_ind = ind;
ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
#ifdef TCC_TARGET_PE