llvmutil

package
v0.35.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 4 Imported by: 0

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

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

func ByteOrder(target string) binary.ByteOrder

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.

func Version added in v0.32.0

func Version() int

Version returns the LLVM major version.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL