switch demo from Util.java to LoopFactory, delete Util.java
authoradam <adam@megacz.com>
Sun, 7 Sep 2008 06:12:10 +0000 (07:12 +0100)
committeradam <adam@megacz.com>
Sun, 7 Sep 2008 06:12:10 +0000 (07:12 +0100)
src/edu/berkeley/fleet/ir/New.java
src/edu/berkeley/fleet/ir/Util.java [deleted file]

index a975af6..44aa964 100644 (file)
@@ -8,6 +8,7 @@ import edu.berkeley.fleet.api.Instruction.Set;
 import edu.berkeley.fleet.api.Instruction.Set.SetDest;
 import edu.berkeley.fleet.api.Instruction.Set.FlagFunction;
 import static edu.berkeley.fleet.api.Predicate.*;
+import edu.berkeley.fleet.ir.Context.LoopFactory;
 import java.io.*;
 import java.util.*;
 import java.net.*;
@@ -17,9 +18,30 @@ public class New {
     public final Fleet fleet;
     public New(Fleet fleet) { this.fleet = fleet; }
 
-    private HashSet<Segment> segments = new HashSet<Segment>();
+    private Context context = new Context();
 
+    private HashSet<Segment> segments = new HashSet<Segment>();
     private HashSet<Ship> allocated = new HashSet<Ship>();
+
+    private HashMap<Dock,LoopFactory> loops = new HashMap<Dock,LoopFactory>();
+    private HashSet<LoopFactory> emitLoops = new HashSet<LoopFactory>();
+
+    public LoopFactory getLoopFactory(Dock d) { return getLoopFactory(d, 0); }
+    public LoopFactory getNextLoopFactory(Dock d, int count) {
+        LoopFactory lf = loops.get(d);
+        if (lf!=null) loops.put(d, lf = context.new LoopFactory(d, count, d+"", lf));
+        return getLoopFactory(d, count);
+    }
+    public LoopFactory getLoopFactory(Dock d, int count) {
+        LoopFactory lf = loops.get(d);
+        if (lf==null) {
+            loops.put(d, lf = context.new LoopFactory(d, count, d+"", null));
+            emitLoops.add(lf);
+        }
+        if (lf.count != count) throw new RuntimeException();
+        return lf;
+    }
+
     Ship allocate(String shipType) {
         for(Ship ship : fleet)
             if (shipType.equals(ship.getType()) && !allocated.contains(ship)) {
@@ -33,6 +55,7 @@ public class New {
         for(Segment s : segments) s.emitPrologue(al);
         for(Segment s : segments) s.emitInstructions(al);
         for(Segment s : segments) s.emitEpilogue(al);
+        for(LoopFactory lf : emitLoops) lf.emit(al);
     }
 
     public abstract class Segment {
@@ -71,11 +94,10 @@ public class New {
         public Dock[] _setInputs() { return new Dock[0]; }
         public void emitPrologue(ArrayList<Instruction> il) { }
         public void emitInstructions(ArrayList<Instruction> il) {
-            il.add(Util.sendto(inputs[0], true, debugShip.getDock("in")));
-            il.add(Util.wait(inputs[0], true));
-
-            il.add(Util.setILCInfinity(debugShip.getDock("in")));
-            il.add(Util.recvDeliverAck(debugShip.getDock("in"), inputs[0]));
+            LoopFactory lf;
+            lf = context.new LoopFactory(debugShip.getDock("in"), 0, "debug.in", null);
+            lf.recvWord();
+            lf.deliver();
         }
         public void emitEpilogue(ArrayList<Instruction> il) { }
     }
@@ -92,17 +114,18 @@ public class New {
             return new Dock[] { fifoShip.getDock("out") };
         }
         public void emitPrologue(ArrayList<Instruction> il) {
-            il.add(Util.setOLC(fifoShip.getDock("out"), 1));
-            il.add(Util.collect(fifoShip.getDock("out"), true));
+            LoopFactory lf;
+            lf = getLoopFactory(fifoShip.getDock("out"), 0);
+            lf.collectWord();
         }
         public void emitInstructions(ArrayList<Instruction> il) {
-            Dock fifoIn = fifoShip.getDock("in");
-            Util.literal(fifoIn, constant, il);
-            il.add(Util.setILCInfinity(fifoIn));
-            il.add(Util.deliver(fifoIn));
+            LoopFactory lf;
+            lf = getLoopFactory(fifoShip.getDock("in"), 1);
+            lf.literal(constant);
+            lf = getNextLoopFactory(fifoShip.getDock("in"), 0);
+            lf.deliver();
         }
         public void emitEpilogue(ArrayList<Instruction> il) {
-            il.add(Util.tail(fifoShip.getDock("out")));
         }
     }
 
@@ -118,35 +141,39 @@ public class New {
             return new Dock[] { alu.getDock("out") };
         }
         public void emitPrologue(ArrayList<Instruction> il) {
-            il.add(Util.setOLC(alu.getDock("out"), 1));
-            il.add(Util.collect(alu.getDock("out"), true));
+            LoopFactory lf;
+            lf = getLoopFactory(alu.getDock("out"), 0);
+            lf.collectWord();
         }
         public void emitInstructions(ArrayList<Instruction> il) {
             Dock inOp = alu.getDock("inOp");
 
             if (opcode==-1) {
-                il.add(Util.setILCInfinity(alu.getDock("inOp")));
-                il.add(Util.recvDeliverAck(alu.getDock("inOp"), inputs[2]));
-                il.add(Util.sendto(inputs[2], true, alu.getDock("inOp")));
-                il.add(Util.wait(inputs[2], true));
+                recvSendTokenDeliver(alu.getDock("inOp"), inputs[2].getDataDestination());
+                LoopFactory lf;
+                lf = getLoopFactory(inputs[2], 0);
+                lf.send(alu.getDock("inOp").getDataDestination());
+                lf.recvToken();
             } else {
-                Util.literal(alu.getDock("inOp"), opcode, il);
-                il.add(Util.setILCInfinity(alu.getDock("inOp")));
-                il.add(Util.deliver(alu.getDock("inOp")));
+                LoopFactory lf;
+                lf = getLoopFactory(alu.getDock("inOp"), 1);
+                lf.literal(opcode);
+                lf = getNextLoopFactory(alu.getDock("inOp"), 0);
+                lf.deliver();
             }
 
-            il.add(Util.setILCInfinity(alu.getDock("in1")));
-            il.add(Util.recvDeliverAck(alu.getDock("in1"), inputs[0]));
-            il.add(Util.sendto(inputs[0], true, alu.getDock("in1")));
-            il.add(Util.wait(inputs[0], true));
+            recvSendTokenDeliver(alu.getDock("in1"), inputs[0].getDataDestination());
+            LoopFactory lf;
+            lf = getLoopFactory(inputs[0], 0);
+            lf.send(alu.getDock("in1").getDataDestination());
+            lf.recvToken();
 
-            il.add(Util.setILCInfinity(alu.getDock("in2")));
-            il.add(Util.recvDeliverAck(alu.getDock("in2"), inputs[1]));
-            il.add(Util.sendto(inputs[1], true, alu.getDock("in2")));
-            il.add(Util.wait(inputs[1], true));
+            recvSendTokenDeliver(alu.getDock("in2"), inputs[1].getDataDestination());
+            lf = getLoopFactory(inputs[1], 0);
+            lf.send(alu.getDock("in2").getDataDestination());
+            lf.recvToken();
         }
         public void emitEpilogue(ArrayList<Instruction> il) {
-            il.add(Util.tail(alu.getDock("out")));
         }
     }
 
@@ -164,24 +191,32 @@ public class New {
             return new Dock[] { alu.getDock("out") };
         }
         public void emitPrologue(ArrayList<Instruction> il) {
-            Util.literal(alu.getDock("out"), start, il);
-            il.add(Util.setOLC(alu.getDock("out"), 1));
+            LoopFactory lf;
+            lf = getLoopFactory(alu.getDock("out"), 1);
+            lf.literal(start);
+            getNextLoopFactory(alu.getDock("out"), 0);
         }
         public void emitInstructions(ArrayList<Instruction> il) {
-            Dock inOp = alu.getDock("inOp");
-            Util.literal(inOp, 2, il);
-            il.add(Util.setILCInfinity(inOp));
-            il.add(Util.deliver(inOp));
+            LoopFactory lf;
+            lf = getLoopFactory(alu.getDock("inOp"), 1);
+            lf.literal(2);
+            lf = getNextLoopFactory(alu.getDock("inOp"), 0);
+            lf.deliver();
 
-            il.add(Util.setILCInfinity(alu.getDock("in1")));
-            il.add(Util.recvDeliver(alu.getDock("in1")));
+            lf = getLoopFactory(alu.getDock("in1"), 0);
+            lf.recvWord();
+            lf.deliver();
 
-            Util.infiniteLiteral(alu.getDock("in2"), incr, il);
+            lf = getLoopFactory(alu.getDock("in2"), 1);
+            lf.literal(incr);
+            lf = getNextLoopFactory(alu.getDock("in2"), 0);
+            lf.deliver();
         }
         public void emitEpilogue(ArrayList<Instruction> il) {
-            il.add(Util.sendto(alu.getDock("out"), true, alu.getDock("in1")));
-            il.add(Util.collect(alu.getDock("out"), true));
-            il.add(Util.tail(alu.getDock("out")));
+            LoopFactory lf;
+            lf = getLoopFactory(alu.getDock("out"), 0);
+            lf.send(alu.getDock("in1").getDataDestination());
+            lf.collectWord();
         }
     }
 
@@ -199,47 +234,54 @@ public class New {
             return new Dock[] { alu.getDock("out") };
         }
         public void emitPrologue(ArrayList<Instruction> il) {
-            il.add(Util.setOLC(alu.getDock("out"), 1));
-            il.add(Util.setOLC(alu.getDock("inOp"), 1));
-            il.add(Util.setOLC(alu.getDock("in1"), 1));
-            il.add(Util.setOLC(alu.getDock("in2"), 1));
-
-            il.add(Util.collect(alu.getDock("out"), true));
-            il.add(new Set(alu.getDock("out"), true, Predicate.Default, FlagFunction.ZERO.add(FlagC), FlagFunction.ZERO));
-            il.add(Util.collect(alu.getDock("out"), true));
-            il.add(new Set(alu.getDock("out"), true, Predicate.Default, FlagFunction.ZERO.add(FlagC).add(FlagA), FlagFunction.ZERO));
-            il.add(new Set(alu.getDock("out"), true, Predicate.NotFlagA, SetDest.DataLatch, 1));
-            il.add(new Set(alu.getDock("out"), true, Predicate.FlagA, SetDest.DataLatch, 0));
+            getLoopFactory(alu.getDock("in1"), 0);
+            getLoopFactory(alu.getDock("in2"), 0);
+
+            LoopFactory lf;
+            lf = getLoopFactory(alu.getDock("out"), 0);
+            lf.collectWord();
+            lf.setFlags(FlagFunction.ZERO.add(FlagC), FlagFunction.ZERO);
+            lf.collectWord();
+            lf.setFlags(FlagFunction.ZERO.add(FlagC).add(FlagA), FlagFunction.ZERO);
+            lf.setPredicate(Predicate.NotFlagA);
+            lf.literal(1);
+            lf.setPredicate(Predicate.FlagA);
+            lf.literal(0);
+            lf.setPredicate(null);
         }
 
         public void emitInstructions(ArrayList<Instruction> il) {
-            Util.literal(alu.getDock("inOp"), 4, il, true);   // MAX
-            il.add(Util.deliver(alu.getDock("inOp"), true));
-            Util.literal(alu.getDock("in1"), max, il, true);
-            il.add(Util.deliver(alu.getDock("in1"), true));
-            il.add(Util.recvDeliverAck(alu.getDock("in2"), inputs[0], true));
-
-            Util.literal(alu.getDock("inOp"), 4, il, true);   // MIN
-            il.add(Util.deliver(alu.getDock("inOp"), true));
-            Util.literal(alu.getDock("in2"), min, il, true);
-            il.add(Util.deliver(alu.getDock("in2"), true));
-            il.add(Util.recvDeliverAck(alu.getDock("in1"), inputs[0], true));
-
-            il.add(Util.sendto(inputs[0], true, alu.getDock("in2")));
-            il.add(Util.sendto(inputs[0], true, alu.getDock("in1")));
-            il.add(Util.wait(inputs[0], true));
-            il.add(Util.wait(inputs[0], true));
+            LoopFactory lf;
+            lf = getLoopFactory(alu.getDock("inOp"), 0);
+            lf.literal(4); // MAX
+            lf.deliver();
+            lf.literal(4); // MAX
+            lf.deliver();
+
+            lf = getLoopFactory(alu.getDock("in1"), 0);
+            lf.recvWord();
+            lf.sendToken(inputs[0].getDataDestination());
+            lf.deliver();
+            lf.literal(max);
+            lf.deliver();
+
+            lf = getLoopFactory(alu.getDock("in2"), 0);
+            lf.literal(min);
+            lf.deliver();
+            lf.recvWord();
+            lf.sendToken(inputs[0].getDataDestination());
+            lf.deliver();
+
+            lf = getLoopFactory(inputs[0], 0);
+            lf.send(alu.getDock("in2").getDataDestination());
+            lf.send(alu.getDock("in1").getDataDestination());
+            lf.recvToken();
+            lf.recvToken();
         }
 
-        public void emitEpilogue(ArrayList<Instruction> il) {
-            il.add(Util.tail(alu.getDock("in1")));
-            il.add(Util.tail(alu.getDock("in2")));
-            il.add(Util.tail(alu.getDock("inOp")));
-            il.add(Util.tail(alu.getDock("out")));
-        }
+        public void emitEpilogue(ArrayList<Instruction> il) { }
     }
 
