Hashtable<LocalityBinding, Set<FlatNode>> treadmap;
Hashtable<LocalityBinding, Set<TempFlatPair>> transreadmap;
Hashtable<LocalityBinding, Set<FlatNode>> srcmap;
+ Hashtable<LocalityBinding, Set<FlatNode>> leftsrcmap;
+ Hashtable<LocalityBinding, Set<FlatNode>> rightsrcmap;
TypeAnalysis typeanalysis;
public DiscoverConflicts(LocalityAnalysis locality, State state, TypeAnalysis typeanalysis) {
transreadmap=new Hashtable<LocalityBinding, Set<TempFlatPair>>();
treadmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
srcmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
+ leftsrcmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
+ rightsrcmap=new Hashtable<LocalityBinding, Set<FlatNode>>();
}
public void doAnalysis() {
return srcmap.get(lb).contains(fn);
}
+ public boolean getNeedLeftSrcTrans(LocalityBinding lb, FlatNode fn) {
+ return leftsrcmap.get(lb).contains(fn);
+ }
+
+ public boolean getNeedRightSrcTrans(LocalityBinding lb, FlatNode fn) {
+ return rightsrcmap.get(lb).contains(fn);
+ }
+
public boolean getNeedTrans(LocalityBinding lb, FlatNode fn) {
return treadmap.get(lb).contains(fn);
}
Hashtable<FlatNode, Hashtable<TempDescriptor, Set<TempFlatPair>>> fnmap=computeTempSets(lb);
HashSet<TempFlatPair> tfset=computeTranslationSet(lb, fm, fnmap);
HashSet<FlatNode> srctrans=new HashSet<FlatNode>();
+ HashSet<FlatNode> leftsrctrans=new HashSet<FlatNode>();
+ HashSet<FlatNode> rightsrctrans=new HashSet<FlatNode>();
transreadmap.put(lb, tfset);
srcmap.put(lb,srctrans);
+ leftsrcmap.put(lb,leftsrctrans);
+ rightsrcmap.put(lb,rightsrctrans);
//compute writes that need translation on source
if (atomictable.get(fn).intValue()>0) {
Hashtable<TempDescriptor, Set<TempFlatPair>> tmap=fnmap.get(fn);
switch(fn.kind()) {
+ case FKind.FlatOpNode: {
+ FlatOpNode fon=(FlatOpNode)fn;
+ if (fon.getOp().getOp()==Operation.EQUAL||
+ fon.getOp().getOp()==Operation.NOTEQUAL) {
+ if (!fon.getLeft().getType().isPtr())
+ break;
+ Set<TempFlatPair> lefttfpset=tmap.get(fon.getLeft());
+ Set<TempFlatPair> righttfpset=tmap.get(fon.getRight());
+ //handle left operand
+ if (lefttfpset!=null) {
+ for(Iterator<TempFlatPair> tfpit=lefttfpset.iterator();tfpit.hasNext();) {
+ TempFlatPair tfp=tfpit.next();
+ if (tfset.contains(tfp)||ok(tfp)) {
+ leftsrctrans.add(fon);
+ break;
+ }
+ }
+ }
+ //handle right operand
+ if (righttfpset!=null) {
+ for(Iterator<TempFlatPair> tfpit=righttfpset.iterator();tfpit.hasNext();) {
+ TempFlatPair tfp=tfpit.next();
+ if (tfset.contains(tfp)||ok(tfp)) {
+ rightsrctrans.add(fon);
+ break;
+ }
+ }
+ }
+ }
+ break;
+ }
case FKind.FlatSetFieldNode: {
//definitely need to translate these
FlatSetFieldNode fsfn=(FlatSetFieldNode)fn;
outmethod.println("invokeSESEargs* tempSESEargs;");
}
+
//Store the sizes of classes & array elements
generateSizeArray(outmethod);
outclassdefs.print("#endif\n");
outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n");
- outclassdefs.print("int classsize[]={");
Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
cdarray=new ClassDescriptor[state.numClasses()];
while(it.hasNext()) {
ClassDescriptor cd=(ClassDescriptor)it.next();
cdarray[cd.getId()]=cd;
}
- boolean needcomma=false;
- for(int i=0; i<state.numClasses(); i++) {
- if (needcomma)
- outclassdefs.print(", ");
- outclassdefs.print("sizeof(struct "+cdarray[i].getSafeSymbol()+")");
- needcomma=true;
- }
-
arraytable=new TypeDescriptor[state.numArrays()];
arraytable[id]=td;
}
+
+
+ /* Print out types */
+ outclassdefs.println("/* ");
+ for(int i=0; i<state.numClasses(); i++) {
+ ClassDescriptor cd=cdarray[i];
+ outclassdefs.println(cd +" "+i);
+ }
+
+ for(int i=0; i<state.numArrays(); i++) {
+ TypeDescriptor arraytd=arraytable[i];
+ outclassdefs.println(arraytd.toPrettyString() +" "+(i+state.numClasses()));
+ }
+
+ outclassdefs.println("*/");
+
+
+ outclassdefs.print("int classsize[]={");
+
+ boolean needcomma=false;
+ for(int i=0; i<state.numClasses(); i++) {
+ if (needcomma)
+ outclassdefs.print(", ");
+ outclassdefs.print("sizeof(struct "+cdarray[i].getSafeSymbol()+")");
+ needcomma=true;
+ }
+
+
for(int i=0; i<state.numArrays(); i++) {
if (needcomma)
outclassdefs.print(", ");
else
output.println(generateTemp(fm, fon.getDest(),lb)+" = ((unsigned int)"+generateTemp(fm, fon.getLeft(),lb)+")>>"+generateTemp(fm,fon.getRight(),lb)+";");
+ } else if (dc!=null) {
+ output.print(generateTemp(fm, fon.getDest(),lb)+" = ");
+ if (dc.getNeedLeftSrcTrans(lb, fon))
+ output.print("("+generateTemp(fm, fon.getLeft(),lb)+"!=NULL?"+generateTemp(fm, fon.getLeft(),lb)+"->"+oidstr+":NULL)");
+ else
+ output.print(generateTemp(fm, fon.getLeft(),lb));
+ output.print(fon.getOp().toString());
+ if (dc.getNeedRightSrcTrans(lb, fon))
+ output.println("("+generateTemp(fm, fon.getRight(),lb)+"!=NULL?"+generateTemp(fm, fon.getRight(),lb)+"->"+oidstr+":NULL);");
+ else
+ output.println(generateTemp(fm,fon.getRight(),lb)+";");
} else
output.println(generateTemp(fm, fon.getDest(),lb)+" = "+generateTemp(fm, fon.getLeft(),lb)+fon.getOp().toString()+generateTemp(fm,fon.getRight(),lb)+";");
} else if (fon.getOp().getOp()==Operation.ASSIGN)