import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
+import java.util.Iterator;
import java.util.List;
import java.util.Hashtable;
return nodetotemps;
}
+ public static Hashtable<FlatNode, Set<TempDescriptor>> computeLiveOut(FlatMethod fm) {
+ Hashtable<FlatNode, Set<TempDescriptor>> liveinmap=computeLiveTemps(fm);
+ Hashtable<FlatNode, Set<TempDescriptor>> liveoutmap=new Hashtable<FlatNode, Set<TempDescriptor>>();
+
+ for(Iterator<FlatNode> fnit=fm.getNodeSet().iterator(); fnit.hasNext();) {
+ FlatNode fn=fnit.next();
+ liveoutmap.put(fn, new HashSet<TempDescriptor>());
+ for(int i=0;i<fn.numNext();i++) {
+ FlatNode fn2=fn.getNext(i);
+ liveoutmap.get(fn).addAll(liveinmap.get(fn2));
+ }
+ }
+ return liveoutmap;
+ }
}
\ No newline at end of file
/* This methods takes in a FlatMethod and returns a map from a
* FlatNode to the set of live temps for that FlatNode.*/
- public static Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> computeReachingDefs(FlatMethod fm, Hashtable<FlatNode, Set<TempDescriptor>> livemap) {
+ /* liveintoset if true computes the reaching defs into the node and if false computes the reaching defs out of the node. */
+
+ public static Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> computeReachingDefs(FlatMethod fm, Hashtable<FlatNode, Set<TempDescriptor>> livemap, boolean liveintoset) {
Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> nodetotemps=new Hashtable<FlatNode, Hashtable<TempDescriptor,Set<FlatNode>>>();
+
+ Hashtable<FlatNode, Hashtable<TempDescriptor, Set<FlatNode>>> liveinto=liveintoset?new Hashtable<FlatNode, Hashtable<TempDescriptor,Set<FlatNode>>>():null;
+
Set<FlatNode> toprocess=fm.getNodeSet();
}
}
}
+
+ if (liveintoset) {
+ liveinto.put(fn, new Hashtable<TempDescriptor, Set<FlatNode>>(tempset));
+ }
TempDescriptor writes[]=fn.writesTemps();
for(int i=0;i<writes.length;i++) {
toprocess.add(fn.getNext(i));
}
}
- return nodetotemps;
+ return liveintoset?liveinto:nodetotemps;
}
}
\ No newline at end of file