History

x86-64: fix gtst, back to only 5 regs for now

grischka committed 16 years ago

Commit b5486241 parent 070b86a1 file · +9 −17Browse files

Unified · Split

x86_64-gen.c+9−17
@@ -270,7 +270,6 @@ static void gen_gotpcrel(int r, Sym *sym, int c) · 269 unmodified lines
270270 greloc(cur_text_section, sym, ind, R_X86_64_PC32);
271271 #endif
272272 gen_le32(0);
273−
274273 if (c) {
275274 /* we use add c, %xxx for displacement */
276275 orex(1, r, 0, 0x81);
@@ -323,8 +322,8 @@ static void gen_modrm(int op_reg, int r, Sym *sym, int c) · 46 unmodified lines
323322 static void gen_modrm64(int opcode, int op_reg, int r, Sym *sym, int c)
324323 {
325324 int is_got;
326− orex(1, r, op_reg, opcode);
327325 is_got = (op_reg & TREG_MEM) && !(sym->type.t & VT_STATIC);
326+ orex(1, r, op_reg, opcode);
328327 gen_modrm_impl(op_reg, r, sym, c, is_got);
329328 }
330329
@@ -833,8 +832,6 @@ void gfunc_call(int nb_args) · 502 unmodified lines
833832 }
834833 }
835834
836− save_regs(0); /* save used temporary registers */
837−
838835 /* for struct arguments, we need to call memcpy and the function
839836 call breaks register passing arguments we are preparing.
840837 So, we process arguments which will be passed by stack first. */
@@ -899,6 +896,7 @@ void gfunc_call(int nb_args) · 58 unmodified lines
899896 }
900897 vtop = orig_vtop;
901898
899+ save_regs(0); /* save used temporary registers */
902900
903901 /* then, we prepare register passing arguments.
904902 Note that we cannot set RDX and RCX in this loop because gv()
@@ -922,19 +920,13 @@ void gfunc_call(int nb_args) · 17 unmodified lines
922920 /* simple type */
923921 /* XXX: implicit cast ? */
924922 if (j < REGN) {
923+ int d = arg_regs[j];
925924 r = gv(RC_INT);
926− if (j < 2) {
927− o(0x8948); /* mov */
928− o(0xc0 + r * 8 + arg_regs[j]);
929− } else if (j < 4) {
930− o(0x8949); /* mov */
925+ if (j == 2 || j == 3)
931926 /* j=2: r10, j=3: r11 */
932− o(0xc0 + r * 8 + j);
933− } else {
934− o(0x8949); /* mov */
935− /* j=4: r8, j=5: r9 */
936− o(0xc0 + r * 8 + j - 4);
937− }
927+ d = j + 8;
928+ orex(1,d,r,0x89); /* mov */
929+ o(0xc0 + REG_VALUE(r) * 8 + REG_VALUE(d));
938930 }
939931 }
940932 vtop--;
@@ -1168,8 +1160,8 @@ int gtst(int inv, int t) · 227 unmodified lines
11681160 t = gjmp(t);
11691161 } else {
11701162 v = gv(RC_INT);
1171− o(0x85);
1172− o(0xc0 + v * 9);
1163+ orex(0,v,v,0x85);
1164+ o(0xc0 + REG_VALUE(v) * 9);
11731165 g(0x0f);
11741166 t = psym(0x85 ^ inv, t);
11751167 }

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