13#ifndef LLVM_TARGET_TARGETMACHINE_H
14#define LLVM_TARGET_TARGETMACHINE_H
42class MachineModuleInfoWrapperPass;
43struct MachineSchedContext;
52class raw_pwrite_stream;
54class PassInstrumentationCallbacks;
55struct PerFunctionMIParsingState;
56class ScheduleDAGInstrs;
60class TargetIRAnalysis;
61class TargetTransformInfo;
62class TargetLoweringObjectFile;
63class TargetPassConfig;
64class TargetSubtargetInfo;
70using legacy::PassManagerBase;
72struct MachineFunctionInfo;
74struct MachineFunctionInfo;
113 std::unique_ptr<const MCRegisterInfo>
MRI;
114 std::unique_ptr<const MCInstrInfo>
MII;
115 std::unique_ptr<const MCSubtargetInfo>
STI;
200 return *
static_cast<const STC*
>(getSubtargetImpl(
F));
212 return DL == Candidate;
219 return DL.getPointerSize(AS);
223 return DL.getPointerSizeInBits(AS);
227 return DL.getPointerSize(
DL.getProgramAddressSpace());
231 return DL.getPointerSize(
DL.getAllocaAddrSpace());
237 void resetTargetOptions(
const Function &
F)
const;
250 return Options.ExceptionModel == ExceptionHandling::None
273 bool isLargeGlobalValue(
const GlobalValue *GV)
const;
275 bool isPositionIndependent()
const;
277 bool shouldAssumeDSOLocal(
const GlobalValue *GV)
const;
280 bool useEmulatedTLS()
const;
283 bool useTLSDESC()
const;
314 return Options.EnableAIXExtendedAltivecABI;
321 return Options.UniqueBasicBlockSectionNames;
325 return Options.SeparateNamedSections;
337 return Options.FunctionSections;
341 return Options.EnableStaticDataPartitioning;
347 return Options.IgnoreXCOFFVisibility;
362 return Options.BBSectionsFuncListBuf.get();
370 void setPGOOption(std::optional<PGOOptions> PGOOpt) { PGOOption = PGOOpt; }
371 const std::optional<PGOOptions> &
getPGOOption()
const {
return PGOOption; }
388 virtual std::pair<const Value *, unsigned>
390 return std::make_pair(
nullptr, -1);
452 Mangler &Mang,
bool MayAlwaysUsePrivate =
false)
const;
456 static constexpr unsigned DefaultSjLjDataSize = 32;
459 static std::pair<int, int> parseBinutilsVersion(
StringRef Version);
477 Module &M,
unsigned NumParts,
478 function_ref<
void(std::unique_ptr<Module> MPart)> ModuleCallback) {
492 return make_error<StringError>(
"buildCodeGenPipeline is not overridden",
524 virtual bool useIPRA()
const {
return false; }
unsigned const MachineRegisterInfo * MRI
static MCStreamer * createMCStreamer(const Triple &T, MCContext &Context, std::unique_ptr< MCAsmBackend > &&MAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the BumpPtrAllocator interface.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This header defines various interfaces for pass management in LLVM.
Define option tunables for PGO.
static cl::opt< RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode::Development, "development", "for training")))
A manager for alias analyses.
Allocate memory in an ever growing pool, as if by bump-pointer.
A parsed version of the target data layout string in and methods for querying it.
Lightweight error class with error context and mandatory checking.
Tagged union holding either a T or a Error.
This class is intended to be used as a base class for asm properties and features specific to the tar...
Context object for machine code objects.
Interface to description of machine instruction set.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
This interface provides simple read-only access to a block of memory, and provides simple methods for...
A Module instance is used to store all the information related to an LLVM module.
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...
Represents a range in source code.
A ScheduleDAG for scheduling lists of MachineInstr.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
Analysis pass providing the TargetTransformInfo.
Primary interface to the complete machine description for the target machine.
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
void setSupportsDebugEntryValues(bool Enable)
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
std::unique_ptr< const MCAsmInfo > AsmInfo
Contains target specific asm information.
ExceptionHandling getExceptionModel() const
Return the ExceptionHandling to use, considering TargetOptions and the Triple's default.
virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const
getAddressSpaceForPseudoSourceKind - Given the kind of memory (e.g.
virtual void registerEarlyDefaultAliasAnalyses(AAManager &)
Allow the target to register early alias analyses (AA before BasicAA) with the AAManager for use with...
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.
unsigned getAllocaPointerSize() const
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,...
virtual void registerPassBuilderCallbacks(PassBuilder &)
Allow the target to modify the pass pipeline.
virtual bool usesPhysRegsForValues() const
True if the target uses physical regs (as nearly all targets do).
bool getAIXExtendedAltivecABI() const
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
virtual ScheduleDAGInstrs * createPostMachineScheduler(MachineSchedContext *C) const
Similar to createMachineScheduler but used when postRA machine scheduling is enabled.
virtual MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const
Create the target's instance of MachineFunctionInfo.
const Triple & getTargetTriple() const
virtual bool splitModule(Module &M, unsigned NumParts, function_ref< void(std::unique_ptr< Module > MPart)> ModuleCallback)
Entry point for module splitting.
const DataLayout createDataLayout() const
Create a DataLayout.
void setMachineOutliner(bool Enable)
void setFastISel(bool Enable)
const std::optional< PGOOptions > & getPGOOption() const
const MCSubtargetInfo * getMCSubtargetInfo() const
virtual 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 getSeparateNamedSections() const
const MemoryBuffer * getBBSectionsFuncListBuf() const
Get the list of functions and basic block ids that need unique sections.
virtual unsigned getSjLjDataSize() const
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
unsigned getPointerSizeInBits(unsigned AS) const
bool getIgnoreXCOFFVisibility() const
Return true if visibility attribute should not be emitted in XCOFF, corresponding to -mignore-xcoff-v...
virtual int unqualifiedInlineAsmVariant() const
The default variant to use in unqualified asm instructions.
void setCFIFixup(bool Enable)
bool getUniqueBasicBlockSectionNames() const
Return true if unique basic block section names must be generated.
bool getUniqueSectionNames() const
unsigned getPointerSize(unsigned AS) const
Get the pointer size for this target.
std::unique_ptr< const MCInstrInfo > MII
void setSupportsDefaultOutlining(bool Enable)
TargetMachine(const TargetMachine &)=delete
void setGlobalISelAbort(GlobalISelAbortMode Mode)
virtual unsigned getAssumedAddrSpace(const Value *V) const
If the specified generic pointer could be assumed as a pointer to a specific address space,...
virtual TargetLoweringObjectFile * getObjFileLowering() const
std::optional< PGOOptions > PGOOption
virtual yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
bool getEnableStaticDataPartitioning() const
StringRef getTargetFeatureString() const
virtual Error buildCodeGenPipeline(ModulePassManager &, raw_pwrite_stream &, raw_pwrite_stream *, CodeGenFileType, const CGPassBuilderOption &, PassInstrumentationCallbacks *)
virtual bool targetSchedulesPostRAScheduling() const
True if subtarget inserts the final scheduling pass on its own.
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.
const DataLayout DL
DataLayout for the target: keep ABI type size and alignment.
StringRef getTargetCPU() const
const MCInstrInfo * getMCInstrInfo() const
void setOptLevel(CodeGenOptLevel Level)
Overrides the optimization level.
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
virtual ScheduleDAGInstrs * createMachineScheduler(MachineSchedContext *C) const
Create an instance of ScheduleDAGInstrs to be run within the standard MachineScheduler pass for this ...
bool requiresStructuredCFG() const
void setRequiresStructuredCFG(bool Value)
virtual bool isMachineVerifierClean() const
Returns true if the target is expected to pass all machine verifier checks.
std::unique_ptr< const MCSubtargetInfo > STI
void setGlobalISel(bool Enable)
virtual void registerDefaultAliasAnalyses(AAManager &)
Allow the target to register alias analyses with the AAManager for use with the new pass manager.
void setLargeDataThreshold(uint64_t LDT)
virtual void registerMachineRegisterInfoCallback(MachineFunction &MF) const
bool getO0WantsFastISel()
unsigned RequireStructuredCFG
void setO0WantsFastISel(bool Enable)
virtual yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
virtual size_t clearLinkerOptimizationHints(const SmallPtrSetImpl< MachineInstr * > &MIs) const
Remove all Linker Optimization Hints (LOH) associated with instructions in MIs and.
virtual TargetPassConfig * createPassConfig(PassManagerBase &PM)
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
bool isCompatibleDataLayout(const DataLayout &Candidate) const
Test if a DataLayout if compatible with the CodeGen for this target.
void operator=(const TargetMachine &)=delete
unsigned getProgramPointerSize() const
bool getXCOFFTracebackTable() const
Return true if XCOFF traceback table should be emitted, corresponding to -xcoff-traceback-table.
bool getDataSections() const
Return true if data objects should be emitted into their own section, corresponds to -fdata-sections.
const Target & getTarget() const
void setTargetFeatureString(StringRef FS)
const Target & TheTarget
The Target that this machine was created for.
CodeModel::Model getCodeModel() const
Returns the code model.
const MCRegisterInfo * getMCRegisterInfo() const
virtual bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
virtual bool useIPRA() const
True if the target wants to use interprocedural register allocation by default.
void setCodeModel(CodeModel::Model CM)
Set the code model.
void setPGOOption(std::optional< PGOOptions > PGOOpt)
std::unique_ptr< const MCRegisterInfo > MRI
bool getFunctionSections() const
Return true if functions should be emitted into their own section, corresponding to -ffunction-sectio...
llvm::BasicBlockSection getBBSectionsType() const
If basic blocks should be emitted into their own section, corresponding to -fbasic-block-sections.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
Target-Independent Code Generator Pass Configuration Options.
TargetSubtargetInfo - Generic base class for all target subtargets.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
LLVM_ABI ExceptionHandling getDefaultExceptionHandling() const
LLVM Value Representation.
An efficient, type-erasing, non-owning reference to a callable.
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
An abstract base class for streams implementations that also support a pwrite operation.
LLVM_ABI llvm::cl::opt< bool > NoKernelInfoEndLTO
This file defines the TargetMachine class.
This is an optimization pass for GlobalISel generic memory operations.
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
template class LLVM_TEMPLATE_ABI PassManager< Module >
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
CodeGenOptLevel
Code generation optimization level.
GlobalISelAbortMode
Enable abort calls when global instruction selection fails to lower/select an instruction.
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.