|
16 | 16 | #ifndef LLVM_MC_MCINSTRITINERARIES_H
|
17 | 17 | #define LLVM_MC_MCINSTRITINERARIES_H
|
18 | 18 |
|
| 19 | +#include "llvm/MC/MCSchedule.h" |
19 | 20 | #include <algorithm>
|
20 | 21 |
|
21 | 22 | namespace llvm {
|
@@ -103,96 +104,28 @@ struct InstrItinerary {
|
103 | 104 | };
|
104 | 105 |
|
105 | 106 |
|
106 |
| -//===----------------------------------------------------------------------===// |
107 |
| -/// Instruction itinerary properties - These properties provide general |
108 |
| -/// information about the microarchitecture to the scheduler. |
109 |
| -/// |
110 |
| -struct InstrItineraryProps { |
111 |
| - // IssueWidth is the maximum number of instructions that may be scheduled in |
112 |
| - // the same per-cycle group. |
113 |
| - unsigned IssueWidth; |
114 |
| - static const unsigned DefaultIssueWidth = 1; |
115 |
| - |
116 |
| - // MinLatency is the minimum latency between a register write |
117 |
| - // followed by a data dependent read. This determines which |
118 |
| - // instructions may be scheduled in the same per-cycle group. This |
119 |
| - // is distinct from *expected* latency, which determines the likely |
120 |
| - // critical path but does not guarantee a pipeline |
121 |
| - // hazard. MinLatency can always be overridden by the number of |
122 |
| - // InstrStage cycles. |
123 |
| - // |
124 |
| - // (-1) Standard in-order processor. |
125 |
| - // Use InstrItinerary OperandCycles as MinLatency. |
126 |
| - // If no OperandCycles exist, then use the cycle of the last InstrStage. |
127 |
| - // |
128 |
| - // (0) Out-of-order processor, or in-order with bundled dependencies. |
129 |
| - // RAW dependencies may be dispatched in the same cycle. |
130 |
| - // Optional InstrItinerary OperandCycles provides expected latency. |
131 |
| - // |
132 |
| - // (>0) In-order processor with variable latencies. |
133 |
| - // Use the greater of this value or the cycle of the last InstrStage. |
134 |
| - // Optional InstrItinerary OperandCycles provides expected latency. |
135 |
| - // TODO: can't yet specify both min and expected latency per operand. |
136 |
| - int MinLatency; |
137 |
| - static const unsigned DefaultMinLatency = -1; |
138 |
| - |
139 |
| - // LoadLatency is the expected latency of load instructions. |
140 |
| - // |
141 |
| - // If MinLatency >= 0, this may be overriden for individual load opcodes by |
142 |
| - // InstrItinerary OperandCycles. |
143 |
| - unsigned LoadLatency; |
144 |
| - static const unsigned DefaultLoadLatency = 4; |
145 |
| - |
146 |
| - // HighLatency is the expected latency of "very high latency" operations. |
147 |
| - // See TargetInstrInfo::isHighLatencyDef(). |
148 |
| - // By default, this is set to an arbitrarily high number of cycles |
149 |
| - // likely to have some impact on scheduling heuristics. |
150 |
| - // If MinLatency >= 0, this may be overriden by InstrItinData OperandCycles. |
151 |
| - unsigned HighLatency; |
152 |
| - static const unsigned DefaultHighLatency = 10; |
153 |
| - |
154 |
| - // Default's must be specified as static const literals so that tablegenerated |
155 |
| - // target code can use it in static initializers. The defaults need to be |
156 |
| - // initialized in this default ctor because some clients directly instantiate |
157 |
| - // InstrItineraryData instead of using a generated itinerary. |
158 |
| - InstrItineraryProps(): IssueWidth(DefaultMinLatency), |
159 |
| - MinLatency(DefaultMinLatency), |
160 |
| - LoadLatency(DefaultLoadLatency), |
161 |
| - HighLatency(DefaultHighLatency) {} |
162 |
| - |
163 |
| - InstrItineraryProps(unsigned iw, int ml, unsigned ll, unsigned hl): |
164 |
| - IssueWidth(iw), MinLatency(ml), LoadLatency(ll), HighLatency(hl) {} |
165 |
| -}; |
166 |
| - |
167 |
| -//===----------------------------------------------------------------------===// |
168 |
| -/// Encapsulate all subtarget specific information for scheduling for use with |
169 |
| -/// SubtargetInfoKV. |
170 |
| -struct InstrItinerarySubtargetValue { |
171 |
| - const InstrItineraryProps *Props; |
172 |
| - const InstrItinerary *Itineraries; |
173 |
| -}; |
174 |
| - |
175 | 107 | //===----------------------------------------------------------------------===//
|
176 | 108 | /// Instruction itinerary Data - Itinerary data supplied by a subtarget to be
|
177 | 109 | /// used by a target.
|
178 | 110 | ///
|
179 | 111 | class InstrItineraryData {
|
180 | 112 | public:
|
181 |
| - InstrItineraryProps Props; |
| 113 | + const MCSchedModel *SchedModel; ///< Basic machine properties. |
182 | 114 | const InstrStage *Stages; ///< Array of stages selected
|
183 | 115 | const unsigned *OperandCycles; ///< Array of operand cycles selected
|
184 | 116 | const unsigned *Forwardings; ///< Array of pipeline forwarding pathes
|
185 | 117 | const InstrItinerary *Itineraries; ///< Array of itineraries selected
|
186 | 118 |
|
187 | 119 | /// Ctors.
|
188 | 120 | ///
|
189 |
| - InstrItineraryData() : Stages(0), OperandCycles(0), Forwardings(0), |
190 |
| - Itineraries(0) {} |
| 121 | + InstrItineraryData() : SchedModel(&MCSchedModel::DefaultSchedModel), |
| 122 | + Stages(0), OperandCycles(0), |
| 123 | + Forwardings(0), Itineraries(0) {} |
191 | 124 |
|
192 |
| - InstrItineraryData(const InstrItineraryProps *P, const InstrStage *S, |
193 |
| - const unsigned *OS, const unsigned *F, |
194 |
| - const InstrItinerary *I) |
195 |
| - : Props(*P), Stages(S), OperandCycles(OS), Forwardings(F), Itineraries(I) {} |
| 125 | + InstrItineraryData(const MCSchedModel *SM, const InstrStage *S, |
| 126 | + const unsigned *OS, const unsigned *F) |
| 127 | + : SchedModel(SM), Stages(S), OperandCycles(OS), Forwardings(F), |
| 128 | + Itineraries(SchedModel->InstrItineraries) {} |
196 | 129 |
|
197 | 130 | /// isEmpty - Returns true if there are no itineraries.
|
198 | 131 | ///
|
@@ -232,13 +165,9 @@ class InstrItineraryData {
|
232 | 165 | /// then it defaults to one cycle.
|
233 | 166 | unsigned getStageLatency(unsigned ItinClassIndx) const {
|
234 | 167 | // If the target doesn't provide itinerary information, use a simple
|
235 |
| - // non-zero default value for all instructions. Some target's provide a |
236 |
| - // dummy (Generic) itinerary which should be handled as if it's itinerary is |
237 |
| - // empty. We identify this by looking for a reference to stage zero (invalid |
238 |
| - // stage). This is different from beginStage == endStage != 0, which could |
239 |
| - // be used for zero-latency pseudo ops. |
240 |
| - if (isEmpty() || Itineraries[ItinClassIndx].FirstStage == 0) |
241 |
| - return (Props.MinLatency < 0) ? 1 : Props.MinLatency; |
| 168 | + // non-zero default value for all instructions. |
| 169 | + if (isEmpty()) |
| 170 | + return SchedModel->MinLatency < 0 ? 1 : SchedModel->MinLatency; |
242 | 171 |
|
243 | 172 | // Calculate the maximum completion time for any stage.
|
244 | 173 | unsigned Latency = 0, StartCycle = 0;
|
|
0 commit comments