blob: 3a140fe63fdee773cf896daa9b7956cfc2ebf097 [file] [log] [blame]
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01001//===- MacroFusion.h - Macro Fusion -----------------------------*- C++ -*-===//
2//
Andrew Walbran16937d02019-10-22 13:54:20 +01003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Andrew Scull5e1ddfa2018-08-14 10:06:54 +01006//
7//===----------------------------------------------------------------------===//
8//
9/// \file This file contains the definition of the DAG scheduling mutation to
10/// pair instructions back to back.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_MACROFUSION_H
15#define LLVM_CODEGEN_MACROFUSION_H
16
17#include <functional>
18#include <memory>
19
20namespace llvm {
21
22class MachineInstr;
23class ScheduleDAGMutation;
24class TargetInstrInfo;
25class TargetSubtargetInfo;
26
Andrew Scullcdfcccc2018-10-05 20:58:37 +010027/// Check if the instr pair, FirstMI and SecondMI, should be fused
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010028/// together. Given SecondMI, when FirstMI is unspecified, then check if
29/// SecondMI may be part of a fused pair at all.
30using ShouldSchedulePredTy = std::function<bool(const TargetInstrInfo &TII,
31 const TargetSubtargetInfo &TSI,
32 const MachineInstr *FirstMI,
33 const MachineInstr &SecondMI)>;
34
Andrew Scullcdfcccc2018-10-05 20:58:37 +010035/// Create a DAG scheduling mutation to pair instructions back to back
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010036/// for instructions that benefit according to the target-specific
37/// shouldScheduleAdjacent predicate function.
38std::unique_ptr<ScheduleDAGMutation>
39createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
40
Andrew Scullcdfcccc2018-10-05 20:58:37 +010041/// Create a DAG scheduling mutation to pair branch instructions with one
Andrew Scull5e1ddfa2018-08-14 10:06:54 +010042/// of their predecessors back to back for instructions that benefit according
43/// to the target-specific shouldScheduleAdjacent predicate function.
44std::unique_ptr<ScheduleDAGMutation>
45createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
46
47} // end namespace llvm
48
49#endif // LLVM_CODEGEN_MACROFUSION_H