Remove resetSubtargetFeatures as it is unused.
[oota-llvm.git] / include / llvm / Target / TargetSubtargetInfo.h
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
14 #ifndef LLVM_TARGET_TARGETSUBTARGETINFO_H
15 #define LLVM_TARGET_TARGETSUBTARGETINFO_H
16
17 #include "llvm/MC/MCSubtargetInfo.h"
18 #include "llvm/Support/CodeGen.h"
19
20 namespace llvm {
21
22 class DataLayout;
23 class MachineFunction;
24 class MachineInstr;
25 class SDep;
26 class SUnit;
27 class TargetFrameLowering;
28 class TargetInstrInfo;
29 class TargetLowering;
30 class TargetRegisterClass;
31 class TargetRegisterInfo;
32 class TargetSchedModel;
33 class TargetSelectionDAGInfo;
34 struct MachineSchedPolicy;
35 template <typename T> class SmallVectorImpl;
36
37 //===----------------------------------------------------------------------===//
38 ///
39 /// TargetSubtargetInfo - Generic base class for all target subtargets.  All
40 /// Target-specific options that control code generation and printing should
41 /// be exposed through a TargetSubtargetInfo-derived class.
42 ///
43 class TargetSubtargetInfo : public MCSubtargetInfo {
44   TargetSubtargetInfo(const TargetSubtargetInfo&) LLVM_DELETED_FUNCTION;
45   void operator=(const TargetSubtargetInfo&) LLVM_DELETED_FUNCTION;
46 protected: // Can only create subclasses...
47   TargetSubtargetInfo();
48 public:
49   // AntiDepBreakMode - Type of anti-dependence breaking that should
50   // be performed before post-RA scheduling.
51   typedef enum { ANTIDEP_NONE, ANTIDEP_CRITICAL, ANTIDEP_ALL } AntiDepBreakMode;
52   typedef SmallVectorImpl<const TargetRegisterClass*> RegClassVector;
53
54   virtual ~TargetSubtargetInfo();
55
56   // Interfaces to the major aspects of target machine information:
57   //
58   // -- Instruction opcode and operand information
59   // -- Pipelines and scheduling information
60   // -- Stack frame information
61   // -- Selection DAG lowering information
62   //
63   // N.B. These objects may change during compilation. It's not safe to cache
64   // them between functions.
65   virtual const TargetInstrInfo *getInstrInfo() const { return nullptr; }
66   virtual const TargetFrameLowering *getFrameLowering() const {
67     return nullptr;
68   }
69   virtual const TargetLowering *getTargetLowering() const { return nullptr; }
70   virtual const TargetSelectionDAGInfo *getSelectionDAGInfo() const {
71     return nullptr;
72   }
73   virtual const DataLayout *getDataLayout() const { return nullptr; }
74
75   /// getRegisterInfo - If register information is available, return it.  If
76   /// not, return null.  This is kept separate from RegInfo until RegInfo has
77   /// details of graph coloring register allocation removed from it.
78   ///
79   virtual const TargetRegisterInfo *getRegisterInfo() const { return nullptr; }
80
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
88   /// Resolve a SchedClass at runtime, where SchedClass identifies an
89   /// MCSchedClassDesc with the isVariant property. This may return the ID of
90   /// another variant SchedClass, but repeated invocation must quickly terminate
91   /// in a nonvariant SchedClass.
92   virtual unsigned resolveSchedClass(unsigned SchedClass, const MachineInstr *MI,
93                                      const TargetSchedModel* SchedModel) const {
94     return 0;
95   }
96
97   /// \brief Temporary API to test migration to MI scheduler.
98   bool useMachineScheduler() const;
99
100   /// \brief True if the subtarget should run MachineScheduler after aggressive
101   /// coalescing.
102   ///
103   /// This currently replaces the SelectionDAG scheduler with the "source" order
104   /// scheduler. It does not yet disable the postRA scheduler.
105   virtual bool enableMachineScheduler() const;
106
107   /// \brief True if the subtarget should run PostMachineScheduler.
108   ///
109   /// This only takes effect if the target has configured the
110   /// PostMachineScheduler pass to run, or if the global cl::opt flag,
111   /// MISchedPostRA, is set.
112   virtual bool enablePostMachineScheduler() const;
113
114   /// \brief True if the subtarget should run the atomic expansion pass.
115   virtual bool enableAtomicExpand() const;
116
117   /// \brief Override generic scheduling policy within a region.
118   ///
119   /// This is a convenient way for targets that don't provide any custom
120   /// scheduling heuristics (no custom MachineSchedStrategy) to make
121   /// changes to the generic scheduling policy.
122   virtual void overrideSchedPolicy(MachineSchedPolicy &Policy,
123                                    MachineInstr *begin,
124                                    MachineInstr *end,
125                                    unsigned NumRegionInstrs) const {}
126
127   // \brief Perform target specific adjustments to the latency of a schedule
128   // dependency.
129   virtual void adjustSchedDependency(SUnit *def, SUnit *use,
130                                      SDep& dep) const { }
131
132   // For use with PostRAScheduling: get the anti-dependence breaking that should
133   // be performed before post-RA scheduling.
134   virtual AntiDepBreakMode getAntiDepBreakMode() const {
135     return ANTIDEP_NONE;
136   }
137
138   // For use with PostRAScheduling: in CriticalPathRCs, return any register
139   // classes that should only be considered for anti-dependence breaking if they
140   // are on the critical path.
141   virtual void getCriticalPathRCs(RegClassVector &CriticalPathRCs) const {
142     return CriticalPathRCs.clear();
143   }
144
145   // For use with PostRAScheduling: get the minimum optimization level needed
146   // to enable post-RA scheduling.
147   virtual CodeGenOpt::Level getOptLevelToEnablePostRAScheduler() const {
148     return CodeGenOpt::Default;
149   }
150
151   /// \brief True if the subtarget should run the local reassignment
152   /// heuristic of the register allocator.
153   /// This heuristic may be compile time intensive, \p OptLevel provides
154   /// a finer grain to tune the register allocator.
155   virtual bool enableRALocalReassignment(CodeGenOpt::Level OptLevel) const;
156
157   /// \brief Enable use of alias analysis during code generation (during MI
158   /// scheduling, DAGCombine, etc.).
159   virtual bool useAA() const;
160
161   /// \brief Enable the use of the early if conversion pass.
162   virtual bool enableEarlyIfConversion() const { return false; }
163 };
164
165 } // End llvm namespace
166
167 #endif