// merge sets from control flow joins
VarSrcTokTable inUnion = new VarSrcTokTable();
for( int i = 0; i < fn.numPrev(); i++ ) {
- FlatNode nn = fn.getPrev( i );
-
+ FlatNode nn = fn.getPrev( i );
VarSrcTokTable incoming = variableResults.get( nn );
- if( incoming != null ) {
- incoming.assertConsistency();
- }
-
inUnion.merge( incoming );
}
VarSrcTokTable curr = variable_nodeActions( fn, inUnion, seseStack.peek() );
// if a new result, schedule forward nodes for analysis
- if( !curr.equals( prev ) ) {
-
-
- curr.assertConsistency();
-
+ if( !curr.equals( prev ) ) {
variableResults.put( fn, curr );
for( int i = 0; i < fn.numNext(); i++ ) {
vstTable.remove( lhs );
+ Set<VariableSourceToken> forAddition = new HashSet<VariableSourceToken>();
+
Iterator<VariableSourceToken> itr = vstTable.get( rhs ).iterator();
while( itr.hasNext() ) {
VariableSourceToken vst = itr.next();
// if this is from a child, keep the source information
if( currentSESE.getChildren().contains( vst.getSESE() ) ) {
- vstTable.add( new VariableSourceToken( ts,
- vst.getSESE(),
- vst.getAge(),
- vst.getAddrVar()
- )
- );
+ forAddition.add( new VariableSourceToken( ts,
+ vst.getSESE(),
+ vst.getAge(),
+ vst.getAddrVar()
+ )
+ );
// otherwise, it's our or an ancestor's token so we
// can assume we have everything we need
} else {
- vstTable.add( new VariableSourceToken( ts,
- currentSESE,
- new Integer( 0 ),
- lhs
- )
- );
+ forAddition.add( new VariableSourceToken( ts,
+ currentSESE,
+ new Integer( 0 ),
+ lhs
+ )
+ );
}
}
+ vstTable.addAll( forAddition );
+
// only break if this is an ASSIGN op node,
// otherwise fall through to default case
vstTable.assertConsistency();
}
if( state.MLPDEBUG ) {
- System.out.println( fm.printMethod( livenessRootView ) );
+ //System.out.println( fm.printMethod( livenessRootView ) );
+ //System.out.println( fm.printMethod( variableResults ) );
//System.out.println( fm.printMethod( isAvailableResults ) );
- //System.out.println( fm.printMethod( codePlans ) );
+ System.out.println( fm.printMethod( codePlans ) );
}
}
} break;
default: {
+ // decide if we must stall for variables
+ // dereferenced at this node
Set<VariableSourceToken> stallSet = vstTable.getStallSet( currentSESE );
TempDescriptor[] readarray = fn.readsTemps();
for( int i = 0; i < readarray.length; i++ ) {
vstTable.remove( vst );
}
}
+
+ // if any variable at this node has a static source (exactly one sese)
+ // but goes to a dynamic source at a next node, write its dynamic addr
+ Set<VariableSourceToken> static2dynamicSet = new HashSet<VariableSourceToken>();
+ for( int i = 0; i < fn.numNext(); i++ ) {
+ FlatNode nn = fn.getNext( i );
+ VarSrcTokTable nextVstTable = variableResults.get( nn );
+ assert nextVstTable != null;
+ static2dynamicSet.addAll( vstTable.getStatic2DynamicSet( nextVstTable ) );
+ }
+ Iterator<VariableSourceToken> vstItr = static2dynamicSet.iterator();
+ while( vstItr.hasNext() ) {
+ VariableSourceToken vst = vstItr.next();
+ if( after == null ) {
+ after = "** Write dynamic: ";
+ }
+ after += "("+vst+")";
+ }
+
} break;
} // end switch
out.addAll( get( child ) );
}
- assertConsistency();
+ return out;
+ }
+
+
+ // given a table from a subsequent program point, decide
+ // which variables are going from a static source to a
+ // dynamic source and return them
+ public Set<VariableSourceToken> getStatic2DynamicSet( VarSrcTokTable next ) {
+
+ Set<VariableSourceToken> out = new HashSet<VariableSourceToken>();
+
+ Iterator itr = var2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ TempDescriptor var = (TempDescriptor) me.getKey();
+ HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue();
+
+ if( s1.size() == 1 ) {
+ // this is a variable with a static source
+ Set<VariableSourceToken> s2 = next.get( var );
+
+ if( s2.size() > 1 ) {
+ // and in the next table, it is dynamic
+ out.addAll( s1 );
+ }
+ }
+ }
+
return out;
}
}
public String toString() {
- return "trueSet ="+trueSet.toString();
+ //return "trueSet ="+trueSet.toString();
+ return toStringPretty();
}
public String toStringVerbose() {