Fixed variable dynamic source bookkeeping bug, regression test runs for single and...
authorjjenista <jjenista>
Fri, 4 Sep 2009 00:09:10 +0000 (00:09 +0000)
committerjjenista <jjenista>
Fri, 4 Sep 2009 00:09:10 +0000 (00:09 +0000)
Robust/src/Analysis/MLP/CodePlan.java
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Tests/mlp/tinyTest/test.java

index 76a504044177e1871991f8134fcc643edc4f35d6..d5d398dddae626c2358f52e9c7d0129595c1bb54 100644 (file)
@@ -13,13 +13,15 @@ public class CodePlan {
   private Hashtable< VariableSourceToken, Set<TempDescriptor> > stall2copySet;
   private Set<TempDescriptor>                                   dynamicStallSet;
   private Hashtable<TempDescriptor, TempDescriptor>             dynAssign_lhs2rhs;
+  private Set<TempDescriptor>                                   dynAssign_lhs2curr;
   private FlatSESEEnterNode                                     currentSESE;
   
   public CodePlan( FlatSESEEnterNode fsen ) {
-    stall2copySet     = new Hashtable< VariableSourceToken, Set<TempDescriptor> >();
-    dynamicStallSet   = new HashSet<TempDescriptor>();
-    dynAssign_lhs2rhs = new Hashtable<TempDescriptor, TempDescriptor>();
-    currentSESE       = fsen;
+    stall2copySet      = new Hashtable< VariableSourceToken, Set<TempDescriptor> >();
+    dynamicStallSet    = new HashSet<TempDescriptor>();
+    dynAssign_lhs2rhs  = new Hashtable<TempDescriptor, TempDescriptor>();
+    dynAssign_lhs2curr = new HashSet<TempDescriptor>();
+    currentSESE        = fsen;
   }
 
   public FlatSESEEnterNode getCurrentSESE() {
@@ -63,39 +65,12 @@ public class CodePlan {
     return dynAssign_lhs2rhs;
   }
 
-  public boolean equals( Object o ) {
-    if( o == null ) {
-      return false;
-    }
-
-    if( !(o instanceof CodePlan) ) {
-      return false;
-    }
-
-    CodePlan cp = (CodePlan) o;
-
-    boolean copySetsEq = (stall2copySet.equals( cp.stall2copySet ));
-
-    boolean dynStallSetEq = (dynamicStallSet.equals( cp.dynamicStallSet ));
-
-    boolean dynAssignEq = (dynAssign_lhs2rhs.equals( cp.dynAssign_lhs2rhs ));
-        
-    return copySetsEq && dynStallSetEq && dynAssignEq;
+  public void addDynAssign( TempDescriptor lhs ) {
+    dynAssign_lhs2curr.add( lhs );
   }
 
-  public int hashCode() {
-
-    int copySetsHC = stall2copySet.hashCode();
-
-    int dynStallSetHC = dynamicStallSet.hashCode();
-
-    int dynAssignHC = dynAssign_lhs2rhs.hashCode();
-
-    int hash = 7;
-    hash = 31*hash + copySetsHC;
-    hash = 31*hash + dynStallSetHC;
-    hash = 31*hash + dynAssignHC;
-    return hash;
+  public Set<TempDescriptor> getDynAssignCurr() {
+    return dynAssign_lhs2curr;
   }
 
   public String toString() {
@@ -124,6 +99,10 @@ public class CodePlan {
       s += "[DYN ASSIGNS:"+dynAssign_lhs2rhs+"]";
     }
 
+    if( !dynAssign_lhs2curr.isEmpty() ) {
+      s += "[DYN ASS2CURR:"+dynAssign_lhs2curr+"]";
+    }
+
     return s;
   }
 }
index 1dbb8d14dd1912f031de9fa8342a4ba07366cec0..1c9e8eec52f465204fca70d34bcbdd49412d0cbb 100644 (file)
@@ -901,19 +901,29 @@ public class MLPAnalysis {
        // if this is an op node, don't stall, copy
        // source and delay until we need to use value
 
-       // but check the source type of rhs variable
-       // and if dynamic, lhs becomes dynamic, too,
-       // and we need to keep dynamic sources during
-       Integer srcType 
+       // ask whether lhs and rhs sources are dynamic, static, etc.
+       Integer lhsSrcType
+         = vstTableIn.getRefVarSrcType( lhs,
+                                        currentSESE,
+                                        currentSESE.getParent() );
+
+       Integer rhsSrcType
          = vstTableIn.getRefVarSrcType( rhs,
                                         currentSESE,
                                         currentSESE.getParent() );
 
-       if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) {
+       if( rhsSrcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) {
+         // if rhs is dynamic going in, lhs will definitely be dynamic
+         // going out of this node, so track that here   
          plan.addDynAssign( lhs, rhs );
          currentSESE.addDynamicVar( lhs );
          currentSESE.addDynamicVar( rhs );
-       }
+
+       } else if( lhsSrcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) {
+         // otherwise, if the lhs is dynamic, but the rhs is not, we
+         // need to update the variable's dynamic source as "current SESE"
+         plan.addDynAssign( lhs );
+       }       
 
        // only break if this is an ASSIGN op node,
        // otherwise fall through to default case
index f17905a5c54cdb52dc62c917f3721aeab3d06aec..9c24aa680a3ee83ca2c5645a87da79b704fdfac0 100644 (file)
@@ -2431,6 +2431,14 @@ public class BuildCode {
          output.println("   "+lhs+"_srcSESE   = "+rhs+"_srcSESE;");
          output.println("   "+lhs+"_srcOffset = "+rhs+"_srcOffset;");
        }
+
+       // for each lhs that is dynamic from a non-dynamic source, set the
+       // dynamic source vars to the current SESE
+       dynItr = cp.getDynAssignCurr().iterator();
+       while( dynItr.hasNext() ) {
+         TempDescriptor dynVar = dynItr.next();
+         output.println("   "+dynVar+"_srcSESE = NULL;");
+       }
       }     
     }
 
index 3c779968d36df04ca5184eed5927ca6775081de9..75e30bb8d4d67ed71d94288e12cabff828bf9ad1 100644 (file)
@@ -1,36 +1,23 @@
 
 public class Test {
 
-  public static void main( String args[] ) {        
+  public static void main( String args[] ) {
     int x = Integer.parseInt( args[0] );
     doSomeWork( x );
   }
 
   public static void doSomeWork( int x ) {
     for( int i = 0; i < x; ++i ) {
-      sese calc {
-       int sum = 0;    
-       for( int j = 0; j <= i; ++j ) {
-         sum = calculateStuff( sum, 1, 0 );
-       }       
-      }           
-      sese forceVirtualReal {
-       if( i % 3 == 0 ) {
-         sum = sum + (i % 20);
-       }
-      }      
-      if( i % 2 == 0 ) {
-       sese change {
-         for( int k = 0; k < i*2; ++k ) {
-           sum = calculateStuff( sum, k, 1 );
-         }
-         sum = sum + 1;
-       }       
+      int sum = 0;
        
-       for( int l = 0; l < 3; ++l ) {
-         sum = calculateStuff( sum, 2, 2 );
-       }
+      sese change {
+       sum = sum + 1;  
+      }        
+
+      for( int l = 0; l < 3; ++l ) {
+       sum = calculateStuff( sum, 2, 2 );
       }      
+
       sese prnt {
        mightPrint( x, i, sum );
       }
@@ -38,26 +25,7 @@ public class Test {
   }
 
   public static int calculateStuff( int sum, int num, int mode ) {
-    int answer = sum;
-    sese makePlaceholderStallAfter {
-      sum = sum + 1;
-    }
-    sum = sum + 1;
-    if( mode == 0 ) {
-      sese mode1 {
-       answer = sum + num;
-      }
-    } else if( mode == 1 ) {
-      sese mode2 {
-       answer = sum + (num/2);
-      }
-    } else if( mode == 2 ) {
-      sese mode3 {
-       answer = sum + (num/2);
-      }
-    }    
-
-    return answer;
+    return sum + 10;
   }
 
   public static void mightPrint( int x, int i, int sum ) {