Moduleghc-9.10.3GHC2021
GHC.CmmToLlvm.Base
Base LLVM Code Generation module
Contains functions useful through out the code generator.
- 8 types
- 39 values
- Packageghc-9.10.3
- Exports47
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceBase.hs
Global registers live on proc entry
Unresolved code. Of the form: (data label, data type, unresolved data)
Top level LLVM Data (globals and type aliases)
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.
The Llvm monad. Wraps LlvmEnv state as well as the IO monad
Instances5Monad, Functor, Applicative, HasLogger, MonadUnique
Monad LlvmMDefined in ghc-9.10.3 · GHC.CmmToLlvm.BaseFunctor LlvmMDefined in ghc-9.10.3 · GHC.CmmToLlvm.BaseApplicative LlvmMDefined in ghc-9.10.3 · GHC.CmmToLlvm.BaseHasLogger LlvmMDefined in ghc-9.10.3 · GHC.CmmToLlvm.BaseMonadUnique LlvmMDefined in ghc-9.10.3 · GHC.CmmToLlvm.Base
Get initial Llvm environment.
Clear variables from the environment for a subcomputation
Lookup variables or functions in the environment.
Insert variables or functions into the environment.
Set a register as allocated on the stack
Check whether a register is allocated on the stack
Lookup variables or functions in the environment.
Insert variables or functions into the environment.
Get the LLVM version we are generating code for
Dumps the document if the corresponding flag has been set by the user
Prints the given contents to the output handle
Marks a variable as "used"
Return all variables marked as "used" so far
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 #5486.
Get target platform
Allocate a new global unnamed metadata identifier
Sets metadata node for a given unique
Gets metadata node for given unique
Lifting of IO actions. Not exported, as we want to encapsulate IO.
Translate a basic CmmType to an LlvmType.
Translate a Cmm Float Width to a LlvmType.
Translate a Cmm Bit Width to a LlvmType.
Llvm Function type for Cmm function
Llvm Function signature
A Function's arguments
Llvm standard fun attributes
Alignment to use for functions
Alignment to use for into tables
Pointer width
Convert a list of types to a list of function parameters (each with no parameter attributes)
Section to use for a function
Return a list of "padding" registers for LLVM function calls.
When we generate LLVM function signatures, we can't just make any register alive on function entry. Instead, we need to insert fake arguments of the same register class until we are sure that one of them is mapped to the register we want alive. E.g. to ensure that F5 is alive, we may need to insert fake arguments mapped to F1, F2, F3 and F4.
Invariant: Cmm FPR regs with number "n" maps to real registers with number "n" If the calling convention uses registers in a different order or if the invariant doesn't hold, this code probably won't be correct.
Pretty print a CLabel.
Create/get a pointer to a global value. Might return an alias if the value in question hasn't been defined yet. We especially make no guarantees on the type of the returned pointer.
Generate definitions for aliases forward-referenced by getGlobalPtr.
Must be called at a point where we are sure that no new global definitions will be generated anymore!
Here we take a global variable definition, rename it with a
$def suffix, and generate the appropriate alias.
Derive the definition label. It has an identified structure type.