LLVM: Add in literal undefined value to binding
[ghc-hetmet.git] / compiler / llvmGen / Llvm / Types.hs
index af2ae9e..0d66dd3 100644 (file)
@@ -99,6 +99,10 @@ data LlvmLit
   = LMIntLit Integer LlvmType
   -- | Floating point literal
   | LMFloatLit Double LlvmType
+  -- | Literal NULL, only applicable to pointer types
+  | LMNullLit LlvmType
+  -- | Undefined value, random bit pattern. Useful for optimisations.
+  | LMUndefLit LlvmType
   deriving (Eq)
 
 instance Show LlvmLit where
@@ -205,6 +209,8 @@ getLit (LMIntLit   i _) = show ((fromInteger i)::Int)
 getLit (LMFloatLit r LMFloat ) = fToStr $ realToFrac r
 getLit (LMFloatLit r LMDouble) = dToStr r
 getLit f@(LMFloatLit _ _) = error $ "Can't print this float literal!" ++ show f
+getLit (LMNullLit _) = "null"
+getLit (LMUndefLit _) = "undef"
 
 -- | Return the 'LlvmType' of the 'LlvmVar'
 getVarType :: LlvmVar -> LlvmType
@@ -217,6 +223,8 @@ getVarType (LMLitVar    l          ) = getLitType l
 getLitType :: LlvmLit -> LlvmType
 getLitType (LMIntLit   _ t) = t
 getLitType (LMFloatLit _ t) = t
+getLitType (LMNullLit    t) = t
+getLitType (LMUndefLit   t) = t
 
 -- | Return the 'LlvmType' of the 'LlvmStatic'
 getStatType :: LlvmStatic -> LlvmType