-
     public class FifoWithInit extends Segment {
         Ship fifoShip = null;
         public final long init;
@@ -252,19 +294,24 @@ public class New {
             return new Dock[] { fifoShip.getDock("out") };
         }
         public void emitPrologue(ArrayList<Instruction> il) {
-            Util.literal(fifoShip.getDock("out"), init, il, false);
-            il.add(Util.setOLC(fifoShip.getDock("out"), 1));
+            LoopFactory lf;
+            lf = getLoopFactory(fifoShip.getDock("out"), 1);
+            lf.literal(init);
+            lf = getNextLoopFactory(fifoShip.getDock("out"), 0);
+            lf = getLoopFactory(fifoShip.getDock("in"), 0);
         }
         public void emitInstructions(ArrayList<Instruction> il) {
-            il.add(Util.sendto(inputs[0], true, fifoShip.getDock("in")));
-            il.add(Util.wait(inputs[0], true));
+            LoopFactory lf;
+            lf = getLoopFactory(inputs[0], 0);
+            lf.send(fifoShip.getDock("in").getDataDestination());
+            lf.recvToken();
 
-            il.add(Util.setILCInfinity(fifoShip.getDock("in")));
-            il.add(Util.recvDeliverAck(fifoShip.getDock("in"), inputs[0]));
+            recvSendTokenDeliver(fifoShip.getDock("in"), inputs[0].getDataDestination());
         }
         public void emitEpilogue(ArrayList<Instruction> il) {
-            il.add(Util.collect(fifoShip.getDock("out"), true));
-            il.add(Util.tail(fifoShip.getDock("out")));
+            LoopFactory lf;
+            lf = getLoopFactory(fifoShip.getDock("out"), 0);
+            lf.collectWord();
         }
     }
 
