rocm.bindings.llvm.c.targetmachine

Contents

rocm.bindings.llvm.c.targetmachine#

2026-09-24

14 min read time

Applies to Linux and Windows

Advanced Micro Devices, Inc.

Attributes#

Classes#

LLVMOpaqueTargetMachineOptions

(No short description)

LLVMOpaqueTargetMachine

(No short description)

LLVMTarget

(No short description)

LLVMCodeGenOptLevel

(No short description)

LLVMRelocMode

(No short description)

LLVMCodeModel

(No short description)

LLVMCodeGenFileType

(No short description)

LLVMGlobalISelAbortMode

(No short description)

Functions#

has_symbol(→ bool)

LLVMGetFirstTarget()

Returns the first llvm::Target in the registered targets list.

LLVMGetNextTarget(T)

Returns the next llvm::Target given a previous one (or null if there's none)

LLVMGetTargetFromName(Name)

Finds the target corresponding to the given name and stores it in T.

LLVMGetTargetFromTriple(Triple)

Finds the target corresponding to the given triple and stores it in T.

LLVMGetTargetName(T)

Returns the name of a target. See llvm::Target::getName

LLVMGetTargetDescription(T)

Returns the description of a target. See llvm::Target::getDescription

LLVMTargetHasJIT(T)

Returns if the target has a JIT

LLVMTargetHasTargetMachine(T)

Returns if the target has a TargetMachine associated

LLVMTargetHasAsmBackend(T)

Returns if the target as an ASM backend (required for emitting output)

LLVMCreateTargetMachineOptions()

Create a new set of options for an llvm::TargetMachine.

LLVMDisposeTargetMachineOptions(Options)

Dispose of an LLVMTargetMachineOptionsRef instance.

LLVMTargetMachineOptionsSetCPU(Options, CPU)

Dispose of an LLVMTargetMachineOptionsRef instance.

LLVMTargetMachineOptionsSetFeatures(Options, Features)

Set the list of features for the target machine.

LLVMTargetMachineOptionsSetABI(Options, ABI)

Set the list of features for the target machine.

LLVMTargetMachineOptionsSetCodeGenOptLevel(Options, Level)

Set the list of features for the target machine.

LLVMTargetMachineOptionsSetRelocMode(Options, Reloc)

Set the list of features for the target machine.

LLVMTargetMachineOptionsSetCodeModel(Options, CodeModel)

Set the list of features for the target machine.

LLVMCreateTargetMachineWithOptions(T, Triple, Options)

Create a new llvm::TargetMachine.

LLVMCreateTargetMachine(T, Triple, CPU, Features, ...)

Creates a new llvm::TargetMachine. See llvm::Target::createTargetMachine

LLVMDisposeTargetMachine(T)

Dispose the LLVMTargetMachineRef instance generated by

LLVMGetTargetMachineTarget(T)

Returns the Target used in a TargetMachine

LLVMGetTargetMachineTriple(T)

Returns the triple used creating this target machine.

LLVMGetTargetMachineCPU(T)

Returns the cpu used creating this target machine.

LLVMGetTargetMachineFeatureString(T)

Returns the feature string used creating this target machine.

LLVMCreateTargetDataLayout(T)

Create a DataLayout based on the targetMachine.

LLVMSetTargetMachineAsmVerbosity(T, VerboseAsm)

Set the target machine's ASM verbosity.

LLVMSetTargetMachineFastISel(T, Enable)

Enable fast-path instruction selection.

LLVMSetTargetMachineGlobalISel(T, Enable)

Enable global instruction selection.

LLVMSetTargetMachineGlobalISelAbort(T, Mode)

Set abort behaviour when global instruction selection fails to lower/select

LLVMSetTargetMachineMachineOutliner(T, Enable)

Enable the MachineOutliner pass.

LLVMTargetMachineEmitToFile(T, M, Filename, codegen, ...)

Emits an asm or object file for the given module to the filename.

LLVMTargetMachineEmitToMemoryBuffer(T, M, codegen, ...)

Compile the LLVM IR stored in M and store the result in OutMemBuf.

LLVMGetDefaultTargetTriple()

Get a triple for the host machine as a string.

LLVMNormalizeTargetTriple(triple)

Normalize a target triple.

LLVMGetHostCPUName()

Get the host CPU as a string.

LLVMGetHostCPUFeatures()

Get the host CPU's features as a string.

LLVMAddAnalysisPasses(T, PM)

Adds the target-specific analysis passes to the pass manager.

Module Contents#

rocm.bindings.llvm.c.targetmachine.has_symbol(name: str | bytes | bytearray) → bool#
class rocm.bindings.llvm.c.targetmachine.LLVMOpaqueTargetMachineOptions(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

(No short description)

rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineOptionsRef#
class rocm.bindings.llvm.c.targetmachine.LLVMOpaqueTargetMachine(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

(No short description)

rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineRef#
class rocm.bindings.llvm.c.targetmachine.LLVMTarget(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

(No short description)

rocm.bindings.llvm.c.targetmachine.LLVMTargetRef#
class rocm.bindings.llvm.c.targetmachine.LLVMCodeGenOptLevel#

Bases: enum.IntEnum

(No short description)

LLVMCodeGenLevelNone: int#
LLVMCodeGenLevelLess: int#
LLVMCodeGenLevelDefault: int#
LLVMCodeGenLevelAggressive: int#
class rocm.bindings.llvm.c.targetmachine.LLVMRelocMode#

Bases: enum.IntEnum

(No short description)

LLVMRelocDefault: int#
LLVMRelocStatic: int#
LLVMRelocPIC: int#
LLVMRelocDynamicNoPic: int#
LLVMRelocROPI: int#
LLVMRelocRWPI: int#
LLVMRelocROPI_RWPI: int#
class rocm.bindings.llvm.c.targetmachine.LLVMCodeModel#

Bases: enum.IntEnum

(No short description)

LLVMCodeModelDefault: int#
LLVMCodeModelJITDefault: int#
LLVMCodeModelTiny: int#
LLVMCodeModelSmall: int#
LLVMCodeModelKernel: int#
LLVMCodeModelMedium: int#
LLVMCodeModelLarge: int#
class rocm.bindings.llvm.c.targetmachine.LLVMCodeGenFileType#

Bases: enum.IntEnum

(No short description)

LLVMAssemblyFile: int#
LLVMObjectFile: int#
class rocm.bindings.llvm.c.targetmachine.LLVMGlobalISelAbortMode#

Bases: enum.IntEnum

(No short description)

LLVMGlobalISelAbortEnable: int#
LLVMGlobalISelAbortDisable: int#
LLVMGlobalISelAbortDisableWithDiag: int#
rocm.bindings.llvm.c.targetmachine.LLVMGetFirstTarget()#

Returns the first llvm::Target in the registered targets list.

Returns:

None: (undocumented)

C signature

LLVMTargetRef LLVMGetFirstTarget()
rocm.bindings.llvm.c.targetmachine.LLVMGetNextTarget(T)#

Returns the next llvm::Target given a previous one (or null if there’s none)

Args:
T (LLVMTarget/object):

(undocumented)

Returns:

None: (undocumented)

C signature

LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T)
rocm.bindings.llvm.c.targetmachine.LLVMGetTargetFromName(Name)#

Finds the target corresponding to the given name and stores it in T. Returns 0 on success.

Args:
Name (CStr/object):

(undocumented)

Returns:

None: (undocumented)

C signature

LLVMTargetRef LLVMGetTargetFromName(const char * Name)
rocm.bindings.llvm.c.targetmachine.LLVMGetTargetFromTriple(Triple)#

Finds the target corresponding to the given triple and stores it in T. Returns 0 on success.

Optionally returns any error in ErrorMessage. Use LLVMDisposeMessage to dispose the message.

Args:
Triple (CStr/object):

(undocumented)

Returns:

A tuple of size 3 that contains (in that order):

C signature

LLVMBool LLVMGetTargetFromTriple(const char * Triple, LLVMTargetRef * T, char ** ErrorMessage)
rocm.bindings.llvm.c.targetmachine.LLVMGetTargetName(T)#

Returns the name of a target. See llvm::Target::getName

Args:
T (LLVMTarget/object):

(undocumented)

Returns:

bytes: (undocumented)

C signature

const char * LLVMGetTargetName(LLVMTargetRef T)
rocm.bindings.llvm.c.targetmachine.LLVMGetTargetDescription(T)#

Returns the description of a target. See llvm::Target::getDescription

Args:
T (LLVMTarget/object):

(undocumented)

Returns:

bytes: (undocumented)

C signature

const char * LLVMGetTargetDescription(LLVMTargetRef T)
rocm.bindings.llvm.c.targetmachine.LLVMTargetHasJIT(T)#

Returns if the target has a JIT

Args:
T (LLVMTarget/object):

(undocumented)

Returns:

int: (undocumented)

C signature

LLVMBool LLVMTargetHasJIT(LLVMTargetRef T)
rocm.bindings.llvm.c.targetmachine.LLVMTargetHasTargetMachine(T)#

Returns if the target has a TargetMachine associated

Args:
T (LLVMTarget/object):

(undocumented)

Returns:

int: (undocumented)

C signature

LLVMBool LLVMTargetHasTargetMachine(LLVMTargetRef T)
rocm.bindings.llvm.c.targetmachine.LLVMTargetHasAsmBackend(T)#

Returns if the target as an ASM backend (required for emitting output)

Args:
T (LLVMTarget/object):

(undocumented)

Returns:

int: (undocumented)

C signature

LLVMBool LLVMTargetHasAsmBackend(LLVMTargetRef T)
rocm.bindings.llvm.c.targetmachine.LLVMCreateTargetMachineOptions()#

Create a new set of options for an llvm::TargetMachine.

The returned option structure must be released with LLVMDisposeTargetMachineOptions() after the call to LLVMCreateTargetMachineWithOptions().

Returns:

None: (undocumented)

C signature

LLVMTargetMachineOptionsRef LLVMCreateTargetMachineOptions()
rocm.bindings.llvm.c.targetmachine.LLVMDisposeTargetMachineOptions(Options)#

Dispose of an LLVMTargetMachineOptionsRef instance.

Args:
Options (LLVMOpaqueTargetMachineOptions/object):

(undocumented)

C signature

void LLVMDisposeTargetMachineOptions(LLVMTargetMachineOptionsRef Options)
rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineOptionsSetCPU(Options, CPU)#

Dispose of an LLVMTargetMachineOptionsRef instance.

Args:
Options (LLVMOpaqueTargetMachineOptions/object):

(undocumented)

CPU (CStr/object):

(undocumented)

C signature

void LLVMTargetMachineOptionsSetCPU(LLVMTargetMachineOptionsRef Options, const char * CPU)
rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineOptionsSetFeatures(Options, Features)#

Set the list of features for the target machine.

Args:
Options (LLVMOpaqueTargetMachineOptions/object):

(undocumented)

Features (CStr/object):

a comma-separated list of features.

C signature

void LLVMTargetMachineOptionsSetFeatures(LLVMTargetMachineOptionsRef Options, const char * Features)
rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineOptionsSetABI(Options, ABI)#

Set the list of features for the target machine.

Args:
Options (LLVMOpaqueTargetMachineOptions/object):

(undocumented)

ABI (CStr/object):

(undocumented)

C signature

void LLVMTargetMachineOptionsSetABI(LLVMTargetMachineOptionsRef Options, const char * ABI)
rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineOptionsSetCodeGenOptLevel(Options, Level)#

Set the list of features for the target machine.

Args:
Options (LLVMOpaqueTargetMachineOptions/object):

(undocumented)

Level (LLVMCodeGenOptLevel):

(undocumented)

C signature

void LLVMTargetMachineOptionsSetCodeGenOptLevel(LLVMTargetMachineOptionsRef Options, LLVMCodeGenOptLevel Level)
rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineOptionsSetRelocMode(Options, Reloc)#

Set the list of features for the target machine.

Args:
Options (LLVMOpaqueTargetMachineOptions/object):

(undocumented)

Reloc (LLVMRelocMode):

(undocumented)

C signature

void LLVMTargetMachineOptionsSetRelocMode(LLVMTargetMachineOptionsRef Options, LLVMRelocMode Reloc)
rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineOptionsSetCodeModel(Options, CodeModel)#

Set the list of features for the target machine.

Args:
Options (LLVMOpaqueTargetMachineOptions/object):

(undocumented)

CodeModel (LLVMCodeModel):

(undocumented)

C signature

void LLVMTargetMachineOptionsSetCodeModel(LLVMTargetMachineOptionsRef Options, LLVMCodeModel CodeModel)
rocm.bindings.llvm.c.targetmachine.LLVMCreateTargetMachineWithOptions(T, Triple, Options)#

Create a new llvm::TargetMachine.

Args:
T (LLVMTarget/object):

the target to create a machine for.

Triple (CStr/object):

a triple describing the target machine.

Options (LLVMOpaqueTargetMachineOptions/object):

additional configuration (see LLVMCreateTargetMachineOptions()).

Returns:

None: (undocumented)

C signature

LLVMTargetMachineRef LLVMCreateTargetMachineWithOptions(LLVMTargetRef T, const char * Triple, LLVMTargetMachineOptionsRef Options)
rocm.bindings.llvm.c.targetmachine.LLVMCreateTargetMachine(T, Triple, CPU, Features, Level, Reloc, CodeModel)#

Creates a new llvm::TargetMachine. See llvm::Target::createTargetMachine

Args:
T (LLVMTarget/object):

(undocumented)

Triple (CStr/object):

(undocumented)

CPU (CStr/object):

(undocumented)

Features (CStr/object):

(undocumented)

Level (LLVMCodeGenOptLevel):

(undocumented)

Reloc (LLVMRelocMode):

(undocumented)

CodeModel (LLVMCodeModel):

(undocumented)

Returns:

None: (undocumented)

C signature

LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T, const char * Triple, const char * CPU, const char * Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, LLVMCodeModel CodeModel)
rocm.bindings.llvm.c.targetmachine.LLVMDisposeTargetMachine(T)#

Dispose the LLVMTargetMachineRef instance generated by LLVMCreateTargetMachine.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

C signature

void LLVMDisposeTargetMachine(LLVMTargetMachineRef T)
rocm.bindings.llvm.c.targetmachine.LLVMGetTargetMachineTarget(T)#

Returns the Target used in a TargetMachine

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

Returns:

None: (undocumented)

C signature

LLVMTargetRef LLVMGetTargetMachineTarget(LLVMTargetMachineRef T)
rocm.bindings.llvm.c.targetmachine.LLVMGetTargetMachineTriple(T)#

Returns the triple used creating this target machine.

See llvm::TargetMachine::getTriple. The result needs to be disposed with LLVMDisposeMessage.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

Returns:

bytes: (undocumented)

C signature

char * LLVMGetTargetMachineTriple(LLVMTargetMachineRef T)
rocm.bindings.llvm.c.targetmachine.LLVMGetTargetMachineCPU(T)#

Returns the cpu used creating this target machine.

See llvm::TargetMachine::getCPU. The result needs to be disposed with LLVMDisposeMessage.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

Returns:

bytes: (undocumented)

C signature

char * LLVMGetTargetMachineCPU(LLVMTargetMachineRef T)
rocm.bindings.llvm.c.targetmachine.LLVMGetTargetMachineFeatureString(T)#

Returns the feature string used creating this target machine.

See llvm::TargetMachine::getFeatureString. The result needs to be disposed with LLVMDisposeMessage.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

Returns:

bytes: (undocumented)

C signature

char * LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T)
rocm.bindings.llvm.c.targetmachine.LLVMCreateTargetDataLayout(T)#

Create a DataLayout based on the targetMachine.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

Returns:

None: (undocumented)

C signature

LLVMTargetDataRef LLVMCreateTargetDataLayout(LLVMTargetMachineRef T)
rocm.bindings.llvm.c.targetmachine.LLVMSetTargetMachineAsmVerbosity(T, VerboseAsm)#

Set the target machine’s ASM verbosity.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

VerboseAsm (int):

(undocumented)

C signature

void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T, LLVMBool VerboseAsm)
rocm.bindings.llvm.c.targetmachine.LLVMSetTargetMachineFastISel(T, Enable)#

