@@ -85,9 +85,9 @@ std::string llvm::getQualifiedName(const Record *R) {
85
85
86
86
// / getTarget - Return the current instance of the Target class.
87
87
// /
88
- CodeGenTarget::CodeGenTarget (RecordKeeper &records)
88
+ CodeGenTarget::CodeGenTarget (const RecordKeeper &records)
89
89
: Records(records), CGH(records), Intrinsics(records) {
90
- std::vector< Record *> Targets = Records.getAllDerivedDefinitions (" Target" );
90
+ ArrayRef< const Record *> Targets = Records.getAllDerivedDefinitions (" Target" );
91
91
if (Targets.size () == 0 )
92
92
PrintFatalError (" No 'Target' subclasses defined!" );
93
93
if (Targets.size () != 1 )
@@ -223,11 +223,6 @@ std::optional<CodeGenRegisterClass *> CodeGenTarget::getSuperRegForSubReg(
223
223
return Candidates[0 ];
224
224
}
225
225
226
- void CodeGenTarget::ReadRegAltNameIndices () const {
227
- RegAltNameIndices = Records.getAllDerivedDefinitions (" RegAltNameIndex" );
228
- llvm::sort (RegAltNameIndices, LessRecord ());
229
- }
230
-
231
226
// / getRegisterByName - If there is a register with the specific AsmName,
232
227
// / return it.
233
228
const CodeGenRegister *CodeGenTarget::getRegisterByName (StringRef Name) const {
@@ -271,12 +266,13 @@ CodeGenSchedModels &CodeGenTarget::getSchedModels() const {
271
266
}
272
267
273
268
void CodeGenTarget::ReadInstructions () const {
274
- std::vector<Record *> Insts = Records.getAllDerivedDefinitions (" Instruction" );
269
+ ArrayRef<const Record *> Insts =
270
+ Records.getAllDerivedDefinitions (" Instruction" );
275
271
if (Insts.size () <= 2 )
276
272
PrintFatalError (" No 'Instruction' subclasses defined!" );
277
273
278
274
// Parse the instructions defined in the .td file.
279
- for (Record *R : Insts) {
275
+ for (const Record *R : Insts) {
280
276
Instructions[R] = std::make_unique<CodeGenInstruction>(R);
281
277
if (Instructions[R]->isVariableLengthEncoding ())
282
278
HasVariableLengthEncodings = true ;
@@ -286,7 +282,7 @@ void CodeGenTarget::ReadInstructions() const {
286
282
static const CodeGenInstruction *GetInstByName (
287
283
const char *Name,
288
284
const DenseMap<const Record *, std::unique_ptr<CodeGenInstruction>> &Insts,
289
- RecordKeeper &Records) {
285
+ const RecordKeeper &Records) {
290
286
const Record *Rec = Records.getDef (Name);
291
287
292
288
const auto I = Insts.find (Rec);
@@ -358,9 +354,8 @@ void CodeGenTarget::reverseBitsForLittleEndianEncoding() {
358
354
if (!isLittleEndianEncoding ())
359
355
return ;
360
356
361
- std::vector<Record *> Insts =
362
- Records.getAllDerivedDefinitions (" InstructionEncoding" );
363
- for (Record *R : Insts) {
357
+ for (const Record *R :
358
+ Records.getAllDerivedDefinitions (" InstructionEncoding" )) {
364
359
if (R->getValueAsString (" Namespace" ) == " TargetOpcode" ||
365
360
R->getValueAsBit (" isPseudo" ))
366
361
continue ;
@@ -383,11 +378,15 @@ void CodeGenTarget::reverseBitsForLittleEndianEncoding() {
383
378
NewBits[middle] = BI->getBit (middle);
384
379
}
385
380
386
- BitsInit *NewBI = BitsInit::get (Records, NewBits);
381
+ RecordKeeper &MutableRC = const_cast <RecordKeeper &>(Records);
382
+ BitsInit *NewBI = BitsInit::get (MutableRC, NewBits);
387
383
388
- // Update the bits in reversed order so that emitInstrOpBits will get the
389
- // correct endianness.
390
- R->getValue (" Inst" )->setValue (NewBI);
384
+ // Update the bits in reversed order so that emitters will get the correct
385
+ // endianness.
386
+ // FIXME: Eliminate mutation of TG records by creating a helper function
387
+ // to reverse bits and maintain a cache instead of mutating records.
388
+ Record *MutableR = const_cast <Record *>(R);
389
+ MutableR->getValue (" Inst" )->setValue (NewBI);
391
390
}
392
391
}
393
392
0 commit comments