On this page:
3.1 Module Creation and Management
llvm-module
llvm-dispose-module
llvm-clone-module
3.2 Module Verification and Output
llvm-module-verify
llvm-module->string
llvm-dump-module
llvm-print-module-to-string
llvm-write-bitcode-to-file
3.3 Functions
llvm-add-function
llvm-get-function
llvm-set-function-call-conv
llvm-count-params
llvm-verify-function
3.4 Global Variables
llvm-add-global
llvm-get-named-global
llvm-set-initializer
llvm-get-initializer
3.5 Context
llvm-context-create
llvm-get-global-context
3.6 Initialization
llvm-link-in-mcjit
llvm-link-in-interpreter
9.0

3 Module🔗ℹ

3.1 Module Creation and Management🔗ℹ

procedure

(llvm-module module-name)  LLVMModuleRef?

  module-name : string?
llvm-module returns a module, the core concept in LLVM. We puts global variables, functions, and type definitions in module.

procedure

(llvm-dispose-module module)  void?

  module : LLVMModuleRef?
Disposes a module and frees its resources.

procedure

(llvm-clone-module module)  LLVMModuleRef?

  module : LLVMModuleRef?
Creates a deep copy of the given module.

3.2 Module Verification and Output🔗ℹ

procedure

(llvm-module-verify module)  boolean?

  module : LLVMModuleRef?
verify given module

procedure

(llvm-module->string module)  string?

  module : LLVMModuleRef?
convert given module as string

procedure

(llvm-dump-module module)  void?

  module : LLVMModuleRef?
Dumps the module’s IR to stderr for debugging.

procedure

(llvm-print-module-to-string module)  string?

  module : LLVMModuleRef?
Returns the module’s LLVM IR as a string.

procedure

(llvm-write-bitcode-to-file module    
  file-path)  void?
  module : LLVMModuleRef?
  file-path : string?
Write module as content of file-path.

3.3 Functions🔗ℹ

procedure

(llvm-add-function module    
  function-name    
  function-type)  LLVMValueRef?
  module : LLVMModuleRef?
  function-name : string?
  function-type : LLVMTypeRef?
Add function into given module, return a function value. The function name is given by function-name, the function type is given by function-type.

procedure

(llvm-get-function module name)  LLVMValueRef?

  module : LLVMModuleRef?
  name : string?
Gets a function from the module by name. Returns #f if not found.

procedure

(llvm-set-function-call-conv function cc)  void?

  function : LLVMValueRef?
  cc : exact-nonnegative-integer?
Sets the calling convention of a function.

procedure

(llvm-count-params function)  exact-nonnegative-integer?

  function : LLVMValueRef?
Returns the number of parameters of a function.

procedure

(llvm-verify-function function action)  boolean?

  function : LLVMValueRef?
  action : exact-nonnegative-integer?
Verifies that a function is well-formed.

3.4 Global Variables🔗ℹ

procedure

(llvm-add-global module var-type var-name)  LLVMValueRef?

  module : LLVMModuleRef?
  var-type : LLVMTypeRef?
  var-name : string?
Add a global variable into given module.

procedure

(llvm-get-named-global module    
  global-variable-name)  LLVMValueRef?
  module : LLVMModuleRef?
  global-variable-name : string?
Get global variable reference by its name.

procedure

(llvm-set-initializer global constant-val)  void?

  global : LLVMValueRef?
  constant-val : LLVMValueRef?
Sets the initializer for a global variable.

procedure

(llvm-get-initializer global)  LLVMValueRef?

  global : LLVMValueRef?
Gets the initializer of a global variable.

3.5 Context🔗ℹ

Creates a new LLVM context. Contexts allow multiple independent compilations in the same process.

Returns the global LLVM context shared by all modules that don’t use a specific context.

3.6 Initialization🔗ℹ

procedure

(llvm-link-in-mcjit)  void?

Links in the MCJIT execution engine. Must be called before creating an MCJIT-based execution engine.

Links in the LLVM interpreter. Must be called before creating an interpreter-based execution engine.