Enable fast-path instruction selection.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

Enable (int):

(undocumented)

C signature

void LLVMSetTargetMachineFastISel(LLVMTargetMachineRef T, LLVMBool Enable)
rocm.bindings.llvm.c.targetmachine.LLVMSetTargetMachineGlobalISel(T, Enable)#

Enable global instruction selection.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

Enable (int):

(undocumented)

C signature

void LLVMSetTargetMachineGlobalISel(LLVMTargetMachineRef T, LLVMBool Enable)
rocm.bindings.llvm.c.targetmachine.LLVMSetTargetMachineGlobalISelAbort(T, Mode)#

Set abort behaviour when global instruction selection fails to lower/select an instruction.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

Mode (LLVMGlobalISelAbortMode):

(undocumented)

C signature

void LLVMSetTargetMachineGlobalISelAbort(LLVMTargetMachineRef T, LLVMGlobalISelAbortMode Mode)
rocm.bindings.llvm.c.targetmachine.LLVMSetTargetMachineMachineOutliner(T, Enable)#

Enable the MachineOutliner pass.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

Enable (int):

(undocumented)

C signature

void LLVMSetTargetMachineMachineOutliner(LLVMTargetMachineRef T, LLVMBool Enable)
rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineEmitToFile(T, M, Filename, codegen, ErrorMessage)#

