1 //===- MacroFusion.h - Macro Fusion -----------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 /// \file This file contains the definition of the DAG scheduling mutation to
11 /// pair instructions back to back.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_MACROFUSION_H
16 #define LLVM_CODEGEN_MACROFUSION_H
24 class ScheduleDAGMutation;
25 class TargetInstrInfo;
26 class TargetSubtargetInfo;
28 /// \brief Check if the instr pair, FirstMI and SecondMI, should be fused
29 /// together. Given SecondMI, when FirstMI is unspecified, then check if
30 /// SecondMI may be part of a fused pair at all.
31 using ShouldSchedulePredTy = std::function<bool(const TargetInstrInfo &TII,
32 const TargetSubtargetInfo &TSI,
33 const MachineInstr *FirstMI,
34 const MachineInstr &SecondMI)>;
36 /// \brief Create a DAG scheduling mutation to pair instructions back to back
37 /// for instructions that benefit according to the target-specific
38 /// shouldScheduleAdjacent predicate function.
39 std::unique_ptr<ScheduleDAGMutation>
40 createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
42 /// \brief Create a DAG scheduling mutation to pair branch instructions with one
43 /// of their predecessors back to back for instructions that benefit according
44 /// to the target-specific shouldScheduleAdjacent predicate function.
45 std::unique_ptr<ScheduleDAGMutation>
46 createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
48 } // end namespace llvm
50 #endif // LLVM_CODEGEN_MACROFUSION_H