diff --git a/src/codegen_new/codegen.c b/src/codegen_new/codegen.c index 0b3449500..8dfb9b386 100644 --- a/src/codegen_new/codegen.c +++ b/src/codegen_new/codegen.c @@ -31,9 +31,9 @@ static struct { } codegen_instructions[MAX_INSTRUCTION_COUNT]; void -codegen_print_mmx(void) +codegen_print_mmx(const char* str) { - pclog("MMX results: %016llX, %016llX, %016llX, %016llX, %016llX, %016llX, %016llX, %016llX\n", (unsigned long long)cpu_state.MM[0].q, (unsigned long long)cpu_state.MM[1].q, (unsigned long long)cpu_state.MM[2].q, (unsigned long long)cpu_state.MM[3].q, (unsigned long long)cpu_state.MM[4].q, (unsigned long long)cpu_state.MM[5].q, (unsigned long long)cpu_state.MM[6].q, (unsigned long long)cpu_state.MM[7].q); + pclog("MMX results: %016llX, %016llX, %016llX, %016llX, %016llX, %016llX, %016llX, %016llX (%s)\n", (unsigned long long)cpu_state.MM[0].q, (unsigned long long)cpu_state.MM[1].q, (unsigned long long)cpu_state.MM[2].q, (unsigned long long)cpu_state.MM[3].q, (unsigned long long)cpu_state.MM[4].q, (unsigned long long)cpu_state.MM[5].q, (unsigned long long)cpu_state.MM[6].q, (unsigned long long)cpu_state.MM[7].q, str); } int diff --git a/src/codegen_new/codegen_backend_arm64_uops.c b/src/codegen_new/codegen_backend_arm64_uops.c index 925e6517b..c09b74fca 100644 --- a/src/codegen_new/codegen_backend_arm64_uops.c +++ b/src/codegen_new/codegen_backend_arm64_uops.c @@ -850,28 +850,28 @@ codegen_LOAD_FUNC_ARG3(codeblock_t *block, uop_t *uop) static int codegen_LOAD_FUNC_ARG0_IMM(codeblock_t *block, uop_t *uop) { - host_arm64_mov_imm(block, REG_ARG0, uop->imm_data); + host_arm64_MOVX_IMM(block, REG_ARG0, uop->imm_data); return 0; } static int codegen_LOAD_FUNC_ARG1_IMM(codeblock_t *block, uop_t *uop) { - host_arm64_mov_imm(block, REG_ARG1, uop->imm_data); + host_arm64_MOVX_IMM(block, REG_ARG1, uop->imm_data); return 0; } static int codegen_LOAD_FUNC_ARG2_IMM(codeblock_t *block, uop_t *uop) { - host_arm64_mov_imm(block, REG_ARG2, uop->imm_data); + host_arm64_MOVX_IMM(block, REG_ARG2, uop->imm_data); return 0; } static int codegen_LOAD_FUNC_ARG3_IMM(codeblock_t *block, uop_t *uop) { - host_arm64_mov_imm(block, REG_ARG3, uop->imm_data); + host_arm64_MOVX_IMM(block, REG_ARG3, uop->imm_data); return 0; } diff --git a/src/codegen_new/codegen_backend_x86-64_uops.c b/src/codegen_new/codegen_backend_x86-64_uops.c index 356c8bcde..6b206d5b5 100644 --- a/src/codegen_new/codegen_backend_x86-64_uops.c +++ b/src/codegen_new/codegen_backend_x86-64_uops.c @@ -220,9 +220,9 @@ static int codegen_CALL_INSTRUCTION_FUNC(codeblock_t *block, uop_t *uop) { # if _WIN64 - host_x86_MOV32_REG_IMM(block, REG_ECX, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RCX, uop->imm_data); # else - host_x86_MOV32_REG_IMM(block, REG_EDI, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RDI, uop->imm_data); # endif host_x86_CALL(block, uop->p); host_x86_TEST32_REG(block, REG_EAX, REG_EAX); @@ -906,9 +906,9 @@ static int codegen_LOAD_FUNC_ARG0_IMM(codeblock_t *block, uop_t *uop) { # if _WIN64 - host_x86_MOV32_REG_IMM(block, REG_ECX, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RCX, uop->imm_data); # else - host_x86_MOV32_REG_IMM(block, REG_EDI, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RDI, uop->imm_data); # endif return 0; } @@ -916,9 +916,9 @@ static int codegen_LOAD_FUNC_ARG1_IMM(codeblock_t *block, uop_t *uop) { # if _WIN64 - host_x86_MOV32_REG_IMM(block, REG_EDX, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RDX, uop->imm_data); # else - host_x86_MOV32_REG_IMM(block, REG_ESI, uop->imm_data); + host_x86_MOV64_REG_IMM(block, REG_RSI, uop->imm_data); # endif return 0; } diff --git a/src/codegen_new/codegen_ir_defs.h b/src/codegen_new/codegen_ir_defs.h index 60f7badea..bfc19373b 100644 --- a/src/codegen_new/codegen_ir_defs.h +++ b/src/codegen_new/codegen_ir_defs.h @@ -336,7 +336,7 @@ typedef struct uop_t { ir_reg_t src_reg_a; ir_reg_t src_reg_b; ir_reg_t src_reg_c; - uint32_t imm_data; + uintptr_t imm_data; void *p; ir_host_reg_t dest_reg_a_real; ir_host_reg_t src_reg_a_real, src_reg_b_real, src_reg_c_real; @@ -601,7 +601,7 @@ uop_gen_reg_src3_imm(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_re } static inline void -uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uint32_t imm) +uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uintptr_t imm) { uop_t *uop = uop_alloc(ir, uop_type); diff --git a/src/codegen_new/codegen_ops_mmx_arith.c b/src/codegen_new/codegen_ops_mmx_arith.c index 3ac6eb0d6..4f8a5d91c 100644 --- a/src/codegen_new/codegen_ops_mmx_arith.c +++ b/src/codegen_new/codegen_ops_mmx_arith.c @@ -16,7 +16,7 @@ #include "codegen_ops_mmx_arith.h" #include "codegen_ops_helpers.h" -extern void codegen_print_mmx(void); +extern void codegen_print_mmx(const char* str); #define ropParith(func) \ uint32_t rop##func(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), \ @@ -39,6 +39,7 @@ extern void codegen_print_mmx(void); uop_##func(ir, IREG_MM(dest_reg), IREG_MM(dest_reg), IREG_temp0_Q); \ } \ \ + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); \ uop_CALL_FUNC(ir, codegen_print_mmx); \ return op_pc + 1; \ } diff --git a/src/codegen_new/codegen_ops_mmx_cmp.c b/src/codegen_new/codegen_ops_mmx_cmp.c index 865522f09..d28c9197c 100644 --- a/src/codegen_new/codegen_ops_mmx_cmp.c +++ b/src/codegen_new/codegen_ops_mmx_cmp.c @@ -16,7 +16,7 @@ #include "codegen_ops_mmx_cmp.h" #include "codegen_ops_helpers.h" -extern void codegen_print_mmx(void); +extern void codegen_print_mmx(const char* str); #define ropPcmp(func) \ uint32_t rop##func(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), \ @@ -39,6 +39,7 @@ extern void codegen_print_mmx(void); uop_##func(ir, IREG_MM(dest_reg), IREG_MM(dest_reg), IREG_temp0_Q); \ } \ \ + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); \ uop_CALL_FUNC(ir, codegen_print_mmx); \ return op_pc + 1; \ } diff --git a/src/codegen_new/codegen_ops_mmx_loadstore.c b/src/codegen_new/codegen_ops_mmx_loadstore.c index c0148781e..d7ff5b355 100644 --- a/src/codegen_new/codegen_ops_mmx_loadstore.c +++ b/src/codegen_new/codegen_ops_mmx_loadstore.c @@ -16,7 +16,7 @@ #include "codegen_ops_mmx_loadstore.h" #include "codegen_ops_helpers.h" -extern void codegen_print_mmx(void); +extern void codegen_print_mmx(const char* str); uint32_t ropMOVD_r_d(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) @@ -38,6 +38,7 @@ ropMOVD_r_d(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t uop_MOVZX(ir, IREG_MM(dest_reg), IREG_temp0); } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); return op_pc + 1; } @@ -65,6 +66,7 @@ ropMOVD_d_r(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_temp0); } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); return op_pc + 1; } @@ -88,6 +90,7 @@ ropMOVQ_r_q(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t uop_MEM_LOAD_REG(ir, IREG_MM(dest_reg), ireg_seg_base(target_seg), IREG_eaaddr); } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); return op_pc + 1; } @@ -112,6 +115,7 @@ ropMOVQ_q_r(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t uop_MEM_STORE_REG(ir, ireg_seg_base(target_seg), IREG_eaaddr, IREG_MM(src_reg)); } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); return op_pc + 1; } diff --git a/src/codegen_new/codegen_ops_mmx_logic.c b/src/codegen_new/codegen_ops_mmx_logic.c index 36d957c5e..e8e092fad 100644 --- a/src/codegen_new/codegen_ops_mmx_logic.c +++ b/src/codegen_new/codegen_ops_mmx_logic.c @@ -16,7 +16,7 @@ #include "codegen_ops_mmx_logic.h" #include "codegen_ops_helpers.h" -extern void codegen_print_mmx(void); +extern void codegen_print_mmx(const char* str); uint32_t ropPAND(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) { @@ -37,6 +37,7 @@ ropPAND(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t fetc uop_AND(ir, IREG_MM(dest_reg), IREG_MM(dest_reg), IREG_temp0_Q); } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); return op_pc + 1; } @@ -60,6 +61,7 @@ ropPANDN(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t fet uop_ANDN(ir, IREG_MM(dest_reg), IREG_MM(dest_reg), IREG_temp0_Q); } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); return op_pc + 1; } @@ -83,6 +85,7 @@ ropPOR(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t fetch uop_OR(ir, IREG_MM(dest_reg), IREG_MM(dest_reg), IREG_temp0_Q); } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); return op_pc + 1; } @@ -106,6 +109,7 @@ ropPXOR(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t fetc uop_XOR(ir, IREG_MM(dest_reg), IREG_MM(dest_reg), IREG_temp0_Q); } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); return op_pc + 1; } diff --git a/src/codegen_new/codegen_ops_mmx_pack.c b/src/codegen_new/codegen_ops_mmx_pack.c index 69ec3ce3a..5c01c7e92 100644 --- a/src/codegen_new/codegen_ops_mmx_pack.c +++ b/src/codegen_new/codegen_ops_mmx_pack.c @@ -16,7 +16,7 @@ #include "codegen_ops_mmx_pack.h" #include "codegen_ops_helpers.h" -extern void codegen_print_mmx(void); +extern void codegen_print_mmx(const char* str); #define ropPpack(func) \ uint32_t rop##func(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), \ uint32_t fetchdat, uint32_t op_32, uint32_t op_pc) \ @@ -38,6 +38,7 @@ extern void codegen_print_mmx(void); uop_##func(ir, IREG_MM(dest_reg), IREG_MM(dest_reg), IREG_temp0_Q); \ } \ \ + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); \ uop_CALL_FUNC(ir, codegen_print_mmx); \ return op_pc + 1; \ } diff --git a/src/codegen_new/codegen_ops_mmx_shift.c b/src/codegen_new/codegen_ops_mmx_shift.c index b1f41d1bb..42aea4f1c 100644 --- a/src/codegen_new/codegen_ops_mmx_shift.c +++ b/src/codegen_new/codegen_ops_mmx_shift.c @@ -16,7 +16,7 @@ #include "codegen_ops_mmx_shift.h" #include "codegen_ops_helpers.h" -extern void codegen_print_mmx(void); +extern void codegen_print_mmx(const char* str); uint32_t ropPSxxW_imm(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t fetchdat, UNUSED(uint32_t op_32), uint32_t op_pc) { @@ -40,6 +40,7 @@ ropPSxxW_imm(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t return 0; } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); codegen_mark_code_present(block, cs + op_pc + 1, 1); return op_pc + 2; @@ -67,6 +68,7 @@ ropPSxxD_imm(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t return 0; } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); codegen_mark_code_present(block, cs + op_pc + 1, 1); return op_pc + 2; @@ -94,6 +96,7 @@ ropPSxxQ_imm(codeblock_t *block, ir_data_t *ir, UNUSED(uint8_t opcode), uint32_t return 0; } + uop_LOAD_FUNC_ARG_IMM(ir, 0, (uintptr_t)__func__); uop_CALL_FUNC(ir, codegen_print_mmx); codegen_mark_code_present(block, cs + op_pc + 1, 1); return op_pc + 2;