⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 irdefs.c

📁 The Valgrind distribution has multiple tools. The most popular is the memory checking tool (called M
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Constructors -- IRStmt */IRStmt* IRStmt_NoOp ( void ){   /* Just use a single static closure. */   static IRStmt static_closure;   static_closure.tag = Ist_NoOp;   return &static_closure;}IRStmt* IRStmt_IMark ( Addr64 addr, Int len ) {   IRStmt* s         = LibVEX_Alloc(sizeof(IRStmt));   s->tag            = Ist_IMark;   s->Ist.IMark.addr = addr;   s->Ist.IMark.len  = len;   return s;}IRStmt* IRStmt_AbiHint ( IRExpr* base, Int len ) {   IRStmt* s           = LibVEX_Alloc(sizeof(IRStmt));   s->tag              = Ist_AbiHint;   s->Ist.AbiHint.base = base;   s->Ist.AbiHint.len  = len;   return s;}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.data   = data;   return s;}IRStmt* IRStmt_PutI ( IRArray* descr, IRExpr* ix,                      Int bias, IRExpr* data ) {   IRStmt* s         = LibVEX_Alloc(sizeof(IRStmt));   s->tag            = Ist_PutI;   s->Ist.PutI.descr = descr;   s->Ist.PutI.ix    = ix;   s->Ist.PutI.bias  = bias;   s->Ist.PutI.data  = data;   return s;}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.data = data;   return s;}IRStmt* IRStmt_Store ( IREndness end, IRExpr* addr, IRExpr* data ) {   IRStmt* s         = LibVEX_Alloc(sizeof(IRStmt));   s->tag            = Ist_Store;   s->Ist.Store.end  = end;   s->Ist.Store.addr = addr;   s->Ist.Store.data = data;   vassert(end == Iend_LE || end == Iend_BE);   return s;}IRStmt* IRStmt_Dirty ( IRDirty* d ){   IRStmt* s            = LibVEX_Alloc(sizeof(IRStmt));   s->tag               = Ist_Dirty;   s->Ist.Dirty.details = d;   return s;}IRStmt* IRStmt_MFence ( void ){   /* Just use a single static closure. */   static IRStmt static_closure;   static_closure.tag = Ist_MFence;   return &static_closure;}IRStmt* IRStmt_Exit ( IRExpr* guard, IRJumpKind jk, IRConst* dst ) {   IRStmt* s         = LibVEX_Alloc(sizeof(IRStmt));   s->tag            = Ist_Exit;   s->Ist.Exit.guard = guard;   s->Ist.Exit.jk    = jk;   s->Ist.Exit.dst   = dst;   return s;}/* Constructors -- IRTypeEnv */IRTypeEnv* emptyIRTypeEnv ( void ){   IRTypeEnv* env   = LibVEX_Alloc(sizeof(IRTypeEnv));   env->types       = LibVEX_Alloc(8 * sizeof(IRType));   env->types_size  = 8;   env->types_used  = 0;   return env;}/* Constructors -- IRBB */IRBB* emptyIRBB ( void ){   IRBB* bb       = LibVEX_Alloc(sizeof(IRBB));   bb->tyenv      = emptyIRTypeEnv();   bb->stmts_used = 0;   bb->stmts_size = 8;   bb->stmts      = LibVEX_Alloc(bb->stmts_size * sizeof(IRStmt*));   bb->next       = NULL;   bb->jumpkind   = Ijk_Boring;   return bb;}/*---------------------------------------------------------------*//*--- (Deep) copy constructors.  These make complete copies   ---*//*--- the original, which can be modified without affecting   ---*//*--- the original.                                           ---*//*---------------------------------------------------------------*//* Copying IR Expr vectors (for call args). *//* Shallow copy of an IRExpr vector */IRExpr** sopyIRExprVec ( IRExpr** vec ){   Int      i;   IRExpr** newvec;   for (i = 0; vec[i]; i++)      ;   newvec = LibVEX_Alloc((i+1)*sizeof(IRExpr*));   for (i = 0; vec[i]; i++)      newvec[i] = vec[i];   newvec[i] = NULL;   return newvec;}/* Deep copy of an IRExpr vector */IRExpr** dopyIRExprVec ( IRExpr** vec ){   Int      i;   IRExpr** newvec = sopyIRExprVec( vec );   for (i = 0; newvec[i]; i++)      newvec[i] = dopyIRExpr(newvec[i]);   return newvec;}/* Deep copy constructors for all heap-allocated IR types follow. */IRConst* dopyIRConst ( IRConst* c ){   switch (c->tag) {      case Ico_U1:   return IRConst_U1(c->Ico.U1);      case Ico_U8:   return IRConst_U8(c->Ico.U8);      case Ico_U16:  return IRConst_U16(c->Ico.U16);      case Ico_U32:  return IRConst_U32(c->Ico.U32);      case Ico_U64:  return IRConst_U64(c->Ico.U64);      case Ico_F64:  return IRConst_F64(c->Ico.F64);      case Ico_F64i: return IRConst_F64i(c->Ico.F64i);      case Ico_V128: return IRConst_V128(c->Ico.V128);      default: vpanic("dopyIRConst");   }}IRCallee* dopyIRCallee ( IRCallee* ce ){   IRCallee* ce2 = mkIRCallee(ce->regparms, ce->name, ce->addr);   ce2->mcx_mask = ce->mcx_mask;   return ce2;}IRArray* dopyIRArray ( IRArray* d ){   return mkIRArray(d->base, d->elemTy, d->nElems);}IRExpr* dopyIRExpr ( IRExpr* e ){   switch (e->tag) {      case Iex_Get:          return IRExpr_Get(e->Iex.Get.offset, e->Iex.Get.ty);      case Iex_GetI:          return IRExpr_GetI(dopyIRArray(e->Iex.GetI.descr),                             dopyIRExpr(e->Iex.GetI.ix),                            e->Iex.GetI.bias);      case Iex_Tmp:          return IRExpr_Tmp(e->Iex.Tmp.tmp);      case Iex_Qop:          return IRExpr_Qop(e->Iex.Qop.op,                           dopyIRExpr(e->Iex.Qop.arg1),                           dopyIRExpr(e->Iex.Qop.arg2),                           dopyIRExpr(e->Iex.Qop.arg3),                           dopyIRExpr(e->Iex.Qop.arg4));      case Iex_Triop:          return IRExpr_Triop(e->Iex.Triop.op,                             dopyIRExpr(e->Iex.Triop.arg1),                             dopyIRExpr(e->Iex.Triop.arg2),                             dopyIRExpr(e->Iex.Triop.arg3));      case Iex_Binop:          return IRExpr_Binop(e->Iex.Binop.op,                             dopyIRExpr(e->Iex.Binop.arg1),                             dopyIRExpr(e->Iex.Binop.arg2));      case Iex_Unop:          return IRExpr_Unop(e->Iex.Unop.op,                            dopyIRExpr(e->Iex.Unop.arg));      case Iex_Load:          return IRExpr_Load(e->Iex.Load.end,                            e->Iex.Load.ty,                            dopyIRExpr(e->Iex.Load.addr));      case Iex_Const:          return IRExpr_Const(dopyIRConst(e->Iex.Const.con));      case Iex_CCall:         return IRExpr_CCall(dopyIRCallee(e->Iex.CCall.cee),                             e->Iex.CCall.retty,                             dopyIRExprVec(e->Iex.CCall.args));      case Iex_Mux0X:          return IRExpr_Mux0X(dopyIRExpr(e->Iex.Mux0X.cond),                             dopyIRExpr(e->Iex.Mux0X.expr0),                             dopyIRExpr(e->Iex.Mux0X.exprX));      default:         vpanic("dopyIRExpr");   }}IRDirty* dopyIRDirty ( IRDirty* d ){   Int      i;   IRDirty* d2 = emptyIRDirty();   d2->cee   = dopyIRCallee(d->cee);   d2->guard = dopyIRExpr(d->guard);   d2->args  = dopyIRExprVec(d->args);   d2->tmp   = d->tmp;   d2->mFx   = d->mFx;   d2->mAddr = d->mAddr==NULL ? NULL : dopyIRExpr(d->mAddr);   d2->mSize = d->mSize;   d2->needsBBP = d->needsBBP;   d2->nFxState = d->nFxState;   for (i = 0; i < d2->nFxState; i++)      d2->fxState[i] = d->fxState[i];   return d2;}IRStmt* dopyIRStmt ( IRStmt* s ){   switch (s->tag) {      case Ist_NoOp:         return IRStmt_NoOp();      case Ist_AbiHint:         return IRStmt_AbiHint(dopyIRExpr(s->Ist.AbiHint.base),                               s->Ist.AbiHint.len);      case Ist_IMark:         return IRStmt_IMark(s->Ist.IMark.addr, s->Ist.IMark.len);      case Ist_Put:          return IRStmt_Put(s->Ist.Put.offset,                            dopyIRExpr(s->Ist.Put.data));      case Ist_PutI:          return IRStmt_PutI(dopyIRArray(s->Ist.PutI.descr),                            dopyIRExpr(s->Ist.PutI.ix),                            s->Ist.PutI.bias,                             dopyIRExpr(s->Ist.PutI.data));      case Ist_Tmp:         return IRStmt_Tmp(s->Ist.Tmp.tmp,                           dopyIRExpr(s->Ist.Tmp.data));      case Ist_Store:          return IRStmt_Store(s->Ist.Store.end,                             dopyIRExpr(s->Ist.Store.addr),                             dopyIRExpr(s->Ist.Store.data));      case Ist_Dirty:          return IRStmt_Dirty(dopyIRDirty(s->Ist.Dirty.details));      case Ist_MFence:         return IRStmt_MFence();      case Ist_Exit:          return IRStmt_Exit(dopyIRExpr(s->Ist.Exit.guard),                            s->Ist.Exit.jk,                            dopyIRConst(s->Ist.Exit.dst));      default:          vpanic("dopyIRStmt");   }}IRTypeEnv* dopyIRTypeEnv ( IRTypeEnv* src ){   Int        i;   IRTypeEnv* dst = LibVEX_Alloc(sizeof(IRTypeEnv));   dst->types_size = src->types_size;   dst->types_used = src->types_used;   dst->types = LibVEX_Alloc(dst->types_size * sizeof(IRType));   for (i = 0; i < src->types_used; i++)      dst->types[i] = src->types[i];   return dst;}IRBB* dopyIRBB ( IRBB* bb ){   Int      i;   IRStmt** sts2;   IRBB* bb2 = emptyIRBB();   bb2->tyenv = dopyIRTypeEnv(bb->tyenv);   bb2->stmts_used = bb2->stmts_size = bb->stmts_used;   sts2 = LibVEX_Alloc(bb2->stmts_used * sizeof(IRStmt*));   for (i = 0; i < bb2->stmts_used; i++)      sts2[i] = dopyIRStmt(bb->stmts[i]);   bb2->stmts    = sts2;   bb2->next     = dopyIRExpr(bb->next);   bb2->jumpkind = bb->jumpkind;   return bb2;}/*---------------------------------------------------------------*//*--- Primop types                                            ---*//*---------------------------------------------------------------*/staticvoid typeOfPrimop ( IROp op,                     /*OUTs*/                    IRType* t_dst,                     IRType* t_arg1, IRType* t_arg2,                     IRType* t_arg3, IRType* t_arg4 ){#  define UNARY(_ta1,_td)                                      \      *t_dst = (_td); *t_arg1 = (_ta1); break#  define BINARY(_ta1,_ta2,_td)                                \     *t_dst = (_td); *t_arg1 = (_ta1); *t_arg2 = (_ta2); break#  define TERNARY(_ta1,_ta2,_ta3,_td)                          \     *t_dst = (_td); *t_arg1 = (_ta1);                         \     *t_arg2 = (_ta2); *t_arg3 = (_ta3); break#  define QUATERNARY(_ta1,_ta2,_ta3,_ta4,_td)                  \     *t_dst = (_td); *t_arg1 = (_ta1);                         \     *t_arg2 = (_ta2); *t_arg3 = (_ta3);                       \     *t_arg4 = (_ta4); break#  define COMPARISON(_ta)                                      \     *t_dst = Ity_I1; *t_arg1 = *t_arg2 = (_ta); break;#  define UNARY_COMPARISON(_ta)                                \     *t_dst = Ity_I1; *t_arg1 = (_ta); break;   /* Rounding mode values are always Ity_I32, encoded as per      IRRoundingMode */   const IRType ity_RMode = Ity_I32;   *t_dst  = Ity_INVALID;   *t_arg1 = Ity_INVALID;   *t_arg2 = Ity_INVALID;   *t_arg3 = Ity_INVALID;   *t_arg4 = Ity_INVALID;   switch (op) {      case Iop_Add8: case Iop_Sub8: case Iop_Mul8:       case Iop_Or8:  case Iop_And8: case Iop_Xor8:         BINARY(Ity_I8,Ity_I8, Ity_I8);      case Iop_Add16: case Iop_Sub16: case Iop_Mul16:      case Iop_Or16:  case Iop_And16: case Iop_Xor16:         BINARY(Ity_I16,Ity_I16, Ity_I16);      case Iop_CmpORD32U:      case Iop_CmpORD32S:      case Iop_Add32: case Iop_Sub32: case Iop_Mul32:      case Iop_Or32:  case Iop_And32: case Iop_Xor32:         BINARY(Ity_I32,Ity_I32, Ity_I32);      case Iop_Add64: case Iop_Sub64: case Iop_Mul64:      case Iop_Or64:  case Iop_And64: case Iop_Xor64:      case Iop_CmpORD64U:      case Iop_CmpORD64S:      case Iop_Avg8Ux8: case Iop_Avg16Ux4:      case Iop_Add8x8: case Iop_Add16x4: case Iop_Add32x2:      case Iop_CmpEQ8x8: case Iop_CmpEQ16x4: case Iop_CmpEQ32x2:      case Iop_CmpGT8Sx8: case Iop_CmpGT16Sx4: case Iop_CmpGT32Sx2:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -