doesn't convey any useful meaning to the reader.
Extra sanity check for PutI: check that the .data type to be put'd
matches the stated array element type in the .descr field.
git-svn-id: svn://svn.valgrind.org/vex/trunk@285
/* --------- PUT --------- */
case Ist_Put: {
- IRType ty = typeOfIRExpr(env->type_env, stmt->Ist.Put.expr);
+ 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. */
- X86RI* ri = iselIntExpr_RI(env, stmt->Ist.Put.expr);
+ X86RI* ri = iselIntExpr_RI(env, stmt->Ist.Put.data);
addInstr(env,
X86Instr_Alu32M(
Xalu_MOV,
return;
}
if (ty == Ity_I8 || ty == Ity_I16) {
- HReg r = iselIntExpr_R(env, stmt->Ist.Put.expr);
+ HReg r = iselIntExpr_R(env, stmt->Ist.Put.data);
addInstr(env, X86Instr_Store(
ty==Ity_I8 ? 1 : 2,
r,
IRTemp tmp = stmt->Ist.Tmp.tmp;
IRType ty = typeOfIRTemp(env->type_env, tmp);
if (ty == Ity_I32 || ty == Ity_I16 || ty == Ity_I8) {
- X86RMI* rmi = iselIntExpr_RMI(env, stmt->Ist.Tmp.expr);
+ X86RMI* rmi = iselIntExpr_RMI(env, stmt->Ist.Tmp.data);
HReg dst = lookupIRTemp(env, tmp);
addInstr(env, X86Instr_Alu32R(Xalu_MOV,rmi,dst));
return;
}
if (ty == Ity_I64) {
HReg rHi, rLo, dstHi, dstLo;
- iselIntExpr64(&rHi,&rLo, env, stmt->Ist.Tmp.expr);
+ iselIntExpr64(&rHi,&rLo, env, stmt->Ist.Tmp.data);
lookupIRTemp64( &dstHi, &dstLo, env, tmp);
addInstr(env, mk_MOVsd_RR(rHi,dstHi) );
addInstr(env, mk_MOVsd_RR(rLo,dstLo) );
return;
}
if (ty == Ity_Bit) {
- X86CondCode cond = iselCondCode(env, stmt->Ist.Tmp.expr);
+ X86CondCode cond = iselCondCode(env, stmt->Ist.Tmp.data);
HReg dst = lookupIRTemp(env, tmp);
addInstr(env, X86Instr_Set32(cond, dst));
return;
}
if (ty == Ity_F64) {
HReg dst = lookupIRTemp(env, tmp);
- HReg src = iselDblExpr(env, stmt->Ist.Tmp.expr);
+ HReg src = iselDblExpr(env, stmt->Ist.Tmp.data);
addInstr(env, X86Instr_FpUnary(Xfp_MOV,src,dst));
return;
}
switch (s->tag) {
case Ist_Put:
vex_printf( "PUT(%d) = ", s->Ist.Put.offset);
- ppIRExpr(s->Ist.Put.expr);
+ ppIRExpr(s->Ist.Put.data);
break;
case Ist_PutI:
vex_printf( "PUTI" );
case Ist_Tmp:
ppIRTemp(s->Ist.Tmp.tmp);
vex_printf( " = " );
- ppIRExpr(s->Ist.Tmp.expr);
+ ppIRExpr(s->Ist.Tmp.data);
break;
case Ist_STle:
vex_printf( "STle(");
/* Constructors -- IRStmt */
-IRStmt* IRStmt_Put ( Int off, IRExpr* value ) {
+IRStmt* IRStmt_Put ( Int off, IRExpr* data ) {
IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
s->tag = Ist_Put;
s->Ist.Put.offset = off;
- s->Ist.Put.expr = value;
+ s->Ist.Put.data = data;
return s;
}
IRStmt* IRStmt_PutI ( IRArray* descr, IRExpr* off,
s->Ist.PutI.data = data;
return s;
}
-IRStmt* IRStmt_Tmp ( IRTemp tmp, IRExpr* expr ) {
+IRStmt* IRStmt_Tmp ( IRTemp tmp, IRExpr* data ) {
IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
s->tag = Ist_Tmp;
s->Ist.Tmp.tmp = tmp;
- s->Ist.Tmp.expr = expr;
+ s->Ist.Tmp.data = data;
return s;
}
-IRStmt* IRStmt_STle ( IRExpr* addr, IRExpr* value ) {
+IRStmt* IRStmt_STle ( IRExpr* addr, IRExpr* data ) {
IRStmt* s = LibVEX_Alloc(sizeof(IRStmt));
s->tag = Ist_STle;
s->Ist.STle.addr = addr;
- s->Ist.STle.data = value;
+ s->Ist.STle.data = data;
return s;
}
IRStmt* IRStmt_Dirty ( IRDirty* d )
IRDirty* d;
switch (stmt->tag) {
case Ist_Put:
- useBeforeDef_Expr(bb,stmt,stmt->Ist.Put.expr,def_counts);
+ useBeforeDef_Expr(bb,stmt,stmt->Ist.Put.data,def_counts);
break;
case Ist_PutI:
useBeforeDef_Expr(bb,stmt,stmt->Ist.PutI.off,def_counts);
useBeforeDef_Expr(bb,stmt,stmt->Ist.PutI.data,def_counts);
break;
case Ist_Tmp:
- useBeforeDef_Expr(bb,stmt,stmt->Ist.Tmp.expr,def_counts);
+ useBeforeDef_Expr(bb,stmt,stmt->Ist.Tmp.data,def_counts);
break;
case Ist_STle:
useBeforeDef_Expr(bb,stmt,stmt->Ist.STle.addr,def_counts);
IRTypeEnv* tyenv = bb->tyenv;
switch (stmt->tag) {
case Ist_Put:
- tcExpr( bb, stmt, stmt->Ist.Put.expr, gWordTy );
- if (typeOfIRExpr(tyenv,stmt->Ist.Put.expr) == Ity_Bit)
- sanityCheckFail(bb,stmt,"IRStmt.Put.expr: cannot Put :: Ity_Bit");
+ tcExpr( bb, stmt, stmt->Ist.Put.data, gWordTy );
+ if (typeOfIRExpr(tyenv,stmt->Ist.Put.data) == Ity_Bit)
+ sanityCheckFail(bb,stmt,"IRStmt.Put.data: cannot Put :: Ity_Bit");
break;
case Ist_PutI:
tcExpr( bb, stmt, stmt->Ist.PutI.data, gWordTy );
tcExpr( bb, stmt, stmt->Ist.PutI.off, gWordTy );
if (typeOfIRExpr(tyenv,stmt->Ist.PutI.data) == Ity_Bit)
- sanityCheckFail(bb,stmt,"IRStmt.PutI.expr: cannot PutI :: Ity_Bit");
+ sanityCheckFail(bb,stmt,"IRStmt.PutI.data: cannot PutI :: Ity_Bit");
+ if (typeOfIRExpr(tyenv,stmt->Ist.PutI.data)
+ != stmt->Ist.PutI.descr->elemTy)
+ sanityCheckFail(bb,stmt,"IRStmt.PutI.data: data ty != elem ty");
if (typeOfIRExpr(tyenv,stmt->Ist.PutI.off) != Ity_I32)
sanityCheckFail(bb,stmt,"IRStmt.PutI.off: not :: Ity_I32");
if (!saneIRArray(stmt->Ist.PutI.descr))
sanityCheckFail(bb,stmt,"IRStmt.PutI.descr: invalid descr");
break;
case Ist_Tmp:
- tcExpr( bb, stmt, stmt->Ist.Tmp.expr, gWordTy );
+ tcExpr( bb, stmt, stmt->Ist.Tmp.data, gWordTy );
if (typeOfIRTemp(tyenv, stmt->Ist.Tmp.tmp)
- != typeOfIRExpr(tyenv, stmt->Ist.Tmp.expr))
+ != typeOfIRExpr(tyenv, stmt->Ist.Tmp.data))
sanityCheckFail(bb,stmt,"IRStmt.Put.Tmp: tmp and expr do not match");
break;
case Ist_STle:
IRDirty *d, *d2;
switch (st->tag) {
case Ist_Put:
- e1 = flatten_Expr(bb, st->Ist.Put.expr);
+ e1 = flatten_Expr(bb, st->Ist.Put.data);
addStmtToIRBB(bb, IRStmt_Put(st->Ist.Put.offset, e1));
break;
case Ist_PutI:
e2));
break;
case Ist_Tmp:
- if (isFlat(st->Ist.Tmp.expr)) {
+ if (isFlat(st->Ist.Tmp.data)) {
/* optimisation, to reduce the number of tmp-tmp
copies generated */
addStmtToIRBB(bb, st);
} else {
/* general case, always correct */
- e1 = flatten_Expr(bb, st->Ist.Tmp.expr);
+ e1 = flatten_Expr(bb, st->Ist.Tmp.data);
addStmtToIRBB(bb, IRStmt_Tmp(st->Ist.Tmp.tmp, e1));
}
break;
# endif
if (st->tag == Ist_Put) {
- vassert(isAtom(st->Ist.Put.expr));
+ vassert(isAtom(st->Ist.Put.data));
return IRStmt_Put(
st->Ist.Put.offset,
- fold_Expr(subst_Expr(env, st->Ist.Put.expr))
+ fold_Expr(subst_Expr(env, st->Ist.Put.data))
);
}
}
if (st->tag == Ist_Tmp) {
- /* This is the one place where an expr (st->Ist.Tmp.expr) is
+ /* This is the one place where an expr (st->Ist.Tmp.data) is
allowed to be more than just a constant or a tmp. */
return IRStmt_Tmp(
st->Ist.Tmp.tmp,
- fold_Expr(subst_Expr(env, st->Ist.Tmp.expr))
+ fold_Expr(subst_Expr(env, st->Ist.Tmp.data))
);
}
and not to the output BB. Otherwise, add it to the output
BB. */
- if (st2->tag == Ist_Tmp && st2->Ist.Tmp.expr->tag == Iex_Const) {
+ if (st2->tag == Ist_Tmp && st2->Ist.Tmp.data->tag == Iex_Const) {
/* 't = const' -- add to env.
The pair (IRTemp, IRExpr*) is added. */
addToH64(env, (ULong)(st2->Ist.Tmp.tmp),
- (ULong)(st2->Ist.Tmp.expr) );
+ (ULong)(st2->Ist.Tmp.data) );
}
else
- if (st2->tag == Ist_Tmp && st2->Ist.Tmp.expr->tag == Iex_Tmp) {
+ if (st2->tag == Ist_Tmp && st2->Ist.Tmp.data->tag == Iex_Tmp) {
/* 't1 = t2' -- add to env.
The pair (IRTemp, IRExpr*) is added. */
addToH64(env, (ULong)(st2->Ist.Tmp.tmp),
- (ULong)(st2->Ist.Tmp.expr) );
+ (ULong)(st2->Ist.Tmp.data) );
}
else {
/* Not interesting, copy st2 into the output block. */
addUses_Expr(set, st->Ist.PutI.data);
return;
case Ist_Tmp:
- addUses_Expr(set, st->Ist.Tmp.expr);
+ addUses_Expr(set, st->Ist.Tmp.data);
return;
case Ist_Put:
- addUses_Expr(set, st->Ist.Put.expr);
+ addUses_Expr(set, st->Ist.Put.data);
return;
case Ist_STle:
addUses_Expr(set, st->Ist.STle.addr);
/* Deal with Gets */
if (st->tag == Ist_Tmp
- && st->Ist.Tmp.expr->tag == Iex_Get) {
+ && st->Ist.Tmp.data->tag == Iex_Get) {
/* st is 't = Get(...)'. Look up in the environment and see
if the Get can be replaced. */
- IRExpr* get = st->Ist.Tmp.expr;
+ IRExpr* get = st->Ist.Tmp.data;
key = (ULong)mk_key_GetPut( get->Iex.Get.offset,
get->Iex.Get.ty );
if (lookupH64(env, &val, (ULong)key)) {
case Ist_Put:
isPut = True;
key = mk_key_GetPut( st->Ist.Put.offset,
- typeOfIRExpr(bb->tyenv,st->Ist.Put.expr) );
+ typeOfIRExpr(bb->tyenv,st->Ist.Put.data) );
break;
case Ist_PutI:
isPut = True;
/* add this one to the env, if appropriate */
if (st->tag == Ist_Put) {
- vassert(isAtom(st->Ist.Put.expr));
- addToH64( env, (ULong)key, (ULong)(st->Ist.Put.expr));
+ vassert(isAtom(st->Ist.Put.data));
+ addToH64( env, (ULong)key, (ULong)(st->Ist.Put.data));
}
} /* for (i = 0; i < bb->stmts_used; i++) */
/* This is the only interesting case. Deal with Gets in the RHS
expression. */
case Ist_Tmp:
- e = st->Ist.Tmp.expr;
+ e = st->Ist.Tmp.data;
switch (e->tag) {
case Iex_Get:
isGet = True;
case Ist_Put:
isPut = True;
key = mk_key_GetPut( st->Ist.Put.offset,
- typeOfIRExpr(bb->tyenv,st->Ist.Put.expr) );
- vassert(isAtom(st->Ist.Put.expr));
+ typeOfIRExpr(bb->tyenv,st->Ist.Put.data) );
+ vassert(isAtom(st->Ist.Put.data));
break;
case Ist_PutI:
isPut = True;
if (!st
|| st->tag != Ist_Tmp
- || st->Ist.Tmp.expr->tag != Iex_CCall)
+ || st->Ist.Tmp.data->tag != Iex_CCall)
continue;
- ex = (*specHelper)( st->Ist.Tmp.expr->Iex.CCall.name,
- st->Ist.Tmp.expr->Iex.CCall.args );
+ ex = (*specHelper)( st->Ist.Tmp.data->Iex.CCall.name,
+ st->Ist.Tmp.data->Iex.CCall.args );
if (!ex)
/* the front end can't think of a suitable replacement */
continue;
if (0) {
vex_printf("SPEC: ");
- ppIRExpr(st->Ist.Tmp.expr);
+ ppIRExpr(st->Ist.Tmp.data);
vex_printf(" --> ");
ppIRExpr(ex);
vex_printf("\n");
IRDirty* d;
switch (st->tag) {
case Ist_Tmp:
- occCount_Expr(env, st->Ist.Tmp.expr);
+ occCount_Expr(env, st->Ist.Tmp.data);
return;
case Ist_Put:
- occCount_Expr(env, st->Ist.Put.expr);
+ occCount_Expr(env, st->Ist.Put.data);
return;
case Ist_PutI:
occCount_Expr(env, st->Ist.PutI.off);
case Ist_Tmp:
return IRStmt_Tmp(
st->Ist.Tmp.tmp,
- tbSubst_Expr(env, st->Ist.Tmp.expr)
+ tbSubst_Expr(env, st->Ist.Tmp.data)
);
case Ist_Put:
return IRStmt_Put(
st->Ist.Put.offset,
- tbSubst_Expr(env, st->Ist.Put.expr)
+ tbSubst_Expr(env, st->Ist.Put.data)
);
case Ist_PutI:
return IRStmt_PutI(
ti = (TmpInfo*)res;
if (ti->occ == 1) {
/* ok, we have 't = E', occ(t)==1. Do the abovementioned actions. */
- IRExpr* e = st->Ist.Tmp.expr;
+ IRExpr* e = st->Ist.Tmp.data;
IRExpr* e2 = tbSubst_Expr(env, e);
ti->expr = e2;
ti->eDoesLoad = ti->eDoesGet = False;
continue;
t = st->Ist.Tmp.tmp;
- eprime = irExpr_to_AvailExpr(st->Ist.Tmp.expr);
+ eprime = irExpr_to_AvailExpr(st->Ist.Tmp.data);
/* ignore if not of AvailExpr form */
if (!eprime)
continue;
case Ist_PutI:
return True;
case Ist_Tmp:
- if (st->Ist.Tmp.expr->tag == Iex_GetI)
+ if (st->Ist.Tmp.data->tag == Iex_GetI)
return True;
break;
case Ist_Put:
- vassert(isAtom(st->Ist.Put.expr));
+ vassert(isAtom(st->Ist.Put.data));
break;
case Ist_STle:
vassert(isAtom(st->Ist.STle.addr));
union {
struct {
Int offset;
- IRExpr* expr;
+ IRExpr* data;
} Put;
struct {
IRArray* descr;
} PutI;
struct {
IRTemp tmp;
- IRExpr* expr;
+ IRExpr* data;
} Tmp;
struct {
IRExpr* addr;
}
IRStmt;
-extern IRStmt* IRStmt_Put ( Int off, IRExpr* value );
+extern IRStmt* IRStmt_Put ( Int off, IRExpr* data );
extern IRStmt* IRStmt_PutI ( IRArray* descr, IRExpr* off, Int bias,
IRExpr* data );
-extern IRStmt* IRStmt_Tmp ( IRTemp tmp, IRExpr* expr );
-extern IRStmt* IRStmt_STle ( IRExpr* addr, IRExpr* value );
+extern IRStmt* IRStmt_Tmp ( IRTemp tmp, IRExpr* data );
+extern IRStmt* IRStmt_STle ( IRExpr* addr, IRExpr* data );
extern IRStmt* IRStmt_Dirty ( IRDirty* details );
extern IRStmt* IRStmt_Exit ( IRExpr* cond, IRConst* dst );