@@ -51,19 +51,19 @@ using IdxIter = IdxVec::const_iterator;
51
51
struct CodeGenSchedRW {
52
52
unsigned Index;
53
53
std::string Name;
54
- Record *TheDef;
54
+ const Record *TheDef;
55
55
bool IsRead;
56
56
bool IsAlias;
57
57
bool HasVariants;
58
58
bool IsVariadic;
59
59
bool IsSequence;
60
60
IdxVec Sequence;
61
- RecVec Aliases;
61
+ ConstRecVec Aliases;
62
62
63
63
CodeGenSchedRW ()
64
64
: Index(0 ), TheDef(nullptr ), IsRead(false ), IsAlias(false ),
65
65
HasVariants (false ), IsVariadic(false ), IsSequence(false ) {}
66
- CodeGenSchedRW (unsigned Idx, Record *Def)
66
+ CodeGenSchedRW (unsigned Idx, const Record *Def)
67
67
: Index(Idx), TheDef(Def), IsAlias(false ), IsVariadic(false ) {
68
68
Name = std::string (Def->getName ());
69
69
IsRead = Def->isSubClassOf (" SchedRead" );
@@ -102,7 +102,7 @@ struct CodeGenSchedRW {
102
102
struct CodeGenSchedTransition {
103
103
unsigned ToClassIdx;
104
104
unsigned ProcIndex;
105
- RecVec PredTerm;
105
+ ConstRecVec PredTerm;
106
106
};
107
107
108
108
// / Scheduling class.
@@ -145,7 +145,7 @@ struct CodeGenSchedClass {
145
145
// Instruction no longer mapped to this class by InstrClassMap. These
146
146
// Instructions should be ignored by this class because they have been split
147
147
// off to join another inferred class.
148
- RecVec InstRWs;
148
+ ConstRecVec InstRWs;
149
149
// InstRWs processor indices. Filled in inferFromInstRWs
150
150
DenseSet<unsigned > InstRWProcIndices;
151
151
@@ -189,14 +189,14 @@ struct CodeGenRegisterCost {
189
189
// / stalls due to register pressure.
190
190
struct CodeGenRegisterFile {
191
191
std::string Name;
192
- Record *RegisterFileDef;
192
+ const Record *RegisterFileDef;
193
193
unsigned MaxMovesEliminatedPerCycle;
194
194
bool AllowZeroMoveEliminationOnly;
195
195
196
196
unsigned NumPhysRegs;
197
197
std::vector<CodeGenRegisterCost> Costs;
198
198
199
- CodeGenRegisterFile (StringRef name, Record *def,
199
+ CodeGenRegisterFile (StringRef name, const Record *def,
200
200
unsigned MaxMoveElimPerCy = 0 ,
201
201
bool AllowZeroMoveElimOnly = false )
202
202
: Name(name), RegisterFileDef(def),
@@ -223,8 +223,8 @@ struct CodeGenRegisterFile {
223
223
struct CodeGenProcModel {
224
224
unsigned Index;
225
225
std::string ModelName;
226
- Record *ModelDef;
227
- Record *ItinsDef;
226
+ const Record *ModelDef;
227
+ const Record *ItinsDef;
228
228
229
229
// Derived members...
230
230
@@ -235,30 +235,31 @@ struct CodeGenProcModel {
235
235
236
236
// Map itinerary classes to per-operand resources.
237
237
// This list is empty if no ItinRW refers to this Processor.
238
- RecVec ItinRWDefs;
238
+ ConstRecVec ItinRWDefs;
239
239
240
240
// List of unsupported feature.
241
241
// This list is empty if the Processor has no UnsupportedFeatures.
242
242
RecVec UnsupportedFeaturesDefs;
243
243
244
244
// All read/write resources associated with this processor.
245
- RecVec WriteResDefs;
246
- RecVec ReadAdvanceDefs;
245
+ ConstRecVec WriteResDefs;
246
+ ConstRecVec ReadAdvanceDefs;
247
247
248
248
// Per-operand machine model resources associated with this processor.
249
- RecVec ProcResourceDefs;
249
+ ConstRecVec ProcResourceDefs;
250
250
251
251
// List of Register Files.
252
252
std::vector<CodeGenRegisterFile> RegisterFiles;
253
253
254
254
// Optional Retire Control Unit definition.
255
- Record *RetireControlUnit;
255
+ const Record *RetireControlUnit;
256
256
257
257
// Load/Store queue descriptors.
258
- Record *LoadQueue;
259
- Record *StoreQueue;
258
+ const Record *LoadQueue;
259
+ const Record *StoreQueue;
260
260
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)
262
263
: Index(Idx), ModelName(std::move(Name)), ModelDef(MDef), ItinsDef(IDef),
263
264
RetireControlUnit (nullptr ), LoadQueue(nullptr ), StoreQueue(nullptr ) {}
264
265
@@ -275,12 +276,12 @@ struct CodeGenProcModel {
275
276
!RegisterFiles.empty ();
276
277
}
277
278
278
- unsigned getProcResourceIdx (Record *PRDef) const ;
279
+ unsigned getProcResourceIdx (const Record *PRDef) const ;
279
280
280
281
bool isUnsupported (const CodeGenInstruction &Inst) const ;
281
282
282
283
// 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 ;
284
285
285
286
#ifndef NDEBUG
286
287
void dump () const ;
@@ -421,7 +422,7 @@ using ProcModelMapTy = DenseMap<const Record *, unsigned>;
421
422
422
423
// / Top level container for machine model data.
423
424
class CodeGenSchedModels {
424
- RecordKeeper &Records;
425
+ const RecordKeeper &Records;
425
426
const CodeGenTarget &Target;
426
427
427
428
// Map dag expressions to Instruction lists.
@@ -443,8 +444,8 @@ class CodeGenSchedModels {
443
444
// Any inferred SchedClass has an index greater than NumInstrSchedClassses.
444
445
unsigned NumInstrSchedClasses;
445
446
446
- RecVec ProcResourceDefs;
447
- RecVec ProcResGroups;
447
+ ConstRecVec ProcResourceDefs;
448
+ ConstRecVec ProcResGroups;
448
449
449
450
// Map each instruction to its unique SchedClass index considering the
450
451
// combination of it's itinerary class, SchedRW list, and InstRW records.
@@ -455,7 +456,7 @@ class CodeGenSchedModels {
455
456
std::vector<unsigned > getAllProcIndices () const ;
456
457
457
458
public:
458
- CodeGenSchedModels (RecordKeeper &RK, const CodeGenTarget &TGT);
459
+ CodeGenSchedModels (const RecordKeeper &RK, const CodeGenTarget &TGT);
459
460
460
461
// iterator access to the scheduling classes.
461
462
using class_iterator = std::vector<CodeGenSchedClass>::iterator;
@@ -477,9 +478,9 @@ class CodeGenSchedModels {
477
478
return make_range (classes_begin (), classes_begin () + NumInstrSchedClasses);
478
479
}
479
480
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" );
483
484
if (!ItinsDef->getValueAsListOfDefs (" IID" ).empty ()) {
484
485
assert (ModelDef->getValueAsBit (" NoModel" ) &&
485
486
" Itineraries must be defined within SchedMachineModel" );
@@ -489,18 +490,18 @@ class CodeGenSchedModels {
489
490
}
490
491
491
492
const CodeGenProcModel &getModelForProc (Record *ProcDef) const {
492
- Record *ModelDef = getModelOrItinDef (ProcDef);
493
+ const Record *ModelDef = getModelOrItinDef (ProcDef);
493
494
ProcModelMapTy::const_iterator I = ProcModelMap.find (ModelDef);
494
495
assert (I != ProcModelMap.end () && " missing machine model" );
495
496
return ProcModels[I->second ];
496
497
}
497
498
498
- CodeGenProcModel &getProcModel (Record *ModelDef) {
499
+ CodeGenProcModel &getProcModel (const Record *ModelDef) {
499
500
ProcModelMapTy::const_iterator I = ProcModelMap.find (ModelDef);
500
501
assert (I != ProcModelMap.end () && " missing machine model" );
501
502
return ProcModels[I->second ];
502
503
}
503
- const CodeGenProcModel &getProcModel (Record *ModelDef) const {
504
+ const CodeGenProcModel &getProcModel (const Record *ModelDef) const {
504
505
return const_cast <CodeGenSchedModels *>(this )->getProcModel (ModelDef);
505
506
}
506
507
@@ -575,8 +576,9 @@ class CodeGenSchedModels {
575
576
576
577
unsigned findOrInsertRW (ArrayRef<unsigned > Seq, bool IsRead);
577
578
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 ;
580
582
581
583
ArrayRef<STIPredicateFunction> getSTIPredicates () const {
582
584
return STIPredicates;
@@ -586,7 +588,7 @@ class CodeGenSchedModels {
586
588
void collectProcModels ();
587
589
588
590
// Initialize a new processor model if it is unique.
589
- void addProcModel (Record *ProcDef);
591
+ void addProcModel (const Record *ProcDef);
590
592
591
593
void collectSchedRW ();
592
594
@@ -605,7 +607,7 @@ class CodeGenSchedModels {
605
607
ArrayRef<unsigned > OperWrites,
606
608
ArrayRef<unsigned > OperReads);
607
609
std::string createSchedClassName (const ConstRecVec &InstDefs);
608
- void createInstRWClass (Record *InstRWDef);
610
+ void createInstRWClass (const Record *InstRWDef);
609
611
610
612
void collectProcItins ();
611
613
@@ -643,12 +645,12 @@ class CodeGenSchedModels {
643
645
void collectRWResources (ArrayRef<unsigned > Writes, ArrayRef<unsigned > Reads,
644
646
ArrayRef<unsigned > ProcIndices);
645
647
646
- void addProcResource (Record *ProcResourceKind, CodeGenProcModel &PM,
648
+ void addProcResource (const Record *ProcResourceKind, CodeGenProcModel &PM,
647
649
ArrayRef<SMLoc> Loc);
648
650
649
- void addWriteRes (Record *ProcWriteResDef, unsigned PIdx);
651
+ void addWriteRes (const Record *ProcWriteResDef, unsigned PIdx);
650
652
651
- void addReadAdvance (Record *ProcReadAdvanceDef, unsigned PIdx);
653
+ void addReadAdvance (const Record *ProcReadAdvanceDef, unsigned PIdx);
652
654
};
653
655
654
656
} // namespace llvm
0 commit comments