add Context.literal(BitVector)
authoradam <adam@megacz.com>
Mon, 3 Nov 2008 10:13:58 +0000 (11:13 +0100)
committeradam <adam@megacz.com>
Mon, 3 Nov 2008 10:13:58 +0000 (11:13 +0100)
src/edu/berkeley/fleet/ir/Context.java

index 40da894..b7b22ac 100644 (file)
@@ -217,6 +217,22 @@ public class Context {
         }
 
         /** sets the data latch to a literal value */
+        public void literal(BitVector literal) {
+            // FIXME: code duplication here
+            // FIXME: be more intelligent here to avoid shifts if possible?
+            int counter = 0;
+            while(counter < dock.getShip().getFleet().getWordWidth()) counter += fleet.getShiftWidth();
+            while(counter > 0) {
+                BitVector temp = new BitVector(dock.getShip().getFleet().getShiftWidth());
+                for(int i=counter-1; i>=counter-fleet.getShiftWidth(); i--)
+                    if (i<literal.length())
+                        temp.set(i-(counter-fleet.getShiftWidth()), literal.get(i));
+                instructions.add(new Shift(dock, count!=1, predicate, temp));
+                counter -= fleet.getShiftWidth();
+            }
+        }
+
+        /** sets the data latch to a literal value */
         public void literal(long literal) {
             flush_pending();
             if (((FleetTwoFleet)fleet).isSmallEnoughToFit(literal)) {