LLVM  3.7.0
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
llvm::TargetMachine Class Reference

Primary interface to the complete machine description for the target machine. More...

#include <TargetMachine.h>

Inheritance diagram for llvm::TargetMachine:
[legend]
Collaboration diagram for llvm::TargetMachine:
[legend]

Public Types

enum  CodeGenFileType { CGFT_AssemblyFile, CGFT_ObjectFile, CGFT_Null }
 These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit, and returned by it to indicate what type of file could actually be made. More...
 

Public Member Functions

virtual ~TargetMachine ()
 
const TargetgetTarget () const
 
const TriplegetTargetTriple () const
 
StringRef getTargetCPU () const
 
StringRef getTargetFeatureString () const
 
virtual const TargetSubtargetInfogetSubtargetImpl (const Function &) const
 Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInfo-derived member variable. More...
 
virtual TargetLoweringObjectFilegetObjFileLowering () const
 
template<typename STC >
const STC & getSubtarget (const Function &F) const
 This method returns a pointer to the specified type of TargetSubtargetInfo. More...
 
const DataLayoutgetDataLayout () const
 Deprecated in 3.7, will be removed in 3.8. More...
 
const DataLayout createDataLayout () const
 Create a DataLayout. More...
 
void resetTargetOptions (const Function &F) const
 Reset the target options based on the function's attributes. More...
 
const MCAsmInfogetMCAsmInfo () const
 Return target specific asm information. More...
 
const MCRegisterInfogetMCRegisterInfo () const
 
const MCInstrInfogetMCInstrInfo () const
 
const MCSubtargetInfogetMCSubtargetInfo () const
 
virtual const TargetIntrinsicInfogetIntrinsicInfo () const
 If intrinsic information is available, return it. If not, return null. More...
 
bool requiresStructuredCFG () const
 
void setRequiresStructuredCFG (bool Value)
 
Reloc::Model getRelocationModel () const
 Returns the code generation relocation model. More...
 
CodeModel::Model getCodeModel () const
 Returns the code model. More...
 
TLSModel::Model getTLSModel (const GlobalValue *GV) const
 Returns the TLS model which should be used for the given global variable. More...
 
CodeGenOpt::Level getOptLevel () const
 Returns the optimization level: None, Less, Default, or Aggressive. More...
 
void setOptLevel (CodeGenOpt::Level Level) const
 Overrides the optimization level. More...
 
void setFastISel (bool Enable)
 
bool shouldPrintMachineCode () const
 
bool getAsmVerbosityDefault () const
 Returns the default value of asm verbosity. More...
 
bool getUniqueSectionNames () const
 
bool getDataSections () const
 Return true if data objects should be emitted into their own section, corresponds to -fdata-sections. More...
 
bool getFunctionSections () const
 Return true if functions should be emitted into their own section, corresponding to -ffunction-sections. More...
 
virtual TargetIRAnalysis getTargetIRAnalysis ()
 Get a TargetIRAnalysis appropriate for the target. More...
 
virtual bool addPassesToEmitFile (PassManagerBase &, raw_pwrite_stream &, CodeGenFileType, bool=true, AnalysisID=nullptr, AnalysisID=nullptr, AnalysisID=nullptr, MachineFunctionInitializer *=nullptr)
 Add passes to the specified pass manager to get the specified file emitted. More...
 
virtual bool addPassesToEmitMC (PassManagerBase &, MCContext *&, raw_pwrite_stream &, bool=true)
 Add passes to the specified pass manager to get machine code emitted with the MCJIT. More...
 
