@@ -137,19 +137,34 @@ 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
- ShouldSchedulePredTy shouldScheduleAdjacent ;
140
+ std::vector<MacroFusionPredTy> Predicates ;
141
141
bool FuseBlock;
142
142
bool scheduleAdjacentImpl (ScheduleDAGInstrs &DAG, SUnit &AnchorSU);
143
143
144
144
public:
145
- MacroFusion (ShouldSchedulePredTy shouldScheduleAdjacent, bool FuseBlock)
146
- : shouldScheduleAdjacent(shouldScheduleAdjacent), FuseBlock(FuseBlock) {}
145
+ MacroFusion (ArrayRef<MacroFusionPredTy> Predicates, bool FuseBlock)
146
+ : Predicates(Predicates.begin(), Predicates.end()), FuseBlock(FuseBlock) {
147
+ }
147
148
148
149
void apply (ScheduleDAGInstrs *DAGInstrs) override ;
150
+
151
+ bool shouldScheduleAdjacent (const TargetInstrInfo &TII,
152
+ const TargetSubtargetInfo &STI,
153
+ const MachineInstr *FirstMI,
154
+ const MachineInstr &SecondMI);
149
155
};
150
156
151
157
} // end anonymous namespace
152
158
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
+
153
168
void MacroFusion::apply (ScheduleDAGInstrs *DAG) {
154
169
if (FuseBlock)
155
170
// For each of the SUnits in the scheduling block, try to fuse the instr in
@@ -197,17 +212,15 @@ bool MacroFusion::scheduleAdjacentImpl(ScheduleDAGInstrs &DAG, SUnit &AnchorSU)
197
212
}
198
213
199
214
std::unique_ptr<ScheduleDAGMutation>
200
- llvm::createMacroFusionDAGMutation (
201
- ShouldSchedulePredTy shouldScheduleAdjacent) {
202
- if (EnableMacroFusion)
203
- return std::make_unique<MacroFusion>(shouldScheduleAdjacent, true );
215
+ llvm::createMacroFusionDAGMutation (ArrayRef<MacroFusionPredTy> Predicates) {
216
+ if (EnableMacroFusion)
217
+ return std::make_unique<MacroFusion>(Predicates, true );
204
218
return nullptr ;
205
219
}
206
220
207
- std::unique_ptr<ScheduleDAGMutation>
208
- llvm::createBranchMacroFusionDAGMutation (
209
- ShouldSchedulePredTy shouldScheduleAdjacent) {
210
- if (EnableMacroFusion)
211
- return std::make_unique<MacroFusion>(shouldScheduleAdjacent, false );
221
+ std::unique_ptr<ScheduleDAGMutation> llvm::createBranchMacroFusionDAGMutation (
222
+ ArrayRef<MacroFusionPredTy> Predicates) {
223
+ if (EnableMacroFusion)
224
+ return std::make_unique<MacroFusion>(Predicates, false );
212
225
return nullptr ;
213
226
}
0 commit comments