@@ -279,20 +326,22 @@ public class New {
         }
         public void emitPrologue(ArrayList<Instruction> il) { }
         public void emitInstructions(ArrayList<Instruction> il) {
-            il.add(Util.setILCInfinity(videoShip.getDock("inX")));
-            il.add(Util.recvDeliverAck(videoShip.getDock("inX"), inputs[0]));
-            il.add(Util.sendto(inputs[0], true, videoShip.getDock("inX")));
-            il.add(Util.wait(inputs[0], true));
+            recvSendTokenDeliver(videoShip.getDock("inX"),    inputs[0].getDataDestination());
+            recvSendTokenDeliver(videoShip.getDock("inY"),    inputs[1].getDataDestination());
+            recvSendTokenDeliver(videoShip.getDock("inData"), inputs[2].getDataDestination());
+
+            LoopFactory lf;
+            lf = getLoopFactory(inputs[0]);
+            lf.send(videoShip.getDock("inX").getDataDestination());
+            lf.recvToken();
 
-            il.add(Util.setILCInfinity(videoShip.getDock("inY")));
-            il.add(Util.recvDeliverAck(videoShip.getDock("inY"), inputs[1]));
-            il.add(Util.sendto(inputs[1], true, videoShip.getDock("inY")));
-            il.add(Util.wait(inputs[1], true));
+            lf = getLoopFactory(inputs[1]);
+            lf.send(videoShip.getDock("inY").getDataDestination());
+            lf.recvToken();
 
-            il.add(Util.setILCInfinity(videoShip.getDock("inData")));
-            il.add(Util.recvDeliverAck(videoShip.getDock("inData"), inputs[2]));
-            il.add(Util.sendto(inputs[2], true, videoShip.getDock("inData")));
-            il.add(Util.wait(inputs[2], true));
+            lf = getLoopFactory(inputs[2]);
+            lf.send(videoShip.getDock("inData").getDataDestination());
+            lf.recvToken();
         }
         public void emitEpilogue(ArrayList<Instruction> il) { }
     }
