From 83c50bb5590a10748574a8bd0007ffb0b600102e Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 24 Jun 2009 08:35:31 +0000 Subject: [PATCH] changes --- .../Analysis/Locality/DelayComputation.java | 48 +++++++++++--- .../Analysis/Locality/DiscoverConflicts.java | 4 +- .../src/Analysis/Loops/CopyPropagation.java | 1 + Robust/src/IR/Flat/BuildCode.java | 63 ++++++++++++++----- 4 files changed, 94 insertions(+), 22 deletions(-) diff --git a/Robust/src/Analysis/Locality/DelayComputation.java b/Robust/src/Analysis/Locality/DelayComputation.java index b65ef1a1..5e0ffd1d 100644 --- a/Robust/src/Analysis/Locality/DelayComputation.java +++ b/Robust/src/Analysis/Locality/DelayComputation.java @@ -88,7 +88,7 @@ public class DelayComputation { } //This method computes which temps are live into the second part - public Set liveinto(LocalityBinding lb, FlatAtomicEnterNode faen, Set liveset) { + public Set liveinto(LocalityBinding lb, FlatAtomicEnterNode faen, Set recordset) { MethodDescriptor md=lb.getMethod(); FlatMethod fm=state.getMethodFlat(md); Set atomicnodes=faen.getReachableSet(faen.getExits()); @@ -96,7 +96,7 @@ public class DelayComputation { //Compute second part set of nodes Set secondpart=new HashSet(); secondpart.addAll(getNotReady(lb)); - secondpart.addAll(liveset); + secondpart.addAll(recordset); //make it just this transaction secondpart.retainAll(atomicnodes); @@ -106,7 +106,8 @@ public class DelayComputation { for(Iterator fnit=secondpart.iterator();fnit.hasNext();) { FlatNode fn=fnit.next(); - + if (recordset.contains(fn)) + continue; TempDescriptor readset[]=fn.readsTemps(); for(int i=0;i getNext(FlatNode fn, int i, HashSet delayset) { + public static Set getBranchNodes(FlatNode fn, int i, Set delayset) { + FlatNode fnnext=fn.getNext(i); + HashSet reachable=new HashSet(); + + if (delayset.contains(fnnext)) { + reachable.add(fnnext); + return reachable; + } + + Stack nodes=new Stack(); + HashSet visited=new HashSet(); + nodes.push(fnnext); + visited.add(fn);//don't go back to the start node + + while(!nodes.isEmpty()) { + FlatNode fn2=nodes.pop(); + if (visited.contains(fn2)) + continue; + visited.add(fn2); + for (int j=0;j getNext(FlatNode fn, int i, Set delayset) { FlatNode fnnext=fn.getNext(i); HashSet reachable=new HashSet(); @@ -409,9 +439,13 @@ public class DelayComputation { nodelayarrayrdset.addAll(typeanalysis.expandSet(gft.getArraysRdAll(mdcall))); } - // Can't delay branches + //Delay branches if possible if (fn.kind()==FKind.FlatCondBranch) { - isnodelay=true; + Set leftset=getBranchNodes(fn, 0, cannotdelay); + Set rightset=getBranchNodes(fn, 1, cannotdelay); + if (leftset.size()>0&&rightset.size()>0&& + !leftset.equals(rightset)) + isnodelay=true; } //Check for field conflicts diff --git a/Robust/src/Analysis/Locality/DiscoverConflicts.java b/Robust/src/Analysis/Locality/DiscoverConflicts.java index 197e735b..f0acbd48 100644 --- a/Robust/src/Analysis/Locality/DiscoverConflicts.java +++ b/Robust/src/Analysis/Locality/DiscoverConflicts.java @@ -209,10 +209,12 @@ public class DiscoverConflicts { //or a method we called FlatGlobalConvNode fgcn=(FlatGlobalConvNode)fn; - if (fgcn.getLocality()!=lb) + if (fgcn.getLocality()!=lb|| + fgcn.getMakePtr()) break; Set tfpset=tmap.get(fgcn.getSrc()); + if (tfpset!=null) { for(Iterator tfpit=tfpset.iterator();tfpit.hasNext();) { TempFlatPair tfp=tfpit.next(); diff --git a/Robust/src/Analysis/Loops/CopyPropagation.java b/Robust/src/Analysis/Loops/CopyPropagation.java index 85ca787f..e151f82a 100644 --- a/Robust/src/Analysis/Loops/CopyPropagation.java +++ b/Robust/src/Analysis/Loops/CopyPropagation.java @@ -14,6 +14,7 @@ public class CopyPropagation { Hashtable> table =new Hashtable>(); boolean changed=false; + TempDescriptor bogustd=new TempDescriptor("bogus"); do { changed=false; HashSet tovisit=new HashSet(); diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 48f20209..2379220f 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1912,6 +1912,7 @@ public class BuildCode { Set storeset=null; HashSet genset=null; + Set unionset=null; if (state.DELAYCOMP&&!lb.isAtomic()&&lb.getHasAtomic()) { storeset=delaycomp.livecode(lb); @@ -1922,6 +1923,9 @@ public class BuildCode { } else { genset.addAll(delaycomp.getNotReady(lb)); } + unionset=new HashSet(); + unionset.addAll(storeset); + unionset.addAll(genset); } /* Do the actual code generation */ @@ -2016,31 +2020,62 @@ public class BuildCode { } else if (current_node.numNext()==2) { /* Branch */ if (state.DELAYCOMP) { + boolean computeside=false; if (firstpass) { //need to record which way it should go - output.print(" "); - if (storeset!=null&&storeset.contains(current_node)) { - //need to store which way branch goes - generateStoreFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); - } else - generateFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + if (genset==null||genset.contains(current_node)) { + if (storeset!=null&&storeset.contains(current_node)) { + //need to store which way branch goes + generateStoreFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + } else + generateFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + } else { + //which side to execute + computeside=true; + } } else { - if (storeset.contains(current_node)) { + if (genset.contains(current_node)) { + generateFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + } else if (storeset.contains(current_node)) { //need to do branch output.println("RESTOREANDBRANCH(L"+nodetolabel.get(current_node.getNext(1))+");"); + } else { + //which side to execute + computeside=true; + } + } + if (computeside) { + Set leftset=DelayComputation.getBranchNodes(current_node, 0, unionset); + int branch=0; + if (leftset.size()==0) + branch=1; + if (visited.contains(current_node.getNext(branch))) { + //already visited -- build jump + output.println("goto L"+nodetolabel.get(current_node.getNext(branch))+";"); + current_node=null; + } else { + current_node=current_node.getNext(branch); } + } else { + if (!visited.contains(current_node.getNext(1))) + tovisit.add(current_node.getNext(1)); + if (visited.contains(current_node.getNext(0))) { + output.println("goto L"+nodetolabel.get(current_node.getNext(0))+";"); + current_node=null; + } else + current_node=current_node.getNext(0); } } else { output.print(" "); generateFlatCondBranch(fm, lb, (FlatCondBranch)current_node, "L"+nodetolabel.get(current_node.getNext(1)), output); + if (!visited.contains(current_node.getNext(1))) + tovisit.add(current_node.getNext(1)); + if (visited.contains(current_node.getNext(0))) { + output.println("goto L"+nodetolabel.get(current_node.getNext(0))+";"); + current_node=null; + } else + current_node=current_node.getNext(0); } - if (!visited.contains(current_node.getNext(1))) - tovisit.add(current_node.getNext(1)); - if (visited.contains(current_node.getNext(0))) { - output.println("goto L"+nodetolabel.get(current_node.getNext(0))+";"); - current_node=null; - } else - current_node=current_node.getNext(0); } else throw new Error(); } } -- 2.34.1