improve instruction dispatch code in Parser.java
authoradam <adam@megacz.com>
Thu, 21 Aug 2008 10:30:34 +0000 (11:30 +0100)
committeradam <adam@megacz.com>
Thu, 21 Aug 2008 10:30:34 +0000 (11:30 +0100)
src/edu/berkeley/fleet/assembler/Parser.java

index 5843110..c4dc3c3 100644 (file)
@@ -166,8 +166,20 @@ public class Parser {
         ret.add(wait(inCBD));
         ret.add(deliver(inCBD));
         ret.add(sendto(out, out.getPath(inCBD.getDataDestination(),null)));
-        ret.add(new Instruction.Set(ihorn, false, IgnoreOLC, SetDest.InnerLoopCounter, SetSource.Infinity));
-        ret.add(new Instruction.Move(ihorn, false, IgnoreOLC, false, null,false,true,true,true,true,false));
+
+        int count = (int)FleetTwoFleet.CBD_SIZE.getval(startcbd);
+        // FIXME FIXME FIXME!
+        int MAX_ILC = 31;
+        int num_instrs = 0;
+        while(count > 0) {
+            int num = Math.min(count, MAX_ILC);
+            num_instrs+=2;
+            count -= num;
+            ret.add(new Instruction.Set(ihorn, false, IgnoreOLC, SetDest.InnerLoopCounter, num));
+            ret.add(new Instruction.Move(ihorn, false, IgnoreOLC, false, null,false,true,true,true,true,false));
+        }
+        if (num_instrs > ihorn.getInstructionFifoSize()) throw new RuntimeException();
+
         return (Instruction[])ret.toArray(new Instruction[0]);
     }