@@ -137,34 +137,19 @@ namespace {
137
137
// / Post-process the DAG to create cluster edges between instrs that may
138
138
// / be fused by the processor into a single operation.
139
139
class MacroFusion : public ScheduleDAGMutation {
140
- std::vector<MacroFusionPredTy> Predicates ;
140
+ ShouldSchedulePredTy shouldScheduleAdjacent ;
141
141
bool FuseBlock;
142
142
bool scheduleAdjacentImpl (ScheduleDAGInstrs &DAG, SUnit &AnchorSU);
143
143
144
144
public:
145
- MacroFusion (ArrayRef<MacroFusionPredTy> Predicates, bool FuseBlock)
146
- : Predicates(Predicates.begin(), Predicates.end()), FuseBlock(FuseBlock) {
147
- }
145
+ MacroFusion (ShouldSchedulePredTy shouldScheduleAdjacent, bool FuseBlock)
146
+ : shouldScheduleAdjacent(shouldScheduleAdjacent), FuseBlock(FuseBlock) {}
148
147
149
148
void apply (ScheduleDAGInstrs *DAGInstrs) override ;
150
-
151
- bool shouldScheduleAdjacent (const TargetInstrInfo &TII,
152
- const TargetSubtargetInfo &STI,
153
- const MachineInstr *FirstMI,
154
- const MachineInstr &SecondMI);
155
149
};
156
150
157
151
} // end anonymous namespace
158
152
159
- bool MacroFusion::shouldScheduleAdjacent (const TargetInstrInfo &TII,
160
- const TargetSubtargetInfo &STI,
161
- const MachineInstr *FirstMI,
162
- const MachineInstr &SecondMI) {
163
- return llvm::any_of (Predicates, [&](MacroFusionPredTy Predicate) {
164
- return Predicate (TII, STI, FirstMI, SecondMI);
165
- });
166
- }
167
-
168
153
void MacroFusion::apply (ScheduleDAGInstrs *DAG) {
169
154
if (FuseBlock)
170
155
// For each of the SUnits in the scheduling block, try to fuse the instr in
@@ -212,15 +197,17 @@ bool MacroFusion::scheduleAdjacentImpl(ScheduleDAGInstrs &DAG, SUnit &AnchorSU)
212
197
}
213
198
214
199
std::unique_ptr<ScheduleDAGMutation>
215
- llvm::createMacroFusionDAGMutation (ArrayRef<MacroFusionPredTy> Predicates) {
216
- if (EnableMacroFusion)
217
- return std::make_unique<MacroFusion>(Predicates, true );
200
+ llvm::createMacroFusionDAGMutation (
201
+ ShouldSchedulePredTy shouldScheduleAdjacent) {
202
+ if (EnableMacroFusion)
203
+ return std::make_unique<MacroFusion>(shouldScheduleAdjacent, true );
218
204
return nullptr ;
219
205
}
220
206
221
- std::unique_ptr<ScheduleDAGMutation> llvm::createBranchMacroFusionDAGMutation (
222
- ArrayRef<MacroFusionPredTy> Predicates) {
223
- if (EnableMacroFusion)
224
- return std::make_unique<MacroFusion>(Predicates, false );
207
+ std::unique_ptr<ScheduleDAGMutation>
208
+ llvm::createBranchMacroFusionDAGMutation (
209
+ ShouldSchedulePredTy shouldScheduleAdjacent) {
210
+ if (EnableMacroFusion)
211
+ return std::make_unique<MacroFusion>(shouldScheduleAdjacent, false );
225
212
return nullptr ;
226
213
}
0 commit comments