Add Class object so that we can implement getClass() and can have class lock for...
[IRC.git] / Robust / src / Main / Main.java
index 1e4d3ed6bbf73863ca2439f54382c6356d05456d..d33533db08962315cba8604aeb807bbf5f1442da 100644 (file)
@@ -15,6 +15,7 @@ import IR.Tree.ParseNode;
 import IR.Tree.BuildIR;
 import IR.Tree.SemanticCheck;
 import IR.Flat.BuildCodeMultiCore;
+import IR.Flat.BuildCodeMGC;
 import IR.Flat.BuildFlat;
 import IR.Flat.BuildCode;
 import IR.Flat.Inliner;
@@ -147,7 +148,9 @@ public class Main {
        state.MULTICORE=true;
       else if (option.equals("-multicoregc"))
         state.MULTICOREGC=true;
-      else if (option.equals("-ownership"))
+      else if (option.equals("-mgc")) {
+        state.MGC = true;
+      } else if (option.equals("-ownership"))
        state.OWNERSHIP=true;
       else if (option.equals("-ownallocdepth")) {
        state.OWNERSHIPALLOCDEPTH=Integer.parseInt(args[++i]);
@@ -270,6 +273,8 @@ public class Main {
        state.OPTIONAL=true;
       else if (option.equals("-optimize"))
        state.OPTIMIZE=true;
+      else if (option.equals("-noloop"))
+       state.NOLOOP=true;
       else if (option.equals("-dcopts"))
        state.DCOPTS=true;
       else if (option.equals("-arraypad"))
@@ -320,6 +325,9 @@ public class Main {
 
       } else if (option.equals("-methodeffects")) {
        state.METHODEFFECTS=true;
+       
+      } else if (option.equals("-coreprof")) {
+       state.COREPROF=true;
 
       } else if (option.equals("-ooojava")) {
        state.OOOJAVA  = true;
@@ -329,6 +337,8 @@ public class Main {
 
       } else if (option.equals("-ooodebug") ){ 
   state.OOODEBUG  = true;
+      } else if (option.equals("-rcr")){
+   state.RCR = true;
       } else if (option.equals("-help")) {
        System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
        System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
@@ -356,6 +366,7 @@ public class Main {
        System.out.println("-ownwritedots <all/final> -- write ownership graphs; can be all results or just final results");
        System.out.println("-ownaliasfile <filename> -- write a text file showing all detected aliases in program tasks");
        System.out.println("-optimize -- enable optimizations");
+       System.out.println("-noloop -- disable loop optimizations");
        System.out.println("-optional -- enable optional arguments");
        System.out.println("-abcclose close the array boundary check");
        System.out.println("-scheduling do task scheduling");
@@ -392,6 +403,7 @@ public class Main {
     for(int i=0;i<sourcefiles.size();i++)
       loadClass(state, bir,(String)sourcefiles.get(i));
 
+
     //Stuff the runtime wants to see
     sc.getClass("String");
     sc.getClass("Math");
@@ -403,10 +415,11 @@ public class Main {
     if (state.TASK) {
       sc.getClass("TagDescriptor");
     }
-    if (state.THREAD||state.DSM||state.SINGLETM) {
+    if (state.THREAD||state.DSM||state.SINGLETM||state.MGC) {
       sc.getClass("Thread");
     }
 
+
     sc.semanticCheck();
 
     tu.createFullTable();
@@ -439,7 +452,9 @@ public class Main {
       GlobalFieldType gft=new GlobalFieldType(callgraph, state, tu.getMain());
       CSE cse=new CSE(gft, tu);
       localCSE lcse=new localCSE(gft, tu);
-      LoopOptimize lo=new LoopOptimize(gft, tu);
+      LoopOptimize lo=null;
+      if (!state.NOLOOP)
+         lo=new LoopOptimize(gft, tu);
       Iterator classit=state.getClassSymbolTable().getDescriptorsIterator();
       while(classit.hasNext()) {
         ClassDescriptor cn=(ClassDescriptor)classit.next();
@@ -450,7 +465,8 @@ public class Main {
           FlatMethod fm=state.getMethodFlat(md);
          cp.optimize(fm);
          dc.optimize(fm);
-         lo.optimize(fm);
+         if (!state.NOLOOP)
+             lo.optimize(fm);
          cp.optimize(fm);
          dc.optimize(fm);
          lcse.doAnalysis(fm);
@@ -556,15 +572,15 @@ public class Main {
        CallGraph callGraph = new CallGraph(state);
        Liveness liveness = new Liveness();
         ArrayReferencees ar = new ArrayReferencees(state);
-       OwnershipAnalysis oa = new OwnershipAnalysis(state,
+       OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state,
                                                     tu,
                                                     callGraph,
-                                                    liveness,
-                                                     ar,
+                                                 liveness,
+                                                 ar,
                                                     state.OWNERSHIPALLOCDEPTH,
                                                     state.OWNERSHIPWRITEDOTS,
                                                     state.OWNERSHIPWRITEALL,
-                                                    state.OWNERSHIPALIASFILE);
+                                                    state.OWNERSHIPALIASFILE);*/
        
        // synthesis a layout according to target multicore processor
        MCImplSynthesis mcImplSynthesis = new MCImplSynthesis(state,
@@ -604,6 +620,22 @@ public class Main {
        }
       }
     }
+    
+    if (state.MGC) {
+      // generate multicore codes
+      if(state.MULTICORE) {
+        BuildCodeMGC bcmgc=new BuildCodeMGC(state,
+                                            bf.getMap(),
+                                            tu,
+                                            sa,
+                                            state.CORENUM,
+                                            state.CORENUM,
+                                            state.CORENUM4GC,
+                                            pa);
+        bcmgc.buildCode();
+      }
+    }
+  
     if(!state.MULTICORE) {
       if (state.DSM||state.SINGLETM) {
        CallGraph callgraph=new CallGraph(state);