Documentation ¶
Overview ¶
Package llvmutil contains utility functions used across multiple compiler packages. For example, they may be used by both the compiler pacakge and transformation packages.
Normally, utility packages are avoided. However, in this case, the utility functions are non-trivial and hard to get right. Copying them to multiple places would be a big risk if only one of them is updated.
Index ¶
- func CreateEntryBlockAlloca(builder llvm.Builder, t llvm.Type, name string) llvm.Value
- func CreateInstructionAlloca(builder llvm.Builder, mod llvm.Module, t llvm.Type, inst llvm.Value, ...) llvm.Value
- func CreateTemporaryAlloca(builder llvm.Builder, mod llvm.Module, t llvm.Type, name string) (alloca, bitcast, size llvm.Value)
- func EmitLifetimeEnd(builder llvm.Builder, mod llvm.Module, ptr, size llvm.Value)
- func EmitPointerPack(builder llvm.Builder, mod llvm.Module, prefix string, needsStackObjects bool, ...) llvm.Value
- func EmitPointerUnpack(builder llvm.Builder, mod llvm.Module, ptr llvm.Value, valueTypes []llvm.Type) []llvm.Value
- func SplitBasicBlock(builder llvm.Builder, afterInst llvm.Value, insertAfter llvm.BasicBlock, ...) llvm.BasicBlock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateEntryBlockAlloca ¶
func CreateEntryBlockAlloca(builder llvm.Builder, t llvm.Type, name string) llvm.Value
CreateEntryBlockAlloca creates a new alloca in the entry block, even though the IR builder is located elsewhere. It assumes that the insert point is at the end of the current block.
func CreateInstructionAlloca ¶
func CreateInstructionAlloca(builder llvm.Builder, mod llvm.Module, t llvm.Type, inst llvm.Value, name string) llvm.Value
CreateInstructionAlloca creates an alloca in the entry block, and places lifetime control intrinsics around the instruction
func CreateTemporaryAlloca ¶
func CreateTemporaryAlloca(builder llvm.Builder, mod llvm.Module, t llvm.Type, name string) (alloca, bitcast, size llvm.Value)
CreateTemporaryAlloca creates a new alloca in the entry block and adds lifetime start infromation in the IR signalling that the alloca won't be used before this point.
This is useful for creating temporary allocas for intrinsics. Don't forget to end the lifetime using emitLifetimeEnd after you're done with it.
func EmitLifetimeEnd ¶
func EmitLifetimeEnd(builder llvm.Builder, mod llvm.Module, ptr, size llvm.Value)
EmitLifetimeEnd signals the end of an (alloca) lifetime by calling the llvm.lifetime.end intrinsic. It is commonly used together with createTemporaryAlloca.
func EmitPointerPack ¶
func EmitPointerPack(builder llvm.Builder, mod llvm.Module, prefix string, needsStackObjects bool, values []llvm.Value) llvm.Value
EmitPointerPack packs the list of values into a single pointer value using bitcasts, or else allocates a value on the heap if it cannot be packed in the pointer value directly. It returns the pointer with the packed data. If the values are all constants, they are be stored in a constant global and deduplicated.
func EmitPointerUnpack ¶
func EmitPointerUnpack(builder llvm.Builder, mod llvm.Module, ptr llvm.Value, valueTypes []llvm.Type) []llvm.Value
EmitPointerUnpack extracts a list of values packed using EmitPointerPack.
func SplitBasicBlock ¶ added in v0.11.0
func SplitBasicBlock(builder llvm.Builder, afterInst llvm.Value, insertAfter llvm.BasicBlock, name string) llvm.BasicBlock
SplitBasicBlock splits a LLVM basic block into two parts. All instructions after afterInst are moved into a new basic block (created right after the current one) with the given name.
Types ¶
This section is empty.