llvm

package module
v0.0.0-...-d4249bf Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 11 Imported by: 2

README

go-llvm

This library provides bindings to a system-installed LLVM.

Currently supported:

  • LLVM 15
  • LLVM 16
  • LLVM 17

Usage

First, you need to make sure that you have installed a supported version of LLVM.

And then

go get github.com/kkkunny/go-llvm
curl -O https://raw.githubusercontent.com/kkkunny/go-llvm/master/Makefile
make config EXPECT_VERSION=VERION OF LLVM
# eg.make config EXPECT_VERSION=15
package main

import (
	"os"

	"github.com/kkkunny/go-llvm"
)

func main() {
	ctx := llvm.NewContext()
	module := ctx.NewModule("main")
	builder := ctx.NewBuilder()

	mainFn := module.NewFunction("main", ctx.FunctionType(false, ctx.IntegerType(8)))
	mainFnEntry := mainFn.NewBlock("entry")
	builder.MoveToAfter(mainFnEntry)
	var ret llvm.Value = ctx.ConstInteger(ctx.IntegerType(8), 0)
	builder.CreateRet(&ret)

	_ = llvm.InitializeNativeTarget()
	_ = llvm.InitializeNativeAsmPrinter()

	jiter, err := llvm.NewJITCompiler(module, llvm.CodeOptLevelNone)
	if err != nil {
		panic(err)
	}
	os.Exit(int(jiter.RunMainFunction(mainFn, nil, nil)))
}

Documentation

Index

Constants

View Source
const (
	ExternalLinkage            = Linkage(binding.LLVMExternalLinkage)
	AvailableExternallyLinkage = Linkage(binding.LLVMAvailableExternallyLinkage)
	LinkOnceAnyLinkage         = Linkage(binding.LLVMLinkOnceAnyLinkage)
	LinkOnceODRLinkage         = Linkage(binding.LLVMLinkOnceODRLinkage)
	LinkOnceODRAutoHideLinkage = Linkage(binding.LLVMLinkOnceODRAutoHideLinkage)
	WeakAnyLinkage             = Linkage(binding.LLVMWeakAnyLinkage)
	WeakODRLinkage             = Linkage(binding.LLVMWeakODRLinkage)
	AppendingLinkage           = Linkage(binding.LLVMAppendingLinkage)
	InternalLinkage            = Linkage(binding.LLVMInternalLinkage)
	PrivateLinkage             = Linkage(binding.LLVMPrivateLinkage)
	DLLImportLinkage           = Linkage(binding.LLVMDLLImportLinkage)
	DLLExportLinkage           = Linkage(binding.LLVMDLLExportLinkage)
	ExternalWeakLinkage        = Linkage(binding.LLVMExternalWeakLinkage)
	GhostLinkage               = Linkage(binding.LLVMGhostLinkage)
	CommonLinkage              = Linkage(binding.LLVMCommonLinkage)
	LinkerPrivateLinkage       = Linkage(binding.LLVMLinkerPrivateLinkage)
	LinkerPrivateWeakLinkage   = Linkage(binding.LLVMLinkerPrivateWeakLinkage)
)
View Source
const (
	DefaultVisibility   = Visibility(binding.LLVMDefaultVisibility)
	HiddenVisibility    = Visibility(binding.LLVMHiddenVisibility)
	ProtectedVisibility = Visibility(binding.LLVMProtectedVisibility)
)
View Source
const (
	RelocModeDefault      = RelocMode(binding.LLVMRelocDefault)
	RelocModeStatic       = RelocMode(binding.LLVMRelocStatic)
	RelocModePIC          = RelocMode(binding.LLVMRelocPIC)
	RelocModeDynamicNoPic = RelocMode(binding.LLVMRelocDynamicNoPic)
	RelocModeROPI         = RelocMode(binding.LLVMRelocROPI)
	RelocModeRWPI         = RelocMode(binding.LLVMRelocRWPI)
	RelocModeROPI_RWPI    = RelocMode(binding.LLVMRelocROPI_RWPI)
)
View Source
const (
	FloatTypeKindHalf     = FloatTypeKind(binding.LLVMHalfTypeKind)
	FloatTypeKindBFloat   = FloatTypeKind(binding.LLVMBFloatTypeKind)
	FloatTypeKindFloat    = FloatTypeKind(binding.LLVMFloatTypeKind)
	FloatTypeKindDouble   = FloatTypeKind(binding.LLVMDoubleTypeKind)
	FloatTypeKindX86FP80  = FloatTypeKind(binding.LLVMX86_FP80TypeKind)
	FloatTypeKindFP128    = FloatTypeKind(binding.LLVMFP128TypeKind)
	FloatTypeKindPPCFP128 = FloatTypeKind(binding.LLVMPPC_FP128TypeKind)
)
View Source
const MajorVersion = binding.LLVM_VERSION_MAJOR

MajorVersion LLVM大版本号

Version LLVM版本号

Variables

View Source
var (
	// CPUName cpu名称
	CPUName = binding.LLVMGetHostCPUName()
	// CPUFeatures cpu特性
	CPUFeatures = binding.LLVMGetHostCPUFeatures()
	// PointerSize 指针大小(字节)
	PointerSize = unsafe.Sizeof(uintptr(0))
)
View Source
var ErrUnknownArch = errors.New("unknown arch")

ErrUnknownArch 未知的架构

Functions

func InitializeAllAsmParsers

func InitializeAllAsmParsers()

func InitializeAllAsmPrinters

func InitializeAllAsmPrinters()

func InitializeAllDisassemblers

func InitializeAllDisassemblers()

func InitializeAllTargetInfos

func InitializeAllTargetInfos()

func InitializeAllTargetMCs

func InitializeAllTargetMCs()

func InitializeAllTargets

