Essentials
Initialization
LLVM.backends
— Functionbackends()
Return a list of back-ends supported by the LLVM library.
LLVM.InitializeAllTargetInfos
— FunctionLLVM.InitializeAllTargetInfos()
LLVM.InitializeXXXTargetInfo()
Enables access to specific targets.
LLVM.InitializeAllTargets
— FunctionLLVM.InitializeAllTargets()
LLVM.InitializeXXXTarget()
LLVM.InitializeNativeTarget()
Enables use of specific targets.
LLVM.InitializeAllTargetMCs
— FunctionLLVM.InitializeAllTargetMCs()
LLVM.InitializeXXXTargetMC()
Enable use of machine code generation for specific targets.
LLVM.InitializeAllAsmParsers
— FunctionLLVM.InitializeAllAsmParsers()
LLVM.InitializeXXXAsmParser()
LLVM.InitializeNativeAsmParser()
Enables use of assembly parsing functionality for specific targets.
LLVM.InitializeAllAsmPrinters
— FunctionLLVM.InitializeAllAsmPrinters()
LLVM.InitializeXXXAsmPrinter()
LLVM.InitializeNativeAsmPrinter()
Enables use of assembly output functionality for specific targets.
LLVM.InitializeAllDisassemblers
— FunctionLLVM.InitializeAllDisassemblers()
LLVM.InitializeXXXDisassembler()
LLVM.InitializeNativeDisassembler()
Enables use of disassembly functionality for specific targets.
Contexts
LLVM.Context
— TypeLLVM.Context
Execution state for the core LLVM IR system. Created by calling the Context()
constructor, and should be disposed of.
Most types are tied to a context instance. Multiple contexts can exist simultaneously. A single context is not thread safe. However, different contexts can execute on different threads simultaneously.
LLVM.Context
— MethodLLVM.Context(; opaque_pointers=nothing)
Create a new LLVM context. If opaque_pointers
is true
, the context will use opaque pointers instead of typed pointers (if suppoprted). Otherwise the behavior of the context depends on the LLVM version.
This object needs to be disposed of using dispose(::Context)
.
LLVM.dispose
— Methoddispose(ctx::Context)
Dispose of the context, releasing all resources associated with it. The context should not be used after this operation.
LLVM.supports_typed_pointers
— Functionsupports_typed_pointers()
Check whether the current context supports typed pointers.
LLVM.jl also tracks the context in task-local scope:
LLVM.context
— Methodcontext(; throw_error::Bool=true)
Get the active LLVM context for the current tasks. Throws an exception if no context is active, unless throw_error=false
.
LLVM.activate
— Methodactivate(ctx::LLVM.Context)
Pushes a new context onto the context stack.
LLVM.deactivate
— Methoddeactivate(ctx::LLVM.Context)
Pops the current context from the context stack.
LLVM.context!
— Functioncontext!(ctx::LLVM.Context) do
...
end
Temporarily activates the given context for the duration of the block.
LLVM.ts_context
— Functionts_context(; throw_error::Bool=true)
Get the active LLVM thread-safe context for the current tasks. Throws an exception if no context is active, unless throw_error=false
.
LLVM.activate
— Methodactivate(ts_ctx::LLVM.ThreadSafeContext)
Pushes a new thread-safe context onto the context stack.
LLVM.deactivate
— Methoddeactivate(ts_ctx::LLVM.ThreadSafeContext)
Pops the current thread-safe context from the context stack.
LLVM.ts_context!
— Functionts_context!(ts_ctx::LLVM.ThreadSafeContext) do
...
end
Temporarily activates the given thread-safe context for the duration of the block.
Resources
LLVM.@dispose
— Macro@dispose foo=Foo() bar=Bar() begin
...
end
Helper macro for disposing resources (by calling the dispose
function for every resource in reverse order) after executing a block of code. This is often equivalent to calling the recourse constructor with do-block syntax, but without using (potentially costly) closures.
Exceptions
LLVM.LLVMException
— TypeLLVMException
Exception type for errors in the LLVM API. Possibly thrown by diagnostic handlers, and fatal eror handlers.
Memory buffers
LLVM.MemoryBuffer
— TypeMemoryBuffer
A memory buffer representing a simple block of memory.
LLVM.MemoryBuffer
— MethodMemoryBuffer(data::Vector{T}, name::String="", copy::Bool=true)
Create a memory buffer from the given data. If copy
is true
, the data is copied into the buffer. Otherwise, the user is responsible for keeping the data alive across the lifetime of the buffer.
This object needs to be disposed of using dispose
.
LLVM.MemoryBufferFile
— FunctionMemoryBufferFile(path::String)
Create a memory buffer from the contents of a file.
This object needs to be disposed of using dispose
.
LLVM.dispose
— Methoddispose(membuf::MemoryBuffer)
Dispose of the given memory buffer.
Other
LLVM.clopts
— Functionclopts(opts...)
Parse the given arguments using the LLVM command-line parser.
Note that this function modifies the global state of the LLVM library. It is also not safe to rely on the stability of the command-line options between different versions of LLVM.
LLVM.ismultithreaded
— Functionismultithreaded()
Check whether LLVM is executing in thread-safe mode or not.