Author: iraisr
Date: Mon Mar 27 20:44:33 2017
New Revision: 3332
Log:
Progress further with a next iteration where we have only single global
type environment.
Modified:
branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c
branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c
branches/VEX_JIT_HACKS/priv/host_x86_isel.c
branches/VEX_JIT_HACKS/priv/ir_defs.c
branches/VEX_JIT_HACKS/priv/ir_inject.c
branches/VEX_JIT_HACKS/priv/ir_opt.c
branches/VEX_JIT_HACKS/pub/libvex_ir.h
Modified: branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c (original)
+++ branches/VEX_JIT_HACKS/priv/guest_generic_bb_to_IR.c Mon Mar 27 20:44:33 2017
@@ -668,8 +668,8 @@
the area of guest code to invalidate should we exit with a
self-check failure. */
- tistart_tmp = newIRTemp(irsb->stmts->tyenv, guest_word_type);
- tilen_tmp = newIRTemp(irsb->stmts->tyenv, guest_word_type);
+ tistart_tmp = newIRTemp(irsb->tyenv, irsb->stmts, guest_word_type);
+ tilen_tmp = newIRTemp(irsb->tyenv, irsb->stmts, guest_word_type);
IRConst* base2check_IRConst
= guest_word_type==Ity_I32 ? IRConst_U32(toUInt(base2check))
Modified: branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c (original)
+++ branches/VEX_JIT_HACKS/priv/guest_x86_toIR.c Mon Mar 27 20:44:33 2017
@@ -316,11 +316,12 @@
addStmtToIRStmtVec(irsb->stmts, st);
}
-/* Generate a new temporary of the given type. */
+/* Generate a new temporary of the given type.
+ Works only for the main IRStmtVec #0. */
static IRTemp newTemp ( IRType ty )
{
vassert(isPlausibleIRType(ty));
- return newIRTemp(irsb->stmts->tyenv, ty);
+ return newIRTemp(irsb->tyenv, irsb->stmts, ty);
}
/* Various simple conversions */
@@ -548,7 +549,7 @@
/* Ditto, but write to a reg instead. */
static void putIReg ( Int sz, UInt archreg, IRExpr* e )
{
- IRType ty = typeOfIRExpr(irsb->stmts, e);
+ IRType ty = typeOfIRExpr(irsb->tyenv, e);
switch (sz) {
case 1: vassert(ty == Ity_I8); break;
case 2: vassert(ty == Ity_I16); break;
@@ -566,7 +567,7 @@
static void putSReg ( UInt sreg, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_I16);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_I16);
stmt( IRStmt_Put( segmentGuestRegOffset(sreg), e ) );
}
@@ -597,37 +598,37 @@
static void putXMMReg ( UInt xmmreg, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_V128);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_V128);
stmt( IRStmt_Put( xmmGuestRegOffset(xmmreg), e ) );
}
static void putXMMRegLane64 ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_I64);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_I64);
stmt( IRStmt_Put( xmmGuestRegLane64offset(xmmreg,laneno), e ) );
}
static void putXMMRegLane64F ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_F64);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_F64);
stmt( IRStmt_Put( xmmGuestRegLane64offset(xmmreg,laneno), e ) );
}
static void putXMMRegLane32F ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_F32);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_F32);
stmt( IRStmt_Put( xmmGuestRegLane32offset(xmmreg,laneno), e ) );
}
static void putXMMRegLane32 ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_I32);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_I32);
stmt( IRStmt_Put( xmmGuestRegLane32offset(xmmreg,laneno), e ) );
}
static void putXMMRegLane16 ( UInt xmmreg, Int laneno, IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_I16);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_I16);
stmt( IRStmt_Put( xmmGuestRegLane16offset(xmmreg,laneno), e ) );
}
@@ -735,8 +736,8 @@
static IRExpr* mkAnd1 ( IRExpr* x, IRExpr* y )
{
- vassert(typeOfIRExpr(irsb->stmts, x) == Ity_I1);
- vassert(typeOfIRExpr(irsb->stmts, y) == Ity_I1);
+ vassert(typeOfIRExpr(irsb->tyenv, x) == Ity_I1);
+ vassert(typeOfIRExpr(irsb->tyenv, y) == Ity_I1);
return unop(Iop_32to1,
binop(Iop_And32,
unop(Iop_1Uto32,x),
@@ -753,14 +754,14 @@
Addr32 restart_point )
{
IRCAS* cas;
- IRType tyE = typeOfIRExpr(irsb->stmts, expVal);
- IRType tyN = typeOfIRExpr(irsb->stmts, newVal);
+ IRType tyE = typeOfIRExpr(irsb->tyenv, expVal);
+ IRType tyN = typeOfIRExpr(irsb->tyenv, newVal);
IRTemp oldTmp = newTemp(tyE);
IRTemp expTmp = newTemp(tyE);
vassert(tyE == tyN);
vassert(tyE == Ity_I32 || tyE == Ity_I16 || tyE == Ity_I8);
assign(expTmp, expVal);
- cas = mkIRCAS(IRTemp_INVALID(), oldTmp, Iend_LE, addr,
+ cas = mkIRCAS(IRTemp_INVALID, oldTmp, Iend_LE, addr,
NULL, mkexpr(expTmp), NULL, newVal);
stmt( IRStmt_CAS(cas) );
stmt( IRStmt_Exit(
@@ -868,7 +869,7 @@
/* U-widen 8/16/32 bit int expr to 32. */
static IRExpr* widenUto32 ( IRExpr* e )
{
- switch (typeOfIRExpr(irsb->stmts, e)) {
+ switch (typeOfIRExpr(irsb->tyenv, e)) {
case Ity_I32: return e;
case Ity_I16: return unop(Iop_16Uto32,e);
case Ity_I8: return unop(Iop_8Uto32,e);
@@ -879,7 +880,7 @@
/* S-widen 8/16/32 bit int expr to 32. */
static IRExpr* widenSto32 ( IRExpr* e )
{
- switch (typeOfIRExpr(irsb->stmts, e)) {
+ switch (typeOfIRExpr(irsb->tyenv, e)) {
case Ity_I32: return e;
case Ity_I16: return unop(Iop_16Sto32,e);
case Ity_I8: return unop(Iop_8Sto32,e);
@@ -891,7 +892,7 @@
of these combinations make sense. */
static IRExpr* narrowTo ( IRType dst_ty, IRExpr* e )
{
- IRType src_ty = typeOfIRExpr(irsb->stmts, e);
+ IRType src_ty = typeOfIRExpr(irsb->tyenv, e);
if (src_ty == dst_ty)
return e;
if (src_ty == Ity_I32 && dst_ty == Ity_I16)
@@ -971,7 +972,7 @@
Int ccOp = ty==Ity_I8 ? 2 : (ty==Ity_I16 ? 1 : 0);
vassert(ty == Ity_I8 || ty == Ity_I16 || ty == Ity_I32);
- vassert(!isIRTempInvalid(guard));
+ vassert(guard != IRTemp_INVALID);
/* Both kinds of right shifts are handled by the same thunk
operation. */
@@ -1133,7 +1134,7 @@
IROp plus = mkSizedOp(ty, Iop_Add8);
IROp xor = mkSizedOp(ty, Iop_Xor8);
- vassert(typeOfIRTemp(irsb->stmts, tres) == ty);
+ vassert(typeOfIRTemp(irsb->tyenv, tres) == ty);
vassert(sz == 1 || sz == 2 || sz == 4);
thunkOp = sz==4 ? X86G_CC_OP_ADCL
: (sz==2 ? X86G_CC_OP_ADCW : X86G_CC_OP_ADCB);
@@ -1151,12 +1152,12 @@
/* Possibly generate a store of 'tres' to 'taddr'. See comment at
start of this function. */
- if (!isIRTempInvalid(taddr)) {
- if (isIRTempInvalid(texpVal)) {
+ if (taddr != IRTemp_INVALID) {
+ if (texpVal == IRTemp_INVALID) {
vassert(restart_point == 0);
storeLE( mkexpr(taddr), mkexpr(tres) );
} else {
- vassert(typeOfIRTemp(irsb->stmts, texpVal) == ty);
+ vassert(typeOfIRTemp(irsb->tyenv, texpVal) == ty);
/* .. and hence 'texpVal' has the same type as 'tres'. */
casLE( mkexpr(taddr),
mkexpr(texpVal), mkexpr(tres), restart_point );
@@ -1187,7 +1188,7 @@
IROp minus = mkSizedOp(ty, Iop_Sub8);
IROp xor = mkSizedOp(ty, Iop_Xor8);
- vassert(typeOfIRTemp(irsb->stmts, tres) == ty);
+ vassert(typeOfIRTemp(irsb->tyenv, tres) == ty);
vassert(sz == 1 || sz == 2 || sz == 4);
thunkOp = sz==4 ? X86G_CC_OP_SBBL
: (sz==2 ? X86G_CC_OP_SBBW : X86G_CC_OP_SBBB);
@@ -1205,12 +1206,12 @@
/* Possibly generate a store of 'tres' to 'taddr'. See comment at
start of this function. */
- if (!isIRTempInvalid(taddr)) {
- if (isIRTempInvalid(texpVal)) {
+ if (taddr != IRTemp_INVALID) {
+ if (texpVal == IRTemp_INVALID) {
vassert(restart_point == 0);
storeLE( mkexpr(taddr), mkexpr(tres) );
} else {
- vassert(typeOfIRTemp(irsb->stmts, texpVal) == ty);
+ vassert(typeOfIRTemp(irsb->tyenv, texpVal) == ty);
/* .. and hence 'texpVal' has the same type as 'tres'. */
casLE( mkexpr(taddr),
mkexpr(texpVal), mkexpr(tres), restart_point );
@@ -1838,7 +1839,7 @@
IRTemp src = newTemp(ty);
IRTemp dst0 = newTemp(ty);
UChar rm = getUChar(delta0);
- IRTemp addr = IRTemp_INVALID();
+ IRTemp addr = IRTemp_INVALID;
/* addSubCarry == True indicates the intended operation is
add-with-carry or subtract-with-borrow. */
@@ -1861,12 +1862,12 @@
if (addSubCarry && op8 == Iop_Add8) {
helper_ADC( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
putIReg(size, gregOfRM(rm), mkexpr(dst1));
} else
if (addSubCarry && op8 == Iop_Sub8) {
helper_SBB( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
putIReg(size, gregOfRM(rm), mkexpr(dst1));
} else {
assign( dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)) );
@@ -1890,12 +1891,12 @@
if (addSubCarry && op8 == Iop_Add8) {
helper_ADC( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
putIReg(size, gregOfRM(rm), mkexpr(dst1));
} else
if (addSubCarry && op8 == Iop_Sub8) {
helper_SBB( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
putIReg(size, gregOfRM(rm), mkexpr(dst1));
} else {
assign( dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)) );
@@ -1951,7 +1952,7 @@
IRTemp src = newTemp(ty);
IRTemp dst0 = newTemp(ty);
UChar rm = getIByte(delta0);
- IRTemp addr = IRTemp_INVALID();
+ IRTemp addr = IRTemp_INVALID;
/* addSubCarry == True indicates the intended operation is
add-with-carry or subtract-with-borrow. */
@@ -1974,12 +1975,12 @@
if (addSubCarry && op8 == Iop_Add8) {
helper_ADC( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
putIReg(size, eregOfRM(rm), mkexpr(dst1));
} else
if (addSubCarry && op8 == Iop_Sub8) {
helper_SBB( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
putIReg(size, eregOfRM(rm), mkexpr(dst1));
} else {
assign(dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)));
@@ -2011,7 +2012,7 @@
} else {
/* normal store */
helper_ADC( size, dst1, dst0, src,
- /*store*/addr, IRTemp_INVALID(), 0 );
+ /*store*/addr, IRTemp_INVALID, 0 );
}
} else
if (addSubCarry && op8 == Iop_Sub8) {
@@ -2022,7 +2023,7 @@
} else {
/* normal store */
helper_SBB( size, dst1, dst0, src,
- /*store*/addr, IRTemp_INVALID(), 0 );
+ /*store*/addr, IRTemp_INVALID, 0 );
}
} else {
assign(dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)));
@@ -2168,12 +2169,12 @@
else
if (op8 == Iop_Add8 && carrying) {
helper_ADC( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
}
else
if (op8 == Iop_Sub8 && carrying) {
helper_SBB( size, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
}
else
vpanic("dis_op_imm_A(x86,guest)");
@@ -2291,7 +2292,7 @@
IRTemp dst1 = newTemp(ty);
IRTemp src = newTemp(ty);
IRTemp dst0 = newTemp(ty);
- IRTemp addr = IRTemp_INVALID();
+ IRTemp addr = IRTemp_INVALID;
IROp op8 = Iop_INVALID;
UInt mask = sz==1 ? 0xFF : (sz==2 ? 0xFFFF : 0xFFFFFFFF);
@@ -2313,11 +2314,11 @@
if (gregOfRM(modrm) == 2 /* ADC */) {
helper_ADC( sz, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
} else
if (gregOfRM(modrm) == 3 /* SBB */) {
helper_SBB( sz, dst1, dst0, src,
- /*no store*/IRTemp_INVALID(), IRTemp_INVALID(), 0 );
+ /*no store*/IRTemp_INVALID, IRTemp_INVALID, 0 );
} else {
assign(dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)));
if (isAddSub(op8))
@@ -2346,7 +2347,7 @@
} else {
/* normal store */
helper_ADC( sz, dst1, dst0, src,
- /*store*/addr, IRTemp_INVALID(), 0 );
+ /*store*/addr, IRTemp_INVALID, 0 );
}
} else
if (gregOfRM(modrm) == 3 /* SBB */) {
@@ -2357,7 +2358,7 @@
} else {
/* normal store */
helper_SBB( sz, dst1, dst0, src,
- /*store*/addr, IRTemp_INVALID(), 0 );
+ /*store*/addr, IRTemp_INVALID, 0 );
}
} else {
assign(dst1, binop(mkSizedOp(ty,op8), mkexpr(dst0), mkexpr(src)));
@@ -2400,7 +2401,7 @@
IRType ty = szToITy(sz);
IRTemp dst0 = newTemp(ty);
IRTemp dst1 = newTemp(ty);
- IRTemp addr = IRTemp_INVALID();
+ IRTemp addr = IRTemp_INVALID;
*decode_OK = True;
@@ -2638,7 +2639,7 @@
IRType ty = szToITy(sz);
IRTemp t2 = newTemp(Ity_I32);
IRTemp t2m = newTemp(Ity_I32);
- IRTemp t_addr = IRTemp_INVALID();
+ IRTemp t_addr = IRTemp_INVALID;
HChar dis_buf[50];
UInt mask;
@@ -3043,10 +3044,10 @@
Int len;
UChar modrm;
HChar dis_buf[50];
- IRTemp addr = IRTemp_INVALID();
+ IRTemp addr = IRTemp_INVALID;
IRType ty = szToITy(sz);
IRTemp t1 = newTemp(ty);
- IRTemp t2 = IRTemp_INVALID();
+ IRTemp t2 = IRTemp_INVALID;
*decode_OK = True;
@@ -3432,7 +3433,6 @@
mkU32(8 * sizeofIRType(ty)),
unop(Iop_Clz32, mkexpr(src32x))
));
-
IRTemp res = newTemp(ty);
assign(res, narrowTo(ty, mkexpr(res32)));
return res;
@@ -3451,7 +3451,7 @@
static void put_emwarn ( IRExpr* e /* :: Ity_I32 */ )
{
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_I32);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_I32);
stmt( IRStmt_Put( OFFB_EMNOTE, e ) );
}
@@ -3475,7 +3475,7 @@
static void put_ftop ( IRExpr* e )
{
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_I32);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_I32);
stmt( IRStmt_Put( OFFB_FTOP, e ) );
}
@@ -3527,7 +3527,7 @@
static void put_ST_TAG ( Int i, IRExpr* value )
{
IRRegArray* descr;
- vassert(typeOfIRExpr(irsb->stmts, value) == Ity_I8);
+ vassert(typeOfIRExpr(irsb->tyenv, value) == Ity_I8);
descr = mkIRRegArray( OFFB_FPTAGS, Ity_I8, 8 );
stmt( IRStmt_PutI( mkIRPutI(descr, get_ftop(), i, value) ) );
}
@@ -3551,7 +3551,7 @@
static void put_ST_UNCHECKED ( Int i, IRExpr* value )
{
IRRegArray* descr;
- vassert(typeOfIRExpr(irsb->stmts, value) == Ity_F64);
+ vassert(typeOfIRExpr(irsb->tyenv, value) == Ity_F64);
descr = mkIRRegArray( OFFB_FPREGS, Ity_F64, 8 );
stmt( IRStmt_PutI( mkIRPutI(descr, get_ftop(), i, value) ) );
/* Mark the register as in-use. */
@@ -5141,7 +5141,7 @@
case 7: { /* FNSTSW m16 */
IRExpr* sw = get_FPU_sw();
- vassert(typeOfIRExpr(irsb->stmts, sw) == Ity_I16);
+ vassert(typeOfIRExpr(irsb->tyenv, sw) == Ity_I16);
storeLE( mkexpr(addr), sw );
DIP("fnstsw %s\n", dis_buf);
break;
@@ -5543,7 +5543,7 @@
static void putMMXReg ( UInt archreg, IRExpr* e )
{
vassert(archreg < 8);
- vassert(typeOfIRExpr(irsb->stmts, e) == Ity_I64);
+ vassert(typeOfIRExpr(irsb->tyenv, e) == Ity_I64);
stmt( IRStmt_Put( OFFB_FPREGS + 8 * archreg, e ) );
}
@@ -6193,11 +6193,11 @@
IRType ty = szToITy(sz);
IRTemp gsrc = newTemp(ty);
IRTemp esrc = newTemp(ty);
- IRTemp addr = IRTemp_INVALID();
+ IRTemp addr = IRTemp_INVALID;
IRTemp tmpSH = newTemp(Ity_I8);
- IRTemp tmpL = IRTemp_INVALID();
- IRTemp tmpRes = IRTemp_INVALID();
- IRTemp tmpSubSh = IRTemp_INVALID();
+ IRTemp tmpL = IRTemp_INVALID;
+ IRTemp tmpRes = IRTemp_INVALID;
+ IRTemp tmpSubSh = IRTemp_INVALID;
IROp mkpair;
IROp getres;
IROp shift;
@@ -6325,7 +6325,7 @@
t_fetched = t_bitno0 = t_bitno1 = t_bitno2
= t_addr0 = t_addr1 = t_esp
- = t_mask = t_new = IRTemp_INVALID();
+ = t_mask = t_new = IRTemp_INVALID;
t_fetched = newTemp(Ity_I8);
t_new = newTemp(Ity_I8);
@@ -6652,7 +6652,7 @@
IRTemp dest2 = newTemp(ty);
IRTemp acc2 = newTemp(ty);
IRTemp cond = newTemp(Ity_I1);
- IRTemp addr = IRTemp_INVALID();
+ IRTemp addr = IRTemp_INVALID;
UChar rm = getUChar(delta0);
/* There are 3 cases to consider:
@@ -6708,7 +6708,7 @@
assign( src, getIReg(size, gregOfRM(rm)) );
assign( acc, getIReg(size, R_EAX) );
stmt( IRStmt_CAS(
- mkIRCAS( IRTemp_INVALID(), dest, Iend_LE, mkexpr(addr),
+ mkIRCAS( IRTemp_INVALID, dest, Iend_LE, mkexpr(addr),
NULL, mkexpr(acc), NULL, mkexpr(src) )
));
setFlags_DEP1_DEP2(Iop_Sub8, acc, dest, ty);
@@ -7542,7 +7542,7 @@
static void put_sse_roundingmode ( IRExpr* sseround )
{
- vassert(typeOfIRExpr(irsb->stmts, sseround) == Ity_I32);
+ vassert(typeOfIRExpr(irsb->tyenv, sseround) == Ity_I32);
stmt( IRStmt_Put( OFFB_SSEROUND, sseround ) );
}
@@ -7558,10 +7558,10 @@
assign( hi64, unop(Iop_V128HIto64, mkexpr(t128)) );
assign( lo64, unop(Iop_V128to64, mkexpr(t128)) );
- vassert(t0 && isIRTempInvalid(*t0));
- vassert(t1 && isIRTempInvalid(*t1));
- vassert(t2 && isIRTempInvalid(*t2));
- vassert(t3 && isIRTempInvalid(*t3));
+ vassert(t0 && *t0 == IRTemp_INVALID);
+ vassert(t1 && *t1 == IRTemp_INVALID);
+ vassert(t2 && *t2 == IRTemp_INVALID);
+ vassert(t3 && *t3 == IRTemp_INVALID);
*t0 = newTemp(Ity_I32);
*t1 = newTemp(Ity_I32);
@@ -7597,10 +7597,10 @@
assign( hi32, unop(Iop_64HIto32, mkexpr(t64)) );
assign( lo32, unop(Iop_64to32, mkexpr(t64)) );
- vassert(t0 && isIRTempInvalid(*t0));
- vassert(t1 && isIRTempInvalid(*t1));
- vassert(t2 && isIRTempInvalid(*t2));
- vassert(t3 && isIRTempInvalid(*t3));
+ vassert(t0 && *t0 == IRTemp_INVALID);
+ vassert(t1 && *t1 == IRTemp_INVALID);
+ vassert(t2 && *t2 == IRTemp_INVALID);
+ vassert(t3 && *t3 == IRTemp_INVALID);
*t0 = newTemp(Ity_I16);
*t1 = newTemp(Ity_I16);
@@ -7642,7 +7642,7 @@
Bool emit_AC_emwarn,
Addr32 next_insn_EIP )
{
- vassert(typeOfIRTemp(irsb->stmts,t1) == Ity_I32);
+ vassert(typeOfIRTemp(irsb->tyenv,t1) == Ity_I32);
/* t1 is the flag word. Mask out everything except OSZACP and set
the flags thunk to X86G_CC_OP_COPY. */
@@ -8116,7 +8116,7 @@
*expect_CAS = False;
- addr = t0 = t1 = t2 = t3 = t4 = t5 = t6 = IRTemp_INVALID();
+ addr = t0 = t1 = t2 = t3 = t4 = t5 = t6 = IRTemp_INVALID;
vassert(guest_EIP_bbstart + delta == guest_EIP_curr_instr);
DIP("\t0x%x: ", guest_EIP_bbstart+delta);
@@ -9044,7 +9044,7 @@
if (sz == 4 && insn[0] == 0x0F && insn[1] == 0x70) {
Int order;
IRTemp sV, dV, s3, s2, s1, s0;
- s3 = s2 = s1 = s0 = IRTemp_INVALID();
+ s3 = s2 = s1 = s0 = IRTemp_INVALID;
sV = newTemp(Ity_I64);
dV = newTemp(Ity_I64);
do_MMX_preamble();
@@ -9395,7 +9395,7 @@
IRTemp s3, s2, s1, s0, d3, d2, d1, d0;
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
- s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID();
+ s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID;
modrm = insn[2];
assign( dV, getXMMReg(gregOfRM(modrm)) );
@@ -9496,7 +9496,7 @@
Bool hi = toBool(insn[1] == 0x15);
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
- s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID();
+ s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID;
modrm = insn[2];
assign( dV, getXMMReg(gregOfRM(modrm)) );
@@ -11155,7 +11155,7 @@
IRTemp s3, s2, s1, s0, d3, d2, d1, d0;
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
- s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID();
+ s3 = s2 = s1 = s0 = d3 = d2 = d1 = d0 = IRTemp_INVALID;
t1 = newTemp(Ity_I64);
t0 = newTemp(Ity_I64);
modrm = insn[2];
@@ -11241,7 +11241,7 @@
if (sz == 2 && insn[0] == 0x0F && insn[1] == 0x70) {
Int order;
IRTemp sV, dV, s3, s2, s1, s0;
- s3 = s2 = s1 = s0 = IRTemp_INVALID();
+ s3 = s2 = s1 = s0 = IRTemp_INVALID;
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
modrm = insn[2];
@@ -11279,7 +11279,7 @@
if (insn[0] == 0xF3 && insn[1] == 0x0F && insn[2] == 0x70) {
Int order;
IRTemp sVhi, dVhi, sV, dV, s3, s2, s1, s0;
- s3 = s2 = s1 = s0 = IRTemp_INVALID();
+ s3 = s2 = s1 = s0 = IRTemp_INVALID;
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
sVhi = newTemp(Ity_I64);
@@ -11323,7 +11323,7 @@
if (insn[0] == 0xF2 && insn[1] == 0x0F && insn[2] == 0x70) {
Int order;
IRTemp sVlo, dVlo, sV, dV, s3, s2, s1, s0;
- s3 = s2 = s1 = s0 = IRTemp_INVALID();
+ s3 = s2 = s1 = s0 = IRTemp_INVALID;
sV = newTemp(Ity_V128);
dV = newTemp(Ity_V128);
sVlo = newTemp(Ity_I64);
@@ -11800,7 +11800,7 @@
IRTemp s3, s2, s1, s0;
IRTemp sV = newTemp(Ity_V128);
Bool isH = insn[2] == 0x16;
- s3 = s2 = s1 = s0 = IRTemp_INVALID();
+ s3 = s2 = s1 = s0 = IRTemp_INVALID;
modrm = insn[3];
if (epartIsReg(modrm)) {
@@ -11859,7 +11859,7 @@
IRTemp addV = newTemp(Ity_V128);
IRTemp subV = newTemp(Ity_V128);
IRTemp rm = newTemp(Ity_I32);
- a3 = a2 = a1 = a0 = s3 = s2 = s1 = s0 = IRTemp_INVALID();
+ a3 = a2 = a1 = a0 = s3 = s2 = s1 = s0 = IRTemp_INVALID;
modrm = insn[3];
if (epartIsReg(modrm)) {
@@ -11938,7 +11938,7 @@
IRTemp rm = newTemp(Ity_I32);
Bool isAdd = insn[2] == 0x7C;
const HChar* str = isAdd ? "add" : "sub";
- e3 = e2 = e1 = e0 = g3 = g2 = g1 = g0 = IRTemp_INVALID();
+ e3 = e2 = e1 = e0 = g3 = g2 = g1 = g0 = IRTemp_INVALID;
modrm = insn[3];
if (epartIsReg(modrm)) {
Modified: branches/VEX_JIT_HACKS/priv/host_x86_isel.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/host_x86_isel.c (original)
+++ branches/VEX_JIT_HACKS/priv/host_x86_isel.c Mon Mar 27 20:44:33 2017
@@ -172,6 +172,7 @@
typedef
struct {
/* Constant -- are set at the start and do not change. */
+ IRTypeEnv* type_env;
IRStmtVec* stmts;
HReg* vregmap;
@@ -192,20 +193,18 @@
static HReg lookupIRTemp ( ISelEnv* env, IRTemp tmp )
{
- vassert(tmp.id == 0); // TODO-JIT: assume now only IRTypeEnv ID #0
- vassert(tmp.index >= 0);
- vassert(tmp.index < env->n_vregmap);
- return env->vregmap[tmp.index];
+ vassert(tmp >= 0);
+ vassert(tmp < env->n_vregmap);
+ return env->vregmap[tmp];
}
static void lookupIRTemp64 ( HReg* vrHI, HReg* vrLO, ISelEnv* env, IRTemp tmp )
{
- vassert(tmp.id == 0); // TODO-JIT: assume now only IRTypeEnv ID #0
- vassert(tmp.index >= 0);
- vassert(tmp.index < env->n_vregmap);
- vassert(! hregIsInvalid(env->vregmapHI[tmp.index]));
- *vrLO = env->vregmap[tmp.index];
- *vrHI = env->vregmapHI[tmp.index];
+ vassert(tmp >= 0);
+ vassert(tmp < env->n_vregmap);
+ vassert(! hregIsInvalid(env->vregmapHI[tmp]));
+ *vrLO = env->vregmap[tmp];
+ *vrHI = env->vregmapHI[tmp];
}
static void addInstr ( ISelEnv* env, X86Instr* instr )
@@ -359,7 +358,7 @@
return 1;
}
/* Else it's a "normal" expression. */
- IRType arg_ty = typeOfIRExpr(env->stmts, arg);
+ IRType arg_ty = typeOfIRExpr(env->type_env, arg);
if (arg_ty == Ity_I32) {
addInstr(env, X86Instr_Push(iselIntExpr_RMI(env, arg)));
return 1;
@@ -593,7 +592,7 @@
else if (UNLIKELY(arg->tag == Iex_GSPTR)) {
vassert(0); //ATC
} else {
- vassert(typeOfIRExpr(env->stmts, arg) == Ity_I32);
+ vassert(typeOfIRExpr(env->type_env, arg) == Ity_I32);
tmpregs[argreg] = iselIntExpr_R(env, arg);
}
not_done_yet--;
@@ -620,7 +619,7 @@
else if (UNLIKELY(arg->tag == Iex_GSPTR)) {
vassert(0); //ATC
} else {
- vassert(typeOfIRExpr(env->stmts, arg) == Ity_I32);
+ vassert(typeOfIRExpr(env->type_env, arg) == Ity_I32);
addInstr(env, X86Instr_Alu32R(Xalu_MOV,
iselIntExpr_RMI(env, arg),
argregs[argreg]));
@@ -854,7 +853,7 @@
{
MatchInfo mi;
- IRType ty = typeOfIRExpr(env->stmts, e);
+ IRType ty = typeOfIRExpr(env->type_env, e);
vassert(ty == Ity_I32 || ty == Ity_I16 || ty == Ity_I8);
switch (e->tag) {
@@ -1495,7 +1494,7 @@
/* --------- MULTIPLEX --------- */
case Iex_ITE: { // VFD
if ((ty == Ity_I32 || ty == Ity_I16 || ty == Ity_I8)
- && typeOfIRExpr(env->stmts, e->Iex.ITE.cond) == Ity_I1) {
+ && typeOfIRExpr(env->type_env, e->Iex.ITE.cond) == Ity_I1) {
HReg r1 = iselIntExpr_R(env, e->Iex.ITE.iftrue);
X86RM* r0 = iselIntExpr_RM(env, e->Iex.ITE.iffalse);
HReg dst = newVRegI(env);
@@ -1558,7 +1557,7 @@
/* DO NOT CALL THIS DIRECTLY ! */
static X86AMode* iselIntExpr_AMode_wrk ( ISelEnv* env, const IRExpr* e )
{
- IRType ty = typeOfIRExpr(env->stmts, e);
+ IRType ty = typeOfIRExpr(env->type_env, e);
vassert(ty == Ity_I32);
/* Add32( Add32(expr1, Shl32(expr2, simm)), imm32 ) */
@@ -1645,7 +1644,7 @@
/* DO NOT CALL THIS DIRECTLY ! */
static X86RMI* iselIntExpr_RMI_wrk ( ISelEnv* env, const IRExpr* e )
{
- IRType ty = typeOfIRExpr(env->stmts, e);
+ IRType ty = typeOfIRExpr(env->type_env, e);
vassert(ty == Ity_I32 || ty == Ity_I16 || ty == Ity_I8);
/* special case: immediate */
@@ -1705,7 +1704,7 @@
/* DO NOT CALL THIS DIRECTLY ! */
static X86RI* iselIntExpr_RI_wrk ( ISelEnv* env, const IRExpr* e )
{
- IRType ty = typeOfIRExpr(env->stmts, e);
+ IRType ty = typeOfIRExpr(env->type_env, e);
vassert(ty == Ity_I32 || ty == Ity_I16 || ty == Ity_I8);
/* special case: immediate */
@@ -1753,7 +1752,7 @@
/* DO NOT CALL THIS DIRECTLY ! */
static X86RM* iselIntExpr_RM_wrk ( ISelEnv* env, const IRExpr* e )
{
- IRType ty = typeOfIRExpr(env->stmts, e);
+ IRType ty = typeOfIRExpr(env->type_env, e);
vassert(ty == Ity_I32 || ty == Ity_I16 || ty == Ity_I8);
/* special case: 32-bit GET */
@@ -1790,7 +1789,7 @@
MatchInfo mi;
vassert(e);
- vassert(typeOfIRExpr(env->stmts, e) == Ity_I1);
+ vassert(typeOfIRExpr(env->type_env, e) == Ity_I1);
/* var */
if (e->tag == Iex_RdTmp) {
@@ -2091,7 +2090,7 @@
MatchInfo mi;
HWord fn = 0; /* helper fn for most SIMD64 stuff */
vassert(e);
- vassert(typeOfIRExpr(env->stmts, e) == Ity_I64);
+ vassert(typeOfIRExpr(env->type_env, e) == Ity_I64);
/* 64-bit literal */
if (e->tag == Iex_Const) {
@@ -2889,7 +2888,7 @@
/* DO NOT CALL THIS DIRECTLY */
static HReg iselFltExpr_wrk ( ISelEnv* env, const IRExpr* e )
{
- IRType ty = typeOfIRExpr(env->stmts, e);
+ IRType ty = typeOfIRExpr(env->type_env, e);
vassert(ty == Ity_F32);
if (e->tag == Iex_RdTmp) {
@@ -3006,7 +3005,7 @@
/* DO NOT CALL THIS DIRECTLY */
static HReg iselDblExpr_wrk ( ISelEnv* env, const IRExpr* e )
{
- IRType ty = typeOfIRExpr(env->stmts, e);
+ IRType ty = typeOfIRExpr(env->type_env, e);
vassert(e);
vassert(ty == Ity_F64);
@@ -3223,7 +3222,7 @@
/* --------- MULTIPLEX --------- */
if (e->tag == Iex_ITE) { // VFD
if (ty == Ity_F64
- && typeOfIRExpr(env->stmts, e->Iex.ITE.cond) == Ity_I1) {
+ && typeOfIRExpr(env->type_env, e->Iex.ITE.cond) == Ity_I1) {
HReg r1 = iselDblExpr(env, e->Iex.ITE.iftrue);
HReg r0 = iselDblExpr(env, e->Iex.ITE.iffalse);
HReg dst = newVRegF(env);
@@ -3277,7 +3276,7 @@
MatchInfo mi;
Bool arg1isEReg = False;
X86SseOp op = Xsse_INVALID;
- IRType ty = typeOfIRExpr(env->stmts, e);
+ IRType ty = typeOfIRExpr(env->type_env, e);
vassert(e);
vassert(ty == Ity_V128);
@@ -3873,8 +3872,8 @@
/* --------- STORE --------- */
case Ist_Store: {
- IRType tya = typeOfIRExpr(env->stmts, stmt->Ist.Store.addr);
- IRType tyd = typeOfIRExpr(env->stmts, stmt->Ist.Store.data);
+ IRType tya = typeOfIRExpr(env->type_env, stmt->Ist.Store.addr);
+ IRType tyd = typeOfIRExpr(env->type_env, stmt->Ist.Store.data);
IREndness end = stmt->Ist.Store.end;
if (tya != Ity_I32 || end != Iend_LE)
@@ -3926,7 +3925,7 @@
/* --------- PUT --------- */
case Ist_Put: {
- IRType ty = typeOfIRExpr(env->stmts, stmt->Ist.Put.data);
+ IRType ty = typeOfIRExpr(env->type_env, stmt->Ist.Put.data);
if (ty == Ity_I32) {
/* We're going to write to memory, so compute the RHS into an
X86RI. */
@@ -3989,7 +3988,7 @@
env, puti->descr,
puti->ix, puti->bias );
- IRType ty = typeOfIRExpr(env->stmts, puti->data);
+ IRType ty = typeOfIRExpr(env->type_env, puti->data);
if (ty == Ity_F64) {
HReg val = iselDblExpr(env, puti->data);
addInstr(env, X86Instr_FpLdSt( False/*store*/, 8, val, am ));
@@ -4019,7 +4018,7 @@
/* --------- TMP --------- */
case Ist_WrTmp: {
IRTemp tmp = stmt->Ist.WrTmp.tmp;
- IRType ty = typeOfIRTemp(env->stmts, tmp);
+ IRType ty = typeOfIRTemp(env->type_env, tmp);
/* optimisation: if stmt->Ist.WrTmp.data is Add32(..,..),
compute it into an AMode and then use LEA. This usually
@@ -4091,8 +4090,8 @@
/* Figure out the return type, if any. */
IRType retty = Ity_INVALID;
- if (!isIRTempInvalid(d->tmp))
- retty = typeOfIRTemp(env->stmts, d->tmp);
+ if (d->tmp != IRTemp_INVALID)
+ retty = typeOfIRTemp(env->type_env, d->tmp);
Bool retty_ok = False;
switch (retty) {
@@ -4118,7 +4117,7 @@
switch (retty) {
case Ity_INVALID: {
/* No return value. Nothing to do. */
- vassert(isIRTempInvalid(d->tmp));
+ vassert(d->tmp == IRTemp_INVALID);
vassert(rloc.pri == RLPri_None);
vassert(addToSp == 0);
return;
@@ -4176,11 +4175,11 @@
/* --------- ACAS --------- */
case Ist_CAS:
- if (isIRTempInvalid(stmt->Ist.CAS.details->oldHi)) {
+ if (stmt->Ist.CAS.details->oldHi == IRTemp_INVALID) {
/* "normal" singleton CAS */
UChar sz;
IRCAS* cas = stmt->Ist.CAS.details;
- IRType ty = typeOfIRExpr(env->stmts, cas->dataLo);
+ IRType ty = typeOfIRExpr(env->type_env, cas->dataLo);
/* get: cas->expdLo into %eax, and cas->dataLo into %ebx */
X86AMode* am = iselIntExpr_AMode(env, cas->addr);
HReg rDataLo = iselIntExpr_R(env, cas->dataLo);
@@ -4205,7 +4204,7 @@
} else {
/* double CAS */
IRCAS* cas = stmt->Ist.CAS.details;
- IRType ty = typeOfIRExpr(env->stmts, cas->dataLo);
+ IRType ty = typeOfIRExpr(env->type_env, cas->dataLo);
/* only 32-bit allowed in this case */
/* get: cas->expdLo into %eax, and cas->dataLo into %ebx */
/* get: cas->expdHi into %edx, and cas->dataHi into %ecx */
@@ -4463,7 +4462,7 @@
/* Make up an IRTemp -> virtual HReg mapping. This doesn't
change as we go along. */
- env->n_vregmap = bb->stmts->tyenv->types_used;
+ env->n_vregmap = bb->tyenv->used;
env->vregmap = LibVEX_Alloc_inline(env->n_vregmap * sizeof(HReg));
env->vregmapHI = LibVEX_Alloc_inline(env->n_vregmap * sizeof(HReg));
@@ -4477,7 +4476,7 @@
j = 0;
for (i = 0; i < env->n_vregmap; i++) {
hregHI = hreg = INVALID_HREG;
- switch (bb->stmts->tyenv->types[i]) {
+ switch (bb->tyenv->types[i]) {
case Ity_I1:
case Ity_I8:
case Ity_I16:
@@ -4487,7 +4486,7 @@
case Ity_F32:
case Ity_F64: hreg = mkHReg(True, HRcFlt64, 0, j++); break;
case Ity_V128: hreg = mkHReg(True, HRcVec128, 0, j++); break;
- default: ppIRType(bb->stmts->tyenv->types[i]);
+ default: ppIRType(bb->tyenv->types[i]);
vpanic("iselBB: IRTemp type");
}
env->vregmap[i] = hreg;
Modified: branches/VEX_JIT_HACKS/priv/ir_defs.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_defs.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_defs.c Mon Mar 27 20:44:33 2017
@@ -3788,6 +3788,13 @@
def_set->set[tmp / sizeof(UChar)] |= mask;
}
+void clearIRTempDefSet(IRTempDefSet* def_set)
+{
+ for (UInt i = 0; i < def_set->slots_used; i++) {
+ def_set->set[i] = 0;
+ }
+}
+
/*---------------------------------------------------------------*/
/*--- Helper functions for the IR -- IR Basic Blocks ---*/
/*---------------------------------------------------------------*/
@@ -3831,16 +3838,11 @@
/*--- Helper functions for the IR -- IR Type Environments ---*/
/*---------------------------------------------------------------*/
-IRTemp newIRTemp(IRTypeEnv* env, IRStmtVec* stmts, IRType ty)
+void ensureSpaceInIRTypeEnv(IRTypeEnv* env, UInt new_size)
{
vassert(env != NULL);
- vassert(stmts != NULL);
- vassert(env->used >= 0);
- vassert(env->size >= 0);
- vassert(env->used <= env->size);
- if (env->used == env->size) {
- UInt new_size = 2 * env->size;
+ if (new_size > env->size) {
IRType* new_types = LibVEX_Alloc_inline(new_size * sizeof(IRType));
IRStmtVecID* new_ids = LibVEX_Alloc_inline(new_size * sizeof(IRStmtVecID));
for (UInt i = 0; i < env->used; i++) {
@@ -3851,6 +3853,19 @@
env->ids = new_ids;
env->size = new_size;
}
+}
+
+IRTemp newIRTemp(IRTypeEnv* env, IRStmtVec* stmts, IRType ty)
+{
+ vassert(env != NULL);
+ vassert(stmts != NULL);
+ vassert(env->used >= 0);
+ vassert(env->size >= 0);
+ vassert(env->used <= env->size);
+
+ if (env->used == env->size) {
+ ensureSpaceInIRTypeEnv(env, 2 * env->size);
+ }
IRTemp tmp = env->used;
env->used += 1;
@@ -5131,7 +5146,7 @@
void sanityCheckIRSB(const IRSB* bb, const HChar* caller, Bool require_flat,
IRType gWordTy)
{
- UInt n_ids = bb->id_seq + 1;
+ UInt n_ids = bb->id_seq;
UInt *id_counts = LibVEX_Alloc_inline(n_ids * sizeof(UInt));
for (UInt i = 0; i < n_ids; i++) {
id_counts[i] = 0;
Modified: branches/VEX_JIT_HACKS/priv/ir_inject.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_inject.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_inject.c Mon Mar 27 20:44:33 2017
@@ -125,13 +125,13 @@
static void
store_aux(IRSB *irsb, IREndness endian, IRExpr *addr, IRExpr *data)
{
- if (typeOfIRExpr(irsb->stmts, data) == Ity_D64) {
+ if (typeOfIRExpr(irsb->tyenv, data) == Ity_D64) {
/* The insn selectors do not support writing a DFP value to memory.
So we need to fix it here by reinterpreting the DFP value as an
integer and storing that. */
data = unop(Iop_ReinterpD64asI64, data);
}
- if (typeOfIRExpr(irsb->stmts, data) == Ity_I1) {
+ if (typeOfIRExpr(irsb->tyenv, data) == Ity_I1) {
/* We cannot store a single bit. So we store it in a 32-bit container.
See also load_aux. */
data = unop(Iop_1Uto32, data);
@@ -158,7 +158,7 @@
vpanic("invalid #bytes for address");
}
- IRType type = typeOfIRExpr(irsb->stmts, data);
+ IRType type = typeOfIRExpr(irsb->tyenv, data);
vassert(type == Ity_I1 || sizeofIRType(type) <= 16);
Modified: branches/VEX_JIT_HACKS/priv/ir_opt.c
==============================================================================
--- branches/VEX_JIT_HACKS/priv/ir_opt.c (original)
+++ branches/VEX_JIT_HACKS/priv/ir_opt.c Mon Mar 27 20:44:33 2017
@@ -282,80 +282,79 @@
the same value, after having appended extra IRTemp assignments to
the end of 'stmts'. */
-static IRExpr* flatten_Expr(IRStmtVec* stmts, IRExpr* ex)
+static IRExpr* flatten_Expr(IRTypeEnv* tyenv, IRStmtVec* stmts, IRExpr* ex)
{
Int i;
IRExpr** newargs;
- IRTypeEnv* tyenv = stmts->tyenv;
- IRType ty = typeOfIRExpr(stmts, ex);
+ IRType ty = typeOfIRExpr(tyenv, ex);
IRTemp t1;
switch (ex->tag) {
case Iex_GetI:
- t1 = newIRTemp(tyenv, ty);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_GetI(ex->Iex.GetI.descr,
- flatten_Expr(stmts, ex->Iex.GetI.ix),
+ flatten_Expr(tyenv, stmts, ex->Iex.GetI.ix),
ex->Iex.GetI.bias)));
return IRExpr_RdTmp(t1);
case Iex_Get:
- t1 = newIRTemp(tyenv, ty);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1, ex));
return IRExpr_RdTmp(t1);
case Iex_Qop: {
IRQop* qop = ex->Iex.Qop.details;
- t1 = newIRTemp(tyenv, ty);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Qop(qop->op,
- flatten_Expr(stmts, qop->arg1),
- flatten_Expr(stmts, qop->arg2),
- flatten_Expr(stmts, qop->arg3),
- flatten_Expr(stmts, qop->arg4))));
+ flatten_Expr(tyenv, stmts, qop->arg1),
+ flatten_Expr(tyenv, stmts, qop->arg2),
+ flatten_Expr(tyenv, stmts, qop->arg3),
+ flatten_Expr(tyenv, stmts, qop->arg4))));
return IRExpr_RdTmp(t1);
}
case Iex_Triop: {
IRTriop* triop = ex->Iex.Triop.details;
- t1 = newIRTemp(tyenv, ty);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Triop(triop->op,
- flatten_Expr(stmts, triop->arg1),
- flatten_Expr(stmts, triop->arg2),
- flatten_Expr(stmts, triop->arg3))));
+ flatten_Expr(tyenv, stmts, triop->arg1),
+ flatten_Expr(tyenv, stmts, triop->arg2),
+ flatten_Expr(tyenv, stmts, triop->arg3))));
return IRExpr_RdTmp(t1);
}
case Iex_Binop:
- t1 = newIRTemp(tyenv, ty);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Binop(ex->Iex.Binop.op,
- flatten_Expr(stmts, ex->Iex.Binop.arg1),
- flatten_Expr(stmts, ex->Iex.Binop.arg2))));
+ flatten_Expr(tyenv, stmts, ex->Iex.Binop.arg1),
+ flatten_Expr(tyenv, stmts, ex->Iex.Binop.arg2))));
return IRExpr_RdTmp(t1);
case Iex_Unop:
- t1 = newIRTemp(tyenv, ty);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Unop(ex->Iex.Unop.op,
- flatten_Expr(stmts, ex->Iex.Unop.arg))));
+ flatten_Expr(tyenv, stmts, ex->Iex.Unop.arg))));
return IRExpr_RdTmp(t1);
case Iex_Load:
- t1 = newIRTemp(tyenv, ty);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Load(ex->Iex.Load.end,
ex->Iex.Load.ty,
- flatten_Expr(stmts, ex->Iex.Load.addr))));
+ flatten_Expr(tyenv, stmts, ex->Iex.Load.addr))));
return IRExpr_RdTmp(t1);
case Iex_CCall:
newargs = shallowCopyIRExprVec(ex->Iex.CCall.args);
for (i = 0; newargs[i]; i++)
- newargs[i] = flatten_Expr(stmts, newargs[i]);
- t1 = newIRTemp(tyenv, ty);
+ newargs[i] = flatten_Expr(tyenv, stmts, newargs[i]);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_CCall(ex->Iex.CCall.cee,
ex->Iex.CCall.retty,
@@ -363,18 +362,18 @@
return IRExpr_RdTmp(t1);
case Iex_ITE:
- t1 = newIRTemp(tyenv, ty);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
- IRExpr_ITE(flatten_Expr(stmts, ex->Iex.ITE.cond),
- flatten_Expr(stmts, ex->Iex.ITE.iftrue),
- flatten_Expr(stmts, ex->Iex.ITE.iffalse))));
+ IRExpr_ITE(flatten_Expr(tyenv, stmts, ex->Iex.ITE.cond),
+ flatten_Expr(tyenv, stmts, ex->Iex.ITE.iftrue),
+ flatten_Expr(tyenv, stmts, ex->Iex.ITE.iffalse))));
return IRExpr_RdTmp(t1);
case Iex_Const:
/* Lift F64i constants out onto temps so they can be CSEd
later. */
if (ex->Iex.Const.con->tag == Ico_F64i) {
- t1 = newIRTemp(tyenv, ty);
+ t1 = newIRTemp(tyenv, stmts, ty);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(t1,
IRExpr_Const(ex->Iex.Const.con)));
return IRExpr_RdTmp(t1);
@@ -394,10 +393,12 @@
}
}
-static IRStmtVec* flatten_IRStmtVec(IRStmtVec* in, IRStmtVec* parent);
+static IRStmtVec* flatten_IRStmtVec(IRTypeEnv* tyenv, IRStmtVec* in,
+ IRStmtVec* parent);
/* Append a completely flattened form of 'st' to the end of 'stmts'. */
-static void flatten_Stmt(IRStmtVec* stmts, IRStmt* st, IRStmtVec* parent)
+static void flatten_Stmt(IRTypeEnv* tyenv, IRStmtVec* stmts, IRStmt* st,
+ IRStmtVec* parent)
{
Int i;
IRExpr *e1, *e2, *e3, *e4, *e5;
@@ -414,14 +415,14 @@
addStmtToIRStmtVec(stmts, st);
} else {
/* general case, always correct */
- e1 = flatten_Expr(stmts, st->Ist.Put.data);
+ e1 = flatten_Expr(tyenv, stmts, st->Ist.Put.data);
addStmtToIRStmtVec(stmts, IRStmt_Put(st->Ist.Put.offset, e1));
}
break;
case Ist_PutI:
puti = st->Ist.PutI.details;
- e1 = flatten_Expr(stmts, puti->ix);
- e2 = flatten_Expr(stmts, puti->data);
+ e1 = flatten_Expr(tyenv, stmts, puti->ix);
+ e2 = flatten_Expr(tyenv, stmts, puti->data);
puti2 = mkIRPutI(puti->descr, e1, puti->bias, e2);
addStmtToIRStmtVec(stmts, IRStmt_PutI(puti2));
break;
@@ -432,45 +433,45 @@
addStmtToIRStmtVec(stmts, st);
} else {
/* general case, always correct */
- e1 = flatten_Expr(stmts, st->Ist.WrTmp.data);
+ e1 = flatten_Expr(tyenv, stmts, st->Ist.WrTmp.data);
addStmtToIRStmtVec(stmts, IRStmt_WrTmp(st->Ist.WrTmp.tmp, e1));
}
break;
case Ist_Store:
- e1 = flatten_Expr(stmts, st->Ist.Store.addr);
- e2 = flatten_Expr(stmts, st->Ist.Store.data);
+ e1 = flatten_Expr(tyenv, stmts, st->Ist.Store.addr);
+ e2 = flatten_Expr(tyenv, stmts, st->Ist.Store.data);
addStmtToIRStmtVec(stmts, IRStmt_Store(st->Ist.Store.end, e1,e2));
break;
case Ist_StoreG:
sg = st->Ist.StoreG.details;
- e1 = flatten_Expr(stmts, sg->addr);
- e2 = flatten_Expr(stmts, sg->data);
- e3 = flatten_Expr(stmts, sg->guard);
+ e1 = flatten_Expr(tyenv, stmts, sg->addr);
+ e2 = flatten_Expr(tyenv, stmts, sg->data);
+ e3 = flatten_Expr(tyenv, stmts, sg->guard);
addStmtToIRStmtVec(stmts, IRStmt_StoreG(sg->end, e1, e2, e3));
break;
case Ist_LoadG:
lg = st->Ist.LoadG.details;
- e1 = flatten_Expr(stmts, lg->addr);
- e2 = flatten_Expr(stmts, lg->alt);
- e3 = flatten_Expr(stmts, lg->guard);
+ e1 = flatten_Expr(tyenv, stmts, lg->addr);
+ e2 = flatten_Expr(tyenv, stmts, lg->alt);
+ e3 = flatten_Expr(tyenv, stmts, lg->guard);
addStmtToIRStmtVec(stmts, IRStmt_LoadG(lg->end, lg->cvt, lg->dst,
e1, e2, e3));
break;
case Ist_CAS:
cas = st->Ist.CAS.details;
- e1 = flatten_Expr(stmts, cas->addr);
- e2 = cas->expdHi ? flatten_Expr(stmts, cas->expdHi) : NULL;
- e3 = flatten_Expr(stmts, cas->expdLo);
- e4 = cas->dataHi ? flatten_Expr(stmts, cas->dataHi) : NULL;
- e5 = flatten_Expr(stmts, cas->dataLo);
+ e1 = flatten_Expr(tyenv, stmts, cas->addr);
+ e2 = cas->expdHi ? flatten_Expr(tyenv, stmts, cas->expdHi) : NULL;
+ e3 = flatten_Expr(tyenv, stmts, cas->expdLo);
+ e4 = cas->dataHi ? flatten_Expr(tyenv, stmts, cas->dataHi) : NULL;
+ e5 = flatten_Expr(tyenv, stmts, cas->dataLo);
cas2 = mkIRCAS( cas->oldHi, cas->oldLo, cas->end,
e1, e2, e3, e4, e5 );
addStmtToIRStmtVec(stmts, IRStmt_CAS(cas2));
break;
case Ist_LLSC:
- e1 = flatten_Expr(stmts, st->Ist.LLSC.addr);
+ e1 = flatten_Expr(tyenv, stmts, st->Ist.LLSC.addr);
e2 = st->Ist.LLSC.storedata
- ? flatten_Expr(stmts, st->Ist.LLSC.storedata)
+ ? flatten_Expr(tyenv, stmts, st->Ist.LLSC.storedata)
: NULL;
addStmtToIRStmtVec(stmts, IRStmt_LLSC(st->Ist.LLSC.end,
st->Ist.LLSC.result, e1, e2));
@@ -481,15 +482,15 @@
*d2 = *d;
d2->args = shallowCopyIRExprVec(d2->args);
if (d2->mFx != Ifx_None) {
- d2->mAddr = flatten_Expr(stmts, d2->mAddr);
+ d2->mAddr = flatten_Expr(tyenv, stmts, d2->mAddr);
} else {
vassert(d2->mAddr == NULL);
}
- d2->guard = flatten_Expr(stmts, d2->guard);
+ d2->guard = flatten_Expr(tyenv, stmts, d2->guard);
for (i = 0; d2->args[i]; i++) {
IRExpr* arg = d2->args[i];
if (LIKELY(!is_IRExpr_VECRET_or_GSPTR(arg)))
- d2->args[i] = flatten_Expr(stmts, arg);
+ d2->args[i] = flatten_Expr(tyenv, stmts, arg);
}
addStmtToIRStmtVec(stmts, IRStmt_Dirty(d2));
break;
@@ -499,22 +500,23 @@
addStmtToIRStmtVec(stmts, st);
break;
case Ist_AbiHint:
- e1 = flatten_Expr(stmts, st->Ist.AbiHint.base);
- e2 = flatten_Expr(stmts, st->Ist.AbiHint.nia);
+ e1 = flatten_Expr(tyenv, stmts, st->Ist.AbiHint.base);
+ e2 = flatten_Expr(tyenv, stmts, st->Ist.AbiHint.nia);
addStmtToIRStmtVec(stmts, IRStmt_AbiHint(e1, st->Ist.AbiHint.len, e2));
break;
case Ist_Exit:
- e1 = flatten_Expr(stmts, st->Ist.Exit.guard);
+ e1 = flatten_Expr(tyenv, stmts, st->Ist.Exit.guard);
addStmtToIRStmtVec(stmts, IRStmt_Exit(e1, st->Ist.Exit.jk,
st->Ist.Exit.dst,
st->Ist.Exit.offsIP));
break;
case Ist_IfThenElse:
- e1 = flatten_Expr(stmts, st->Ist.IfThenElse.cond);
- addStmtToIRStmtVec(stmts, IRStmt_IfThenElse(e1,
- flatten_IRStmtVec(st->Ist.IfThenElse.then_leg, parent),
- flatten_IRStmtVec(st->Ist.IfThenElse.else_leg, parent),
- st->Ist.IfThenElse.phi_nodes));
+ e1 = flatten_Expr(tyenv, stmts, st->Ist.IfThenElse.cond);
+ addStmtToIRStmtVec(
+ stmts, IRStmt_IfThenElse(e1,
+ flatten_IRStmtVec(tyenv, st->Ist.IfThenElse.then_leg, parent),
+ flatten_IRStmtVec(tyenv, st->Ist.IfThenElse.else_leg, parent),
+ st->Ist.IfThenElse.phi_nodes));
break;
default:
vex_printf("\n");
@@ -524,13 +526,15 @@
}
}
-static IRStmtVec* flatten_IRStmtVec(IRStmtVec* in, IRStmtVec* parent)
+static IRStmtVec* flatten_IRStmtVec(IRTypeEnv* tyenv, IRStmtVec* in,
+ IRStmtVec* parent)
{
IRStmtVec* out = emptyIRStmtVec();
- out->tyenv = deepCopyIRTypeEnv(in->tyenv);
out->parent = parent;
+ out->id = in->id;
+ out->def_set = deepCopyIRTempDefSet(in->def_set);
for (UInt i = 0; i < in->stmts_used; i++) {
- flatten_Stmt(out, in->stmts[i], out);
+ flatten_Stmt(tyenv, out, in->stmts[i], out);
}
return out;
}
@@ -538,9 +542,10 @@
static IRSB* flatten_BB ( IRSB* in )
{
IRSB* out = emptyIRSB();
+ out->tyenv = deepCopyIRTypeEnv(in->tyenv);
out->id_seq = in->id_seq;
- out->stmts = flatten_IRStmtVec(in->stmts, NULL);
- out->next = flatten_Expr(out->stmts, in->next);
+ out->stmts = flatten_IRStmtVec(out->tyenv, in->stmts, NULL);
+ out->next = flatten_Expr(out->tyenv, out->stmts, in->next);
out->jumpkind = in->jumpkind;
out->offsIP = in->offsIP;
return out;
@@ -623,7 +628,8 @@
}
}
-static void redundant_get_removal_IRStmtVec(IRStmtVec* stmts)
+static
+void redundant_get_removal_IRStmtVec(const IRTypeEnv* tyenv, IRStmtVec* stmts)
{
HashHW* env = newHHW();
UInt key = 0; /* keep gcc -O happy */
@@ -652,7 +658,7 @@
be to stick in a reinterpret-style cast, although that
would make maintaining flatness more difficult. */
IRExpr* valE = (IRExpr*)val;
- Bool typesOK = toBool( typeOfIRExpr(stmts, valE)
+ Bool typesOK = toBool( typeOfIRExpr(tyenv, valE)
== st->Ist.WrTmp.data->Iex.Get.ty );
if (typesOK && DEBUG_IROPT) {
vex_printf("rGET: "); ppIRExpr(get);
@@ -676,7 +682,7 @@
UInt k_lo, k_hi;
if (st->tag == Ist_Put) {
key = mk_key_GetPut( st->Ist.Put.offset,
- typeOfIRExpr(stmts, st->Ist.Put.data) );
+ typeOfIRExpr(tyenv, st->Ist.Put.data) );
} else {
vassert(st->tag == Ist_PutI);
key = mk_key_GetIPutI( st->Ist.PutI.details->descr );
@@ -714,8 +720,8 @@
if (st->tag == Ist_IfThenElse) {
/* Consider "then" and "else" legs in isolation. */
- redundant_get_removal_IRStmtVec(st->Ist.IfThenElse.then_leg);
- redundant_get_removal_IRStmtVec(st->Ist.IfThenElse.else_leg);
+ redundant_get_removal_IRStmtVec(tyenv, st->Ist.IfThenElse.then_leg);
+ redundant_get_removal_IRStmtVec(tyenv, st->Ist.IfThenElse.else_leg);
}
} /* for (UInt i = 0; i < stmts->stmts_used; i++) */
@@ -723,7 +729,7 @@
static void redundant_get_removal_BB(IRSB* bb)
{
- redundant_get_removal_IRStmtVec(bb->stmts);
+ redundant_get_removal_IRStmtVec(bb->tyenv, bb->stmts);
}
@@ -909,8 +915,8 @@
and loads/stores.
*/
-static void redundant_put_removal_IRStmtVec(
- IRStmtVec* stmts,
+static void redundant_put_removal_IRStmtVec(
+ IRTypeEnv* tyenv, IRStmtVec* stmts,
Bool (*preciseMemExnsFn)(Int,Int,VexRegisterUpdates),
VexRegisterUpdates pxControl,
HashHW* env)
@@ -960,7 +966,7 @@
case Ist_Put:
isPut = True;
key = mk_key_GetPut( st->Ist.Put.offset,
- typeOfIRExpr(stmts, st->Ist.Put.data) );
+ typeOfIRExpr(tyenv, st->Ist.Put.data) );
vassert(isIRAtom(st->Ist.Put.data));
break;
case Ist_PutI:
@@ -1003,9 +1009,9 @@
/* Consider "then" and "else" legs in isolation. They get a new env. */
if (st->tag == Ist_IfThenElse) {
- redundant_put_removal_IRStmtVec(st->Ist.IfThenElse.then_leg,
+ redundant_put_removal_IRStmtVec(tyenv, st->Ist.IfThenElse.then_leg,
preciseMemExnsFn, pxControl, newHHW());
- redundant_put_removal_IRStmtVec(st->Ist.IfThenElse.else_leg,
+ redundant_put_removal_IRStmtVec(tyenv, st->Ist.IfThenElse.else_leg,
preciseMemExnsFn, pxControl, newHHW());
}
}
@@ -1024,10 +1030,11 @@
writes the IP (or, whatever it claims to write. We don't
care.) */
UInt key = mk_key_GetPut(bb->offsIP,
- typeOfIRExpr(bb->stmts, bb->next));
+ typeOfIRExpr(bb->tyenv, bb->next));
addToHHW(env, (HWord)key, 0);
- redundant_put_removal_IRStmtVec(bb->stmts, preciseMemExnsFn, pxControl, env);
+ redundant_put_removal_IRStmtVec(bb->tyenv, bb->stmts, preciseMemExnsFn,
+ pxControl, env);
}
@@ -1067,60 +1074,41 @@
/* The env in this section is a structure which holds:
- A map from IRTemp to IRExpr*, that is, an array indexed by IRTemp.
Keys are IRTemp.indices. Values are IRExpr*s.
- - IRTypeEnv ID
+ - IR Type Environment
- Current IRStmtVec* which is being constructed.
- A pointer to the parent env (or NULL). */
typedef
- struct _FoldEnv {
- IRExpr** map;
- IRTyEnvID id;
- IRStmtVec* stmts;
- struct _FoldEnv* parent;
- }
- FoldEnv;
-
-/* Sets up the constant propagation and folding environment. */
-static FoldEnv* newFoldEnv(IRStmtVec* stmts_in, FoldEnv* parent_env)
+ struct _SubstEnv {
+ IRExpr** map;
+ IRTypeEnv* tyenv;
+ IRStmtVec* stmts;
+ struct _SubstEnv* parent;
+ }
+ SubstEnv;
+
+/* Sets up the substitution environment.
+ Note that the map is established fresh new for every IRStmtVec (which are
+ thus considered in isolation). */
+static SubstEnv* newSubstEnv(IRTypeEnv* tyenv, IRStmtVec* stmts_in,
+ SubstEnv* parent_env)
{
IRStmtVec* stmts_out = emptyIRStmtVec();
- stmts_out->tyenv = deepCopyIRTypeEnv(stmts_in->tyenv);
+ stmts_out->id = stmts_in->id;
stmts_out->parent = (parent_env != NULL) ? parent_env->stmts : NULL;
+ stmts_out->def_set = deepCopyIRTempDefSet(stmts_in->def_set);
- FoldEnv* env = LibVEX_Alloc_inline(sizeof(FoldEnv));
- env->id = stmts_out->tyenv->id;
- env->stmts = stmts_out;
- env->parent = parent_env;
+ SubstEnv* env = LibVEX_Alloc_inline(sizeof(SubstEnv));
+ env->tyenv = tyenv;
+ env->stmts = stmts_out;
+ env->parent = parent_env;
- UInt n_tmps = stmts_out->tyenv->types_used;
+ UInt n_tmps = tyenv->used;
env->map = LibVEX_Alloc_inline(n_tmps * sizeof(IRExpr*));
for (UInt i = 0; i < n_tmps; i++)
env->map[i] = NULL;
return env;
}
-static inline IRExpr* findIRExpr(const FoldEnv* env, IRTemp tmp)
-{
- while (env->id != tmp.id) {
- env = env->parent;
- vassert(env != NULL);
- }
- vassert(env->id == tmp.id);
-
- return env->map[tmp.index];
-}
-
-static void setIRExpr(FoldEnv* env, IRTemp tmp, IRExpr* e)
-{
- while (env->id != tmp.id) {
- env = env->parent;
- vassert(env != NULL);
- }
- vassert(env->id == tmp.id);
-
- vassert(env->map[tmp.index] == NULL);
- env->map[tmp.index] = e;
-}
-
/* Do both expressions compute the same value? The answer is generally
conservative, i.e. it will report that the expressions do not compute
the same value when in fact they do. The reason is that we do not
@@ -1138,11 +1126,11 @@
slower out of line general case. Saves a few insns. */
__attribute__((noinline))
-static Bool sameIRExprs_aux2(const FoldEnv* env, const IRExpr* e1,
+static Bool sameIRExprs_aux2(const SubstEnv* env, const IRExpr* e1,
const IRExpr* e2);
inline
-static Bool sameIRExprs_aux(const FoldEnv* env, const IRExpr* e1,
+static Bool sameIRExprs_aux(const SubstEnv* env, const IRExpr* e1,
const IRExpr* e2)
{
if (e1->tag != e2->tag) return False;
@@ -1150,7 +1138,7 @@
}
__attribute__((noinline))
-static Bool sameIRExprs_aux2(const FoldEnv* env, const IRExpr* e1,
+static Bool sameIRExprs_aux2(const SubstEnv* env, const IRExpr* e1,
const IRExpr* e2)
{
if (num_nodes_visited++ > NODE_LIMIT) return False;
@@ -1160,9 +1148,9 @@
IRTemp tmp1 = e1->Iex.RdTmp.tmp;
IRTemp tmp2 = e2->Iex.RdTmp.tmp;
- if (eqIRTemp(tmp1, tmp2)) return True;
- const IRExpr* subst1 = findIRExpr(env, tmp1);
- const IRExpr* subst2 = findIRExpr(env, tmp2);
+ if (tmp1 == tmp2) return True;
+ const IRExpr* subst1 = env->map[tmp1];
+ const IRExpr* subst2 = env->map[tmp2];
if (subst1 != NULL && subst2 != NULL) {
Bool same = sameIRExprs_aux(env, subst1, subst2);
#if STATS_IROPT
@@ -1233,7 +1221,7 @@
}
inline
-static Bool sameIRExprs(const FoldEnv* env, const IRExpr* e1, const IRExpr* e2)
+static Bool sameIRExprs(const SubstEnv* env, const IRExpr* e1, const IRExpr* e2)
{
Bool same;
@@ -1448,14 +1436,14 @@
return NULL if it can't resolve 'e' to a new expression, which will
be the case if 'e' is instead defined by an IRStmt (IRDirty or
LLSC). */
-static IRExpr* chase(FoldEnv* env, IRExpr* e)
+static IRExpr* chase(SubstEnv* env, IRExpr* e)
{
/* Why is this loop guaranteed to terminate? Because all tmps must
have definitions before use, hence a tmp cannot be bound
(directly or indirectly) to itself. */
while (e->tag == Iex_RdTmp) {
if (0) { vex_printf("chase "); ppIRExpr(e); vex_printf("\n"); }
- e = findIRExpr(env, e->Iex.RdTmp.tmp);
+ e = env->map[e->Iex.RdTmp.tmp];
if (e == NULL) break;
}
return e;
@@ -1467,10 +1455,10 @@
if (e == NULL || e->tag != Iex_RdTmp)
return e;
else
- return env[e->Iex.RdTmp.tmp.index];
+ return env[e->Iex.RdTmp.tmp];
}
-static IRExpr* fold_Expr(FoldEnv* env, IRExpr* e)
+static IRExpr* fold_Expr(SubstEnv* env, IRExpr* e)
{
Int shift;
IRExpr* e2 = e; /* e2 is the result of folding e, if possible */
@@ -2530,11 +2518,11 @@
/* Apply the subst to a simple 1-level expression -- guaranteed to be
1-level due to previous flattening pass. */
-static IRExpr* subst_Expr(FoldEnv* env, IRExpr* ex)
+static IRExpr* subst_Expr(SubstEnv* env, IRExpr* ex)
{
switch (ex->tag) {
case Iex_RdTmp: {
- IRExpr* rhs = findIRExpr(env, ex->Iex.RdTmp.tmp);
+ IRExpr* rhs = env->map[ex->Iex.RdTmp.tmp];
if (rhs != NULL) {
if (rhs->tag == Iex_RdTmp)
return rhs;
@@ -2641,13 +2629,13 @@
}
}
-static IRStmtVec* subst_and_fold_Stmts(FoldEnv* env, IRStmtVec* in);
+static IRStmtVec* subst_and_fold_Stmts(SubstEnv* env, IRStmtVec* in);
/* Apply the...
[truncated message content] |