On this page:
5.1 Execution Engine
llvm-create-execution-engine-for-module
llvm-get-function-address
llvm-get-execution-engine-target-data
llvm-get-execution-engine-target-machine
5.2 Running Functions
llvm-run-function
5.3 Generic Values
llvm-create-generic-value-of-int
llvm-create-generic-value-of-float
llvm-generic-value->int
llvm-generic-value-to-float
5.4 Target Machine Configuration
llvm-create-target-machine
llvm-target-machine-emit-to-file
llvm-target-machine-emit-to-memory-buffer
llvm-target-machine-options-set-code-gen-opt-level
llvm-target-machine-options-set-code-model
llvm-target-machine-options-set-reloc-mode
llvm-set-target-machine-global-i-sel-abort
5.5 Binary Objects
llvm-binary-get-type
llvm-binary-copy-memory-buffer
5.6 ORC JIT
5.6.1 LLJIT Builder and Creation
llvm-orc-create-lljit-builder
llvm-orc-lljit-builder-set-jit-target-machine-builder
llvm-orc-dispose-lljit-builder
llvm-orc-create-lljit
llvm-orc-dispose-lljit
5.6.2 Adding Code to LLJIT
llvm-orc-lljit-add-llvmir-module
llvm-orc-lljit-add-object-file
5.6.3 Looking up Symbols
llvm-orc-lljit-lookup
5.6.4 LLJIT Introspection
llvm-orc-lljit-get-main-jit-dylib
llvm-orc-lljit-get-execution-session
llvm-orc-lljit-get-data-layout-str
llvm-orc-lljit-get-triple-string
5.6.5 Thread-Safe Modules
llvm-orc-create-new-thread-safe-context
llvm-orc-create-new-thread-safe-module
llvm-orc-dispose-thread-safe-context
9.1

5 JIT🔗ℹ

Functions for JIT compilation and execution of LLVM IR.

5.1 Execution Engine🔗ℹ

return an execution engine for given module

procedure

(llvm-get-function-address engine name)

  exact-nonnegative-integer?
  engine : LLVMExecutionEngineRef?
  name : string?
Returns the address of the compiled function with the given name. The returned integer can be cast to a function pointer using Racket FFI.

Returns the target data associated with the execution engine.

Returns the target machine associated with the execution engine.

5.2 Running Functions🔗ℹ

procedure

(llvm-run-function engine function)  LLVMGenericValueRef?

  engine : LLVMExecutionEngineRef?
  function : LLVMValueRef?
run given function on engine, it returns result as LLVMGenericValueRef?

5.3 Generic Values🔗ℹ

Generic values are used to pass arguments to and receive results from JIT-compiled functions.

procedure

(llvm-create-generic-value-of-int type 
  value 
  signed?) 
  LLVMGenericValueRef?
  type : LLVMTypeRef?
  value : integer?
  signed? : boolean?
Converted given value to LLVMGenericValueRef?. type decided it’s LLVM type corresponding. signed? decided it’s signed integer or not.

procedure

(llvm-create-generic-value-of-float type 
  value) 
  LLVMGenericValueRef?
  type : LLVMTypeRef?
  value : number?
Converted given value to LLVMGenericValueRef?. type decided it’s LLVM type corresponding.

procedure

(llvm-generic-value->int generic-value    
  signed?)  integer?
  generic-value : LLVMGenericValueRef?
  signed? : boolean?
convert generic-value back to racket integer?. signed? decided treat it as a signed integer or not.

procedure

(llvm-generic-value-to-float type    
  generic-value)  number?
  type : LLVMTypeRef?
  generic-value : LLVMGenericValueRef?
convert generic-value back to racket number?

5.4 Target Machine Configuration🔗ℹ

procedure

(llvm-create-target-machine target    
  triple    
  cpu    
  features    
  level    
  reloc    
  model)  _LLVMTargetMachineRef
  target : _LLVMTargetRef
  triple : string?
  cpu : string?
  features : string?
  level : _llvm-code-gen-opt-level
  reloc : _llvm-reloc-mode
  model : _llvm-code-model
Creates a target machine for the given target, CPU, and features. level specifies optimization level. reloc specifies the relocation model. model specifies the code model.

procedure

(llvm-target-machine-emit-to-file target-machine    
  module    
  filename    
  codegen)  void?
  target-machine : _LLVMTargetMachineRef
  module : LLVMModuleRef?
  filename : string?
  codegen : _llvm-code-gen-file-type
