Julia integration
Essentials
LLVM.Interop.isboxed
— Functionisboxed(typ::Type)
Return if a type would be boxed when instantiated in the code generator.
LLVM.Interop.isghosttype
— Functionisghosttype(t::Type)
isghosttype(T::LLVMType)
Check if a type is a ghost type, implying it would not be emitted by the Julia compiler. This only works for types created by the Julia compiler (living in its LLVM context).
LLVM.Interop.create_function
— Functioncreate_function(rettyp::LLVMType, argtyp::Vector{LLVMType}, [name::String])
Create an LLVM function, given its return type rettyp
and a vector of argument types argtyp
. The function is marked for inlining, to be embedded in the caller's body. Returns both the newly created function, and its type.
LLVM.Interop.call_function
— Functioncall_function(f::LLVM.Function, rettyp::Type, argtyp::Type, args...)
Generate a call to an LLVM function f
, given its return type rettyp
and a tuple-type for the arguments. The arguments should be passed as a tuple expression containing the argument values (eg. :((1,2))
), which will be splatted into the call to the function.
Calling inline assembly
LLVM.Interop.@asmcall
— Macro@asmcall asm::String [constraints::String] [side_effects::Bool=false]
rettyp=Nothing argtyp=Tuple{} args...
Call some inline assembly asm
, optionally constrained by constraints
and denoting other side effects in side_effects
, specifying the return type in rettyp
and types of arguments as a tuple-type in argtyp
.
LLVM pointer support
LLVM.Interop.@typed_ccall
— Macro@typed_ccall(intrinsic, llvmcall, rettyp, (argtyps...), args...)
Perform a ccall
while more accurately preserving argument types like LLVM expects them:
Bool
s are passed asi1
, noti8
;- Pointers (both
Ptr
andCore.LLVMPtr
) are passed as typed pointers (instead of resp.i8*
andi64
); Val
-typed arguments will be passed as constants, if supported.
These features can be useful to call LLVM intrinsics, which may expect a specific set of argument types.
This macro is not needed anymore on Julia 1.12, where the llvmcall
ABI has been extended to preserve argument types more accurately.
LLVM intrinsics
LLVM.Interop.trap
— Functiontrap()
Trap the program, causing it to abort.
LLVM.Interop.assume
— Functionassume(cond::Bool)
Assume that the condition cond
is true. This is a hint to the compiler, possibly enabling it to optimize more aggressively.