3.3. Modules¶
A module is a compilation unit. It defines a set of related functions,
global variables and metadata. In the IR layer, a module is representated
by the Module class.
-
class
llvmlite.ir.Module(name='')¶ Create a module. The optional name, a Python string, can be specified for informational purposes.
Modules have the following methods and attributes:
-
add_global(globalvalue)¶ Add the given globalvalue (a
GlobalValue) to this module. It should have a unique name in the whole module.
-
add_metadata(operands)¶ Add an unnamed metadata node to the module with the given operands (a list of metadata-compatible values). If another metadata node with equal operands already exists in the module, it is reused instead. A
MDValueis returned.
-
add_named_metadata(name)¶ Add a named metadata with the given name. A
NamedMetaDatais returned.
-
get_global(name)¶ Get the global value (a
GlobalValue) with the given name.KeyErroris raised if it doesn’t exist.
-
get_named_metadata(name)¶ Return the named metadata with the given name.
KeyErroris raised if it doesn’t exist.
-
get_unique_name(name)¶ Return a unique name accross the whole module. name is the desired name, but a variation can be returned if it is already in use.
-
data_layout¶ A string representing the data layout in LLVM format.
-
global_values¶ An iterable of global values in this module.
-
triple¶ A string representing the target architecture in LLVM “triple” form.
-