LLVM 24.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/StringMap.h"
17#include "llvm/ADT/StringRef.h"
18#include "llvm/IR/DataLayout.h"
19#include "llvm/IR/PassManager.h"
24#include "llvm/Support/Error.h"
29#include <optional>
30#include <string>
31#include <utility>
32
33namespace llvm {
34
36
37class AAManager;
39
40class Function;
41class GlobalValue;
42class MachineInstr;
45class Mangler;
46class MCAsmInfo;
47class MCContext;
48class MCInstrInfo;
49class MCRegisterInfo;
50class MCStreamer;
51class MCSubtargetInfo;
52class MCSymbol;
54class PassBuilder;
58class SMDiagnostic;
59class SMRange;
60class Target;
66
67// The old pass manager infrastructure is hidden in a legacy namespace now.
68namespace legacy {
69class PassManagerBase;
70} // namespace legacy
72
74namespace yaml {
76} // namespace yaml
77
78//===----------------------------------------------------------------------===//
79///
80/// Primary interface to the complete machine description for the target
81/// machine. All target-specific information should be accessible through this
82/// interface.
83///
85protected: // Can only create subclasses.
86 TargetMachine(const Target &T, StringRef DataLayoutString,
87 const Triple &TargetTriple, StringRef CPU, StringRef FS,
88 const TargetOptions &Options);
89
90 /// The Target that this machine was created for.
92
93 /// DataLayout for the target: keep ABI type size and alignment.
94 ///
95 /// The DataLayout is created based on the string representation provided
96 /// during construction. It is kept here only to avoid reparsing the string
97 /// but should not really be used during compilation, because it has an
98 /// internal cache that is context specific.
100
101 /// Triple string, CPU name, and target feature strings the TargetMachine
102 /// instance is created with.
104 std::string TargetCPU;
105 std::string TargetFS;
106
111
112 /// Contains target specific asm information.
113 std::unique_ptr<const MCAsmInfo> AsmInfo;
114 std::unique_ptr<const MCRegisterInfo> MRI;
115 std::unique_ptr<const MCInstrInfo> MII;
116 std::unique_ptr<const MCSubtargetInfo> STI;
117
118 /// MC subtarget keyed by target features and target CPU.
120
121 /// Bit N is set if the target can lower exceptions using model N.
123
125 unsigned O0WantsFastISel : 1;
127
128 /// Set if the target supports default outlining behaviour.
130
131 /// Set if the target supports the debug entry values by default.
133
134 // PGO related tunables.
135 std::optional<PGOOptions> PGOOption;
136
137public:
139
140 TargetMachine(const TargetMachine &) = delete;
141 void operator=(const TargetMachine &) = delete;
142 virtual ~TargetMachine();
143
144 const Target &getTarget() const { return TheTarget; }
145
146 const Triple &getTargetTriple() const { return TargetTriple; }
147 StringRef getTargetCPU() const { return TargetCPU; }
149 void setTargetFeatureString(StringRef FS) { TargetFS = std::string(FS); }
150
151 /// Returns the effective target ABI name: the "target-abi" module flag if
152 /// present, otherwise the -target-abi option. This is a pure query; call
153 /// verifyOptionsConsistency once per module to diagnose a conflict.
154 StringRef getTargetABIName(const Module &M) const;
155
156 /// Diagnoses command-line codegen options that conflict with the
157 /// corresponding module flags (e.g. -target-abi vs the "target-abi" module
158 /// flag). Intended to be called once per module.
159 void verifyOptionsConsistency(const Module &M) const;
160
161 /// Virtual method implemented by subclasses that returns a reference to that
162 /// target's TargetSubtargetInfo-derived member variable.
163 virtual const TargetSubtargetInfo *getSubtargetImpl(const Function &) const {
164 return nullptr;
165 }
167 return nullptr;
168 }
169
170 /// Create the target's instance of MachineFunctionInfo
171 virtual MachineFunctionInfo *
173 const TargetSubtargetInfo *STI) const {
174 return nullptr;
175 }
176
177 /// Create an instance of ScheduleDAGInstrs to be run within the standard
178 /// MachineScheduler pass for this function and target at the current
179 /// optimization level.
180 ///
181 /// This can also be used to plug a new MachineSchedStrategy into an instance
182 /// of the standard ScheduleDAGMI:
183 /// return new ScheduleDAGMI(C, std::make_unique<MyStrategy>(C),
184 /// /*RemoveKillFlags=*/false)
185 ///
186 /// Return NULL to select the default (generic) machine scheduler.
187 virtual ScheduleDAGInstrs *
189 return nullptr;
190 }
191
192 /// Similar to createMachineScheduler but used when postRA machine scheduling
193 /// is enabled.
194 virtual ScheduleDAGInstrs *
196 return nullptr;
197 }
198
199 /// Allocate and return a default initialized instance of the YAML
200 /// representation for the MachineFunctionInfo.
202 return nullptr;
203 }
204
205 /// Allocate and initialize an instance of the YAML representation of the
206 /// MachineFunctionInfo.
209 return nullptr;
210 }
211
212 /// Parse out the target's MachineFunctionInfo from the YAML reprsentation.
216 SMRange &SourceRange) const {
217 return false;
218 }
219
220 /// This method returns a pointer to the specified type of
221 /// TargetSubtargetInfo. In debug builds, it verifies that the object being
222 /// returned is of the correct type.
223 template <typename STC> const STC &getSubtarget(const Function &F) const {
224 return *static_cast<const STC*>(getSubtargetImpl(F));
225 }
226
227 /// Create a DataLayout.
228 const DataLayout createDataLayout() const { return DL; }
229
230 /// Test if a DataLayout if compatible with the CodeGen for this target.
231 ///
232 /// The LLVM Module owns a DataLayout that is used for the target independent
233 /// optimizations and code generation. This hook provides a target specific
234 /// check on the validity of this DataLayout.
235 bool isCompatibleDataLayout(const DataLayout &Candidate) const {
236 return DL == Candidate;
237 }
238
239 /// Get the pointer size for this target.
240 ///
241 /// This is the only time the DataLayout in the TargetMachine is used.
242 unsigned getPointerSize(unsigned AS) const {
243 return DL.getPointerSize(AS);
244 }
245
246 unsigned getPointerSizeInBits(unsigned AS) const {
247 return DL.getPointerSizeInBits(AS);
248 }
249
250 unsigned getProgramPointerSize() const {
251 return DL.getPointerSize(DL.getProgramAddressSpace());
252 }
253
254 unsigned getAllocaPointerSize() const {
255 return DL.getPointerSize(DL.getAllocaAddrSpace());
256 }
257
258 /// Return target specific asm information.
259 const MCAsmInfo &getMCAsmInfo() const { return *AsmInfo; }
260
261 const MCRegisterInfo &getMCRegisterInfo() const { return *MRI; }
262 const MCInstrInfo *getMCInstrInfo() const { return MII.get(); }
263 const MCSubtargetInfo &getMCSubtargetInfo() const { return *STI; }
264
265 /// Get the MCSubtargetInfo for the given target CPU and target features.
266 /// For use in contexts where a feature-specific MC subtarget is needed,
267 /// but no MachineFunctionis available, such as for module-level inline
268 /// assembly.
269 const MCSubtargetInfo &getMCSubtargetInfo(StringRef CPU, StringRef FS);
270
273
274 /// Return true if this target can lower exceptions using \p Model. Used to
275 /// guard scheduling of the exception-handling preparation passes.
277 assert(Model != ExceptionHandling::None && "none is trivially supported");
278 return SupportedExceptionModels & (1u << static_cast<unsigned>(Model));
279 }
280
281 /// Override whether this target can lower exceptions using \p Model. The
282 /// default is derived from the object format and architecture.
284 unsigned Bit = 1u << static_cast<unsigned>(Model);
287 }
288
293
294 /// NOTE: There are targets that still do not support the debug entry values
295 /// production.
296 bool shouldEmitDebugEntryValues() const;
297
298 /// Whether the fast register allocator lowers tied operands itself instead
299 /// of running TwoAddressInstructionPass. AMDGPU anchors passes on
300 /// TwoAddressInstructionPassID and cannot enable it.
303
304 /// Returns the code generation relocation model. The choices are static, PIC,
305 /// and dynamic-no-pic, and target default.
306 Reloc::Model getRelocationModel() const;
307
308 /// Returns the code model. The choices are small, kernel, medium, large, and
309 /// target default.
311
312 /// Returns the maximum code size possible under the code model.
313 uint64_t getMaxCodeSize() const;
314
315 /// Set the code model.
317
319 bool isLargeGlobalValue(const GlobalValue *GV) const;
320 bool isLargeDataSize(uint64_t Size) const;
321
322 bool isPositionIndependent() const;
323
324 bool shouldAssumeDSOLocal(const GlobalValue *GV) const;
325
326 /// Returns true if this target uses emulated TLS.
327 bool useEmulatedTLS() const;
328
329 /// Returns true if this target uses TLS Descriptors.
330 bool useTLSDESC() const;
331
332 /// Returns the TLS model which should be used for the given global variable.
333 TLSModel::Model getTLSModel(const GlobalValue *GV) const;
334
335 /// Returns the optimization level: None, Less, Default, or Aggressive.
337
338 /// Overrides the optimization level.
339 void setOptLevel(CodeGenOptLevel Level) { OptLevel = Level; }
340
341 void setFastISel(bool Enable) { Options.EnableFastISel = Enable; }
344 void setGlobalISel(bool Enable) { Options.EnableGlobalISel = Enable; }
346 Options.GlobalISelAbort = Mode;
347 }
349 Options.EnableMachineOutliner = Enable;
350 }
355 Options.EnableDefaultMachineVerifier = Enable;
356 }
357
358 void setCFIFixup(bool Enable) { Options.EnableCFIFixup = Enable; }
359
360 bool getUniqueSectionNames() const { return Options.UniqueSectionNames; }
361
362 /// Return true if unique basic block section names must be generated.
364 return Options.UniqueBasicBlockSectionNames;
365 }
366
368 return Options.SeparateNamedSections;
369 }
370
371 /// Return true if data objects should be emitted into their own section,
372 /// corresponds to -fdata-sections.
373 bool getDataSections() const {
374 return Options.DataSections;
375 }
376
377 /// Return true if functions should be emitted into their own section,
378 /// corresponding to -ffunction-sections.
379 bool getFunctionSections() const {
380 return Options.FunctionSections;
381 }
382
384 return Options.EnableStaticDataPartitioning;
385 }
386
387 /// Return true if visibility attribute should not be emitted in XCOFF,
388 /// corresponding to -mignore-xcoff-visibility.
390 return Options.IgnoreXCOFFVisibility;
391 }
392
393 /// Return true if XCOFF traceback table should be emitted,
394 /// corresponding to -xcoff-traceback-table.
395 bool getXCOFFTracebackTable() const { return Options.XCOFFTracebackTable; }
396
397 /// If basic blocks should be emitted into their own section,
398 /// corresponding to -fbasic-block-sections.
400 return Options.BBSections;
401 }
402
403 /// Get the list of functions and basic block ids that need unique sections.
405 return Options.BBSectionsFuncListBuf.get();
406 }
407
408 /// Returns true if a cast between SrcAS and DestAS is a noop.
409 virtual bool isNoopAddrSpaceCast(const DataLayout &DL, unsigned SrcAS,
410 unsigned DestAS) const {
411 return false;
412 }
413
414 void setPGOOption(std::optional<PGOOptions> PGOOpt) { PGOOption = PGOOpt; }
415 const std::optional<PGOOptions> &getPGOOption() const { return PGOOption; }
416
417 /// If the specified generic pointer could be assumed as a pointer to a
418 /// specific address space, return that address space.
419 ///
420 /// Under offloading programming, the offloading target may be passed with
421 /// values only prepared on the host side and could assume certain
422 /// properties.
423 virtual unsigned getAssumedAddrSpace(const Value *V) const { return -1; }
424
425 /// If the specified predicate checks whether a generic pointer falls within
426 /// a specified address space, return that generic pointer and the address
427 /// space being queried.
428 ///
429 /// Such predicates could be specified in @llvm.assume intrinsics for the
430 /// optimizer to assume that the given generic pointer always falls within
431 /// the address space based on that predicate.
432 virtual std::pair<const Value *, unsigned>
434 return std::make_pair(nullptr, -1);
435 }
436
437 /// Get a \c TargetIRAnalysis appropriate for the target.
438 ///
439 /// This is used to construct the new pass manager's target IR analysis pass,
440 /// set up appropriately for this target machine. Even the old pass manager
441 /// uses this to answer queries about the IR.
442 TargetIRAnalysis getTargetIRAnalysis() const;
443
444 /// Return a TargetTransformInfo for a given function.
445 ///
446 /// The returned TargetTransformInfo is specialized to the subtarget
447 /// corresponding to \p F.
448 virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const;
449
450 /// Allow the target to modify the pass pipeline.
451 // TODO: Populate all pass names by using <Target>PassRegistry.def.
453
454 /// Allow the target to register early alias analyses (AA before BasicAA) with
455 /// the AAManager for use with the new pass manager. Only affects the
456 /// "default" AAManager.
458
459 /// Allow the target to register alias analyses with the AAManager for use
460 /// with the new pass manager. Only affects the "default" AAManager.
462
463 /// Add passes to the specified pass manager to get the specified file
464 /// emitted. Typically this will involve several steps of code generation.
465 /// This method should return true if emission of this file type is not
466 /// supported, or false on success.
467 /// \p MMIWP is an optional parameter that, if set to non-nullptr,
468 /// will be used to set the MachineModuloInfo for this PM.
469 virtual bool
472 bool /*DisableVerify*/ = true,
473 MachineModuleInfoWrapperPass *MMIWP = nullptr) {
474 return true;
475 }
476
477 /// Add passes to the specified pass manager to get machine code emitted with
478 /// the MCJIT. This method returns true if machine code is not supported. It
479 /// fills the MCContext Ctx pointer which can be used to build custom
480 /// MCStreamer.
481 ///
484 bool /*DisableVerify*/ = true) {
485 return true;
486 }
487
488 /// True if subtarget inserts the final scheduling pass on its own.
489 ///
490 /// Branch relaxation, which must happen after block placement, can
491 /// on some targets (e.g. SystemZ) expose additional post-RA
492 /// scheduling opportunities.
493 virtual bool targetSchedulesPostRAScheduling() const { return false; };
494
495 void getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV,
496 Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
497 MCSymbol *getSymbol(const GlobalValue *GV) const;
498
499 /// The integer bit size to use for SjLj based exception handling.
500 static constexpr unsigned DefaultSjLjDataSize = 32;
501 virtual unsigned getSjLjDataSize() const { return DefaultSjLjDataSize; }
502
503 /// getAddressSpaceForPseudoSourceKind - Given the kind of memory
504 /// (e.g. stack) the target returns the corresponding address space.
505 virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const {
506 return 0;
507 }
508
509 /// Entry point for module splitting. Targets can implement custom module
510 /// splitting logic, mainly used by LTO for --lto-partitions.
511 ///
512 /// On success, this guarantees that between 1 and \p NumParts modules were
513 /// created and passed to \p ModuleCallBack.
514 ///
515 /// \returns `true` if the module was split, `false` otherwise. When `false`
516 /// is returned, it is assumed that \p ModuleCallback has never been called
517 /// and \p M has not been modified.
518 virtual bool splitModule(
519 Module &M, unsigned NumParts,
520 function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback) {
521 return false;
522 }
523
524 /// Create a pass configuration object to be used by addPassToEmitX methods
525 /// for generating a pipeline of CodeGen passes.
527 return nullptr;
528 }
529
530 virtual Error
533 CodeGenFileType FileType, const CGPassBuilderOption &Opt,
535 return make_error<StringError>("buildCodeGenPipeline is not overridden",
537 }
538
539 /// Returns true if frontends should default to using the NewPM for this
540 /// specific target.
541 virtual bool shouldDefaultToNewPM() const { return false; }
542
543 /// Returns true if the target is expected to pass all machine verifier
544 /// checks. This is a stopgap measure to fix targets one by one. We will
545 /// remove this at some point and always enable the verifier when
546 /// EXPENSIVE_CHECKS is enabled.
547 virtual bool isMachineVerifierClean() const { return true; }
548
549 /// Adds an AsmPrinter pass to the pipeline that prints assembly or
550 /// machine code from the MI representation.
552 raw_pwrite_stream *DwoOut,
553 CodeGenFileType FileType, MCContext &Context) {
554 return false;
555 }
556
559 CodeGenFileType FileType, MCContext &Ctx);
560
561 /// True if the target uses physical regs (as nearly all targets do). False
562 /// for stack machines such as WebAssembly and other virtual-register
563 /// machines. If true, all vregs must be allocated before PEI. If false, then
564 /// callee-save register spilling and scavenging are not needed or used. If
565 /// false, implicitly defined registers will still be assumed to be physical
566 /// registers, except that variadic defs will be allocated vregs.
567 virtual bool usesPhysRegsForValues() const { return true; }
568
569 /// True if the target wants to use interprocedural register allocation by
570 /// default. The -enable-ipra flag can be used to override this.
571 virtual bool useIPRA() const { return false; }
572
573 /// The default variant to use in unqualified `asm` instructions.
574 /// If this returns 0, `asm "$(foo$|bar$)"` will evaluate to `asm "foo"`.
575 virtual int unqualifiedInlineAsmVariant() const { return 0; }
576
577 // MachineRegisterInfo callback function
579
580 /// Remove all Linker Optimization Hints (LOH) associated with instructions in
581 /// \p MIs and \return the number of hints removed. This is useful in
582 /// transformations that cause these hints to be illegal, like in the machine
583 /// outliner.
585 const SmallPtrSetImpl<MachineInstr *> &MIs) const {
586 return 0;
587 }
588
589 /// Returns whether the backend can lower the llvm.cond.loop intrinsic. If
590 /// this function returns false, the intrinsic will be supported generically
591 /// but without loop detection support.
592 virtual bool canLowerCondLoop() const { return false; }
593};
594
595} // end namespace llvm
596
597#endif // LLVM_TARGET_TARGETMACHINE_H
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
uint64_t uint64_t
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.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
#define LLVM_ABI
Definition Compiler.h:211
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:67
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:68
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:307
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...
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:129
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.
virtual bool shouldDefaultToNewPM() const
Returns true if frontends should default to using the NewPM for this specific target.
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,...
void setSupportsExceptionModel(ExceptionHandling Model, bool Value=true)
Override whether this target can lower exceptions using Model.
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)
CodeModel::Model CMModel
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
unsigned SupportedExceptionModels
Bit N is set if the target can lower exceptions using model N.
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.
bool enableTiedFastRegAlloc() const
Whether the fast register allocator lowers tied operands itself instead of running TwoAddressInstruct...
virtual unsigned getSjLjDataSize() const
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
StringMap< std::unique_ptr< const MCSubtargetInfo > > MCSubtargetMap
MC subtarget keyed by target features and target CPU.
virtual bool isNoopAddrSpaceCast(const DataLayout &DL, unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
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
unsigned SupportsDebugEntryValues
Set if the target supports the debug entry values by default.
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
bool supportsExceptionModel(ExceptionHandling Model) const
Return true if this target can lower exceptions using Model.
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)
void setEnableTiedFastRegAlloc(bool Value)
virtual void registerMachineRegisterInfoCallback(MachineFunction &MF) const
bool supportsDefaultOutlining() const
unsigned RequireStructuredCFG
void setO0WantsFastISel(bool Enable)
virtual bool canLowerCondLoop() const
Returns whether the backend can lower the llvm.cond.loop intrinsic.
unsigned EnableTiedFastRegAlloc
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
unsigned SupportsDefaultOutlining
Set if the target supports default outlining behaviour.
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.
void setEnableDefaultMachineVerifier(bool Enable)
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:48
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.
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
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition CodeGen.h:256
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:227
@ Default
-O2, -Os, -Oz
Definition CodeGen.h:230
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340
ExceptionHandling
Definition CodeGen.h:54
@ None
No exception support.
Definition CodeGen.h:56
BasicBlockSection
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
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.