Modules
LLVM.Module — Type
LLVM.ModuleModules are the top level container of all other LLVM IR objects. Each module directly contains a list of globals variables, a list of functions, a list of libraries (or other modules) this module depends on, a symbol table, and various data about the target's characteristics.
LLVM.dispose — Method
dispose(mod::LLVM.Module)Dispose of the given module, releasing all resources associated with it. The module should not be used after this operation.
Properties and operations
LLVM.context — Method
context(mod::LLVM.Module)Get the context in which the given module was created.
LLVM.name! — Method
name!(mod::LLVM.Module, name::String)Set the name of the given module.
LLVM.triple — Method
triple(mod::LLVM.Module)Get the target triple of the given module.
LLVM.triple! — Method
triple!(mod::LLVM.Module, triple::String)Set the target triple of the given module.
LLVM.datalayout — Function
datalayout(mod::LLVM.Module)Get the data layout of the given module.
LLVM.datalayout! — Function
datalayout!(mod::LLVM.Module, layout)Set the data layout of the given module. The layout can be a string or a DataLayout object.
LLVM.inline_asm! — Function
inline_asm!(mod::LLVM.Module, asm::String; overwrite::Bool=false)Add module-level inline assembly to the given module. If overwrite is true, the existing inline assembly is replaced, otherwise the new assembly is appended.
LLVM.inline_asm — Function
inline_asm(mod::LLVM.Module) -> StringGet the module-level inline assembly of the given module.
LLVM.sdk_version — Function
sdk_version!(mod::LLVM.Module, version::VersionNumber)Set the SDK version of the given module.
LLVM.sdk_version! — Function
sdk_version(mod::LLVM.Module)Get the SDK version of the given module, if it has been set.
LLVM.set_used! — Function
set_used!(mod::LLVM.Module, values::GlobalVariable...)Mark the given global variables as used in the given module by appending them to the llvm.used metadata node.
LLVM.set_compiler_used! — Function
set_compiler_used!(mod::LLVM.Module, values::GlobalVariable...)Mark the given global variables as used by the compiler in the given module by appending them to the llvm.compiler.used metadata node. As opposed to set_used!, this still allows the linker to remove the variable if it is not actually used.
Textual representation
Base.parse — Method
parse(::Type{Module}, ir::String)Parse the given LLVM IR string into a module.
Base.string — Method
string(mod::Module)Convert the given module to a string.
Binary representation ("bitcode")
Base.parse — Method
parse(::Type{Module}, membuf::MemoryBuffer; lazy::Bool=false)Parse bitcode from the given memory buffer into a module.
If lazy is true, only the module header is read; function bodies are deserialized on demand. The module then takes ownership of membuf, and the underlying byte storage (membuf's data) must remain valid for the module's lifetime.
Base.parse — Method
parse(::Type{Module}, data::Vector; lazy::Bool=false)Parse bitcode from the given byte vector into a module.
If lazy is true, data must remain live (unmutated) for the module's lifetime, as the bitcode reader keeps reading from it on demand.
Base.convert — Method
convert(::Type{MemoryBuffer}, mod::Module)Convert the given module to a memory buffer containing its bitcode.
Base.convert — Method
convert(::Type{Vector}, mod::Module)Convert the given module to a byte vector containing its bitcode.
Base.write — Method
write(io::IO, mod::Module)Write bitcode of the given module to the given IO stream.
Contents
LLVM.globals — Function
globals(mod::LLVM.Module)Get an iterator over the global variables in the given module.
LLVM.prevglobal — Function
prevglobal(gv::LLVM.GlobalVariable)Get the previous global variable in the module, or nothing if there is none.
See also: nextglobal.
LLVM.nextglobal — Function
nextglobal(gv::LLVM.GlobalVariable)Get the next global variable in the module, or nothing if there is none.
See also: prevglobal.
LLVM.functions — Method
functions(mod::LLVM.Module)Get an iterator over the functions in the given module.
LLVM.prevfun — Function
prevfun(fun::LLVM.Function)Get the previous function in the module, or nothing if there is none.
LLVM.nextfun — Function
nextfun(fun::LLVM.Function)Get the next function in the module, or nothing if there is none.
LLVM.flags — Method
flags(mod::LLVM.Module)Get a dictionary-like object representing the module flags of the given module.
This object can be used to get and set module flags, by calling getindex and setindex!.
Linking
LLVM.link! — Method
link!(dst::Module, src::Module; only_needed=false, override_from_src=false)Link the source module src into the destination module dst. The source module is destroyed in the process.
Keyword arguments:
only_needed: if true, only link symbols fromsrcthat are needed bydst(i.e., referenced but not defined there). This corresponds to LLVM'sLinker::LinkOnlyNeededflag.override_from_src: if true, have symbols fromsrcshadow those indst. This corresponds to LLVM'sLinker::OverrideFromSrcflag.