module LLVM.General.AST.Global where
import LLVM.General.Prelude
import LLVM.General.AST.Name
import LLVM.General.AST.Type
import LLVM.General.AST.Constant (Constant)
import LLVM.General.AST.AddrSpace
import LLVM.General.AST.Instruction (Named, Instruction, Terminator)
import qualified LLVM.General.AST.Linkage as L
import qualified LLVM.General.AST.Visibility as V
import qualified LLVM.General.AST.CallingConvention as CC
import qualified LLVM.General.AST.Attribute as A
data Global
= GlobalVariable {
name :: Name,
linkage :: L.Linkage,
visibility :: V.Visibility,
isThreadLocal :: Bool,
addrSpace :: AddrSpace,
hasUnnamedAddr :: Bool,
isConstant :: Bool,
type' :: Type,
initializer :: Maybe Constant,
section :: Maybe String,
alignment :: Word32
}
| GlobalAlias {
name :: Name,
linkage :: L.Linkage,
visibility :: V.Visibility,
type' :: Type,
aliasee :: Constant
}
| Function {
linkage :: L.Linkage,
visibility :: V.Visibility,
callingConvention :: CC.CallingConvention,
returnAttributes :: [A.ParameterAttribute],
returnType :: Type,
name :: Name,
parameters :: ([Parameter],Bool),
functionAttributes :: [A.FunctionAttribute],
section :: Maybe String,
alignment :: Word32,
garbageCollectorName :: Maybe String,
basicBlocks :: [BasicBlock]
}
deriving (Eq, Read, Show, Typeable, Data)
data Parameter = Parameter Type Name [A.ParameterAttribute]
deriving (Eq, Read, Show, Typeable, Data)
data BasicBlock = BasicBlock Name [Named Instruction] (Named Terminator)
deriving (Eq, Read, Show, Typeable, Data)
globalVariableDefaults :: Global
globalVariableDefaults =
GlobalVariable {
name = error "global variable name not defined",
linkage = L.External,
visibility = V.Default,
isThreadLocal = False,
addrSpace = AddrSpace 0,
hasUnnamedAddr = False,
isConstant = False,
type' = error "global variable type not defined",
initializer = Nothing,
section = Nothing,
alignment = 0
}
globalAliasDefaults :: Global
globalAliasDefaults =
GlobalAlias {
name = error "global alias name not defined",
linkage = L.External,
visibility = V.Default,
type' = error "global alias type not defined",
aliasee = error "global alias aliasee not defined"
}
functionDefaults :: Global
functionDefaults =
Function {
linkage = L.External,
visibility = V.Default,
callingConvention = CC.C,
returnAttributes = [],
returnType = error "function return type not defined",
name = error "function name not defined",
parameters = ([], False),
functionAttributes = [],
section = Nothing,
alignment = 0,
garbageCollectorName = Nothing,
basicBlocks = []
}