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() {
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() {
s += "[DYN ASSIGNS:"+dynAssign_lhs2rhs+"]";
}
+ if( !dynAssign_lhs2curr.isEmpty() ) {
+ s += "[DYN ASS2CURR:"+dynAssign_lhs2curr+"]";
+ }
+
return s;
}
}
// 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
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;");
+ }
}
}
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 );
}
}
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 ) {