Go to the documentation of this file.
13 #ifndef LLVM_TARGET_TARGETMACHINE_H
14 #define LLVM_TARGET_TARGETMACHINE_H
37 class MachineFunctionPassManager;
38 class MachineFunctionAnalysisManager;
39 class MachineModuleInfoWrapperPass;
46 class MCSubtargetInfo;
48 class raw_pwrite_stream;
50 struct PerFunctionMIParsingState;
54 class TargetIntrinsicInfo;
55 class TargetIRAnalysis;
56 class TargetTransformInfo;
57 class TargetLoweringObjectFile;
58 class TargetPassConfig;
59 class TargetSubtargetInfo;
63 class PassManagerBase;
65 using legacy::PassManagerBase;
67 struct MachineFunctionInfo;
69 struct MachineFunctionInfo;
107 std::unique_ptr<const MCRegisterInfo>
MRI;
108 std::unique_ptr<const MCInstrInfo>
MII;
109 std::unique_ptr<const MCSubtargetInfo>
STI;
185 return DL == Candidate;
340 virtual std::pair<const Value *, unsigned>
342 return std::make_pair(
nullptr, -1);
398 Mangler &Mang,
bool MayAlwaysUsePrivate =
false)
const;
444 bool DisableVerify =
true,
453 return make_error<StringError>(
"buildCodeGenPipeline is not overridden",
459 "getPassNameFromLegacyName parseMIRPipeline is not overridden");
468 bool DisableVerify =
true)
override;
525 #endif // LLVM_TARGET_TARGETMACHINE_H
bool requiresStructuredCFG() const
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
A manager for alias analyses.
virtual int unqualifiedInlineAsmVariant() const
The default variant to use in unqualified asm instructions.
Analysis pass providing the TargetTransformInfo.
unsigned getPointerSizeInBits(unsigned AS) const
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
std::unique_ptr< const MCSubtargetInfo > STI
A parsed version of the target data layout string in and methods for querying it.
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
bool getUniqueBasicBlockSectionNames() const
Return true if unique basic block section names must be generated.
virtual bool targetSchedulesPostRAScheduling() const
True if subtarget inserts the final scheduling pass on its own.
unsigned getProgramAddressSpace() const
Context object for machine code objects.
const DataLayout createDataLayout() const
Create a DataLayout.
virtual bool usesPhysRegsForValues() const
True if the target uses physical regs (as nearly all targets do).
unsigned EnableAIXExtendedAltivecABI
EnableAIXExtendedAltivecABI - This flag returns true when -vec-extabi is specified.
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
const Target & TheTarget
The Target that this machine was created for.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Target - Wrapper for Target specific information.
virtual Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &, MachineFunctionAnalysisManager &, raw_pwrite_stream &, raw_pwrite_stream *, CodeGenFileType, CGPassBuilderOption, PassInstrumentationCallbacks *)
bool getO0WantsFastISel()
const MCRegisterInfo * getMCRegisterInfo() const
virtual TargetPassConfig * createPassConfig(PassManagerBase &PM)
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
std::shared_ptr< MemoryBuffer > BBSectionsFuncListBuf
Memory Buffer that contains information on sampled basic blocks and used to selectively generate basi...
Triple - Helper class for working with autoconf configuration names.
BasicBlockSection BBSections
Emit basic blocks into separate sections.
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
void setSupportsDefaultOutlining(bool Enable)
std::unique_ptr< const MCInstrInfo > MII
virtual bool isMachineVerifierClean() const
Returns true if the target is expected to pass all machine verifier checks.
bool getUniqueSectionNames() const
void setCFIFixup(bool Enable)
Tagged union holding either a T or a Error.
virtual void registerPassBuilderCallbacks(PassBuilder &)
Allow the target to modify the pass pipeline.
This interface provides simple read-only access to a block of memory, and provides simple methods for...
bool getXCOFFTracebackTable() const
Return true if XCOFF traceback table should be emitted, corresponding to -xcoff-traceback-table.
TargetIntrinsicInfo - Interface to description of machine instruction set.
virtual yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
void operator=(const TargetMachine &)=delete
unsigned getProgramPointerSize() const
static constexpr unsigned DefaultSjLjDataSize
The integer bit size to use for SjLj based exception handling.
void setMachineOutliner(bool Enable)
unsigned UniqueSectionNames
bool getFunctionSections() const
Return true if functions should be emitted into their own section, corresponding to -ffunction-sectio...
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
const std::optional< PGOOptions > & getPGOOption() const
unsigned SupportsDefaultOutlining
Set if the target supports default outlining behaviour.
This class provides access to building LLVM's passes.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
static std::pair< int, int > parseBinutilsVersion(StringRef Version)
virtual unsigned getAssumedAddrSpace(const Value *V) const
If the specified generic pointer could be assumed as a pointer to a specific address space,...
void setPGOOption(std::optional< PGOOptions > PGOOpt)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
bool addPassesToEmitFile(PassManagerBase &PM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, bool DisableVerify=true, MachineModuleInfoWrapperPass *MMIWP=nullptr) override
Add passes to the specified pass manager to get the specified file emitted.
virtual bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
MCSymbol * getSymbol(const GlobalValue *GV) const
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
An AnalysisManager<MachineFunction> that also exposes IR analysis results.
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.
void setCodeModel(CodeModel::Model CM)
Set the code model.
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
const MCInstrInfo * getMCInstrInfo() const
bool isPositionIndependent() const
FileType
Defines the file type this file represents.
Target-Independent Code Generator Pass Configuration Options.
bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx, raw_pwrite_stream &Out, bool DisableVerify=true) override
Add passes to the specified pass manager to get machine code emitted with the MCJIT.
unsigned EnableGlobalISel
EnableGlobalISel - This flag enables global instruction selection.
bool getAIXExtendedAltivecABI() const
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
LLVMTargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
const DataLayout DL
DataLayout for the target: keep ABI type size and alignment.
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
void setO0WantsFastISel(bool Enable)
const TargetOptions DefaultOptions
bool isCompatibleDataLayout(const DataLayout &Candidate) const
Test if a DataLayout if compatible with the CodeGen for this target.
unsigned SupportsDebugEntryValues
Set if the target supports the debug entry values by default.
CodeModel::Model getEffectiveCodeModel(std::optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
void setRequiresStructuredCFG(bool Value)
An abstract base class for streams implementations that also support a pwrite operation.
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
const MCSubtargetInfo * getMCSubtargetInfo() const
Allocate memory in an ever growing pool, as if by bump-pointer.
CodeGenOpt::Level OptLevel
TargetIRAnalysis getTargetIRAnalysis() const
Get a TargetIRAnalysis appropriate for the target.
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
virtual void registerDefaultAliasAnalyses(AAManager &)
Allow the target to register alias analyses with the AAManager for use with the new pass manager.
TargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TargetTriple, StringRef CPU, StringRef FS, const TargetOptions &Options)
Primary interface to the complete machine description for the target machine.
virtual TargetLoweringObjectFile * getObjFileLowering() const
A Module instance is used to store all the information related to an LLVM module.
void setTargetFeatureString(StringRef FS)
GlobalISelAbortMode
Enable abort calls when global instruction selection fails to lower/select an instruction.
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
bool getIgnoreXCOFFVisibility() const
Return true if visibility attribute should not be emitted in XCOFF, corresponding to -mignore-xcoff-v...
unsigned IgnoreXCOFFVisibility
Do not emit visibility attribute for xcoff.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const
getAddressSpaceForPseudoSourceKind - Given the kind of memory (e.g.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
StringRef - Represent a constant reference to a string, i.e.
virtual std::pair< const Value *, unsigned > getPredicatedAddrSpace(const Value *V) const
If the specified predicate checks whether a generic pointer falls within a specified address space,...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &, raw_pwrite_stream *, CodeGenFileType, bool=true, MachineModuleInfoWrapperPass *MMIWP=nullptr)
Add passes to the specified pass manager to get the specified file emitted.
StringRef getTargetFeatureString() const
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
void setFastISel(bool Enable)
unsigned getAllocaAddrSpace() const
TargetSubtargetInfo - Generic base class for all target subtargets.
unsigned XCOFFTracebackTable
Emit XCOFF traceback table.
virtual yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
Interface to description of machine instruction set.
unsigned RequireStructuredCFG
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
void setGlobalISelAbort(GlobalISelAbortMode Mode)
unsigned UniqueBasicBlockSectionNames
Use unique names for basic block sections.
GlobalISelAbortMode GlobalISelAbort
EnableGlobalISelAbort - Control abort behaviour when global instruction selection fails to lower/sele...
Lightweight error class with error context and mandatory checking.
std::optional< PGOOptions > PGOOption
unsigned DataSections
Emit data into separate sections.
virtual MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const
Create the target's instance of MachineFunctionInfo.
This class describes a target machine that is implemented with the LLVM target-independent code gener...
void setGlobalISel(bool Enable)
unsigned EnableMachineOutliner
Enables the MachineOutliner pass.
MachineFunctionPassManager adds/removes below features to/from the base PassManager template instanti...
unsigned getAllocaPointerSize() const
const MemoryBuffer * getBBSectionsFuncListBuf() const
Get the list of functions and basic block ids that need unique sections.
StringRef getTargetCPU() const
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
Represents a range in source code.
virtual std::pair< StringRef, bool > getPassNameFromLegacyName(StringRef)
std::unique_ptr< const MCAsmInfo > AsmInfo
Contains target specific asm information.
const Triple & getTargetTriple() const
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
Level
Code generation optimization level.
CodeModel::Model getCodeModel() const
Returns the code model.
void setSupportsDebugEntryValues(bool Enable)
unsigned FunctionSections
Emit functions into separate sections.
void setOptLevel(CodeGenOpt::Level Level)
Overrides the optimization level.
const Target & getTarget() const
virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const
Return a TargetTransformInfo for a given function.
unsigned getPointerSize(unsigned AS) const
Get the pointer size for this target.
unsigned EnableCFIFixup
Enable the CFIFixup pass.
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
Generic base class for all target subtargets.
virtual bool useIPRA() const
True if the target wants to use interprocedural register allocation by default.
std::unique_ptr< const MCRegisterInfo > MRI
LLVM Value Representation.
Expected< std::unique_ptr< MCStreamer > > createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext &Ctx)
virtual unsigned getSjLjDataSize() const
llvm::BasicBlockSection getBBSectionsType() const
If basic blocks should be emitted into their own section, corresponding to -fbasic-block-sections.
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
bool addAsmPrinter(PassManagerBase &PM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext &Context)
Adds an AsmPrinter pass to the pipeline that prints assembly or machine code from the MI representati...
bool getDataSections() const
Return true if data objects should be emitted into their own section, corresponds to -fdata-sections.