From: bdemsky Date: Fri, 19 Jun 2009 23:27:14 +0000 (+0000) Subject: Move liveness analysis into its own class X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=add273a631dd21a83478e47b30e8eecbeeee5579;p=IRC.git Move liveness analysis into its own class --- diff --git a/Robust/src/Analysis/Liveness.java b/Robust/src/Analysis/Liveness.java new file mode 100644 index 00000000..6fe3a671 --- /dev/null +++ b/Robust/src/Analysis/Liveness.java @@ -0,0 +1,44 @@ +package Analysis; + +import IR.Flat.*; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; +import java.util.List; +import java.util.Hashtable; + +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.*/ + + public static Hashtable> computeLiveTemps(FlatMethod fm) { + 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; i