func InitializeAllTargets()

func InitializeAsmParser

func InitializeAsmParser(arch Arch) error

InitializeAsmParser 初始化汇编格式化器

func InitializeAsmPrinter

func InitializeAsmPrinter(arch Arch) error

InitializeAsmPrinter 初始化汇编输出器

func InitializeDisassembler

func InitializeDisassembler(arch Arch) error

InitializeDisassembler 初始化目标反汇编器

func InitializeNativeAsmParser

func InitializeNativeAsmParser() error

func InitializeNativeAsmPrinter

func InitializeNativeAsmPrinter() error

func InitializeNativeDisassembler

func InitializeNativeDisassembler() error

func InitializeNativeTarget

func InitializeNativeTarget() error

func InitializeTarget

func InitializeTarget(arch Arch) error

InitializeTarget 初始化目标

func InitializeTargetInfo

func InitializeTargetInfo(arch Arch) error

InitializeTargetInfo 初始化目标信息

func InitializeTargetMC

func InitializeTargetMC(arch Arch) error

InitializeTargetMC 初始化目标机器

Types

type Add

func (Add) Belong

func (i Add) Belong() Block

func (Add) String

func (v Add) String() string

func (Add) Type

func (v Add) Type() Type

type AggregateType

type AggregateType interface {
	Type
	// contains filtered or unexported methods
}

type Alloca

type Alloca binding.LLVMValueRef

func (Alloca) Belong

func (i Alloca) Belong() Block

func (Alloca) GetAlign

func (v Alloca) GetAlign() uint32

func (Alloca) SetAlign

func (v Alloca) SetAlign(align uint32)

func (Alloca) String

func (v Alloca) String() string

func (Alloca) Type

func (v Alloca) Type() Type

type And

func (And) Belong

func (i And) Belong() Block

func (And) String

func (v And) String() string

func (And) Type

func (v And) Type() Type

type Arch

type Arch uint8

Arch 架构

const (
	AArch64 Arch = iota
	AMDGPU
	ARM
	AVR
	BPF
	Hexagon
	Lanai
	LoongArch
	Mips
	MSP430
	NVPTX
	PowerPC
	RISCV
	Sparc
	SystemZ
	VE
	WebAssembly
	X86
	XCore
)

type Array

type Array binding.LLVMValueRef

func (Array) GetElem

func (c Array) GetElem(i uint) Constant

func (Array) String

func (c Array) String() string

func (Array) Type

func (c Array) Type() Type

type ArrayType

type ArrayType binding.LLVMTypeRef

func (ArrayType) Capacity

func (t ArrayType) Capacity() uint32

func (ArrayType) Context

func (t ArrayType) Context() Context

func (ArrayType) Element

func (t ArrayType) Element() Type

func (ArrayType) IsSized

func (t ArrayType) IsSized() bool

func (ArrayType) String

func (t ArrayType) String() string

type BitCast

type BitCast binding.LLVMValueRef

func (BitCast) Belong

func (i BitCast) Belong() Block

func (BitCast) String

func (v BitCast) String() string

func (BitCast) Type

func (v BitCast) Type() Type

type Block

func (Block) Belong

func (b Block) Belong() Function

func (Block) GetTerminator

func (b Block) GetTerminator() Terminator

func (Block) IsTerminating

func (b Block) IsTerminating() bool

func (Block) Name

func (b Block) Name() string

type Br

func (Br) Belong

func (i Br) Belong() Block

type Builder

type Builder binding.LLVMBuilderRef

func (Builder) CreateAShr

func (b Builder) CreateAShr(name string, l, r Value) Shr

func (Builder) CreateAlloca

func (b Builder) CreateAlloca(name string, t Type) Alloca

func (Builder) CreateAllocaWithSize

func (b Builder) CreateAllocaWithSize(name string, t Type, size Value) Alloca

func (Builder) CreateAnd

func (b Builder) CreateAnd(name string, l, r Value) And

func (Builder) CreateBitCast

func (b Builder) CreateBitCast(name string, from Value, to Type) BitCast

func (Builder) CreateBr

func (b Builder) CreateBr(block Block) Br

func (Builder) CreateCall

func (b Builder) CreateCall(name string, ft Type, fn Value, args ...Value) Call

func (Builder) CreateCatchPad

func (b Builder) CreateCatchPad(name string, parentPad Value, arg ...Value) CatchPad

func (Builder) CreateCatchRet

func (b Builder) CreateCatchRet(catchPad Value, bb Block) CatchRet

func (Builder) CreateCatchSwitch

func (b Builder) CreateCatchSwitch(name string, parentPad Value, unwindBB Block, numHandlers uint32) CatchSwitch

func (Builder) CreateCleanupPad

func (b Builder) CreateCleanupPad(name string, parentPad Value, arg ...Value) CleanupPad

func (Builder) CreateCleanupRet

func (b Builder) CreateCleanupRet(catchPad Value, bb Block) CleanupRet

func (Builder) CreateCondBr

func (b Builder) CreateCondBr(cond Value, tblock, fblock Block) Br

func (Builder) CreateExtractElement

func (b Builder) CreateExtractElement(name string, vec, index Value) ExtractElement

func (Builder) CreateExtractValue

func (b Builder) CreateExtractValue(name string, vec Value, index uint) ExtractValue

func (Builder) CreateFAdd

func (b Builder) CreateFAdd(name string, l, r Value) Add

func (Builder) CreateFDiv

func (b Builder) CreateFDiv(name string, l, r Value) Div

func (Builder) CreateFMul

func (b Builder) CreateFMul(name string, l, r Value) Mul

func (Builder) CreateFNeg

func (b Builder) CreateFNeg(name string, v Value) Neg

func (Builder) CreateFPExt

