bug fixes and implementation adjustments: matches analysis up through IV
authorjjenista <jjenista>
Thu, 23 Apr 2009 22:26:14 +0000 (22:26 +0000)
committerjjenista <jjenista>
Thu, 23 Apr 2009 22:26:14 +0000 (22:26 +0000)
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/Analysis/MLP/VarSrcTokTable.java
Robust/src/IR/Flat/FlatSESEEnterNode.java

index b9f07420b8783c835eb4e1272c6057f85a1ae8d1..5f70ae770e15a10feff772fd624e01ea7bc502a6 100644 (file)
@@ -153,6 +153,7 @@ public class MLPAnalysis {
       FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;      
       assert !seseStack.empty();
       seseStack.peek().addChild( fsen );
+      fsen.setParent( seseStack.peek() );
       seseStack.push( fsen );
     } break;
 
@@ -326,16 +327,15 @@ public class MLPAnalysis {
 
     case FKind.FlatSESEEnterNode: {
       FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
-
-      if( fsen.equals( currentSESE ) ) {
-       vstTable.age( currentSESE );
-      }
+      assert fsen.equals( currentSESE );
+      vstTable.age( currentSESE );
     } break;
 
     case FKind.FlatSESEExitNode: {
       FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
-
-      vstTable.removeChildToks( currentSESE );
+      assert currentSESE.getChildren().contains( fsexn.getFlatEnter() );
+      vstTable = vstTable.remapChildTokens( currentSESE );
+      vstTable = vstTable.removeParentAndSiblingTokens( currentSESE );
     } break;
 
     case FKind.FlatOpNode: {
@@ -350,13 +350,26 @@ public class MLPAnalysis {
        Iterator<VariableSourceToken> itr = vstTable.get( rhs ).iterator();
        while( itr.hasNext() ) {
          VariableSourceToken vst = itr.next();
-         
-         vstTable.add( new VariableSourceToken( lhs,
-                                                vst.getSESE(),
-                                                vst.getAge(),
-                                                vst.getVarSrc()
-                                              )
-                       );
+
+          // if this is from a child, keep the source information
+          if( currentSESE.getChildren().contains( vst.getSESE() ) ) {    
+            vstTable.add( new VariableSourceToken( lhs,
+                                                   vst.getSESE(),
+                                                   vst.getAge(),
+                                                   vst.getVarSrc()
+                                                   )
+                          );
+
+          // otherwise, it's our or an ancestor's token so we
+          // can assume we have everything we need
+          } else {
+            vstTable.add( new VariableSourceToken( lhs,
+                                                   currentSESE,
+                                                   new Integer( 0 ),
+                                                   lhs
+                                                   )
+                          );
+          }
        }
 
        // only break if this is an ASSIGN op node,
@@ -422,7 +435,7 @@ public class MLPAnalysis {
     }      
 
     if( state.MLPDEBUG ) { 
-      fm.printMethod( codePlan );
+      System.out.println( fm.printMethod( codePlan ) );
     }
   }
 
@@ -450,7 +463,7 @@ public class MLPAnalysis {
        Iterator<VariableSourceToken> itr = stallSet.iterator();
        while( itr.hasNext() ) {
          VariableSourceToken vst = itr.next();
-         s += "  "+vst;
+         s += "  "+vst.getVarLive();
        }       
       }      
 
index 6b940d4e905af69da3b9a954084ac29b42f680c0..77adefc9dfbec62eaec8d7385fbbc53fcf26c2cb 100644 (file)
@@ -274,30 +274,72 @@ public class VarSrcTokTable {
   }\r
 \r
   \r
-  // for the given SESE, remove tokens for the same live\r
-  // variable if it comes from a child SESE\r
-  public VarSrcTokTable removeChildToks( FlatSESEEnterNode curr ) {\r
+  // for the given SESE, change child tokens into this parent\r
+  public VarSrcTokTable remapChildTokens( FlatSESEEnterNode curr ) {\r
 \r
     // create a table to modify as a copy of this\r
     VarSrcTokTable out = new VarSrcTokTable( this );\r
 \r
-    // iterate over this table, modify out table\r
-    Iterator<VariableSourceToken> itr = get( curr ).iterator();\r
-    while( itr.hasNext() ) {\r
-      VariableSourceToken vst = itr.next();\r
+    Iterator<FlatSESEEnterNode> childItr = curr.getChildren().iterator();\r
+    if( childItr.hasNext() ) {\r
+      FlatSESEEnterNode child = childItr.next();\r
+\r
+      Iterator<VariableSourceToken> vstItr = get( child ).iterator();\r
+      while( vstItr.hasNext() ) {\r
+        VariableSourceToken vst = vstItr.next();\r
+        out.remove( vst );\r
+        out.add( new VariableSourceToken( vst.getVarLive(),\r
+                                          curr,\r
+                                          new Integer( 0 ),\r
+                                          vst.getVarLive() ) );\r
+      }\r
+    }\r
+\r
+    return out;    \r
+  }   \r
+\r
+\r
+  // if we can get a value from the current SESE and the parent\r
+  // or a sibling, just getting from the current SESE suffices now\r
+  public VarSrcTokTable removeParentAndSiblingTokens( FlatSESEEnterNode curr ) {\r
+\r
+    // create a table to modify as a copy of this\r
+    VarSrcTokTable out = new VarSrcTokTable( this );\r
+\r
+    FlatSESEEnterNode parent = curr.getParent();\r
+    if( parent == null ) {\r
+      // have no parent or siblings\r
+      return out;\r
+    }      \r
+\r
+    out.remove_A_if_B( parent, curr );\r
 \r
-      Iterator<VariableSourceToken> itr2 = get( vst.getVarLive() ).iterator();\r
-      while( itr2.hasNext() ) {\r
-       VariableSourceToken vst2 = itr2.next();\r
+    Iterator<FlatSESEEnterNode> childItr = parent.getChildren().iterator();\r
+    if( childItr.hasNext() ) {\r
+      FlatSESEEnterNode child = childItr.next();\r
 \r
-       if( curr.getChildren().contains( vst2.getSESE() ) ) {\r
-         out.remove( vst2 );\r
-       }       \r
+      if( !child.equals( curr ) ) {\r
+        out.remove_A_if_B( child, curr );\r
       }\r
     }\r
 \r
     return out;    \r
-  }   \r
+  }\r
+\r
+  // if B is also a source for some variable, remove all entries\r
+  // of A as a source for that variable\r
+  protected void remove_A_if_B( FlatSESEEnterNode a, FlatSESEEnterNode b ) {\r
+\r
+    Iterator<VariableSourceToken> vstItr = get( a ).iterator();\r
+    while( vstItr.hasNext() ) {\r
+      VariableSourceToken vst = vstItr.next();\r
+\r
+      Set<VariableSourceToken> bSet = get( new SVKey( b, vst.getVarLive() ) );\r
+      if( !bSet.isEmpty() ) {\r
+        remove( vst );\r
+      }\r
+    }\r
+  }\r
 \r
 \r
   public Set<VariableSourceToken> getStallSet( FlatSESEEnterNode curr ) {\r
index ee035b7355c245409e369fef824b1153d8d0e4a2..b1f81e92cfa677f04780bd73c2d6d6a127e3e747 100644 (file)
@@ -8,6 +8,7 @@ public class FlatSESEEnterNode extends FlatNode {
   private int id;
   protected FlatSESEExitNode exit;
   protected SESENode treeNode;
+  protected FlatSESEEnterNode parent;
   protected Set<FlatSESEEnterNode> children;
   protected Set<TempDescriptor> inVars;
   protected Set<VariableSourceToken> outVars;
@@ -27,6 +28,14 @@ public class FlatSESEEnterNode extends FlatNode {
   public void rewriteDef() {
   }
 
+  public void setParent( FlatSESEEnterNode parent ) {
+    this.parent = parent;
+  }
+
+  public FlatSESEEnterNode getParent() {
+    return parent;
+  }
+
   public void addChild( FlatSESEEnterNode child ) {
     children.add( child );
   }