blob: dc105fdc68fd8e71463812b57b09a49ff3a601f1 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- 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
21namespace llvm {
22
23class MachineInstr;
24class ScheduleDAGMutation;
25class TargetInstrInfo;
26class TargetSubtargetInfo;
27
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.
31using ShouldSchedulePredTy = std::function<bool(const TargetInstrInfo &TII,
32 const TargetSubtargetInfo &TSI,
33 const MachineInstr *FirstMI,
34 const MachineInstr &SecondMI)>;
35
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.
39std::unique_ptr<ScheduleDAGMutation>
40createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
41
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.
45std::unique_ptr<ScheduleDAGMutation>
46createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
47
48} // end namespace llvm
49
50#endif // LLVM_CODEGEN_MACROFUSION_H