Unified · Split
| @@ -270,7 +270,6 @@ static void gen_gotpcrel(int r, Sym *sym, int c) · 269 unmodified lines | ||
| 270 | 270 | greloc(cur_text_section, sym, ind, R_X86_64_PC32); |
| 271 | 271 | #endif |
| 272 | 272 | gen_le32(0); |
| 273 | − | |
| 274 | 273 | if (c) { |
| 275 | 274 | /* we use add c, %xxx for displacement */ |
| 276 | 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 | ||
| 323 | 322 | static void gen_modrm64(int opcode, int op_reg, int r, Sym *sym, int c) |
| 324 | 323 | { |
| 325 | 324 | int is_got; |
| 326 | − orex(1, r, op_reg, opcode); | |
| 327 | 325 | is_got = (op_reg & TREG_MEM) && !(sym->type.t & VT_STATIC); |
| 326 | + orex(1, r, op_reg, opcode); | |
| 328 | 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 | 835 | /* for struct arguments, we need to call memcpy and the function |
| 839 | 836 | call breaks register passing arguments we are preparing. |
| 840 | 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 | 897 | vtop = orig_vtop; |
| 901 | 898 | |
| 899 | + save_regs(0); /* save used temporary registers */ | |
| 902 | 900 | |
| 903 | 901 | /* then, we prepare register passing arguments. |
| 904 | 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 | 920 | /* simple type */ |
| 923 | 921 | /* XXX: implicit cast ? */ |
| 924 | 922 | if (j < REGN) { |
| 923 | + int d = arg_regs[j]; | |
| 925 | 924 | 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) | |
| 931 | 926 | /* 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)); | |
| 938 | 930 | } |
| 939 | 931 | } |
| 940 | 932 | vtop--; |
| @@ -1168,8 +1160,8 @@ int gtst(int inv, int t) · 227 unmodified lines | ||
| 1168 | 1160 | t = gjmp(t); |
| 1169 | 1161 | } else { |
| 1170 | 1162 | 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); | |
| 1173 | 1165 | g(0x0f); |
| 1174 | 1166 | t = psym(0x85 ^ inv, t); |
| 1175 | 1167 | } |