improve code gen to omit empty switch cases for stall sites
authorjjenista <jjenista>
Fri, 4 Feb 2011 01:02:49 +0000 (01:02 +0000)
committerjjenista <jjenista>
Fri, 4 Feb 2011 01:02:49 +0000 (01:02 +0000)
Robust/src/IR/Flat/BuildOoOJavaCode.java

index a277d40a7442b7f61a8cd49ac419b4cc664fee1a..b0d045bcc6648aa3585fc2a68dc29e600ea33adb 100644 (file)
@@ -1027,8 +1027,9 @@ public class BuildOoOJavaCode extends BuildCode {
       // executing, so create a switch on task ID, because waiting elements
       // generated by this stall site should be inserted into possibly a
       // different memory queue index, depending on which task type it is
-      output.println("   // potential stall site ");      
-      output.println("   switch( runningSESE->classID ) {");
+      // update: only generate the switch statement if there is at least
+      // one non-empty case that will go in it!
+      boolean atLeastOneCase = false;
 
       // create a case for each class of task that might be executing
       Iterator<FlatSESEEnterNode> taskItr = oooa.getPossibleExecutingRBlocks( fn ).iterator();
@@ -1047,6 +1048,12 @@ public class BuildOoOJavaCode extends BuildCode {
           continue;
         }
 
+        if( atLeastOneCase == false ) {
+          atLeastOneCase = true;
+          output.println("   // potential stall site ");      
+          output.println("   switch( runningSESE->classID ) {");
+        }
+
         output.println("     case "+parent.getIdentifier()+": {");
 
         if( state.RCR ) {
@@ -1094,7 +1101,10 @@ public class BuildOoOJavaCode extends BuildCode {
         }
         output.println("     } break; // end case "+parent.getIdentifier());
       }
-      output.println("   } // end stall site switch");
+
+      if( atLeastOneCase ) {
+        output.println("   } // end stall site switch");
+      }
     }
   }
   
@@ -1395,9 +1405,7 @@ public class BuildOoOJavaCode extends BuildCode {
         // based on task ID, each type of task has a different index
         // scheme for its memory queue's, and the cases here drop the
         // new task instance in the right bucket
-
-        output.println("   // add new task instance to current task's memory queues if needed ");      
-        output.println("   switch( runningSESE->classID ) {");
+        boolean atLeastOneCase = false;
 
         // create a case for each class of task that might be executing
         Iterator<FlatSESEEnterNode> taskItr = oooa.getPossibleExecutingRBlocks( fsen ).iterator();
@@ -1418,6 +1426,12 @@ public class BuildOoOJavaCode extends BuildCode {
             continue;
           }
 
+          if( atLeastOneCase == false ) {
+            atLeastOneCase = true;
+            output.println("   // add new task instance to current task's memory queues if needed ");      
+            output.println("   switch( runningSESE->classID ) {");
+          }
+
           output.println("     case "+parent.getIdentifier()+": {");
           output.println("       REntry* rentry=NULL;");
           output.println("       INTPTR* pointer=NULL;");
@@ -1502,7 +1516,10 @@ public class BuildOoOJavaCode extends BuildCode {
           output.println("     } break; // end case "+parent.getIdentifier());
           output.println();          
         }
-        output.println("   } // end stall site switch");
+
+        if( atLeastOneCase ) {
+          output.println("   } // end stall site switch");
+        }
       }      
       
       if( state.COREPROF ) {