From 6135e3bd176a07ccaf3759807ba1abe9a4544381 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Fri, 3 Apr 2009 22:15:38 +0000 Subject: [PATCH] changes --- Robust/src/Analysis/Loops/CSE.java | 92 +++++++++++++++++++++++------- Robust/src/Tests/dotest | 2 +- 2 files changed, 72 insertions(+), 22 deletions(-) diff --git a/Robust/src/Analysis/Loops/CSE.java b/Robust/src/Analysis/Loops/CSE.java index 0454068e..76adcd85 100644 --- a/Robust/src/Analysis/Loops/CSE.java +++ b/Robust/src/Analysis/Loops/CSE.java @@ -37,27 +37,8 @@ public class CSE { discovered.add(nnext); } } - Hashtable tab=new Hashtable(); - boolean first=true; - - //compute intersection - for(int i=0;i table=availexpr.get(prev); - for(Iterator mapit=tab.entrySet().iterator();mapit.hasNext();) { - Object entry=mapit.next(); - if (!table.contains(entry)) - mapit.remove(); - } - } - } - } + Hashtable tab=computeIntersection(fn, availexpr); + //Do kills of expression/variable mappings TempDescriptor[] write=fn.writesTemps(); for(int i=0;i> availexpr) { + for(Iterator it=fm.getNodeSet().iterator();it.hasNext();) { + FlatNode fn=it.next(); + Hashtable tab=computeIntersection(fn, availexpr); + switch(fn.kind()) { + case FKind.FlatOpNode: + { + FlatOpNode fon=(FlatOpNode) fn; + Expression e=new Expression(fon.getLeft(), fon.getRight(),fon.getOp()); + if (tab.containsKey(e)) { + TempDescriptor t=tab.get(e); + FlatOpNode newfon=new FlatOpNode(fon.getDest(),t,null,new Operation(Operation.ASSIGN)); + fon.replace(newfon); + } + break; + } + case FKind.FlatFieldNode: + { + FlatFieldNode ffn=(FlatFieldNode)fn; + Expression e=new Expression(ffn.getSrc(), ffn.getField()); + if (tab.containsKey(e)) { + TempDescriptor t=tab.get(e); + FlatOpNode newfon=new FlatOpNode(ffn.getDst(),t,null,new Operation(Operation.ASSIGN)); + ffn.replace(newfon); + } + break; + } + case FKind.FlatElementNode: + { + FlatElementNode fen=(FlatElementNode)fn; + Expression e=new Expression(fen.getSrc(),fen.getIndex()); + if (tab.containsKey(e)) { + TempDescriptor t=tab.get(e); + FlatOpNode newfon=new FlatOpNode(fen.getDst(),t,null,new Operation(Operation.ASSIGN)); + fen.replace(newfon); + } + break; + } + default: + } + } + } + + public Hashtable computeIntersection(FlatNode fn, Hashtable> availexpr) { + Hashtable tab=new Hashtable(); + boolean first=true; + + //compute intersection + for(int i=0;i table=availexpr.get(prev); + for(Iterator mapit=tab.entrySet().iterator();mapit.hasNext();) { + Object entry=mapit.next(); + if (!table.contains(entry)) + mapit.remove(); + } + } + } + } + return tab; } public void killexpressions(Hashtable tab, Set fields, Set arrays) { diff --git a/Robust/src/Tests/dotest b/Robust/src/Tests/dotest index 20ed204c..63fed7f5 100755 --- a/Robust/src/Tests/dotest +++ b/Robust/src/Tests/dotest @@ -7,7 +7,7 @@ shift dir=`pwd` echo Doing Test $ARG1 -../buildscript -robustroot ${dir}/../ -mainclass $ARG1 $ARG2 -o $ARG1 &>/dev/null +../buildscript -joptimize -robustroot ${dir}/../ -mainclass $ARG1 $ARG2 -o $ARG1 $ARG1.bin $@ &> output/$ARG1.output diff output/$ARG1.output output/$ARG1.output.goal rm $ARG1.bin -- 2.34.1