[add explicit registers to grin
John Meacham <john@repetae.net>**20100408110241
 Ignore-this: 3fb41943723271892e7913303659bec
] hunk ./src/Grin/Grin.hs 163
+    | GcPush                -- push some pointers onto the GC stack, returning registers representing the values on the stack
+    | NewRegister           -- create a new register
+    | ReadRegister          -- read a register
+    | WriteRegister         -- write to a register
hunk ./src/Grin/Grin.hs 238
+    | TyGcContext                -- ^ the context for garbage collection
+    | TyRegister Ty              -- ^ a register contains a mutable value, the register itself cannot be addressed, 
+                                 --   hence they may not be returned from functions or passed as arguments.
hunk ./src/Grin/Grin.hs 302
-    show TyRegion = "R"
+    show TyRegion = "M"
+    show TyGcContext = "GC"
+    show (TyRegister t) = 'r':show t
hunk ./src/Grin/Grin.hs 317
-        | TyRegion <- t = text "r" <> tshow i
---        | TyPtr TyINode <- t = text "np" <> tshow i
+        | TyRegion <- t = text "m" <> tshow i
+        | TyRegister ty <- t = text "r" <> tshow (Var (V i) ty)
+        | TyGcContext <- t = text "gc" <> tshow i
hunk ./src/Grin/Grin.hs 523
+    getType (BaseOp NewRegister xs) = map (TyRegister . getType) xs
+    getType (BaseOp WriteRegister _) = []
+    getType (BaseOp ReadRegister [r]) = case getType r of
+        TyRegister t -> [t]
+        _ -> error "Exp.getType: ReadRegister of non register"
hunk ./src/Grin/Grin.hs 551
-        t -> TyPtr t
+        t -> error "Val.getType: Const of non-node"
hunk ./src/Grin/Noodle.hs 6
-import Data.Monoid
hunk ./src/Grin/Noodle.hs 166
+isOmittable (BaseOp ReadRegister _) = True
+isOmittable (BaseOp NewRegister _) = True
+isOmittable (BaseOp GcPush _) = True  -- omittable because if we don't use the returned gc context, then we don't need to push to begin with
hunk ./src/Grin/Noodle.hs 171
---isOmittable (Store x) | getType x /= TyNode = False
---isOmittable (Store {}) = True
hunk ./src/Grin/Noodle.hs 179
+isErrOmittable (BaseOp WriteRegister _) = True
hunk ./src/Grin/Noodle.hs 184
-
-
--- collect tail called, and normally called functions
-
+-- collect tail and normally called functions
hunk ./src/Grin/Noodle.hs 205
---        cfunc Store {} = return mempty
hunk ./src/Grin/Optimize.hs 186
---        h (Update v (NodeC t xs)) | not (isMutableNodeTag t), t `member` sset = do
---            let t' = tagFlipFunction t
---            mtick $ "Optimize.speculate.update.{" ++ show t'
---            return (App t' xs [TyNode] :>>= [n1] :-> Update v n1)
hunk ./src/Grin/Show.hs 93
+prettyExp vl (BaseOp NewRegister xs) = vl <> keyword "register" <+> tupled (map prettyVal xs)
+prettyExp vl (BaseOp WriteRegister [r,x]) = vl <> prettyVal r <+> keyword ":=" <+> prettyVal x
+prettyExp vl (BaseOp ReadRegister [r]) = vl <> keyword "*" <> prettyVal r
+prettyExp vl (BaseOp GcPush xs) = vl <> keyword "gcPush" <+> tupled (map prettyVal xs)