Documentation ¶
Overview ¶
Package llvmutil contains utility functions used across multiple compiler packages. For example, they may be used by both the compiler package 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 AppendToGlobal(mod llvm.Module, globalName string, values ...llvm.Value)
- func ByteOrder(target string) binary.ByteOrder
- 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, size llvm.Value)
- func EmitLifetimeEnd(builder llvm.Builder, mod llvm.Module, ptr, size llvm.Value)
- func SplitBasicBlock(builder llvm.Builder, afterInst llvm.Value, insertAfter llvm.BasicBlock, ...) llvm.BasicBlock
- func Version() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendToGlobal ¶ added in v0.27.0
func AppendToGlobal(mod llvm.Module, globalName string, values ...llvm.Value)
AppendToGlobal appends the given values to a global array like llvm.used. The global might not exist yet. The values can be any pointer type, they will be cast to i8*.
func ByteOrder ¶ added in v0.34.0
Return the byte order for the given target triple. Most targets are little endian, but for example MIPS can be big-endian.
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, size llvm.Value)
CreateTemporaryAlloca creates a new alloca in the entry block and adds lifetime start information 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 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.