@@ -461,9 +461,10 @@ std::vector<std::string> CombineRuleOperandTypeChecker::getMCOIOperandTypes(
461
461
462
462
std::vector<std::string> OpTypes;
463
463
auto &CGI = CGP.getInst ();
464
- Record *VarArgsTy = CGI.TheDef ->isSubClassOf (" GenericInstruction" )
465
- ? CGI.TheDef ->getValueAsOptionalDef (" variadicOpsType" )
466
- : nullptr ;
464
+ const Record *VarArgsTy =
465
+ CGI.TheDef ->isSubClassOf (" GenericInstruction" )
466
+ ? CGI.TheDef ->getValueAsOptionalDef (" variadicOpsType" )
467
+ : nullptr ;
467
468
std::string VarArgsTyName =
468
469
VarArgsTy ? (" MCOI::" + VarArgsTy->getValueAsString (" OperandType" )).str ()
469
470
: (" unknown_type_" + Twine (UnknownTypeIdx++)).str ();
@@ -636,7 +637,7 @@ class CombineRuleBuilder {
636
637
637
638
CombineRuleBuilder (const CodeGenTarget &CGT,
638
639
SubtargetFeatureInfoMap &SubtargetFeatures,
639
- Record &RuleDef, unsigned ID,
640
+ const Record &RuleDef, unsigned ID,
640
641
std::vector<RuleMatcher> &OutRMs)
641
642
: Parser(CGT, RuleDef.getLoc()), CGT(CGT),
642
643
SubtargetFeatures (SubtargetFeatures), RuleDef(RuleDef), RuleID(ID),
@@ -765,7 +766,7 @@ class CombineRuleBuilder {
765
766
PatternParser Parser;
766
767
const CodeGenTarget &CGT;
767
768
SubtargetFeatureInfoMap &SubtargetFeatures;
768
- Record &RuleDef;
769
+ const Record &RuleDef;
769
770
const unsigned RuleID;
770
771
std::vector<RuleMatcher> &OutRMs;
771
772
@@ -1374,12 +1375,12 @@ bool CombineRuleBuilder::addFeaturePredicates(RuleMatcher &M) {
1374
1375
return true ;
1375
1376
1376
1377
ListInit *Preds = RuleDef.getValueAsListInit (" Predicates" );
1377
- for (Init *PI : Preds->getValues ()) {
1378
- DefInit *Pred = dyn_cast<DefInit>(PI);
1378
+ for (const Init *PI : Preds->getValues ()) {
1379
+ const DefInit *Pred = dyn_cast<DefInit>(PI);
1379
1380
if (!Pred)
1380
1381
continue ;
1381
1382
1382
- Record *Def = Pred->getDef ();
1383
+ const Record *Def = Pred->getDef ();
1383
1384
if (!Def->isSubClassOf (" Predicate" )) {
1384
1385
::PrintError (Def, " Unknown 'Predicate' Type" );
1385
1386
return false ;
@@ -1525,7 +1526,7 @@ bool CombineRuleBuilder::parseDefs(const DagInit &Def) {
1525
1526
// Subclasses of GIDefMatchData should declare that this rule needs to pass
1526
1527
// data from the match stage to the apply stage, and ensure that the
1527
1528
// generated matcher has a suitable variable for it to do so.
1528
- if (Record *MatchDataRec =
1529
+ if (const Record *MatchDataRec =
1529
1530
getDefOfSubClass (*Def.getArg (I), MatchDataClassName)) {
1530
1531
MatchDatas.emplace_back (Def.getArgNameStr (I),
1531
1532
MatchDataRec->getValueAsString (" Type" ));
@@ -2360,10 +2361,10 @@ bool CombineRuleBuilder::emitCodeGenInstructionMatchPattern(
2360
2361
// / static storage pools and wires them together to emit the match table &
2361
2362
// / associated function/data structures.
2362
2363
class GICombinerEmitter final : public GlobalISelMatchTableExecutorEmitter {
2363
- RecordKeeper &Records;
2364
+ const RecordKeeper &Records;
2364
2365
StringRef Name;
2365
2366
const CodeGenTarget &Target;
2366
- Record *Combiner;
2367
+ const Record *Combiner;
2367
2368
unsigned NextRuleID = 0 ;
2368
2369
2369
2370
// List all combine rules (ID, name) imported.
@@ -2403,11 +2404,12 @@ class GICombinerEmitter final : public GlobalISelMatchTableExecutorEmitter {
2403
2404
}
2404
2405
2405
2406
void gatherRules (std::vector<RuleMatcher> &Rules,
2406
- const std::vector< Record *> && RulesAndGroups);
2407
+ ArrayRef< const Record *> RulesAndGroups);
2407
2408
2408
2409
public:
2409
- explicit GICombinerEmitter (RecordKeeper &RK, const CodeGenTarget &Target,
2410
- StringRef Name, Record *Combiner);
2410
+ explicit GICombinerEmitter (const RecordKeeper &RK,
2411
+ const CodeGenTarget &Target, StringRef Name,
2412
+ const Record *Combiner);
2411
2413
~GICombinerEmitter () {}
2412
2414
2413
2415
void run (raw_ostream &OS);
@@ -2628,9 +2630,9 @@ void GICombinerEmitter::emitRunCustomAction(raw_ostream &OS) {
2628
2630
<< " }\n " ;
2629
2631
}
2630
2632
2631
- GICombinerEmitter::GICombinerEmitter (RecordKeeper &RK,
2633
+ GICombinerEmitter::GICombinerEmitter (const RecordKeeper &RK,
2632
2634
const CodeGenTarget &Target,
2633
- StringRef Name, Record *Combiner)
2635
+ StringRef Name, const Record *Combiner)
2634
2636
: Records(RK), Name(Name), Target(Target), Combiner(Combiner) {}
2635
2637
2636
2638
MatchTable
@@ -2675,12 +2677,11 @@ GICombinerEmitter::buildMatchTable(MutableArrayRef<RuleMatcher> Rules) {
2675
2677
}
2676
2678
2677
2679
// / Recurse into GICombineGroup's and flatten the ruleset into a simple list.
2678
- void GICombinerEmitter::gatherRules (
2679
- std::vector<RuleMatcher> &ActiveRules,
2680
- const std::vector<Record *> &&RulesAndGroups) {
2681
- for (Record *Rec : RulesAndGroups) {
2680
+ void GICombinerEmitter::gatherRules (std::vector<RuleMatcher> &ActiveRules,
2681
+ ArrayRef<const Record *> RulesAndGroups) {
2682
+ for (const Record *Rec : RulesAndGroups) {
2682
2683
if (!Rec->isValueUnset (" Rules" )) {
2683
- gatherRules (ActiveRules, Rec->getValueAsListOfDefs (" Rules" ));
2684
+ gatherRules (ActiveRules, Rec->getValueAsListOfConstDefs (" Rules" ));
2684
2685
continue ;
2685
2686
}
2686
2687
@@ -2719,7 +2720,7 @@ void GICombinerEmitter::run(raw_ostream &OS) {
2719
2720
2720
2721
Records.startTimer (" Gather rules" );
2721
2722
std::vector<RuleMatcher> Rules;
2722
- gatherRules (Rules, Combiner->getValueAsListOfDefs (" Rules" ));
2723
+ gatherRules (Rules, Combiner->getValueAsListOfConstDefs (" Rules" ));
2723
2724
if (ErrorsPrinted)
2724
2725
PrintFatalError (Combiner->getLoc (), " Failed to parse one or more rules" );
2725
2726
@@ -2747,11 +2748,6 @@ void GICombinerEmitter::run(raw_ostream &OS) {
2747
2748
2748
2749
emitSourceFileHeader (getClassName ().str () + " Combiner Match Table" , OS);
2749
2750
2750
- // Unused
2751
- std::vector<StringRef> CustomRendererFns;
2752
- // Unused
2753
- std::vector<Record *> ComplexPredicates;
2754
-
2755
2751
SmallVector<LLTCodeGen, 16 > TypeObjects;
2756
2752
append_range (TypeObjects, KnownTypes);
2757
2753
llvm::sort (TypeObjects);
@@ -2780,8 +2776,8 @@ void GICombinerEmitter::run(raw_ostream &OS) {
2780
2776
emitTemporariesDecl (OS, " GET_GICOMBINER_CLASS_MEMBERS" );
2781
2777
2782
2778
// GET_GICOMBINER_IMPL, which needs to be included outside the class.
2783
- emitExecutorImpl (OS, Table, TypeObjects, Rules, ComplexPredicates ,
2784
- CustomRendererFns, " GET_GICOMBINER_IMPL" );
2779
+ emitExecutorImpl (OS, Table, TypeObjects, Rules, {}, {} ,
2780
+ " GET_GICOMBINER_IMPL" );
2785
2781
2786
2782
// GET_GICOMBINER_CONSTRUCTOR_INITS, which are in the constructor's
2787
2783
// initializer list.
@@ -2793,14 +2789,14 @@ void GICombinerEmitter::run(raw_ostream &OS) {
2793
2789
2794
2790
// ===----------------------------------------------------------------------===//
2795
2791
2796
- static void EmitGICombiner (RecordKeeper &RK, raw_ostream &OS) {
2792
+ static void EmitGICombiner (const RecordKeeper &RK, raw_ostream &OS) {
2797
2793
EnablePrettyStackTrace ();
2798
- CodeGenTarget Target (RK);
2794
+ const CodeGenTarget Target (RK);
2799
2795
2800
2796
if (SelectedCombiners.empty ())
2801
2797
PrintFatalError (" No combiners selected with -combiners" );
2802
2798
for (const auto &Combiner : SelectedCombiners) {
2803
- Record *CombinerDef = RK.getDef (Combiner);
2799
+ const Record *CombinerDef = RK.getDef (Combiner);
2804
2800
if (!CombinerDef)
2805
2801
PrintFatalError (" Could not find " + Combiner);
2806
2802
GICombinerEmitter (RK, Target, Combiner, CombinerDef).run (OS);
0 commit comments