Emits an asm or object file for the given module to the filename.

This wraps several c++ only classes (among them a file stream). Returns any error in ErrorMessage. Use LLVMDisposeMessage to dispose the message.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

M (Pointer/object):

(undocumented)

Filename (CStr/object):

(undocumented)

codegen (LLVMCodeGenFileType):

(undocumented)

ErrorMessage (Pointer/object):

(undocumented)

Returns:

int: (undocumented)

C signature

LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, const char * Filename, LLVMCodeGenFileType codegen, char ** ErrorMessage)
rocm.bindings.llvm.c.targetmachine.LLVMTargetMachineEmitToMemoryBuffer(T, M, codegen, ErrorMessage, OutMemBuf)#

Compile the LLVM IR stored in M and store the result in OutMemBuf.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

M (Pointer/object):

(undocumented)

codegen (LLVMCodeGenFileType):

(undocumented)

ErrorMessage (Pointer/object):

(undocumented)

OutMemBuf (Pointer/object):

(undocumented)

Returns:

int: (undocumented)

C signature

LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M, LLVMCodeGenFileType codegen, char ** ErrorMessage, LLVMMemoryBufferRef * OutMemBuf)
rocm.bindings.llvm.c.targetmachine.LLVMGetDefaultTargetTriple()#

Get a triple for the host machine as a string.

