class TargetMachine

Declaration

class TargetMachine { /* full declaration omitted */ };

Description

Primary interface to the complete machine description for the target machine. All target-specific information should be accessible through this interface.

Declared at: llvm/include/llvm/Target/TargetMachine.h:77

Member Variables

protected const llvm::Target& TheTarget
The Target that this machine was created for.
protected const llvm::DataLayout DL
The DataLayout is created based on the string representation provided during construction. It is kept here only to avoid reparsing the string but should not really be used during compilation, because it has an internal cache that is context specific.
protected llvm::Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
protected std::string TargetCPU
protected std::string TargetFS
protected Reloc::Model RM = Reloc::Static
protected CodeModel::Model CMModel = CodeModel::Small
protected CodeGenOpt::Level OptLevel = CodeGenOpt::Default
protected std::unique_ptr<const MCAsmInfo> AsmInfo
Contains target specific asm information.
protected std::unique_ptr<const MCRegisterInfo> MRI
protected std::unique_ptr<const MCInstrInfo> MII
protected std::unique_ptr<const MCSubtargetInfo> STI
protected unsigned int RequireStructuredCFG
protected unsigned int O0WantsFastISel
protected Optional<llvm::PGOOptions> PGOOption = None
public const llvm::TargetOptions DefaultOptions
public llvm::TargetOptions Options
public static const unsigned int DefaultSjLjDataSize = 32
The integer bit size to use for SjLj based exception handling.

Method Overview

Methods

TargetMachine(const llvm::TargetMachine&)

Declared at: llvm/include/llvm/Target/TargetMachine.h:120

Parameters

const llvm::TargetMachine&

TargetMachine(const llvm::Target& T,
              llvm::StringRef DataLayoutString,
              const llvm::Triple& TargetTriple,
              llvm::StringRef CPU,
              llvm::StringRef FS,
              const llvm::TargetOptions& Options)

Declared at: llvm/include/llvm/Target/TargetMachine.h:79

Parameters

const llvm::Target& T
llvm::StringRef DataLayoutString
const llvm::Triple& TargetTriple
llvm::StringRef CPU
llvm::StringRef FS
const llvm::TargetOptions& Options

virtual bool addPassesToEmitFile(
    llvm::legacy::PassManagerBase&,
    llvm::raw_pwrite_stream&,
    llvm::raw_pwrite_stream*,
    llvm::CodeGenFileType,
    bool = true,
    llvm::MachineModuleInfoWrapperPass* MMIWP =
        nullptr)

Description

Add passes to the specified pass manager to get the specified file emitted. Typically this will involve several steps of code generation. This method should return true if emission of this file type is not supported, or false on success.\p MMIWP is an optional parameter that, if set to non-nullptr, will be used to set the MachineModuloInfo for this PM.

Declared at: llvm/include/llvm/Target/TargetMachine.h:369

Parameters

llvm::legacy::PassManagerBase&
llvm::raw_pwrite_stream&
llvm::raw_pwrite_stream*
llvm::CodeGenFileType
bool = true
llvm::MachineModuleInfoWrapperPass* MMIWP = nullptr

virtual bool addPassesToEmitMC(
    llvm::legacy::PassManagerBase&,
    llvm::MCContext*&,
    llvm::raw_pwrite_stream&,
    bool = true)

Description

Add passes to the specified pass manager to get machine code emitted with the MCJIT. This method returns true if machine code is not supported. It fills the MCContext Ctx pointer which can be used to build custom MCStreamer.

Declared at: llvm/include/llvm/Target/TargetMachine.h:381

Parameters

llvm::legacy::PassManagerBase&
llvm::MCContext*&
llvm::raw_pwrite_stream&
bool = true

virtual void adjustPassManager(
    llvm::PassManagerBuilder&)

Description

Allow the target to modify the pass manager, e.g. by calling PassManagerBuilder::addExtension.

Declared at: llvm/include/llvm/Target/TargetMachine.h:352

Parameters

llvm::PassManagerBuilder&

virtual yaml::MachineFunctionInfo*
convertFuncInfoToYAML(
    const llvm::MachineFunction& MF) const

Description

Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.

Declared at: llvm/include/llvm/Target/TargetMachine.h:149

Parameters

const llvm::MachineFunction& MF

const llvm::DataLayout createDataLayout() const

Description

Create a DataLayout.

Declared at: llvm/include/llvm/Target/TargetMachine.h:169

