LLVM 22.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
33
34namespace llvm {
35
36class AAManager;
38
39class Function;
40class GlobalValue;
41class MachineInstr;
42class MachineModuleInfoWrapperPass;
43struct MachineSchedContext;
44class Mangler;
45class MCAsmInfo;
46class MCContext;
47class MCInstrInfo;
48class MCRegisterInfo;
49class MCStreamer;
50class MCSubtargetInfo;
51class MCSymbol;
52class raw_pwrite_stream;
53class PassBuilder;
54class PassInstrumentationCallbacks;
55struct PerFunctionMIParsingState;
56class ScheduleDAGInstrs;
57class SMDiagnostic;
58class SMRange;
59class Target;
60class TargetIRAnalysis;
61class TargetTransformInfo;
62class TargetLoweringObjectFile;
63class TargetPassConfig;
64class TargetSubtargetInfo;
65
66// The old pass manager infrastructure is hidden in a legacy namespace now.
67namespace legacy {
68class PassManagerBase;
69} // namespace legacy
70using legacy::PassManagerBase;
71
72struct MachineFunctionInfo;
73namespace yaml {
74struct MachineFunctionInfo;
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
106 Reloc::Model RM = Reloc::Static;
107 CodeModel::Model CMModel = CodeModel::Small;
108 uint64_t LargeDataThreshold = 0;
109 CodeGenOptLevel OptLevel = CodeGenOptLevel::Default;
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; }
134 StringRef getTargetFeatureString() const { return TargetFS; }
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 /// Reset the target options based on the function's attributes.
235 // FIXME: Remove TargetOptions that affect per-function code generation
236 // from TargetMachine.
237 void resetTargetOptions(const Function &F) const;
238
239 /// Return target specific asm information.
240 const MCAsmInfo *getMCAsmInfo() const { return AsmInfo.get(); }
241
242 const MCRegisterInfo *getMCRegisterInfo() const { return MRI.get(); }
243 const MCInstrInfo *getMCInstrInfo() const { return MII.get(); }
244 const MCSubtargetInfo *getMCSubtargetInfo() const { return STI.get(); }
245
246 /// Return the ExceptionHandling to use, considering TargetOptions and the
247 /// Triple's default.
249 // FIXME: This interface fails to distinguish default from not supported.
250 return Options.ExceptionModel == ExceptionHandling::None
251 ? TargetTriple.getDefaultExceptionHandling()
252 : Options.ExceptionModel;
253 }
254
255 bool requiresStructuredCFG() const { return RequireStructuredCFG; }
256 void setRequiresStructuredCFG(bool Value) { RequireStructuredCFG = Value; }
257
258 /// Returns the code generation relocation model. The choices are static, PIC,
259 /// and dynamic-no-pic, and target default.
260 Reloc::Model getRelocationModel() const;
261
262 /// Returns the code model. The choices are small, kernel, medium, large, and
263 /// target default.
264 CodeModel::Model getCodeModel() const { return CMModel; }
265
266 /// Returns the maximum code size possible under the code model.
267 uint64_t getMaxCodeSize() const;
268
269 /// Set the code model.
270 void setCodeModel(CodeModel::Model CM) { CMModel = CM; }
271
272 void setLargeDataThreshold(uint64_t LDT) { LargeDataThreshold = LDT; }
273 bool isLargeGlobalValue(const GlobalValue *GV) const;
274
275 bool isPositionIndependent() const;
276
277 bool shouldAssumeDSOLocal(const GlobalValue *GV) const;
278
279 /// Returns true if this target uses emulated TLS.
280 bool useEmulatedTLS() const;
281
282 /// Returns true if this target uses TLS Descriptors.
283 bool useTLSDESC() const;
284
285 /// Returns the TLS model which should be used for the given global variable.
286 TLSModel::Model getTLSModel(const GlobalValue *GV) const;
287
288 /// Returns the optimization level: None, Less, Default, or Aggressive.
289 CodeGenOptLevel getOptLevel() const { return OptLevel; }
290
291 /// Overrides the optimization level.
292 void setOptLevel(CodeGenOptLevel Level) { OptLevel = Level; }
293
294 void setFastISel(bool Enable) { Options.EnableFastISel = Enable; }
295 bool getO0WantsFastISel() { return O0WantsFastISel; }
296 void setO0WantsFastISel(bool Enable) { O0WantsFastISel = Enable; }
297 void setGlobalISel(bool Enable) { Options.EnableGlobalISel = Enable; }
299 Options.GlobalISelAbort = Mode;
300 }
302 Options.EnableMachineOutliner = Enable;
303 }
305 Options.SupportsDefaultOutlining = Enable;
306 }
308 Options.SupportsDebugEntryValues = Enable;
309 }
310
311 void setCFIFixup(bool Enable) { Options.EnableCFIFixup = Enable; }
312
314 return Options.EnableAIXExtendedAltivecABI;
315 }
316
317 bool getUniqueSectionNames() const { return Options.UniqueSectionNames; }
318
319 /// Return true if unique basic block section names must be generated.
321 return Options.UniqueBasicBlockSectionNames;
322 }
323
325 return Options.SeparateNamedSections;
326 }
327
328 /// Return true if data objects should be emitted into their own section,
329 /// corresponds to -fdata-sections.
330 bool getDataSections() const {
331 return Options.DataSections;
332 }
333
334 /// Return true if functions should be emitted into their own section,
335 /// corresponding to -ffunction-sections.
336 bool getFunctionSections() const {
337 return Options.FunctionSections;
338 }
339
341 return Options.EnableStaticDataPartitioning;
342 }
343
344 /// Return true if visibility attribute should not be emitted in XCOFF,
345 /// corresponding to -mignore-xcoff-visibility.
347 return Options.IgnoreXCOFFVisibility;
348 }
349
350 /// Return true if XCOFF traceback table should be emitted,
351 /// corresponding to -xcoff-traceback-table.
352 bool getXCOFFTracebackTable() const { return Options.XCOFFTracebackTable; }
353
354 /// If basic blocks should be emitted into their own section,
355 /// corresponding to -fbasic-block-sections.
357 return Options.BBSections;
358 }
359
360 /// Get the list of functions and basic block ids that need unique sections.
362 return Options.BBSectionsFuncListBuf.get();
363 }
364
365 /// Returns true if a cast between SrcAS and DestAS is a noop.
366 virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const {
367 return false;
368 }
369
370 void setPGOOption(std::optional<PGOOptions> PGOOpt) { PGOOption = PGOOpt; }
371 const std::optional<PGOOptions> &getPGOOption() const { return PGOOption; }
372
373 /// If the specified generic pointer could be assumed as a pointer to a
374 /// specific address space, return that address space.
375 ///
376 /// Under offloading programming, the offloading target may be passed with
377 /// values only prepared on the host side and could assume certain
378 /// properties.
379 virtual unsigned getAssumedAddrSpace(const Value *V) const { return -1; }
380
381 /// If the specified predicate checks whether a generic pointer falls within
382 /// a specified address space, return that generic pointer and the address
383 /// space being queried.
384 ///
385 /// Such predicates could be specified in @llvm.assume intrinsics for the
386 /// optimizer to assume that the given generic pointer always falls within
387 /// the address space based on that predicate.
388 virtual std::pair<const Value *, unsigned>
390 return std::make_pair(nullptr, -1);
391 }
392
393 /// Get a \c TargetIRAnalysis appropriate for the target.
394 ///
395 /// This is used to construct the new pass manager's target IR analysis pass,
396 /// set up appropriately for this target machine. Even the old pass manager
397 /// uses this to answer queries about the IR.
398 TargetIRAnalysis getTargetIRAnalysis() const;
399
400 /// Return a TargetTransformInfo for a given function.
401 ///
402 /// The returned TargetTransformInfo is specialized to the subtarget
403 /// corresponding to \p F.
404 virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const;
405
406 /// Allow the target to modify the pass pipeline.
407 // TODO: Populate all pass names by using <Target>PassRegistry.def.
409
410 /// Allow the target to register early alias analyses (AA before BasicAA) with
411 /// the AAManager for use with the new pass manager. Only affects the
412 /// "default" AAManager.
414
415 /// Allow the target to register alias analyses with the AAManager for use
416 /// with the new pass manager. Only affects the "default" AAManager.
418
419 /// Add passes to the specified pass manager to get the specified file
420 /// emitted. Typically this will involve several steps of code generation.
421 /// This method should return true if emission of this file type is not
422 /// supported, or false on success.
423 /// \p MMIWP is an optional parameter that, if set to non-nullptr,
424 /// will be used to set the MachineModuloInfo for this PM.
425 virtual bool
428 bool /*DisableVerify*/ = true,
429 MachineModuleInfoWrapperPass *MMIWP = nullptr) {
430 return true;
431 }
432
433 /// Add passes to the specified pass manager to get machine code emitted with
434 /// the MCJIT. This method returns true if machine code is not supported. It
435 /// fills the MCContext Ctx pointer which can be used to build custom
436 /// MCStreamer.
437 ///
440 bool /*DisableVerify*/ = true) {
441 return true;
442 }
443
444 /// True if subtarget inserts the final scheduling pass on its own.
445 ///
446 /// Branch relaxation, which must happen after block placement, can
447 /// on some targets (e.g. SystemZ) expose additional post-RA
448 /// scheduling opportunities.
449 virtual bool targetSchedulesPostRAScheduling() const { return false; };
450
451 void getNameWithPrefix(SmallVectorImpl<char> &Name, const GlobalValue *GV,
452 Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
453 MCSymbol *getSymbol(const GlobalValue *GV) const;
454
455 /// The integer bit size to use for SjLj based exception handling.
456 static constexpr unsigned DefaultSjLjDataSize = 32;
457 virtual unsigned getSjLjDataSize() const { return DefaultSjLjDataSize; }
458
459 static std::pair<int, int> parseBinutilsVersion(StringRef Version);
460
461 /// getAddressSpaceForPseudoSourceKind - Given the kind of memory
462 /// (e.g. stack) the target returns the corresponding address space.
463 virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const {
464 return 0;
465 }
466
467 /// Entry point for module splitting. Targets can implement custom module
468 /// splitting logic, mainly used by LTO for --lto-partitions.
469 ///
470 /// On success, this guarantees that between 1 and \p NumParts modules were
471 /// created and passed to \p ModuleCallBack.
472 ///
473 /// \returns `true` if the module was split, `false` otherwise. When `false`
474 /// is returned, it is assumed that \p ModuleCallback has never been called
475 /// and \p M has not been modified.
476 virtual bool splitModule(
477 Module &M, unsigned NumParts,
478 function_ref<void(std::unique_ptr<Module> MPart)> ModuleCallback) {
479 return false;
480 }
481
482 /// Create a pass configuration object to be used by addPassToEmitX methods
483 /// for generating a pipeline of CodeGen passes.
485 return nullptr;
486 }
487
490 const CGPassBuilderOption &,
492 return make_error<StringError>("buildCodeGenPipeline is not overridden",
494 }
495
496 /// Returns true if the target is expected to pass all machine verifier
497 /// checks. This is a stopgap measure to fix targets one by one. We will
498 /// remove this at some point and always enable the verifier when
499 /// EXPENSIVE_CHECKS is enabled.
500 virtual bool isMachineVerifierClean() const { return true; }
501
502 /// Adds an AsmPrinter pass to the pipeline that prints assembly or
503 /// machine code from the MI representation.
505 raw_pwrite_stream *DwoOut,
506 CodeGenFileType FileType, MCContext &Context) {
507 return false;
508 }
509
512 CodeGenFileType FileType, MCContext &Ctx);
513
514 /// True if the target uses physical regs (as nearly all targets do). False
515 /// for stack machines such as WebAssembly and other virtual-register
516 /// machines. If true, all vregs must be allocated before PEI. If false, then
517 /// callee-save register spilling and scavenging are not needed or used. If
518 /// false, implicitly defined registers will still be assumed to be physical
519 /// registers, except that variadic defs will be allocated vregs.
520 virtual bool usesPhysRegsForValues() const { return true; }
521
522 /// True if the target wants to use interprocedural register allocation by
523 /// default. The -enable-ipra flag can be used to override this.
524 virtual bool useIPRA() const { return false; }
525
526 /// The default variant to use in unqualified `asm` instructions.
527 /// If this returns 0, `asm "$(foo$|bar$)"` will evaluate to `asm "foo"`.
528 virtual int unqualifiedInlineAsmVariant() const { return 0; }
529
530 // MachineRegisterInfo callback function
532
533 /// Remove all Linker Optimization Hints (LOH) associated with instructions in
534 /// \p MIs and \return the number of hints removed. This is useful in
535 /// transformations that cause these hints to be illegal, like in the machine
536 /// outliner.
538 const SmallPtrSetImpl<MachineInstr *> &MIs) const {
539 return 0;
540 }
541};
542
543} // end namespace llvm
544
545#endif // LLVM_TARGET_TARGETMACHINE_H
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")
#define LLVM_ABI
Definition: Compiler.h:213
@ Enable
Definition: DwarfDebug.cpp:86
std::string Name
This header defines various interfaces for pass management in LLVM.
static LVOptions Options
Definition: LVOptions.cpp:25
#define F(x, y, z)
Definition: MD5.cpp:55
Define option tunables for PGO.
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.
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:67
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
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:64
Context object for machine code objects.
Definition: MCContext.h:83
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:27
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode.
Definition: MCInstrInfo.h:64
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 ...
Definition: MCSymbol.h:42
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:52
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.
Definition: PassBuilder.h:110
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:282
Represents a range in source code.
Definition: SMLoc.h:48
A ScheduleDAG for scheduling lists of MachineInstr.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:380
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:574
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Analysis pass providing the TargetTransformInfo.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:83
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::string TargetFS
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.
Definition: TargetMachine.h:98
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...
std::string TargetCPU
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 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.
Definition: TargetMachine.h:90
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.
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_ABI ExceptionHandling getDefaultExceptionHandling() const
Definition: Triple.cpp:2294
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.
Definition: raw_ostream.h:435
LLVM_ABI llvm::cl::opt< bool > NoKernelInfoEndLTO
This file defines the TargetMachine class.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
Definition: PassManager.h:239
template class LLVM_TEMPLATE_ABI PassManager< Module >
Definition: PassManager.cpp:22
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:98
ExceptionHandling
Definition: CodeGen.h:53
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition: CodeGen.h:111
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:82
BasicBlockSection
Definition: TargetOptions.h:55
GlobalISelAbortMode
Enable abort calls when global instruction selection fails to lower/select an instruction.
Definition: TargetOptions.h:90
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.