package Analysis; 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 temps that are live into the FlatNode.*/ 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(); while(!toprocess.isEmpty()) { FlatNode fn=toprocess.iterator().next(); toprocess.remove(fn); List reads=Arrays.asList(fn.readsTemps()); List writes=Arrays.asList(fn.writesTemps()); HashSet tempset=new HashSet(); for(int i=0; ithreshold){ 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 ); } }