@@ -143,10 +143,10 @@ class AsmMatcherInfo;
143
143
typedef std::set<const Record *, LessRecordByID> RegisterSet;
144
144
145
145
class AsmMatcherEmitter {
146
- RecordKeeper &Records;
146
+ const RecordKeeper &Records;
147
147
148
148
public:
149
- AsmMatcherEmitter (RecordKeeper &R) : Records(R) {}
149
+ AsmMatcherEmitter (const RecordKeeper &R) : Records(R) {}
150
150
151
151
void run (raw_ostream &o);
152
152
};
@@ -739,13 +739,13 @@ struct OperandMatchEntry {
739
739
class AsmMatcherInfo {
740
740
public:
741
741
// / Tracked Records
742
- RecordKeeper &Records;
742
+ const RecordKeeper &Records;
743
743
744
744
// / The tablegen AsmParser record.
745
- Record *AsmParser;
745
+ const Record *AsmParser;
746
746
747
747
// / Target - The target information.
748
- CodeGenTarget &Target;
748
+ const CodeGenTarget &Target;
749
749
750
750
// / The classes which are needed for matching.
751
751
std::forward_list<ClassInfo> Classes;
@@ -798,8 +798,8 @@ class AsmMatcherInfo {
798
798
MatchableInfo::AsmOperand &Op);
799
799
800
800
public:
801
- AsmMatcherInfo (Record *AsmParser, CodeGenTarget &Target,
802
- RecordKeeper &Records);
801
+ AsmMatcherInfo (const Record *AsmParser, const CodeGenTarget &Target,
802
+ const RecordKeeper &Records);
803
803
804
804
// / Construct the various tables used during matching.
805
805
void buildInfo ();
@@ -816,7 +816,7 @@ class AsmMatcherInfo {
816
816
return I == SubtargetFeatures.end () ? nullptr : &I->second ;
817
817
}
818
818
819
- RecordKeeper &getRecords () const { return Records; }
819
+ const RecordKeeper &getRecords () const { return Records; }
820
820
821
821
bool hasOptionalOperands () const {
822
822
return any_of (Classes,
@@ -965,7 +965,7 @@ void MatchableInfo::initialize(
965
965
Mnemonic = AsmOperands[0 ].Token ;
966
966
967
967
// Compute the require features.
968
- for (Record *Predicate : TheDef->getValueAsListOfDefs (" Predicates" ))
968
+ for (const Record *Predicate : TheDef->getValueAsListOfDefs (" Predicates" ))
969
969
if (const SubtargetFeatureInfo *Feature =
970
970
Info.getSubtargetFeature (Predicate))
971
971
RequiredFeatures.push_back (Feature);
@@ -1215,7 +1215,7 @@ ClassInfo *AsmMatcherInfo::getOperandClass(const Record *Rec, int SubOpIdx) {
1215
1215
}
1216
1216
1217
1217
// No custom match class. Just use the register class.
1218
- Record *ClassRec = Rec->getValueAsDef (" RegClass" );
1218
+ const Record *ClassRec = Rec->getValueAsDef (" RegClass" );
1219
1219
if (!ClassRec)
1220
1220
PrintFatalError (Rec->getLoc (),
1221
1221
" RegisterOperand `" + Rec->getName () +
@@ -1235,7 +1235,7 @@ ClassInfo *AsmMatcherInfo::getOperandClass(const Record *Rec, int SubOpIdx) {
1235
1235
PrintFatalError (Rec->getLoc (),
1236
1236
" Operand `" + Rec->getName () +
1237
1237
" ' does not derive from class Operand!\n " );
1238
- Record *MatchClass = Rec->getValueAsDef (" ParserMatchClass" );
1238
+ const Record *MatchClass = Rec->getValueAsDef (" ParserMatchClass" );
1239
1239
if (ClassInfo *CI = AsmOperandClasses[MatchClass])
1240
1240
return CI;
1241
1241
@@ -1384,17 +1384,17 @@ void AsmMatcherInfo::buildRegisterClasses(
1384
1384
}
1385
1385
1386
1386
void AsmMatcherInfo::buildOperandClasses () {
1387
- std::vector< Record *> AsmOperands =
1387
+ ArrayRef< const Record *> AsmOperands =
1388
1388
Records.getAllDerivedDefinitions (" AsmOperandClass" );
1389
1389
1390
1390
// Pre-populate AsmOperandClasses map.
1391
- for (Record *Rec : AsmOperands) {
1391
+ for (const Record *Rec : AsmOperands) {
1392
1392
Classes.emplace_front ();
1393
1393
AsmOperandClasses[Rec] = &Classes.front ();
1394
1394
}
1395
1395
1396
1396
unsigned Index = 0 ;
1397
- for (Record *Rec : AsmOperands) {
1397
+ for (const Record *Rec : AsmOperands) {
1398
1398
ClassInfo *CI = AsmOperandClasses[Rec];
1399
1399
CI->Kind = ClassInfo::UserClass0 + Index;
1400
1400
@@ -1468,14 +1468,14 @@ void AsmMatcherInfo::buildOperandClasses() {
1468
1468
}
1469
1469
}
1470
1470
1471
- AsmMatcherInfo::AsmMatcherInfo (Record *asmParser, CodeGenTarget &target,
1472
- RecordKeeper &records)
1471
+ AsmMatcherInfo::AsmMatcherInfo (const Record *asmParser,
1472
+ const CodeGenTarget &target,
1473
+ const RecordKeeper &records)
1473
1474
: Records(records), AsmParser(asmParser), Target(target) {}
1474
1475
1475
1476
// / buildOperandMatchInfo - Build the necessary information to handle user
1476
1477
// / defined operand parsing methods.
1477
1478
void AsmMatcherInfo::buildOperandMatchInfo () {
1478
-
1479
1479
// / Map containing a mask with all operands indices that can be found for
1480
1480
// / that class inside a instruction.
1481
1481
typedef std::map<ClassInfo *, unsigned , deref<std::less<>>> OpClassMaskTy;
@@ -1527,7 +1527,7 @@ void AsmMatcherInfo::buildInfo() {
1527
1527
SmallPtrSet<const Record *, 16 > SingletonRegisters;
1528
1528
unsigned VariantCount = Target.getAsmParserVariantCount ();
1529
1529
for (unsigned VC = 0 ; VC != VariantCount; ++VC) {
1530
- Record *AsmVariant = Target.getAsmParserVariant (VC);
1530
+ const Record *AsmVariant = Target.getAsmParserVariant (VC);
1531
1531
StringRef CommentDelimiter =
1532
1532
AsmVariant->getValueAsString (" CommentDelimiter" );
1533
1533
AsmVariantInfo Variant;
@@ -1570,9 +1570,8 @@ void AsmMatcherInfo::buildInfo() {
1570
1570
1571
1571
// Parse all of the InstAlias definitions and stick them in the list of
1572
1572
// matchables.
1573
- std::vector<Record *> AllInstAliases =
1574
- Records.getAllDerivedDefinitions (" InstAlias" );
1575
- for (Record *InstAlias : AllInstAliases) {
1573
+ for (const Record *InstAlias :
1574
+ Records.getAllDerivedDefinitions (" InstAlias" )) {
1576
1575
auto Alias = std::make_unique<CodeGenInstAlias>(InstAlias, Target);
1577
1576
1578
1577
// If the tblgen -match-prefix option is specified (for tblgen hackers),
@@ -1678,9 +1677,7 @@ void AsmMatcherInfo::buildInfo() {
1678
1677
1679
1678
// Process token alias definitions and set up the associated superclass
1680
1679
// information.
1681
- std::vector<Record *> AllTokenAliases =
1682
- Records.getAllDerivedDefinitions (" TokenAlias" );
1683
- for (Record *Rec : AllTokenAliases) {
1680
+ for (const Record *Rec : Records.getAllDerivedDefinitions (" TokenAlias" )) {
1684
1681
ClassInfo *FromClass = getTokenClass (Rec->getValueAsString (" FromToken" ));
1685
1682
ClassInfo *ToClass = getTokenClass (Rec->getValueAsString (" ToToken" ));
1686
1683
if (FromClass == ToClass)
@@ -2616,8 +2613,8 @@ static void emitMatchTokenString(CodeGenTarget &Target,
2616
2613
2617
2614
// / emitMatchRegisterName - Emit the function to match a string to the target
2618
2615
// / specific register enum.
2619
- static void emitMatchRegisterName (CodeGenTarget &Target, Record *AsmParser ,
2620
- raw_ostream &OS) {
2616
+ static void emitMatchRegisterName (const CodeGenTarget &Target,
2617
+ const Record *AsmParser, raw_ostream &OS) {
2621
2618
// Construct the match list.
2622
2619
std::vector<StringMatcher::StringPair> Matches;
2623
2620
const auto &Regs = Target.getRegBank ().getRegisters ();
@@ -2644,8 +2641,8 @@ static void emitMatchRegisterName(CodeGenTarget &Target, Record *AsmParser,
2644
2641
2645
2642
// / Emit the function to match a string to the target
2646
2643
// / specific register enum.
2647
- static void emitMatchRegisterAltName (CodeGenTarget &Target, Record *AsmParser ,
2648
- raw_ostream &OS) {
2644
+ static void emitMatchRegisterAltName (const CodeGenTarget &Target,
2645
+ const Record *AsmParser, raw_ostream &OS) {
2649
2646
// Construct the match list.
2650
2647
std::vector<StringMatcher::StringPair> Matches;
2651
2648
const auto &Regs = Target.getRegBank ().getRegisters ();
@@ -2744,13 +2741,13 @@ static std::string GetAliasRequiredFeatures(const Record *R,
2744
2741
2745
2742
static void
2746
2743
emitMnemonicAliasVariant (raw_ostream &OS, const AsmMatcherInfo &Info,
2747
- std::vector< Record *> & Aliases, unsigned Indent = 0 ,
2744
+ ArrayRef< const Record *> Aliases, unsigned Indent = 0 ,
2748
2745
StringRef AsmParserVariantName = StringRef()) {
2749
2746
// Keep track of all the aliases from a mnemonic. Use an std::map so that the
2750
2747
// iteration order of the map is stable.
2751
- std::map<std::string, std::vector<Record *>> AliasesFromMnemonic;
2748
+ std::map<std::string, std::vector<const Record *>> AliasesFromMnemonic;
2752
2749
2753
- for (Record *R : Aliases) {
2750
+ for (const Record *R : Aliases) {
2754
2751
// FIXME: Allow AssemblerVariantName to be a comma separated list.
2755
2752
StringRef AsmVariantName = R->getValueAsString (" AsmVariantName" );
2756
2753
if (AsmVariantName != AsmParserVariantName)
@@ -2827,7 +2824,7 @@ static bool emitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info,
2827
2824
if (!MatchPrefix.empty ())
2828
2825
return false ;
2829
2826
2830
- std::vector< Record *> Aliases =
2827
+ ArrayRef< const Record *> Aliases =
2831
2828
Info.getRecords ().getAllDerivedDefinitions (" MnemonicAlias" );
2832
2829
if (Aliases.empty ())
2833
2830
return false ;
@@ -2836,7 +2833,7 @@ static bool emitMnemonicAliases(raw_ostream &OS, const AsmMatcherInfo &Info,
2836
2833
" const FeatureBitset &Features, unsigned VariantID) {\n " ;
2837
2834
unsigned VariantCount = Target.getAsmParserVariantCount ();
2838
2835
for (unsigned VC = 0 ; VC != VariantCount; ++VC) {
2839
- Record *AsmVariant = Target.getAsmParserVariant (VC);
2836
+ const Record *AsmVariant = Target.getAsmParserVariant (VC);
2840
2837
int AsmParserVariantNo = AsmVariant->getValueAsInt (" Variant" );
2841
2838
StringRef AsmParserVariantName = AsmVariant->getValueAsString (" Name" );
2842
2839
@@ -3104,7 +3101,7 @@ static void emitMnemonicSpellChecker(raw_ostream &OS, CodeGenTarget &Target,
3104
3101
OS << " switch (VariantID) {\n " ;
3105
3102
OS << " default: llvm_unreachable(\" invalid variant!\" );\n " ;
3106
3103
for (unsigned VC = 0 ; VC != VariantCount; ++VC) {
3107
- Record *AsmVariant = Target.getAsmParserVariant (VC);
3104
+ const Record *AsmVariant = Target.getAsmParserVariant (VC);
3108
3105
int AsmVariantNo = AsmVariant->getValueAsInt (" Variant" );
3109
3106
OS << " case " << AsmVariantNo << " : Start = std::begin(MatchTable" << VC
3110
3107
<< " ); End = std::end(MatchTable" << VC << " ); break;\n " ;
@@ -3164,7 +3161,7 @@ static void emitMnemonicChecker(raw_ostream &OS, CodeGenTarget &Target,
3164
3161
OS << " switch (VariantID) {\n " ;
3165
3162
OS << " default: llvm_unreachable(\" invalid variant!\" );\n " ;
3166
3163
for (unsigned VC = 0 ; VC != VariantCount; ++VC) {
3167
- Record *AsmVariant = Target.getAsmParserVariant (VC);
3164
+ const Record *AsmVariant = Target.getAsmParserVariant (VC);
3168
3165
int AsmVariantNo = AsmVariant->getValueAsInt (" Variant" );
3169
3166
OS << " case " << AsmVariantNo << " : Start = std::begin(MatchTable" << VC
3170
3167
<< " ); End = std::end(MatchTable" << VC << " ); break;\n " ;
@@ -3231,7 +3228,7 @@ getNameForFeatureBitset(ArrayRef<const Record *> FeatureBitset) {
3231
3228
3232
3229
void AsmMatcherEmitter::run (raw_ostream &OS) {
3233
3230
CodeGenTarget Target (Records);
3234
- Record *AsmParser = Target.getAsmParser ();
3231
+ const Record *AsmParser = Target.getAsmParser ();
3235
3232
StringRef ClassName = AsmParser->getValueAsString (" AsmParserClassName" );
3236
3233
3237
3234
emitSourceFileHeader (" Assembly Matcher Source Fragment" , OS, Records);
@@ -3536,7 +3533,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
3536
3533
3537
3534
unsigned VariantCount = Target.getAsmParserVariantCount ();
3538
3535
for (unsigned VC = 0 ; VC != VariantCount; ++VC) {
3539
- Record *AsmVariant = Target.getAsmParserVariant (VC);
3536
+ const Record *AsmVariant = Target.getAsmParserVariant (VC);
3540
3537
int AsmVariantNo = AsmVariant->getValueAsInt (" Variant" );
3541
3538
3542
3539
OS << " static const MatchEntry MatchTable" << VC << " [] = {\n " ;
@@ -3637,7 +3634,7 @@ void AsmMatcherEmitter::run(raw_ostream &OS) {
3637
3634
OS << " switch (VariantID) {\n " ;
3638
3635
OS << " default: llvm_unreachable(\" invalid variant!\" );\n " ;
3639
3636
for (unsigned VC = 0 ; VC != VariantCount; ++VC) {
3640
- Record *AsmVariant = Target.getAsmParserVariant (VC);
3637
+ const Record *AsmVariant = Target.getAsmParserVariant (VC);
3641
3638
int AsmVariantNo = AsmVariant->getValueAsInt (" Variant" );
3642
3639
OS << " case " << AsmVariantNo << " : Start = std::begin(MatchTable" << VC
3643
3640
<< " ); End = std::end(MatchTable" << VC << " ); break;\n " ;
0 commit comments