import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
+import IR.State;
import Analysis.Disjoint.AllocSite;
import Analysis.Disjoint.DisjointAnalysis;
public static final int NON_WRITE_CONFLICT = 0;
public static final int FINE_GRAIN_EDGE = 1;
public static final int COARSE_GRAIN_EDGE = 2;
- public static final int CONFLICT = 3;
+
+ State state;
- public ConflictGraph() {
+ public ConflictGraph(State state) {
+ this.state=state;
id2cn = new Hashtable<String, ConflictNode>();
sese2te = new Hashtable<FlatNode, Hashtable<Taint, Set<Effect>>>();
}
TempDescriptor invar = t.getVar();
AllocSite as = t.getAllocSite();
- String id = invar + "_sese" + sese.getIdentifier();
+ String id = invar + "_sese" + sese.getPrettyIdentifier();
ConflictNode node = id2cn.get(id);
if (node == null) {
node = new ConflictNode(id, ConflictNode.INVAR, t.getVar(), t.getSESE());
conflictType = updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
}
} else {
- return ConflictGraph.CONFLICT;
+ if (state.RCR) {
+ // need coarse effects for RCR from just one pass
+ addCoarseEffect(nodeA, asA, strongUpdateA);
+ if (!nodeA.equals(nodeB)) {
+ addCoarseEffect(nodeB, asB, effectB);
+ }
+ conflictType=ConflictGraph.COARSE_GRAIN_EDGE;
+ } else {
+ return ConflictGraph.COARSE_GRAIN_EDGE;
+ }
}
}
conflictType = updateConflictType(conflictType, ConflictGraph.COARSE_GRAIN_EDGE);
}
} else {
- return ConflictGraph.CONFLICT;
+ return ConflictGraph.COARSE_GRAIN_EDGE;
}
}
}
}
} else {
- return ConflictGraph.CONFLICT;
+ if (state.RCR) {
+ // need coarse effects for RCR from just one pass
+ addCoarseEffect(nodeA, asA, effectA);
+ if (!nodeA.equals(nodeB)) {
+ addCoarseEffect(nodeB, asB, effectB);
+ }
+ conflictType=ConflictGraph.COARSE_GRAIN_EDGE;
+ } else {
+ return ConflictGraph.COARSE_GRAIN_EDGE;
+ }
}
}
}
WaitingElement newElement = new WaitingElement();
newElement.setQueueID(seseLock.getID());
newElement.setStatus(seseLock.getNodeType(node));
+ newElement.setTempDesc(node.getVar());
if (isFineElement(newElement.getStatus())) {
- newElement.setDynID(node.getVar().toString());
- newElement.setTempDesc(node.getVar());
+ newElement.setDynID(node.getVar().toString());
}
if (!waitingElementSet.contains(newElement)) {
waitingElementSet.add(newElement);
// handle the case that multiple enqueues by an SESE for different live-in
// into the same queue
- return refineQueue(waitingElementSet);
- // return waitingElementSet;
+ return refineQueue(waitingElementSet);
}
set.add(waitingElement);
map.put(new Integer(waitingElement.getQueueID()), set);
}
-
+
Set<Integer> keySet = map.keySet();
for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
Integer queueID = (Integer) iterator.next();
SCCelement = waitingElement;
}
}
-
if (SCCelement != null) {
// if there is at lease one SCC element, just enqueue SCC and
// ignore others.
+ if(state.RCR){
+ // for rcr, we need to label all of coarse tempdescriptors
+ // here assume that all waiting elements are coarse
+ for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
+ WaitingElement waitingElement = (WaitingElement) iterator.next();
+ SCCelement.addTempDesc(waitingElement.getTempDesc());
+ if(waitingElement!=SCCelement){
+ waitingElement.setBogus(true);
+ refinedSet.add(waitingElement);
+ }
+ }
+ }
refinedSet.add(SCCelement);
- } else if (numCoarse == 1 && (numRead + numWrite + numCoarse == total)) {
+ } else if (numCoarse == 1 && (numRead + numWrite == total)) {
// if one is a coarse, the othere are reads/write, enqueue SCC.
WaitingElement we = new WaitingElement();
we.setQueueID(queueID);
refinedSet.add(we);
} else if (numCoarse == total) {
// if there are multiple coarses, enqueue just one coarse.
+ if(state.RCR){
+ // for rcr, we need to label all of coarse tempdescriptors
+ for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
+ WaitingElement waitingElement = (WaitingElement) iterator.next();
+ if(waitingElement!=coarseElement){
+ coarseElement.addTempDesc(waitingElement.getTempDesc());
+ waitingElement.setBogus(true);
+ refinedSet.add(waitingElement);
+ }
+ }
+ }
refinedSet.add(coarseElement);
} else if (numWrite == total || (numRead + numWrite) == total) {
// code generator is going to handle the case for multiple writes &
newElement.setStatus(seseLock.getNodeType(node));
if (isFineElement(newElement.getStatus())) {
newElement.setDynID(node.getVar().toString());
- newElement.setTempDesc(node.getVar());
}
+ newElement.setTempDesc(node.getVar());
waitingElementSet.add(newElement);
}
}
return waitingElementSet;
}
- public Hashtable<Taint, Set<Effect>> getConflictEffectSet(FlatSESEEnterNode fsen) {
- return sese2te.get(fsen);
+ public Hashtable<Taint, Set<Effect>> getConflictEffectSet(FlatNode fn) {
+ return sese2te.get(fn);
}
public void writeGraph(String graphName, boolean filter) throws java.io.IOException {
bw.close();
}
+
+ public Hashtable<String, ConflictNode> getId2cn() {
+ return id2cn;
+ }
}