History

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).

grischka committed 9 years ago

Commit 559ee1e1 parent d2332392 files · +11 −6Browse files

Unified · Split

2 files
  1. i386-gen.c +10 −5
  2. tccgen.c +1 −1
i386-gen.c+10−5
@@ -79,7 +79,7 @@ enum { · 78 unmodified lines
7979 #include "tcc.h"
8080
8181 /* define to 1/0 to [not] have EBX as 4th register */
82−#define USE_EBX 1
82+#define USE_EBX 0
8383
8484 ST_DATA const int reg_classes[NB_REGS] = {
8585 /* eax */ RC_INT | RC_EAX,
@@ -636,7 +636,15 @@ ST_FUNC void gfunc_epilog(void) · 550 unmodified lines
636636 o(0x585a); /* restore returned value, if any */
637637 }
638638 #endif
639− o(0x5b * USE_EBX); /* pop ebx */
639+
640+ /* align local size to word & save local variables */
641+ v = (-loc + 3) & -4;
642+
643+#if USE_EBX
644+ o(0x8b);
645+ gen_modrm(TREG_EBX, VT_LOCAL, NULL, -(v+4));
646+#endif
647+
640648 o(0xc9); /* leave */
641649 if (func_ret_sub == 0) {
642650 o(0xc3); /* ret */
@@ -645,9 +653,6 @@ ST_FUNC void gfunc_epilog(void) · 2 unmodified lines
645653 g(func_ret_sub);
646654 g(func_ret_sub >> 8);
647655 }
648− /* align local size to word & save local variables */
649−
650− v = (-loc + 3) & -4;
651656 saved_ind = ind;
652657 ind = func_sub_sp_offset - FUNC_PROLOG_SIZE;
653658 #ifdef TCC_TARGET_PE
tccgen.c+1−1
@@ -5164,8 +5164,8 @@ static void expr_cond(void) · 5163 unmodified lines
51645164 #endif
51655165 } else
51665166 rc = RC_INT;
5167− save_regs(1);
51685167 gv(rc);
5168+ save_regs(1);
51695169 if (g)
51705170 gv_dup();
51715171 tt = gvtst(1, 0);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t