|
From: Florian K. <fk...@so...> - 2025-12-03 22:29:52
|
https://sourceware.org/cgit/valgrind/commit/?id=cd9d7d0d2edeef5ef37582c6d6fa55ca3c3bcccd commit cd9d7d0d2edeef5ef37582c6d6fa55ca3c3bcccd Author: Florian Krohm <fl...@ei...> Date: Wed Dec 3 22:26:57 2025 +0000 Change the data type of libvex_Backend::emit. Both the s390 and arm insn emitters need to know the host's hardware capabilities. Today, these are provided by means of global variables s390_host_hwcaps and arm_hwcaps. To eliminate that kludge the emit function is changed. Instead of passing VexEndness we now pass a pointer to VexArchInfo which provides both the endianess and hardware capabilities. Those global variables will be removed in a followup patch. Diff: --- VEX/priv/host_amd64_defs.c | 2 +- VEX/priv/host_amd64_defs.h | 2 +- VEX/priv/host_arm64_defs.c | 2 +- VEX/priv/host_arm64_defs.h | 2 +- VEX/priv/host_arm_defs.c | 2 +- VEX/priv/host_arm_defs.h | 2 +- VEX/priv/host_mips_defs.c | 2 +- VEX/priv/host_mips_defs.h | 2 +- VEX/priv/host_nanomips_defs.c | 2 +- VEX/priv/host_nanomips_defs.h | 2 +- VEX/priv/host_ppc_defs.c | 3 ++- VEX/priv/host_ppc_defs.h | 2 +- VEX/priv/host_riscv64_defs.c | 2 +- VEX/priv/host_riscv64_defs.h | 2 +- VEX/priv/host_s390_defs.c | 2 +- VEX/priv/host_s390_defs.h | 2 +- VEX/priv/host_x86_defs.c | 2 +- VEX/priv/host_x86_defs.h | 2 +- VEX/priv/main_main.c | 8 ++++---- 19 files changed, 23 insertions(+), 22 deletions(-) diff --git a/VEX/priv/host_amd64_defs.c b/VEX/priv/host_amd64_defs.c index d7d1ab1aad..e834e82536 100644 --- a/VEX/priv/host_amd64_defs.c +++ b/VEX/priv/host_amd64_defs.c @@ -2592,7 +2592,7 @@ static UChar* do_ffree_st ( UChar* p, Int n ) Int emit_AMD64Instr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const AMD64Instr* i, - Bool mode64, VexEndness endness_host, + Bool mode64, const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_amd64_defs.h b/VEX/priv/host_amd64_defs.h index 4c16db17bf..731fd2efd3 100644 --- a/VEX/priv/host_amd64_defs.h +++ b/VEX/priv/host_amd64_defs.h @@ -836,7 +836,7 @@ extern Int emit_AMD64Instr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const AMD64Instr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_arm64_defs.c b/VEX/priv/host_arm64_defs.c index da52748eb9..b00aad94d5 100644 --- a/VEX/priv/host_arm64_defs.c +++ b/VEX/priv/host_arm64_defs.c @@ -3627,7 +3627,7 @@ static UInt* do_load_or_store64 ( UInt* p, Int emit_ARM64Instr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const ARM64Instr* i, - Bool mode64, VexEndness endness_host, + Bool mode64, const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_arm64_defs.h b/VEX/priv/host_arm64_defs.h index 4f5b1bce3e..83bb6a286e 100644 --- a/VEX/priv/host_arm64_defs.h +++ b/VEX/priv/host_arm64_defs.h @@ -1115,7 +1115,7 @@ extern void mapRegs_ARM64Instr ( HRegRemap*, ARM64Instr*, Bool ); extern Int emit_ARM64Instr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const ARM64Instr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo *archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_arm_defs.c b/VEX/priv/host_arm_defs.c index 39d89f7e87..a838565a20 100644 --- a/VEX/priv/host_arm_defs.c +++ b/VEX/priv/host_arm_defs.c @@ -3069,7 +3069,7 @@ static UInt* do_load_or_store32 ( UInt* p, Int emit_ARMInstr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const ARMInstr* i, - Bool mode64, VexEndness endness_host, + Bool mode64, const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_arm_defs.h b/VEX/priv/host_arm_defs.h index 904bd0c43c..d6dbc4ee27 100644 --- a/VEX/priv/host_arm_defs.h +++ b/VEX/priv/host_arm_defs.h @@ -1057,7 +1057,7 @@ extern void mapRegs_ARMInstr ( HRegRemap*, ARMInstr*, Bool ); extern Int emit_ARMInstr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const ARMInstr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_mips_defs.c b/VEX/priv/host_mips_defs.c index ad92c055c9..d018aac841 100644 --- a/VEX/priv/host_mips_defs.c +++ b/VEX/priv/host_mips_defs.c @@ -3768,7 +3768,7 @@ static UChar *mkMoveReg(UChar * p, UInt r_dst, UInt r_src) Int emit_MIPSInstr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const MIPSInstr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_mips_defs.h b/VEX/priv/host_mips_defs.h index 423f68ea09..838368b85c 100644 --- a/VEX/priv/host_mips_defs.h +++ b/VEX/priv/host_mips_defs.h @@ -1006,7 +1006,7 @@ extern void mapRegs_MIPSInstr (HRegRemap *, MIPSInstr *, Bool mode64); extern Int emit_MIPSInstr (/*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const MIPSInstr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_nanomips_defs.c b/VEX/priv/host_nanomips_defs.c index 3e91c904f6..19b4ee0fa4 100644 --- a/VEX/priv/host_nanomips_defs.c +++ b/VEX/priv/host_nanomips_defs.c @@ -1343,7 +1343,7 @@ Int emit_NANOMIPSInstr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const NANOMIPSInstr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_nanomips_defs.h b/VEX/priv/host_nanomips_defs.h index beb8084797..aa40b1e140 100644 --- a/VEX/priv/host_nanomips_defs.h +++ b/VEX/priv/host_nanomips_defs.h @@ -393,7 +393,7 @@ extern Int emit_NANOMIPSInstr (/*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const NANOMIPSInstr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_ppc_defs.c b/VEX/priv/host_ppc_defs.c index dfefcb3fd4..7dc9714572 100644 --- a/VEX/priv/host_ppc_defs.c +++ b/VEX/priv/host_ppc_defs.c @@ -4154,7 +4154,7 @@ static UChar* mkFormVA ( UChar* p, UInt opc1, UInt r1, UInt r2, */ Int emit_PPCInstr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const PPCInstr* i, - Bool mode64, VexEndness endness_host, + Bool mode64, const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, @@ -4167,6 +4167,7 @@ Int emit_PPCInstr ( /*MB_MOD*/Bool* is_profInc, vex_printf("asm ");ppPPCInstr(i, mode64); vex_printf("\n"); } + VexEndness endness_host = archinfo_host->endness; switch (i->tag) { case Pin_LI: diff --git a/VEX/priv/host_ppc_defs.h b/VEX/priv/host_ppc_defs.h index c57afd50b5..df376e21c7 100644 --- a/VEX/priv/host_ppc_defs.h +++ b/VEX/priv/host_ppc_defs.h @@ -1269,7 +1269,7 @@ extern void mapRegs_PPCInstr ( HRegRemap*, PPCInstr* , Bool mode64); extern Int emit_PPCInstr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const PPCInstr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_riscv64_defs.c b/VEX/priv/host_riscv64_defs.c index 152d4ae92c..dcb1a968de 100644 --- a/VEX/priv/host_riscv64_defs.c +++ b/VEX/priv/host_riscv64_defs.c @@ -1774,7 +1774,7 @@ Int emit_RISCV64Instr(/*MB_MOD*/ Bool* is_profInc, Int nbuf, const RISCV64Instr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_riscv64_defs.h b/VEX/priv/host_riscv64_defs.h index 7a97f90ef4..97a8420f79 100644 --- a/VEX/priv/host_riscv64_defs.h +++ b/VEX/priv/host_riscv64_defs.h @@ -612,7 +612,7 @@ Int emit_RISCV64Instr(/*MB_MOD*/ Bool* is_profInc, Int nbuf, const RISCV64Instr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_s390_defs.c b/VEX/priv/host_s390_defs.c index 04b06c4cfe..3479bbc91b 100644 --- a/VEX/priv/host_s390_defs.c +++ b/VEX/priv/host_s390_defs.c @@ -10896,7 +10896,7 @@ s390_insn_vec_replicate_emit(UChar *buf, const s390_insn *insn) Int emit_S390Instr(Bool *is_profinc, UChar *buf, Int nbuf, const s390_insn *insn, - Bool mode64, VexEndness endness_host, + Bool mode64, const VexArchInfo *archinfo, const void *disp_cp_chain_me_to_slowEP, const void *disp_cp_chain_me_to_fastEP, const void *disp_cp_xindir, diff --git a/VEX/priv/host_s390_defs.h b/VEX/priv/host_s390_defs.h index 48ea79f18d..a743abb501 100644 --- a/VEX/priv/host_s390_defs.h +++ b/VEX/priv/host_s390_defs.h @@ -885,7 +885,7 @@ UInt ppHRegS390(HReg); void getRegUsage_S390Instr( HRegUsage *, const s390_insn *, Bool ); void mapRegs_S390Instr ( HRegRemap *, s390_insn *, Bool ); Int emit_S390Instr ( Bool *, UChar *, Int, const s390_insn *, Bool, - VexEndness, const void *, const void *, + const VexArchInfo *, const void *, const void *, const void *, const void *); const RRegUniverse *getRRegUniverse_S390( void ); void genSpill_S390 ( HInstr **, HInstr **, HReg , Int , Bool ); diff --git a/VEX/priv/host_x86_defs.c b/VEX/priv/host_x86_defs.c index 200c122fd8..5b50d8a536 100644 --- a/VEX/priv/host_x86_defs.c +++ b/VEX/priv/host_x86_defs.c @@ -2122,7 +2122,7 @@ static UChar* push_word_from_tags ( UChar* p, UShort tags ) Int emit_X86Instr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const X86Instr* i, - Bool mode64, VexEndness endness_host, + Bool mode64, const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/host_x86_defs.h b/VEX/priv/host_x86_defs.h index ecd74e6a53..65cca18f6f 100644 --- a/VEX/priv/host_x86_defs.h +++ b/VEX/priv/host_x86_defs.h @@ -717,7 +717,7 @@ extern void mapRegs_X86Instr ( HRegRemap*, X86Instr*, Bool ); extern Int emit_X86Instr ( /*MB_MOD*/Bool* is_profInc, UChar* buf, Int nbuf, const X86Instr* i, Bool mode64, - VexEndness endness_host, + const VexArchInfo* archinfo_host, const void* disp_cp_chain_me_to_slowEP, const void* disp_cp_chain_me_to_fastEP, const void* disp_cp_xindir, diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index 32a78190ad..e979952853 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -780,9 +780,9 @@ static void libvex_BackEnd ( const VexTranslateArgs *vta, const VexAbiInfo*, Int, Int, Bool, Bool, Addr ); Int (*emit) ( /*MB_MOD*/Bool*, - UChar*, Int, const HInstr*, Bool, VexEndness, - const void*, const void*, const void*, - const void* ); + UChar*, Int, const HInstr*, Bool, + const VexArchInfo*, const void*, + const void*, const void*, const void* ); Bool (*preciseMemExnsFn) ( Int, Int, VexRegisterUpdates ); const RRegUniverse* rRegUniv = NULL; @@ -1232,7 +1232,7 @@ static void libvex_BackEnd ( const VexTranslateArgs *vta, } j = emit( &hi_isProfInc, insn_bytes, sizeof insn_bytes, hi, - mode64, vta->archinfo_host.endness, + mode64, &vta->archinfo_host, vta->disp_cp_chain_me_to_slowEP, vta->disp_cp_chain_me_to_fastEP, vta->disp_cp_xindir, |