• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===- MacroFusion.h - Macro Fusion -----------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file This file contains the definition of the DAG scheduling mutation to
11 /// pair instructions back to back.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CODEGEN_MACROFUSION_H
16 #define LLVM_CODEGEN_MACROFUSION_H
17 
18 #include <functional>
19 #include <memory>
20 
21 namespace llvm {
22 
23 class MachineInstr;
24 class ScheduleDAGMutation;
25 class TargetInstrInfo;
26 class TargetSubtargetInfo;
27 
28 /// 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)>;
35 
36 /// 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);
41 
42 /// 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);
47 
48 } // end namespace llvm
49 
50 #endif // LLVM_CODEGEN_MACROFUSION_H
51