TargetSubtargetInfo.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. //==-- llvm/Target/TargetSubtargetInfo.h - Target Information ----*- C++ -*-==//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file describes the subtarget options of a Target machine.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_TARGET_TARGETSUBTARGETINFO_H
  14. #define LLVM_TARGET_TARGETSUBTARGETINFO_H
  15. #include "llvm/CodeGen/PBQPRAConstraint.h"
  16. #include "llvm/MC/MCSubtargetInfo.h"
  17. #include "llvm/Support/CodeGen.h"
  18. namespace llvm {
  19. class DataLayout;
  20. class MachineFunction;
  21. class MachineInstr;
  22. class SDep;
  23. class SUnit;
  24. class TargetFrameLowering;
  25. class TargetInstrInfo;
  26. class TargetLowering;
  27. class TargetRegisterClass;
  28. class TargetRegisterInfo;
  29. class TargetSchedModel;
  30. class TargetSelectionDAGInfo;
  31. struct MachineSchedPolicy;
  32. template <typename T> class SmallVectorImpl;
  33. // //
  34. ///////////////////////////////////////////////////////////////////////////////
  35. ///
  36. /// TargetSubtargetInfo - Generic base class for all target subtargets. All
  37. /// Target-specific options that control code generation and printing should
  38. /// be exposed through a TargetSubtargetInfo-derived class.
  39. ///
  40. class TargetSubtargetInfo : public MCSubtargetInfo {
  41. TargetSubtargetInfo(const TargetSubtargetInfo &) = delete;
  42. void operator=(const TargetSubtargetInfo &) = delete;
  43. TargetSubtargetInfo() = delete;
  44. protected: // Can only create subclasses...
  45. TargetSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS,
  46. ArrayRef<SubtargetFeatureKV> PF,
  47. ArrayRef<SubtargetFeatureKV> PD,
  48. const SubtargetInfoKV *ProcSched,
  49. const MCWriteProcResEntry *WPR,
  50. const MCWriteLatencyEntry *WL,
  51. const MCReadAdvanceEntry *RA, const InstrStage *IS,
  52. const unsigned *OC, const unsigned *FP);
  53. public:
  54. // AntiDepBreakMode - Type of anti-dependence breaking that should
  55. // be performed before post-RA scheduling.
  56. typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } AntiDepBreakMode;
  57. typedef SmallVectorImpl<const TargetRegisterClass *> RegClassVector;
  58. virtual ~TargetSubtargetInfo();
  59. // Interfaces to the major aspects of target machine information:
  60. //
  61. // -- Instruction opcode and operand information
  62. // -- Pipelines and scheduling information
  63. // -- Stack frame information
  64. // -- Selection DAG lowering information
  65. //
  66. // N.B. These objects may change during compilation. It's not safe to cache
  67. // them between functions.
  68. virtual const TargetInstrInfo *getInstrInfo() const { return nullptr; }
  69. virtual const TargetFrameLowering *getFrameLowering() const {
  70. return nullptr;
  71. }
  72. virtual const TargetLowering *getTargetLowering() const { return nullptr; }
  73. virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
  74. return nullptr;
  75. }
  76. /// getRegisterInfo - If register information is available, return it. If
  77. /// not, return null. This is kept separate from RegInfo until RegInfo has
  78. /// details of graph coloring register allocation removed from it.
  79. ///
  80. virtual const TargetRegisterInfo *getRegisterInfo() const { return nullptr; }
  81. /// getInstrItineraryData - Returns instruction itinerary data for the target
  82. /// or specific subtarget.
  83. ///
  84. virtual const InstrItineraryData *getInstrItineraryData() const {
  85. return nullptr;
  86. }
  87. /// Resolve a SchedClass at runtime, where SchedClass identifies an
  88. /// MCSchedClassDesc with the isVariant property. This may return the ID of
  89. /// another variant SchedClass, but repeated invocation must quickly terminate
  90. /// in a nonvariant SchedClass.
  91. virtual unsigned resolveSchedClass(unsigned SchedClass,
  92. const MachineInstr *MI,
  93. const TargetSchedModel *SchedModel) const {
  94. return 0;
  95. }
  96. /// \brief True if the subtarget should run MachineScheduler after aggressive
  97. /// coalescing.
  98. ///
  99. /// This currently replaces the SelectionDAG scheduler with the "source" order
  100. /// scheduler (though see below for an option to turn this off and use the
  101. /// TargetLowering preference). It does not yet disable the postRA scheduler.
  102. virtual bool enableMachineScheduler() const;
  103. /// \brief True if the machine scheduler should disable the TLI preference
  104. /// for preRA scheduling with the source level scheduler.
  105. virtual bool enableMachineSchedDefaultSched() const { return true; }
  106. /// \brief True if the subtarget should enable joining global copies.
  107. ///
  108. /// By default this is enabled if the machine scheduler is enabled, but
  109. /// can be overridden.
  110. virtual bool enableJoinGlobalCopies() const;
  111. /// True if the subtarget should run a scheduler after register allocation.
  112. ///
  113. /// By default this queries the PostRAScheduling bit in the scheduling model
  114. /// which is the preferred way to influence this.
  115. virtual bool enablePostRAScheduler() const;
  116. /// \brief True if the subtarget should run the atomic expansion pass.
  117. virtual bool enableAtomicExpand() const;
  118. /// \brief Override generic scheduling policy within a region.
  119. ///
  120. /// This is a convenient way for targets that don't provide any custom
  121. /// scheduling heuristics (no custom MachineSchedStrategy) to make
  122. /// changes to the generic scheduling policy.
  123. virtual void overrideSchedPolicy(MachineSchedPolicy &Policy,
  124. MachineInstr *begin, MachineInstr *end,
  125. unsigned NumRegionInstrs) const {}
  126. // \brief Perform target specific adjustments to the latency of a schedule
  127. // dependency.
  128. virtual void adjustSchedDependency(SUnit *def, SUnit *use, SDep &dep) const {}
  129. // For use with PostRAScheduling: get the anti-dependence breaking that should
  130. // be performed before post-RA scheduling.
  131. virtual AntiDepBreakMode getAntiDepBreakMode() const { return ANTIDEP_NONE; }
  132. // For use with PostRAScheduling: in CriticalPathRCs, return any register
  133. // classes that should only be considered for anti-dependence breaking if they
  134. // are on the critical path.
  135. virtual void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const {
  136. return CriticalPathRCs.clear();
  137. }
  138. // For use with PostRAScheduling: get the minimum optimization level needed
  139. // to enable post-RA scheduling.
  140. virtual CodeGenOpt::Level getOptLevelToEnablePostRAScheduler() const {
  141. return CodeGenOpt::Default;
  142. }
  143. /// \brief True if the subtarget should run the local reassignment
  144. /// heuristic of the register allocator.
  145. /// This heuristic may be compile time intensive, \p OptLevel provides
  146. /// a finer grain to tune the register allocator.
  147. virtual bool enableRALocalReassignment(CodeGenOpt::Level OptLevel) const;
  148. /// \brief Enable use of alias analysis during code generation (during MI
  149. /// scheduling, DAGCombine, etc.).
  150. virtual bool useAA() const;
  151. /// \brief Enable the use of the early if conversion pass.
  152. virtual bool enableEarlyIfConversion() const { return false; }
  153. /// \brief Return PBQPConstraint(s) for the target.
  154. ///
  155. /// Override to provide custom PBQP constraints.
  156. virtual std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const {
  157. return nullptr;
  158. }
  159. /// Enable tracking of subregister liveness in register allocator.
  160. virtual bool enableSubRegLiveness() const { return false; }
  161. };
  162. } // End llvm namespace
  163. #endif