bug fix for comparisons
authorbdemsky <bdemsky>
Fri, 12 Jun 2009 00:41:05 +0000 (00:41 +0000)
committerbdemsky <bdemsky>
Fri, 12 Jun 2009 00:41:05 +0000 (00:41 +0000)
Robust/src/Analysis/Locality/DiscoverConflicts.java
Robust/src/IR/Flat/BuildCode.java

index 1a0b2a8800de7b950a3287dc443260b218ab2a30..928733c40c4a5b394cc01a93fb4eaf98f94b39c4 100644 (file)
@@ -20,6 +20,8 @@ public class DiscoverConflicts {
   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) {
@@ -31,6 +33,8 @@ public class DiscoverConflicts {
     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() {
@@ -94,6 +98,14 @@ public class DiscoverConflicts {
     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);
   }
@@ -104,8 +116,12 @@ public class DiscoverConflicts {
     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
 
@@ -115,6 +131,37 @@ public class DiscoverConflicts {
       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;
index d765ecaa36acc144629af6697c5458fecb66f8e8..10845a51cf750647d00f3ac8ed67ff50ca4fa6d0 100644 (file)
@@ -439,6 +439,7 @@ public class BuildCode {
       outmethod.println("invokeSESEargs* tempSESEargs;");
     }
 
+
     //Store the sizes of classes & array elements
     generateSizeArray(outmethod);
 
@@ -876,21 +877,12 @@ public class BuildCode {
     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()];
 
@@ -901,6 +893,34 @@ public class BuildCode {
       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(", ");
@@ -2873,6 +2893,17 @@ public class BuildCode {
        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)