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
270 greloc(cur_text_section, sym, ind, R_X86_64_PC32);270 greloc(cur_text_section, sym, ind, R_X86_64_PC32);
271#endif271#endif
272 gen_le32(0);272 gen_le32(0);
273
274 if (c) {273 if (c) {
275 /* we use add c, %xxx for displacement */274 /* we use add c, %xxx for displacement */
276 orex(1, r, 0, 0x81);275 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
323static void gen_modrm64(int opcode, int op_reg, int r, Sym *sym, int c)322static void gen_modrm64(int opcode, int op_reg, int r, Sym *sym, int c)
324{323{
325 int is_got;324 int is_got;
326 orex(1, r, op_reg, opcode);
327 is_got = (op_reg & TREG_MEM) && !(sym->type.t & VT_STATIC);325 is_got = (op_reg & TREG_MEM) && !(sym->type.t & VT_STATIC);
326 orex(1, r, op_reg, opcode);
328 gen_modrm_impl(op_reg, r, sym, c, is_got);327 gen_modrm_impl(op_reg, r, sym, c, is_got);
329}328}
330 329
@@ -833,8 +832,6 @@ void gfunc_call(int nb_args) · 502 unmodified lines
833 }832 }
834 }833 }
835 834
836 save_regs(0); /* save used temporary registers */
837
838 /* for struct arguments, we need to call memcpy and the function835 /* for struct arguments, we need to call memcpy and the function
839 call breaks register passing arguments we are preparing.836 call breaks register passing arguments we are preparing.
840 So, we process arguments which will be passed by stack first. */837 So, we process arguments which will be passed by stack first. */
@@ -899,6 +896,7 @@ void gfunc_call(int nb_args) · 58 unmodified lines
899 }896 }
900 vtop = orig_vtop;897 vtop = orig_vtop;
901 898
899 save_regs(0); /* save used temporary registers */
902 900
903 /* then, we prepare register passing arguments.901 /* then, we prepare register passing arguments.
904 Note that we cannot set RDX and RCX in this loop because gv()902 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
922 /* simple type */920 /* simple type */
923 /* XXX: implicit cast ? */921 /* XXX: implicit cast ? */
924 if (j < REGN) {922 if (j < REGN) {
923 int d = arg_regs[j];
925 r = gv(RC_INT);924 r = gv(RC_INT);
926 if (j < 2) {925 if (j == 2 || j == 3)
927 o(0x8948); /* mov */
928 o(0xc0 + r * 8 + arg_regs[j]);
929 } else if (j < 4) {
930 o(0x8949); /* mov */
931 /* j=2: r10, j=3: r11 */926 /* j=2: r10, j=3: r11 */
932 o(0xc0 + r * 8 + j);927 d = j + 8;
933 } else {928 orex(1,d,r,0x89); /* mov */
934 o(0x8949); /* mov */929 o(0xc0 + REG_VALUE(r) * 8 + REG_VALUE(d));
935 /* j=4: r8, j=5: r9 */
936 o(0xc0 + r * 8 + j - 4);
937 }
938 }930 }
939 }931 }
940 vtop--;932 vtop--;
@@ -1168,8 +1160,8 @@ int gtst(int inv, int t) · 227 unmodified lines
1168 t = gjmp(t);1160 t = gjmp(t);
1169 } else {1161 } else {
1170 v = gv(RC_INT);1162 v = gv(RC_INT);
1171 o(0x85);1163 orex(0,v,v,0x85);
1172 o(0xc0 + v * 9);1164 o(0xc0 + REG_VALUE(v) * 9);
1173 g(0x0f);1165 g(0x0f);
1174 t = psym(0x85 ^ inv, t);1166 t = psym(0x85 ^ inv, t);
1175 }1167 }

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