LLVM 18.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 and LLVMTargetMachine classes.
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"
21#include "llvm/Support/Error.h"
26#include <optional>
27#include <string>
28#include <utility>
29
30namespace llvm {
31
32class AAManager;
33using ModulePassManager = PassManager<Module>;
34
35class Function;
36class GlobalValue;
37class MachineFunctionPassManager;
38class MachineFunctionAnalysisManager;
39class MachineModuleInfoWrapperPass;
40class Mangler;
41class MCAsmInfo;
42class MCContext;
43class MCInstrInfo;
44class MCRegisterInfo;
45class MCStreamer;
46class MCSubtargetInfo;
47class MCSymbol;
48class raw_pwrite_stream;
49class PassBuilder;
50struct PerFunctionMIParsingState;
51class SMDiagnostic;
52class SMRange;
53class Target;
54class TargetIntrinsicInfo;
55class TargetIRAnalysis;
56class TargetTransformInfo;
57class TargetLoweringObjectFile;
58class TargetPassConfig;
59class TargetSubtargetInfo;
60
61// The old pass manager infrastructure is hidden in a legacy namespace now.
62namespace legacy {
63class PassManagerBase;
64}
65using legacy::PassManagerBase;
66
67struct MachineFunctionInfo;
68namespace yaml {
69struct MachineFunctionInfo;
70}
71
72//===----------------------------------------------------------------------===//
73///
74/// Primary interface to the complete machine description for the target
75/// machine. All target-specific information should be accessible through this
76/// interface.
77///
79protected: // Can only create subclasses.
80 TargetMachine(const Target &T, StringRef DataLayoutString,
81 const Triple &TargetTriple, StringRef CPU, StringRef FS,
82 const TargetOptions &Options);
83
84 /// The Target that this machine was created for.
86
87 /// DataLayout for the target: keep ABI type size and alignment.
88 ///
89 /// The DataLayout is created based on the string representation provided
90 /// during construction. It is kept here only to avoid reparsing the string
91 /// but should not really be used during compilation, because it has an
92 /// internal cache that is context specific.
94
95 /// Triple string, CPU name, and target feature strings the TargetMachine
96 /// instance is created with.
98 std::string TargetCPU;
99 std::string TargetFS;
100
105
106 /// Contains target specific asm information.
107 std::unique_ptr<const MCAsmInfo> AsmInfo;
108 std::unique_ptr<const MCRegisterInfo> MRI;
109 std::unique_ptr<const MCInstrInfo> MII;
110 std::unique_ptr<const MCSubtargetInfo> STI;
111
113 unsigned O0WantsFastISel : 1;
114
115 // PGO related tunables.
116 std::optional<PGOOptions> PGOOption;
117
118public:
120
121 TargetMachine(const TargetMachine &) = delete;
122 void operator=(const TargetMachine &) = delete;
123 virtual ~TargetMachine();
124
125 const Target &getTarget() const { return TheTarget; }
126
127 const Triple &getTargetTriple() const { return TargetTriple; }
128 StringRef getTargetCPU() const { return TargetCPU; }
130 void setTargetFeatureString(StringRef FS) { TargetFS = std::string(FS); }
131
132 /// Virtual method implemented by subclasses that returns a reference to that
133 /// target's TargetSubtargetInfo-derived member variable.
134 virtual const TargetSubtargetInfo *getSubtargetImpl(const Function &) const {
135 return nullptr;
136 }
138 return nullptr;
139 }
140
141 /// Create the target's instance of MachineFunctionInfo
142 virtual MachineFunctionInfo *
144 const TargetSubtargetInfo *STI) const {
145 return nullptr;
146 }
147
148 /// Allocate and return a default initialized instance of the YAML
149 /// representation for the MachineFunctionInfo.
151 return nullptr;
152 }
153
154 /// Allocate and initialize an instance of the YAML representation of the
155 /// MachineFunctionInfo.
158 return nullptr;
159 }
160
161 /// Parse out the target's MachineFunctionInfo from the YAML reprsentation.
165 SMRange &SourceRange) const {
166 return false;
167 }
168
169 /// This method returns a pointer to the specified type of
170 /// TargetSubtargetInfo. In debug builds, it verifies that the object being
171 /// returned is of the correct type.
172 template <typename STC> const STC &getSubtarget(const Function &F) const {
173 return *static_cast<const STC*>(getSubtargetImpl(F));
174 }
175
176 /// Create a DataLayout.
177 const DataLayout createDataLayout() const { return DL; }
178
179 /// Test if a DataLayout if compatible with the CodeGen for this target.
180 ///
181 /// The LLVM Module owns a DataLayout that is used for the target independent
182 /// optimizations and code generation. This hook provides a target specific
183 /// check on the validity of this DataLayout.
184 bool isCompatibleDataLayout(const DataLayout &Candidate) const {
185 return DL == Candidate;
186 }
187
188 /// Get the pointer size for this target.
189 ///
190 /// This is the only time the DataLayout in the TargetMachine is used.
191 unsigned getPointerSize(unsigned AS) const {
192 return DL.getPointerSize(AS);
193 }
194
195 unsigned getPointerSizeInBits(unsigned AS) const {
196 return DL.getPointerSizeInBits(AS);
197 }
198
199 unsigned getProgramPointerSize() const {
201 }
202
203 unsigned getAllocaPointerSize() const {
205 }
206
207 /// Reset the target options based on the function's attributes.
208 // FIXME: Remove TargetOptions that affect per-function code generation
209 // from TargetMachine.
210 void resetTargetOptions(const Function &F) const;
211
212 /// Return target specific asm information.
213 const MCAsmInfo *getMCAsmInfo() const { return AsmInfo.get(); }
214
215 const MCRegisterInfo *getMCRegisterInfo() const { return MRI.get(); }
216 const MCInstrInfo *getMCInstrInfo() const { return MII.get(); }
217 const MCSubtargetInfo *getMCSubtargetInfo() const { return STI.get(); }
218
219 /// If intrinsic information is available, return it. If not, return null.
220 virtual const TargetIntrinsicInfo *getIntrinsicInfo() const {
221 return nullptr;
222 }
223
226
227 /// Returns the code generation relocation model. The choices are static, PIC,
228 /// and dynamic-no-pic, and target default.
230
231 /// Returns the code model. The choices are small, kernel, medium, large, and
232 /// target default.
234
235 /// Returns the maximum code size possible under the code model.
236 uint64_t getMaxCodeSize() const;
237
238 /// Set the code model.
240
242 bool isLargeData(const GlobalVariable *GV) const;
243
244 bool isPositionIndependent() const;
245
246 bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const;
247
248 /// Returns true if this target uses emulated TLS.
249 bool useEmulatedTLS() const;
250
251 /// Returns the TLS model which should be used for the given global variable.
252 TLSModel::Model getTLSModel(const GlobalValue *GV) const;
253
254 /// Returns the optimization level: None, Less, Default, or Aggressive.
256
257 /// Overrides the optimization level.
258 void setOptLevel(CodeGenOptLevel Level);
259
266 }
269 }
272 }
275 }
276
278
281 }
282
284
285 /// Return true if unique basic block section names must be generated.
288 }
289
290 /// Return true if data objects should be emitted into their own section,
291 /// corresponds to -fdata-sections.
292 bool getDataSections() const {
293 return Options.DataSections;
294 }
295
296 /// Return true if functions should be emitted into their own section,
297 /// corresponding to -ffunction-sections.
298 bool getFunctionSections() const {
300 }
301
302 /// Return true if visibility attribute should not be emitted in XCOFF,
303 /// corresponding to -mignore-xcoff-visibility.
306 }
307
308 /// Return true if XCOFF traceback table should be emitted,
309 /// corresponding to -xcoff-traceback-table.
311
312 /// If basic blocks should be emitted into their own section,
313 /// corresponding to -fbasic-block-sections.
315 return Options.BBSections;
316 }
317
318 /// Get the list of functions and basic block ids that need unique sections.
320 return Options.BBSectionsFuncListBuf.get();
321 }
322
323 /// Returns true if a cast between SrcAS and DestAS is a noop.
324 virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const {
325 return false;
326 }
327
328 void setPGOOption(std::optional<PGOOptions> PGOOpt) { PGOOption = PGOOpt; }
329 const std::optional<PGOOptions> &getPGOOption() const { return PGOOption; }
330
331 /// If the specified generic pointer could be assumed as a pointer to a
332 /// specific address space, return that address space.
333 ///
334 /// Under offloading programming, the offloading target may be passed with
335 /// values only prepared on the host side and could assume certain
336 /// properties.
337 virtual unsigned getAssumedAddrSpace(const Value *V) const { return -1; }
338
339 /// If the specified predicate checks whether a generic pointer falls within
340 /// a specified address space, return that generic pointer and the address
341 /// space being queried.
342 ///
343 /// Such predicates could be specified in @llvm.assume intrinsics for the
344 /// optimizer to assume that the given generic pointer always falls within
345 /// the address space based on that predicate.
346 virtual std::pair<const Value *, unsigned>
348 return std::make_pair(nullptr, -1);
349 }
350
351 /// Get a \c TargetIRAnalysis appropriate for the target.
352 ///
353 /// This is used to construct the new pass manager's target IR analysis pass,
354 /// set up appropriately for this target machine. Even the old pass manager
355 /// uses this to answer queries about the IR.
357
358 /// Return a TargetTransformInfo for a given function.
359 ///
360 /// The returned TargetTransformInfo is specialized to the subtarget
361 /// corresponding to \p F.
363
364 /// Allow the target to modify the pass pipeline.
366
367 /// Allow the target to register alias analyses with the AAManager for use
368 /// with the new pass manager. Only affects the "default" AAManager.
370
371 /// Add passes to the specified pass manager to get the specified file
372 /// emitted. Typically this will involve several steps of code generation.
373 /// This method should return true if emission of this file type is not
374 /// supported, or false on success.
375 /// \p MMIWP is an optional parameter that, if set to non-nullptr,
376 /// will be used to set the MachineModuloInfo for this PM.
377 virtual bool
380 bool /*DisableVerify*/ = true,
381 MachineModuleInfoWrapperPass *MMIWP = nullptr) {
382 return true;
383 }
384
385 /// Add passes to the specified pass manager to get machine code emitted with
386 /// the MCJIT. This method returns true if machine code is not supported. It
387 /// fills the MCContext Ctx pointer which can be used to build custom
388 /// MCStreamer.
389 ///
392 bool /*DisableVerify*/ = true) {
393 return true;
394 }
395
396 /// True if subtarget inserts the final scheduling pass on its own.
397 ///
398 /// Branch relaxation, which must happen after block placement, can
399 /// on some targets (e.g. SystemZ) expose additional post-RA
400 /// scheduling opportunities.
401 virtual bool targetSchedulesPostRAScheduling() const { return false; };
402
404 Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
405 MCSymbol *getSymbol(const GlobalValue *GV) const;
406
407 /// The integer bit size to use for SjLj based exception handling.
408 static constexpr unsigned DefaultSjLjDataSize = 32;
409 virtual unsigned getSjLjDataSize() const { return DefaultSjLjDataSize; }
410
411 static std::pair<int, int> parseBinutilsVersion(StringRef Version);
412
413 /// getAddressSpaceForPseudoSourceKind - Given the kind of memory
414 /// (e.g. stack) the target returns the corresponding address space.
415 virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const {
416 return 0;
417 }
418};
419
420/// This class describes a target machine that is implemented with the LLVM
421/// target-independent code generator.
422///
424protected: // Can only create subclasses.
425 LLVMTargetMachine(const Target &T, StringRef DataLayoutString,
426 const Triple &TT, StringRef CPU, StringRef FS,
429
430 void initAsmInfo();
431
432public:
433 /// Get a TargetTransformInfo implementation for the target.
434 ///
435 /// The TTI returned uses the common code generator to answer queries about
436 /// the IR.
438
439 /// Create a pass configuration object to be used by addPassToEmitX methods
440 /// for generating a pipeline of CodeGen passes.
442
443 /// Add passes to the specified pass manager to get the specified file
444 /// emitted. Typically this will involve several steps of code generation.
445 /// \p MMIWP is an optional parameter that, if set to non-nullptr,
446 /// will be used to set the MachineModuloInfo for this PM.
447 bool
449 raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
450 bool DisableVerify = true,
451 MachineModuleInfoWrapperPass *MMIWP = nullptr) override;
452
459 return make_error<StringError>("buildCodeGenPipeline is not overridden",
461 }
462
463 virtual std::pair<StringRef, bool> getPassNameFromLegacyName(StringRef) {
465 "getPassNameFromLegacyName parseMIRPipeline is not overridden");
466 }
467
468 /// Add passes to the specified pass manager to get machine code emitted with
469 /// the MCJIT. This method returns true if machine code is not supported. It
470 /// fills the MCContext Ctx pointer which can be used to build custom
471 /// MCStreamer.
474 bool DisableVerify = true) override;
475
476 /// Returns true if the target is expected to pass all machine verifier
477 /// checks. This is a stopgap measure to fix targets one by one. We will
478 /// remove this at some point and always enable the verifier when
479 /// EXPENSIVE_CHECKS is enabled.
480 virtual bool isMachineVerifierClean() const { return true; }
481
482 /// Adds an AsmPrinter pass to the pipeline that prints assembly or
483 /// machine code from the MI representation.
485 raw_pwrite_stream *DwoOut, CodeGenFileType FileType,
486 MCContext &Context);
487
490 CodeGenFileType FileType, MCContext &Ctx);
491
492 /// True if the target uses physical regs (as nearly all targets do). False
493 /// for stack machines such as WebAssembly and other virtual-register
494 /// machines. If true, all vregs must be allocated before PEI. If false, then
495 /// callee-save register spilling and scavenging are not needed or used. If
496 /// false, implicitly defined registers will still be assumed to be physical
497 /// registers, except that variadic defs will be allocated vregs.
498 virtual bool usesPhysRegsForValues() const { return true; }
499
500 /// True if the target wants to use interprocedural register allocation by
501 /// default. The -enable-ipra flag can be used to override this.
502 virtual bool useIPRA() const {
503 return false;
504 }
505
506 /// The default variant to use in unqualified `asm` instructions.
507 /// If this returns 0, `asm "$(foo$|bar$)"` will evaluate to `asm "foo"`.
508 virtual int unqualifiedInlineAsmVariant() const { return 0; }
509
510 // MachineRegisterInfo callback function
512};
513
514/// Helper method for getting the code model, returning Default if
515/// CM does not have a value. The tiny and kernel models will produce
516/// an error, so targets that support them or require more complex codemodel
517/// selection logic should implement and call their own getEffectiveCodeModel.
518inline CodeModel::Model
519getEffectiveCodeModel(std::optional<CodeModel::Model> CM,
521 if (CM) {
522 // By default, targets do not support the tiny and kernel models.
523 if (*CM == CodeModel::Tiny)
524 report_fatal_error("Target does not support the tiny CodeModel", false);
525 if (*CM == CodeModel::Kernel)
526 report_fatal_error("Target does not support the kernel CodeModel", false);
527 return *CM;
528 }
529 return Default;
530}
531
532} // end namespace llvm
533
534#endif // LLVM_TARGET_TARGETMACHINE_H
This file defines the BumpPtrAllocator interface.
std::string Name
#define F(x, y, z)
Definition: MD5.cpp:55
Define option tunables for PGO.
This header defines various interfaces for pass management in LLVM.
Basic Register Allocator
static cl::opt< RegAllocEvictionAdvisorAnalysis::AdvisorMode > Mode("regalloc-enable-advisor", cl::Hidden, cl::init(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default), cl::desc("Enable regalloc advisor mode"), cl::values(clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Default, "default", "Default"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Release, "release", "precompiled"), clEnumValN(RegAllocEvictionAdvisorAnalysis::AdvisorMode::Development, "development", "for training")))
A manager for alias analyses.
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:110
unsigned getProgramAddressSpace() const
Definition: DataLayout.h:293
unsigned getPointerSizeInBits(unsigned AS=0) const
Layout pointer size, in bits FIXME: The defaults need to be removed once all of the backends/clients ...
Definition: DataLayout.h:410
unsigned getAllocaAddrSpace() const
Definition: DataLayout.h:276
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
Definition: DataLayout.cpp:748
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:474
This class describes a target machine that is implemented with the LLVM target-independent code gener...
virtual bool isMachineVerifierClean() const
Returns true if the target is expected to pass all machine verifier checks.
virtual void registerMachineRegisterInfoCallback(MachineFunction &MF) const
virtual bool useIPRA() const
True if the target wants to use interprocedural register allocation by default.
virtual TargetPassConfig * createPassConfig(PassManagerBase &PM)
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
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...
virtual Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &, MachineFunctionAnalysisManager &, raw_pwrite_stream &, raw_pwrite_stream *, CodeGenFileType, CGPassBuilderOption, PassInstrumentationCallbacks *)
bool addPassesToEmitFile(PassManagerBase &PM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, bool DisableVerify=true, MachineModuleInfoWrapperPass *MMIWP=nullptr) override
Add passes to the specified pass manager to get the specified file emitted.
virtual std::pair< StringRef, bool > getPassNameFromLegacyName(StringRef)
bool addPassesToEmitMC(PassManagerBase &PM, MCContext *&Ctx, raw_pwrite_stream &Out, bool DisableVerify=true) override
Add passes to the specified pass manager to get machine code emitted with the MCJIT.
virtual bool usesPhysRegsForValues() const
True if the target uses physical regs (as nearly all targets do).
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
virtual int unqualifiedInlineAsmVariant() const
The default variant to use in unqualified asm instructions.
Expected< std::unique_ptr< MCStreamer > > createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext &Ctx)
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
Context object for machine code objects.
Definition: MCContext.h:76
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
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:41
An AnalysisManager<MachineFunction> that also exposes IR analysis results.
MachineFunctionPassManager adds/removes below features to/from the base PassManager template instanti...
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:51
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
This class provides access to building LLVM's passes.
Definition: PassBuilder.h:103
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:281
Represents a range in source code.
Definition: SMLoc.h:48
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:577
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Analysis pass providing the TargetTransformInfo.
TargetIntrinsicInfo - Interface to description of machine instruction set.
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:78
void setSupportsDebugEntryValues(bool Enable)
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
Definition: TargetMachine.h:97
std::unique_ptr< const MCAsmInfo > AsmInfo
Contains target specific asm information.
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
bool isPositionIndependent() const
virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const
getAddressSpaceForPseudoSourceKind - Given the kind of memory (e.g.
virtual bool addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &, raw_pwrite_stream *, CodeGenFileType, bool=true, MachineModuleInfoWrapperPass *MMIWP=nullptr)
Add passes to the specified pass manager to get the specified file emitted.
unsigned getAllocaPointerSize() const
virtual std::pair< const Value *, unsigned > getPredicatedAddrSpace(const Value *V) const
If the specified predicate checks whether a generic pointer falls within a specified address space,...
virtual void registerPassBuilderCallbacks(PassBuilder &)
Allow the target to modify the pass pipeline.
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
uint64_t getMaxCodeSize() const
Returns the maximum code size possible under the code model.
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 MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const
Create the target's instance of MachineFunctionInfo.
const Triple & getTargetTriple() const
const DataLayout createDataLayout() const
Create a DataLayout.
void setMachineOutliner(bool Enable)
void setFastISel(bool Enable)
const std::optional< PGOOptions > & getPGOOption() const
uint64_t LargeDataThreshold
const MCSubtargetInfo * getMCSubtargetInfo() 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...
void setCFIFixup(bool Enable)
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
bool getUniqueBasicBlockSectionNames() const
Return true if unique basic block section names must be generated.
bool getUniqueSectionNames() const
unsigned getPointerSize(unsigned AS) const
Get the pointer size for this target.
std::unique_ptr< const MCInstrInfo > MII
void setSupportsDefaultOutlining(bool Enable)
TargetMachine(const TargetMachine &)=delete
void setGlobalISelAbort(GlobalISelAbortMode Mode)
virtual unsigned getAssumedAddrSpace(const Value *V) const
If the specified generic pointer could be assumed as a pointer to a specific address space,...
bool isLargeData(const GlobalVariable *GV) const
virtual TargetLoweringObjectFile * getObjFileLowering() const
std::string TargetFS
Definition: TargetMachine.h:99
std::optional< PGOOptions > PGOOption
virtual yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
StringRef getTargetFeatureString() const
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
static constexpr unsigned DefaultSjLjDataSize
The integer bit size to use for SjLj based exception handling.
virtual bool targetSchedulesPostRAScheduling() const
True if subtarget inserts the final scheduling pass on its own.
virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const
Return a TargetTransformInfo for a given function.
virtual bool addPassesToEmitMC(PassManagerBase &, MCContext *&, raw_pwrite_stream &, bool=true)
Add passes to the specified pass manager to get machine code emitted with the MCJIT.
const DataLayout DL
DataLayout for the target: keep ABI type size and alignment.
Definition: TargetMachine.h:93
StringRef getTargetCPU() const
const MCInstrInfo * getMCInstrInfo() const
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
std::string TargetCPU
Definition: TargetMachine.h:98
bool requiresStructuredCFG() const
void setRequiresStructuredCFG(bool Value)
static std::pair< int, int > parseBinutilsVersion(StringRef Version)
std::unique_ptr< const MCSubtargetInfo > STI
void setGlobalISel(bool Enable)
TargetIRAnalysis getTargetIRAnalysis() const
Get a TargetIRAnalysis appropriate for the target.
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)
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()
bool isCompatibleDataLayout(const DataLayout &Candidate) const
Test if a DataLayout if compatible with the CodeGen for this target.
void operator=(const TargetMachine &)=delete
MCSymbol * getSymbol(const GlobalValue *GV) const
unsigned getProgramPointerSize() const
bool getXCOFFTracebackTable() const
Return true if XCOFF traceback table should be emitted, corresponding to -xcoff-traceback-table.
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
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:85
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.
void setCodeModel(CodeModel::Model CM)
Set the code model.
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
void setPGOOption(std::optional< PGOOptions > PGOOpt)
std::unique_ptr< const MCRegisterInfo > MRI
bool getFunctionSections() const
Return true if functions should be emitted into their own section, corresponding to -ffunction-sectio...
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
CodeGenOptLevel OptLevel
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.
void setOptLevel(CodeGenOptLevel Level)
Overrides the optimization level.
unsigned EnableAIXExtendedAltivecABI
EnableAIXExtendedAltivecABI - This flag returns true when -vec-extabi is specified.
unsigned EnableMachineOutliner
Enables the MachineOutliner pass.
unsigned SupportsDebugEntryValues
Set if the target supports the debug entry values by default.
BasicBlockSection BBSections
Emit basic blocks into separate sections.
GlobalISelAbortMode GlobalISelAbort
EnableGlobalISelAbort - Control abort behaviour when global instruction selection fails to lower/sele...
unsigned XCOFFTracebackTable
Emit XCOFF traceback table.
unsigned IgnoreXCOFFVisibility
Do not emit visibility attribute for xcoff.
unsigned EnableCFIFixup
Enable the CFIFixup pass.
unsigned SupportsDefaultOutlining
Set if the target supports default outlining behaviour.
unsigned UniqueBasicBlockSectionNames
Use unique names for basic block sections.
unsigned UniqueSectionNames
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
std::shared_ptr< MemoryBuffer > BBSectionsFuncListBuf
Memory Buffer that contains information on sampled basic blocks and used to selectively generate basi...
unsigned FunctionSections
Emit functions into separate sections.
unsigned EnableGlobalISel
EnableGlobalISel - This flag enables global instruction selection.
unsigned DataSections
Emit data into separate sections.
Target-Independent Code Generator Pass Configuration Options.
TargetSubtargetInfo - Generic base class for all target subtargets.
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
LLVM Value Representation.
Definition: Value.h:74
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:428
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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:582
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:90
CodeModel::Model getEffectiveCodeModel(std::optional< CodeModel::Model > CM, CodeModel::Model Default)
Helper method for getting the code model, returning Default if CM does not have a value.
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition: CodeGen.h:83
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:156
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:54
BasicBlockSection
Definition: TargetOptions.h:61
@ Default
The result values are uniform if and only if all operands are uniform.
GlobalISelAbortMode
Enable abort calls when global instruction selection fails to lower/select an instruction.
@ Enable
Enable colors.
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.