LLVM: include/llvm/Target/TargetMachine.h Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13#ifndef LLVM_TARGET_TARGETMACHINE_H
14#define LLVM_TARGET_TARGETMACHINE_H
15
27#include
28#include
29#include
30
31namespace llvm {
32
33class AAManager;
35
37class GlobalValue;
38class MachineModuleInfoWrapperPass;
39class Mangler;
40class MCAsmInfo;
41class MCContext;
42class MCInstrInfo;
43class MCRegisterInfo;
44class MCSubtargetInfo;
46class raw_pwrite_stream;
47class PassBuilder;
48class PassInstrumentationCallbacks;
49struct PerFunctionMIParsingState;
50class SMDiagnostic;
51class SMRange;
53class TargetIntrinsicInfo;
54class TargetIRAnalysis;
55class TargetTransformInfo;
56class TargetLoweringObjectFile;
57class TargetPassConfig;
58class TargetSubtargetInfo;
59
60
61namespace legacy {
62class PassManagerBase;
63}
64using legacy::PassManagerBase;
65
66struct MachineFunctionInfo;
67namespace yaml {
68struct MachineFunctionInfo;
69}
70
71
72
73
74
75
76
78protected:
82
83
85
86
87
88
89
90
91
93
94
95
99
104
105
110
113
114
116
117public:
119
123
125
130
131
132
134 return nullptr;
135 }
137 return nullptr;
138 }
139
140
144 return nullptr;
145 }
146
147
148
150 return nullptr;
151 }
152
153
154
157 return nullptr;
158 }
159
160
164 SMRange &SourceRange) const {
165 return false;
166 }
167
168
169
170
173 }
174
175
177
178
179
180
181
182
184 return DL == Candidate;
185 }
186
187
188
189
192 }
193
196 }
197
200 }
201
204 }
205
206
207
208
210
211
213
217
218
220 return nullptr;
221 }
222
225
226
227
229
230
231
233
234
236
237
239
242
244
246
247
249
250
252
253
255
256
258
259
261
268 }
271 }
274 }
277 }
278
280
283 }
284
286
287
290 }
291
294 }
295
296
297
300 }
301
302
303
306 }
307
308
309
312 }
313
314
315
317
318
319
322 }
323
324
327 }
328
329
331 return false;
332 }
333
336
337
338
339
340
341
342
344
345
346
347
348
349
350
351
352 virtual std::pair<const Value *, unsigned>
354 return std::make_pair(nullptr, -1);
355 }
356
357
358
359
360
361
363
364
365
366
367
369
370
371
373
374
375
377
378
379
380
381
382
383
384 virtual bool
387 bool = true,
389 return true;
390 }
391
392
393
394
395
396
399 bool = true) {
400 return true;
401 }
402
403
404
405
406
407
409
411 Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
413
414
417
419
420
421
423 return 0;
424 }
425
426
427
428
429
430
431
433 Module &M, unsigned NumParts,
434 function_ref<void(std::unique_ptr MPart)> ModuleCallback) {
435 return false;
436 }
437
438
439
441 return nullptr;
442 }
443
448 return make_error("buildCodeGenPipeline is not overridden",
450 }
451
452
453
454
455
457
458
459
463 return false;
464 }
465
469 return nullptr;
470 }
471
472
473
474
475
476
477
479
480
481
482 virtual bool useIPRA() const { return false; }
483
484
485
487
488
490};
491
492}
493
494#endif
This file defines the BumpPtrAllocator interface.
This header defines various interfaces for pass management in LLVM.
Define option tunables for PGO.
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::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.
unsigned getProgramAddressSpace() const
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
unsigned getAllocaAddrSpace() const
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
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.
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.
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.
TargetIntrinsicInfo - Interface to description of machine instruction set.
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.
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
bool isPositionIndependent() const
virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const
getAddressSpaceForPseudoSourceKind - Given the kind of memory (e.g.
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 Expected< std::unique_ptr< MCStreamer > > createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext &Ctx)
virtual void registerPassBuilderCallbacks(PassBuilder &)
Allow the target to modify the pass pipeline.
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
virtual bool usesPhysRegsForValues() const
True if the target uses physical regs (as nearly all targets do).
uint64_t getMaxCodeSize() const
Returns the maximum code size possible under the code model.
bool getAIXExtendedAltivecABI() const
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
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
bool useTLSDESC() const
Returns true if this target uses TLS Descriptors.
uint64_t LargeDataThreshold
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 useEmulatedTLS() const
Returns true if this target uses emulated TLS.
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.
StringRef getTargetFeatureString() const
virtual Error buildCodeGenPipeline(ModulePassManager &, raw_pwrite_stream &, raw_pwrite_stream *, CodeGenFileType, const CGPassBuilderOption &, PassInstrumentationCallbacks *)
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
static constexpr unsigned DefaultSjLjDataSize
The integer bit size to use for SjLj based exception handling.
virtual bool targetSchedulesPostRAScheduling() const
True if subtarget inserts the final scheduling pass on its own.
virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const
Return a TargetTransformInfo for a given function.
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...
bool requiresStructuredCFG() const
bool shouldAssumeDSOLocal(const GlobalValue *GV) const
void setRequiresStructuredCFG(bool Value)
virtual bool isMachineVerifierClean() const
Returns true if the target is expected to pass all machine verifier checks.
static std::pair< int, int > parseBinutilsVersion(StringRef Version)
std::unique_ptr< const MCSubtargetInfo > STI
void setGlobalISel(bool Enable)
TargetIRAnalysis getTargetIRAnalysis() const
Get a TargetIRAnalysis appropriate for the target.
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 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
MCSymbol * getSymbol(const GlobalValue *GV) const
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
bool isLargeGlobalValue(const GlobalValue *GV) 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 resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
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.
unsigned EnableAIXExtendedAltivecABI
EnableAIXExtendedAltivecABI - This flag returns true when -vec-extabi is specified.
unsigned EnableMachineOutliner
Enables the MachineOutliner pass.
unsigned SeparateNamedSections
Emit named sections with the same name into different sections.
unsigned SupportsDebugEntryValues
Set if the target supports the debug entry values by default.
BasicBlockSection BBSections
Emit basic blocks into separate sections.
GlobalISelAbortMode GlobalISelAbort
EnableGlobalISelAbort - Control abort behaviour when global instruction selection fails to lower/sele...
unsigned XCOFFTracebackTable
Emit XCOFF traceback table.
unsigned IgnoreXCOFFVisibility
Do not emit visibility attribute for xcoff.
unsigned EnableCFIFixup
Enable the CFIFixup pass.
unsigned SupportsDefaultOutlining
Set if the target supports default outlining behaviour.
unsigned UniqueBasicBlockSectionNames
Use unique names for basic block sections.
unsigned UniqueSectionNames
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
std::shared_ptr< MemoryBuffer > BBSectionsFuncListBuf
Memory Buffer that contains information on sampled basic blocks and used to selectively generate basi...
unsigned FunctionSections
Emit functions into separate sections.
unsigned EnableGlobalISel
EnableGlobalISel - This flag enables global instruction selection.
unsigned DataSections
Emit data into separate sections.
Target-Independent Code Generator Pass Configuration Options.
TargetSubtargetInfo - Generic base class for all target subtargets.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
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.
This is an optimization pass for GlobalISel generic memory operations.
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
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...
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.