@@ -52,36 +52,37 @@ using namespace llvm;
52
52
53
53
namespace {
54
54
class MacroFusionPredicatorEmitter {
55
- RecordKeeper &Records;
56
- CodeGenTarget Target;
55
+ const RecordKeeper &Records;
56
+ const CodeGenTarget Target;
57
57
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,
65
66
PredicateExpander &PE, raw_ostream &OS);
66
- void emitSecondPredicate (Record *SecondPredicate, bool IsCommutable,
67
+ void emitSecondPredicate (const Record *SecondPredicate, bool IsCommutable,
67
68
PredicateExpander &PE, raw_ostream &OS);
68
- void emitBothPredicate (Record *Predicates, bool IsCommutable,
69
+ void emitBothPredicate (const Record *Predicates, bool IsCommutable,
69
70
PredicateExpander &PE, raw_ostream &OS);
70
71
71
72
public:
72
- MacroFusionPredicatorEmitter (RecordKeeper &R) : Records(R), Target(R) {}
73
+ MacroFusionPredicatorEmitter (const RecordKeeper &R) : Records(R), Target(R) {}
73
74
74
75
void run (raw_ostream &OS);
75
76
};
76
77
} // End anonymous namespace.
77
78
78
79
void MacroFusionPredicatorEmitter::emitMacroFusionDecl (
79
- ArrayRef<Record *> Fusions, PredicateExpander &PE, raw_ostream &OS) {
80
+ ArrayRef<const Record *> Fusions, PredicateExpander &PE, raw_ostream &OS) {
80
81
OS << " #ifdef GET_" << Target.getName () << " _MACRO_FUSION_PRED_DECL\n " ;
81
82
OS << " #undef GET_" << Target.getName () << " _MACRO_FUSION_PRED_DECL\n\n " ;
82
83
OS << " namespace llvm {\n " ;
83
84
84
- for (Record *Fusion : Fusions) {
85
+ for (const Record *Fusion : Fusions) {
85
86
OS << " bool is" << Fusion->getName () << " (const TargetInstrInfo &, "
86
87
<< " const TargetSubtargetInfo &, "
87
88
<< " const MachineInstr *, "
@@ -93,14 +94,14 @@ void MacroFusionPredicatorEmitter::emitMacroFusionDecl(
93
94
}
94
95
95
96
void MacroFusionPredicatorEmitter::emitMacroFusionImpl (
96
- ArrayRef<Record *> Fusions, PredicateExpander &PE, raw_ostream &OS) {
97
+ ArrayRef<const Record *> Fusions, PredicateExpander &PE, raw_ostream &OS) {
97
98
OS << " #ifdef GET_" << Target.getName () << " _MACRO_FUSION_PRED_IMPL\n " ;
98
99
OS << " #undef GET_" << Target.getName () << " _MACRO_FUSION_PRED_IMPL\n\n " ;
99
100
OS << " namespace llvm {\n " ;
100
101
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" );
104
105
bool IsCommutable = Fusion->getValueAsBit (" IsCommutable" );
105
106
106
107
OS << " bool is" << Fusion->getName () << " (\n " ;
@@ -121,12 +122,11 @@ void MacroFusionPredicatorEmitter::emitMacroFusionImpl(
121
122
OS << " \n #endif\n " ;
122
123
}
123
124
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" );
130
130
if (Target->getName () == " first_fusion_target" )
131
131
emitFirstPredicate (Predicate, IsCommutable, PE, OS);
132
132
else if (Target->getName () == " second_fusion_target" )
@@ -139,7 +139,7 @@ void MacroFusionPredicatorEmitter::emitPredicates(ArrayRef<Record *> Predicates,
139
139
}
140
140
}
141
141
142
- void MacroFusionPredicatorEmitter::emitFirstPredicate (Record *Predicate,
142
+ void MacroFusionPredicatorEmitter::emitFirstPredicate (const Record *Predicate,
143
143
bool IsCommutable,
144
144
PredicateExpander &PE,
145
145
raw_ostream &OS) {
@@ -172,7 +172,7 @@ void MacroFusionPredicatorEmitter::emitFirstPredicate(Record *Predicate,
172
172
}
173
173
}
174
174
175
- void MacroFusionPredicatorEmitter::emitSecondPredicate (Record *Predicate,
175
+ void MacroFusionPredicatorEmitter::emitSecondPredicate (const Record *Predicate,
176
176
bool IsCommutable,
177
177
PredicateExpander &PE,
178
178
raw_ostream &OS) {
@@ -223,7 +223,7 @@ void MacroFusionPredicatorEmitter::emitSecondPredicate(Record *Predicate,
223
223
}
224
224
}
225
225
226
- void MacroFusionPredicatorEmitter::emitBothPredicate (Record *Predicate,
226
+ void MacroFusionPredicatorEmitter::emitBothPredicate (const Record *Predicate,
227
227
bool IsCommutable,
228
228
PredicateExpander &PE,
229
229
raw_ostream &OS) {
@@ -277,9 +277,7 @@ void MacroFusionPredicatorEmitter::run(raw_ostream &OS) {
277
277
PE.setByRef (false );
278
278
PE.setExpandForMC (false );
279
279
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" );
283
281
emitMacroFusionDecl (Fusions, PE, OS);
284
282
OS << " \n " ;
285
283
emitMacroFusionImpl (Fusions, PE, OS);
0 commit comments