@@ -55,13 +55,13 @@ using namespace llvm;
55
55
namespace {
56
56
57
57
class AsmWriterEmitter {
58
- RecordKeeper &Records;
58
+ const RecordKeeper &Records;
59
59
CodeGenTarget Target;
60
60
ArrayRef<const CodeGenInstruction *> NumberedInstructions;
61
61
std::vector<AsmWriterInst> Instructions;
62
62
63
63
public:
64
- AsmWriterEmitter (RecordKeeper &R);
64
+ AsmWriterEmitter (const RecordKeeper &R);
65
65
66
66
void run (raw_ostream &o);
67
67
@@ -326,7 +326,7 @@ void AsmWriterEmitter::EmitGetMnemonic(
326
326
raw_ostream &O,
327
327
std::vector<std::vector<std::string>> &TableDrivenOperandPrinters,
328
328
unsigned &BitsLeft, unsigned &AsmStrBits) {
329
- Record *AsmWriter = Target.getAsmWriter ();
329
+ const Record *AsmWriter = Target.getAsmWriter ();
330
330
StringRef ClassName = AsmWriter->getValueAsString (" AsmWriterClassName" );
331
331
bool PassSubtarget = AsmWriter->getValueAsInt (" PassSubtarget" );
332
332
@@ -486,7 +486,7 @@ void AsmWriterEmitter::EmitPrintInstruction(
486
486
std::vector<std::vector<std::string>> &TableDrivenOperandPrinters,
487
487
unsigned &BitsLeft, unsigned &AsmStrBits) {
488
488
const unsigned OpcodeInfoBits = 64 ;
489
- Record *AsmWriter = Target.getAsmWriter ();
489
+ const Record *AsmWriter = Target.getAsmWriter ();
490
490
StringRef ClassName = AsmWriter->getValueAsString (" AsmWriterClassName" );
491
491
bool PassSubtarget = AsmWriter->getValueAsInt (" PassSubtarget" );
492
492
@@ -596,8 +596,8 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName,
596
596
AsmName = std::string (Reg.getName ());
597
597
} else {
598
598
// Make sure the register has an alternate name for this index.
599
- std::vector<Record *> AltNameList =
600
- Reg.TheDef ->getValueAsListOfDefs (" RegAltNameIndices" );
599
+ std::vector<const Record *> AltNameList =
600
+ Reg.TheDef ->getValueAsListOfConstDefs (" RegAltNameIndices" );
601
601
unsigned Idx = 0 , e;
602
602
for (e = AltNameList.size ();
603
603
Idx < e && (AltNameList[Idx]->getName () != AltName); ++Idx)
@@ -633,7 +633,7 @@ emitRegisterNameString(raw_ostream &O, StringRef AltName,
633
633
}
634
634
635
635
void AsmWriterEmitter::EmitGetRegisterName (raw_ostream &O) {
636
- Record *AsmWriter = Target.getAsmWriter ();
636
+ const Record *AsmWriter = Target.getAsmWriter ();
637
637
StringRef ClassName = AsmWriter->getValueAsString (" AsmWriterClassName" );
638
638
const auto &Registers = Target.getRegBank ().getRegisters ();
639
639
ArrayRef<const Record *> AltNameIndices = Target.getRegAltNameIndices ();
@@ -829,7 +829,7 @@ struct AliasPriorityComparator {
829
829
} // end anonymous namespace
830
830
831
831
void AsmWriterEmitter::EmitPrintAliasInstruction (raw_ostream &O) {
832
- Record *AsmWriter = Target.getAsmWriter ();
832
+ const Record *AsmWriter = Target.getAsmWriter ();
833
833
834
834
O << " \n #ifdef PRINT_ALIAS_INSTR\n " ;
835
835
O << " #undef PRINT_ALIAS_INSTR\n\n " ;
@@ -843,14 +843,11 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
843
843
unsigned Variant = AsmWriter->getValueAsInt (" Variant" );
844
844
bool PassSubtarget = AsmWriter->getValueAsInt (" PassSubtarget" );
845
845
846
- std::vector<Record *> AllInstAliases =
847
- Records.getAllDerivedDefinitions (" InstAlias" );
848
-
849
846
// Create a map from the qualified name to a list of potential matches.
850
847
typedef std::set<std::pair<CodeGenInstAlias, int >, AliasPriorityComparator>
851
848
AliasWithPriority;
852
849
std::map<std::string, AliasWithPriority> AliasMap;
853
- for (Record *R : AllInstAliases ) {
850
+ for (const Record *R : Records. getAllDerivedDefinitions ( " InstAlias " ) ) {
854
851
int Priority = R->getValueAsInt (" EmitPriority" );
855
852
if (Priority < 1 )
856
853
continue ; // Aliases with priority 0 are never emitted.
@@ -1011,17 +1008,17 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
1011
1008
MIOpNum += RO.getMINumOperands ();
1012
1009
}
1013
1010
1014
- std::vector<Record *> ReqFeatures;
1011
+ std::vector<const Record *> ReqFeatures;
1015
1012
if (PassSubtarget) {
1016
1013
// We only consider ReqFeatures predicates if PassSubtarget
1017
- std::vector<Record *> RF =
1018
- CGA.TheDef ->getValueAsListOfDefs (" Predicates" );
1019
- copy_if (RF, std::back_inserter (ReqFeatures), [](Record *R) {
1014
+ std::vector<const Record *> RF =
1015
+ CGA.TheDef ->getValueAsListOfConstDefs (" Predicates" );
1016
+ copy_if (RF, std::back_inserter (ReqFeatures), [](const Record *R) {
1020
1017
return R->getValueAsBit (" AssemblerMatcherPredicate" );
1021
1018
});
1022
1019
}
1023
1020
1024
- for (Record *const R : ReqFeatures) {
1021
+ for (const Record *R : ReqFeatures) {
1025
1022
const DagInit *D = R->getValueAsDag (" AssemblerCondDag" );
1026
1023
auto *Op = dyn_cast<DefInit>(D->getOperator ());
1027
1024
if (!Op)
@@ -1315,17 +1312,17 @@ void AsmWriterEmitter::EmitPrintAliasInstruction(raw_ostream &O) {
1315
1312
O << " #endif // PRINT_ALIAS_INSTR\n " ;
1316
1313
}
1317
1314
1318
- AsmWriterEmitter::AsmWriterEmitter (RecordKeeper &R) : Records(R), Target(R) {
1319
- Record *AsmWriter = Target.getAsmWriter ();
1315
+ AsmWriterEmitter::AsmWriterEmitter (const RecordKeeper &R)
1316
+ : Records(R), Target(R) {
1317
+ const Record *AsmWriter = Target.getAsmWriter ();
1320
1318
unsigned Variant = AsmWriter->getValueAsInt (" Variant" );
1321
1319
1322
1320
// Get the instruction numbering.
1323
1321
NumberedInstructions = Target.getInstructionsByEnumValue ();
1324
1322
1325
- for (unsigned i = 0 , e = NumberedInstructions.size (); i != e; ++i) {
1326
- const CodeGenInstruction *I = NumberedInstructions[i];
1323
+ for (const auto &[Idx, I] : enumerate(NumberedInstructions)) {
1327
1324
if (!I->AsmString .empty () && I->TheDef ->getName () != " PHI" )
1328
- Instructions.emplace_back (*I, i , Variant);
1325
+ Instructions.emplace_back (*I, Idx , Variant);
1329
1326
}
1330
1327
}
1331
1328
0 commit comments