func (b Builder) CreateFPExt(name string, from Value, to FloatType) Expand

func (Builder) CreateFPToSI

func (b Builder) CreateFPToSI(name string, from Value, to IntegerType) FloatToInt

func (Builder) CreateFPToUI

func (b Builder) CreateFPToUI(name string, from Value, to IntegerType) FloatToInt

func (Builder) CreateFPTrunc

func (b Builder) CreateFPTrunc(name string, from Value, to FloatType) Trunc

func (Builder) CreateFRem

func (b Builder) CreateFRem(name string, l, r Value) Rem

func (Builder) CreateFSub

func (b Builder) CreateFSub(name string, l, r Value) Sub

func (Builder) CreateFloatCmp

func (b Builder) CreateFloatCmp(name string, op FloatPredicate, l, r Value) FloatCmp

func (Builder) CreateFree

func (b Builder) CreateFree(p Value) Call

func (Builder) CreateGEP

func (b Builder) CreateGEP(name string, t Type, from Value, indices ...Value) GetElementPtr

func (Builder) CreateInBoundsGEP

func (b Builder) CreateInBoundsGEP(name string, t Type, from Value, indices ...Value) GetElementPtr

func (Builder) CreateIntCmp

func (b Builder) CreateIntCmp(name string, op IntPredicate, l, r Value) IntCmp

func (Builder) CreateIntToPtr

func (b Builder) CreateIntToPtr(name string, from Value, to PointerType) IntToPtr

func (Builder) CreateInvoke

func (b Builder) CreateInvoke(name string, ft Type, then, catch Block, fn Value, args ...Value) Invoke

func (Builder) CreateLShr

func (b Builder) CreateLShr(name string, l, r Value) Shr

func (Builder) CreateLandingPad

func (b Builder) CreateLandingPad(name string, t Type, f Value, numClauses uint32) LandingPad

func (Builder) CreateLoad

func (b Builder) CreateLoad(name string, t Type, p Value) Load

func (Builder) CreateMalloc

func (b Builder) CreateMalloc(name string, t Type) Call

func (Builder) CreateMallocWithSize

func (b Builder) CreateMallocWithSize(t Type, size Value, name string) Call

func (Builder) CreateMemCpy

func (b Builder) CreateMemCpy(dst Value, dstAlign32 uint32, src Value, srcAlign uint32, size Value) Call

func (Builder) CreateMemMove

func (b Builder) CreateMemMove(dst Value, dstAlign32 uint32, src Value, srcAlign uint32, size Value) Call

func (Builder) CreateMemSet

func (b Builder) CreateMemSet(ptr, value, length Value, align uint32) Call

func (Builder) CreateNot

func (b Builder) CreateNot(name string, v Value) Not

func (Builder) CreateOr

func (b Builder) CreateOr(name string, l, r Value) Or

func (Builder) CreatePHI

func (b Builder) CreatePHI(name string, t Type, incomings ...struct {
	Value Value
	Block Block
}) PHI

func (Builder) CreatePtrToInt

func (b Builder) CreatePtrToInt(name string, from Value, to IntegerType) PtrToInt

func (Builder) CreateResume

func (b Builder) CreateResume(v *Value) Resume

func (Builder) CreateRet

func (b Builder) CreateRet(v *Value) Return

func (Builder) CreateSAdd

func (b Builder) CreateSAdd(name string, l, r Value) Add

func (Builder) CreateSDiv

func (b Builder) CreateSDiv(name string, l, r Value) Div

func (Builder) CreateSExt

func (b Builder) CreateSExt(name string, from Value, to IntegerType) Expand

func (Builder) CreateSIToFP

func (b Builder) CreateSIToFP(name string, from Value, to FloatType) IntToFloat

func (Builder) CreateSMul

func (b Builder) CreateSMul(name string, l, r Value) Mul

func (Builder) CreateSNeg

func (b Builder) CreateSNeg(name string, v Value) Neg

func (Builder) CreateSRem

func (b Builder) CreateSRem(name string, l, r Value) Rem

func (Builder) CreateSSub

func (b Builder) CreateSSub(name string, l, r Value) Sub

func (Builder) CreateSelect

func (b Builder) CreateSelect(name string, cond Value, trueValue, falseValue Value) Select

func (Builder) CreateShl

func (b Builder) CreateShl(name string, l, r Value) Shl

func (Builder) CreateStore

func (b Builder) CreateStore(from, to Value) Store

func (Builder) CreateStructGEP

func (b Builder) CreateStructGEP(name string, t Type, from Value, i uint) GetElementPtr

func (Builder) CreateSwitch

func (b Builder) CreateSwitch(v Value, defaultBlock Block, conds ...struct {
	Value Value
	Block Block
}) Switch

func (Builder) CreateTrunc

func (b Builder) CreateTrunc(name string, from Value, to IntegerType) Trunc

func (Builder) CreateUAdd

func (b Builder) CreateUAdd(name string, l, r Value) Add

func (Builder) CreateUDiv

func (b Builder) CreateUDiv(name string, l, r Value) Div

func (Builder) CreateUIToFP

func (b Builder) CreateUIToFP(name string, from Value, to FloatType) IntToFloat

func (Builder) CreateUMul

func (b Builder) CreateUMul(name string, l, r Value) Mul

func (Builder) CreateUNeg

func (b Builder) CreateUNeg(name string, v Value) Neg

func (Builder) CreateURem

func (b Builder) CreateURem(name string, l, r Value) Rem

func (Builder) CreateUSub

func (b Builder) CreateUSub(name string, l, r Value) Sub

func (Builder) CreateUnreachable

func (b Builder) CreateUnreachable() Unreachable

func (Builder) CreateXor

func (b Builder) CreateXor(name string, l, r Value) Xor

func (Builder) CreateZExt

