]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Change the name of some IR fields from .expr to .data, as .expr
authorJulian Seward <jseward@acm.org>
Thu, 23 Sep 2004 11:06:17 +0000 (11:06 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 23 Sep 2004 11:06:17 +0000 (11:06 +0000)
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

VEX/priv/host-x86/isel.c
VEX/priv/ir/irdefs.c
VEX/priv/ir/iropt.c
VEX/pub/libvex_ir.h

index 869de7b09e3321f943873f380d40ee5ffb586730..a147b800ab9487b208dfc5cb3145f8d2f03eab2f 100644 (file)
@@ -1981,11 +1981,11 @@ static void iselStmt ( ISelEnv* env, IRStmt* stmt )
 
    /* --------- 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,
@@ -1995,7 +1995,7 @@ static void iselStmt ( ISelEnv* env, IRStmt* stmt )
          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,
@@ -2032,28 +2032,28 @@ static void iselStmt ( ISelEnv* env, IRStmt* stmt )
       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;
       }
index 38c300b28c8df8c61d9d37cd5c103174ca909c6c..b82b5ac71398d60b29057c0bbbf3a9e01ad9efdc 100644 (file)
@@ -299,7 +299,7 @@ void ppIRStmt ( IRStmt* s )
    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" );
@@ -312,7 +312,7 @@ void ppIRStmt ( IRStmt* s )
       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(");
@@ -551,11 +551,11 @@ IRDirty* emptyIRDirty ( void )
 
 /* 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,
@@ -568,18 +568,18 @@ 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 )
@@ -999,14 +999,14 @@ void useBeforeDef_Stmt ( IRBB* bb, IRStmt* stmt, Int* def_counts )
    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);
@@ -1128,24 +1128,27 @@ void tcStmt ( IRBB* bb, IRStmt* stmt, IRType gWordTy )
    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:
index f45081c1ee2a5a9804f6157af7132fd5db8edbc4..4bd3544bd0fac407fbb1d832312cd8454de388ae 100644 (file)
@@ -253,7 +253,7 @@ static void flatten_Stmt ( IRBB* bb, IRStmt* st )
    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:
@@ -265,13 +265,13 @@ static void flatten_Stmt ( IRBB* bb, IRStmt* st )
                                        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;
@@ -628,10 +628,10 @@ static IRStmt* subst_and_fold_Stmt ( Hash64* env, IRStmt* st )
 #  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)) 
              );
    }
 
@@ -647,11 +647,11 @@ static IRStmt* subst_and_fold_Stmt ( Hash64* env, IRStmt* st )
    }
 
    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))
              );
    }
 
@@ -752,18 +752,18 @@ static IRBB* cprop_BB ( IRBB* in )
          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. */
@@ -840,10 +840,10 @@ static void addUses_Stmt ( Hash64* set, IRStmt* st )
          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);
@@ -987,10 +987,10 @@ static void redundant_get_removal_BB ( IRBB* bb )
 
       /* 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)) {
@@ -1016,7 +1016,7 @@ static void redundant_get_removal_BB ( IRBB* bb )
          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;
@@ -1036,8 +1036,8 @@ static void redundant_get_removal_BB ( IRBB* bb )
 
       /* 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++) */
@@ -1063,7 +1063,7 @@ static void handle_gets_Stmt ( Hash64* env, IRStmt* st )
       /* 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;
@@ -1153,8 +1153,8 @@ static void redundant_put_removal_BB ( IRBB* bb )
          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;
@@ -1213,11 +1213,11 @@ void spec_helpers_BB ( IRBB* bb,
 
       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;
@@ -1228,7 +1228,7 @@ void spec_helpers_BB ( IRBB* bb,
 
       if (0) {
          vex_printf("SPEC: ");
-         ppIRExpr(st->Ist.Tmp.expr);
+         ppIRExpr(st->Ist.Tmp.data);
          vex_printf("  -->  ");
          ppIRExpr(ex);
          vex_printf("\n");
@@ -1335,10 +1335,10 @@ static void occCount_Stmt ( Hash64* env, IRStmt* st )
    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);
@@ -1465,12 +1465,12 @@ static IRStmt* tbSubst_Stmt ( Hash64* env, IRStmt* st )
       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(
@@ -1681,7 +1681,7 @@ static void treebuild_BB ( IRBB* bb )
          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;
@@ -1918,7 +1918,7 @@ static void cse_BB ( IRBB* bb )
          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;
@@ -2033,11 +2033,11 @@ static Bool hasGetIorPutI ( IRBB* bb )
          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));
index f4b769b5534c46e9d0c1c63190688b864e37d68c..f4f577632e5a2dfdfe49cd46b132e790bf06200a 100644 (file)
@@ -497,7 +497,7 @@ typedef
       union {
          struct {
             Int     offset;
-            IRExpr* expr;
+            IRExpr* data;
          } Put;
          struct {
             IRArray* descr;
@@ -507,7 +507,7 @@ typedef
          } PutI;
          struct {
             IRTemp  tmp;
-            IRExpr* expr;
+            IRExpr* data;
          } Tmp;
          struct {
             IRExpr* addr;
@@ -524,11 +524,11 @@ typedef
    }
    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 );