Emits the module as code to the given file. codegen specifies whether to emit assembly or object code.

procedure

(llvm-target-machine-emit-to-memory-buffer target-machine 
  module 
  codegen) 
  bytes?
  target-machine : _LLVMTargetMachineRef
  module : LLVMModuleRef?
  codegen : _llvm-code-gen-file-type
Emits the module as code to a memory buffer. Returns the generated code as bytes.

Sets the code generation optimization level for target machine options.

procedure

(llvm-target-machine-options-set-code-model options    
  model)  void?
  options : _LLVMTargetMachineOptionsRef
  model : _llvm-code-model
Sets the code model for target machine options.

procedure

(llvm-target-machine-options-set-reloc-mode options    
  reloc)  void?
  options : _LLVMTargetMachineOptionsRef
  reloc : _llvm-reloc-mode
Sets the relocation mode for target machine options.

procedure

(llvm-set-target-machine-global-i-sel-abort machine    
  mode)  void?
  machine : _LLVMTargetMachineRef
  mode : _llvm-global-i-sel-abort-mode
Controls whether GlobalISel aborts on failure.

5.5 Binary Objects🔗ℹ

procedure

(llvm-binary-get-type binary)  _llvm-binary-type

  binary : LLVMBinaryRef?
Returns the type of a binary object file.

procedure

(llvm-binary-copy-memory-buffer binary)  _LLVMMemoryBufferRef

  binary : LLVMBinaryRef?
Creates a copy of the memory buffer of a binary object file.

5.6 ORC JIT🔗ℹ

The ORC JIT (On-Request Compilation) API provides a higher-level JIT compilation interface compared to the basic execution engine.

5.6.1 LLJIT Builder and Creation🔗ℹ

Creates a new LLJIT builder for configuring JIT options before creating an LLJIT instance.

procedure

(llvm-orc-lljit-builder-set-jit-target-machine-builder 
  builder 
  target-machine-builder) 
  void?
  builder : _LLVMOrcOpaqueLLJITBuilderRef
  target-machine-builder : _LLVMOrcOpaqueJITTargetMachineBuilderRef
Sets the target machine builder for the LLJIT builder.

procedure

(llvm-orc-dispose-lljit-builder builder)  void?

  builder : _LLVMOrcOpaqueLLJITBuilderRef
Disposes of an LLJIT builder.

procedure

(llvm-orc-create-lljit out-lljit builder)  _LLVMErrorRef

  out-lljit : (box/c any?)
  builder : _LLVMOrcOpaqueLLJITBuilderRef
Creates an LLJIT instance using the given builder. The LLJIT reference is returned in out-lljit.

procedure

(llvm-orc-dispose-lljit lljit)  _LLVMErrorRef

  lljit : _LLVMOrcOpaqueLLJITRef
Disposes of an LLJIT instance.

5.6.2 Adding Code to LLJIT🔗ℹ

procedure

(llvm-orc-lljit-add-llvmir-module lljit    
  dylib    
  module)  _LLVMErrorRef
  lljit : _LLVMOrcOpaqueLLJITRef
  dylib : _LLVMOrcOpaqueJITDylibRef
  module : _LLVMOrcOpaqueThreadSafeModuleRef
Adds an LLVM IR module to the LLJIT instance.

procedure

(llvm-orc-lljit-add-object-file lljit    
  dylib    
  obj-buffer)  _LLVMErrorRef
  lljit : _LLVMOrcOpaqueLLJITRef
  dylib : _LLVMOrcOpaqueJITDylibRef
  obj-buffer : _LLVMMemoryBufferRef
Adds an object file to the LLJIT instance.

5.6.3 Looking up Symbols🔗ℹ

procedure

(llvm-orc-lljit-lookup lljit    
  out-address    
  symbol)  _LLVMErrorRef
  lljit : _LLVMOrcOpaqueLLJITRef
  out-address : (box/c any?)
  symbol : string?
Looks up a symbol in the LLJIT instance and returns its address in out-address.

5.6.4 LLJIT Introspection🔗ℹ

Returns the main JIT dylib of the LLJIT instance.

Returns the execution session of the LLJIT instance.

Returns the data layout string of the LLJIT instance.

Returns the target triple string of the LLJIT instance.

5.6.5 Thread-Safe Modules🔗ℹ

Creates a thread-safe context for use with ORC JIT.

Creates a thread-safe module from an LLVM module and context.

Disposes of a thread-safe context.