Пример #1
0
void instrument_WrTmp_Mux0X(IRStmt* st, IRSB* sb_out)
{
    IRTemp tmp = st->Ist.WrTmp.tmp;
    IRExpr* data = st->Ist.WrTmp.data;
    IRExpr* cond = data->Iex.Mux0X.cond;
    IRExpr* expr0 = data->Iex.Mux0X.expr0;
    IRExpr* exprX = data->Iex.Mux0X.exprX;
    Int size = sizeofIRType_bits(typeOfIRExpr(sb_out->tyenv, expr0));
    IRDirty* di;

    tl_assert(cond->tag == Iex_RdTmp);
    tl_assert(isIRAtom(expr0));
    tl_assert(isIRAtom(exprX));
    tl_assert(typeOfIRTemp(sb_out->tyenv, tmp) == typeOfIRExpr(sb_out->tyenv, expr0));
    tl_assert(typeOfIRTemp(sb_out->tyenv, tmp) == typeOfIRExpr(sb_out->tyenv, exprX));

    di = unsafeIRDirty_0_N(0,
                           "helper_instrument_WrTmp_Mux0X",
                           VG_(fnptr_to_fnentry)(helper_instrument_WrTmp_Mux0X),
                           mkIRExprVec_5(mkIRExpr_HWord(tmp),
                                         assignNew_HWord(sb_out, cond),
                                         mkIRExpr_HWord((expr0->tag == Iex_RdTmp) ? expr0->Iex.RdTmp.tmp : IRTemp_INVALID),
                                         mkIRExpr_HWord((exprX->tag == Iex_RdTmp) ? exprX->Iex.RdTmp.tmp : IRTemp_INVALID),
                                         mkIRExpr_HWord(size))
                            );
    addStmtToIRSB(sb_out, IRStmt_Dirty(di));
}
Пример #2
0
void AddBinopHelper(IRSB* sb,IRStmt* st)
{
  IROp op;
  IRDirty* d1;
  IRDirty* d2;
  IRExpr* arg1;
  IRExpr* arg2;
  HWord lhs,tmpname;
//  HWord cur_ctr = (HWord)counter;

  vassert(st->tag = Ist_WrTmp);
  op = (HWord)st->Ist.WrTmp.data->Iex.Binop.op;
  arg1 = st->Ist.WrTmp.data->Iex.Binop.arg1;
  arg2 = st->Ist.WrTmp.data->Iex.Binop.arg2;
  
  lhs = (HWord)st->Ist.WrTmp.tmp;
  d1 = unsafeIRDirty_0_N(0, "EmitNewTmpTyvarHelper", 
			&EmitNewTmpTyvarHelper,
			mkIRExprVec_2(
				      mkIRExpr_HWord(lhs),
				      mkIRExpr_HWord(counter)
				      )
			);
  setHelperAnns(d1);
  addStmtToIRSB(sb,IRStmt_Dirty(d1));

  if (arg1->tag == Iex_RdTmp && arg2->tag == Iex_RdTmp)
    {
      d2 = unsafeIRDirty_0_N(0, "EmitBinopTmpTmpTypeHelper", 
			     &EmitBinopTmpTmpTypeHelper,
			     mkIRExprVec_5(
			        	   mkIRExpr_HWord(lhs),
				           mkIRExpr_HWord(op),
				           mkIRExpr_HWord((HWord)arg1->Iex.RdTmp.tmp),
				           mkIRExpr_HWord((HWord)arg2->Iex.RdTmp.tmp),
				           mkIRExpr_HWord(counter)
				           )
			     );
      setHelperAnns(d2);
      addStmtToIRSB(sb,IRStmt_Dirty(d2));
    }

  if ((arg1->tag == Iex_RdTmp && arg2->tag == Iex_Const)
      || (arg1->tag == Iex_Const && arg2->tag == Iex_RdTmp))
    {
      if (arg1->tag == Iex_RdTmp) tmpname = (HWord)arg1->Iex.RdTmp.tmp;
      else if (arg2->tag == Iex_RdTmp) tmpname = (HWord)arg2->Iex.RdTmp.tmp;
      else vpanic("Neither arg1 nor arg2 is a tmp! \n");
      d2 = unsafeIRDirty_0_N(0, "EmitBinopTmpConstTypeHelper", 
			     &EmitBinopTmpConstTypeHelper,
			     mkIRExprVec_4(
			        	   mkIRExpr_HWord(lhs),
				           mkIRExpr_HWord(op),
				           mkIRExpr_HWord(tmpname),
				           mkIRExpr_HWord(counter)
				           )
			     );
      setHelperAnns(d2);
      addStmtToIRSB(sb,IRStmt_Dirty(d2));
    }

  return;
}