LLVM 20.0.0git
Public Member Functions | Static Public Member Functions | Friends | List of all members
llvm::orc::JITTargetMachineBuilder Class Reference

A utility class for building TargetMachines for JITs. More...

#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h"

Public Member Functions

 JITTargetMachineBuilder (Triple TT)
 Create a JITTargetMachineBuilder based on the given triple.
 
Expected< std::unique_ptr< TargetMachine > > createTargetMachine ()
 Create a TargetMachine.
 
Expected< DataLayoutgetDefaultDataLayoutForTarget ()
 Get the default DataLayout for the target.
 
JITTargetMachineBuildersetCPU (std::string CPU)
 Set the CPU string.
 
const std::string & getCPU () const
 Returns the CPU string.
 
JITTargetMachineBuildersetRelocationModel (std::optional< Reloc::Model > RM)
 Set the relocation model.
 
const std::optional< Reloc::Model > & getRelocationModel () const
 Get the relocation model.
 
JITTargetMachineBuildersetCodeModel (std::optional< CodeModel::Model > CM)
 Set the code model.
 
const std::optional< CodeModel::Model > & getCodeModel () const
 Get the code model.
 
JITTargetMachineBuildersetCodeGenOptLevel (CodeGenOptLevel OptLevel)
 Set the LLVM CodeGen optimization level.
 
JITTargetMachineBuildersetFeatures (StringRef FeatureString)
 Set subtarget features.
 
JITTargetMachineBuilderaddFeatures (const std::vector< std::string > &FeatureVec)
 Add subtarget features.
 
SubtargetFeaturesgetFeatures ()
 Access subtarget features.
 
const SubtargetFeaturesgetFeatures () const
 Access subtarget features.
 
JITTargetMachineBuildersetOptions (TargetOptions Options)
 Set TargetOptions.
 
TargetOptionsgetOptions ()
 Access TargetOptions.
 
const TargetOptionsgetOptions () const
 Access TargetOptions.
 
TriplegetTargetTriple ()
 Access Triple.
 
const TriplegetTargetTriple () const
 Access Triple.
 

Static Public Member Functions

static Expected< JITTargetMachineBuilderdetectHost ()
 Create a JITTargetMachineBuilder for the host system.
 

Friends

class JITTargetMachineBuilderPrinter
 

Detailed Description

A utility class for building TargetMachines for JITs.

Definition at line 34 of file JITTargetMachineBuilder.h.

Constructor & Destructor Documentation

◆ JITTargetMachineBuilder()

llvm::orc::JITTargetMachineBuilder::JITTargetMachineBuilder ( Triple  TT)

Create a JITTargetMachineBuilder based on the given triple.

Note: TargetOptions is default-constructed, then EmulatedTLS is set to true. If EmulatedTLS is not required, these values should be reset before calling createTargetMachine.

Definition at line 19 of file JITTargetMachineBuilder.cpp.

References llvm::TargetOptions::EmulatedTLS, and llvm::TargetOptions::UseInitArray.

Member Function Documentation

◆ addFeatures()

JITTargetMachineBuilder & llvm::orc::JITTargetMachineBuilder::addFeatures ( const std::vector< std::string > &  FeatureVec)

Add subtarget features.

Definition at line 61 of file JITTargetMachineBuilder.cpp.

References llvm::SubtargetFeatures::AddFeature(), and F.

◆ createTargetMachine()

Expected< std::unique_ptr< TargetMachine > > llvm::orc::JITTargetMachineBuilder::createTargetMachine ( )

Create a TargetMachine.

This operation will fail if the requested target is not registered, in which case see llvm/Support/TargetSelect.h. To JIT IR the Target and the target's AsmPrinter must both be registered. To JIT assembly (including inline and module level assembly) the target's AsmParser must also be registered.

Definition at line 40 of file JITTargetMachineBuilder.cpp.

References llvm::SubtargetFeatures::getString(), llvm::Triple::getTriple(), llvm::inconvertibleErrorCode(), and llvm::TargetRegistry::lookupTarget().

Referenced by llvm::orc::LLJIT::createCompileFunction(), getDefaultDataLayoutForTarget(), and llvm::orc::ConcurrentIRCompiler::operator()().

◆ detectHost()

Expected< JITTargetMachineBuilder > llvm::orc::JITTargetMachineBuilder::detectHost ( )
static

Create a JITTargetMachineBuilder for the host system.

Note: TargetOptions is default-constructed, then EmulatedTLS is set to true. If EmulatedTLS is not required, these values should be reset before calling createTargetMachine.

Definition at line 25 of file JITTargetMachineBuilder.cpp.

References llvm::SubtargetFeatures::AddFeature(), getFeatures(), llvm::sys::getHostCPUFeatures(), llvm::sys::getHostCPUName(), llvm::sys::getProcessTriple(), and setCPU().

