add LoopFactory.literal(String) convenience method
[fleet.git] / src / edu / berkeley / fleet / loops / LoopFactory.java
index d7b6648..76ffb83 100644 (file)
@@ -113,7 +113,6 @@ public class LoopFactory {
                 throw new RuntimeException("abortLoopIfTorpedoPresent() must be followed immediately by a Move");
         } else {
             instructions.add(new Move(dock,
-                                      count!=1,
                                       predicate,
                                       pending_interruptible,
                                       pending_path==null ? null : pending_path,
@@ -136,7 +135,6 @@ public class LoopFactory {
     public void interruptibleNop() {
         flush_pending();
         instructions.add(new Move(dock,
-                                  count!=1,
                                   predicate,
                                   true,
                                   null,
@@ -206,7 +204,7 @@ public class LoopFactory {
     public void flush() {
         if (!dock.isInputDock()) throw new RuntimeException("flush() may only be used at input docks");
         flush_pending();
-        instructions.add(new Instruction.Flush(dock, count!=1, predicate));
+        instructions.add(new Instruction.Flush(dock, predicate));
     }
 
     /** [outboxes only], will fuse with previous instruction if it was a sendToken() */
@@ -218,6 +216,10 @@ public class LoopFactory {
         flush_pending(true);
     }
 
+    public void literal(String constantName) {
+        literal(dock.getConstant(constantName));
+    }
+
     /** sets the data latch to a literal value */
     public void literal(BitVector literal) {
         // FIXME: code duplication here
@@ -229,7 +231,7 @@ public class LoopFactory {
             for(int i=counter-1; i>=counter-ctx.fleet.getShiftWidth(); i--)
                 if (i<literal.length())
                     temp.set(i-(counter-ctx.fleet.getShiftWidth()), literal.get(i));
-            instructions.add(new Shift(dock, count!=1, predicate, temp));
+            instructions.add(new Shift(dock, predicate, temp));
             counter -= ctx.fleet.getShiftWidth();
         }
     }
@@ -238,14 +240,14 @@ public class LoopFactory {
     public void literal(long literal) {
         flush_pending();
         if (((FleetTwoFleet)ctx.fleet).isSmallEnoughToFit(literal)) {
-            instructions.add(new Instruction.Set(dock, count!=1, predicate, SetDest.DataLatch, literal));
+            instructions.add(new Instruction.Set(dock, predicate, SetDest.DataLatch, literal));
         } else {
             int counter = 0;
             int extra = 0;
             while(counter < dock.getShip().getFleet().getWordWidth()) { extra++; counter += ctx.fleet.getShiftWidth(); }
             warn("literal " + literal + " requires " + extra + " instructions");
             while(counter > 0) {
-                instructions.add(new Shift(dock, count!=1, predicate,
+                instructions.add(new Shift(dock, predicate,
                                            new BitVector(dock.getShip().getFleet().getWordWidth())
                                            .set(getField(counter-1, counter-ctx.fleet.getShiftWidth(), literal))));
                 counter -= ctx.fleet.getShiftWidth();
@@ -257,7 +259,6 @@ public class LoopFactory {
     public void setFlags(Instruction.Set.FlagFunction newFlagA, Instruction.Set.FlagFunction newFlagB) {
         flush_pending();
         instructions.add(new Instruction.Set(dock,
-                                             count!=1,
                                              predicate,
                                              newFlagA,
                                              newFlagB));
@@ -267,7 +268,6 @@ public class LoopFactory {
     public void abort() {
         flush_pending();
         instructions.add(new Instruction.Set(dock,
-                                             count!=1,
                                              predicate,
                                              SetDest.OuterLoopCounter,
                                              0));
@@ -308,7 +308,7 @@ public class LoopFactory {
         boolean blockingInstructionEncountered = false;
 
         // Set the OLC (it might previously have been zero)
-        ic.add(new Set(dock, false, Predicate.IgnoreFlagD, SetDest.OuterLoopCounter, count==0 ? 1 : count));
+        ic.add(new Set(dock, Predicate.IgnoreFlagD, SetDest.OuterLoopCounter, count==0 ? 1 : count));
         if (count!=1) {
             ic.add(new Instruction.Head(dock));
         }
@@ -327,7 +327,7 @@ public class LoopFactory {
                 throw new RuntimeException("instruction sequence is too long for instruction fifo at " + dock);
         } else {
             if (count != 0) {
-                ic.add(new Instruction.Set(dock, true, Predicate.Default, SetDest.OuterLoopCounter, SetSource.Decrement));
+                ic.add(new Instruction.Set(dock, Predicate.Default, SetDest.OuterLoopCounter, SetSource.Decrement));
                 if (blockingInstructionEncountered)
                     numInstructionsNotIncludingNonblockingPrefix++;
                 loopSize++;
@@ -336,7 +336,7 @@ public class LoopFactory {
         if (count!=1)
             ic.add(new Instruction.Abort(dock, Predicate.FlagD));
         if (ctx.autoflush && next==null && dock.isInputDock())
-            ic.add(new Instruction.Flush(dock, true, Predicate.FlagD));
+            ic.add(new Instruction.Flush(dock, Predicate.FlagD));
 
         // FIXME: need to somehow deal with count!=0 loops that are
         // torpedoable; they need to wait for a torpedo to arrive