FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
assert !seseStack.empty();
seseStack.peek().addChild( fsen );
+ fsen.setParent( seseStack.peek() );
seseStack.push( fsen );
} break;
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: {
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,
}
if( state.MLPDEBUG ) {
- fm.printMethod( codePlan );
+ System.out.println( fm.printMethod( codePlan ) );
}
}
Iterator<VariableSourceToken> itr = stallSet.iterator();
while( itr.hasNext() ) {
VariableSourceToken vst = itr.next();
- s += " "+vst;
+ s += " "+vst.getVarLive();
}
}
}\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