virtual yaml::MachineFunctionInfo*
createDefaultFuncInfoYAML() const

Description

Allocate and return a default initialized instance of the YAML representation for the MachineFunctionInfo.

Declared at: llvm/include/llvm/Target/TargetMachine.h:142

bool getAIXExtendedAltivecABI() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:265

virtual unsigned int
getAddressSpaceForPseudoSourceKind(
    unsigned int Kind) const

Description

getAddressSpaceForPseudoSourceKind - Given the kind of memory (e.g. stack) the target returns the corresponding address space.

Declared at: llvm/include/llvm/Target/TargetMachine.h:406

Parameters

unsigned int Kind

unsigned int getAllocaPointerSize() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:195

virtual unsigned int getAssumedAddrSpace(
    const llvm::Value* V) const

Description

If the specified generic pointer could be assumed as a pointer to a specific address space, return that address space. Under offloading programming, the offloading target may be passed with values only prepared on the host side and could assume certain properties.

Declared at: llvm/include/llvm/Target/TargetMachine.h:323

Parameters

const llvm::Value* V

const llvm::MemoryBuffer*
getBBSectionsFuncListBuf() const

Description

Get the list of functions and basic block ids that need unique sections.

Declared at: llvm/include/llvm/Target/TargetMachine.h:305

llvm::BasicBlockSection getBBSectionsType() const

Description

If basic blocks should be emitted into their own section, corresponding to -fbasic-block-sections.

Declared at: llvm/include/llvm/Target/TargetMachine.h:300

CodeModel::Model getCodeModel() const

Description

Returns the code model. The choices are small, kernel, medium, large, and target default.

Declared at: llvm/include/llvm/Target/TargetMachine.h:225

bool getDataSections() const

Description

Return true if data objects should be emitted into their own section, corresponds to -fdata-sections.

Declared at: llvm/include/llvm/Target/TargetMachine.h:278

bool getFunctionSections() const

Description

Return true if functions should be emitted into their own section, corresponding to -ffunction-sections.

Declared at: llvm/include/llvm/Target/TargetMachine.h:284

bool getIgnoreXCOFFVisibility() const

Description

Return true if visibility attribute should not be emitted in XCOFF, corresponding to -mignore-xcoff-visibility.

Declared at: llvm/include/llvm/Target/TargetMachine.h:290

virtual const llvm::TargetIntrinsicInfo*
getIntrinsicInfo() const

Description

If intrinsic information is available, return it. If not, return null.

Declared at: llvm/include/llvm/Target/TargetMachine.h:212

const llvm::MCAsmInfo* getMCAsmInfo() const

Description

Return target specific asm information.

Declared at: llvm/include/llvm/Target/TargetMachine.h:205

const llvm::MCInstrInfo* getMCInstrInfo() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:208

const llvm::MCRegisterInfo* getMCRegisterInfo()
    const

Declared at: llvm/include/llvm/Target/TargetMachine.h:207

const llvm::MCSubtargetInfo* getMCSubtargetInfo()
    const

Declared at: llvm/include/llvm/Target/TargetMachine.h:209

void getNameWithPrefix(
    SmallVectorImpl<char>& Name,
    const llvm::GlobalValue* GV,
    llvm::Mangler& Mang,
    bool MayAlwaysUsePrivate = false) const

Declared at: llvm/include/llvm/Target/TargetMachine.h:394

Parameters

SmallVectorImpl<char>& Name
const llvm::GlobalValue* GV
llvm::Mangler& Mang
bool MayAlwaysUsePrivate = false

bool getO0WantsFastISel()

Declared at: llvm/include/llvm/Target/TargetMachine.h:247

virtual llvm::TargetLoweringObjectFile*
getObjFileLowering() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:136

CodeGenOpt::Level getOptLevel() const

Description

Returns the optimization level: None, Less, Default, or Aggressive.

Declared at: llvm/include/llvm/Target/TargetMachine.h:241

const Optional<llvm::PGOOptions>& getPGOOption()
    const

Declared at: llvm/include/llvm/Target/TargetMachine.h:315

unsigned int getPointerSize(unsigned int AS) const

Description

Get the pointer size for this target. This is the only time the DataLayout in the TargetMachine is used.

Declared at: llvm/include/llvm/Target/TargetMachine.h:183

Parameters

unsigned int AS

unsigned int getPointerSizeInBits(
    unsigned int AS) const

Declared at: llvm/include/llvm/Target/TargetMachine.h:187

