blob: 59c084b1af3f11de47fd3ce58595432d87f2f6d0 [file] [log] [blame]
Andrew Trick87255e32012-07-07 04:00:00 +00001//===- CodeGenSchedule.h - Scheduling Machine Models ------------*- 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//
Alp Tokercb402912014-01-24 17:20:08 +000010// This file defines structures to encapsulate the machine model as described in
Andrew Trick87255e32012-07-07 04:00:00 +000011// the target description.
12//
13//===----------------------------------------------------------------------===//
14
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000015#ifndef LLVM_UTILS_TABLEGEN_CODEGENSCHEDULE_H
16#define LLVM_UTILS_TABLEGEN_CODEGENSCHEDULE_H
Andrew Trick87255e32012-07-07 04:00:00 +000017
Andrew Trick87255e32012-07-07 04:00:00 +000018#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/StringMap.h"
Chandler Carruth91d19d82012-12-04 10:37:14 +000020#include "llvm/Support/ErrorHandling.h"
21#include "llvm/TableGen/Record.h"
James Molloyf1653b52014-06-17 13:10:38 +000022#include "llvm/TableGen/SetTheory.h"
Andrew Trick87255e32012-07-07 04:00:00 +000023
24namespace llvm {
25
26class CodeGenTarget;
Andrew Trick76686492012-09-15 00:19:57 +000027class CodeGenSchedModels;
28class CodeGenInstruction;
Andrew Trick87255e32012-07-07 04:00:00 +000029
Javed Absar67b042c2017-09-13 10:31:10 +000030using RecVec = std::vector<Record*>;
31using RecIter = std::vector<Record*>::const_iterator;
Andrew Trick76686492012-09-15 00:19:57 +000032
Javed Absar67b042c2017-09-13 10:31:10 +000033using IdxVec = std::vector<unsigned>;
34using IdxIter = std::vector<unsigned>::const_iterator;
Andrew Trick76686492012-09-15 00:19:57 +000035
Andrew Trick76686492012-09-15 00:19:57 +000036/// We have two kinds of SchedReadWrites. Explicitly defined and inferred
37/// sequences. TheDef is nonnull for explicit SchedWrites, but Sequence may or
38/// may not be empty. TheDef is null for inferred sequences, and Sequence must
39/// be nonempty.
40///
41/// IsVariadic controls whether the variants are expanded into multiple operands
42/// or a sequence of writes on one operand.
43struct CodeGenSchedRW {
Andrew Trickda984b12012-10-03 23:06:28 +000044 unsigned Index;
Andrew Trick76686492012-09-15 00:19:57 +000045 std::string Name;
46 Record *TheDef;
Andrew Trickda984b12012-10-03 23:06:28 +000047 bool IsRead;
Andrew Trick9257b8f2012-09-22 02:24:21 +000048 bool IsAlias;
Andrew Trick76686492012-09-15 00:19:57 +000049 bool HasVariants;
50 bool IsVariadic;
51 bool IsSequence;
52 IdxVec Sequence;
Andrew Trick9257b8f2012-09-22 02:24:21 +000053 RecVec Aliases;
Andrew Trick76686492012-09-15 00:19:57 +000054
Richard Smitha7bb16a2012-12-20 01:05:39 +000055 CodeGenSchedRW()
Craig Topperada08572014-04-16 04:21:27 +000056 : Index(0), TheDef(nullptr), IsRead(false), IsAlias(false),
Richard Smitha7bb16a2012-12-20 01:05:39 +000057 HasVariants(false), IsVariadic(false), IsSequence(false) {}
58 CodeGenSchedRW(unsigned Idx, Record *Def)
59 : Index(Idx), TheDef(Def), IsAlias(false), IsVariadic(false) {
Andrew Trick76686492012-09-15 00:19:57 +000060 Name = Def->getName();
Andrew Trickda984b12012-10-03 23:06:28 +000061 IsRead = Def->isSubClassOf("SchedRead");
Andrew Trick76686492012-09-15 00:19:57 +000062 HasVariants = Def->isSubClassOf("SchedVariant");
63 if (HasVariants)
64 IsVariadic = Def->getValueAsBit("Variadic");
65
66 // Read records don't currently have sequences, but it can be easily
67 // added. Note that implicit Reads (from ReadVariant) may have a Sequence
68 // (but no record).
69 IsSequence = Def->isSubClassOf("WriteSequence");
70 }
71
Benjamin Kramere1761952015-10-24 12:46:49 +000072 CodeGenSchedRW(unsigned Idx, bool Read, ArrayRef<unsigned> Seq,
Richard Smitha7bb16a2012-12-20 01:05:39 +000073 const std::string &Name)
Benjamin Kramere1761952015-10-24 12:46:49 +000074 : Index(Idx), Name(Name), TheDef(nullptr), IsRead(Read), IsAlias(false),
75 HasVariants(false), IsVariadic(false), IsSequence(true), Sequence(Seq) {
Andrew Trick76686492012-09-15 00:19:57 +000076 assert(Sequence.size() > 1 && "implied sequence needs >1 RWs");
77 }
78
79 bool isValid() const {
80 assert((!HasVariants || TheDef) && "Variant write needs record def");
81 assert((!IsVariadic || HasVariants) && "Variadic write needs variants");
82 assert((!IsSequence || !HasVariants) && "Sequence can't have variant");
83 assert((!IsSequence || !Sequence.empty()) && "Sequence should be nonempty");
Andrew Trick9257b8f2012-09-22 02:24:21 +000084 assert((!IsAlias || Aliases.empty()) && "Alias cannot have aliases");
Andrew Trick76686492012-09-15 00:19:57 +000085 return TheDef || !Sequence.empty();
86 }
87
88#ifndef NDEBUG
89 void dump() const;
90#endif
91};
92
Andrew Trickea28dbd2012-09-18 04:03:30 +000093/// Represent a transition between SchedClasses induced by SchedVariant.
Andrew Trick33401e82012-09-15 00:19:59 +000094struct CodeGenSchedTransition {
95 unsigned ToClassIdx;
96 IdxVec ProcIndices;
97 RecVec PredTerm;
98};
99
Andrew Trick76686492012-09-15 00:19:57 +0000100/// Scheduling class.
101///
102/// Each instruction description will be mapped to a scheduling class. There are
103/// four types of classes:
104///
105/// 1) An explicitly defined itinerary class with ItinClassDef set.
106/// Writes and ReadDefs are empty. ProcIndices contains 0 for any processor.
107///
108/// 2) An implied class with a list of SchedWrites and SchedReads that are
109/// defined in an instruction definition and which are common across all
110/// subtargets. ProcIndices contains 0 for any processor.
111///
112/// 3) An implied class with a list of InstRW records that map instructions to
113/// SchedWrites and SchedReads per-processor. InstrClassMap should map the same
114/// instructions to this class. ProcIndices contains all the processors that
115/// provided InstrRW records for this class. ItinClassDef or Writes/Reads may
116/// still be defined for processors with no InstRW entry.
117///
118/// 4) An inferred class represents a variant of another class that may be
119/// resolved at runtime. ProcIndices contains the set of processors that may
120/// require the class. ProcIndices are propagated through SchedClasses as
121/// variants are expanded. Multiple SchedClasses may be inferred from an
122/// itinerary class. Each inherits the processor index from the ItinRW record
123/// that mapped the itinerary class to the variant Writes or Reads.
Andrew Trick87255e32012-07-07 04:00:00 +0000124struct CodeGenSchedClass {
Andrew Trickbf8a28d2013-03-16 18:58:55 +0000125 unsigned Index;
Andrew Trick87255e32012-07-07 04:00:00 +0000126 std::string Name;
Andrew Trick87255e32012-07-07 04:00:00 +0000127 Record *ItinClassDef;
128
Andrew Trick76686492012-09-15 00:19:57 +0000129 IdxVec Writes;
130 IdxVec Reads;
131 // Sorted list of ProcIdx, where ProcIdx==0 implies any processor.
132 IdxVec ProcIndices;
133
Andrew Trick33401e82012-09-15 00:19:59 +0000134 std::vector<CodeGenSchedTransition> Transitions;
135
Andrew Trick9257b8f2012-09-22 02:24:21 +0000136 // InstRW records associated with this class. These records may refer to an
137 // Instruction no longer mapped to this class by InstrClassMap. These
138 // Instructions should be ignored by this class because they have been split
139 // off to join another inferred class.
Andrew Trick76686492012-09-15 00:19:57 +0000140 RecVec InstRWs;
141
Craig Topperada08572014-04-16 04:21:27 +0000142 CodeGenSchedClass(): Index(0), ItinClassDef(nullptr) {}
Andrew Trickbf8a28d2013-03-16 18:58:55 +0000143
Benjamin Kramere1761952015-10-24 12:46:49 +0000144 bool isKeyEqual(Record *IC, ArrayRef<unsigned> W, ArrayRef<unsigned> R) {
145 return ItinClassDef == IC && makeArrayRef(Writes) == W &&
146 makeArrayRef(Reads) == R;
Andrew Trick87255e32012-07-07 04:00:00 +0000147 }
Andrew Trick76686492012-09-15 00:19:57 +0000148
Andrew Trickbf8a28d2013-03-16 18:58:55 +0000149 // Is this class generated from a variants if existing classes? Instructions
150 // are never mapped directly to inferred scheduling classes.
151 bool isInferred() const { return !ItinClassDef; }
152
Andrew Trick76686492012-09-15 00:19:57 +0000153#ifndef NDEBUG
154 void dump(const CodeGenSchedModels *SchedModels) const;
155#endif
Andrew Trick87255e32012-07-07 04:00:00 +0000156};
157
158// Processor model.
159//
160// ModelName is a unique name used to name an instantiation of MCSchedModel.
161//
162// ModelDef is NULL for inferred Models. This happens when a processor defines
Alp Tokercb402912014-01-24 17:20:08 +0000163// an itinerary but no machine model. If the processor defines neither a machine
Andrew Trick87255e32012-07-07 04:00:00 +0000164// model nor itinerary, then ModelDef remains pointing to NoModel. NoModel has
165// the special "NoModel" field set to true.
166//
167// ItinsDef always points to a valid record definition, but may point to the
168// default NoItineraries. NoItineraries has an empty list of InstrItinData
169// records.
170//
171// ItinDefList orders this processor's InstrItinData records by SchedClass idx.
172struct CodeGenProcModel {
Andrew Trick76686492012-09-15 00:19:57 +0000173 unsigned Index;
Andrew Trick87255e32012-07-07 04:00:00 +0000174 std::string ModelName;
175 Record *ModelDef;
176 Record *ItinsDef;
177
Andrew Trick76686492012-09-15 00:19:57 +0000178 // Derived members...
Andrew Trick87255e32012-07-07 04:00:00 +0000179
Andrew Trick76686492012-09-15 00:19:57 +0000180 // Array of InstrItinData records indexed by a CodeGenSchedClass index.
181 // This list is empty if the Processor has no value for Itineraries.
182 // Initialized by collectProcItins().
183 RecVec ItinDefList;
184
185 // Map itinerary classes to per-operand resources.
186 // This list is empty if no ItinRW refers to this Processor.
187 RecVec ItinRWDefs;
188
Simon Dardis5f95c9a2016-06-24 08:43:27 +0000189 // List of unsupported feature.
190 // This list is empty if the Processor has no UnsupportedFeatures.
191 RecVec UnsupportedFeaturesDefs;
192
Andrew Trick1e46d482012-09-15 00:20:02 +0000193 // All read/write resources associated with this processor.
194 RecVec WriteResDefs;
195 RecVec ReadAdvanceDefs;
196
197 // Per-operand machine model resources associated with this processor.
198 RecVec ProcResourceDefs;
199
Andrew Trick76686492012-09-15 00:19:57 +0000200 CodeGenProcModel(unsigned Idx, const std::string &Name, Record *MDef,
201 Record *IDef) :
202 Index(Idx), ModelName(Name), ModelDef(MDef), ItinsDef(IDef) {}
203
Andrew Trickbf8a28d2013-03-16 18:58:55 +0000204 bool hasItineraries() const {
205 return !ItinsDef->getValueAsListOfDefs("IID").empty();
206 }
207
Andrew Trick1e46d482012-09-15 00:20:02 +0000208 bool hasInstrSchedModel() const {
209 return !WriteResDefs.empty() || !ItinRWDefs.empty();
210 }
211
212 unsigned getProcResourceIdx(Record *PRDef) const;
213
Simon Dardis5f95c9a2016-06-24 08:43:27 +0000214 bool isUnsupported(const CodeGenInstruction &Inst) const;
215
Andrew Trick76686492012-09-15 00:19:57 +0000216#ifndef NDEBUG
217 void dump() const;
218#endif
Andrew Trick87255e32012-07-07 04:00:00 +0000219};
220
Andrew Trick76686492012-09-15 00:19:57 +0000221/// Top level container for machine model data.
Andrew Trick87255e32012-07-07 04:00:00 +0000222class CodeGenSchedModels {
223 RecordKeeper &Records;
224 const CodeGenTarget &Target;
225
Andrew Trick9e1deb62012-10-03 23:06:32 +0000226 // Map dag expressions to Instruction lists.
227 SetTheory Sets;
228
Andrew Trick76686492012-09-15 00:19:57 +0000229 // List of unique processor models.
230 std::vector<CodeGenProcModel> ProcModels;
231
232 // Map Processor's MachineModel or ProcItin to a CodeGenProcModel index.
Javed Absar67b042c2017-09-13 10:31:10 +0000233 using ProcModelMapTy = DenseMap<Record*, unsigned>;
Andrew Trick76686492012-09-15 00:19:57 +0000234 ProcModelMapTy ProcModelMap;
235
236 // Per-operand SchedReadWrite types.
237 std::vector<CodeGenSchedRW> SchedWrites;
238 std::vector<CodeGenSchedRW> SchedReads;
239
Andrew Trick87255e32012-07-07 04:00:00 +0000240 // List of unique SchedClasses.
241 std::vector<CodeGenSchedClass> SchedClasses;
242
Andrew Trick76686492012-09-15 00:19:57 +0000243 // Any inferred SchedClass has an index greater than NumInstrSchedClassses.
244 unsigned NumInstrSchedClasses;
Andrew Trick87255e32012-07-07 04:00:00 +0000245
Matthias Braun6b1fd9a2016-06-21 03:24:03 +0000246 RecVec ProcResourceDefs;
247 RecVec ProcResGroups;
248
Andrew Trickbf8a28d2013-03-16 18:58:55 +0000249 // Map each instruction to its unique SchedClass index considering the
250 // combination of it's itinerary class, SchedRW list, and InstRW records.
Javed Absar67b042c2017-09-13 10:31:10 +0000251 using InstClassMapTy = DenseMap<Record*, unsigned>;
Andrew Trick76686492012-09-15 00:19:57 +0000252 InstClassMapTy InstrClassMap;
Andrew Trick87255e32012-07-07 04:00:00 +0000253
254public:
255 CodeGenSchedModels(RecordKeeper& RK, const CodeGenTarget &TGT);
256
Jim Grosbachaf814452014-04-18 02:09:04 +0000257 // iterator access to the scheduling classes.
Javed Absar67b042c2017-09-13 10:31:10 +0000258 using class_iterator = std::vector<CodeGenSchedClass>::iterator;
259 using const_class_iterator = std::vector<CodeGenSchedClass>::const_iterator;
Jim Grosbachaf814452014-04-18 02:09:04 +0000260 class_iterator classes_begin() { return SchedClasses.begin(); }
261 const_class_iterator classes_begin() const { return SchedClasses.begin(); }
262 class_iterator classes_end() { return SchedClasses.end(); }
263 const_class_iterator classes_end() const { return SchedClasses.end(); }
264 iterator_range<class_iterator> classes() {
Craig Topper15576e12015-12-06 05:08:07 +0000265 return make_range(classes_begin(), classes_end());
Jim Grosbachaf814452014-04-18 02:09:04 +0000266 }
267 iterator_range<const_class_iterator> classes() const {
Craig Topper15576e12015-12-06 05:08:07 +0000268 return make_range(classes_begin(), classes_end());
Jim Grosbachaf814452014-04-18 02:09:04 +0000269 }
270 iterator_range<class_iterator> explicit_classes() {
Craig Topper15576e12015-12-06 05:08:07 +0000271 return make_range(classes_begin(), classes_begin() + NumInstrSchedClasses);
Jim Grosbachaf814452014-04-18 02:09:04 +0000272 }
273 iterator_range<const_class_iterator> explicit_classes() const {
Craig Topper15576e12015-12-06 05:08:07 +0000274 return make_range(classes_begin(), classes_begin() + NumInstrSchedClasses);
Jim Grosbachaf814452014-04-18 02:09:04 +0000275 }
276
Andrew Trick76686492012-09-15 00:19:57 +0000277 Record *getModelOrItinDef(Record *ProcDef) const {
278 Record *ModelDef = ProcDef->getValueAsDef("SchedModel");
279 Record *ItinsDef = ProcDef->getValueAsDef("ProcItin");
280 if (!ItinsDef->getValueAsListOfDefs("IID").empty()) {
281 assert(ModelDef->getValueAsBit("NoModel")
282 && "Itineraries must be defined within SchedMachineModel");
283 return ItinsDef;
284 }
285 return ModelDef;
286 }
287
288 const CodeGenProcModel &getModelForProc(Record *ProcDef) const {
289 Record *ModelDef = getModelOrItinDef(ProcDef);
290 ProcModelMapTy::const_iterator I = ProcModelMap.find(ModelDef);
291 assert(I != ProcModelMap.end() && "missing machine model");
292 return ProcModels[I->second];
293 }
294
Andrew Trick40c4f382013-06-15 04:50:06 +0000295 CodeGenProcModel &getProcModel(Record *ModelDef) {
Andrew Trick76686492012-09-15 00:19:57 +0000296 ProcModelMapTy::const_iterator I = ProcModelMap.find(ModelDef);
297 assert(I != ProcModelMap.end() && "missing machine model");
298 return ProcModels[I->second];
299 }
Andrew Trick40c4f382013-06-15 04:50:06 +0000300 const CodeGenProcModel &getProcModel(Record *ModelDef) const {
301 return const_cast<CodeGenSchedModels*>(this)->getProcModel(ModelDef);
302 }
Andrew Trick76686492012-09-15 00:19:57 +0000303
304 // Iterate over the unique processor models.
Javed Absar67b042c2017-09-13 10:31:10 +0000305 using ProcIter = std::vector<CodeGenProcModel>::const_iterator;
Andrew Trick76686492012-09-15 00:19:57 +0000306 ProcIter procModelBegin() const { return ProcModels.begin(); }
307 ProcIter procModelEnd() const { return ProcModels.end(); }
Craig Topper29c55dcb2016-02-13 06:03:32 +0000308 ArrayRef<CodeGenProcModel> procModels() const { return ProcModels; }
Andrew Trick76686492012-09-15 00:19:57 +0000309
Andrew Trickbf8a28d2013-03-16 18:58:55 +0000310 // Return true if any processors have itineraries.
311 bool hasItineraries() const;
312
Andrew Trick76686492012-09-15 00:19:57 +0000313 // Get a SchedWrite from its index.
314 const CodeGenSchedRW &getSchedWrite(unsigned Idx) const {
315 assert(Idx < SchedWrites.size() && "bad SchedWrite index");
316 assert(SchedWrites[Idx].isValid() && "invalid SchedWrite");
317 return SchedWrites[Idx];
318 }
319 // Get a SchedWrite from its index.
320 const CodeGenSchedRW &getSchedRead(unsigned Idx) const {
321 assert(Idx < SchedReads.size() && "bad SchedRead index");
322 assert(SchedReads[Idx].isValid() && "invalid SchedRead");
323 return SchedReads[Idx];
324 }
325
326 const CodeGenSchedRW &getSchedRW(unsigned Idx, bool IsRead) const {
327 return IsRead ? getSchedRead(Idx) : getSchedWrite(Idx);
328 }
Andrew Trickda984b12012-10-03 23:06:28 +0000329 CodeGenSchedRW &getSchedRW(Record *Def) {
Andrew Trick9257b8f2012-09-22 02:24:21 +0000330 bool IsRead = Def->isSubClassOf("SchedRead");
Andrew Trickda984b12012-10-03 23:06:28 +0000331 unsigned Idx = getSchedRWIdx(Def, IsRead);
Andrew Trick9257b8f2012-09-22 02:24:21 +0000332 return const_cast<CodeGenSchedRW&>(
333 IsRead ? getSchedRead(Idx) : getSchedWrite(Idx));
334 }
Andrew Trickda984b12012-10-03 23:06:28 +0000335 const CodeGenSchedRW &getSchedRW(Record*Def) const {
336 return const_cast<CodeGenSchedModels&>(*this).getSchedRW(Def);
Andrew Trick9257b8f2012-09-22 02:24:21 +0000337 }
Andrew Trick76686492012-09-15 00:19:57 +0000338
Craig Toppere2611842018-03-21 05:13:04 +0000339 unsigned getSchedRWIdx(Record *Def, bool IsRead) const;
Andrew Trick76686492012-09-15 00:19:57 +0000340
Andrew Trickcfe222c2012-09-19 04:43:19 +0000341 // Return true if the given write record is referenced by a ReadAdvance.
342 bool hasReadOfWrite(Record *WriteDef) const;
343
Andrew Trick87255e32012-07-07 04:00:00 +0000344 // Get a SchedClass from its index.
Andrew Trick76686492012-09-15 00:19:57 +0000345 CodeGenSchedClass &getSchedClass(unsigned Idx) {
346 assert(Idx < SchedClasses.size() && "bad SchedClass index");
347 return SchedClasses[Idx];
348 }
349 const CodeGenSchedClass &getSchedClass(unsigned Idx) const {
Andrew Trick87255e32012-07-07 04:00:00 +0000350 assert(Idx < SchedClasses.size() && "bad SchedClass index");
351 return SchedClasses[Idx];
352 }
353
Andrew Trick76686492012-09-15 00:19:57 +0000354 // Get the SchedClass index for an instruction. Instructions with no
355 // itinerary, no SchedReadWrites, and no InstrReadWrites references return 0
356 // for NoItinerary.
357 unsigned getSchedClassIdx(const CodeGenInstruction &Inst) const;
358
Javed Absar67b042c2017-09-13 10:31:10 +0000359 using SchedClassIter = std::vector<CodeGenSchedClass>::const_iterator;
Andrew Trick76686492012-09-15 00:19:57 +0000360 SchedClassIter schedClassBegin() const { return SchedClasses.begin(); }
361 SchedClassIter schedClassEnd() const { return SchedClasses.end(); }
Craig Topper29c55dcb2016-02-13 06:03:32 +0000362 ArrayRef<CodeGenSchedClass> schedClasses() const { return SchedClasses; }
Andrew Trick87255e32012-07-07 04:00:00 +0000363
Andrew Trickbf8a28d2013-03-16 18:58:55 +0000364 unsigned numInstrSchedClasses() const { return NumInstrSchedClasses; }
365
Andrew Trick76686492012-09-15 00:19:57 +0000366 void findRWs(const RecVec &RWDefs, IdxVec &Writes, IdxVec &Reads) const;
367 void findRWs(const RecVec &RWDefs, IdxVec &RWs, bool IsRead) const;
Andrew Trick33401e82012-09-15 00:19:59 +0000368 void expandRWSequence(unsigned RWIdx, IdxVec &RWSeq, bool IsRead) const;
Andrew Trickda984b12012-10-03 23:06:28 +0000369 void expandRWSeqForProc(unsigned RWIdx, IdxVec &RWSeq, bool IsRead,
370 const CodeGenProcModel &ProcModel) const;
Andrew Trick76686492012-09-15 00:19:57 +0000371
Benjamin Kramere1761952015-10-24 12:46:49 +0000372 unsigned addSchedClass(Record *ItinDef, ArrayRef<unsigned> OperWrites,
373 ArrayRef<unsigned> OperReads,
374 ArrayRef<unsigned> ProcIndices);
Andrew Trick76686492012-09-15 00:19:57 +0000375
376 unsigned findOrInsertRW(ArrayRef<unsigned> Seq, bool IsRead);
377
Benjamin Kramere1761952015-10-24 12:46:49 +0000378 unsigned findSchedClassIdx(Record *ItinClassDef, ArrayRef<unsigned> Writes,
379 ArrayRef<unsigned> Reads) const;
Andrew Trick87255e32012-07-07 04:00:00 +0000380
Evandro Menezes9dc54e22017-11-21 21:33:52 +0000381 Record *findProcResUnits(Record *ProcResKind, const CodeGenProcModel &PM,
382 ArrayRef<SMLoc> Loc) const;
Andrew Trick1e46d482012-09-15 00:20:02 +0000383
Andrew Trick87255e32012-07-07 04:00:00 +0000384private:
Andrew Trick76686492012-09-15 00:19:57 +0000385 void collectProcModels();
Andrew Trick87255e32012-07-07 04:00:00 +0000386
387 // Initialize a new processor model if it is unique.
388 void addProcModel(Record *ProcDef);
389
Andrew Trick76686492012-09-15 00:19:57 +0000390 void collectSchedRW();
391
Benjamin Kramere1761952015-10-24 12:46:49 +0000392 std::string genRWName(ArrayRef<unsigned> Seq, bool IsRead);
393 unsigned findRWForSequence(ArrayRef<unsigned> Seq, bool IsRead);
Andrew Trick76686492012-09-15 00:19:57 +0000394
395 void collectSchedClasses();
396
Andrew Trickbf8a28d2013-03-16 18:58:55 +0000397 std::string createSchedClassName(Record *ItinClassDef,
Benjamin Kramere1761952015-10-24 12:46:49 +0000398 ArrayRef<unsigned> OperWrites,
399 ArrayRef<unsigned> OperReads);
Andrew Trick76686492012-09-15 00:19:57 +0000400 std::string createSchedClassName(const RecVec &InstDefs);
401 void createInstRWClass(Record *InstRWDef);
402
403 void collectProcItins();
404
405 void collectProcItinRW();
Andrew Trick33401e82012-09-15 00:19:59 +0000406
Simon Dardis5f95c9a2016-06-24 08:43:27 +0000407 void collectProcUnsupportedFeatures();
408
Andrew Trick33401e82012-09-15 00:19:59 +0000409 void inferSchedClasses();
410
Matthias Braun17cb5792016-03-01 20:03:21 +0000411 void checkCompleteness();
412
Benjamin Kramere1761952015-10-24 12:46:49 +0000413 void inferFromRW(ArrayRef<unsigned> OperWrites, ArrayRef<unsigned> OperReads,
414 unsigned FromClassIdx, ArrayRef<unsigned> ProcIndices);
Andrew Trick33401e82012-09-15 00:19:59 +0000415 void inferFromItinClass(Record *ItinClassDef, unsigned FromClassIdx);
416 void inferFromInstRWs(unsigned SCIdx);
Andrew Trick1e46d482012-09-15 00:20:02 +0000417
Andrew Trickcf398b22013-04-23 23:45:14 +0000418 bool hasSuperGroup(RecVec &SubUnits, CodeGenProcModel &PM);
419 void verifyProcResourceGroups(CodeGenProcModel &PM);
420
Andrew Trick1e46d482012-09-15 00:20:02 +0000421 void collectProcResources();
422
423 void collectItinProcResources(Record *ItinClassDef);
424
Andrew Trickd0b9c442012-10-10 05:43:13 +0000425 void collectRWResources(unsigned RWIdx, bool IsRead,
Benjamin Kramere1761952015-10-24 12:46:49 +0000426 ArrayRef<unsigned> ProcIndices);
Andrew Trickd0b9c442012-10-10 05:43:13 +0000427
Benjamin Kramere1761952015-10-24 12:46:49 +0000428 void collectRWResources(ArrayRef<unsigned> Writes, ArrayRef<unsigned> Reads,
429 ArrayRef<unsigned> ProcIndices);
Andrew Trick1e46d482012-09-15 00:20:02 +0000430
Evandro Menezes9dc54e22017-11-21 21:33:52 +0000431 void addProcResource(Record *ProcResourceKind, CodeGenProcModel &PM,
432 ArrayRef<SMLoc> Loc);
Andrew Trick1e46d482012-09-15 00:20:02 +0000433
434 void addWriteRes(Record *ProcWriteResDef, unsigned PIdx);
435
436 void addReadAdvance(Record *ProcReadAdvanceDef, unsigned PIdx);
Andrew Trick87255e32012-07-07 04:00:00 +0000437};
438
439} // namespace llvm
440
441#endif