From 6e621235cc2d1c7912ac4e2e34913d19d58a32d8 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Sun, 30 Apr 2006 23:37:32 +0000 Subject: [PATCH] Don't use the bits VexArchInfo.hwcaps to distinguish ppc32 and ppc64, since that doesn't work properly. Instead pass the guest arch around too. Small change with lots of associated plumbing. git-svn-id: svn://svn.valgrind.org/vex/trunk@1605 --- VEX/priv/guest-amd64/gdefs.h | 1 + VEX/priv/guest-amd64/toIR.c | 2 ++ VEX/priv/guest-generic/bb_to_IR.c | 2 ++ VEX/priv/guest-generic/bb_to_IR.h | 2 ++ VEX/priv/guest-ppc/gdefs.h | 1 + VEX/priv/guest-ppc/toIR.c | 27 +++++++++++---------------- VEX/priv/guest-x86/gdefs.h | 1 + VEX/priv/guest-x86/toIR.c | 2 ++ VEX/priv/main/vex_main.c | 1 + 9 files changed, 23 insertions(+), 16 deletions(-) diff --git a/VEX/priv/guest-amd64/gdefs.h b/VEX/priv/guest-amd64/gdefs.h index cae514240d..0a0d0a9574 100644 --- a/VEX/priv/guest-amd64/gdefs.h +++ b/VEX/priv/guest-amd64/gdefs.h @@ -64,6 +64,7 @@ DisResult disInstr_AMD64 ( IRBB* irbb, UChar* guest_code, Long delta, Addr64 guest_IP, + VexArch guest_arch, VexArchInfo* archinfo, Bool host_bigendian ); diff --git a/VEX/priv/guest-amd64/toIR.c b/VEX/priv/guest-amd64/toIR.c index d667bbf042..9de659dff3 100644 --- a/VEX/priv/guest-amd64/toIR.c +++ b/VEX/priv/guest-amd64/toIR.c @@ -13833,12 +13833,14 @@ DisResult disInstr_AMD64 ( IRBB* irbb_IN, UChar* guest_code_IN, Long delta, Addr64 guest_IP, + VexArch guest_arch, VexArchInfo* archinfo, Bool host_bigendian_IN ) { DisResult dres; /* Set globals (see top of this file) */ + vassert(guest_arch == VexArchAMD64); guest_code = guest_code_IN; irbb = irbb_IN; host_is_bigendian = host_bigendian_IN; diff --git a/VEX/priv/guest-generic/bb_to_IR.c b/VEX/priv/guest-generic/bb_to_IR.c index ca3d9f9047..9b118fe0ec 100644 --- a/VEX/priv/guest-generic/bb_to_IR.c +++ b/VEX/priv/guest-generic/bb_to_IR.c @@ -99,6 +99,7 @@ IRBB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, /*IN*/ Addr64 guest_IP_bbstart, /*IN*/ Bool (*chase_into_ok)(void*,Addr64), /*IN*/ Bool host_bigendian, + /*IN*/ VexArch arch_guest, /*IN*/ VexArchInfo* archinfo_guest, /*IN*/ IRType guest_word_type, /*IN*/ Bool do_self_check, @@ -231,6 +232,7 @@ IRBB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, guest_code, delta, guest_IP_curr_instr, + arch_guest, archinfo_guest, host_bigendian ); diff --git a/VEX/priv/guest-generic/bb_to_IR.h b/VEX/priv/guest-generic/bb_to_IR.h index 04af2eb4af..391b9cdf11 100644 --- a/VEX/priv/guest-generic/bb_to_IR.h +++ b/VEX/priv/guest-generic/bb_to_IR.h @@ -140,6 +140,7 @@ typedef /*IN*/ Addr64 guest_IP, /* Info about the guest architecture */ + /*IN*/ VexArch guest_arch, /*IN*/ VexArchInfo* archinfo, /* Is the host bigendian? */ @@ -161,6 +162,7 @@ IRBB* bb_to_IR ( /*OUT*/VexGuestExtents* vge, /*IN*/ Addr64 guest_IP_bbstart, /*IN*/ Bool (*chase_into_ok)(void*,Addr64), /*IN*/ Bool host_bigendian, + /*IN*/ VexArch arch_guest, /*IN*/ VexArchInfo* archinfo_guest, /*IN*/ IRType guest_word_type, /*IN*/ Bool do_self_check, diff --git a/VEX/priv/guest-ppc/gdefs.h b/VEX/priv/guest-ppc/gdefs.h index d427f93f40..e3c0bcfa80 100644 --- a/VEX/priv/guest-ppc/gdefs.h +++ b/VEX/priv/guest-ppc/gdefs.h @@ -65,6 +65,7 @@ DisResult disInstr_PPC ( IRBB* irbb, UChar* guest_code, Long delta, Addr64 guest_IP, + VexArch guest_arch, VexArchInfo* archinfo, Bool host_bigendian ); diff --git a/VEX/priv/guest-ppc/toIR.c b/VEX/priv/guest-ppc/toIR.c index dde7adce1c..f19f0a4ddb 100644 --- a/VEX/priv/guest-ppc/toIR.c +++ b/VEX/priv/guest-ppc/toIR.c @@ -9447,38 +9447,33 @@ DisResult disInstr_PPC ( IRBB* irbb_IN, UChar* guest_code_IN, Long delta, Addr64 guest_IP, + VexArch guest_arch, VexArchInfo* archinfo, Bool host_bigendian_IN ) { IRType ty; DisResult dres; - Bool is32, is64; UInt mask32, mask64; UInt hwcaps_guest = archinfo->hwcaps; + vassert(guest_arch == VexArchPPC32 || guest_arch == VexArchPPC64); + /* global -- ick */ - mode64 = False; + mode64 = guest_arch == VexArchPPC64; + ty = mode64 ? Ity_I64 : Ity_I32; - /* Figure out whether we're being ppc32 or ppc64 today. */ + /* do some sanity checks */ mask32 = VEX_HWCAPS_PPC32_F | VEX_HWCAPS_PPC32_V | VEX_HWCAPS_PPC32_FX | VEX_HWCAPS_PPC32_GX; - is32 = (hwcaps_guest & mask32) > 0; - mask64 = VEX_HWCAPS_PPC64_V | VEX_HWCAPS_PPC64_FX | VEX_HWCAPS_PPC64_GX; - is64 = (hwcaps_guest & mask64) > 0; - - if (is32 && !is64) - mode64 = False; - else if (is64 && !is32) - mode64 = True; - else - vpanic("distInstr_PPC: illegal subarch"); - - - ty = mode64 ? Ity_I64 : Ity_I32; + if (mode64) { + vassert((hwcaps_guest & mask32) == 0); + } else { + vassert((hwcaps_guest & mask64) == 0); + } /* Set globals (see top of this file) */ guest_code = guest_code_IN; diff --git a/VEX/priv/guest-x86/gdefs.h b/VEX/priv/guest-x86/gdefs.h index 9f84cedff9..e4113ab2d8 100644 --- a/VEX/priv/guest-x86/gdefs.h +++ b/VEX/priv/guest-x86/gdefs.h @@ -64,6 +64,7 @@ DisResult disInstr_X86 ( IRBB* irbb, UChar* guest_code, Long delta, Addr64 guest_IP, + VexArch guest_arch, VexArchInfo* archinfo, Bool host_bigendian ); diff --git a/VEX/priv/guest-x86/toIR.c b/VEX/priv/guest-x86/toIR.c index a337a81610..7532404166 100644 --- a/VEX/priv/guest-x86/toIR.c +++ b/VEX/priv/guest-x86/toIR.c @@ -12689,12 +12689,14 @@ DisResult disInstr_X86 ( IRBB* irbb_IN, UChar* guest_code_IN, Long delta, Addr64 guest_IP, + VexArch guest_arch, VexArchInfo* archinfo, Bool host_bigendian_IN ) { DisResult dres; /* Set globals (see top of this file) */ + vassert(guest_arch == VexArchX86); guest_code = guest_code_IN; irbb = irbb_IN; host_is_bigendian = host_bigendian_IN; diff --git a/VEX/priv/main/vex_main.c b/VEX/priv/main/vex_main.c index a6713f3570..b26fc012f1 100644 --- a/VEX/priv/main/vex_main.c +++ b/VEX/priv/main/vex_main.c @@ -430,6 +430,7 @@ VexTranslateResult LibVEX_Translate ( VexTranslateArgs* vta ) vta->guest_bytes_addr, vta->chase_into_ok, host_is_bigendian, + vta->arch_guest, &vta->archinfo_guest, guest_word_type, vta->do_self_check, -- 2.47.3