func (b Builder) CreateZExt(name string, from Value, to IntegerType) Expand

func (Builder) CurrentBlock

func (b Builder) CurrentBlock() Block

func (Builder) Free

func (b Builder) Free()

func (Builder) MoveToAfter

func (b Builder) MoveToAfter(block Block)

type Call

type Call binding.LLVMValueRef

func (Call) Belong

func (i Call) Belong() Block

func (Call) String

func (v Call) String() string

func (Call) Type

func (v Call) Type() Type

type CatchPad

type CatchPad binding.LLVMValueRef

func (CatchPad) Belong

func (i CatchPad) Belong() Block

func (CatchPad) String

func (v CatchPad) String() string

func (CatchPad) Type

func (v CatchPad) Type() Type

type CatchRet

type CatchRet binding.LLVMValueRef

func (CatchRet) Belong

func (i CatchRet) Belong() Block

func (CatchRet) String

func (v CatchRet) String() string

func (CatchRet) Type

func (v CatchRet) Type() Type

type CatchSwitch

type CatchSwitch binding.LLVMValueRef

func (CatchSwitch) Belong

func (i CatchSwitch) Belong() Block

func (CatchSwitch) String

func (v CatchSwitch) String() string

func (CatchSwitch) Type

func (v CatchSwitch) Type() Type

type CleanupPad

type CleanupPad binding.LLVMValueRef

func (CleanupPad) Belong

func (i CleanupPad) Belong() Block

func (CleanupPad) String

func (v CleanupPad) String() string

func (CleanupPad) Type

func (v CleanupPad) Type() Type

type CleanupRet

type CleanupRet binding.LLVMValueRef

func (CleanupRet) Belong

func (i CleanupRet) Belong() Block

func (CleanupRet) String

func (v CleanupRet) String() string

func (CleanupRet) Type

func (v CleanupRet) Type() Type

type CodeModel

type CodeModel binding.LLVMRelocMode

type CodeOptLevel

type CodeOptLevel binding.LLVMCodeGenOptLevel

type Constant

type Constant interface {
	Value
	// contains filtered or unexported methods
}

type Context

type Context binding.LLVMContextRef

func NewContext

func NewContext() Context

func (Context) ArrayType

func (ctx Context) ArrayType(elem Type, cap uint32) ArrayType

func (Context) ConstAggregateZero

func (ctx Context) ConstAggregateZero(t AggregateType) Constant

func (Context) ConstArray

func (ctx Context) ConstArray(et Type, elem ...Constant) Array

func (Context) ConstExtractElement

func (ctx Context) ConstExtractElement(v, index Constant) Constant

func (Context) ConstFloat

func (ctx Context) ConstFloat(t FloatType, v float64) Float

func (Context) ConstFloatFromString

func (ctx Context) ConstFloatFromString(t FloatType, s string) Float

func (Context) ConstGEP

func (ctx Context) ConstGEP(t Type, v Constant, indice ...Constant) Constant

func (Context) ConstInBoundsGEP

func (ctx Context) ConstInBoundsGEP(t Type, v Constant, indice ...Constant) Constant

func (Context) ConstInteger

func (ctx Context) ConstInteger(t IntegerType, v int64) Integer

func (Context) ConstIntegerFromString

func (ctx Context) ConstIntegerFromString(t IntegerType, s string, radix uint8) Integer

func (Context) ConstNamedStruct

func (ctx Context) ConstNamedStruct(t StructType, elem ...Constant) Struct

func (Context) ConstNull

func (ctx Context) ConstNull(t Type) Constant

func (Context) ConstPointer

func (ctx Context) ConstPointer(t Type) Pointer

func (Context) ConstString

func (ctx Context) ConstString(s string) Array

func (Context) ConstStruct

func (ctx Context) ConstStruct(packed bool, elem ...Constant) Struct

func (Context) FloatType

func (ctx Context) FloatType(kind FloatTypeKind) FloatType

func (Context) Free

func (ctx Context) Free()

func (Context) FunctionType

func (ctx Context) FunctionType(isVarArg bool, ret Type, param ...Type) FunctionType

func (Context) GetTypeByName

func (ctx Context) GetTypeByName(name string) *StructType

func (Context) IntPtrType

func (ctx Context) IntPtrType(t *Target) IntegerType

func (Context) IntegerType

func (ctx Context) IntegerType(bits uint32) IntegerType

func (Context) NamedStructType

func (ctx Context) NamedStructType(name string, packed bool, elems ...Type) StructType

func (Context) NewBuilder

func (ctx Context) NewBuilder() Builder

func (Context) NewModule

func (ctx Context) NewModule(name string) Module

func (Context) OpaquePointerType

func (ctx Context) OpaquePointerType() PointerType

func (Context) PointerType

func (ctx Context) PointerType(elem Type) PointerType

func (Context) StructType

func (ctx Context) StructType(packed bool, elems ...Type) StructType

func (Context) VoidType

func (ctx Context) VoidType() VoidType

type Div

func (Div) Belong

func (i Div) Belong() Block

func (Div) String

func (v Div) String() string

func (Div) Type

func (v Div) Type() Type

type ExecutionEngine

type ExecutionEngine struct {
	// contains filtered or unexported fields
}

func DefaultMCJITCompiler

func DefaultMCJITCompiler(m Module) (*ExecutionEngine, error)

func NewExecutionEngine

func NewExecutionEngine(m Module) (*ExecutionEngine, error)

func NewInterpreter

func NewInterpreter(m Module) (*ExecutionEngine, error)

func NewJITCompiler

func NewJITCompiler(m Module, opt CodeOptLevel) (*ExecutionEngine, error)

func (ExecutionEngine) Free

func (engine ExecutionEngine) Free()

func (ExecutionEngine) GetFunction

