@@ -52,36 +52,37 @@ using namespace llvm;
5252
5353namespace {
5454class MacroFusionPredicatorEmitter {
55- RecordKeeper &Records;
56- CodeGenTarget Target;
55+ const RecordKeeper &Records;
56+ const CodeGenTarget Target;
5757
58- void emitMacroFusionDecl (ArrayRef<Record *> Fusions, PredicateExpander &PE,
59- raw_ostream &OS);
60- void emitMacroFusionImpl (ArrayRef<Record *> Fusions, PredicateExpander &PE,
61- raw_ostream &OS);
62- void emitPredicates (ArrayRef<Record *> FirstPredicate, bool IsCommutable,
63- PredicateExpander &PE, raw_ostream &OS);
64- void emitFirstPredicate (Record *SecondPredicate, bool IsCommutable,
58+ void emitMacroFusionDecl (ArrayRef<const Record *> Fusions,
59+ PredicateExpander &PE, raw_ostream &OS);
60+ void emitMacroFusionImpl (ArrayRef<const Record *> Fusions,
61+ PredicateExpander &PE, raw_ostream &OS);
62+ void emitPredicates (ArrayRef<const Record *> FirstPredicate,
63+ bool IsCommutable, PredicateExpander &PE,
64+ raw_ostream &OS);
65+ void emitFirstPredicate (const Record *SecondPredicate, bool IsCommutable,
6566 PredicateExpander &PE, raw_ostream &OS);
66- void emitSecondPredicate (Record *SecondPredicate, bool IsCommutable,
67+ void emitSecondPredicate (const Record *SecondPredicate, bool IsCommutable,
6768 PredicateExpander &PE, raw_ostream &OS);
68- void emitBothPredicate (Record *Predicates, bool IsCommutable,
69+ void emitBothPredicate (const Record *Predicates, bool IsCommutable,
6970 PredicateExpander &PE, raw_ostream &OS);
7071
7172public:
72- MacroFusionPredicatorEmitter (RecordKeeper &R) : Records(R), Target(R) {}
73+ MacroFusionPredicatorEmitter (const RecordKeeper &R) : Records(R), Target(R) {}
7374
7475 void run (raw_ostream &OS);
7576};
7677} // End anonymous namespace.
7778
7879void MacroFusionPredicatorEmitter::emitMacroFusionDecl (
79- ArrayRef<Record *> Fusions, PredicateExpander &PE, raw_ostream &OS) {
80+ ArrayRef<const Record *> Fusions, PredicateExpander &PE, raw_ostream &OS) {
8081 OS << " #ifdef GET_" << Target.getName () << " _MACRO_FUSION_PRED_DECL\n " ;
8182 OS << " #undef GET_" << Target.getName () << " _MACRO_FUSION_PRED_DECL\n\n " ;
8283 OS << " namespace llvm {\n " ;
8384
84- for (Record *Fusion : Fusions) {
85+ for (const Record *Fusion : Fusions) {
8586 OS << " bool is" << Fusion->getName () << " (const TargetInstrInfo &, "
8687 << " const TargetSubtargetInfo &, "
8788 << " const MachineInstr *, "
@@ -93,14 +94,14 @@ void MacroFusionPredicatorEmitter::emitMacroFusionDecl(
9394}
9495
9596void MacroFusionPredicatorEmitter::emitMacroFusionImpl (
96- ArrayRef<Record *> Fusions, PredicateExpander &PE, raw_ostream &OS) {
97+ ArrayRef<const Record *> Fusions, PredicateExpander &PE, raw_ostream &OS) {
9798 OS << " #ifdef GET_" << Target.getName () << " _MACRO_FUSION_PRED_IMPL\n " ;
9899 OS << " #undef GET_" << Target.getName () << " _MACRO_FUSION_PRED_IMPL\n\n " ;
99100 OS << " namespace llvm {\n " ;
100101
101- for (Record *Fusion : Fusions) {
102- std::vector<Record *> Predicates =
103- Fusion->getValueAsListOfDefs (" Predicates" );
102+ for (const Record *Fusion : Fusions) {
103+ std::vector<const Record *> Predicates =
104+ Fusion->getValueAsListOfConstDefs (" Predicates" );
104105 bool IsCommutable = Fusion->getValueAsBit (" IsCommutable" );
105106
106107 OS << " bool is" << Fusion->getName () << " (\n " ;
@@ -121,12 +122,11 @@ void MacroFusionPredicatorEmitter::emitMacroFusionImpl(
121122 OS << " \n #endif\n " ;
122123}
123124
124- void MacroFusionPredicatorEmitter::emitPredicates (ArrayRef<Record *> Predicates,
125- bool IsCommutable,
126- PredicateExpander &PE,
127- raw_ostream &OS) {
128- for (Record *Predicate : Predicates) {
129- Record *Target = Predicate->getValueAsDef (" Target" );
125+ void MacroFusionPredicatorEmitter::emitPredicates (
126+ ArrayRef<const Record *> Predicates, bool IsCommutable,
127+ PredicateExpander &PE, raw_ostream &OS) {
128+ for (const Record *Predicate : Predicates) {
129+ const Record *Target = Predicate->getValueAsDef (" Target" );
130130 if (Target->getName () == " first_fusion_target" )
131131 emitFirstPredicate (Predicate, IsCommutable, PE, OS);
132132 else if (Target->getName () == " second_fusion_target" )
@@ -139,7 +139,7 @@ void MacroFusionPredicatorEmitter::emitPredicates(ArrayRef<Record *> Predicates,
139139 }
140140}
141141
142- void MacroFusionPredicatorEmitter::emitFirstPredicate (Record *Predicate,
142+ void MacroFusionPredicatorEmitter::emitFirstPredicate (const Record *Predicate,
143143 bool IsCommutable,
144144 PredicateExpander &PE,
145145 raw_ostream &OS) {
@@ -172,7 +172,7 @@ void MacroFusionPredicatorEmitter::emitFirstPredicate(Record *Predicate,
172172 }
173173}
174174
175- void MacroFusionPredicatorEmitter::emitSecondPredicate (Record *Predicate,
175+ void MacroFusionPredicatorEmitter::emitSecondPredicate (const Record *Predicate,
176176 bool IsCommutable,
177177 PredicateExpander &PE,
178178 raw_ostream &OS) {
@@ -223,7 +223,7 @@ void MacroFusionPredicatorEmitter::emitSecondPredicate(Record *Predicate,
223223 }
224224}
225225
226- void MacroFusionPredicatorEmitter::emitBothPredicate (Record *Predicate,
226+ void MacroFusionPredicatorEmitter::emitBothPredicate (const Record *Predicate,
227227 bool IsCommutable,
228228 PredicateExpander &PE,
229229 raw_ostream &OS) {
@@ -277,9 +277,7 @@ void MacroFusionPredicatorEmitter::run(raw_ostream &OS) {
277277 PE.setByRef (false );
278278 PE.setExpandForMC (false );
279279
280- std::vector<Record *> Fusions = Records.getAllDerivedDefinitions (" Fusion" );
281- // Sort macro fusions by name.
282- sort (Fusions, LessRecord ());
280+ ArrayRef<const Record *> Fusions = Records.getAllDerivedDefinitions (" Fusion" );
283281 emitMacroFusionDecl (Fusions, PE, OS);
284282 OS << " \n " ;
285283 emitMacroFusionImpl (Fusions, PE, OS);
0 commit comments