LLVM 23.0.0git
TargetMachine.h
Go to the documentation of this file.
1//===-- llvm/Target/TargetMachine.h - Target Information --------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// This file defines the TargetMachine class.
10///
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TARGET_TARGETMACHINE_H
14#define LLVM_TARGET_TARGETMACHINE_H
15
16#include "llvm/ADT/StringRef.h"
17#include "llvm/IR/DataLayout.h"
18#include "llvm/IR/PassManager.h"
23#include "llvm/Support/Error.h"
28#include <optional>
29#include <string>
30#include <utility>
31
32namespace llvm {
33
35
36class AAManager;
38
39class Function;
40class GlobalValue;
41class MachineInstr;
44class Mangler;
45class MCAsmInfo;
46class MCContext;
47class MCInstrInfo;
48class MCRegisterInfo;
49class MCStreamer;
50class MCSubtargetInfo;
51class MCSymbol;
53class PassBuilder;
57class SMDiagnostic;
58class SMRange;
59class Target;
65
66// The old pass manager infrastructure is hidden in a legacy namespace now.
67namespace legacy {
68class PassManagerBase;
69} // namespace legacy
71
73namespace yaml {
75} // namespace yaml
76
77//===----------------------------------------------------------------------===//
78///
79/// Primary interface to the complete machine description for the target
80/// machine. All target-specific information should be accessible through this
81/// interface.
82///
84protected: // Can only create subclasses.
85 TargetMachine(const Target &T, StringRef DataLayoutString,
86 const Triple &TargetTriple, StringRef CPU, StringRef FS,
87 const TargetOptions &Options);
88
89 /// The Target that this machine was created for.
91
92 /// DataLayout for the target: keep ABI type size and alignment.
93 ///
94 /// The DataLayout is created based on the string representation provided
95 /// during construction. It is kept here only to avoid reparsing the string
96 /// but should not really be used during compilation, because it has an
97 /// internal cache that is context specific.
99
100 /// Triple string, CPU name, and target feature strings the TargetMachine
101 /// instance is created with.
103 std::string TargetCPU;
104 std::string TargetFS;
105
110
111 /// Contains target specific asm information.
112 std::unique_ptr<const MCAsmInfo> AsmInfo;
113 std::unique_ptr<const MCRegisterInfo> MRI;
114 std::unique_ptr<const MCInstrInfo> MII;
115 std::unique_ptr<const MCSubtargetInfo> STI;
116
118 unsigned O0WantsFastISel : 1;
119
120 // PGO related tunables.
121 std::optional<PGOOptions> PGOOption;
122
123public:
125
126 TargetMachine(const TargetMachine &) = delete;
127 void operator=(const TargetMachine &) = delete;
128 virtual ~TargetMachine();
129
130 const Target &getTarget() const { return TheTarget; }
131
132 const Triple &getTargetTriple() const { return TargetTriple; }
133 StringRef getTargetCPU() const { return TargetCPU; }
135 void setTargetFeatureString(StringRef FS) { TargetFS = std::string(FS); }
136
137 /// Virtual method implemented by subclasses that returns a reference to that
138 /// target's TargetSubtargetInfo-derived member variable.
139 virtual const TargetSubtargetInfo *getSubtargetImpl(const Function &) const {
140 return nullptr;
141 }
143 return nullptr;
144 }
145
146 /// Create the target's instance of MachineFunctionInfo
147 virtual MachineFunctionInfo *
149 const TargetSubtargetInfo *STI) const {
150 return nullptr;
151 }
152
153 /// Create an instance of ScheduleDAGInstrs to be run within the standard
154 /// MachineScheduler pass for this function and target at the current
155 /// optimization level.
156 ///
157 /// This can also be used to plug a new MachineSchedStrategy into an instance
158 /// of the standard ScheduleDAGMI:
159 /// return new ScheduleDAGMI(C, std::make_unique<MyStrategy>(C),
160 /// /*RemoveKillFlags=*/false)
161 ///
162 /// Return NULL to select the default (generic) machine scheduler.
163 virtual ScheduleDAGInstrs *
165 return nullptr;
166 }
167
168 /// Similar to createMachineScheduler but used when postRA machine scheduling
169 /// is enabled.
170 virtual ScheduleDAGInstrs *
172 return nullptr;
173 }
174
175 /// Allocate and return a default initialized instance of the YAML
176 /// representation for the MachineFunctionInfo.
178 return nullptr;
179 }
180
181 /// Allocate and initialize an instance of the YAML representation of the
182 /// MachineFunctionInfo.
185 return nullptr;
186 }
187
188 /// Parse out the target's MachineFunctionInfo from the YAML reprsentation.
192 SMRange &SourceRange) const {
193 return false;
194 }
195
196 /// This method returns a pointer to the specified type of
197 /// TargetSubtargetInfo. In debug builds, it verifies that the object being
198 /// returned is of the correct type.
199 template <typename STC> const STC &getSubtarget(const Function &F) const {
200 return *static_cast<const STC*>(getSubtargetImpl(F));
201 }
202
203 /// Create a DataLayout.
204 const DataLayout createDataLayout() const { return DL; }
205
206 /// Test if a DataLayout if compatible with the CodeGen for this target.
207 ///
208 /// The LLVM Module owns a DataLayout that is used for the target independent
209 /// optimizations and code generation. This hook provides a target specific
210 /// check on the validity of this DataLayout.
211 bool isCompatibleDataLayout(const DataLayout &Candidate) const {
212 return DL == Candidate;
213 }
214
215 /// Get the pointer size for this target.
216 ///
217 /// This is the only time the DataLayout in the TargetMachine is used.
218 unsigned getPointerSize(unsigned AS) const {
219 return DL.getPointerSize(AS);
220 }
221
222 unsigned getPointerSizeInBits(unsigned AS) const {
223 return DL.getPointerSizeInBits(AS);
224 }
225
226 unsigned getProgramPointerSize() const {
227 return DL.getPointerSize(DL.getProgramAddressSpace());
228 }
229
230 unsigned getAllocaPointerSize() const {
231 return DL.getPointerSize(DL.getAllocaAddrSpace());
232 }
233
234 /// Return target specific asm information.
235 const MCAsmInfo &getMCAsmInfo() const { return *AsmInfo; }
236
237 const MCRegisterInfo &getMCRegisterInfo() const { return *MRI; }
238 const MCInstrInfo *getMCInstrInfo() const { return MII.get(); }
239 const MCSubtargetInfo &getMCSubtargetInfo() const { return *STI; }
240
241 /// Return the ExceptionHandling to use, considering TargetOptions and the
242 /// Triple's default.
244 // FIXME: This interface fails to distinguish default from not supported.
245 return Options.ExceptionModel == ExceptionHandling::None
246 ? TargetTriple.getDefaultExceptionHandling()
247 : Options.ExceptionModel;
248 }
249
252
253 /// Returns the code generation relocation model. The choices are static, PIC,
254 /// and dynamic-no-pic, and target default.
255 Reloc::Model getRelocationModel() const;
256
257 /// Returns the code model. The choices are small, kernel, medium, large, and
258 /// target default.
260
261 /// Returns the maximum code size possible under the code model.
262 uint64_t getMaxCodeSize() const;
263
264 /// Set the code model.
266
268 bool isLargeGlobalValue(const GlobalValue *GV) const;
269
270 bool isPositionIndependent() const;
271
272 bool shouldAssumeDSOLocal(const GlobalValue *GV) const;
273
274 /// Returns true if this target uses emulated TLS.
275 bool useEmulatedTLS() const;
276
277 /// Returns true if this target uses TLS Descriptors.
278 bool useTLSDESC() const;
279
280 /// Returns the TLS model which should be used for the given global variable.
281 TLSModel::Model getTLSModel(const GlobalValue *GV) const;
282
283 /// Returns the optimization level: None, Less, Default, or Aggressive.
285
286 /// Overrides the optimization level.
287 void setOptLevel(CodeGenOptLevel Level) { OptLevel = Level; }
288
289 void setFastISel(bool Enable) { Options.EnableFastISel = Enable; }
292 void setGlobalISel(bool Enable) { Options.EnableGlobalISel = Enable; }
294 Options.GlobalISelAbort = Mode;
295 }
297 Options.EnableMachineOutliner = Enable;
298 }
300 Options.SupportsDefaultOutlining = Enable;
301 }
303 Options.SupportsDebugEntryValues = Enable;
304 }
305
306 void setCFIFixup(bool Enable) { Options.EnableCFIFixup = Enable; }
307
309 return Options.EnableAIXExtendedAltivecABI;
310 }
311
312 bool getUniqueSectionNames() const { return Options.UniqueSectionNames; }
313
314 /// Return true if unique basic block section names must be generated.
316 return Options.UniqueBasicBlockSectionNames;
317 }
318
320 return Options.SeparateNamedSections;
321 }
322
323 /// Return true if data objects should be emitted into their own section,
324 /// corresponds to -fdata-sections.
325 bool getDataSections() const {
326 return Options.DataSections;
327 }
328
329 /// Return true if functions should be emitted into their own section,
330 /// corresponding to -ffunction-sections.
331 bool getFunctionSections() const {
332 return Options.FunctionSections;
333 }
334
336 return Options.EnableStaticDataPartitioning;
337 }
338
339 /// Return true if visibility attribute should not be emitted in XCOFF,
340 /// corresponding to -mignore-xcoff-visibility.
342 return Options.IgnoreXCOFFVisibility;
343 }
344
345 /// Return true if XCOFF traceback table should be emitted,
346 /// corresponding to -xcoff-traceback-table.
347 bool getXCOFFTracebackTable() const { return Options.XCOFFTracebackTable; }
348
349 /// If basic blocks should be emitted into their own section,
350 /// corresponding to -fbasic-block-sections.
352 return Options.BBSections;
353 }
354
355 /// Get the list of functions and basic block ids that need unique sections.
357 return Options.BBSectionsFuncListBuf.get();
358 }
359
360 /// Returns true if a cast between SrcAS and DestAS is a noop.
361 virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const {
362 return false;
363 }
364
365 void setPGOOption(std::optional<PGOOptions> PGOOpt) { PGOOption = PGOOpt; }
366 const std::optional<PGOOptions> &getPGOOption() const { return PGOOption; }
367
368 /// If the specified generic pointer could be assumed as a pointer to a
369 /// specific address space, return that address space.
370 ///
371 /// Under offloading programming, the offloading target may be passed with
372 /// values only prepared on the host side and could assume certain
373 /// properties.
374 virtual unsigned getAssumedAddrSpace(const Value *V) const { return -1; }
375
376 /// If the specified predicate checks whether a generic pointer falls within
377 /// a specified address space, return that generic pointer and the address
378 /// space being queried.
379 ///
380 /// Such predicates could be specified in @llvm.assume intrinsics for the
381 /// optimizer to assume that the given generic pointer always falls within
382 /// the address space based on that predicate.
383 virtual std::pair<const Value *, unsigned>
385 return std::make_pair(nullptr, -1);
386 }
387
388 /// Get a \c TargetIRAnalysis appropriate for the target.
389 ///
390 /// This is used to construct the new pass manager's target IR analysis pass,
391 /// set up appropriately for this target machine. Even the old pass manager
392 /// uses this to answer queries about the IR.
393 TargetIRAnalysis getTargetIRAnalysis() const;
394
395 /// Return a TargetTransformInfo for a given function.
396 ///
397 /// The returned TargetTransformInfo is specialized to the subtarget
398 /// corresponding to \p F.
399 virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const;
400
401 /// Allow the target to modify the pass pipeline.
402 // TODO: Populate all pass names by using <Target>PassRegistry.def.
404
405 /// Allow the target to register early alias analyses (AA before BasicAA) with
406 /// the AAManager for use with the new pass manager. Only affects the
407 /// "default" AAManager.
409
410 /// Allow the target to register alias analyses with the AAManager for use
411 /// with the new pass manager. Only affects the "default" AAManager.
413
414 /// Add passes to the specified pass manager to get the specified file
415 /// emitted. Typically this will involve several steps of code generation.
416 /// This method should return true if emission of this file type is not
417 /// supported, or false on success.
418 /// \p MMIWP is an optional parameter that, if set to non-nullptr,
419 /// will be used to set the MachineModuloInfo for this PM.
420 virtual bool
423 bool /*DisableVerify*/ = true,
424 MachineModuleInfoWrapperPass *MMIWP = nullptr) {
425 return true;
426 }
427
428 /// Add passes to the specified pass manager to get machine code emitted with
429 /// the MCJIT. This method returns true if machine code is not supported. It
430 /// fills the MCContext Ctx pointer which can be used to build custom
431 /// MCStreamer.
432 ///
435 bool /*DisableVerify*/ = true) {
436 return true;
437 }
438
439 /// True if subtarget inserts the final scheduling pass on its own.
440 ///
441 /// Branch relaxation, which must happen after block placement, can
442 /// on some targets (e.g. SystemZ) expose additional post-RA
443 /// scheduling opportunities.
444 virtual bool targetSchedulesPostRAScheduling() const { return false; };
445
446 void getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV,
447 Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
448 MCSymbol *getSymbol(const GlobalValue *GV) const;
449
450 /// The integer bit size to use for SjLj based exception handling.
451 static constexpr unsigned DefaultSjLjDataSize = 32;
452 virtual unsigned getSjLjDataSize() const { return DefaultSjLjDataSize; }
453
454 static std::pair<int, int> parseBinutilsVersion(StringRef Version);
455
456 /// getAddressSpaceForPseudoSourceKind - Given the kind of memory
457 /// (e.g. stack) the target returns the corresponding address space.
458 virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const {
459 return 0;
460 }
461
462 /// Entry point for module splitting. Targets can implement custom module
463 /// splitting logic, mainly used by LTO for --lto-partitions.
464 ///
465 /// On success, this guarantees that between 1 and \p NumParts modules were
466 /// created and passed to \p ModuleCallBack.
467 ///
468 /// \returns `true` if the module was split, `false` otherwise. When `false`
469 /// is returned, it is assumed that \p ModuleCallback has never been called
470 /// and \p M has not been modified.
471 virtual bool splitModule(
472 Module &M, unsigned NumParts,
473 function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback) {
474 return false;
475 }
476
477 /// Create a pass configuration object to be used by addPassToEmitX methods
478 /// for generating a pipeline of CodeGen passes.
480 return nullptr;
481 }
482
483 virtual Error
486 CodeGenFileType FileType, const CGPassBuilderOption &Opt,
488 return make_error<StringError>("buildCodeGenPipeline is not overridden",
490 }
491
492 /// Returns true if the target is expected to pass all machine verifier
493 /// checks. This is a stopgap measure to fix targets one by one. We will
494 /// remove this at some point and always enable the verifier when
495 /// EXPENSIVE_CHECKS is enabled.
496 virtual bool isMachineVerifierClean() const { return true; }
497
498 /// Adds an AsmPrinter pass to the pipeline that prints assembly or
499 /// machine code from the MI representation.
501 raw_pwrite_stream *DwoOut,
502 CodeGenFileType FileType, MCContext &Context) {
503 return false;
504 }
505
508 CodeGenFileType FileType, MCContext &Ctx);
509
510 /// True if the target uses physical regs (as nearly all targets do). False
511 /// for stack machines such as WebAssembly and other virtual-register
512 /// machines. If true, all vregs must be allocated before PEI. If false, then
513 /// callee-save register spilling and scavenging are not needed or used. If
514 /// false, implicitly defined registers will still be assumed to be physical
515 /// registers, except that variadic defs will be allocated vregs.
516 virtual bool usesPhysRegsForValues() const { return true; }
517
518 /// True if the target wants to use interprocedural register allocation by
519 /// default. The -enable-ipra flag can be used to override this.
520 virtual bool useIPRA() const { return false; }
521
522 /// The default variant to use in unqualified `asm` instructions.
523 /// If this returns 0, `asm "$(foo$|bar$)"` will evaluate to `asm "foo"`.
524 virtual int unqualifiedInlineAsmVariant() const { return 0; }
525
526 // MachineRegisterInfo callback function
528
529 /// Remove all Linker Optimization Hints (LOH) associated with instructions in
530 /// \p MIs and \return the number of hints removed. This is useful in
531 /// transformations that cause these hints to be illegal, like in the machine
532 /// outliner.
534 const SmallPtrSetImpl<MachineInstr *> &MIs) const {
535 return 0;
536 }
537
538 /// Returns whether the backend can lower the llvm.cond.loop intrinsic. If
539 /// this function returns false, the intrinsic will be supported generically
540 /// but without loop detection support.
541 virtual bool canLowerCondLoop() const { return false; }
542};
543
544} // end namespace llvm
545
546#endif // LLVM_TARGET_TARGETMACHINE_H
static MCStreamer * createMCStreamer(const Triple &T, MCContext &Context, std::unique_ptr< MCAsmBackend > &&MAB, std::unique_ptr< MCObjectWriter > &&OW, std::unique_ptr< MCCodeEmitter > &&Emitter)
This file defines the BumpPtrAllocator interface.
#define LLVM_ABI
Definition Compiler.h:213
This header defines various interfaces for pass management in LLVM.
#define F(x, y, z)
Definition MD5.cpp:54
#define T
Define option tunables for PGO.
ModuleAnalysisManager MAM
PassInstrumentationCallbacks PIC
Basic Register Allocator
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.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition MCAsmInfo.h:66
Context object for machine code objects.
Definition MCContext.h:83
Interface to description of machine instruction set.
Definition MCInstrInfo.h:27
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Streaming machine code generation interface.
Definition MCStreamer.h:222
Generic base class for all target subtargets.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
Representation of each machine instruction.
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.
Definition Module.h:67
This class provides access to building LLVM's passes.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Manages a sequence of passes over a particular unit of IR.
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition SourceMgr.h:303
Represents a range in source code.
Definition SMLoc.h:47
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...
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Analysis pass providing the TargetTransformInfo.
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).
virtual Error buildCodeGenPipeline(ModulePassManager &MPM, ModuleAnalysisManager &MAM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, const CGPassBuilderOption &Opt, MCContext &Ctx, PassInstrumentationCallbacks *PIC)
bool getAIXExtendedAltivecABI() const
CodeModel::Model CMModel
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
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
const MCSubtargetInfo & getMCSubtargetInfo() 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
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.
const MCAsmInfo & getMCAsmInfo() const
Return target specific asm information.
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)
TargetOptions Options
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
unsigned RequireStructuredCFG
void setO0WantsFastISel(bool Enable)
virtual bool canLowerCondLoop() const
Returns whether the backend can lower the llvm.cond.loop intrinsic.
virtual yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
virtual ~TargetMachine()
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.
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.
TargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TargetTriple, StringRef CPU, StringRef FS, const TargetOptions &Options)
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...
CodeGenOptLevel OptLevel
llvm::BasicBlockSection getBBSectionsType() const
If basic blocks should be emitted into their own section, corresponding to -fbasic-block-sections.
const MCRegisterInfo & getMCRegisterInfo() const
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.
Definition Triple.h:47
LLVM Value Representation.
Definition Value.h:75
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.
@ C
The default llvm calling convention, compatible with C.
Definition CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
ExceptionHandling
Definition CodeGen.h:53
@ None
No exception support.
Definition CodeGen.h:54
FunctionAddr VTableAddr uintptr_t uintptr_t Version
Definition InstrProf.h:334
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition CodeGen.h:111
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:82
@ Default
-O2, -Os, -Oz
Definition CodeGen.h:85
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
BasicBlockSection
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:383
LLVM_ABI llvm::cl::opt< bool > NoKernelInfoEndLTO
GlobalISelAbortMode
Enable abort calls when global instruction selection fails to lower/select an instruction.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
@ Enable
Enable colors.
Definition WithColor.h:47
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...
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.