diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:12:03 +0000 |
| commit | c9157d925c489f07ba9c0b2ce47e5149b75969a5 (patch) | |
| tree | 08bc4a3d9cad3f9ebffa558ddf140b9d9257b219 /contrib/llvm-project/llvm/lib/CodeGen/MacroFusion.cpp | |
| parent | 2a66844f606a35d68ad8a8061f4bea204274b3bc (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/MacroFusion.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/CodeGen/MacroFusion.cpp | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/MacroFusion.cpp b/contrib/llvm-project/llvm/lib/CodeGen/MacroFusion.cpp index fa5df68b8abc..aff4d95781f4 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/MacroFusion.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/MacroFusion.cpp @@ -137,19 +137,34 @@ namespace { /// Post-process the DAG to create cluster edges between instrs that may /// be fused by the processor into a single operation. class MacroFusion : public ScheduleDAGMutation { - ShouldSchedulePredTy shouldScheduleAdjacent; + std::vector<MacroFusionPredTy> Predicates; bool FuseBlock; bool scheduleAdjacentImpl(ScheduleDAGInstrs &DAG, SUnit &AnchorSU); public: - MacroFusion(ShouldSchedulePredTy shouldScheduleAdjacent, bool FuseBlock) - : shouldScheduleAdjacent(shouldScheduleAdjacent), FuseBlock(FuseBlock) {} + MacroFusion(ArrayRef<MacroFusionPredTy> Predicates, bool FuseBlock) + : Predicates(Predicates.begin(), Predicates.end()), FuseBlock(FuseBlock) { + } void apply(ScheduleDAGInstrs *DAGInstrs) override; + + bool shouldScheduleAdjacent(const TargetInstrInfo &TII, + const TargetSubtargetInfo &STI, + const MachineInstr *FirstMI, + const MachineInstr &SecondMI); }; } // end anonymous namespace +bool MacroFusion::shouldScheduleAdjacent(const TargetInstrInfo &TII, + const TargetSubtargetInfo &STI, + const MachineInstr *FirstMI, + const MachineInstr &SecondMI) { + return llvm::any_of(Predicates, [&](MacroFusionPredTy Predicate) { + return Predicate(TII, STI, FirstMI, SecondMI); + }); +} + void MacroFusion::apply(ScheduleDAGInstrs *DAG) { if (FuseBlock) // 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) } std::unique_ptr<ScheduleDAGMutation> -llvm::createMacroFusionDAGMutation( - ShouldSchedulePredTy shouldScheduleAdjacent) { - if(EnableMacroFusion) - return std::make_unique<MacroFusion>(shouldScheduleAdjacent, true); +llvm::createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates) { + if (EnableMacroFusion) + return std::make_unique<MacroFusion>(Predicates, true); return nullptr; } -std::unique_ptr<ScheduleDAGMutation> -llvm::createBranchMacroFusionDAGMutation( - ShouldSchedulePredTy shouldScheduleAdjacent) { - if(EnableMacroFusion) - return std::make_unique<MacroFusion>(shouldScheduleAdjacent, false); +std::unique_ptr<ScheduleDAGMutation> llvm::createBranchMacroFusionDAGMutation( + ArrayRef<MacroFusionPredTy> Predicates) { + if (EnableMacroFusion) + return std::make_unique<MacroFusion>(Predicates, false); return nullptr; } |
