diff options
author | David Terei <davidterei@gmail.com> | 2010-07-07 14:20:53 +0000 |
---|---|---|
committer | David Terei <davidterei@gmail.com> | 2010-07-07 14:20:53 +0000 |
commit | e553a60151dc282c8b8c201871212cba0c3bf2a0 (patch) | |
tree | 69157e382a4fc794eed0ae414130a97f6b8c899c /compiler/llvmGen/Llvm | |
parent | d7b861369fa96494659b41b31d8935d65fdeaaae (diff) | |
download | haskell-e553a60151dc282c8b8c201871212cba0c3bf2a0.tar.gz |
LLVM: Add alias type defenitions to LlvmModule.
Diffstat (limited to 'compiler/llvmGen/Llvm')
-rw-r--r-- | compiler/llvmGen/Llvm/AbsSyn.hs | 3 | ||||
-rw-r--r-- | compiler/llvmGen/Llvm/PpLlvm.hs | 23 | ||||
-rw-r--r-- | compiler/llvmGen/Llvm/Types.hs | 34 |
3 files changed, 30 insertions, 30 deletions
diff --git a/compiler/llvmGen/Llvm/AbsSyn.hs b/compiler/llvmGen/Llvm/AbsSyn.hs index 7a5b70048f..6b613689e5 100644 --- a/compiler/llvmGen/Llvm/AbsSyn.hs +++ b/compiler/llvmGen/Llvm/AbsSyn.hs @@ -28,6 +28,9 @@ data LlvmModule = LlvmModule { -- | Comments to include at the start of the module. modComments :: [LMString], + -- | LLVM Alias type defenitions. + modAliases :: [LlvmAlias], + -- | Global variables to include in the module. modGlobals :: [LMGlobal], diff --git a/compiler/llvmGen/Llvm/PpLlvm.hs b/compiler/llvmGen/Llvm/PpLlvm.hs index 4391fc58a2..1a419544f0 100644 --- a/compiler/llvmGen/Llvm/PpLlvm.hs +++ b/compiler/llvmGen/Llvm/PpLlvm.hs @@ -10,8 +10,8 @@ module Llvm.PpLlvm ( ppLlvmComment, ppLlvmGlobals, ppLlvmGlobal, - ppLlvmType, - ppLlvmTypes, + ppLlvmAlias, + ppLlvmAliases, ppLlvmFunctionDecls, ppLlvmFunctionDecl, ppLlvmFunctions, @@ -38,9 +38,11 @@ import Unique -- | Print out a whole LLVM module. ppLlvmModule :: LlvmModule -> Doc -ppLlvmModule (LlvmModule comments globals decls funcs) +ppLlvmModule (LlvmModule comments aliases globals decls funcs) = ppLlvmComments comments $+$ empty + $+$ ppLlvmAliases aliases + $+$ empty $+$ ppLlvmGlobals globals $+$ empty $+$ ppLlvmFunctionDecls decls @@ -83,19 +85,12 @@ ppLlvmGlobal oth = error $ "Non Global var ppr as global! " ++ show oth -- | Print out a list of LLVM type aliases. -ppLlvmTypes :: [LlvmType] -> Doc -ppLlvmTypes tys = vcat $ map ppLlvmType tys +ppLlvmAliases :: [LlvmAlias] -> Doc +ppLlvmAliases tys = vcat $ map ppLlvmAlias tys -- | Print out an LLVM type alias. -ppLlvmType :: LlvmType -> Doc - -ppLlvmType al@(LMAlias _ t) - = texts al <+> equals <+> text "type" <+> texts t - -ppLlvmType (LMFunction t) - = ppLlvmFunctionDecl t - -ppLlvmType _ = empty +ppLlvmAlias :: LlvmAlias -> Doc +ppLlvmAlias (name, ty) = text "%" <> ftext name <+> equals <+> text "type" <+> texts ty -- | Print out a list of function definitions. diff --git a/compiler/llvmGen/Llvm/Types.hs b/compiler/llvmGen/Llvm/Types.hs index 0a39d38eb5..0a4fff2807 100644 --- a/compiler/llvmGen/Llvm/Types.hs +++ b/compiler/llvmGen/Llvm/Types.hs @@ -22,24 +22,26 @@ import PprBase -- -- | A global mutable variable. Maybe defined or external -type LMGlobal = (LlvmVar, Maybe LlvmStatic) +type LMGlobal = (LlvmVar, Maybe LlvmStatic) -- | A String in LLVM -type LMString = FastString +type LMString = FastString +-- | A type alias +type LlvmAlias = (LMString, LlvmType) --- | Llvm Types. +-- | Llvm Types data LlvmType - = LMInt Int -- ^ An integer with a given width in bits. - | LMFloat -- ^ 32 bit floating point - | LMDouble -- ^ 64 bit floating point - | LMFloat80 -- ^ 80 bit (x86 only) floating point - | LMFloat128 -- ^ 128 bit floating point - | LMPointer LlvmType -- ^ A pointer to a 'LlvmType' - | LMArray Int LlvmType -- ^ An array of 'LlvmType' - | LMLabel -- ^ A 'LlvmVar' can represent a label (address) - | LMVoid -- ^ Void type - | LMStruct [LlvmType] -- ^ Structure type - | LMAlias LMString LlvmType -- ^ A type alias + = LMInt Int -- ^ An integer with a given width in bits. + | LMFloat -- ^ 32 bit floating point + | LMDouble -- ^ 64 bit floating point + | LMFloat80 -- ^ 80 bit (x86 only) floating point + | LMFloat128 -- ^ 128 bit floating point + | LMPointer LlvmType -- ^ A pointer to a 'LlvmType' + | LMArray Int LlvmType -- ^ An array of 'LlvmType' + | LMLabel -- ^ A 'LlvmVar' can represent a label (address) + | LMVoid -- ^ Void type + | LMStruct [LlvmType] -- ^ Structure type + | LMAlias LlvmAlias -- ^ A type alias -- | Function type, used to create pointers to functions | LMFunction LlvmFunctionDecl @@ -66,7 +68,7 @@ instance Show LlvmType where _otherwise -> "" in show r ++ " (" ++ args ++ varg' ++ ")" - show (LMAlias s _ ) = "%" ++ unpackFS s + show (LMAlias (s,_)) = "%" ++ unpackFS s -- | An LLVM section defenition. If Nothing then let LLVM decide the section type LMSection = Maybe LMString @@ -318,7 +320,7 @@ llvmWidthInBits LMLabel = 0 llvmWidthInBits LMVoid = 0 llvmWidthInBits (LMStruct tys) = sum $ map llvmWidthInBits tys llvmWidthInBits (LMFunction _) = 0 -llvmWidthInBits (LMAlias _ t) = llvmWidthInBits t +llvmWidthInBits (LMAlias (_,t)) = llvmWidthInBits t -- ----------------------------------------------------------------------------- |