void getNameWithPrefix (SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
 
MCSymbolgetSymbol (const GlobalValue *GV, Mangler &Mang) const
 

Public Attributes

TargetOptions Options
 

Protected Member Functions

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

Protected Attributes

const TargetTheTarget
 The Target that this machine was created for. More...
 
const DataLayout DL
 For ABI type size and alignment. More...
 
Triple TargetTriple
 Triple string, CPU name, and target feature strings the TargetMachine instance is created with. More...
 
std::string TargetCPU
 
std::string TargetFS
 
MCCodeGenInfoCodeGenInfo
 Low level target information such as relocation model. More...
 
const MCAsmInfoAsmInfo
 Contains target specific asm information. More...
 
const MCRegisterInfoMRI
 
const MCInstrInfoMII
 
const MCSubtargetInfoSTI
 
unsigned RequireStructuredCFG: 1
 

Detailed Description

Primary interface to the complete machine description for the target machine.

All target-specific information should be accessible through this interface.

Definition at line 68 of file Target/TargetMachine.h.

Member Enumeration Documentation

These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit, and returned by it to indicate what type of file could actually be made.

Enumerator
CGFT_AssemblyFile 
CGFT_ObjectFile 
CGFT_Null 

Definition at line 208 of file Target/TargetMachine.h.

Constructor & Destructor Documentation

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

Definition at line 40 of file TargetMachine.cpp.

References llvm::DL.

TargetMachine::~TargetMachine ( )
virtual

Definition at line 48 of file TargetMachine.cpp.

References AsmInfo, CodeGenInfo, MII, MRI, and STI.

Member Function Documentation

virtual bool llvm::TargetMachine::addPassesToEmitFile ( PassManagerBase &  ,
raw_pwrite_stream ,
CodeGenFileType  ,
bool  = true,
AnalysisID  = nullptr,
AnalysisID  = nullptr,
AnalysisID  = nullptr,
MachineFunctionInitializer = nullptr 
)
inlinevirtual

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.

Reimplemented in llvm::LLVMTargetMachine, and llvm::CPPTargetMachine.

Definition at line 218 of file Target/TargetMachine.h.

Referenced by LLVMTargetMachineEmit().

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

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.

Reimplemented in llvm::LLVMTargetMachine, and llvm::NVPTXTargetMachine.

Definition at line 231 of file Target/TargetMachine.h.

Referenced by llvm::orc::SimpleCompiler::operator()().

const DataLayout llvm::TargetMachine::createDataLayout ( ) const
inline

Create a DataLayout.

Definition at line 135 of file Target/TargetMachine.h.

References DL.

bool llvm::TargetMachine::getAsmVerbosityDefault ( ) const
inline

Returns the default value of asm verbosity.

Definition at line 180 of file Target/TargetMachine.h.

References llvm::MCTargetOptions::AsmVerbose, and llvm::TargetOptions::MCOptions.

CodeModel::Model TargetMachine::getCodeModel ( ) const
const DataLayout* llvm::TargetMachine::getDataLayout ( ) const
inline

Deprecated in 3.7, will be removed in 3.8.

Use createDataLayout() instead.

This method returns a pointer to the DataLayout for the target. It should be unchanging for every subtarget.

Definition at line 132 of file Target/TargetMachine.h.

References DL.

Referenced by llvm::ScheduleDAGInstrs::buildSchedGraph(), llvm::AsmPrinter::doFinalization(), llvm::AsmPrinter::EmitAlignment(), llvm::AArch64FrameLowering::emitCalleeSavedFrameMoves(), llvm::AsmPrinter::EmitConstantPool(), llvm::AsmPrinter::EmitGlobalConstant(), emitGlobalConstantArray(), emitGlobalConstantDataSequential(), emitGlobalConstantFP(), emitGlobalConstantImpl(), emitGlobalConstantLargeInt(), emitGlobalConstantStruct(), emitGlobalConstantVector(), llvm::AsmPrinter::EmitGlobalVariable(), llvm::ARMAsmPrinter::EmitInstruction(), llvm::AsmPrinter::EmitJumpTableInfo(), llvm::SystemZAsmPrinter::EmitMachineConstantPoolValue(), llvm::ARMAsmPrinter::EmitMachineConstantPoolValue(), llvm::TargetLoweringBase::emitPatchPoint(), llvm::TargetLoweringObjectFileELF::emitPersonalityValue(), llvm::AArch64FrameLowering::emitPrologue(), llvm::ARMAsmPrinter::EmitXXStructor(), llvm::MSP430MCInstLower::GetConstantPoolIndexSymbol(), llvm::X86AsmPrinter::GetCPISymbol(), llvm::AsmPrinter::GetCPISymbol(), llvm::AsmPrinter::getDataLayout(), llvm::AsmPrinter::GetExternalSymbolSymbol(), llvm::AsmPrinter::GetJTSetSymbol(), llvm::MSP430MCInstLower::GetJumpTableSymbol(), llvm::TargetLoweringObjectFile::getKindForGlobal(), llvm::PPCFunctionInfo::getPICOffsetSymbol(), llvm::AsmPrinter::GetSizeOfEncodedValue(), llvm::TargetInstrInfo::getStackSlotRange(), GetSymbolFromOperand(), llvm::TargetLoweringObjectFile::Initialize(), llvm::MipsTargetObjectFile::IsConstantInSmallSection(), llvm::HexagonTargetObjectFile::IsGlobalInSmallSection(), llvm::MipsTargetObjectFile::IsGlobalInSmallSectionImpl(), isRepeatedByteSequence(), LLVMTargetMachineEmit(), llvm::AsmPrinter::lowerConstant(), llvm::LTOCodeGenerator::optimize(), llvm::MipsAsmPrinter::printOperand(), llvm::AsmPrinter::PrintSpecial(), selectELFSectionForGlobal(), llvm::XCoreTargetObjectFile::SelectSectionForGlobal(), llvm::TargetLoweringObjectFileMachO::SelectSectionForGlobal(), llvm::SparcTargetLowering::SparcTargetLowering(), llvm::SystemZTargetLowering::SystemZTargetLowering(), and llvm::X86TargetLowering::X86TargetLowering().

bool llvm::TargetMachine::getDataSections ( ) const
inline

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

Definition at line 188 of file Target/TargetMachine.h.

References llvm::TargetOptions::DataSections.

Referenced by llvm::TargetLoweringObjectFileCOFF::getNameWithPrefix(), llvm::TargetLoweringObjectFileELF::SelectSectionForGlobal(), and llvm::TargetLoweringObjectFileCOFF::SelectSectionForGlobal().

bool llvm::TargetMachine::getFunctionSections ( ) const
inline
virtual const TargetIntrinsicInfo* llvm::TargetMachine::getIntrinsicInfo ( ) const
inlinevirtual

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

Reimplemented in llvm::AMDGPUTargetMachine.

Definition at line 150 of file Target/TargetMachine.h.

Referenced by llvm::SDNode::getOperationName().

const MCAsmInfo* llvm::TargetMachine::getMCAsmInfo ( ) const
inline
const MCInstrInfo* llvm::TargetMachine::getMCInstrInfo ( ) const
inline
const MCRegisterInfo* llvm::TargetMachine::getMCRegisterInfo ( ) const
inline
const MCSubtargetInfo* llvm::TargetMachine::getMCSubtargetInfo ( ) const
inline
void TargetMachine::getNameWithPrefix ( SmallVectorImpl< char > &  Name,
const GlobalValue GV,
Mangler Mang,
bool  MayAlwaysUsePrivate = false 
) const
virtual TargetLoweringObjectFile* llvm::TargetMachine::getObjFileLowering ( ) const
inlinevirtual
CodeGenOpt::Level TargetMachine::getOptLevel ( ) const

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

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

Definition at line 141 of file TargetMachine.cpp.

References CodeGenInfo, llvm::CodeGenOpt::Default, and llvm::MCCodeGenInfo::getOptLevel().

Referenced by addPassesToGenerateCode(), llvm::TargetPassConfig::getOptLevel(), llvm::PPCTargetMachine::getSubtargetImpl(), llvm::SITargetLowering::PerformDAGCombine(), and llvm::X86TargetLowering::X86TargetLowering().

Reloc::Model TargetMachine::getRelocationModel ( ) const
template<typename STC >
const STC& llvm::TargetMachine::getSubtarget ( const Function F) const
inline

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.

Definition at line 124 of file Target/TargetMachine.h.

References getSubtargetImpl().

virtual const TargetSubtargetInfo* llvm::TargetMachine::getSubtargetImpl ( const Function ) const
inlinevirtual
MCSymbol * TargetMachine::getSymbol ( const GlobalValue GV,
Mangler Mang 
) const
const Target& llvm::TargetMachine::getTarget ( ) const
inline
StringRef llvm::TargetMachine::getTargetCPU ( ) const
inline
StringRef llvm::TargetMachine::getTargetFeatureString ( ) const
inline
TargetIRAnalysis TargetMachine::getTargetIRAnalysis ( )
virtual

Get a 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.

Reimplemented in llvm::LLVMTargetMachine, llvm::NVPTXTargetMachine, llvm::AMDGPUTargetMachine, llvm::ARMBaseTargetMachine, llvm::PPCTargetMachine, llvm::MipsTargetMachine, llvm::WebAssemblyTargetMachine, llvm::AArch64TargetMachine, llvm::SystemZTargetMachine, llvm::XCoreTargetMachine, and llvm::X86TargetMachine.

Definition at line 152 of file TargetMachine.cpp.

References F(), llvm::Module::getDataLayout(), and llvm::GlobalValue::getParent().

Referenced by llvm::LTOCodeGenerator::optimize().

const Triple& llvm::TargetMachine::getTargetTriple ( ) const
inline
TLSModel::Model TargetMachine::getTLSModel ( const GlobalValue GV) const
bool llvm::TargetMachine::getUniqueSectionNames ( ) const
inline
bool llvm::TargetMachine::requiresStructuredCFG ( ) const
inline
void TargetMachine::resetTargetOptions ( const Function F) const
void llvm::TargetMachine::setFastISel ( bool  Enable)
inline
void TargetMachine::setOptLevel ( CodeGenOpt::Level  Level) const

Overrides the optimization level.

Definition at line 147 of file TargetMachine.cpp.

References CodeGenInfo, and llvm::MCCodeGenInfo::setOptLevel().

Referenced by llvm::OptLevelChanger::OptLevelChanger(), and llvm::OptLevelChanger::~OptLevelChanger().

void llvm::TargetMachine::setRequiresStructuredCFG ( bool  Value)
inline
bool llvm::TargetMachine::shouldPrintMachineCode ( ) const
inline

Member Data Documentation

const MCAsmInfo* llvm::TargetMachine::AsmInfo
protected

Contains target specific asm information.

Definition at line 93 of file Target/TargetMachine.h.

Referenced by getMCAsmInfo(), getNameWithPrefix(), llvm::LLVMTargetMachine::initAsmInfo(), and ~TargetMachine().

MCCodeGenInfo* llvm::TargetMachine::CodeGenInfo
protected

Low level target information such as relocation model.

Non-const to allow resetting optimization level per-function.

Definition at line 90 of file Target/TargetMachine.h.

Referenced by getCodeModel(), getOptLevel(), getRelocationModel(), llvm::LLVMTargetMachine::LLVMTargetMachine(), setOptLevel(), and ~TargetMachine().

const DataLayout llvm::TargetMachine::DL
protected

For ABI type size and alignment.

Definition at line 80 of file Target/TargetMachine.h.

Referenced by createDataLayout(), and getDataLayout().

const MCInstrInfo* llvm::TargetMachine::MII
protected
const MCRegisterInfo* llvm::TargetMachine::MRI
protected
TargetOptions llvm::TargetMachine::Options
mutable

Definition at line 102 of file Target/TargetMachine.h.

Referenced by llvm::TargetPassConfig::addMachinePasses(), llvm::LLVMTargetMachine::addPassesToEmitFile(), llvm::LLVMTargetMachine::addPassesToEmitMC(), llvm::NVPTXTargetLowering::allowFMA(), llvm::ARMTargetLowering::ARMTargetLowering(), canCombineSinCosLibcall(), llvm::AArch64RegisterInfo::cannotEliminateFrame(), llvm::ARMBaseRegisterInfo::cannotEliminateFrame(), llvm::MipsTargetLowering::createFastISel(), llvm::PPCFrameLowering::determineCalleeSaves(), llvm::AsmPrinter::doInitialization(), llvm::DwarfDebug::DwarfDebug(), llvm::PPCFrameLowering::eliminateCallFramePseudoInstr(), llvm::PPCFrameLowering::emitEpilogue(), llvm::TargetLoweringObjectFile::getKindForGlobal(), llvm::X86InstrInfo::getMachineCombinerPatterns(), GetNegatedExpression(), llvm::SelectionDAG::getNode(), llvm::X86TargetMachine::getSubtargetImpl(), getTLSModel(), llvm::MipsFrameLowering::hasFP(), llvm::SparcFrameLowering::hasFP(), llvm::SystemZFrameLowering::hasFP(), llvm::MSP430FrameLowering::hasFP(), llvm::XCoreFrameLowering::hasFP(), llvm::ARMFrameLowering::hasFP(), llvm::X86FrameLowering::hasFP(), llvm::LLVMTargetMachine::initAsmInfo(), llvm::MipsTargetObjectFile::Initialize(), llvm::HexagonTargetObjectFile::Initialize(), llvm::isInTailCallPosition(), llvm::AArch64TargetLowering::isProfitableToHoist(), llvm::PPCFrameLowering::needsFP(), llvm::OptLevelChanger::OptLevelChanger(), PerformFMinFMaxCombine(), PerformSELECT_CCCombine(), performSelectCCCombine(), PerformSELECTCombine(), llvm::PPCTargetLowering::PPCTargetLowering(), llvm::PPCFrameLowering::processFunctionBeforeFrameFinalized(), llvm::SelectionDAGISel::runOnMachineFunction(), llvm::FastISel::selectOperator(), llvm::DwarfCompileUnit::updateSubprogramScopeDIE(), llvm::ARMSubtarget::useFastISel(), and llvm::X86TargetLowering::X86TargetLowering().

unsigned llvm::TargetMachine::RequireStructuredCFG
protected

Definition at line 99 of file Target/TargetMachine.h.

Referenced by requiresStructuredCFG(), and setRequiresStructuredCFG().

const MCSubtargetInfo* llvm::TargetMachine::STI
protected
std::string llvm::TargetMachine::TargetCPU
protected
std::string llvm::TargetMachine::TargetFS
protected
Triple llvm::TargetMachine::TargetTriple
protected
const Target& llvm::TargetMachine::TheTarget
protected

The Target that this machine was created for.

Definition at line 77 of file Target/TargetMachine.h.

Referenced by getTarget(), and llvm::LLVMTargetMachine::initAsmInfo().


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