@@ -323,56 +372,29 @@ public class New {
     }
 
     public static void main(String[] s) throws Exception {
-
-
-        New n = null;
-
-        if (!s[0].equals("fpga")) n = new New(new Interpreter(new String[] {
-                    "Debug",
-                    "Fifo", "Fifo",
-                    "Fifo", "Fifo",
-                    "Fifo", "Fifo",
-                    "Fifo", "Fifo",
-                    "Fifo", "Fifo",
-                    "Fifo", "Fifo",
-                    "alu2", "alu2",
-                    "alu2", "alu2",
-                    "alu2", "alu2",
-                    "alu2", "alu2",
-                    "alu2", "alu2",
-                    "alu2", "alu2",
-                    "Video"
-                }, false));
-
-
-        if (s[0].equals("fpga")) n = new New(new Fpga());
-
-
-        //Debug debug = n.new Debug();
-
-        /*
-        Constant con12 = n.new Constant(12);
-        debug.setInputs(con12.setInputs(new Dock[0]));
-        */
-
-        /*
-        Alu alu = n.new Alu(2);
-        Constant con12 = n.new Constant(12);
-        Constant con13 = n.new Constant(13);
-        debug.setInputs(alu.setInputs(new Dock[] { con12.setInputs(new Dock[0])[0], con13.setInputs(new Dock[0])[0] }));
-        */
-
-        /*
-        Constant con12 = n.new Constant(12);
-        Counter  con13 = n.new Counter(0, 2);
-        Alu alu = n.new Alu(2);
-        debug.setInputs(alu.setInputs(new Dock[] { con12.setInputs(new Dock[0])[0], con13.setInputs(new Dock[0])[0] }));
-        */
+        New n = s[0].equals("fpga")
+            ? new New(new Fpga())
+            : new New(new Interpreter(new String[] {
+                        "Debug",
+                        "Fifo", "Fifo",
+                        "Fifo", "Fifo",
+                        "Fifo", "Fifo",
+                        "Fifo", "Fifo",
+                        "Fifo", "Fifo",
+                        "Fifo", "Fifo",
+                        "alu2", "alu2",
+                        "alu2", "alu2",
+                        "alu2", "alu2",
+                        "alu2", "alu2",
+                        "alu2", "alu2",
+                        "alu2", "alu2",
+                        "Video"
+                    }, false));
 
         Dock x_pos = bouncer(n, 1, 6, 5, 634);
         Dock y_pos = bouncer(n, 1, 6, 5, 474);
-        Dock color = n.new Constant(2).setInputs(new Dock[0])[0];
-        //Dock color = n.new Counter(0,1).setInputs(new Dock[0])[0];
+        //Dock color = n.new Constant(2).setInputs(new Dock[0])[0];
+        Dock color = n.new Counter(0,1).setInputs(new Dock[0])[0];
 
         //debug.setInputs(new Dock[] { x_pos });
         Video vid = n.new Video();
@@ -380,17 +402,17 @@ public class New {
 
         ArrayList<Instruction> al = new ArrayList<Instruction>();
         n.emit(al);
-
-
-        for(int i=0; i<al.size(); i++)
-            System.out.println(al.get(i));
-
-
+        for(int i=0; i<al.size(); i++) System.out.println(al.get(i));
+        
         FleetProcess fp = n.fleet.run((Instruction[])al.toArray(new Instruction[0]));
         System.out.println("launching...");
-        while(true) {
-            System.out.println(fp.readWord().toLong());
-        }
+        while(true) System.out.println(fp.readWord().toLong());
     }
 
+    private void recvSendTokenDeliver(Dock dock, Destination dest) {
+        LoopFactory lf = getLoopFactory(dock);
+        lf.recvWord();
+        lf.sendToken(dest);
+        lf.deliver();
+    }
 }
