xref: /freebsd/contrib/llvm-project/llvm/include/llvm/Target/TargetMachine.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
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"
19 #include "llvm/Support/Allocator.h"
20 #include "llvm/Support/CodeGen.h"
21 #include "llvm/Support/CommandLine.h"
22 #include "llvm/Support/Compiler.h"
23 #include "llvm/Support/Error.h"
24 #include "llvm/Support/PGOOptions.h"
25 #include "llvm/Target/CGPassBuilderOption.h"
26 #include "llvm/Target/TargetOptions.h"
27 #include "llvm/TargetParser/Triple.h"
28 #include <optional>
29 #include <string>
30 #include <utility>
31 
32 LLVM_ABI extern llvm::cl::opt<bool> NoKernelInfoEndLTO;
33 
34 namespace llvm {
35 
36 class AAManager;
37 using ModulePassManager = PassManager<Module>;
38 
39 class Function;
40 class GlobalValue;
41 class MachineInstr;
42 class MachineModuleInfoWrapperPass;
43 struct MachineSchedContext;
44 class Mangler;
45 class MCAsmInfo;
46 class MCContext;
47 class MCInstrInfo;
48 class MCRegisterInfo;
49 class MCStreamer;
50 class MCSubtargetInfo;
51 class MCSymbol;
52 class raw_pwrite_stream;
53 class PassBuilder;
54 class PassInstrumentationCallbacks;
55 struct PerFunctionMIParsingState;
56 class ScheduleDAGInstrs;
57 class SMDiagnostic;
58 class SMRange;
59 class Target;
60 class TargetIRAnalysis;
61 class TargetTransformInfo;
62 class TargetLoweringObjectFile;
63 class TargetPassConfig;
64 class TargetSubtargetInfo;
65 
66 // The old pass manager infrastructure is hidden in a legacy namespace now.
67 namespace legacy {
68 class PassManagerBase;
69 } // namespace legacy
70 using legacy::PassManagerBase;
71 
72 struct MachineFunctionInfo;
73 namespace yaml {
74 struct 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 ///
83 class LLVM_ABI TargetMachine {
84 protected: // 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.
90   const Target &TheTarget;
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.
98   const DataLayout DL;
99 
100   /// Triple string, CPU name, and target feature strings the TargetMachine
101   /// instance is created with.
102   Triple TargetTriple;
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 
117   unsigned RequireStructuredCFG : 1;
118   unsigned O0WantsFastISel : 1;
119 
120   // PGO related tunables.
121   std::optional<PGOOptions> PGOOption;
122 
123 public:
124   mutable TargetOptions Options;
125 
126   TargetMachine(const TargetMachine &) = delete;
127   void operator=(const TargetMachine &) = delete;
128   virtual ~TargetMachine();
129 
getTarget()130   const Target &getTarget() const { return TheTarget; }
131 
getTargetTriple()132   const Triple &getTargetTriple() const { return TargetTriple; }
getTargetCPU()133   StringRef getTargetCPU() const { return TargetCPU; }
getTargetFeatureString()134   StringRef getTargetFeatureString() const { return TargetFS; }
setTargetFeatureString(StringRef FS)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.
getSubtargetImpl(const Function &)139   virtual const TargetSubtargetInfo *getSubtargetImpl(const Function &) const {
140     return nullptr;
141   }
getObjFileLowering()142   virtual TargetLoweringObjectFile *getObjFileLowering() const {
143     return nullptr;
144   }
145 
146   /// Create the target's instance of MachineFunctionInfo
147   virtual MachineFunctionInfo *
createMachineFunctionInfo(BumpPtrAllocator & Allocator,const Function & F,const TargetSubtargetInfo * STI)148   createMachineFunctionInfo(BumpPtrAllocator &Allocator, const Function &F,
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 *
createMachineScheduler(MachineSchedContext * C)164   createMachineScheduler(MachineSchedContext *C) const {
165     return nullptr;
166   }
167 
168   /// Similar to createMachineScheduler but used when postRA machine scheduling
169   /// is enabled.
170   virtual ScheduleDAGInstrs *
createPostMachineScheduler(MachineSchedContext * C)171   createPostMachineScheduler(MachineSchedContext *C) const {
172     return nullptr;
173   }
174 
175   /// Allocate and return a default initialized instance of the YAML
176   /// representation for the MachineFunctionInfo.
createDefaultFuncInfoYAML()177   virtual yaml::MachineFunctionInfo *createDefaultFuncInfoYAML() const {
178     return nullptr;
179   }
180 
181   /// Allocate and initialize an instance of the YAML representation of the
182   /// MachineFunctionInfo.
183   virtual yaml::MachineFunctionInfo *
convertFuncInfoToYAML(const MachineFunction & MF)184   convertFuncInfoToYAML(const MachineFunction &MF) const {
185     return nullptr;
186   }
187 
188   /// Parse out the target's MachineFunctionInfo from the YAML reprsentation.
parseMachineFunctionInfo(const yaml::MachineFunctionInfo &,PerFunctionMIParsingState & PFS,SMDiagnostic & Error,SMRange & SourceRange)189   virtual bool parseMachineFunctionInfo(const yaml::MachineFunctionInfo &,
190                                         PerFunctionMIParsingState &PFS,
191                                         SMDiagnostic &Error,
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.
getSubtarget(const Function & F)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.
createDataLayout()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.
isCompatibleDataLayout(const DataLayout & Candidate)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.
getPointerSize(unsigned AS)218   unsigned getPointerSize(unsigned AS) const {
219     return DL.getPointerSize(AS);
220   }
221 
getPointerSizeInBits(unsigned AS)222   unsigned getPointerSizeInBits(unsigned AS) const {
223     return DL.getPointerSizeInBits(AS);
224   }
225 
getProgramPointerSize()226   unsigned getProgramPointerSize() const {
227     return DL.getPointerSize(DL.getProgramAddressSpace());
228   }
229 
getAllocaPointerSize()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.
getMCAsmInfo()240   const MCAsmInfo *getMCAsmInfo() const { return AsmInfo.get(); }
241 
getMCRegisterInfo()242   const MCRegisterInfo *getMCRegisterInfo() const { return MRI.get(); }
getMCInstrInfo()243   const MCInstrInfo *getMCInstrInfo() const { return MII.get(); }
getMCSubtargetInfo()244   const MCSubtargetInfo *getMCSubtargetInfo() const { return STI.get(); }
245 
246   /// Return the ExceptionHandling to use, considering TargetOptions and the
247   /// Triple's default.
getExceptionModel()248   ExceptionHandling getExceptionModel() const {
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 
requiresStructuredCFG()255   bool requiresStructuredCFG() const { return RequireStructuredCFG; }
setRequiresStructuredCFG(bool Value)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.
getCodeModel()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.
setCodeModel(CodeModel::Model CM)270   void setCodeModel(CodeModel::Model CM) { CMModel = CM; }
271 
setLargeDataThreshold(uint64_t LDT)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.
getOptLevel()289   CodeGenOptLevel getOptLevel() const { return OptLevel; }
290 
291   /// Overrides the optimization level.
setOptLevel(CodeGenOptLevel Level)292   void setOptLevel(CodeGenOptLevel Level) { OptLevel = Level; }
293 
setFastISel(bool Enable)294   void setFastISel(bool Enable) { Options.EnableFastISel = Enable; }
getO0WantsFastISel()295   bool getO0WantsFastISel() { return O0WantsFastISel; }
setO0WantsFastISel(bool Enable)296   void setO0WantsFastISel(bool Enable) { O0WantsFastISel = Enable; }
setGlobalISel(bool Enable)297   void setGlobalISel(bool Enable) { Options.EnableGlobalISel = Enable; }
setGlobalISelAbort(GlobalISelAbortMode Mode)298   void setGlobalISelAbort(GlobalISelAbortMode Mode) {
299     Options.GlobalISelAbort = Mode;
300   }
setMachineOutliner(bool Enable)301   void setMachineOutliner(bool Enable) {
302     Options.EnableMachineOutliner = Enable;
303   }
setSupportsDefaultOutlining(bool Enable)304   void setSupportsDefaultOutlining(bool Enable) {
305     Options.SupportsDefaultOutlining = Enable;
306   }
setSupportsDebugEntryValues(bool Enable)307   void setSupportsDebugEntryValues(bool Enable) {
308     Options.SupportsDebugEntryValues = Enable;
309   }
310 
setCFIFixup(bool Enable)311   void setCFIFixup(bool Enable) { Options.EnableCFIFixup = Enable; }
312 
getAIXExtendedAltivecABI()313   bool getAIXExtendedAltivecABI() const {
314     return Options.EnableAIXExtendedAltivecABI;
315   }
316 
getUniqueSectionNames()317   bool getUniqueSectionNames() const { return Options.UniqueSectionNames; }
318 
319   /// Return true if unique basic block section names must be generated.
getUniqueBasicBlockSectionNames()320   bool getUniqueBasicBlockSectionNames() const {
321     return Options.UniqueBasicBlockSectionNames;
322   }
323 
getSeparateNamedSections()324   bool getSeparateNamedSections() const {
325     return Options.SeparateNamedSections;
326   }
327 
328   /// Return true if data objects should be emitted into their own section,
329   /// corresponds to -fdata-sections.
getDataSections()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.
getFunctionSections()336   bool getFunctionSections() const {
337     return Options.FunctionSections;
338   }
339 
getEnableStaticDataPartitioning()340   bool getEnableStaticDataPartitioning() const {
341     return Options.EnableStaticDataPartitioning;
342   }
343 
344   /// Return true if visibility attribute should not be emitted in XCOFF,
345   /// corresponding to -mignore-xcoff-visibility.
getIgnoreXCOFFVisibility()346   bool getIgnoreXCOFFVisibility() const {
347     return Options.IgnoreXCOFFVisibility;
348   }
349 
350   /// Return true if XCOFF traceback table should be emitted,
351   /// corresponding to -xcoff-traceback-table.
getXCOFFTracebackTable()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.
getBBSectionsType()356   llvm::BasicBlockSection getBBSectionsType() const {
357     return Options.BBSections;
358   }
359 
360   /// Get the list of functions and basic block ids that need unique sections.
getBBSectionsFuncListBuf()361   const MemoryBuffer *getBBSectionsFuncListBuf() const {
362     return Options.BBSectionsFuncListBuf.get();
363   }
364 
365   /// Returns true if a cast between SrcAS and DestAS is a noop.
isNoopAddrSpaceCast(unsigned SrcAS,unsigned DestAS)366   virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const {
367     return false;
368   }
369 
setPGOOption(std::optional<PGOOptions> PGOOpt)370   void setPGOOption(std::optional<PGOOptions> PGOOpt) { PGOOption = PGOOpt; }
getPGOOption()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.
getAssumedAddrSpace(const Value * V)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>
getPredicatedAddrSpace(const Value * V)389   getPredicatedAddrSpace(const Value *V) const {
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.
registerPassBuilderCallbacks(PassBuilder &)408   virtual void registerPassBuilderCallbacks(PassBuilder &) {}
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.
registerEarlyDefaultAliasAnalyses(AAManager &)413   virtual void registerEarlyDefaultAliasAnalyses(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.
registerDefaultAliasAnalyses(AAManager &)417   virtual void registerDefaultAliasAnalyses(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
426   addPassesToEmitFile(PassManagerBase &, raw_pwrite_stream &,
427                       raw_pwrite_stream *, CodeGenFileType,
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   ///
438   virtual bool addPassesToEmitMC(PassManagerBase &, MCContext *&,
439                                  raw_pwrite_stream &,
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.
targetSchedulesPostRAScheduling()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;
getSjLjDataSize()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.
getAddressSpaceForPseudoSourceKind(unsigned Kind)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.
splitModule(Module & M,unsigned NumParts,function_ref<void (std::unique_ptr<Module> MPart)> ModuleCallback)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.
createPassConfig(PassManagerBase & PM)484   virtual TargetPassConfig *createPassConfig(PassManagerBase &PM) {
485     return nullptr;
486   }
487 
buildCodeGenPipeline(ModulePassManager &,raw_pwrite_stream &,raw_pwrite_stream *,CodeGenFileType,const CGPassBuilderOption &,PassInstrumentationCallbacks *)488   virtual Error buildCodeGenPipeline(ModulePassManager &, raw_pwrite_stream &,
489                                      raw_pwrite_stream *, CodeGenFileType,
490                                      const CGPassBuilderOption &,
491                                      PassInstrumentationCallbacks *) {
492     return make_error<StringError>("buildCodeGenPipeline is not overridden",
493                                    inconvertibleErrorCode());
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.
isMachineVerifierClean()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.
addAsmPrinter(PassManagerBase & PM,raw_pwrite_stream & Out,raw_pwrite_stream * DwoOut,CodeGenFileType FileType,MCContext & Context)504   virtual bool addAsmPrinter(PassManagerBase &PM, raw_pwrite_stream &Out,
505                              raw_pwrite_stream *DwoOut,
506                              CodeGenFileType FileType, MCContext &Context) {
507     return false;
508   }
509 
510   virtual Expected<std::unique_ptr<MCStreamer>>
511   createMCStreamer(raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut,
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.
usesPhysRegsForValues()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.
useIPRA()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"`.
unqualifiedInlineAsmVariant()528   virtual int unqualifiedInlineAsmVariant() const { return 0; }
529 
530   // MachineRegisterInfo callback function
registerMachineRegisterInfoCallback(MachineFunction & MF)531   virtual void registerMachineRegisterInfoCallback(MachineFunction &MF) const {}
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.
clearLinkerOptimizationHints(const SmallPtrSetImpl<MachineInstr * > & MIs)537   virtual size_t clearLinkerOptimizationHints(
538       const SmallPtrSetImpl<MachineInstr *> &MIs) const {
539     return 0;
540   }
541 };
542 
543 } // end namespace llvm
544 
545 #endif // LLVM_TARGET_TARGETMACHINE_H
546