LLVM  17.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/ADT/Triple.h"
18 #include "llvm/IR/DataLayout.h"
19 #include "llvm/IR/PassManager.h"
20 #include "llvm/Support/Allocator.h"
21 #include "llvm/Support/CodeGen.h"
22 #include "llvm/Support/Error.h"
26 #include <optional>
27 #include <string>
28 #include <utility>
29 
30 namespace llvm {
31 
32 class AAManager;
33 using ModulePassManager = PassManager<Module>;
34 
35 class Function;
36 class GlobalValue;
37 class MachineFunctionPassManager;
38 class MachineFunctionAnalysisManager;
39 class MachineModuleInfoWrapperPass;
40 class Mangler;
41 class MCAsmInfo;
42 class MCContext;
43 class MCInstrInfo;
44 class MCRegisterInfo;
45 class MCStreamer;
46 class MCSubtargetInfo;
47 class MCSymbol;
48 class raw_pwrite_stream;
49 class PassBuilder;
50 struct PerFunctionMIParsingState;
51 class SMDiagnostic;
52 class SMRange;
53 class Target;
54 class TargetIntrinsicInfo;
55 class TargetIRAnalysis;
56 class TargetTransformInfo;
57 class TargetLoweringObjectFile;
58 class TargetPassConfig;
59 class TargetSubtargetInfo;
60 
61 // The old pass manager infrastructure is hidden in a legacy namespace now.
62 namespace legacy {
63 class PassManagerBase;
64 }
65 using legacy::PassManagerBase;
66 
67 struct MachineFunctionInfo;
68 namespace yaml {
69 struct 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 ///
79 protected: // Can only create subclasses.
80  TargetMachine(const Target &T, StringRef DataLayoutString,
82  const TargetOptions &Options);
83 
84  /// The Target that this machine was created for.
85  const Target &TheTarget;
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.
93  const DataLayout DL;
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 
104 
105  /// Contains target specific asm information.
106  std::unique_ptr<const MCAsmInfo> AsmInfo;
107  std::unique_ptr<const MCRegisterInfo> MRI;
108  std::unique_ptr<const MCInstrInfo> MII;
109  std::unique_ptr<const MCSubtargetInfo> STI;
110 
111  unsigned RequireStructuredCFG : 1;
112  unsigned O0WantsFastISel : 1;
113 
114  // PGO related tunables.
115  std::optional<PGOOptions> PGOOption;
116 
117 public:
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.
156  virtual yaml::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  /// Set the code model.
237 
238  bool isPositionIndependent() const;
239 
240  bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const;
241 
242  /// Returns true if this target uses emulated TLS.
243  bool useEmulatedTLS() const;
244 
245  /// Returns the TLS model which should be used for the given global variable.
246  TLSModel::Model getTLSModel(const GlobalValue *GV) const;
247 
248  /// Returns the optimization level: None, Less, Default, or Aggressive.
250 
251  /// Overrides the optimization level.
252  void setOptLevel(CodeGenOpt::Level Level);
253 
254  void setFastISel(bool Enable) { Options.EnableFastISel = Enable; }
256  void setO0WantsFastISel(bool Enable) { O0WantsFastISel = Enable; }
257  void setGlobalISel(bool Enable) { Options.EnableGlobalISel = Enable; }
260  }
261  void setMachineOutliner(bool Enable) {
263  }
264  void setSupportsDefaultOutlining(bool Enable) {
266  }
267  void setSupportsDebugEntryValues(bool Enable) {
269  }
270 
271  void setCFIFixup(bool Enable) { Options.EnableCFIFixup = Enable; }
272 
275  }
276 
278 
279  /// Return true if unique basic block section names must be generated.
282  }
283 
284  /// Return true if data objects should be emitted into their own section,
285  /// corresponds to -fdata-sections.
286  bool getDataSections() const {
287  return Options.DataSections;
288  }
289 
290  /// Return true if functions should be emitted into their own section,
291  /// corresponding to -ffunction-sections.
292  bool getFunctionSections() const {
293  return Options.FunctionSections;
294  }
295 
296  /// Return true if visibility attribute should not be emitted in XCOFF,
297  /// corresponding to -mignore-xcoff-visibility.
300  }
301 
302  /// Return true if XCOFF traceback table should be emitted,
303  /// corresponding to -xcoff-traceback-table.
305 
306  /// If basic blocks should be emitted into their own section,
307  /// corresponding to -fbasic-block-sections.
309  return Options.BBSections;
310  }
311 
312  /// Get the list of functions and basic block ids that need unique sections.
314  return Options.BBSectionsFuncListBuf.get();
315  }
316 
317  /// Returns true if a cast between SrcAS and DestAS is a noop.
318  virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const {
319  return false;
320  }
321 
322  void setPGOOption(std::optional<PGOOptions> PGOOpt) { PGOOption = PGOOpt; }
323  const std::optional<PGOOptions> &getPGOOption() const { return PGOOption; }
324 
325  /// If the specified generic pointer could be assumed as a pointer to a
326  /// specific address space, return that address space.
327  ///
328  /// Under offloading programming, the offloading target may be passed with
329  /// values only prepared on the host side and could assume certain
330  /// properties.
331  virtual unsigned getAssumedAddrSpace(const Value *V) const { return -1; }
332 
333  /// If the specified predicate checks whether a generic pointer falls within
334  /// a specified address space, return that generic pointer and the address
335  /// space being queried.
336  ///
337  /// Such predicates could be specified in @llvm.assume intrinsics for the
338  /// optimizer to assume that the given generic pointer always falls within
339  /// the address space based on that predicate.
340  virtual std::pair<const Value *, unsigned>
341  getPredicatedAddrSpace(const Value *V) const {
342  return std::make_pair(nullptr, -1);
343  }
344 
345  /// Get a \c TargetIRAnalysis appropriate for the target.
346  ///
347  /// This is used to construct the new pass manager's target IR analysis pass,
348  /// set up appropriately for this target machine. Even the old pass manager
349  /// uses this to answer queries about the IR.
351 
352  /// Return a TargetTransformInfo for a given function.
353  ///
354  /// The returned TargetTransformInfo is specialized to the subtarget
355  /// corresponding to \p F.
357 
358  /// Allow the target to modify the pass pipeline.
360 
361  /// Allow the target to register alias analyses with the AAManager for use
362  /// with the new pass manager. Only affects the "default" AAManager.
364 
365  /// Add passes to the specified pass manager to get the specified file
366  /// emitted. Typically this will involve several steps of code generation.
367  /// This method should return true if emission of this file type is not
368  /// supported, or false on success.
369  /// \p MMIWP is an optional parameter that, if set to non-nullptr,
370  /// will be used to set the MachineModuloInfo for this PM.
371  virtual bool
374  bool /*DisableVerify*/ = true,
375  MachineModuleInfoWrapperPass *MMIWP = nullptr) {
376  return true;
377  }
378 
379  /// Add passes to the specified pass manager to get machine code emitted with
380  /// the MCJIT. This method returns true if machine code is not supported. It
381  /// fills the MCContext Ctx pointer which can be used to build custom
382  /// MCStreamer.
383  ///
386  bool /*DisableVerify*/ = true) {
387  return true;
388  }
389 
390  /// True if subtarget inserts the final scheduling pass on its own.
391  ///
392  /// Branch relaxation, which must happen after block placement, can
393  /// on some targets (e.g. SystemZ) expose additional post-RA
394  /// scheduling opportunities.
395  virtual bool targetSchedulesPostRAScheduling() const { return false; };
396 
398  Mangler &Mang, bool MayAlwaysUsePrivate = false) const;
399  MCSymbol *getSymbol(const GlobalValue *GV) const;
400 
401  /// The integer bit size to use for SjLj based exception handling.
402  static constexpr unsigned DefaultSjLjDataSize = 32;
403  virtual unsigned getSjLjDataSize() const { return DefaultSjLjDataSize; }
404 
405  static std::pair<int, int> parseBinutilsVersion(StringRef Version);
406 
407  /// getAddressSpaceForPseudoSourceKind - Given the kind of memory
408  /// (e.g. stack) the target returns the corresponding address space.
409  virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const {
410  return 0;
411  }
412 };
413 
414 /// This class describes a target machine that is implemented with the LLVM
415 /// target-independent code generator.
416 ///
418 protected: // Can only create subclasses.
419  LLVMTargetMachine(const Target &T, StringRef DataLayoutString,
420  const Triple &TT, StringRef CPU, StringRef FS,
423 
424  void initAsmInfo();
425 
426 public:
427  /// Get a TargetTransformInfo implementation for the target.
428  ///
429  /// The TTI returned uses the common code generator to answer queries about
430  /// the IR.
431  TargetTransformInfo getTargetTransformInfo(const Function &F) const override;
432 
433  /// Create a pass configuration object to be used by addPassToEmitX methods
434  /// for generating a pipeline of CodeGen passes.
436 
437  /// Add passes to the specified pass manager to get the specified file
438  /// emitted. Typically this will involve several steps of code generation.
439  /// \p MMIWP is an optional parameter that, if set to non-nullptr,
440  /// will be used to set the MachineModuloInfo for this PM.
441  bool
444  bool DisableVerify = true,
445  MachineModuleInfoWrapperPass *MMIWP = nullptr) override;
446 
453  return make_error<StringError>("buildCodeGenPipeline is not overridden",
455  }
456 
457  virtual std::pair<StringRef, bool> getPassNameFromLegacyName(StringRef) {
459  "getPassNameFromLegacyName parseMIRPipeline is not overridden");
460  }
461 
462  /// Add passes to the specified pass manager to get machine code emitted with
463  /// the MCJIT. This method returns true if machine code is not supported. It
464  /// fills the MCContext Ctx pointer which can be used to build custom
465  /// MCStreamer.
467  raw_pwrite_stream &Out,
468  bool DisableVerify = true) override;
469 
470  /// Returns true if the target is expected to pass all machine verifier
471  /// checks. This is a stopgap measure to fix targets one by one. We will
472  /// remove this at some point and always enable the verifier when
473  /// EXPENSIVE_CHECKS is enabled.
474  virtual bool isMachineVerifierClean() const { return true; }
475 
476  /// Adds an AsmPrinter pass to the pipeline that prints assembly or
477  /// machine code from the MI representation.
480  MCContext &Context);
481 
485 
486  /// True if the target uses physical regs (as nearly all targets do). False
487  /// for stack machines such as WebAssembly and other virtual-register
488  /// machines. If true, all vregs must be allocated before PEI. If false, then
489  /// callee-save register spilling and scavenging are not needed or used. If
490  /// false, implicitly defined registers will still be assumed to be physical
491  /// registers, except that variadic defs will be allocated vregs.
492  virtual bool usesPhysRegsForValues() const { return true; }
493 
494  /// True if the target wants to use interprocedural register allocation by
495  /// default. The -enable-ipra flag can be used to override this.
496  virtual bool useIPRA() const {
497  return false;
498  }
499 
500  /// The default variant to use in unqualified `asm` instructions.
501  /// If this returns 0, `asm "$(foo$|bar$)"` will evaluate to `asm "foo"`.
502  virtual int unqualifiedInlineAsmVariant() const { return 0; }
503 };
504 
505 /// Helper method for getting the code model, returning Default if
506 /// CM does not have a value. The tiny and kernel models will produce
507 /// an error, so targets that support them or require more complex codemodel
508 /// selection logic should implement and call their own getEffectiveCodeModel.
509 inline CodeModel::Model
510 getEffectiveCodeModel(std::optional<CodeModel::Model> CM,
511  CodeModel::Model Default) {
512  if (CM) {
513  // By default, targets do not support the tiny and kernel models.
514  if (*CM == CodeModel::Tiny)
515  report_fatal_error("Target does not support the tiny CodeModel", false);
516  if (*CM == CodeModel::Kernel)
517  report_fatal_error("Target does not support the kernel CodeModel", false);
518  return *CM;
519  }
520  return Default;
521 }
522 
523 } // end namespace llvm
524 
525 #endif // LLVM_TARGET_TARGETMACHINE_H
llvm::TargetMachine::requiresStructuredCFG
bool requiresStructuredCFG() const
Definition: TargetMachine.h:224
llvm::TargetMachine::getOptLevel
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
Definition: TargetMachine.cpp:182
llvm::AAManager
A manager for alias analyses.
Definition: AliasAnalysis.h:885
llvm::LLVMTargetMachine::unqualifiedInlineAsmVariant
virtual int unqualifiedInlineAsmVariant() const
The default variant to use in unqualified asm instructions.
Definition: TargetMachine.h:502
llvm::TargetIRAnalysis
Analysis pass providing the TargetTransformInfo.
Definition: TargetTransformInfo.h:2607
llvm::TargetMachine::getPointerSizeInBits
unsigned getPointerSizeInBits(unsigned AS) const
Definition: TargetMachine.h:195
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::MCSymbol
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
llvm::TargetMachine::STI
std::unique_ptr< const MCSubtargetInfo > STI
Definition: TargetMachine.h:109
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:114
llvm::TargetMachine::useEmulatedTLS
bool useEmulatedTLS() const
Returns true if this target uses emulated TLS.
Definition: TargetMachine.cpp:146
llvm::TargetMachine::getUniqueBasicBlockSectionNames
bool getUniqueBasicBlockSectionNames() const
Return true if unique basic block section names must be generated.
Definition: TargetMachine.h:280
llvm::TargetOptions
Definition: TargetOptions.h:124
llvm::TargetMachine::targetSchedulesPostRAScheduling
virtual bool targetSchedulesPostRAScheduling() const
True if subtarget inserts the final scheduling pass on its own.
Definition: TargetMachine.h:395
llvm::DataLayout::getProgramAddressSpace
unsigned getProgramAddressSpace() const
Definition: DataLayout.h:296
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:76
llvm::Function
Definition: Function.h:59
StringRef.h
llvm::TargetMachine::createDataLayout
const DataLayout createDataLayout() const
Create a DataLayout.
Definition: TargetMachine.h:177
llvm::LLVMTargetMachine::usesPhysRegsForValues
virtual bool usesPhysRegsForValues() const
True if the target uses physical regs (as nearly all targets do).
Definition: TargetMachine.h:492
llvm::TargetOptions::EnableAIXExtendedAltivecABI
unsigned EnableAIXExtendedAltivecABI
EnableAIXExtendedAltivecABI - This flag returns true when -vec-extabi is specified.
Definition: TargetOptions.h:198
llvm::yaml::MachineFunctionInfo
Targets should override this in a way that mirrors the implementation of llvm::MachineFunctionInfo.
Definition: MIRYamlMapping.h:677
llvm::TargetMachine::TheTarget
const Target & TheTarget
The Target that this machine was created for.
Definition: TargetMachine.h:85
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:149
llvm::LLVMTargetMachine::buildCodeGenPipeline
virtual Error buildCodeGenPipeline(ModulePassManager &, MachineFunctionPassManager &, MachineFunctionAnalysisManager &, raw_pwrite_stream &, raw_pwrite_stream *, CodeGenFileType, CGPassBuilderOption, PassInstrumentationCallbacks *)
Definition: TargetMachine.h:447
llvm::TargetMachine::getO0WantsFastISel
bool getO0WantsFastISel()
Definition: TargetMachine.h:255
llvm::TargetMachine::getMCRegisterInfo
const MCRegisterInfo * getMCRegisterInfo() const
Definition: TargetMachine.h:215
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:172
llvm::LLVMTargetMachine::createPassConfig
virtual TargetPassConfig * createPassConfig(PassManagerBase &PM)
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Definition: TargetPassConfig.cpp:649
llvm::TargetOptions::BBSectionsFuncListBuf
std::shared_ptr< MemoryBuffer > BBSectionsFuncListBuf
Memory Buffer that contains information on sampled basic blocks and used to selectively generate basi...
Definition: TargetOptions.h:319
Allocator.h
CGPassBuilderOption.h
Error.h
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
llvm::X86AS::FS
@ FS
Definition: X86.h:201
llvm::TargetOptions::BBSections
BasicBlockSection BBSections
Emit basic blocks into separate sections.
Definition: TargetOptions.h:315
llvm::TargetMachine::getRelocationModel
Reloc::Model getRelocationModel() const
Returns the code generation relocation model.
Definition: TargetMachine.cpp:68
llvm::TargetMachine::setSupportsDefaultOutlining
void setSupportsDefaultOutlining(bool Enable)
Definition: TargetMachine.h:264
llvm::TargetMachine::MII
std::unique_ptr< const MCInstrInfo > MII
Definition: TargetMachine.h:108
llvm::LLVMTargetMachine::isMachineVerifierClean
virtual bool isMachineVerifierClean() const
Returns true if the target is expected to pass all machine verifier checks.
Definition: TargetMachine.h:474
llvm::TargetMachine::getUniqueSectionNames
bool getUniqueSectionNames() const
Definition: TargetMachine.h:277
llvm::TargetMachine::RM
Reloc::Model RM
Definition: TargetMachine.h:101
llvm::AMDGPU::Exp::Target
Target
Definition: SIDefines.h:858
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::TargetMachine::setCFIFixup
void setCFIFixup(bool Enable)
Definition: TargetMachine.h:271
llvm::Expected
Tagged union holding either a T or a Error.
Definition: APFloat.h:41
llvm::CodeModel::Kernel
@ Kernel
Definition: CodeGen.h:31
llvm::Mangler
Definition: Mangler.h:27
llvm::TargetMachine::registerPassBuilderCallbacks
virtual void registerPassBuilderCallbacks(PassBuilder &)
Allow the target to modify the pass pipeline.
Definition: TargetMachine.h:359
llvm::MemoryBuffer
This interface provides simple read-only access to a block of memory, and provides simple methods for...
Definition: MemoryBuffer.h:51
llvm::TargetMachine::getXCOFFTracebackTable
bool getXCOFFTracebackTable() const
Return true if XCOFF traceback table should be emitted, corresponding to -xcoff-traceback-table.
Definition: TargetMachine.h:304
F
#define F(x, y, z)
Definition: MD5.cpp:55
llvm::TargetIntrinsicInfo
TargetIntrinsicInfo - Interface to description of machine instruction set.
Definition: TargetIntrinsicInfo.h:29
llvm::TargetMachine::createDefaultFuncInfoYAML
virtual yaml::MachineFunctionInfo * createDefaultFuncInfoYAML() const
Allocate and return a default initialized instance of the YAML representation for the MachineFunction...
Definition: TargetMachine.h:150
llvm::Reloc::Model
Model
Definition: CodeGen.h:25
llvm::TargetLoweringObjectFile
Definition: TargetLoweringObjectFile.h:45
Context
LLVMContext & Context
Definition: NVVMIntrRange.cpp:66
llvm::TargetMachine::operator=
void operator=(const TargetMachine &)=delete
llvm::TargetMachine::getProgramPointerSize
unsigned getProgramPointerSize() const
Definition: TargetMachine.h:199
llvm::TargetMachine::DefaultSjLjDataSize
static constexpr unsigned DefaultSjLjDataSize
The integer bit size to use for SjLj based exception handling.
Definition: TargetMachine.h:402
llvm::TargetMachine::setMachineOutliner
void setMachineOutliner(bool Enable)
Definition: TargetMachine.h:261
llvm::TargetOptions::UniqueSectionNames
unsigned UniqueSectionNames
Definition: TargetOptions.h:274
llvm::TargetMachine::getFunctionSections
bool getFunctionSections() const
Return true if functions should be emitted into their own section, corresponding to -ffunction-sectio...
Definition: TargetMachine.h:292
llvm::TargetMachine::getIntrinsicInfo
virtual const TargetIntrinsicInfo * getIntrinsicInfo() const
If intrinsic information is available, return it. If not, return null.
Definition: TargetMachine.h:220
llvm::TargetMachine::getPGOOption
const std::optional< PGOOptions > & getPGOOption() const
Definition: TargetMachine.h:323
llvm::TargetOptions::SupportsDefaultOutlining
unsigned SupportsDefaultOutlining
Set if the target supports default outlining behaviour.
Definition: TargetOptions.h:309
llvm::PassBuilder
This class provides access to building LLVM's passes.
Definition: PassBuilder.h:96
llvm::SMDiagnostic
Instances of this class encapsulate one diagnostic report, allowing printing to a raw_ostream as a ca...
Definition: SourceMgr.h:281
llvm::TargetMachine::parseBinutilsVersion
static std::pair< int, int > parseBinutilsVersion(StringRef Version)
Definition: TargetMachine.cpp:222
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:31
llvm::TargetMachine::getAssumedAddrSpace
virtual unsigned getAssumedAddrSpace(const Value *V) const
If the specified generic pointer could be assumed as a pointer to a specific address space,...
Definition: TargetMachine.h:331
llvm::TargetMachine::setPGOOption
void setPGOOption(std::optional< PGOOptions > PGOOpt)
Definition: TargetMachine.h:322
llvm::report_fatal_error
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Definition: Error.cpp:145
llvm::LLVMTargetMachine::addPassesToEmitFile
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.
Definition: LLVMTargetMachine.cpp:224
llvm::TargetMachine::parseMachineFunctionInfo
virtual bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &, PerFunctionMIParsingState &PFS, SMDiagnostic &Error, SMRange &SourceRange) const
Parse out the target's MachineFunctionInfo from the YAML reprsentation.
Definition: TargetMachine.h:162
llvm::IndexedInstrProf::Version
const uint64_t Version
Definition: InstrProf.h:1058
llvm::CGPassBuilderOption
Definition: CGPassBuilderOption.h:28
llvm::TargetMachine::getSymbol
MCSymbol * getSymbol(const GlobalValue *GV) const
Definition: TargetMachine.cpp:204
llvm::ModulePassManager
PassManager< Module > ModulePassManager
Convenience typedef for a pass manager over modules.
Definition: PassManager.h:582
llvm::TargetMachine::TargetFS
std::string TargetFS
Definition: TargetMachine.h:99
llvm::MachineFunctionAnalysisManager
An AnalysisManager<MachineFunction> that also exposes IR analysis results.
Definition: MachinePassManager.h:41
llvm::TargetMachine::addPassesToEmitMC
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.
Definition: TargetMachine.h:384
llvm::TargetMachine::setCodeModel
void setCodeModel(CodeModel::Model CM)
Set the code model.
Definition: TargetMachine.h:236
llvm::TargetMachine::resetTargetOptions
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
Definition: TargetMachine.cpp:53
llvm::TargetMachine::O0WantsFastISel
unsigned O0WantsFastISel
Definition: TargetMachine.h:112
llvm::TargetMachine::getMCInstrInfo
const MCInstrInfo * getMCInstrInfo() const
Definition: TargetMachine.h:216
llvm::TargetMachine::isPositionIndependent
bool isPositionIndependent() const
Definition: TargetMachine.cpp:41
llvm::MachO::FileType
FileType
Defines the file type this file represents.
Definition: InterfaceFile.h:53
llvm::CodeModel::Model
Model
Definition: CodeGen.h:31
llvm::TargetPassConfig
Target-Independent Code Generator Pass Configuration Options.
Definition: TargetPassConfig.h:84
llvm::LLVMTargetMachine::addPassesToEmitMC
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.
Definition: LLVMTargetMachine.cpp:254
llvm::TargetOptions::EnableGlobalISel
unsigned EnableGlobalISel
EnableGlobalISel - This flag enables global instruction selection.
Definition: TargetOptions.h:235
llvm::TargetMachine::getAIXExtendedAltivecABI
bool getAIXExtendedAltivecABI() const
Definition: TargetMachine.h:273
llvm::TargetMachine::TargetTriple
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with.
Definition: TargetMachine.h:97
llvm::LLVMTargetMachine::LLVMTargetMachine
LLVMTargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TT, StringRef CPU, StringRef FS, const TargetOptions &Options, Reloc::Model RM, CodeModel::Model CM, CodeGenOpt::Level OL)
Definition: LLVMTargetMachine.cpp:85
llvm::GlobalValue
Definition: GlobalValue.h:44
llvm::TargetMachine::DL
const DataLayout DL
DataLayout for the target: keep ABI type size and alignment.
Definition: TargetMachine.h:93
llvm::TargetMachine::isNoopAddrSpaceCast
virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const
Returns true if a cast between SrcAS and DestAS is a noop.
Definition: TargetMachine.h:318
llvm::TargetMachine::setO0WantsFastISel
void setO0WantsFastISel(bool Enable)
Definition: TargetMachine.h:256
llvm::TargetMachine::DefaultOptions
const TargetOptions DefaultOptions
Definition: TargetMachine.h:118
llvm::TargetMachine::isCompatibleDataLayout
bool isCompatibleDataLayout(const DataLayout &Candidate) const
Test if a DataLayout if compatible with the CodeGen for this target.
Definition: TargetMachine.h:184
llvm::TargetOptions::SupportsDebugEntryValues
unsigned SupportsDebugEntryValues
Set if the target supports the debug entry values by default.
Definition: TargetOptions.h:326
llvm::getEffectiveCodeModel
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.
Definition: TargetMachine.h:510
llvm::TargetMachine::setRequiresStructuredCFG
void setRequiresStructuredCFG(bool Value)
Definition: TargetMachine.h:225
llvm::raw_pwrite_stream
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:428
llvm::LLVMTargetMachine::getTargetTransformInfo
TargetTransformInfo getTargetTransformInfo(const Function &F) const override
Get a TargetTransformInfo implementation for the target.
Definition: LLVMTargetMachine.cpp:101
llvm::MachineModuleInfoWrapperPass
Definition: MachineModuleInfo.h:203
llvm::TargetMachine::getMCSubtargetInfo
const MCSubtargetInfo * getMCSubtargetInfo() const
Definition: TargetMachine.h:217
llvm::BumpPtrAllocatorImpl
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:63
llvm::TargetMachine::OptLevel
CodeGenOpt::Level OptLevel
Definition: TargetMachine.h:103
llvm::TargetMachine::getTargetIRAnalysis
TargetIRAnalysis getTargetIRAnalysis() const
Get a TargetIRAnalysis appropriate for the target.
Definition: TargetMachine.cpp:215
llvm::TargetMachine::getTLSModel
TLSModel::Model getTLSModel(const GlobalValue *GV) const
Returns the TLS model which should be used for the given global variable.
Definition: TargetMachine.cpp:154
Enable
@ Enable
Definition: DwarfDebug.cpp:86
llvm::TargetMachine::Options
TargetOptions Options
Definition: TargetMachine.h:119
llvm::TargetMachine::registerDefaultAliasAnalyses
virtual void registerDefaultAliasAnalyses(AAManager &)
Allow the target to register alias analyses with the AAManager for use with the new pass manager.
Definition: TargetMachine.h:363
llvm::TargetMachine::TargetMachine
TargetMachine(const Target &T, StringRef DataLayoutString, const Triple &TargetTriple, StringRef CPU, StringRef FS, const TargetOptions &Options)
Definition: TargetMachine.cpp:31
llvm::TargetMachine
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:78
Mode
SI Whole Quad Mode
Definition: SIWholeQuadMode.cpp:262
llvm::TargetMachine::getObjFileLowering
virtual TargetLoweringObjectFile * getObjFileLowering() const
Definition: TargetMachine.h:137
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
llvm::TargetMachine::setTargetFeatureString
void setTargetFeatureString(StringRef FS)
Definition: TargetMachine.h:130
llvm::GlobalISelAbortMode
GlobalISelAbortMode
Enable abort calls when global instruction selection fails to lower/select an instruction.
Definition: TargetOptions.h:107
llvm::TargetOptions::EnableFastISel
unsigned EnableFastISel
EnableFastISel - This flag enables fast-path instruction selection which trades away generated code q...
Definition: TargetOptions.h:232
llvm::TargetMachine::getIgnoreXCOFFVisibility
bool getIgnoreXCOFFVisibility() const
Return true if visibility attribute should not be emitted in XCOFF, corresponding to -mignore-xcoff-v...
Definition: TargetMachine.h:298
llvm::MachineFunction
Definition: MachineFunction.h:258
llvm::TargetOptions::IgnoreXCOFFVisibility
unsigned IgnoreXCOFFVisibility
Do not emit visibility attribute for xcoff.
Definition: TargetOptions.h:269
TargetOptions.h
llvm::TargetMachine::getMCAsmInfo
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
Definition: TargetMachine.h:213
Triple.h
llvm::TargetMachine::getAddressSpaceForPseudoSourceKind
virtual unsigned getAddressSpaceForPseudoSourceKind(unsigned Kind) const
getAddressSpaceForPseudoSourceKind - Given the kind of memory (e.g.
Definition: TargetMachine.h:409
DataLayout.h
llvm::CodeGenFileType
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition: CodeGen.h:84
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
llvm::TargetMachine::getPredicatedAddrSpace
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,...
Definition: TargetMachine.h:341
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:143
llvm::Reloc::Static
@ Static
Definition: CodeGen.h:25
llvm::TargetMachine::addPassesToEmitFile
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.
Definition: TargetMachine.h:372
llvm::TargetMachine::getTargetFeatureString
StringRef getTargetFeatureString() const
Definition: TargetMachine.h:129
llvm::TargetMachine::shouldAssumeDSOLocal
bool shouldAssumeDSOLocal(const Module &M, const GlobalValue *GV) const
Definition: TargetMachine.cpp:88
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
llvm::TargetMachine::setFastISel
void setFastISel(bool Enable)
Definition: TargetMachine.h:254
llvm::DataLayout::getAllocaAddrSpace
unsigned getAllocaAddrSpace() const
Definition: DataLayout.h:283
llvm::CodeModel::Tiny
@ Tiny
Definition: CodeGen.h:31
llvm::TargetSubtargetInfo
TargetSubtargetInfo - Generic base class for all target subtargets.
Definition: TargetSubtargetInfo.h:62
llvm::LLVMTargetMachine::initAsmInfo
void initAsmInfo()
Definition: LLVMTargetMachine.cpp:40
llvm::TargetOptions::XCOFFTracebackTable
unsigned XCOFFTracebackTable
Emit XCOFF traceback table.
Definition: TargetOptions.h:272
llvm::PassManager< Module >
llvm::PerFunctionMIParsingState
Definition: MIParser.h:162
llvm::TargetMachine::convertFuncInfoToYAML
virtual yaml::MachineFunctionInfo * convertFuncInfoToYAML(const MachineFunction &MF) const
Allocate and initialize an instance of the YAML representation of the MachineFunctionInfo.
Definition: TargetMachine.h:157
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
llvm::TargetMachine::RequireStructuredCFG
unsigned RequireStructuredCFG
Definition: TargetMachine.h:111
llvm::inconvertibleErrorCode
std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition: Error.cpp:79
llvm::TargetMachine::getNameWithPrefix
void getNameWithPrefix(SmallVectorImpl< char > &Name, const GlobalValue *GV, Mangler &Mang, bool MayAlwaysUsePrivate=false) const
Definition: TargetMachine.cpp:191
llvm::TargetMachine::setGlobalISelAbort
void setGlobalISelAbort(GlobalISelAbortMode Mode)
Definition: TargetMachine.h:258
llvm::TargetOptions::UniqueBasicBlockSectionNames
unsigned UniqueBasicBlockSectionNames
Use unique names for basic block sections.
Definition: TargetOptions.h:277
llvm::TargetOptions::GlobalISelAbort
GlobalISelAbortMode GlobalISelAbort
EnableGlobalISelAbort - Control abort behaviour when global instruction selection fails to lower/sele...
Definition: TargetOptions.h:239
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:156
llvm::TargetMachine::PGOOption
std::optional< PGOOptions > PGOOption
Definition: TargetMachine.h:115
PGOOptions.h
llvm::TargetStackID::Value
Value
Definition: TargetFrameLowering.h:27
PassManager.h
llvm::TargetOptions::DataSections
unsigned DataSections
Emit data into separate sections.
Definition: TargetOptions.h:266
llvm::TargetMachine::createMachineFunctionInfo
virtual MachineFunctionInfo * createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F, const TargetSubtargetInfo *STI) const
Create the target's instance of MachineFunctionInfo.
Definition: TargetMachine.h:143
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:417
llvm::TLSModel::Model
Model
Definition: CodeGen.h:45
llvm::TargetMachine::setGlobalISel
void setGlobalISel(bool Enable)
Definition: TargetMachine.h:257
llvm::TargetOptions::EnableMachineOutliner
unsigned EnableMachineOutliner
Enables the MachineOutliner pass.
Definition: TargetOptions.h:303
llvm::MachineFunctionPassManager
MachineFunctionPassManager adds/removes below features to/from the base PassManager template instanti...
Definition: MachinePassManager.h:132
llvm::TargetMachine::getAllocaPointerSize
unsigned getAllocaPointerSize() const
Definition: TargetMachine.h:203
llvm::TargetMachine::getBBSectionsFuncListBuf
const MemoryBuffer * getBBSectionsFuncListBuf() const
Get the list of functions and basic block ids that need unique sections.
Definition: TargetMachine.h:313
CodeGen.h
llvm::TargetMachine::CMModel
CodeModel::Model CMModel
Definition: TargetMachine.h:102
llvm::TargetMachine::~TargetMachine
virtual ~TargetMachine()
llvm::TargetMachine::getTargetCPU
StringRef getTargetCPU() const
Definition: TargetMachine.h:128
llvm::TargetMachine::getSubtargetImpl
virtual const TargetSubtargetInfo * getSubtargetImpl(const Function &) const
Virtual method implemented by subclasses that returns a reference to that target's TargetSubtargetInf...
Definition: TargetMachine.h:134
llvm::BasicBlockSection
BasicBlockSection
Definition: TargetOptions.h:61
llvm::PassInstrumentationCallbacks
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Definition: PassInstrumentation.h:66
llvm::TargetMachine::getSubtarget
const STC & getSubtarget(const Function &F) const
This method returns a pointer to the specified type of TargetSubtargetInfo.
Definition: TargetMachine.h:172
Allocator
Basic Register Allocator
Definition: RegAllocBasic.cpp:143
llvm::SMRange
Represents a range in source code.
Definition: SMLoc.h:48
llvm::LLVMTargetMachine::getPassNameFromLegacyName
virtual std::pair< StringRef, bool > getPassNameFromLegacyName(StringRef)
Definition: TargetMachine.h:457
llvm::TargetMachine::AsmInfo
std::unique_ptr< const MCAsmInfo > AsmInfo
Contains target specific asm information.
Definition: TargetMachine.h:106
llvm::TargetMachine::getTargetTriple
const Triple & getTargetTriple() const
Definition: TargetMachine.h:127
llvm::legacy::PassManagerBase
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
Definition: LegacyPassManager.h:39
llvm::SmallVectorImpl< char >
llvm::DataLayout::getPointerSizeInBits
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:413
llvm::CodeGenOpt::Level
Level
Code generation optimization level.
Definition: CodeGen.h:57
llvm::TargetMachine::getCodeModel
CodeModel::Model getCodeModel() const
Returns the code model.
Definition: TargetMachine.h:233
llvm::TargetMachine::setSupportsDebugEntryValues
void setSupportsDebugEntryValues(bool Enable)
Definition: TargetMachine.h:267
llvm::TargetOptions::FunctionSections
unsigned FunctionSections
Emit functions into separate sections.
Definition: TargetOptions.h:263
llvm::TargetMachine::setOptLevel
void setOptLevel(CodeGenOpt::Level Level)
Overrides the optimization level.
Definition: TargetMachine.cpp:184
llvm::TargetMachine::getTarget
const Target & getTarget() const
Definition: TargetMachine.h:125
llvm::TargetMachine::getTargetTransformInfo
virtual TargetTransformInfo getTargetTransformInfo(const Function &F) const
Return a TargetTransformInfo for a given function.
Definition: TargetMachine.cpp:187
llvm::TargetMachine::getPointerSize
unsigned getPointerSize(unsigned AS) const
Get the pointer size for this target.
Definition: TargetMachine.h:191
llvm::TargetOptions::EnableCFIFixup
unsigned EnableCFIFixup
Enable the CFIFixup pass.
Definition: TargetOptions.h:361
llvm::MachineFunctionInfo
MachineFunctionInfo - This class can be derived from and used by targets to hold private target-speci...
Definition: MachineFunction.h:95
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:76
llvm::LLVMTargetMachine::useIPRA
virtual bool useIPRA() const
True if the target wants to use interprocedural register allocation by default.
Definition: TargetMachine.h:496
llvm::TargetMachine::MRI
std::unique_ptr< const MCRegisterInfo > MRI
Definition: TargetMachine.h:107
llvm::Value
LLVM Value Representation.
Definition: Value.h:74
llvm::LLVMTargetMachine::createMCStreamer
Expected< std::unique_ptr< MCStreamer > > createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType, MCContext &Ctx)
Definition: LLVMTargetMachine.cpp:145
llvm::TargetMachine::getSjLjDataSize
virtual unsigned getSjLjDataSize() const
Definition: TargetMachine.h:403
llvm::TargetMachine::TargetCPU
std::string TargetCPU
Definition: TargetMachine.h:98
llvm::codeview::PublicSymFlags::Function
@ Function
llvm::ISD::MCSymbol
@ MCSymbol
Definition: ISDOpcodes.h:172
llvm::CodeGenOpt::Default
@ Default
-O2, -Os
Definition: CodeGen.h:60
llvm::TargetMachine::getBBSectionsType
llvm::BasicBlockSection getBBSectionsType() const
If basic blocks should be emitted into their own section, corresponding to -fbasic-block-sections.
Definition: TargetMachine.h:308
llvm::DataLayout::getPointerSize
unsigned getPointerSize(unsigned AS=0) const
Layout pointer size in bytes, rounded up to a whole number of bytes.
Definition: DataLayout.cpp:711
llvm::LLVMTargetMachine::addAsmPrinter
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...
Definition: LLVMTargetMachine.cpp:125
llvm::TargetMachine::getDataSections
bool getDataSections() const
Return true if data objects should be emitted into their own section, corresponds to -fdata-sections.
Definition: TargetMachine.h:286