diff --git a/src/edu/berkeley/fleet/ir/Util.java b/src/edu/berkeley/fleet/ir/Util.java
deleted file mode 100644 (file)
index 2b4bd27..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-package edu.berkeley.fleet.ir;
-import java.util.*;
-import edu.berkeley.fleet.api.*;
-import edu.berkeley.fleet.api.Instruction.*;
-import edu.berkeley.fleet.api.Instruction.Set;
-import edu.berkeley.fleet.api.Instruction.Set.SetDest;
-import edu.berkeley.fleet.api.Instruction.Set.FlagFunction;
-import edu.berkeley.fleet.two.*;
-import static edu.berkeley.fleet.util.BitManipulations.*;
-import static edu.berkeley.fleet.two.FleetTwoFleet.SHIFT;
-
-public class Util {
-
-    public static Instruction tail(Dock dock) { return new Tail(dock); }
-    public static Instruction nop(Dock dock, boolean looping) {
-        return new Set(dock, looping, Predicate.Default, FlagFunction.ZERO, FlagFunction.ZERO);
-    }
-    public static Instruction setOLC(Dock dock, int val) {
-        return new Set(dock, false, Predicate.Default, Set.SetDest.OuterLoopCounter, val);
-    }
-    public static Instruction setILC(Dock dock, int val) {
-        return new Set(dock, false, Predicate.Default, Set.SetDest.InnerLoopCounter, val);
-    }
-    public static Instruction setILCInfinity(Dock dock) {
-        return new Set(dock, false, Predicate.Default, Set.SetDest.InnerLoopCounter, Set.SetSource.Infinity);
-    }
-
-    public static Instruction recvDeliver(Dock dock) {
-        return new Move(dock, false, Predicate.Default, false, null, false, true, true, false, true, false);
-    }
-    public static Instruction recvDeliverAck(Dock dock, Dock ackTo) { return recvDeliverAck(dock, ackTo, false); }
-    public static Instruction recvDeliverAck(Dock dock, Dock ackTo, boolean looping) {
-        Path path = dock.getPath(ackTo.getDataDestination(), new BitVector(0));
-        return new Move(dock, looping, Predicate.Default, false, path, false, true, true, false, true, true);
-    }
-
-    public static Instruction notify(Dock dock, boolean looping, Dock ackTo) {
-        Path path = dock.getPath(ackTo.getDataDestination(), new BitVector(0));
-        return new Move(dock, looping, Predicate.Default, false, path, false, false, false, false, false, true);
-    }
-
-    public static void infiniteLiteral(Dock dock, long literal, ArrayList<Instruction> il) {
-        literal(dock, literal, il);
-        il.add(Util.setILCInfinity(dock));
-        il.add(Util.deliver(dock));
-    }
-
-    public static void literal(Dock dock, long literal, ArrayList<Instruction> il) { literal(dock, literal, il, false); }
-    public static void literal(Dock dock, long literal, ArrayList<Instruction> il, boolean looping) {
-        if (FleetTwoFleet.isSmallEnoughToFit(literal)) {
-            il.add(new Set(dock, looping, Predicate.Default, SetDest.DataLatch, (literal)));
-        } else {
-            int counter = 0;
-            while(counter < dock.getShip().getFleet().getWordWidth()) counter += SHIFT.valmaskwidth;
-            while(counter > 0) {
-                il.add(new Shift(dock, looping, Predicate.Default,
-                                 new BitVector(dock.getShip().getFleet().getWordWidth())
-                                 .set(getField(counter-1, counter-SHIFT.valmaskwidth, literal))));
-                counter -= SHIFT.valmaskwidth;
-            }
-        }
-    }
-
-    public static Instruction deliver(Dock dock) { return deliver(dock, false); }
-    public static Instruction deliver(Dock dock, boolean looping) {
-        return new Move(dock, looping, Predicate.Default, false, null, false, false, false, false, true, false);
-    }
-
-    public static Instruction collectSendto(Dock dock, Dock sendTo) { return collectSendto(dock, sendTo); }
-    public static Instruction collect(Dock dock, boolean looping) {
-        return new Move(dock, looping, Predicate.Default, false, null, false, true, true, false, false, false);
-    }
-    public static Instruction collectSendto(Dock dock, boolean looping, Dock sendTo) {
-        Path path = dock.getPath(sendTo.getDataDestination(), new BitVector(0));
-        return new Move(dock, looping, Predicate.Default, false, path, false, true, true, false, true, false);
-    }
-    public static Instruction sendto(Dock dock, boolean looping, Dock sendTo) {
-        Path path = dock.getPath(sendTo.getDataDestination(), new BitVector(0));
-        return new Move(dock, looping, Predicate.Default, false, path, false, false, false, false, true, false);
-    }
-
-    public static Instruction collectWaitSendto(Dock dock, Dock sendTo) { return collectWaitSendto(dock, false, sendTo); }
-    public static Instruction collectWaitSendto(Dock dock, boolean looping, Dock sendTo) {
-        Path path = dock.getPath(sendTo.getDataDestination(), new BitVector(0));
-        return new Move(dock, looping, Predicate.Default, false, path, true, true, true, false, true, false);
-    }
-    public static Instruction waitSendto(Dock dock, boolean looping, Dock sendTo) {
-        Path path = dock.getPath(sendTo.getDataDestination(), new BitVector(0));
-        return new Move(dock, looping, Predicate.Default, false, path, true, false, false, false, true, false);
-    }
-    public static Instruction wait(Dock dock, boolean looping) {
-        return new Move(dock, looping, Predicate.Default, false, null, true, false, false, false, false, false);
-    }
-    public static Instruction waitDeliver(Dock dock, boolean looping) {
-        return new Move(dock, looping, Predicate.Default, false, null, true, false, false, false, true, false);
-    }
-
-    public static void transfer(Dock source, Dock dest, int inFlight, ArrayList<Instruction> il) {
-        if (inFlight != 1) throw new RuntimeException();
-        il.add(Util.setILCInfinity(dest));
-        il.add(Util.recvDeliverAck(dest, source));
-        il.add(Util.collectSendto(source, dest));
-        il.add(Util.setILCInfinity(source));
-        il.add(Util.collectWaitSendto(source, dest));
-    }
-
-}
\ No newline at end of file