From da45191d832252a2bd09aec1642fb0b924cc442c Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Thu, 13 Sep 2012 19:33:24 +0000 Subject: [PATCH] Tweak the IR injector so it can handle an immediate operand for shift operations. This is needed for Iop_ShlD64 and the like on powerpc where the shift amount is an immediate field in the insn. Part of fixing bugzilla #305948. git-svn-id: svn://svn.valgrind.org/vex/trunk@2529 --- VEX/priv/ir_inject.c | 11 ++++++++++- VEX/pub/libvex.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/VEX/priv/ir_inject.c b/VEX/priv/ir_inject.c index 1914f4f0fc..092c82ff87 100644 --- a/VEX/priv/ir_inject.c +++ b/VEX/priv/ir_inject.c @@ -35,6 +35,7 @@ #include "main_util.h" /* Convenience macros for readibility */ +#define mkU8(v) IRExpr_Const(IRConst_U8(v)) #define mkU32(v) IRExpr_Const(IRConst_U32(v)) #define mkU64(v) IRExpr_Const(IRConst_U64(v)) #define unop(kind, a) IRExpr_Unop(kind, a) @@ -208,7 +209,15 @@ vex_inject_ir(IRSB *irsb, IREndness endian) case 2: opnd1 = load(endian, iricb.t_opnd1, iricb.opnd1); - opnd2 = load(endian, iricb.t_opnd2, iricb.opnd2); + + if (iricb.shift_amount_is_immediate) { + // This implies that the IROp is a shift op + vassert(iricb.t_opnd2 == Ity_I8); + opnd2 = mkU8(*((Char *)iricb.opnd2)); + } else { + opnd2 = load(endian, iricb.t_opnd2, iricb.opnd2); + } + if (rounding_mode) data = triop(iricb.op, rounding_mode, opnd1, opnd2); else diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 24a14b4c2b..3692770e29 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -775,6 +775,7 @@ typedef IRType t_opnd4; // type of 4th operand UInt rounding_mode; UInt num_operands; // excluding rounding mode, if any + Bool shift_amount_is_immediate; } IRICB; -- 2.47.2