The result needs to be disposed with LLVMDisposeMessage.

Returns:

bytes: (undocumented)

C signature

char * LLVMGetDefaultTargetTriple()
rocm.bindings.llvm.c.targetmachine.LLVMNormalizeTargetTriple(triple)#

Normalize a target triple.

The result needs to be disposed with LLVMDisposeMessage.

Args:
triple (CStr/object):

(undocumented)

Returns:

bytes: (undocumented)

C signature

char * LLVMNormalizeTargetTriple(const char * triple)
rocm.bindings.llvm.c.targetmachine.LLVMGetHostCPUName()#

Get the host CPU as a string.

The result needs to be disposed with LLVMDisposeMessage.

Returns:

bytes: (undocumented)

C signature

char * LLVMGetHostCPUName()
rocm.bindings.llvm.c.targetmachine.LLVMGetHostCPUFeatures()#

Get the host CPU’s features as a string.

The result needs to be disposed with LLVMDisposeMessage.

Returns:

bytes: (undocumented)

C signature

char * LLVMGetHostCPUFeatures()
rocm.bindings.llvm.c.targetmachine.LLVMAddAnalysisPasses(T, PM)#

Adds the target-specific analysis passes to the pass manager.

Args:
T (LLVMOpaqueTargetMachine/object):

(undocumented)

PM (Pointer/object):

(undocumented)

C signature

void LLVMAddAnalysisPasses(LLVMTargetMachineRef T, LLVMPassManagerRef PM)