Parameters

unsigned int AS

virtual std::pair<const Value*, unsigned int>
getPredicatedAddrSpace(const llvm::Value* V) const

Description

If the specified predicate checks whether a generic pointer falls within a specified address space, return that generic pointer and the address space being queried. Such predicates could be specified in @llvm.assume intrinsics for the optimizer to assume that the given generic pointer always falls within the address space based on that predicate.

Declared at: llvm/include/llvm/Target/TargetMachine.h:333

Parameters

const llvm::Value* V

unsigned int getProgramPointerSize() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:191

Reloc::Model getRelocationModel() const

Description

Returns the code generation relocation model. The choices are static, PIC, and dynamic-no-pic, and target default.

Declared at: llvm/include/llvm/Target/TargetMachine.h:221

virtual unsigned int getSjLjDataSize() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:400

template <typename STC>
const STC& getSubtarget(
    const llvm::Function& F) const

Description

This method returns a pointer to the specified type of TargetSubtargetInfo. In debug builds, it verifies that the object being returned is of the correct type.

Declared at: llvm/include/llvm/Target/TargetMachine.h:164

Templates

STC

Parameters

const llvm::Function& F

virtual const llvm::TargetSubtargetInfo*
getSubtargetImpl(const llvm::Function&) const

Description

Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInfo-derived member variable.

Declared at: llvm/include/llvm/Target/TargetMachine.h:133

Parameters

const llvm::Function&

llvm::MCSymbol* getSymbol(
    const llvm::GlobalValue* GV) const

Declared at: llvm/include/llvm/Target/TargetMachine.h:396

Parameters

const llvm::GlobalValue* GV

TLSModel::Model getTLSModel(
    const llvm::GlobalValue* GV) const

Description

Returns the TLS model which should be used for the given global variable.

Declared at: llvm/include/llvm/Target/TargetMachine.h:238

Parameters

const llvm::GlobalValue* GV

const llvm::Target& getTarget() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:124

llvm::StringRef getTargetCPU() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:127

llvm::StringRef getTargetFeatureString() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:128

llvm::TargetIRAnalysis getTargetIRAnalysis() const

Description

Get a \c TargetIRAnalysis appropriate for the target. This is used to construct the new pass manager's target IR analysis pass, set up appropriately for this target machine. Even the old pass manager uses this to answer queries about the IR.

Declared at: llvm/include/llvm/Target/TargetMachine.h:342

virtual llvm::TargetTransformInfo
getTargetTransformInfo(
    const llvm::Function& F) const

Description

Return a TargetTransformInfo for a given function. The returned TargetTransformInfo is specialized to the subtarget corresponding to \p F.

Declared at: llvm/include/llvm/Target/TargetMachine.h:348

Parameters

const llvm::Function& F

const llvm::Triple& getTargetTriple() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:126

bool getUniqueBasicBlockSectionNames() const

Description

Return true if unique basic block section names must be generated.

Declared at: llvm/include/llvm/Target/TargetMachine.h:272

bool getUniqueSectionNames() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:269

bool getXCOFFTracebackTable() const

Description

Return true if XCOFF traceback table should be emitted, corresponding to -xcoff-traceback-table.

Declared at: llvm/include/llvm/Target/TargetMachine.h:296

bool isCompatibleDataLayout(
    const llvm::DataLayout& Candidate) const

Description

Test if a DataLayout if compatible with the CodeGen for this target. The LLVM Module owns a DataLayout that is used for the target independent optimizations and code generation. This hook provides a target specific check on the validity of this DataLayout.

Declared at: llvm/include/llvm/Target/TargetMachine.h:176

Parameters

const llvm::DataLayout& Candidate

virtual bool isNoopAddrSpaceCast(
    unsigned int SrcAS,
    unsigned int DestAS) const

Description

Returns true if a cast between SrcAS and DestAS is a noop.

Declared at: llvm/include/llvm/Target/TargetMachine.h:310

Parameters

unsigned int SrcAS
unsigned int DestAS

bool isPositionIndependent() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:230

static std::pair<int, int> parseBinutilsVersion(
    llvm::StringRef Version)

Declared at: llvm/include/llvm/Target/TargetMachine.h:402

Parameters

llvm::StringRef Version

virtual bool parseMachineFunctionInfo(
    const yaml::MachineFunctionInfo&,
    llvm::PerFunctionMIParsingState& PFS,
    llvm::SMDiagnostic& Error,
    llvm::SMRange& SourceRange) const

