From 3f39b3e523dfb7529e7180d05bfd37ff4d352d64 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Thu, 25 Jul 2019 06:18:20 -0700 Subject: [PATCH] [jit] [x86] Cleanup "_body" and finish conversion to x86_byte. (mono/mono#15628) Commit migrated from https://github.com/mono/mono/commit/ee34e2b1223c461c3d55e6f5a031cdfdaa18cd4a --- src/mono/mono/arch/x86/x86-codegen.h | 205 +++++++++++++++-------------------- 1 file changed, 87 insertions(+), 118 deletions(-) diff --git a/src/mono/mono/arch/x86/x86-codegen.h b/src/mono/mono/arch/x86/x86-codegen.h index 7f04e39..e698668 100644 --- a/src/mono/mono/arch/x86/x86-codegen.h +++ b/src/mono/mono/arch/x86/x86-codegen.h @@ -270,14 +270,15 @@ typedef union { #define x86_byte(inst, x) (*(inst)++ = (unsigned char)(x)) -#define x86_address_byte(inst,m,o,r) do { *(inst)++ = ((((m)&0x03)<<6)|(((o)&0x07)<<3)|(((r)&0x07))); } while (0) +#define x86_address_byte(inst,m,o,r) x86_byte (inst, ((((m)&0x03)<<6) | (((o)&0x07)<<3) | (((r)&0x07)))) + #define x86_imm_emit32(inst,imm) \ do { \ x86_imm_buf imb; imb.val = (int) (imm); \ - *(inst)++ = imb.b [0]; \ - *(inst)++ = imb.b [1]; \ - *(inst)++ = imb.b [2]; \ - *(inst)++ = imb.b [3]; \ + x86_byte (inst, imb.b [0]); \ + x86_byte (inst, imb.b [1]); \ + x86_byte (inst, imb.b [2]); \ + x86_byte (inst, imb.b [3]); \ } while (0) #define x86_imm_emit16(inst,imm) do { *(short*)(inst) = (imm); (inst) += 2; } while (0) #define x86_imm_emit8(inst,imm) do { *(inst) = (unsigned char)((imm) & 0xff); ++(inst); } while (0) @@ -291,7 +292,7 @@ typedef union { #define kMaxMembaseEmitPadding 6 -#define x86_membase_emit_body(inst,r,basereg,disp) do {\ +#define x86_membase_emit(inst,r,basereg,disp) do {\ if ((basereg) == X86_ESP) { \ if ((disp) == 0) { \ x86_address_byte ((inst), 0, (r), X86_ESP); \ @@ -320,11 +321,6 @@ typedef union { } \ } while (0) -#define x86_membase_emit(inst,r,basereg,disp) \ - do { \ - x86_membase_emit_body((inst),(r),(basereg),(disp)); \ - } while (0) - #define kMaxMemindexEmitPadding 6 #define x86_memindex_emit(inst,r,basereg,disp,indexreg,shift) \ @@ -363,7 +359,7 @@ typedef union { * the instruction is inspected for validity and the correct displacement * is inserted. */ -#define x86_do_patch(ins,target) \ +#define x86_patch(ins,target) \ do { \ unsigned char* pos = (ins) + 1; \ int disp, size = 0; \ @@ -387,25 +383,17 @@ typedef union { else assert (0); \ } while (0) -#define x86_patch(ins,target) do { x86_do_patch((ins), (target)); } while (0) +#define x86_breakpoint(inst) x86_byte (inst, 0xcc) -#define x86_breakpoint(inst) \ - do { \ - x86_byte (inst, 0xcc); \ - } while (0) +#define x86_cld(inst) x86_byte (inst, 0xfc) +#define x86_stosb(inst) x86_byte (inst, 0xaa) +#define x86_stosl(inst) x86_byte (inst, 0xab) +#define x86_stosd(inst) x86_stosl (inst) +#define x86_movsb(inst) x86_byte (inst, 0xa4) +#define x86_movsl(inst) x86_byte (inst, 0xa5) +#define x86_movsd(inst) x86_movsl (inst) -#define x86_cld(inst) do { *(inst)++ =(unsigned char)0xfc; } while (0) -#define x86_stosb(inst) do { *(inst)++ =(unsigned char)0xaa; } while (0) -#define x86_stosl(inst) do { *(inst)++ =(unsigned char)0xab; } while (0) -#define x86_stosd(inst) x86_stosl((inst)) -#define x86_movsb(inst) do { *(inst)++ =(unsigned char)0xa4; } while (0) -#define x86_movsl(inst) do { *(inst)++ =(unsigned char)0xa5; } while (0) -#define x86_movsd(inst) x86_movsl((inst)) - -#define x86_prefix(inst,p) \ - do { \ - *(inst)++ =(unsigned char) (p); \ - } while (0) +#define x86_prefix(inst,p) x86_byte (inst, p) #define x86_mfence(inst) \ do { \ @@ -523,7 +511,7 @@ typedef union { x86_membase_emit ((inst), 0, (basereg), (disp)); \ } while (0) -#define x86_inc_reg(inst,reg) do { *(inst)++ = (unsigned char)0x40 + (reg); } while (0) +#define x86_inc_reg(inst,reg) x86_byte (inst, (unsigned char)0x40 + (reg)) #define x86_dec_mem(inst,mem) \ do { \ @@ -539,7 +527,7 @@ typedef union { x86_membase_emit ((inst), 1, (basereg), (disp)); \ } while (0) -#define x86_dec_reg(inst,reg) do { *(inst)++ = (unsigned char)0x48 + (reg); } while (0) +#define x86_dec_reg(inst,reg) x86_byte (inst, (unsigned char)0x48 + (reg)) #define x86_not_mem(inst,mem) \ do { \ @@ -589,7 +577,7 @@ typedef union { do { \ if ((reg) == X86_EAX) { \ x86_codegen_pre(&(inst), 5); \ - *(inst)++ = (((unsigned char)(opc)) << 3) + 5; \ + x86_byte (inst, (((unsigned char)(opc)) << 3) + 5); \ x86_imm_emit32 ((inst), (imm)); \ break; \ } \ @@ -647,21 +635,21 @@ typedef union { #define x86_alu_mem_reg(inst,opc,mem,reg) \ do { \ x86_codegen_pre(&(inst), 6); \ - *(inst)++ = (((unsigned char)(opc)) << 3) + 1; \ + x86_byte (inst, (((unsigned char)(opc)) << 3) + 1); \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_alu_membase_reg(inst,opc,basereg,disp,reg) \ do { \ x86_codegen_pre(&(inst), 1 + kMaxMembaseEmitPadding); \ - *(inst)++ = (((unsigned char)(opc)) << 3) + 1; \ + x86_byte (inst, (((unsigned char)(opc)) << 3) + 1); \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) #define x86_alu_reg_reg(inst,opc,dreg,reg) \ do { \ x86_codegen_pre(&(inst), 2); \ - *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ + x86_byte (inst, (((unsigned char)(opc)) << 3) + 3); \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) @@ -677,21 +665,21 @@ typedef union { #define x86_alu_reg8_reg8(inst,opc,dreg,reg,is_dreg_h,is_reg_h) \ do { \ x86_codegen_pre(&(inst), 2); \ - *(inst)++ = (((unsigned char)(opc)) << 3) + 2; \ + x86_byte (inst, (((unsigned char)(opc)) << 3) + 2); \ x86_reg8_emit ((inst), (dreg), (reg), (is_dreg_h), (is_reg_h)); \ } while (0) #define x86_alu_reg_mem(inst,opc,reg,mem) \ do { \ x86_codegen_pre(&(inst), 6); \ - *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ + x86_byte (inst, (((unsigned char)(opc)) << 3) + 3); \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_alu_reg_membase(inst,opc,reg,basereg,disp) \ do { \ x86_codegen_pre(&(inst), 1 + kMaxMembaseEmitPadding); \ - *(inst)++ = (((unsigned char)(opc)) << 3) + 3; \ + x86_byte (inst, (((unsigned char)(opc)) << 3) + 3); \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) @@ -1097,7 +1085,7 @@ typedef union { #define x86_mov_reg_imm(inst,reg,imm) \ do { \ x86_codegen_pre(&(inst), 5); \ - *(inst)++ = (unsigned char)0xb8 + (reg); \ + x86_byte (inst, (unsigned char)0xb8 + (reg)); \ x86_imm_emit32 ((inst), (imm)); \ } while (0) @@ -1193,7 +1181,7 @@ typedef union { x86_byte (inst, 0x0f); \ if ((is_signed)) op += 0x08; \ if ((is_half)) op += 0x01; \ - *(inst)++ = op; \ + x86_byte (inst, op); \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) @@ -1204,7 +1192,7 @@ typedef union { x86_byte (inst, 0x0f); \ if ((is_signed)) op += 0x08; \ if ((is_half)) op += 0x01; \ - *(inst)++ = op; \ + x86_byte (inst, op); \ x86_mem_emit ((inst), (dreg), (mem)); \ } while (0) @@ -1215,7 +1203,7 @@ typedef union { x86_byte (inst, 0x0f); \ if ((is_signed)) op += 0x08; \ if ((is_half)) op += 0x01; \ - *(inst)++ = op; \ + x86_byte (inst, op); \ x86_membase_emit ((inst), (dreg), (basereg), (disp)); \ } while (0) @@ -1226,7 +1214,7 @@ typedef union { x86_byte (inst, 0x0f); \ if ((is_signed)) op += 0x08; \ if ((is_half)) op += 0x01; \ - *(inst)++ = op; \ + x86_byte (inst, op); \ x86_memindex_emit ((inst), (dreg), (basereg), (disp), (indexreg), (shift)); \ } while (0) @@ -1236,14 +1224,14 @@ typedef union { #define x86_fp_op_mem(inst,opc,mem,is_double) \ do { \ x86_codegen_pre(&(inst), 6); \ - *(inst)++ = (is_double) ? (unsigned char)0xdc : (unsigned char)0xd8; \ + x86_byte (inst, (is_double) ? (unsigned char)0xdc : (unsigned char)0xd8); \ x86_mem_emit ((inst), (opc), (mem)); \ } while (0) #define x86_fp_op_membase(inst,opc,basereg,disp,is_double) \ do { \ x86_codegen_pre(&(inst), 1 + kMaxMembaseEmitPadding); \ - *(inst)++ = (is_double) ? (unsigned char)0xdc : (unsigned char)0xd8; \ + x86_byte (inst, (is_double) ? 0xdc : 0xd8); \ x86_membase_emit ((inst), (opc), (basereg), (disp)); \ } while (0) @@ -1251,15 +1239,15 @@ typedef union { do { \ x86_codegen_pre(&(inst), 2); \ x86_byte (inst, 0xd8); \ - *(inst)++ = (unsigned char)0xc0+((opc)<<3)+((index)&0x07); \ + x86_byte (inst, (unsigned char)0xc0+((opc)<<3)+((index)&0x07)); \ } while (0) #define x86_fp_op_reg(inst,opc,index,pop_stack) \ do { \ static const unsigned char map[] = { 0, 1, 2, 3, 5, 4, 7, 6, 8}; \ x86_codegen_pre(&(inst), 2); \ - *(inst)++ = (pop_stack) ? (unsigned char)0xde : (unsigned char)0xdc; \ - *(inst)++ = (unsigned char)0xc0+(map[(opc)]<<3)+((index)&0x07); \ + x86_byte (inst, (pop_stack) ? 0xde : 0xdc); \ + x86_byte (inst, (unsigned char)0xc0+(map[(opc)]<<3)+((index)&0x07)); \ } while (0) /** @@ -1272,7 +1260,7 @@ typedef union { #define x86_fp_int_op_membase(inst,opc,basereg,disp,is_int) \ do { \ x86_codegen_pre(&(inst), 1 + kMaxMembaseEmitPadding); \ - *(inst)++ = (is_int) ? (unsigned char)0xda : (unsigned char)0xde; \ + x86_byte (inst, (is_int) ? 0xda : 0xde); \ x86_membase_emit ((inst), opc, (basereg), (disp)); \ } while (0) @@ -1280,7 +1268,7 @@ typedef union { do { \ x86_codegen_pre(&(inst), 2); \ x86_byte (inst, 0xdd); \ - *(inst)++ = (unsigned char)0xd8+(index); \ + x86_byte (inst, (unsigned char)0xd8+(index)); \ } while (0) #define x86_fcompp(inst) \ @@ -1350,48 +1338,48 @@ typedef union { do { \ x86_codegen_pre(&(inst), 2); \ x86_byte (inst, 0xd9); \ - *(inst)++ = (unsigned char)0xc8 + ((index) & 0x07); \ + x86_byte (inst, (unsigned char)0xc8 + ((index) & 0x07)); \ } while (0) #define x86_fcomi(inst,index) \ do { \ x86_codegen_pre(&(inst), 2); \ x86_byte (inst, 0xdb); \ - *(inst)++ = (unsigned char)0xf0 + ((index) & 0x07); \ + x86_byte (inst, (unsigned char)0xf0 + ((index) & 0x07)); \ } while (0) #define x86_fcomip(inst,index) \ do { \ x86_codegen_pre(&(inst), 2); \ x86_byte (inst, 0xdf); \ - *(inst)++ = (unsigned char)0xf0 + ((index) & 0x07); \ + x86_byte (inst, (unsigned char)0xf0 + ((index) & 0x07)); \ } while (0) #define x86_fucomi(inst,index) \ do { \ x86_codegen_pre(&(inst), 2); \ x86_byte (inst, 0xdb); \ - *(inst)++ = (unsigned char)0xe8 + ((index) & 0x07); \ + x86_byte (inst, (unsigned char)0xe8 + ((index) & 0x07)); \ } while (0) #define x86_fucomip(inst,index) \ do { \ x86_codegen_pre(&(inst), 2); \ x86_byte (inst, 0xdf); \ - *(inst)++ = (unsigned char)0xe8 + ((index) & 0x07); \ + x86_byte (inst, (unsigned char)0xe8 + ((index) & 0x07)); \ } while (0) #define x86_fld(inst,mem,is_double) \ do { \ x86_codegen_pre(&(inst), 6); \ - *(inst)++ = (is_double) ? (unsigned char)0xdd : (unsigned char)0xd9; \ + x86_byte (inst, (is_double) ? 0xdd : 0xd9); \ x86_mem_emit ((inst), 0, (mem)); \ } while (0) #define x86_fld_membase(inst,basereg,disp,is_double) \ do { \ x86_codegen_pre(&(inst), 1 + kMaxMembaseEmitPadding); \ - *(inst)++ = (is_double) ? (unsigned char)0xdd : (unsigned char)0xd9; \ + x86_byte (inst, (is_double) ? 0xdd : 0xd9); \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ } while (0) @@ -1437,7 +1425,7 @@ typedef union { do { \ x86_codegen_pre(&(inst), 2); \ x86_byte (inst, 0xd9); \ - *(inst)++ = (unsigned char)0xc0 + ((index) & 0x07); \ + x86_byte (inst, (unsigned char)0xc0 + ((index) & 0x07)); \ } while (0) #define x86_fldz(inst) \ @@ -1464,14 +1452,14 @@ typedef union { #define x86_fst(inst,mem,is_double,pop_stack) \ do { \ x86_codegen_pre(&(inst), 6); \ - *(inst)++ = (is_double) ? (unsigned char)0xdd: (unsigned char)0xd9; \ + x86_byte (inst, (is_double) ? 0xdd: 0xd9); \ x86_mem_emit ((inst), 2 + ((pop_stack) ? 1 : 0), (mem)); \ } while (0) #define x86_fst_membase(inst,basereg,disp,is_double,pop_stack) \ do { \ x86_codegen_pre(&(inst), 1 + kMaxMembaseEmitPadding); \ - *(inst)++ = (is_double) ? (unsigned char)0xdd: (unsigned char)0xd9; \ + x86_byte (inst, (is_double) ? 0xdd: 0xd9); \ x86_membase_emit ((inst), 2 + ((pop_stack) ? 1 : 0), (basereg), (disp)); \ } while (0) @@ -1542,10 +1530,7 @@ typedef union { } while (0) -#define x86_push_reg(inst,reg) \ - do { \ - *(inst)++ = (unsigned char)0x50 + (reg); \ - } while (0) +#define x86_push_reg(inst,reg) x86_byte(inst, (unsigned char)0x50 + (reg)) #define x86_push_regp(inst,reg) \ do { \ @@ -1591,10 +1576,7 @@ typedef union { } \ } while (0) -#define x86_pop_reg(inst,reg) \ - do { \ - *(inst)++ = (unsigned char)0x58 + (reg); \ - } while (0) +#define x86_pop_reg(inst,reg) x86_byte (inst, (unsigned char)0x58 + (reg)) #define x86_pop_mem(inst,mem) \ do { \ @@ -1690,7 +1672,7 @@ typedef union { /* * target is a pointer in our buffer. */ -#define x86_jump_code_body(inst,target) \ +#define x86_jump_code(inst,target) \ do { \ int t; \ x86_codegen_pre(&(inst), 2); \ @@ -1704,11 +1686,6 @@ typedef union { } \ } while (0) -#define x86_jump_code(inst,target) \ - do { \ - x86_jump_code_body((inst),(target)); \ - } while (0) - #define x86_jump_disp(inst,disp) \ do { \ int t = (disp) - 2; \ @@ -1725,9 +1702,9 @@ typedef union { do { \ x86_codegen_pre(&(inst), 2); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)]; \ + x86_byte(inst, x86_cc_signed_map [(cond)]); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)]; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)]); \ x86_imm_emit8 ((inst), (imm)); \ } while (0) @@ -1736,9 +1713,9 @@ typedef union { x86_codegen_pre(&(inst), 6); \ x86_byte (inst, 0x0f); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)] + 0x10; \ + x86_byte(inst, x86_cc_signed_map [(cond)] + 0x10); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x10; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)] + 0x10); \ x86_imm_emit32 ((inst), (imm)); \ } while (0) #elif defined(TARGET_AMD64) @@ -1748,9 +1725,9 @@ typedef union { do { \ amd64_codegen_pre(inst); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)]; \ + x86_byte(inst, x86_cc_signed_map [(cond)]); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)]; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)]); \ x86_imm_emit8 ((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) @@ -1759,9 +1736,9 @@ typedef union { amd64_codegen_pre(inst); \ x86_byte (inst, 0x0f); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)] + 0x10; \ + x86_byte(inst, x86_cc_signed_map [(cond)] + 0x10); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x10; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)] + 0x10); \ x86_imm_emit32 ((inst), (imm)); \ amd64_codegen_post(inst); \ } while (0) @@ -1788,7 +1765,7 @@ typedef union { /* This macro is used directly from mini-amd64.c and other */ /* amd64 specific files, so it needs to be instrumented directly. */ -#define x86_branch_body(inst,cond,target,is_signed) \ +#define x86_branch(inst,cond,target,is_signed) \ do { \ int offset = (target) - (inst) - 2; \ if (x86_is_imm8 ((offset))) \ @@ -1799,11 +1776,6 @@ typedef union { } \ } while (0) -#define x86_branch(inst,cond,target,is_signed) \ - do { \ - x86_branch_body((inst),(cond),(target),(is_signed)); \ - } while (0) - #endif /* TARGET_AMD64 */ #define x86_branch_disp(inst,cond,disp,is_signed) \ @@ -1823,9 +1795,9 @@ typedef union { x86_codegen_pre(&(inst), 3); \ x86_byte (inst, 0x0f); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)] + 0x20; \ + x86_byte(inst, x86_cc_signed_map [(cond)] + 0x20); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x20; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)] + 0x20); \ x86_reg_emit ((inst), 0, (reg)); \ } while (0) @@ -1834,9 +1806,9 @@ typedef union { x86_codegen_pre(&(inst), 7); \ x86_byte (inst, 0x0f); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)] + 0x20; \ + x86_byte(inst, x86_cc_signed_map [(cond)] + 0x20); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x20; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)] + 0x20); \ x86_mem_emit ((inst), 0, (mem)); \ } while (0) @@ -1845,9 +1817,9 @@ typedef union { x86_codegen_pre(&(inst), 2 + kMaxMembaseEmitPadding); \ x86_byte (inst, 0x0f); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)] + 0x20; \ + x86_byte(inst, x86_cc_signed_map [(cond)] + 0x20); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)] + 0x20; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)] + 0x20); \ x86_membase_emit ((inst), 0, (basereg), (disp)); \ } while (0) @@ -1907,33 +1879,33 @@ typedef union { #define x86_cmov_reg(inst,cond,is_signed,dreg,reg) \ do { \ x86_codegen_pre(&(inst), 3); \ - *(inst)++ = (unsigned char) 0x0f; \ + x86_byte (inst, 0x0f); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)] - 0x30; \ + x86_byte(inst, x86_cc_signed_map [(cond)] - 0x30); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)] - 0x30; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)] - 0x30); \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) #define x86_cmov_mem(inst,cond,is_signed,reg,mem) \ do { \ x86_codegen_pre(&(inst), 7); \ - *(inst)++ = (unsigned char) 0x0f; \ + x86_byte(inst, 0x0f); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)] - 0x30; \ + x86_byte(inst, x86_cc_signed_map [(cond)] - 0x30); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)] - 0x30; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)] - 0x30); \ x86_mem_emit ((inst), (reg), (mem)); \ } while (0) #define x86_cmov_membase(inst,cond,is_signed,reg,basereg,disp) \ do { \ x86_codegen_pre(&(inst), 2 + kMaxMembaseEmitPadding); \ - *(inst)++ = (unsigned char) 0x0f; \ + x86_byte(inst, 0x0f); \ if ((is_signed)) \ - *(inst)++ = x86_cc_signed_map [(cond)] - 0x30; \ + x86_byte(inst, x86_cc_signed_map [(cond)] - 0x30); \ else \ - *(inst)++ = x86_cc_unsigned_map [(cond)] - 0x30; \ + x86_byte(inst, x86_cc_unsigned_map [(cond)] - 0x30); \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) @@ -1942,7 +1914,7 @@ typedef union { x86_codegen_pre(&(inst), 4); \ x86_byte (inst, 0xc8); \ x86_imm_emit16 ((inst), (framesize)); \ - *(inst)++ = 0; \ + x86_byte(inst, 0); \ } while (0) #define x86_leave(inst) do { x86_byte (inst, 0xc9); } while (0) @@ -2184,7 +2156,7 @@ typedef enum { do { \ x86_codegen_pre(&(inst), 3); \ x86_byte (inst, 0x0F); \ - *(inst)++ = (unsigned char)(opc); \ + x86_byte (inst, opc); \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) @@ -2192,7 +2164,7 @@ typedef enum { do { \ x86_codegen_pre(&(inst), 2 + kMaxMembaseEmitPadding); \ x86_byte (inst, 0x0f); \ - *(inst)++ = (unsigned char)(opc); \ + x86_byte (inst, opc); \ x86_membase_emit ((inst), (sreg), (basereg), (disp)); \ } while (0) @@ -2200,7 +2172,7 @@ typedef enum { do { \ x86_codegen_pre(&(inst), 2 + kMaxMembaseEmitPadding); \ x86_byte (inst, 0x0F); \ - *(inst)++ = (unsigned char)(opc); \ + x86_byte (inst, opc); \ x86_membase_emit ((inst), (reg), (basereg), (disp)); \ } while (0) @@ -2208,9 +2180,9 @@ typedef enum { do { \ x86_codegen_pre(&(inst), 4); \ x86_byte (inst, 0x0F); \ - *(inst)++ = (unsigned char)(opc); \ + x86_byte (inst, opc); \ x86_reg_emit ((inst), (dreg), (reg)); \ - *(inst)++ = (unsigned char)(imm8); \ + x86_byte (inst, imm8); \ } while (0) #define x86_sse_alu_pd_reg_reg_imm8(inst,opc,dreg,reg, imm8) \ @@ -2245,14 +2217,14 @@ typedef enum { do { \ x86_codegen_pre(&(inst), 5); \ x86_sse_alu_pd_reg_reg ((inst), (opc), (dreg), (reg)); \ - *(inst)++ = (unsigned char)(imm); \ + x86_byte (inst, imm); \ } while (0) #define x86_sse_alu_pd_reg_membase_imm(inst,opc,dreg,basereg,disp,imm) \ do { \ x86_codegen_pre(&(inst), 4 + kMaxMembaseEmitPadding); \ x86_sse_alu_pd_reg_membase ((inst), (opc), (dreg),(basereg), (disp)); \ - *(inst)++ = (unsigned char)(imm); \ + x86_byte (inst, imm); \ } while (0) @@ -2265,7 +2237,7 @@ typedef enum { do { \ x86_codegen_pre(&(inst), 4); \ x86_sse_alu_reg_reg ((inst), (opc), (dreg), (reg)); \ - *(inst)++ = (unsigned char)imm; \ + x86_byte (inst, imm); \ } while (0) @@ -2306,7 +2278,7 @@ typedef enum { x86_byte (inst, 0x66); \ x86_byte (inst, 0x0F); \ x86_byte (inst, 0x38); \ - *(inst)++ = (unsigned char)(opc); \ + x86_byte (inst, opc); \ x86_reg_emit ((inst), (dreg), (reg)); \ } while (0) @@ -2381,11 +2353,11 @@ typedef enum { #define x86_pshufw_reg_reg(inst,dreg,sreg,mask,high_words) \ do { \ x86_codegen_pre(&(inst), 5); \ - *(inst)++ = (unsigned char)(high_words) ? 0xF3 : 0xF2; \ + x86_byte (inst, (high_words) ? 0xF3 : 0xF2); \ x86_byte (inst, 0x0f); \ x86_byte (inst, 0x70); \ x86_reg_emit ((inst), (dreg), (sreg)); \ - *(inst)++ = (unsigned char)mask; \ + x86_byte (inst, mask); \ } while (0) #define x86_sse_shift_reg_imm(inst,opc,mode, dreg,imm) \ @@ -2400,7 +2372,4 @@ typedef enum { x86_sse_alu_pd_reg_reg (inst, opc, dreg, sreg); \ } while (0) - - #endif // X86_H - -- 2.7.4