X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FLiveness.java;h=1374b24e14c265e91f5b86cfc711a58622a6dfd4;hp=6fe3a671839072246c222ed932d04fce3d2a029c;hb=b124b7bf09a5eed6e272119acba9cfc5a1374b60;hpb=add273a631dd21a83478e47b30e8eecbeeee5579 diff --git a/Robust/src/Analysis/Liveness.java b/Robust/src/Analysis/Liveness.java index 6fe3a671..1374b24e 100644 --- a/Robust/src/Analysis/Liveness.java +++ b/Robust/src/Analysis/Liveness.java @@ -4,14 +4,19 @@ import IR.Flat.*; import java.util.Arrays; import java.util.HashSet; import java.util.Set; +import java.util.Iterator; import java.util.List; import java.util.Hashtable; +import Analysis.Locality.*; public class Liveness { /* This methods takes in a FlatMethod and returns a map from a - * FlatNode to the set of live temps for that FlatNode.*/ + * FlatNode to the set of temps that are live into the FlatNode.*/ - public static Hashtable> computeLiveTemps(FlatMethod fm) { + public static Hashtable> computeLiveTemps(FlatMethod fm, int threshold) { + return computeLiveTemps(fm, null, threshold); + } + public static Hashtable> computeLiveTemps(FlatMethod fm, LocalityBinding lb, int threshold) { Hashtable> nodetotemps=new Hashtable>(); Set toprocess=fm.getNodeSet(); @@ -29,11 +34,17 @@ public class Liveness { if (nodetotemps.containsKey(fnnext)) tempset.addAll(nodetotemps.get(fnnext)); } - tempset.removeAll(writes); - tempset.addAll(reads); + if ((lb==null)||(!(fn instanceof FlatGlobalConvNode))|| + ((FlatGlobalConvNode)fn).getLocality()==lb) { + tempset.removeAll(writes); + tempset.addAll(reads); + } if (!nodetotemps.containsKey(fn)|| !nodetotemps.get(fn).equals(tempset)) { nodetotemps.put(fn, tempset); + if(threshold!=-1 && nodetotemps.size()>threshold){ + return null; + } for(int i=0; i> computeLiveOut(FlatMethod fm) { + return computeLiveOut(fm, null); + } + + public static Hashtable> computeLiveOut(FlatMethod fm, LocalityBinding lb) { + Hashtable> liveinmap=computeLiveTemps(fm, lb,-1); + Hashtable> liveoutmap=new Hashtable>(); + + for(Iterator fnit=fm.getNodeSet().iterator(); fnit.hasNext();) { + FlatNode fn=fnit.next(); + liveoutmap.put(fn, new HashSet()); + for(int i=0;i > > fm2liveMap; + + protected Hashtable< FlatMethod, Hashtable< FlatNode, Set > > fm2liveOutMap; + + public Liveness() { + fm2liveMap = new Hashtable< FlatMethod, Hashtable< FlatNode, Set > >(); + fm2liveOutMap = new Hashtable< FlatMethod, Hashtable< FlatNode, Set > >(); + } + + public Set getLiveOutTemps( FlatMethod fm, FlatNode fn ) { + if( !fm2liveOutMap.containsKey( fm ) ) { + fm2liveOutMap.put( fm, Liveness.computeLiveOut( fm ) ); + } + return fm2liveOutMap.get( fm ).get( fn ); + } + + public Set getLiveInTemps( FlatMethod fm, FlatNode fn ) { + if( !fm2liveMap.containsKey( fm ) ) { + fm2liveMap.put( fm, Liveness.computeLiveTemps( fm,-1 ) ); + } + return fm2liveMap.get( fm ).get( fn ); + } } \ No newline at end of file