Description

Parse out the target's MachineFunctionInfo from the YAML reprsentation.

Declared at: llvm/include/llvm/Target/TargetMachine.h:154

Parameters

const yaml::MachineFunctionInfo&
llvm::PerFunctionMIParsingState& PFS
llvm::SMDiagnostic& Error
llvm::SMRange& SourceRange

virtual void registerDefaultAliasAnalyses(
    llvm::AAManager&)

Description

Allow the target to register alias analyses with the AAManager for use with the new pass manager. Only affects the "default" AAManager.

Declared at: llvm/include/llvm/Target/TargetMachine.h:360

Parameters

llvm::AAManager&

virtual void registerPassBuilderCallbacks(
    llvm::PassBuilder&)

Description

Allow the target to modify the pass pipeline with New Pass Manager (similar to adjustPassManager for Legacy Pass manager).

Declared at: llvm/include/llvm/Target/TargetMachine.h:356

Parameters

llvm::PassBuilder&

bool requiresStructuredCFG() const

Declared at: llvm/include/llvm/Target/TargetMachine.h:216

void resetTargetOptions(
    const llvm::Function& F) const

Description

Reset the target options based on the function's attributes.

Declared at: llvm/include/llvm/Target/TargetMachine.h:202

Parameters

const llvm::Function& F

void setCFIFixup(bool Enable)

Declared at: llvm/include/llvm/Target/TargetMachine.h:263

Parameters

bool Enable

void setCodeModel(CodeModel::Model CM)

Description

Set the code model.

Declared at: llvm/include/llvm/Target/TargetMachine.h:228

Parameters

CodeModel::Model CM

void setFastISel(bool Enable)

Declared at: llvm/include/llvm/Target/TargetMachine.h:246

Parameters

bool Enable

void setGlobalISel(bool Enable)

Declared at: llvm/include/llvm/Target/TargetMachine.h:249

Parameters

bool Enable

void setGlobalISelAbort(
    llvm::GlobalISelAbortMode Mode)

Declared at: llvm/include/llvm/Target/TargetMachine.h:250

Parameters

llvm::GlobalISelAbortMode Mode

void setMachineOutliner(bool Enable)

Declared at: llvm/include/llvm/Target/TargetMachine.h:253

Parameters

bool Enable

void setO0WantsFastISel(bool Enable)

Declared at: llvm/include/llvm/Target/TargetMachine.h:248

Parameters

bool Enable

void setOptLevel(CodeGenOpt::Level Level)

Description

Overrides the optimization level.

Declared at: llvm/include/llvm/Target/TargetMachine.h:244

Parameters

CodeGenOpt::Level Level

void setPGOOption(
    Optional<llvm::PGOOptions> PGOOpt)

Declared at: llvm/include/llvm/Target/TargetMachine.h:314

Parameters

Optional<llvm::PGOOptions> PGOOpt

void setRequiresStructuredCFG(bool Value)

Declared at: llvm/include/llvm/Target/TargetMachine.h:217

Parameters

bool Value

void setSupportsDebugEntryValues(bool Enable)

Declared at: llvm/include/llvm/Target/TargetMachine.h:259

Parameters

bool Enable

void setSupportsDefaultOutlining(bool Enable)

Declared at: llvm/include/llvm/Target/TargetMachine.h:256

Parameters

bool Enable

void setTargetFeatureString(llvm::StringRef FS)

Declared at: llvm/include/llvm/Target/TargetMachine.h:129

Parameters

llvm::StringRef FS

bool shouldAssumeDSOLocal(
    const llvm::Module& M,
    const llvm::GlobalValue* GV) const

Declared at: llvm/include/llvm/Target/TargetMachine.h:232

Parameters

const llvm::Module& M
const llvm::GlobalValue* GV

virtual bool targetSchedulesPostRAScheduling()
    const

Description

True if subtarget inserts the final scheduling pass on its own. Branch relaxation, which must happen after block placement, can on some targets (e.g. SystemZ) expose additional post-RA scheduling opportunities.

Declared at: llvm/include/llvm/Target/TargetMachine.h:392

bool useEmulatedTLS() const

Description

Returns true if this target uses emulated TLS.

Declared at: llvm/include/llvm/Target/TargetMachine.h:235

virtual ~TargetMachine()

Declared at: llvm/include/llvm/Target/TargetMachine.h:122