func (engine ExecutionEngine) GetFunction(name string) (Function, bool)

func (ExecutionEngine) GetFunctionRuntimePointer

func (engine ExecutionEngine) GetFunctionRuntimePointer(f Function) (unsafe.Pointer, bool)

func (ExecutionEngine) GetVariable

func (engine ExecutionEngine) GetVariable(name string) (GlobalValue, bool)

func (ExecutionEngine) GetVariableRuntimePointer

func (engine ExecutionEngine) GetVariableRuntimePointer(v GlobalValue) (unsafe.Pointer, bool)

func (ExecutionEngine) MapFunctionToGo

func (engine ExecutionEngine) MapFunctionToGo(name string, to any) error

MapFunctionToGo 映射函数到go函数

func (ExecutionEngine) MapGlobalToC

func (engine ExecutionEngine) MapGlobalToC(name string, to unsafe.Pointer) error

MapGlobalToC 映射全局值到c语言值

func (ExecutionEngine) RunFunction

func (engine ExecutionEngine) RunFunction(f Function, args ...ExecutionValue) ExecutionValue

func (ExecutionEngine) RunMainFunction

func (engine ExecutionEngine) RunMainFunction(f Function, argv, envp []string) uint8

func (ExecutionEngine) RunMainFunctionWithParentEnv

func (engine ExecutionEngine) RunMainFunctionWithParentEnv(f Function) uint8

type ExecutionValue

type ExecutionValue binding.LLVMGenericValueRef

func NewFloatExecutionValue

func NewFloatExecutionValue(t FloatType, v float64) ExecutionValue

func NewIntExecutionValue

func NewIntExecutionValue(t IntegerType, v uint64, isSigned bool) ExecutionValue

func (ExecutionValue) Float

func (v ExecutionValue) Float(t FloatType) float64

func (ExecutionValue) Free

func (v ExecutionValue) Free()

func (ExecutionValue) Integer

func (v ExecutionValue) Integer(isSigned bool) uint64

type Expand

type Expand binding.LLVMValueRef

func (Expand) Belong

func (i Expand) Belong() Block

func (Expand) String

func (v Expand) String() string

func (Expand) Type

func (v Expand) Type() Type

type ExtractElement

type ExtractElement binding.LLVMValueRef

func (ExtractElement) Belong

func (i ExtractElement) Belong() Block

func (ExtractElement) String

func (v ExtractElement) String() string

func (ExtractElement) Type

func (v ExtractElement) Type() Type

type ExtractValue

type ExtractValue binding.LLVMValueRef

func (ExtractValue) Belong

func (i ExtractValue) Belong() Block

func (ExtractValue) String

func (v ExtractValue) String() string

func (ExtractValue) Type

func (v ExtractValue) Type() Type

type Float

type Float binding.LLVMValueRef

func (Float) String

func (c Float) String() string

func (Float) Type

func (c Float) Type() Type

func (Float) Value

func (c Float) Value() float64

type FloatCmp

type FloatCmp binding.LLVMValueRef

func (FloatCmp) Belong

func (i FloatCmp) Belong() Block

func (FloatCmp) GetOperator

func (c FloatCmp) GetOperator() FloatPredicate

func (FloatCmp) String

func (v FloatCmp) String() string

func (FloatCmp) Type

func (v FloatCmp) Type() Type

type FloatPredicate

type FloatPredicate binding.LLVMRealPredicate

type FloatToInt

type FloatToInt binding.LLVMValueRef

func (FloatToInt) Belong

func (i FloatToInt) Belong() Block

func (FloatToInt) String

func (v FloatToInt) String() string

func (FloatToInt) Type

func (v FloatToInt) Type() Type

type FloatType

type FloatType binding.LLVMTypeRef

func (FloatType) Context

func (t FloatType) Context() Context

func (FloatType) IsSized

func (t FloatType) IsSized() bool

func (FloatType) Kind

func (t FloatType) Kind() FloatTypeKind

func (FloatType) String

func (t FloatType) String() string

type FloatTypeKind

type FloatTypeKind binding.LLVMTypeKind

type FuncAttribute

type FuncAttribute uint8
const (
	FuncAttributeNoReturn     FuncAttribute = iota // 函数不会返回
	FuncAttributeInlineHint                        // 自动内联
	FuncAttributeAlwaysInline                      // 必须内联
	FuncAttributeNoInline                          // 禁止内联
	// FuncAttributeAllocKind 内存分配类型
	// 1-alloc 2-realloc 1|2-alloc,realloc 4-free 8-uninitialized 16-zeroed 32-aligned
	FuncAttributeAllocKind
)

type Function

type Function binding.LLVMValueRef

func (Function) AddAttribute

func (f Function) AddAttribute(attr FuncAttribute, attrValue ...uint)

func (Function) Blocks

func (f Function) Blocks() []Block

func (Function) CountParams

func (f Function) CountParams() uint

func (Function) EntryBlock

func (f Function) EntryBlock() Block

func (Function) FirstBlock

func (f Function) FirstBlock() Block

func (Function) FirstParam

func (f Function) FirstParam() Param

func (Function) FunctionType

func (f Function) FunctionType() FunctionType

func (Function) GetParam

func (f Function) GetParam(i uint) Param

func (Function) LastBlock

func (f Function) LastBlock() Block

func (Function) LastParam

func (f Function) LastParam() Param

func (Function) Linkage

func (g Function) Linkage() Linkage

func (Function) Name

func (c Function) Name() string

func (Function) NewBlock

func (f Function) NewBlock(name string) Block

func (Function) Params

func (f Function) Params() []Param

func (Function) SetLinkage

func (g Function) SetLinkage(linkage Linkage)

func (Function) SetName

func (c Function) SetName(name string)

func (Function) String

func (c Function) String() string

func (Function) Type

func (c Function) Type() Type

func (Function) Verify

func (f Function) Verify() bool

func (Function) VerifyWithCFG

func (f Function) VerifyWithCFG(only bool)

type FunctionType

type FunctionType binding.LLVMTypeRef

func (FunctionType) Context

func (t FunctionType) Context() Context

func (FunctionType) CountParams

func (t FunctionType) CountParams() uint32

func (FunctionType) IsSized

func (t FunctionType) IsSized() bool

func (FunctionType) IsVarArg

func (t FunctionType) IsVarArg() bool

func (FunctionType) Params

func (t FunctionType) Params() []Type

func (FunctionType) ReturnType

func (t FunctionType) ReturnType() Type

func (FunctionType) String

func (t FunctionType) String() string

type GetElementPtr

type GetElementPtr binding.LLVMValueRef

func (GetElementPtr) Belong

func (i GetElementPtr) Belong() Block

func (GetElementPtr) String

func (v GetElementPtr) String() string

func (GetElementPtr) Type

func (v GetElementPtr) Type() Type

type Global

type Global interface {
	// contains filtered or unexported methods
}

type GlobalValue

type GlobalValue binding.LLVMValueRef

func (GlobalValue) GetAlign

func (g GlobalValue) GetAlign() uint32

func (GlobalValue) GetInitializer

func (g GlobalValue) GetInitializer() (Constant, bool)

func (GlobalValue) IsDeclaration

func (g GlobalValue) IsDeclaration() bool

func (GlobalValue) IsExternallyInitialized

func (g GlobalValue) IsExternallyInitialized() bool

func (GlobalValue) IsGlobalConstant

func (g GlobalValue) IsGlobalConstant() bool

func (GlobalValue) IsThreadLocal

func (g GlobalValue) IsThreadLocal() bool

func (GlobalValue) Linkage

func (g GlobalValue) Linkage() Linkage

func (GlobalValue) SetAlign

func (g GlobalValue) SetAlign(align uint32)

func (GlobalValue) SetExternallyInitialized

func (g GlobalValue) SetExternallyInitialized(isConstant bool)

func (GlobalValue) SetGlobalConstant

func (g GlobalValue) SetGlobalConstant(isConstant bool)

func (GlobalValue) SetInitializer

func (g GlobalValue) SetInitializer(v Constant)

func (GlobalValue) SetLinkage

func (g GlobalValue) SetLinkage(linkage Linkage)

func (GlobalValue) SetThreadLocal

func (g GlobalValue) SetThreadLocal(isThreadLocal bool)

func (GlobalValue) SetThreadLocalMode

func (g GlobalValue) SetThreadLocalMode(mode ThreadLocalMode)

func (GlobalValue) SetUnnamedAddress

func (g GlobalValue) SetUnnamedAddress(unnamedAddr UnnamedAddr)

func (GlobalValue) SetVisibility

func (g GlobalValue) SetVisibility(visibility Visibility)

func (GlobalValue) String

func (v GlobalValue) String() string

func (GlobalValue) ThreadLocalMode

func (g GlobalValue) ThreadLocalMode() ThreadLocalMode

func (GlobalValue) Type

func (v GlobalValue) Type() Type

func (GlobalValue) UnnamedAddress

func (g GlobalValue) UnnamedAddress() UnnamedAddr

func (GlobalValue) ValueType

func (g GlobalValue) ValueType() Type

func (GlobalValue) Visibility

func (g GlobalValue) Visibility() Visibility

type Instruction

type Instruction interface {
	Belong() Block
	// contains filtered or unexported methods
}

type IntCmp

type IntCmp binding.LLVMValueRef

func (IntCmp) Belong

func (i IntCmp) Belong() Block

func (IntCmp) GetOperator

func (c IntCmp) GetOperator() IntPredicate

func (IntCmp) String

func (v IntCmp) String() string

func (IntCmp) Type

func (v IntCmp) Type() Type

type IntPredicate

type IntPredicate binding.LLVMIntPredicate

type IntToFloat

type IntToFloat binding.LLVMValueRef

func (IntToFloat) Belong

func (i IntToFloat) Belong() Block

func (IntToFloat) String

func (v IntToFloat) String() string

func (IntToFloat) Type

func (v IntToFloat) Type() Type

type IntToPtr

type IntToPtr binding.LLVMValueRef

func (IntToPtr) Belong

func (i IntToPtr) Belong() Block

func (IntToPtr) String

func (v IntToPtr) String() string

func (IntToPtr) Type

func (v IntToPtr) Type() Type

type Integer

type Integer binding.LLVMValueRef

func (Integer) String

func (c Integer) String() string

func (Integer) Type

func (c Integer) Type() Type

type IntegerType

type IntegerType binding.LLVMTypeRef

func (IntegerType) Bits

func (t IntegerType) Bits() uint32

func (IntegerType) Context

func (t IntegerType) Context() Context

func (IntegerType) IsSized

func (t IntegerType) IsSized() bool

func (IntegerType) String

func (t IntegerType) String() string

type Invoke

type Invoke binding.LLVMValueRef

func (Invoke) Belong

func (i Invoke) Belong() Block

func (Invoke) String

func (v Invoke) String() string

func (Invoke) Type

func (v Invoke) Type() Type

type LandingPad

type LandingPad binding.LLVMValueRef

func (LandingPad) Belong

func (i LandingPad) Belong() Block

func (LandingPad) String

func (v LandingPad) String() string

func (LandingPad) Type

func (v LandingPad) Type() Type

type Linkage

type Linkage binding.LLVMLinkage

type Load

type Load binding.LLVMValueRef

func (Load) Belong

func (i Load) Belong() Block

func (Load) GetAlign

func (v Load) GetAlign() uint32

func (Load) SetAlign

func (v Load) SetAlign(align uint32)

func (Load) String

func (v Load) String() string

func (Load) Type

func (v Load) Type() Type

type Module

type Module struct {
	binding.LLVMModuleRef
	// contains filtered or unexported fields
}

func (Module) AddConstructor

func (m Module) AddConstructor(prior uint16, f Function)

func (Module) AddDestructor

func (m Module) AddDestructor(prior uint16, f Function)

func (Module) Clone

func (m Module) Clone() Module

func (Module) Context

func (m Module) Context() Context

func (Module) DelGlobal

func (m Module) DelGlobal(g GlobalValue)

func (Module) Free

func (m Module) Free()

func (Module) GetFunction

func (m Module) GetFunction(name string) (Function, bool)

func (Module) GetGlobal

func (m Module) GetGlobal(name string) (GlobalValue, bool)

func (Module) GetSource

func (m Module) GetSource() string

func (Module) GetTarget

func (m Module) GetTarget() (*Target, bool)

func (Module) NewFunction

func (m Module) NewFunction(name string, t FunctionType) Function

func (Module) NewGlobal

func (m Module) NewGlobal(name string, t Type) GlobalValue

func (Module) RunPasses

func (m Module) RunPasses(target *Target, option PassOption, pass ...string) error

func (Module) SetSource

func (m Module) SetSource(source string)

func (*Module) SetTarget

func (m *Module) SetTarget(t *Target)

func (Module) String

func (m Module) String() string

func (Module) Verify

func (m Module) Verify() error

type Mul

func (Mul) Belong

func (i Mul) Belong() Block

func (Mul) String

func (v Mul) String() string

func (Mul) Type

func (v Mul) Type() Type

type Neg

func (Neg) Belong

func (i Neg) Belong() Block

func (Neg) String

func (v Neg) String() string

func (Neg) Type

func (v Neg) Type() Type

type Not

func (Not) Belong

func (i Not) Belong() Block

func (Not) String

func (v Not) String() string

func (Not) Type

func (v Not) Type() Type

type Or

func (Or) Belong

func (i Or) Belong() Block

func (Or) String

func (v Or) String() string

func (Or) Type

func (v Or) Type() Type

type PHI

func (PHI) AddIncomings

func (phi PHI) AddIncomings(incomings ...struct {
	Value Value
	Block Block
})

func (PHI) Belong

func (i PHI) Belong() Block

func (PHI) CountIncomings

func (phi PHI) CountIncomings() uint

func (PHI) GetIncoming

func (phi PHI) GetIncoming(i uint) (Value, Block)

func (PHI) Incomings

func (phi PHI) Incomings() (res []struct {
	Value Value
	Block Block
})

func (PHI) String

func (v PHI) String() string

func (PHI) Type

func (v PHI) Type() Type

type Param

type Param binding.LLVMValueRef

func (Param) Belong

func (p Param) Belong() Function

func (Param) SetAlign

func (p Param) SetAlign(align uint32)

func (Param) String

func (v Param) String() string

func (Param) Type

func (v Param) Type() Type

type PassOption

func NewPassOption

func NewPassOption() PassOption

func (PassOption) Free

func (o PassOption) Free()

func (PassOption) SetCallGraphProfile

func (o PassOption) SetCallGraphProfile(v bool)

func (PassOption) SetDebugLogging

func (o PassOption) SetDebugLogging(v bool)

func (PassOption) SetForgetAllSCEVInLoopUnroll

func (o PassOption) SetForgetAllSCEVInLoopUnroll(v bool)

func (PassOption) SetLicmMssaNoAccForPromotionCap

func (o PassOption) SetLicmMssaNoAccForPromotionCap(v uint32)

func (PassOption) SetLicmMssaOptCap

func (o PassOption) SetLicmMssaOptCap(v uint32)

func (PassOption) SetLoopInterleaving

func (o PassOption) SetLoopInterleaving(v bool)

func (PassOption) SetLoopUnrolling

func (o PassOption) SetLoopUnrolling(v bool)

func (PassOption) SetLoopVectorization

func (o PassOption) SetLoopVectorization(v bool)

func (PassOption) SetMergeFunctions

func (o PassOption) SetMergeFunctions(v bool)

func (PassOption) SetSLPVectorization

func (o PassOption) SetSLPVectorization(v bool)

func (PassOption) SetVerifyEach

func (o PassOption) SetVerifyEach(v bool)

type Pointer

type Pointer binding.LLVMValueRef

func (Pointer) String

func (c Pointer) String() string

func (Pointer) Type

func (c Pointer) Type() Type

type PointerType

type PointerType binding.LLVMTypeRef

func (PointerType) AddressSpace

func (t PointerType) AddressSpace() uint32

func (PointerType) Context

func (t PointerType) Context() Context

func (PointerType) IsOpaque

func (t PointerType) IsOpaque() bool

func (PointerType) IsSized

func (t PointerType) IsSized() bool

func (PointerType) String

func (t PointerType) String() string

type PtrToInt

type PtrToInt binding.LLVMValueRef

func (PtrToInt) Belong

func (i PtrToInt) Belong() Block

func (PtrToInt) String

func (v PtrToInt) String() string

func (PtrToInt) Type

func (v PtrToInt) Type() Type

type RelocMode

type RelocMode binding.LLVMRelocMode

type Rem

func (Rem) Belong

func (i Rem) Belong() Block

func (Rem) String

func (v Rem) String() string

func (Rem) Type

func (v Rem) Type() Type

type Resume

type Resume binding.LLVMValueRef

func (Resume) Belong

func (i Resume) Belong() Block

func (Resume) String

func (v Resume) String() string

func (Resume) Type

func (v Resume) Type() Type

