@@ -461,9 +461,10 @@ std::vector<std::string> CombineRuleOperandTypeChecker::getMCOIOperandTypes(
461461
462462 std::vector<std::string> OpTypes;
463463 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 ;
467468 std::string VarArgsTyName =
468469 VarArgsTy ? (" MCOI::" + VarArgsTy->getValueAsString (" OperandType" )).str ()
469470 : (" unknown_type_" + Twine (UnknownTypeIdx++)).str ();
@@ -636,7 +637,7 @@ class CombineRuleBuilder {
636637
637638 CombineRuleBuilder (const CodeGenTarget &CGT,
638639 SubtargetFeatureInfoMap &SubtargetFeatures,
639- Record &RuleDef, unsigned ID,
640+ const Record &RuleDef, unsigned ID,
640641 std::vector<RuleMatcher> &OutRMs)
641642 : Parser(CGT, RuleDef.getLoc()), CGT(CGT),
642643 SubtargetFeatures (SubtargetFeatures), RuleDef(RuleDef), RuleID(ID),
@@ -765,7 +766,7 @@ class CombineRuleBuilder {
765766 PatternParser Parser;
766767 const CodeGenTarget &CGT;
767768 SubtargetFeatureInfoMap &SubtargetFeatures;
768- Record &RuleDef;
769+ const Record &RuleDef;
769770 const unsigned RuleID;
770771 std::vector<RuleMatcher> &OutRMs;
771772
@@ -1374,12 +1375,12 @@ bool CombineRuleBuilder::addFeaturePredicates(RuleMatcher &M) {
13741375 return true ;
13751376
13761377 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);
13791380 if (!Pred)
13801381 continue ;
13811382
1382- Record *Def = Pred->getDef ();
1383+ const Record *Def = Pred->getDef ();
13831384 if (!Def->isSubClassOf (" Predicate" )) {
13841385 ::PrintError (Def, " Unknown 'Predicate' Type" );
13851386 return false ;
@@ -1525,7 +1526,7 @@ bool CombineRuleBuilder::parseDefs(const DagInit &Def) {
15251526 // Subclasses of GIDefMatchData should declare that this rule needs to pass
15261527 // data from the match stage to the apply stage, and ensure that the
15271528 // generated matcher has a suitable variable for it to do so.
1528- if (Record *MatchDataRec =
1529+ if (const Record *MatchDataRec =
15291530 getDefOfSubClass (*Def.getArg (I), MatchDataClassName)) {
15301531 MatchDatas.emplace_back (Def.getArgNameStr (I),
15311532 MatchDataRec->getValueAsString (" Type" ));
@@ -2360,10 +2361,10 @@ bool CombineRuleBuilder::emitCodeGenInstructionMatchPattern(
23602361// / static storage pools and wires them together to emit the match table &
23612362// / associated function/data structures.
23622363class GICombinerEmitter final : public GlobalISelMatchTableExecutorEmitter {
2363- RecordKeeper &Records;
2364+ const RecordKeeper &Records;
23642365 StringRef Name;
23652366 const CodeGenTarget &Target;
2366- Record *Combiner;
2367+ const Record *Combiner;
23672368 unsigned NextRuleID = 0 ;
23682369
23692370 // List all combine rules (ID, name) imported.
@@ -2403,11 +2404,12 @@ class GICombinerEmitter final : public GlobalISelMatchTableExecutorEmitter {
24032404 }
24042405
24052406 void gatherRules (std::vector<RuleMatcher> &Rules,
2406- const std::vector< Record *> && RulesAndGroups);
2407+ ArrayRef< const Record *> RulesAndGroups);
24072408
24082409public:
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);
24112413 ~GICombinerEmitter () {}
24122414
24132415 void run (raw_ostream &OS);
@@ -2628,9 +2630,9 @@ void GICombinerEmitter::emitRunCustomAction(raw_ostream &OS) {
26282630 << " }\n " ;
26292631}
26302632
2631- GICombinerEmitter::GICombinerEmitter (RecordKeeper &RK,
2633+ GICombinerEmitter::GICombinerEmitter (const RecordKeeper &RK,
26322634 const CodeGenTarget &Target,
2633- StringRef Name, Record *Combiner)
2635+ StringRef Name, const Record *Combiner)
26342636 : Records(RK), Name(Name), Target(Target), Combiner(Combiner) {}
26352637
26362638MatchTable
@@ -2675,12 +2677,11 @@ GICombinerEmitter::buildMatchTable(MutableArrayRef<RuleMatcher> Rules) {
26752677}
26762678
26772679// / 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) {
26822683 if (!Rec->isValueUnset (" Rules" )) {
2683- gatherRules (ActiveRules, Rec->getValueAsListOfDefs (" Rules" ));
2684+ gatherRules (ActiveRules, Rec->getValueAsListOfConstDefs (" Rules" ));
26842685 continue ;
26852686 }
26862687
@@ -2719,7 +2720,7 @@ void GICombinerEmitter::run(raw_ostream &OS) {
27192720
27202721 Records.startTimer (" Gather rules" );
27212722 std::vector<RuleMatcher> Rules;
2722- gatherRules (Rules, Combiner->getValueAsListOfDefs (" Rules" ));
2723+ gatherRules (Rules, Combiner->getValueAsListOfConstDefs (" Rules" ));
27232724 if (ErrorsPrinted)
27242725 PrintFatalError (Combiner->getLoc (), " Failed to parse one or more rules" );
27252726
@@ -2747,11 +2748,6 @@ void GICombinerEmitter::run(raw_ostream &OS) {
27472748
27482749 emitSourceFileHeader (getClassName ().str () + " Combiner Match Table" , OS);
27492750
2750- // Unused
2751- std::vector<StringRef> CustomRendererFns;
2752- // Unused
2753- std::vector<Record *> ComplexPredicates;
2754-
27552751 SmallVector<LLTCodeGen, 16 > TypeObjects;
27562752 append_range (TypeObjects, KnownTypes);
27572753 llvm::sort (TypeObjects);
@@ -2780,8 +2776,8 @@ void GICombinerEmitter::run(raw_ostream &OS) {
27802776 emitTemporariesDecl (OS, " GET_GICOMBINER_CLASS_MEMBERS" );
27812777
27822778 // 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" );
27852781
27862782 // GET_GICOMBINER_CONSTRUCTOR_INITS, which are in the constructor's
27872783 // initializer list.
@@ -2793,14 +2789,14 @@ void GICombinerEmitter::run(raw_ostream &OS) {
27932789
27942790// ===----------------------------------------------------------------------===//
27952791
2796- static void EmitGICombiner (RecordKeeper &RK, raw_ostream &OS) {
2792+ static void EmitGICombiner (const RecordKeeper &RK, raw_ostream &OS) {
27972793 EnablePrettyStackTrace ();
2798- CodeGenTarget Target (RK);
2794+ const CodeGenTarget Target (RK);
27992795
28002796 if (SelectedCombiners.empty ())
28012797 PrintFatalError (" No combiners selected with -combiners" );
28022798 for (const auto &Combiner : SelectedCombiners) {
2803- Record *CombinerDef = RK.getDef (Combiner);
2799+ const Record *CombinerDef = RK.getDef (Combiner);
28042800 if (!CombinerDef)
28052801 PrintFatalError (" Could not find " + Combiner);
28062802 GICombinerEmitter (RK, Target, Combiner, CombinerDef).run (OS);
0 commit comments