Referenced by LLVMOrcJITTargetMachineBuilderDetectHost(), and llvm::orc::LLJITBuilderState::prepareForConstruction().

◆ getCodeModel()

const std::optional< CodeModel::Model > & llvm::orc::JITTargetMachineBuilder::getCodeModel ( ) const
inline

Get the code model.

Definition at line 99 of file JITTargetMachineBuilder.h.

◆ getCPU()

const std::string & llvm::orc::JITTargetMachineBuilder::getCPU ( ) const
inline

Returns the CPU string.

Definition at line 81 of file JITTargetMachineBuilder.h.

◆ getDefaultDataLayoutForTarget()

Expected< DataLayout > llvm::orc::JITTargetMachineBuilder::getDefaultDataLayoutForTarget ( )
inline

Get the default DataLayout for the target.

Note: This is reasonably expensive, as it creates a temporary TargetMachine instance under the hood. It is only suitable for use during JIT setup.

Definition at line 67 of file JITTargetMachineBuilder.h.

References createTargetMachine().

◆ getFeatures() [1/2]

SubtargetFeatures & llvm::orc::JITTargetMachineBuilder::getFeatures ( )
inline

Access subtarget features.

Definition at line 118 of file JITTargetMachineBuilder.h.

Referenced by detectHost().

◆ getFeatures() [2/2]

const SubtargetFeatures & llvm::orc::JITTargetMachineBuilder::getFeatures ( ) const
inline

Access subtarget features.

Definition at line 121 of file JITTargetMachineBuilder.h.

◆ getOptions() [1/2]

TargetOptions & llvm::orc::JITTargetMachineBuilder::getOptions ( )
inline

Access TargetOptions.

Definition at line 135 of file JITTargetMachineBuilder.h.

References Options.

◆ getOptions() [2/2]

const TargetOptions & llvm::orc::JITTargetMachineBuilder::getOptions ( ) const
inline

Access TargetOptions.

Definition at line 138 of file JITTargetMachineBuilder.h.

References Options.

◆ getRelocationModel()

const std::optional< Reloc::Model > & llvm::orc::JITTargetMachineBuilder::getRelocationModel ( ) const
inline

Get the relocation model.

Definition at line 90 of file JITTargetMachineBuilder.h.

◆ getTargetTriple() [1/2]

Triple & llvm::orc::JITTargetMachineBuilder::getTargetTriple ( )
inline

Access Triple.

Definition at line 141 of file JITTargetMachineBuilder.h.

◆ getTargetTriple() [2/2]

const Triple & llvm::orc::JITTargetMachineBuilder::getTargetTriple ( ) const
inline

Access Triple.

Definition at line 144 of file JITTargetMachineBuilder.h.

◆ setCodeGenOptLevel()

JITTargetMachineBuilder & llvm::orc::JITTargetMachineBuilder::setCodeGenOptLevel ( CodeGenOptLevel  OptLevel)
inline

Set the LLVM CodeGen optimization level.

Definition at line 102 of file JITTargetMachineBuilder.h.

◆ setCodeModel()

JITTargetMachineBuilder & llvm::orc::JITTargetMachineBuilder::setCodeModel ( std::optional< CodeModel::Model CM)
inline

Set the code model.

Definition at line 93 of file JITTargetMachineBuilder.h.

◆ setCPU()

JITTargetMachineBuilder & llvm::orc::JITTargetMachineBuilder::setCPU ( std::string  CPU)
inline

Set the CPU string.

Definition at line 75 of file JITTargetMachineBuilder.h.

Referenced by detectHost().

◆ setFeatures()

JITTargetMachineBuilder & llvm::orc::JITTargetMachineBuilder::setFeatures ( StringRef  FeatureString)
inline

Set subtarget features.

Definition at line 108 of file JITTargetMachineBuilder.h.

◆ setOptions()

JITTargetMachineBuilder & llvm::orc::JITTargetMachineBuilder::setOptions ( TargetOptions  Options)
inline

Set TargetOptions.

Note: This operation will overwrite any previously configured options, including EmulatedTLS and UseInitArray which the JITTargetMachineBuilder sets by default. Clients are responsible for re-enabling these overwritten options.

Definition at line 129 of file JITTargetMachineBuilder.h.

References Options.

◆ setRelocationModel()

JITTargetMachineBuilder & llvm::orc::JITTargetMachineBuilder::setRelocationModel ( std::optional< Reloc::Model RM)
inline

Set the relocation model.

Definition at line 84 of file JITTargetMachineBuilder.h.

Friends And Related Function Documentation

◆ JITTargetMachineBuilderPrinter

friend class JITTargetMachineBuilderPrinter
friend

Definition at line 36 of file JITTargetMachineBuilder.h.


The documentation for this class was generated from the following files: