1 //==-- llvm/Target/TargetSubtargetInfo.h - Target Information ----*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file describes the subtarget options of a Target machine.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_TARGET_TARGETSUBTARGETINFO_H
15 #define LLVM_TARGET_TARGETSUBTARGETINFO_H
17 #include "llvm/CodeGen/PBQPRAConstraint.h"
18 #include "llvm/MC/MCSubtargetInfo.h"
19 #include "llvm/Support/CodeGen.h"
24 class MachineFunction;
28 class TargetFrameLowering;
29 class TargetInstrInfo;
31 class TargetRegisterClass;
32 class TargetRegisterInfo;
33 class TargetSchedModel;
34 class TargetSelectionDAGInfo;
35 struct MachineSchedPolicy;
36 template <typename T> class SmallVectorImpl;
38 //===----------------------------------------------------------------------===//
40 /// TargetSubtargetInfo - Generic base class for all target subtargets. All
41 /// Target-specific options that control code generation and printing should
42 /// be exposed through a TargetSubtargetInfo-derived class.
44 class TargetSubtargetInfo : public MCSubtargetInfo {
45 TargetSubtargetInfo(const TargetSubtargetInfo&) LLVM_DELETED_FUNCTION;
46 void operator=(const TargetSubtargetInfo&) LLVM_DELETED_FUNCTION;
47 protected: // Can only create subclasses...
48 TargetSubtargetInfo();
50 // AntiDepBreakMode - Type of anti-dependence breaking that should
51 // be performed before post-RA scheduling.
52 typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } AntiDepBreakMode;
53 typedef SmallVectorImpl<const TargetRegisterClass*> RegClassVector;
55 virtual ~TargetSubtargetInfo();
57 // Interfaces to the major aspects of target machine information:
59 // -- Instruction opcode and operand information
60 // -- Pipelines and scheduling information
61 // -- Stack frame information
62 // -- Selection DAG lowering information
64 // N.B. These objects may change during compilation. It's not safe to cache
65 // them between functions.
66 virtual const TargetInstrInfo *getInstrInfo() const { return nullptr; }
67 virtual const TargetFrameLowering *getFrameLowering() const {
70 virtual const TargetLowering *getTargetLowering() const { return nullptr; }
71 virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
74 virtual const DataLayout *getDataLayout() const { return nullptr; }
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.
80 virtual const TargetRegisterInfo *getRegisterInfo() const { return nullptr; }
82 /// getInstrItineraryData - Returns instruction itinerary data for the target
83 /// or specific subtarget.
85 virtual const InstrItineraryData *getInstrItineraryData() const {
89 /// Resolve a SchedClass at runtime, where SchedClass identifies an
90 /// MCSchedClassDesc with the isVariant property. This may return the ID of
91 /// another variant SchedClass, but repeated invocation must quickly terminate
92 /// in a nonvariant SchedClass.
93 virtual unsigned resolveSchedClass(unsigned SchedClass, const MachineInstr *MI,
94 const TargetSchedModel* SchedModel) const {
98 /// \brief Temporary API to test migration to MI scheduler.
99 bool useMachineScheduler() const;
101 /// \brief True if the subtarget should run MachineScheduler after aggressive
104 /// This currently replaces the SelectionDAG scheduler with the "source" order
105 /// scheduler. It does not yet disable the postRA scheduler.
106 virtual bool enableMachineScheduler() const;
108 /// \brief True if the subtarget should run PostMachineScheduler.
110 /// This only takes effect if the target has configured the
111 /// PostMachineScheduler pass to run, or if the global cl::opt flag,
112 /// MISchedPostRA, is set.
113 virtual bool enablePostMachineScheduler() const;
115 /// \brief True if the subtarget should run the atomic expansion pass.
116 virtual bool enableAtomicExpand() const;
118 /// \brief Override generic scheduling policy within a region.
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,
126 unsigned NumRegionInstrs) const {}
128 // \brief Perform target specific adjustments to the latency of a schedule
130 virtual void adjustSchedDependency(SUnit *def, SUnit *use,
133 // For use with PostRAScheduling: get the anti-dependence breaking that should
134 // be performed before post-RA scheduling.
135 virtual AntiDepBreakMode getAntiDepBreakMode() const {
139 // For use with PostRAScheduling: in CriticalPathRCs, return any register
140 // classes that should only be considered for anti-dependence breaking if they
141 // are on the critical path.
142 virtual void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const {
143 return CriticalPathRCs.clear();
146 // For use with PostRAScheduling: get the minimum optimization level needed
147 // to enable post-RA scheduling.
148 virtual CodeGenOpt::Level getOptLevelToEnablePostRAScheduler() const {
149 return CodeGenOpt::Default;
152 /// \brief True if the subtarget should run the local reassignment
153 /// heuristic of the register allocator.
154 /// This heuristic may be compile time intensive, \p OptLevel provides
155 /// a finer grain to tune the register allocator.
156 virtual bool enableRALocalReassignment(CodeGenOpt::Level OptLevel) const;
158 /// \brief Enable use of alias analysis during code generation (during MI
159 /// scheduling, DAGCombine, etc.).
160 virtual bool useAA() const;
162 /// \brief Enable the use of the early if conversion pass.
163 virtual bool enableEarlyIfConversion() const { return false; }
165 /// \brief Return PBQPConstraint(s) for the target.
167 /// Override to provide custom PBQP constraints.
168 virtual std::unique_ptr<PBQPRAConstraint> getCustomPBQPConstraints() const {
173 } // End llvm namespace