ghc-7.6.1: The GHC API

Safe HaskellNone

LlvmCodeGen.Base

Description

Base LLVM Code Generation module

Contains functions useful through out the code generator.

Synopsis

Documentation

type LlvmUnresData = (CLabel, Section, LlvmType, [UnresStatic])

Unresolved code. Of the form: (data label, data type, unresolved data)

type LlvmData = ([LMGlobal], [LlvmType])

Top level LLVM Data (globals and type aliases)

type UnresLabel = CmmLit

An unresolved Label.

Labels are unresolved when we haven't yet determined if they are defined in the module we are currently compiling, or an external one.

type LlvmVersion = Int

LLVM Version Number

defaultLlvmVersion :: LlvmVersion

The LLVM Version we assume if we don't know

data LlvmEnv

initLlvmEnv :: DynFlags -> LlvmEnv

Get initial Llvm environment.

clearVars :: LlvmEnv -> LlvmEnv

Clear variables from the environment.

varLookup :: Uniquable key => key -> LlvmEnv -> Maybe LlvmType

Lookup local variables in the environment.

varInsert :: Uniquable key => key -> LlvmType -> LlvmEnv -> LlvmEnv

Insert local variables into the environment.

funLookup :: Uniquable key => key -> LlvmEnv -> Maybe LlvmType

Lookup functions in the environment.

funInsert :: Uniquable key => key -> LlvmType -> LlvmEnv -> LlvmEnv

Insert functions into the environment.

getLlvmVer :: LlvmEnv -> LlvmVersion

Get the LLVM version we are generating code for

setLlvmVer :: LlvmVersion -> LlvmEnv -> LlvmEnv

Set the LLVM version we are generating code for

getLlvmPlatform :: LlvmEnv -> Platform

Get the platform we are generating code for

getDflags :: LlvmEnv -> DynFlags

Get the DynFlags for this compilation pass

ghcInternalFunctions :: [(LMString, LlvmFunctionDecl)]

Here we pre-initialise some functions that are used internally by GHC so as to make sure they have the most general type in the case that user code also uses these functions but with a different type than GHC internally. (Main offender is treating return type as void instead of 'void *'. Fixes trac #5486.

cmmToLlvmType :: CmmType -> LlvmType

Translate a basic CmmType to an LlvmType.

widthToLlvmFloat :: Width -> LlvmType

Translate a Cmm Float Width to a LlvmType.

widthToLlvmInt :: Width -> LlvmType

Translate a Cmm Bit Width to a LlvmType.

llvmFunTy :: LlvmType

Llvm Function type for Cmm function

llvmFunSig :: LlvmEnv -> CLabel -> LlvmLinkageType -> LlvmFunctionDecl

Llvm Function signature

llvmStdFunAttrs :: [LlvmFuncAttr]

Llvm standard fun attributes

llvmFunAlign :: LMAlign

Alignment to use for functions

llvmInfAlign :: LMAlign

Alignment to use for into tables

llvmPtrBits :: Int

Pointer width

mkLlvmFunc :: LlvmEnv -> CLabel -> LlvmLinkageType -> LMSection -> LlvmBlocks -> LlvmFunction

Create a Haskell function in LLVM.

tysToParams :: [LlvmType] -> [LlvmParameter]

Convert a list of types to a list of function parameters (each with no parameter attributes)

strCLabel_llvm :: LlvmEnv -> CLabel -> LMString

Pretty print a CLabel.

genCmmLabelRef :: LlvmEnv -> CLabel -> LMGlobal

Create an external definition for a CLabel defined in another module.

genStringLabelRef :: LMString -> LMGlobal

As above (genCmmLabelRef) but taking a LMString, not CLabel.