On this page:
2.1 Module Creation and Management
llvm-module
llvm-dispose-module
llvm-clone-module
2.2 Module Verification and Output
llvm-module-verify
llvm-module->string
llvm-dump-module
llvm-print-module-to-string
llvm-write-bitcode-to-file
2.3 Functions
llvm-add-function
llvm-get-function
llvm-set-function-call-conv
llvm-count-params
llvm-verify-function
2.4 Global Variables
llvm-add-global
llvm-add-global-i-func
llvm-add-global-in-address-space
llvm-add-global-mapping
llvm-get-named-global
llvm-set-initializer
llvm-get-initializer
2.5 Global Value Properties
llvm-get-linkage
llvm-set-linkage
llvm-get-visibility
llvm-set-visibility
llvm-get-unnamed-address
llvm-set-unnamed-address
llvm-get-dll-storage-class
llvm-set-dll-storage-class
llvm-get-thread-local-mode
llvm-set-thread-local-mode
2.6 COMDAT (Common Data)
llvm-get-comdat-selection-kind
llvm-set-comdat-selection-kind
2.7 Module Flags
llvm-add-module-flag
llvm-module-flag-entries-get-flag-behavior
2.8 Context
llvm-context-create
llvm-get-global-context
2.9 Initialization
llvm-link-in-mcjit
llvm-link-in-interpreter
2.10 Module Linking and Aliases
llvm-add-alias2
llvm-add-analysis-passes
9.1

2 Module🔗ℹ

2.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.

2.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.

2.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.

2.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-add-global-i-func module    
  name    
  address-space    
  type    
  flags    
  resolver)  LLVMValueRef?
  module : LLVMModuleRef?
  name : string?
  address-space : unsigned
  type : LLVMTypeRef?
  flags : unsigned
  resolver : LLVMValueRef?
Adds a global indirect function to the module with the given name, type, and resolver function.

procedure

(llvm-add-global-in-address-space module 
  type 
  name 
  address-space) 
  LLVMValueRef?
  module : LLVMModuleRef?
  type : LLVMTypeRef?
  name : string?
  address-space : unsigned
Adds a global variable to the module with the given type, name, and address space.

procedure

(llvm-add-global-mapping execution-engine    
  global    
  address)  void?
  execution-engine : LLVMExecutionEngineRef?
  global : LLVMValueRef?
  address : pointer
Maps a global variable to a specific memory address in the execution engine.

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.

2.5 Global Value Properties🔗ℹ

procedure

(llvm-get-linkage global)  _llvm-linkage

  global : LLVMValueRef?
Returns the linkage type of a global value.

procedure

(llvm-set-linkage global linkage)  void?

  global : LLVMValueRef?
  linkage : _llvm-linkage
Sets the linkage type of a global value.

procedure

(llvm-get-visibility global)  _llvm-visibility

  global : LLVMValueRef?
Returns the visibility of a global symbol (default, hidden, or protected).

procedure

(llvm-set-visibility global visibility)  void?

  global : LLVMValueRef?
  visibility : _llvm-visibility
Sets the visibility of a global symbol.

procedure

(llvm-get-unnamed-address global)  _llvm-unnamed-addr

  global : LLVMValueRef?
Returns the unnamed address mode of a global value.

procedure

(llvm-set-unnamed-address global addr)  void?

  global : LLVMValueRef?
  addr : _llvm-unnamed-addr
Sets the unnamed address mode of a global value.

procedure

(llvm-get-dll-storage-class global)  _llvmdll-storage-class

  global : LLVMValueRef?
Returns the DLL storage class of a global value (Windows: import or export).

procedure

(llvm-set-dll-storage-class global    
  storage-class)  void?
  global : LLVMValueRef?
  storage-class : _llvmdll-storage-class
Sets the DLL storage class of a global value.

Returns the thread-local storage mode of a global variable.

procedure

(llvm-set-thread-local-mode global mode)  void?

  global : LLVMValueRef?
  mode : _llvm-thread-local-mode
Sets the thread-local storage mode of a global variable.

2.6 COMDAT (Common Data)🔗ℹ

Returns the selection strategy for a COMDAT symbol.

procedure

(llvm-set-comdat-selection-kind comdat    
  kind)  void?
  comdat : _LLVMComdatRef
  kind : _llvm-comdat-selection-kind
Sets the selection strategy for a COMDAT symbol (how duplicates are handled during linking).

2.7 Module Flags🔗ℹ

procedure

(llvm-add-module-flag module    
  behavior    
  key    
  value)  void?
  module : LLVMModuleRef?
  behavior : _llvm-module-flag-behavior
  key : string?
  value : _LLVMMetadataRef
Adds a module flag with the specified behavior for handling conflicts.

Returns the behavior of a module flag entry.

2.8 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.

2.9 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.

2.10 Module Linking and Aliases🔗ℹ

procedure

(llvm-add-alias2 module    
  alias-type    
  address-space    
  function    
  name)  LLVMValueRef?
  module : LLVMModuleRef?
  alias-type : LLVMTypeRef?
  address-space : unsigned
  function : LLVMValueRef?
  name : string?
Creates an alias for a function in the given module. The alias has the specified type and address space.

procedure

(llvm-add-analysis-passes target-machine    
  pass-manager)  void?
  target-machine : LLVMTargetMachineRef?
  pass-manager : LLVMPassManagerRef?
Adds analysis passes to a pass manager for the given target machine.