@@ -51,19 +51,19 @@ using IdxIter = IdxVec::const_iterator;
5151struct CodeGenSchedRW {
5252 unsigned Index;
5353 std::string Name;
54- Record *TheDef;
54+ const Record *TheDef;
5555 bool IsRead;
5656 bool IsAlias;
5757 bool HasVariants;
5858 bool IsVariadic;
5959 bool IsSequence;
6060 IdxVec Sequence;
61- RecVec Aliases;
61+ ConstRecVec Aliases;
6262
6363 CodeGenSchedRW ()
6464 : Index(0 ), TheDef(nullptr ), IsRead(false ), IsAlias(false ),
6565 HasVariants (false ), IsVariadic(false ), IsSequence(false ) {}
66- CodeGenSchedRW (unsigned Idx, Record *Def)
66+ CodeGenSchedRW (unsigned Idx, const Record *Def)
6767 : Index(Idx), TheDef(Def), IsAlias(false ), IsVariadic(false ) {
6868 Name = std::string (Def->getName ());
6969 IsRead = Def->isSubClassOf (" SchedRead" );
@@ -102,7 +102,7 @@ struct CodeGenSchedRW {
102102struct CodeGenSchedTransition {
103103 unsigned ToClassIdx;
104104 unsigned ProcIndex;
105- RecVec PredTerm;
105+ ConstRecVec PredTerm;
106106};
107107
108108// / Scheduling class.
@@ -145,7 +145,7 @@ struct CodeGenSchedClass {
145145 // Instruction no longer mapped to this class by InstrClassMap. These
146146 // Instructions should be ignored by this class because they have been split
147147 // off to join another inferred class.
148- RecVec InstRWs;
148+ ConstRecVec InstRWs;
149149 // InstRWs processor indices. Filled in inferFromInstRWs
150150 DenseSet<unsigned > InstRWProcIndices;
151151
@@ -189,14 +189,14 @@ struct CodeGenRegisterCost {
189189// / stalls due to register pressure.
190190struct CodeGenRegisterFile {
191191 std::string Name;
192- Record *RegisterFileDef;
192+ const Record *RegisterFileDef;
193193 unsigned MaxMovesEliminatedPerCycle;
194194 bool AllowZeroMoveEliminationOnly;
195195
196196 unsigned NumPhysRegs;
197197 std::vector<CodeGenRegisterCost> Costs;
198198
199- CodeGenRegisterFile (StringRef name, Record *def,
199+ CodeGenRegisterFile (StringRef name, const Record *def,
200200 unsigned MaxMoveElimPerCy = 0 ,
201201 bool AllowZeroMoveElimOnly = false )
202202 : Name(name), RegisterFileDef(def),
@@ -223,8 +223,8 @@ struct CodeGenRegisterFile {
223223struct CodeGenProcModel {
224224 unsigned Index;
225225 std::string ModelName;
226- Record *ModelDef;
227- Record *ItinsDef;
226+ const Record *ModelDef;
227+ const Record *ItinsDef;
228228
229229 // Derived members...
230230
@@ -235,30 +235,31 @@ struct CodeGenProcModel {
235235
236236 // Map itinerary classes to per-operand resources.
237237 // This list is empty if no ItinRW refers to this Processor.
238- RecVec ItinRWDefs;
238+ ConstRecVec ItinRWDefs;
239239
240240 // List of unsupported feature.
241241 // This list is empty if the Processor has no UnsupportedFeatures.
242242 RecVec UnsupportedFeaturesDefs;
243243
244244 // All read/write resources associated with this processor.
245- RecVec WriteResDefs;
246- RecVec ReadAdvanceDefs;
245+ ConstRecVec WriteResDefs;
246+ ConstRecVec ReadAdvanceDefs;
247247
248248 // Per-operand machine model resources associated with this processor.
249- RecVec ProcResourceDefs;
249+ ConstRecVec ProcResourceDefs;
250250
251251 // List of Register Files.
252252 std::vector<CodeGenRegisterFile> RegisterFiles;
253253
254254 // Optional Retire Control Unit definition.
255- Record *RetireControlUnit;
255+ const Record *RetireControlUnit;
256256
257257 // Load/Store queue descriptors.
258- Record *LoadQueue;
259- Record *StoreQueue;
258+ const Record *LoadQueue;
259+ const Record *StoreQueue;
260260
261- CodeGenProcModel (unsigned Idx, std::string Name, Record *MDef, Record *IDef)
261+ CodeGenProcModel (unsigned Idx, std::string Name, const Record *MDef,
262+ const Record *IDef)
262263 : Index(Idx), ModelName(std::move(Name)), ModelDef(MDef), ItinsDef(IDef),
263264 RetireControlUnit (nullptr ), LoadQueue(nullptr ), StoreQueue(nullptr ) {}
264265
@@ -275,12 +276,12 @@ struct CodeGenProcModel {
275276 !RegisterFiles.empty ();
276277 }
277278
278- unsigned getProcResourceIdx (Record *PRDef) const ;
279+ unsigned getProcResourceIdx (const Record *PRDef) const ;
279280
280281 bool isUnsupported (const CodeGenInstruction &Inst) const ;
281282
282283 // Return true if the given write record is referenced by a ReadAdvance.
283- bool hasReadOfWrite (Record *WriteDef) const ;
284+ bool hasReadOfWrite (const Record *WriteDef) const ;
284285
285286#ifndef NDEBUG
286287 void dump () const ;
@@ -421,7 +422,7 @@ using ProcModelMapTy = DenseMap<const Record *, unsigned>;
421422
422423// / Top level container for machine model data.
423424class CodeGenSchedModels {
424- RecordKeeper &Records;
425+ const RecordKeeper &Records;
425426 const CodeGenTarget &Target;
426427
427428 // Map dag expressions to Instruction lists.
@@ -443,8 +444,8 @@ class CodeGenSchedModels {
443444 // Any inferred SchedClass has an index greater than NumInstrSchedClassses.
444445 unsigned NumInstrSchedClasses;
445446
446- RecVec ProcResourceDefs;
447- RecVec ProcResGroups;
447+ ConstRecVec ProcResourceDefs;
448+ ConstRecVec ProcResGroups;
448449
449450 // Map each instruction to its unique SchedClass index considering the
450451 // combination of it's itinerary class, SchedRW list, and InstRW records.
@@ -455,7 +456,7 @@ class CodeGenSchedModels {
455456 std::vector<unsigned > getAllProcIndices () const ;
456457
457458public:
458- CodeGenSchedModels (RecordKeeper &RK, const CodeGenTarget &TGT);
459+ CodeGenSchedModels (const RecordKeeper &RK, const CodeGenTarget &TGT);
459460
460461 // iterator access to the scheduling classes.
461462 using class_iterator = std::vector<CodeGenSchedClass>::iterator;
@@ -477,9 +478,9 @@ class CodeGenSchedModels {
477478 return make_range (classes_begin (), classes_begin () + NumInstrSchedClasses);
478479 }
479480
480- Record *getModelOrItinDef (Record *ProcDef) const {
481- Record *ModelDef = ProcDef->getValueAsDef (" SchedModel" );
482- Record *ItinsDef = ProcDef->getValueAsDef (" ProcItin" );
481+ const Record *getModelOrItinDef (const Record *ProcDef) const {
482+ const Record *ModelDef = ProcDef->getValueAsDef (" SchedModel" );
483+ const Record *ItinsDef = ProcDef->getValueAsDef (" ProcItin" );
483484 if (!ItinsDef->getValueAsListOfDefs (" IID" ).empty ()) {
484485 assert (ModelDef->getValueAsBit (" NoModel" ) &&
485486 " Itineraries must be defined within SchedMachineModel" );
@@ -489,18 +490,18 @@ class CodeGenSchedModels {
489490 }
490491
491492 const CodeGenProcModel &getModelForProc (Record *ProcDef) const {
492- Record *ModelDef = getModelOrItinDef (ProcDef);
493+ const Record *ModelDef = getModelOrItinDef (ProcDef);
493494 ProcModelMapTy::const_iterator I = ProcModelMap.find (ModelDef);
494495 assert (I != ProcModelMap.end () && " missing machine model" );
495496 return ProcModels[I->second ];
496497 }
497498
498- CodeGenProcModel &getProcModel (Record *ModelDef) {
499+ CodeGenProcModel &getProcModel (const Record *ModelDef) {
499500 ProcModelMapTy::const_iterator I = ProcModelMap.find (ModelDef);
500501 assert (I != ProcModelMap.end () && " missing machine model" );
501502 return ProcModels[I->second ];
502503 }
503- const CodeGenProcModel &getProcModel (Record *ModelDef) const {
504+ const CodeGenProcModel &getProcModel (const Record *ModelDef) const {
504505 return const_cast <CodeGenSchedModels *>(this )->getProcModel (ModelDef);
505506 }
506507
@@ -575,8 +576,9 @@ class CodeGenSchedModels {
575576
576577 unsigned findOrInsertRW (ArrayRef<unsigned > Seq, bool IsRead);
577578
578- Record *findProcResUnits (Record *ProcResKind, const CodeGenProcModel &PM,
579- ArrayRef<SMLoc> Loc) const ;
579+ const Record *findProcResUnits (const Record *ProcResKind,
580+ const CodeGenProcModel &PM,
581+ ArrayRef<SMLoc> Loc) const ;
580582
581583 ArrayRef<STIPredicateFunction> getSTIPredicates () const {
582584 return STIPredicates;
@@ -586,7 +588,7 @@ class CodeGenSchedModels {
586588 void collectProcModels ();
587589
588590 // Initialize a new processor model if it is unique.
589- void addProcModel (Record *ProcDef);
591+ void addProcModel (const Record *ProcDef);
590592
591593 void collectSchedRW ();
592594
@@ -605,7 +607,7 @@ class CodeGenSchedModels {
605607 ArrayRef<unsigned > OperWrites,
606608 ArrayRef<unsigned > OperReads);
607609 std::string createSchedClassName (const ConstRecVec &InstDefs);
608- void createInstRWClass (Record *InstRWDef);
610+ void createInstRWClass (const Record *InstRWDef);
609611
610612 void collectProcItins ();
611613
@@ -643,12 +645,12 @@ class CodeGenSchedModels {
643645 void collectRWResources (ArrayRef<unsigned > Writes, ArrayRef<unsigned > Reads,
644646 ArrayRef<unsigned > ProcIndices);
645647
646- void addProcResource (Record *ProcResourceKind, CodeGenProcModel &PM,
648+ void addProcResource (const Record *ProcResourceKind, CodeGenProcModel &PM,
647649 ArrayRef<SMLoc> Loc);
648650
649- void addWriteRes (Record *ProcWriteResDef, unsigned PIdx);
651+ void addWriteRes (const Record *ProcWriteResDef, unsigned PIdx);
650652
651- void addReadAdvance (Record *ProcReadAdvanceDef, unsigned PIdx);
653+ void addReadAdvance (const Record *ProcReadAdvanceDef, unsigned PIdx);
652654};
653655
654656} // namespace llvm
0 commit comments