type Return

type Return binding.LLVMValueRef

func (Return) Belong

func (i Return) Belong() Block

type Select

type Select binding.LLVMValueRef

func (Select) Belong

func (i Select) Belong() Block

func (Select) String

func (v Select) String() string

func (Select) Type

func (v Select) Type() Type

type Shl

func (Shl) Belong

func (i Shl) Belong() Block

func (Shl) String

func (v Shl) String() string

func (Shl) Type

func (v Shl) Type() Type

type Shr

func (Shr) Belong

func (i Shr) Belong() Block

func (Shr) String

func (v Shr) String() string

func (Shr) Type

func (v Shr) Type() Type

type Store

type Store binding.LLVMValueRef

func (Store) Belong

func (i Store) Belong() Block

func (Store) GetAlign

func (i Store) GetAlign() uint32

func (Store) SetAlign

func (i Store) SetAlign(align uint32)

type Struct

type Struct binding.LLVMValueRef

func (Struct) GetElem

func (c Struct) GetElem(i uint) Constant

func (Struct) String

func (c Struct) String() string

func (Struct) Type

func (c Struct) Type() Type

type StructType

type StructType binding.LLVMTypeRef

func (StructType) Context

func (t StructType) Context() Context

func (StructType) CountElems

func (t StructType) CountElems() uint32

func (StructType) Elems

func (t StructType) Elems() []Type

func (StructType) GetElem

func (t StructType) GetElem(i uint32) Type

func (StructType) IsOpaque

func (t StructType) IsOpaque() bool

func (StructType) IsPacked

func (t StructType) IsPacked() bool

func (StructType) IsSized

func (t StructType) IsSized() bool

func (StructType) Name

func (t StructType) Name() string

func (StructType) SetElems

func (t StructType) SetElems(packed bool, elems ...Type)

func (StructType) String

func (t StructType) String() string

type Sub

func (Sub) Belong

func (i Sub) Belong() Block

func (Sub) String

func (v Sub) String() string

func (Sub) Type

func (v Sub) Type() Type

type Switch

type Switch binding.LLVMValueRef

func (Switch) Belong

func (i Switch) Belong() Block

type Target

type Target struct {
	// contains filtered or unexported fields
}

func NativeTarget

func NativeTarget() (*Target, error)

func NewTargetFromTriple

func NewTargetFromTriple(triple string, cpu, feature string) (*Target, error)

func (Target) CPU

func (t Target) CPU() string

func (Target) Description

func (t Target) Description() string

func (Target) Feature

func (t Target) Feature() string

func (Target) Free

func (t Target) Free()

func (Target) GetABIAlignOfType

func (d Target) GetABIAlignOfType(t Type) uint

func (Target) GetABISizeOfType

func (d Target) GetABISizeOfType(t Type) uint

func (Target) GetCallFrameAlignOfType

func (d Target) GetCallFrameAlignOfType(t Type) uint

func (Target) GetOffsetOfElem

func (d Target) GetOffsetOfElem(st StructType, i uint) uint

func (Target) GetPrefAlignOfGlobal

func (d Target) GetPrefAlignOfGlobal(g GlobalValue) uint

func (Target) GetPrefAlignOfType

func (d Target) GetPrefAlignOfType(t Type) uint

func (Target) GetSizeOfType

func (d Target) GetSizeOfType(t Type) uint

func (Target) GetStoreSizeOfType

func (d Target) GetStoreSizeOfType(t Type) uint

func (Target) HasAsmBackend

func (t Target) HasAsmBackend() bool

func (Target) HasJIT

func (t Target) HasJIT() bool

func (Target) HasTargetMachine

func (t Target) HasTargetMachine() bool

func (Target) IsDarwin

func (t Target) IsDarwin() bool

func (Target) IsLinux

func (t Target) IsLinux() bool

func (Target) IsWindows

func (t Target) IsWindows() bool

func (Target) Name

func (t Target) Name() string

func (Target) PointerSize

func (d Target) PointerSize() uint

func (Target) String

func (t Target) String() string

func (Target) Triple

func (t Target) Triple() string

func (Target) WriteASMToFile

func (t Target) WriteASMToFile(m Module, file string, opt CodeOptLevel, reloc RelocMode, code CodeModel) error

func (Target) WriteOBJToFile

func (t Target) WriteOBJToFile(m Module, file string, opt CodeOptLevel, reloc RelocMode, code CodeModel) error

type Terminator

type Terminator interface {
	Instruction
	// contains filtered or unexported methods
}

type ThreadLocalMode

type ThreadLocalMode binding.LLVMThreadLocalMode

type Trunc

type Trunc binding.LLVMValueRef

func (Trunc) Belong

func (i Trunc) Belong() Block

func (Trunc) String

func (v Trunc) String() string

func (Trunc) Type

func (v Trunc) Type() Type

type Type

type Type interface {
	fmt.Stringer

	Context() Context
	IsSized() bool
	// contains filtered or unexported methods
}

type UnnamedAddr

type UnnamedAddr binding.LLVMUnnamedAddr

type Unreachable

type Unreachable binding.LLVMValueRef

func (Unreachable) Belong

func (i Unreachable) Belong() Block

type Value

type Value interface {
	fmt.Stringer

	Type() Type
	// contains filtered or unexported methods
}

type Visibility

type Visibility binding.LLVMVisibility

type VoidType

type VoidType binding.LLVMTypeRef

func (VoidType) Context

func (t VoidType) Context() Context

func (VoidType) IsSized

func (t VoidType) IsSized() bool

func (VoidType) String

func (t VoidType) String() string

type Xor

func (Xor) Belong

func (i Xor) Belong() Block

func (Xor) String

func (v Xor) String() string

func (Xor) Type

func (v Xor) Type() Type

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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