Target information allows you to inspect and modify aspects of the code generation, such as which CPU is targeted or what optimization level is desired.
Minimal use of this module would be to create a
TargetMachine for later use in code generation.
from llvmlite import binding target = binding.Target.from_default_triple() target_machine = target.create_target_machine()
Return a string representing the default target triple that LLVM is configured to produce code for. This represents the host’s architecture and platform.
Return a target triple suitable for generating code for the current process.
EXAMPLE: The default triple from
get_default_triple()is not suitable when LLVM is compiled for 32-bit, but the process is executing in 64-bit mode.
Get the object format for the given triple string, or the default triple if
None. Returns a string such as
Return a dictionary-like object indicating the CPU features for the current architecture and whether they are enabled for this CPU.
The key-value pairs contain the feature name as a string and a boolean indicating whether the feature is available.
The returned value is an instance of the
FeatureMapclass, which adds a new method
.flatten()for returning a string suitable for use as the
If LLVM has not implemented this feature or it fails to get the information, a
RuntimeErrorexception is raised.
- class llvmlite.binding.TargetData¶
Provides functionality around a given data layout. It specifies how the different types are to be represented in memory. Use
- get_element_offset(type, position)¶
Computes the byte offset of the struct element at position.
- class llvmlite.binding.Target¶
Represents a compilation target. The following factories are provided:
The following attributes and methods are available:
A description of the target.
The name of the target.
A string that uniquely identifies the target.
- create_target_machine(cpu='', features='', opt=2, reloc='default', codemodel='jitdefault')¶
Create a new
TargetMachineinstance for this target and with the given options:
cpu is an optional CPU name to specialize for.
features is a comma-separated list of target-specific features to enable or disable.
opt is the optimization level, from 0 to 3.
reloc is the relocation model.
codemodel is the code model.
The defaults for reloc and codemodel are appropriate for JIT compilation.
TIP: To list the available CPUs and features for a target, run the command
- class llvmlite.binding.TargetMachine¶
Holds all the settings necessary for proper code generation, including target information and compiler options. Instantiate using
Set whether this target machine emits assembly with human-readable comments, such as those describing control flow or debug information.
- class llvmlite.binding.FeatureMap¶
Stores processor feature information in a dictionary-like object. This class extends
dictand adds only the