aboutsummaryrefslogtreecommitdiff
path: root/Intermediate.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Intermediate.hs')
-rw-r--r--Intermediate.hs12
1 files changed, 11 insertions, 1 deletions
diff --git a/Intermediate.hs b/Intermediate.hs
index d2ac549..dde941d 100644
--- a/Intermediate.hs
+++ b/Intermediate.hs
@@ -12,7 +12,7 @@ import Pretty
data BB = BB Id [IRIns] IRTerm
deriving (Show, Eq)
-data Ref = Temp Size Int | Argument Size Name | Global Size Name | Constant Size Value
+data Ref = Temp Size Int | StructTemp Size Int | Argument Size Name | Global Size Name | Constant Size Value
deriving (Show, Eq, Ord)
data IRProgram = IRProgram [DVar] [IRFunc]
@@ -26,6 +26,8 @@ data IRIns
| ILea Ref Name
| IStore Ref Ref
| ILoad Ref Ref
+ | ISet Ref Offset Ref
+ | IGet Ref Ref Offset
| IAri ArithType Ref Ref Ref -- destination, operand 1, operand 2
| ICall Name [Ref]
| ICallr Ref Name [Ref]
@@ -66,6 +68,7 @@ instance Pretty BB where
instance Pretty Ref where
prettyI _ (Temp sz k) = "t" ++ show k ++ pretty_sizeSuffix sz
+ prettyI _ (StructTemp sz k) = "s" ++ show k ++ "{" ++ show sz ++ "}"
prettyI _ (Argument sz n) = "a" ++ n ++ pretty_sizeSuffix sz
prettyI _ (Global sz n) = "g" ++ n ++ pretty_sizeSuffix sz
prettyI _ (Constant sz n) = show n ++ pretty_sizeSuffix sz
@@ -103,6 +106,8 @@ instance Pretty IRIns where
prettyI _ (ILea d s) = "lea " ++ pretty d ++ " <- &[" ++ s ++ "]"
prettyI _ (IStore d s) = "store *" ++ pretty d ++ " <- " ++ pretty s
prettyI _ (ILoad d s) = "load " ++ pretty d ++ " <- *" ++ pretty s
+ prettyI _ (ISet d off s) = "set " ++ pretty d ++ ".[" ++ show off ++ "] <- " ++ pretty s
+ prettyI _ (IGet d s off) = "get " ++ pretty d ++ " <- " ++ pretty s ++ ".[" ++ show off ++ "]"
prettyI _ (IAri at d s1 s2) =
pretty at ++ " " ++ pretty d ++ " <- " ++ pretty s1 ++ ", " ++ pretty s2
prettyI _ (ICall n al) =
@@ -156,10 +161,15 @@ blockIdOf (BB bid _ _) = bid
refSize :: Ref -> Size
refSize (Temp sz _) = sz
+refSize (StructTemp sz _) = sz
refSize (Argument sz _) = sz
refSize (Global sz _) = sz
refSize (Constant sz _) = sz
+isStructTemp :: Ref -> Bool
+isStructTemp (StructTemp _ _) = True
+isStructTemp _ = False
+
isConstant :: Ref -> Bool
isConstant (Constant _ _) = True
isConstant _ = False