summaryrefslogtreecommitdiff
path: root/compiler/llvmGen/Llvm/Types.hs
diff options
context:
space:
mode:
authorPeter Wortmann <scpmw@leeds.ac.uk>2013-06-26 15:43:45 +0100
committerDavid Terei <davidterei@gmail.com>2013-06-27 13:39:11 -0700
commit720a87c7ec967ff878f081bd3cc810cae3fe4a50 (patch)
tree925703005df243eb21e175ebf9d817e998292731 /compiler/llvmGen/Llvm/Types.hs
parent99d39221cfa6f6b8ccf950763a73ad32edd7beef (diff)
downloadhaskell-720a87c7ec967ff878f081bd3cc810cae3fe4a50.tar.gz
Extend globals to aliases
Also give them a proper constructor - getGlobalVar and getGlobalValue map directly to the accessors.
Diffstat (limited to 'compiler/llvmGen/Llvm/Types.hs')
-rw-r--r--compiler/llvmGen/Llvm/Types.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/llvmGen/Llvm/Types.hs b/compiler/llvmGen/Llvm/Types.hs
index 2f165a2240..3ccdfecb14 100644
--- a/compiler/llvmGen/Llvm/Types.hs
+++ b/compiler/llvmGen/Llvm/Types.hs
@@ -27,7 +27,11 @@ import GHC.Float
--
-- | A global mutable variable. Maybe defined or external
-type LMGlobal = (LlvmVar, Maybe LlvmStatic)
+data LMGlobal = LMGlobal {
+ getGlobalVar :: LlvmVar, -- ^ Returns the variable of the 'LMGlobal'
+ getGlobalValue :: Maybe LlvmStatic -- ^ Return the value of the 'LMGlobal'
+ }
+
-- | A String in LLVM
type LMString = FastString
@@ -86,7 +90,11 @@ ppParams varg p
-- | An LLVM section definition. If Nothing then let LLVM decide the section
type LMSection = Maybe LMString
type LMAlign = Maybe Int
-type LMConst = Bool -- ^ is a variable constant or not
+
+data LMConst = Global -- ^ Mutable global variable
+ | Constant -- ^ Constant global variable
+ | Alias -- ^ Alias of another variable
+ deriving (Eq)
-- | LLVM Variables
data LlvmVar
@@ -239,14 +247,6 @@ getStatType (LMAdd t _) = getStatType t
getStatType (LMSub t _) = getStatType t
getStatType (LMComment _) = error "Can't call getStatType on LMComment!"
--- | Return the 'LlvmType' of the 'LMGlobal'
-getGlobalType :: LMGlobal -> LlvmType
-getGlobalType (v, _) = getVarType v
-
--- | Return the 'LlvmVar' part of a 'LMGlobal'
-getGlobalVar :: LMGlobal -> LlvmVar
-getGlobalVar (v, _) = v
-
-- | Return the 'LlvmLinkageType' for a 'LlvmVar'
getLink :: LlvmVar -> LlvmLinkageType
getLink (LMGlobalVar _ _ l _ _ _) = l
@@ -634,7 +634,7 @@ instance Outputable LlvmLinkageType where
-- in Llvm.
ppr ExternallyVisible = empty
ppr External = text "external"
-
+ ppr Private = text "private"
-- -----------------------------------------------------------------------------
-- * LLVM Operations