-package Analysis.MLP;\r
-\r
-import IR.*;\r
-import IR.Flat.*;\r
-import java.util.*;\r
-import java.io.*;\r
-\r
-// This class formerly had lazy consistency properties, but\r
-// it is being changed so that the full set and the extra\r
-// hash tables to access the full set efficiently by different\r
-// elements will be consistent after EVERY operation. Also,\r
-// a consistent assert method allows a debugger to ask whether\r
-// an operation has produced an inconsistent VarSrcTokTable.\r
-public class VarSrcTokTable {\r
-\r
- // a set of every token in the table\r
- private HashSet<VariableSourceToken> trueSet;\r
-\r
- // these hashtables provide an efficient retreival from the true set\r
- private Hashtable< TempDescriptor, Set<VariableSourceToken> > var2vst;\r
- private Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> > sese2vst;\r
- private Hashtable< SVKey, Set<VariableSourceToken> > sv2vst;\r
-\r
- // maximum age from aging operation\r
- private Integer MAX_AGE = new Integer( 2 );\r
-\r
-\r
- public VarSrcTokTable() {\r
- trueSet = new HashSet<VariableSourceToken>();\r
-\r
- sese2vst = new Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> >();\r
- var2vst = new Hashtable< TempDescriptor, Set<VariableSourceToken> >();\r
- sv2vst = new Hashtable< SVKey, Set<VariableSourceToken> >();\r
- }\r
-\r
- \r
- public VarSrcTokTable( VarSrcTokTable in ) {\r
- trueSet = (HashSet<VariableSourceToken>) in.trueSet.clone();\r
-\r
- Iterator itr; Set s;\r
-\r
- sese2vst = new Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> >();\r
- itr = in.sese2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();\r
- HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue(); \r
- assert s1 != null;\r
- sese2vst.put( sese, \r
- (HashSet<VariableSourceToken>) (s1.clone()) );\r
- }\r
-\r
- var2vst = new Hashtable< TempDescriptor, Set<VariableSourceToken> >();\r
- itr = in.var2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- TempDescriptor var = (TempDescriptor) me.getKey();\r
- HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue(); \r
- assert s1 != null;\r
- var2vst.put( var, \r
- (HashSet<VariableSourceToken>) (s1.clone()) );\r
- }\r
-\r
- sv2vst = new Hashtable< SVKey, Set<VariableSourceToken> >();\r
- itr = in.sv2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- SVKey key = (SVKey) me.getKey();\r
- HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue(); \r
- assert s1 != null;\r
- sv2vst.put( key, \r
- (HashSet<VariableSourceToken>) (s1.clone()) );\r
- }\r
-\r
- assertConsistency();\r
- }\r
-\r
-\r
- public void add( VariableSourceToken vst ) {\r
- trueSet.add( vst );\r
-\r
- Set<VariableSourceToken> s;\r
-\r
- s = sese2vst.get( vst.getSESE() );\r
- if( s == null ) {\r
- s = new HashSet<VariableSourceToken>();\r
- }\r
- s.add( vst );\r
- sese2vst.put( vst.getSESE(), s );\r
-\r
- Iterator<TempDescriptor> refVarItr = vst.getRefVars().iterator();\r
- while( refVarItr.hasNext() ) {\r
- TempDescriptor refVar = refVarItr.next();\r
- s = var2vst.get( refVar );\r
- if( s == null ) {\r
- s = new HashSet<VariableSourceToken>();\r
- }\r
- s.add( vst );\r
- var2vst.put( refVar, s );\r
-\r
- SVKey key = new SVKey( vst.getSESE(), refVar );\r
- s = sv2vst.get( key );\r
- if( s == null ) {\r
- s = new HashSet<VariableSourceToken>();\r
- }\r
- s.add( vst );\r
- sv2vst.put( key, s );\r
- }\r
-\r
- assertConsistency();\r
- }\r
-\r
- public void addAll( Set<VariableSourceToken> s ) {\r
- Iterator<VariableSourceToken> itr = s.iterator();\r
- while( itr.hasNext() ) {\r
- add( itr.next() );\r
- }\r
- }\r
-\r
-\r
- public Set<VariableSourceToken> get() {\r
- return trueSet;\r
- }\r
-\r
- public Set<VariableSourceToken> get( FlatSESEEnterNode sese ) {\r
- Set<VariableSourceToken> s = sese2vst.get( sese );\r
- if( s == null ) {\r
- s = new HashSet<VariableSourceToken>(); \r
- sese2vst.put( sese, s );\r
- }\r
- return s;\r
- }\r
-\r
- public Set<VariableSourceToken> get( TempDescriptor var ) {\r
- Set<VariableSourceToken> s = var2vst.get( var );\r
- if( s == null ) {\r
- s = new HashSet<VariableSourceToken>();\r
- var2vst.put( var, s );\r
- }\r
- return s;\r
- }\r
-\r
- public Set<VariableSourceToken> get( FlatSESEEnterNode sese,\r
- TempDescriptor refVar ) {\r
- SVKey key = new SVKey( sese, refVar );\r
- Set<VariableSourceToken> s = sv2vst.get( key );\r
- if( s == null ) {\r
- s = new HashSet<VariableSourceToken>();\r
- sv2vst.put( key, s );\r
- }\r
- return s;\r
- }\r
-\r
- public Set<VariableSourceToken> get( FlatSESEEnterNode sese,\r
- Integer age ) {\r
- Set<VariableSourceToken> s = sese2vst.get( sese );\r
- if( s == null ) {\r
- s = new HashSet<VariableSourceToken>(); \r
- sese2vst.put( sese, s );\r
- }\r
- Iterator<VariableSourceToken> sItr = s.iterator();\r
- while( sItr.hasNext() ) {\r
- VariableSourceToken vst = sItr.next();\r
- if( !vst.getAge().equals( age ) ) {\r
- s.remove( vst );\r
- }\r
- }\r
- return s;\r
- }\r
-\r
-\r
- public void merge( VarSrcTokTable tableIn ) {\r
-\r
- if( tableIn == null ) {\r
- return;\r
- }\r
-\r
- // make a copy for modification to use in the merge\r
- VarSrcTokTable table = new VarSrcTokTable( tableIn );\r
-\r
-\r
- trueSet.addAll( table.trueSet );\r
-\r
-\r
- Iterator itr; \r
-\r
- // merge sese2vst mappings\r
- itr = this.sese2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();\r
- Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();\r
- Set<VariableSourceToken> s2 = table.sese2vst.get( sese ); \r
- assert s1 != null;\r
-\r
- if( s2 != null ) {\r
- s1.addAll( s2 );\r
- }\r
- }\r
- itr = table.sese2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();\r
- Set<VariableSourceToken> s2 = (Set<VariableSourceToken>) me.getValue();\r
- Set<VariableSourceToken> s1 = this.sese2vst.get( sese );\r
- assert s2 != null;\r
-\r
- if( s1 == null ) {\r
- this.sese2vst.put( sese, s2 );\r
- } \r
- }\r
-\r
- // merge var2vst mappings\r
- itr = this.var2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- TempDescriptor var = (TempDescriptor) me.getKey();\r
- Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();\r
- Set<VariableSourceToken> s2 = table.var2vst.get( var ); \r
- assert s1 != null;\r
-\r
- if( s2 != null ) {\r
- s1.addAll( s2 );\r
- } \r
- }\r
- itr = table.var2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- TempDescriptor var = (TempDescriptor) me.getKey();\r
- Set<VariableSourceToken> s2 = (Set<VariableSourceToken>) me.getValue();\r
- Set<VariableSourceToken> s1 = this.var2vst.get( var );\r
- assert s2 != null;\r
-\r
- if( s1 == null ) {\r
- this.var2vst.put( var, s2 );\r
- } \r
- }\r
-\r
- // merge sv2vst mappings\r
- itr = this.sv2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- SVKey key = (SVKey) me.getKey();\r
- Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();\r
- Set<VariableSourceToken> s2 = table.sv2vst.get( key ); \r
- assert s1 != null;\r
-\r
- if( s2 != null ) {\r
- s1.addAll( s2 );\r
- } \r
- }\r
- itr = table.sv2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- SVKey key = (SVKey) me.getKey();\r
- Set<VariableSourceToken> s2 = (Set<VariableSourceToken>) me.getValue();\r
- Set<VariableSourceToken> s1 = this.sv2vst.get( key );\r
- assert s2 != null;\r
-\r
- if( s1 == null ) {\r
- this.sv2vst.put( key, s2 );\r
- } \r
- }\r
-\r
- assertConsistency();\r
- }\r
-\r
-\r
- // remove operations must leave the trueSet \r
- // and the hash maps consistent!\r
- public void remove( VariableSourceToken vst ) {\r
- trueSet.remove( vst );\r
- \r
- Set<VariableSourceToken> s;\r
-\r
- s = get( vst.getSESE() );\r
- if( s != null ) { s.remove( vst ); }\r
-\r
- Iterator<TempDescriptor> refVarItr = vst.getRefVars().iterator();\r
- while( refVarItr.hasNext() ) {\r
- TempDescriptor refVar = refVarItr.next();\r
-\r
- s = get( refVar );\r
- if( s != null ) { s.remove( vst ); }\r
- \r
- s = get( vst.getSESE(), refVar );\r
- if( s != null ) { s.remove( vst ); }\r
- }\r
-\r
- assertConsistency();\r
- }\r
-\r
- public void remove( FlatSESEEnterNode sese ) {\r
- Set<VariableSourceToken> s = sese2vst.get( sese );\r
- if( s == null ) {\r
- return;\r
- }\r
-\r
- Iterator<VariableSourceToken> itr = s.iterator();\r
- while( itr.hasNext() ) {\r
- VariableSourceToken vst = itr.next();\r
- remove( vst );\r
- }\r
-\r
- sese2vst.remove( sese );\r
-\r
- assertConsistency();\r
- }\r
-\r
- public void remove( TempDescriptor refVar ) {\r
- Set<VariableSourceToken> s = var2vst.get( refVar );\r
- if( s == null ) {\r
- return;\r
- }\r
- \r
- Set<VariableSourceToken> forRemoval = new HashSet<VariableSourceToken>();\r
-\r
- // iterate over tokens that this temp can reference, make a set\r
- // of tokens that need this temp stripped out of them\r
- Iterator<VariableSourceToken> itr = s.iterator();\r
- while( itr.hasNext() ) {\r
- VariableSourceToken vst = itr.next();\r
- Set<TempDescriptor> refVars = vst.getRefVars();\r
- assert refVars.contains( refVar );\r
- forRemoval.add( vst );\r
- }\r
-\r
- itr = forRemoval.iterator();\r
- while( itr.hasNext() ) {\r
- // here's a token marked for removal, take it out as it is\r
- // in this state\r
- VariableSourceToken vst = itr.next();\r
- remove( vst );\r
-\r
- // if there are other references to the token, alter the\r
- // token and then readd it to this table, because it has\r
- // a new hash value now\r
- Set<TempDescriptor> refVars = vst.getRefVars();\r
- refVars.remove( refVar );\r
- if( refVars.size() > 0 ) {\r
- add( vst );\r
- }\r
- }\r
-\r
- //var2vst.remove( var );\r
-\r
- assertConsistency();\r
- }\r
-\r
- public void remove( FlatSESEEnterNode sese,\r
- TempDescriptor var ) {\r
-\r
- SVKey key = new SVKey( sese, var );\r
- Set<VariableSourceToken> s = sv2vst.get( key );\r
- if( s == null ) {\r
- return;\r
- }\r
- \r
- Iterator<VariableSourceToken> itr = s.iterator();\r
- while( itr.hasNext() ) {\r
- VariableSourceToken vst = itr.next();\r
- remove( vst );\r
- }\r
-\r
- sv2vst.remove( key );\r
-\r
- assertConsistency();\r
- }\r
-\r
-\r
-\r
- // return a new table based on this one and\r
- // age tokens with respect to SESE curr, where\r
- // any curr tokens increase age by 1\r
- public VarSrcTokTable age( FlatSESEEnterNode curr ) {\r
-\r
- // create a table to modify as a copy of this\r
- VarSrcTokTable out = new VarSrcTokTable( this );\r
-\r
- Iterator<VariableSourceToken> itr = trueSet.iterator();\r
- while( itr.hasNext() ) {\r
- VariableSourceToken vst = itr.next();\r
-\r
- if( vst.getSESE().equals( curr ) ) {\r
-\r
- Integer newAge = vst.getAge()+1;\r
- if( newAge > MAX_AGE ) {\r
- newAge = MAX_AGE;\r
- }\r
-\r
- out.remove( vst );\r
-\r
- out.add( new VariableSourceToken( vst.getRefVars(), \r
- curr, \r
- newAge,\r
- vst.getAddrVar()\r
- )\r
- );\r
- } \r
- }\r
-\r
- out.assertConsistency();\r
- return out;\r
- }\r
-\r
- \r
- // for the given SESE, change child tokens into this parent\r
- public void remapChildTokens( FlatSESEEnterNode curr ) {\r
-\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
-\r
- remove( vst );\r
-\r
- add( new VariableSourceToken( vst.getRefVars(),\r
- curr,\r
- new Integer( 0 ),\r
- vst.getAddrVar()\r
- )\r
- );\r
- }\r
- }\r
-\r
- assertConsistency();\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
- // return a set of temps that are virtually read\r
- public Set<TempDescriptor> removeParentAndSiblingTokens( FlatSESEEnterNode curr,\r
- Set<TempDescriptor> liveIn ) {\r
-\r
- HashSet<TempDescriptor> virtualLiveIn = new HashSet<TempDescriptor>();\r
-\r
- FlatSESEEnterNode parent = curr.getParent();\r
- if( parent == null ) {\r
- // have no parent or siblings\r
- return virtualLiveIn;\r
- } \r
-\r
- remove_A_if_B( parent, curr, liveIn, virtualLiveIn );\r
-\r
- Iterator<FlatSESEEnterNode> childItr = parent.getChildren().iterator();\r
- if( childItr.hasNext() ) {\r
- FlatSESEEnterNode child = childItr.next();\r
-\r
- if( !child.equals( curr ) ) {\r
- remove_A_if_B( child, curr, liveIn, virtualLiveIn );\r
- }\r
- }\r
- \r
- assertConsistency();\r
- return virtualLiveIn;\r
- }\r
- \r
- // if B is also a source for some variable, remove all entries\r
- // of A as a source for that variable: s is virtual reads\r
- protected void remove_A_if_B( FlatSESEEnterNode a, \r
- FlatSESEEnterNode b,\r
- Set<TempDescriptor> liveInCurrentSESE,\r
- Set<TempDescriptor> virtualLiveIn ) {\r
-\r
- Set<VariableSourceToken> forRemoval = new HashSet<VariableSourceToken>();\r
-\r
- Iterator<VariableSourceToken> vstItr = get( a ).iterator();\r
- while( vstItr.hasNext() ) {\r
- VariableSourceToken vst = vstItr.next();\r
- Iterator<TempDescriptor> refVarItr = vst.getRefVars().iterator();\r
- while( refVarItr.hasNext() ) {\r
- TempDescriptor refVar = refVarItr.next();\r
- Set<VariableSourceToken> bSet = get( b, refVar );\r
- \r
- if( !bSet.isEmpty() ) {\r
- forRemoval.add( vst );\r
-\r
- // mark this variable as a virtual read as well\r
- //if( liveInCurrentSESE.contains( varLive ) ) { ???????????\r
- virtualLiveIn.add( refVar );\r
- //}\r
- }\r
- }\r
- }\r
-\r
- vstItr = forRemoval.iterator();\r
- while( vstItr.hasNext() ) {\r
- VariableSourceToken vst = vstItr.next();\r
- remove( vst );\r
- }\r
- }\r
-\r
-\r
- public Set<VariableSourceToken> getStallSet( FlatSESEEnterNode curr ) {\r
-\r
- Set<VariableSourceToken> out = new HashSet<VariableSourceToken>();\r
-\r
- Iterator<FlatSESEEnterNode> cItr = curr.getChildren().iterator();\r
- while( cItr.hasNext() ) {\r
- FlatSESEEnterNode child = cItr.next();\r
- out.addAll( get( child ) );\r
- }\r
-\r
- return out;\r
- }\r
-\r
-\r
- // use as an aid for debugging, where true-set is checked\r
- // against the alternate mappings: assert that nothing is\r
- // missing or extra in the alternates\r
- public void assertConsistency() {\r
-\r
- Iterator itr; \r
- Set s;\r
-\r
- Set<VariableSourceToken> trueSetByAlts = new HashSet<VariableSourceToken>();\r
- itr = sese2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();\r
- HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue(); \r
- assert s1 != null;\r
- \r
- // the trueSet should have all entries in s1\r
- assert trueSet.containsAll( s1 );\r
-\r
- // s1 should not have anything that doesn't appear in trueset\r
- Set<VariableSourceToken> sInt = (Set<VariableSourceToken>) s1.clone();\r
- sInt.removeAll( trueSet );\r
-\r
- assert sInt.isEmpty();\r
-\r
- // add s1 to a running union--at the end check if trueSet has extra\r
- trueSetByAlts.addAll( s1 );\r
- }\r
- // make sure trueSet isn't too big\r
- assert trueSetByAlts.containsAll( trueSet );\r
-\r
-\r
- trueSetByAlts = new HashSet<VariableSourceToken>();\r
- itr = var2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- TempDescriptor var = (TempDescriptor) me.getKey();\r
- HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue(); \r
- assert s1 != null;\r
- \r
- // the trueSet should have all entries in s1\r
- assert trueSet.containsAll( s1 );\r
-\r
- // s1 should not have anything that doesn't appear in trueset\r
- Set<VariableSourceToken> sInt = (Set<VariableSourceToken>) s1.clone();\r
- sInt.removeAll( trueSet );\r
-\r
- assert sInt.isEmpty();\r
-\r
- // add s1 to a running union--at the end check if trueSet has extra\r
- trueSetByAlts.addAll( s1 );\r
- }\r
- // make sure trueSet isn't too big\r
- assert trueSetByAlts.containsAll( trueSet );\r
-\r
-\r
- trueSetByAlts = new HashSet<VariableSourceToken>();\r
- itr = sv2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- SVKey key = (SVKey) me.getKey();\r
- HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue(); \r
- assert s1 != null;\r
- \r
- // the trueSet should have all entries in s1\r
- assert trueSet.containsAll( s1 );\r
-\r
- // s1 should not have anything that doesn't appear in trueset\r
- Set<VariableSourceToken> sInt = (Set<VariableSourceToken>) s1.clone();\r
- sInt.removeAll( trueSet );\r
-\r
- assert sInt.isEmpty();\r
-\r
- // add s1 to a running union--at the end check if trueSet has extra\r
- trueSetByAlts.addAll( s1 );\r
- }\r
- // make sure trueSet isn't too big\r
- assert trueSetByAlts.containsAll( trueSet );\r
- }\r
-\r
-\r
- public boolean equals( Object o ) {\r
- if( o == null ) {\r
- return false;\r
- }\r
-\r
- if( !(o instanceof VarSrcTokTable) ) {\r
- return false;\r
- }\r
-\r
- VarSrcTokTable table = (VarSrcTokTable) o;\r
- return trueSet.equals( table.trueSet );\r
- }\r
-\r
- public int hashCode() {\r
- return trueSet.hashCode();\r
- }\r
-\r
- public Iterator<VariableSourceToken> iterator() {\r
- return trueSet.iterator();\r
- }\r
-\r
- public String toString() {\r
- return "trueSet ="+trueSet.toString();\r
- }\r
-\r
- public String toStringVerbose() {\r
- return "trueSet ="+trueSet.toString()+"\n"+\r
- "sese2vst="+sese2vst.toString()+"\n"+\r
- "var2vst ="+var2vst.toString()+"\n"+\r
- "sv2vst ="+sv2vst.toString();\r
- }\r
-\r
- public String toStringPretty() {\r
- String tokHighlighter = "o";\r
-\r
- String str = "VarSrcTokTable\n";\r
- Iterator<VariableSourceToken> vstItr = trueSet.iterator(); \r
- while( vstItr.hasNext() ) {\r
- str += " "+tokHighlighter+" "+vstItr.next()+"\n";\r
- }\r
- return str;\r
- }\r
-\r
- public String toStringPrettyVerbose() {\r
- String tokHighlighter = "o";\r
-\r
- String str = "VarSrcTokTable\n";\r
-\r
- Set s;\r
- Iterator itr; \r
- Iterator<VariableSourceToken> vstItr;\r
-\r
- str += " trueSet\n";\r
- vstItr = trueSet.iterator(); \r
- while( vstItr.hasNext() ) {\r
- str += " "+tokHighlighter+" "+vstItr.next()+"\n";\r
- }\r
-\r
- str += " sese2vst\n";\r
- itr = sese2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();\r
- HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue(); \r
- assert s1 != null;\r
-\r
- str += " "+sese.getPrettyIdentifier()+" -> \n";\r
-\r
- vstItr = s1.iterator();\r
- while( vstItr.hasNext() ) {\r
- str += " "+tokHighlighter+" "+vstItr.next()+"\n";\r
- }\r
- }\r
-\r
- str += " var2vst\n";\r
- itr = var2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- TempDescriptor var = (TempDescriptor) me.getKey();\r
- Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();\r
- assert s1 != null;\r
-\r
- str += " "+var+" -> \n";\r
-\r
- vstItr = s1.iterator();\r
- while( vstItr.hasNext() ) {\r
- str += " "+tokHighlighter+" "+vstItr.next()+"\n";\r
- }\r
- }\r
-\r
- str += " sv2vst\n";\r
- itr = sv2vst.entrySet().iterator();\r
- while( itr.hasNext() ) {\r
- Map.Entry me = (Map.Entry) itr.next();\r
- SVKey key = (SVKey) me.getKey();\r
- Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();\r
- assert s1 != null;\r
-\r
- str += " "+key+" -> \n";\r
-\r
- vstItr = s1.iterator();\r
- while( vstItr.hasNext() ) {\r
- str += " "+tokHighlighter+" "+vstItr.next()+"\n";\r
- }\r
- }\r
-\r
- return str;\r
- }\r
-}\r
+package Analysis.MLP;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+// This class formerly had lazy consistency properties, but
+// it is being changed so that the full set and the extra
+// hash tables to access the full set efficiently by different
+// elements will be consistent after EVERY operation. Also,
+// a consistent assert method allows a debugger to ask whether
+// an operation has produced an inconsistent VarSrcTokTable.
+public class VarSrcTokTable {
+
+ // a set of every token in the table
+ private HashSet<VariableSourceToken> trueSet;
+
+ // these hashtables provide an efficient retreival from the true set
+ private Hashtable< TempDescriptor, Set<VariableSourceToken> > var2vst;
+ private Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> > sese2vst;
+ private Hashtable< SVKey, Set<VariableSourceToken> > sv2vst;
+
+ // maximum age from aging operation
+ private Integer MAX_AGE = new Integer( 2 );
+
+
+ public VarSrcTokTable() {
+ trueSet = new HashSet<VariableSourceToken>();
+
+ sese2vst = new Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> >();
+ var2vst = new Hashtable< TempDescriptor, Set<VariableSourceToken> >();
+ sv2vst = new Hashtable< SVKey, Set<VariableSourceToken> >();
+ }
+
+
+ public VarSrcTokTable( VarSrcTokTable in ) {
+ trueSet = (HashSet<VariableSourceToken>) in.trueSet.clone();
+
+ Iterator itr; Set s;
+
+ sese2vst = new Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> >();
+ itr = in.sese2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();
+ HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue();
+ assert s1 != null;
+ sese2vst.put( sese,
+ (HashSet<VariableSourceToken>) (s1.clone()) );
+ }
+
+ var2vst = new Hashtable< TempDescriptor, Set<VariableSourceToken> >();
+ itr = in.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();
+ assert s1 != null;
+ var2vst.put( var,
+ (HashSet<VariableSourceToken>) (s1.clone()) );
+ }
+
+ sv2vst = new Hashtable< SVKey, Set<VariableSourceToken> >();
+ itr = in.sv2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ SVKey key = (SVKey) me.getKey();
+ HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue();
+ assert s1 != null;
+ sv2vst.put( key,
+ (HashSet<VariableSourceToken>) (s1.clone()) );
+ }
+
+ assertConsistency();
+ }
+
+
+ public void add( VariableSourceToken vst ) {
+
+ // make sure we aren't clobbering anything!
+ assert !trueSet.contains( vst );
+
+ trueSet.add( vst );
+
+ Set<VariableSourceToken> s;
+
+ s = sese2vst.get( vst.getSESE() );
+ if( s == null ) {
+ s = new HashSet<VariableSourceToken>();
+ }
+ s.add( vst );
+ sese2vst.put( vst.getSESE(), s );
+
+ Iterator<TempDescriptor> refVarItr = vst.getRefVars().iterator();
+ while( refVarItr.hasNext() ) {
+ TempDescriptor refVar = refVarItr.next();
+ s = var2vst.get( refVar );
+ if( s == null ) {
+ s = new HashSet<VariableSourceToken>();
+ }
+ s.add( vst );
+ var2vst.put( refVar, s );
+
+ SVKey key = new SVKey( vst.getSESE(), refVar );
+ s = sv2vst.get( key );
+ if( s == null ) {
+ s = new HashSet<VariableSourceToken>();
+ }
+ s.add( vst );
+ sv2vst.put( key, s );
+ }
+
+ assertConsistency();
+ }
+
+ public void addAll( Set<VariableSourceToken> s ) {
+ Iterator<VariableSourceToken> itr = s.iterator();
+ while( itr.hasNext() ) {
+ add( itr.next() );
+ }
+ }
+
+
+ public Set<VariableSourceToken> get() {
+ return trueSet;
+ }
+
+ public Set<VariableSourceToken> get( FlatSESEEnterNode sese ) {
+ Set<VariableSourceToken> s = sese2vst.get( sese );
+ if( s == null ) {
+ s = new HashSet<VariableSourceToken>();
+ sese2vst.put( sese, s );
+ }
+ return s;
+ }
+
+ public Set<VariableSourceToken> get( TempDescriptor var ) {
+ Set<VariableSourceToken> s = var2vst.get( var );
+ if( s == null ) {
+ s = new HashSet<VariableSourceToken>();
+ var2vst.put( var, s );
+ }
+ return s;
+ }
+
+ public Set<VariableSourceToken> get( FlatSESEEnterNode sese,
+ TempDescriptor refVar ) {
+ SVKey key = new SVKey( sese, refVar );
+ Set<VariableSourceToken> s = sv2vst.get( key );
+ if( s == null ) {
+ s = new HashSet<VariableSourceToken>();
+ sv2vst.put( key, s );
+ }
+ return s;
+ }
+
+ public Set<VariableSourceToken> get( FlatSESEEnterNode sese,
+ Integer age ) {
+ Set<VariableSourceToken> s = sese2vst.get( sese );
+ if( s == null ) {
+ s = new HashSet<VariableSourceToken>();
+ sese2vst.put( sese, s );
+ }
+ Iterator<VariableSourceToken> sItr = s.iterator();
+ while( sItr.hasNext() ) {
+ VariableSourceToken vst = sItr.next();
+ if( !vst.getAge().equals( age ) ) {
+ s.remove( vst );
+ }
+ }
+ return s;
+ }
+
+
+ public void merge( VarSrcTokTable tableIn ) {
+
+ if( tableIn == null ) {
+ return;
+ }
+
+ // make a copy for modification to use in the merge
+ VarSrcTokTable table = new VarSrcTokTable( tableIn );
+
+
+ trueSet.addAll( table.trueSet );
+
+
+ Iterator itr;
+
+ // merge sese2vst mappings
+ itr = this.sese2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();
+ Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();
+ Set<VariableSourceToken> s2 = table.sese2vst.get( sese );
+ assert s1 != null;
+
+ if( s2 != null ) {
+ s1.addAll( s2 );
+ }
+ }
+ itr = table.sese2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();
+ Set<VariableSourceToken> s2 = (Set<VariableSourceToken>) me.getValue();
+ Set<VariableSourceToken> s1 = this.sese2vst.get( sese );
+ assert s2 != null;
+
+ if( s1 == null ) {
+ this.sese2vst.put( sese, s2 );
+ }
+ }
+
+ // merge var2vst mappings
+ itr = this.var2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ TempDescriptor var = (TempDescriptor) me.getKey();
+ Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();
+ Set<VariableSourceToken> s2 = table.var2vst.get( var );
+ assert s1 != null;
+
+ if( s2 != null ) {
+ s1.addAll( s2 );
+ }
+ }
+ itr = table.var2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ TempDescriptor var = (TempDescriptor) me.getKey();
+ Set<VariableSourceToken> s2 = (Set<VariableSourceToken>) me.getValue();
+ Set<VariableSourceToken> s1 = this.var2vst.get( var );
+ assert s2 != null;
+
+ if( s1 == null ) {
+ this.var2vst.put( var, s2 );
+ }
+ }
+
+ // merge sv2vst mappings
+ itr = this.sv2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ SVKey key = (SVKey) me.getKey();
+ Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();
+ Set<VariableSourceToken> s2 = table.sv2vst.get( key );
+ assert s1 != null;
+
+ if( s2 != null ) {
+ s1.addAll( s2 );
+ }
+ }
+ itr = table.sv2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ SVKey key = (SVKey) me.getKey();
+ Set<VariableSourceToken> s2 = (Set<VariableSourceToken>) me.getValue();
+ Set<VariableSourceToken> s1 = this.sv2vst.get( key );
+ assert s2 != null;
+
+ if( s1 == null ) {
+ this.sv2vst.put( key, s2 );
+ }
+ }
+
+ assertConsistency();
+ }
+
+
+ // remove operations must leave the trueSet
+ // and the hash maps consistent!
+ public void remove( VariableSourceToken vst ) {
+ trueSet.remove( vst );
+
+ Set<VariableSourceToken> s;
+
+ s = get( vst.getSESE() );
+ if( s != null ) { s.remove( vst ); }
+
+ Iterator<TempDescriptor> refVarItr = vst.getRefVars().iterator();
+ while( refVarItr.hasNext() ) {
+ TempDescriptor refVar = refVarItr.next();
+
+ s = get( refVar );
+ if( s != null ) { s.remove( vst ); }
+
+ s = get( vst.getSESE(), refVar );
+ if( s != null ) { s.remove( vst ); }
+ }
+
+ assertConsistency();
+ }
+
+ public void remove( FlatSESEEnterNode sese ) {
+ Set<VariableSourceToken> s = sese2vst.get( sese );
+ if( s == null ) {
+ return;
+ }
+
+ Iterator<VariableSourceToken> itr = s.iterator();
+ while( itr.hasNext() ) {
+ VariableSourceToken vst = itr.next();
+ remove( vst );
+ }
+
+ sese2vst.remove( sese );
+
+ assertConsistency();
+ }
+
+ public void remove( TempDescriptor refVar ) {
+ Set<VariableSourceToken> s = var2vst.get( refVar );
+ if( s == null ) {
+ return;
+ }
+
+ Set<VariableSourceToken> forRemoval = new HashSet<VariableSourceToken>();
+
+ // iterate over tokens that this temp can reference, make a set
+ // of tokens that need this temp stripped out of them
+ Iterator<VariableSourceToken> itr = s.iterator();
+ while( itr.hasNext() ) {
+ VariableSourceToken vst = itr.next();
+ Set<TempDescriptor> refVars = vst.getRefVars();
+ assert refVars.contains( refVar );
+ forRemoval.add( vst );
+ }
+
+ itr = forRemoval.iterator();
+ while( itr.hasNext() ) {
+ // here's a token marked for removal, take it out as it is
+ // in this state
+ VariableSourceToken vst = itr.next();
+ remove( vst );
+
+ // if there are other references to the token, alter the
+ // token and then readd it to this table, because it has
+ // a new hash value now
+ Set<TempDescriptor> refVars = vst.getRefVars();
+ refVars.remove( refVar );
+ if( refVars.size() > 0 ) {
+ add( vst );
+ }
+ }
+
+ //var2vst.remove( var );
+
+ assertConsistency();
+ }
+
+ public void remove( FlatSESEEnterNode sese,
+ TempDescriptor var ) {
+
+ SVKey key = new SVKey( sese, var );
+ Set<VariableSourceToken> s = sv2vst.get( key );
+ if( s == null ) {
+ return;
+ }
+
+ Iterator<VariableSourceToken> itr = s.iterator();
+ while( itr.hasNext() ) {
+ VariableSourceToken vst = itr.next();
+ remove( vst );
+ }
+
+ sv2vst.remove( key );
+
+ assertConsistency();
+ }
+
+
+
+ // return a new table based on this one and
+ // age tokens with respect to SESE curr, where
+ // any curr tokens increase age by 1
+ public VarSrcTokTable age( FlatSESEEnterNode curr ) {
+
+ // create a table to modify as a copy of this
+ VarSrcTokTable out = new VarSrcTokTable( this );
+
+ Iterator<VariableSourceToken> itr = trueSet.iterator();
+ while( itr.hasNext() ) {
+ VariableSourceToken vst = itr.next();
+
+ if( vst.getSESE().equals( curr ) ) {
+
+ Integer newAge = vst.getAge()+1;
+ if( newAge > MAX_AGE ) {
+ newAge = MAX_AGE;
+ }
+
+ out.remove( vst );
+
+ out.add( new VariableSourceToken( vst.getRefVars(),
+ curr,
+ newAge,
+ vst.getAddrVar()
+ )
+ );
+ }
+ }
+
+ out.assertConsistency();
+ return out;
+ }
+
+
+ // for the given SESE, change child tokens into this parent
+ public void remapChildTokens( FlatSESEEnterNode curr ) {
+
+ Iterator<FlatSESEEnterNode> childItr = curr.getChildren().iterator();
+ if( childItr.hasNext() ) {
+ FlatSESEEnterNode child = childItr.next();
+
+ Iterator<VariableSourceToken> vstItr = get( child ).iterator();
+ while( vstItr.hasNext() ) {
+ VariableSourceToken vst = vstItr.next();
+
+ remove( vst );
+
+ add( new VariableSourceToken( vst.getRefVars(),
+ curr,
+ new Integer( 0 ),
+ vst.getAddrVar()
+ )
+ );
+ }
+ }
+
+ assertConsistency();
+ }
+
+
+ // if we can get a value from the current SESE and the parent
+ // or a sibling, just getting from the current SESE suffices now
+ // return a set of temps that are virtually read
+ public Set<TempDescriptor> removeParentAndSiblingTokens( FlatSESEEnterNode curr,
+ Set<TempDescriptor> liveIn ) {
+
+ HashSet<TempDescriptor> virtualLiveIn = new HashSet<TempDescriptor>();
+
+ FlatSESEEnterNode parent = curr.getParent();
+ if( parent == null ) {
+ // have no parent or siblings
+ return virtualLiveIn;
+ }
+
+ remove_A_if_B( parent, curr, liveIn, virtualLiveIn );
+
+ Iterator<FlatSESEEnterNode> childItr = parent.getChildren().iterator();
+ if( childItr.hasNext() ) {
+ FlatSESEEnterNode child = childItr.next();
+
+ if( !child.equals( curr ) ) {
+ remove_A_if_B( child, curr, liveIn, virtualLiveIn );
+ }
+ }
+
+ assertConsistency();
+ return virtualLiveIn;
+ }
+
+ // if B is also a source for some variable, remove all entries
+ // of A as a source for that variable: s is virtual reads
+ protected void remove_A_if_B( FlatSESEEnterNode a,
+ FlatSESEEnterNode b,
+ Set<TempDescriptor> liveInCurrentSESE,
+ Set<TempDescriptor> virtualLiveIn ) {
+
+ Set<VariableSourceToken> forRemoval = new HashSet<VariableSourceToken>();
+
+ Iterator<VariableSourceToken> vstItr = get( a ).iterator();
+ while( vstItr.hasNext() ) {
+ VariableSourceToken vst = vstItr.next();
+ Iterator<TempDescriptor> refVarItr = vst.getRefVars().iterator();
+ while( refVarItr.hasNext() ) {
+ TempDescriptor refVar = refVarItr.next();
+ Set<VariableSourceToken> bSet = get( b, refVar );
+
+ if( !bSet.isEmpty() ) {
+ forRemoval.add( vst );
+
+ // mark this variable as a virtual read as well
+ virtualLiveIn.add( refVar );
+ }
+ }
+ }
+
+ vstItr = forRemoval.iterator();
+ while( vstItr.hasNext() ) {
+ VariableSourceToken vst = vstItr.next();
+ remove( vst );
+ }
+ }
+
+
+ public Set<VariableSourceToken> getStallSet( FlatSESEEnterNode curr ) {
+
+ Set<VariableSourceToken> out = new HashSet<VariableSourceToken>();
+
+ Iterator<FlatSESEEnterNode> cItr = curr.getChildren().iterator();
+ while( cItr.hasNext() ) {
+ FlatSESEEnterNode child = cItr.next();
+ out.addAll( get( child ) );
+ }
+
+ return out;
+ }
+
+
+ // use as an aid for debugging, where true-set is checked
+ // against the alternate mappings: assert that nothing is
+ // missing or extra in the alternates
+ public void assertConsistency() {
+
+ Iterator itr;
+ Set s;
+
+ Set<VariableSourceToken> trueSetByAlts = new HashSet<VariableSourceToken>();
+ itr = sese2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();
+ HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue();
+ assert s1 != null;
+
+ // the trueSet should have all entries in s1
+ assert trueSet.containsAll( s1 );
+
+ // s1 should not have anything that doesn't appear in trueset
+ Set<VariableSourceToken> sInt = (Set<VariableSourceToken>) s1.clone();
+ sInt.removeAll( trueSet );
+
+ assert sInt.isEmpty();
+
+ // add s1 to a running union--at the end check if trueSet has extra
+ trueSetByAlts.addAll( s1 );
+ }
+ // make sure trueSet isn't too big
+ assert trueSetByAlts.containsAll( trueSet );
+
+
+ trueSetByAlts = new HashSet<VariableSourceToken>();
+ 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();
+ assert s1 != null;
+
+ // the trueSet should have all entries in s1
+ assert trueSet.containsAll( s1 );
+
+ // s1 should not have anything that doesn't appear in trueset
+ Set<VariableSourceToken> sInt = (Set<VariableSourceToken>) s1.clone();
+ sInt.removeAll( trueSet );
+
+ assert sInt.isEmpty();
+
+ // add s1 to a running union--at the end check if trueSet has extra
+ trueSetByAlts.addAll( s1 );
+ }
+ // make sure trueSet isn't too big
+ assert trueSetByAlts.containsAll( trueSet );
+
+
+ trueSetByAlts = new HashSet<VariableSourceToken>();
+ itr = sv2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ SVKey key = (SVKey) me.getKey();
+ HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue();
+ assert s1 != null;
+
+ // the trueSet should have all entries in s1
+ assert trueSet.containsAll( s1 );
+
+ // s1 should not have anything that doesn't appear in trueset
+ Set<VariableSourceToken> sInt = (Set<VariableSourceToken>) s1.clone();
+ sInt.removeAll( trueSet );
+
+ assert sInt.isEmpty();
+
+ // add s1 to a running union--at the end check if trueSet has extra
+ trueSetByAlts.addAll( s1 );
+ }
+ // make sure trueSet isn't too big
+ assert trueSetByAlts.containsAll( trueSet );
+
+
+ // also check that the reference var sets are consistent
+ Hashtable<VariableSourceToken, Set<TempDescriptor> > vst2refVars =
+ new Hashtable<VariableSourceToken, Set<TempDescriptor> >();
+ itr = var2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ TempDescriptor refVar = (TempDescriptor) me.getKey();
+ HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue();
+ Iterator<VariableSourceToken> vstItr = s1.iterator();
+ while( vstItr.hasNext() ) {
+ VariableSourceToken vst = vstItr.next();
+ assert vst.getRefVars().contains( refVar );
+
+ Set<TempDescriptor> refVarsPart = vst2refVars.get( vst );
+ if( refVarsPart == null ) {
+ refVarsPart = new HashSet<TempDescriptor>();
+ }
+ refVarsPart.add( refVar );
+ vst2refVars.put( vst, refVarsPart );
+ }
+ }
+ itr = vst2refVars.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ VariableSourceToken vst = (VariableSourceToken) me.getKey();
+ Set<TempDescriptor> s1 = (Set<TempDescriptor>) me.getValue();
+ assert vst.getRefVars().equals( s1 );
+ }
+ }
+
+
+ public boolean equals( Object o ) {
+ if( o == null ) {
+ return false;
+ }
+
+ if( !(o instanceof VarSrcTokTable) ) {
+ return false;
+ }
+
+ VarSrcTokTable table = (VarSrcTokTable) o;
+ return trueSet.equals( table.trueSet );
+ }
+
+ public int hashCode() {
+ return trueSet.hashCode();
+ }
+
+ public Iterator<VariableSourceToken> iterator() {
+ return trueSet.iterator();
+ }
+
+ public String toString() {
+ return "trueSet ="+trueSet.toString();
+ }
+
+ public String toStringVerbose() {
+ return "trueSet ="+trueSet.toString()+"\n"+
+ "sese2vst="+sese2vst.toString()+"\n"+
+ "var2vst ="+var2vst.toString()+"\n"+
+ "sv2vst ="+sv2vst.toString();
+ }
+
+ public String toStringPretty() {
+ String tokHighlighter = "o";
+
+ String str = "VarSrcTokTable\n";
+ Iterator<VariableSourceToken> vstItr = trueSet.iterator();
+ while( vstItr.hasNext() ) {
+ str += " "+tokHighlighter+" "+vstItr.next()+"\n";
+ }
+ return str;
+ }
+
+ public String toStringPrettyVerbose() {
+ String tokHighlighter = "o";
+
+ String str = "VarSrcTokTable\n";
+
+ Set s;
+ Iterator itr;
+ Iterator<VariableSourceToken> vstItr;
+
+ str += " trueSet\n";
+ vstItr = trueSet.iterator();
+ while( vstItr.hasNext() ) {
+ str += " "+tokHighlighter+" "+vstItr.next()+"\n";
+ }
+
+ str += " sese2vst\n";
+ itr = sese2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey();
+ HashSet<VariableSourceToken> s1 = (HashSet<VariableSourceToken>) me.getValue();
+ assert s1 != null;
+
+ str += " "+sese.getPrettyIdentifier()+" -> \n";
+
+ vstItr = s1.iterator();
+ while( vstItr.hasNext() ) {
+ str += " "+tokHighlighter+" "+vstItr.next()+"\n";
+ }
+ }
+
+ str += " var2vst\n";
+ itr = var2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ TempDescriptor var = (TempDescriptor) me.getKey();
+ Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();
+ assert s1 != null;
+
+ str += " "+var+" -> \n";
+
+ vstItr = s1.iterator();
+ while( vstItr.hasNext() ) {
+ str += " "+tokHighlighter+" "+vstItr.next()+"\n";
+ }
+ }
+
+ str += " sv2vst\n";
+ itr = sv2vst.entrySet().iterator();
+ while( itr.hasNext() ) {
+ Map.Entry me = (Map.Entry) itr.next();
+ SVKey key = (SVKey) me.getKey();
+ Set<VariableSourceToken> s1 = (Set<VariableSourceToken>) me.getValue();
+ assert s1 != null;
+
+ str += " "+key+" -> \n";
+
+ vstItr = s1.iterator();
+ while( vstItr.hasNext() ) {
+ str += " "+tokHighlighter+" "+vstItr.next()+"\n";
+ }
+ }
+
+ return str;
+ }
+}