LLVM 17.0.0git
MacroFusion.h
Go to the documentation of this file.
1//===- MacroFusion.h - Macro Fusion -----------------------------*- C++ -*-===//
2//
3// 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
6//
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;
26class ScheduleDAGInstrs;
27class SUnit;
28
29/// Check if the instr pair, FirstMI and SecondMI, should be fused
30/// together. Given SecondMI, when FirstMI is unspecified, then check if
31/// SecondMI may be part of a fused pair at all.
32using ShouldSchedulePredTy = std::function<bool(const TargetInstrInfo &TII,
33 const TargetSubtargetInfo &TSI,
34 const MachineInstr *FirstMI,
35 const MachineInstr &SecondMI)>;
36
37/// Checks if the number of cluster edges between SU and its predecessors is
38/// less than FuseLimit
39bool hasLessThanNumFused(const SUnit &SU, unsigned FuseLimit);
40
41/// Create an artificial edge between FirstSU and SecondSU.
42/// Make data dependencies from the FirstSU also dependent on the SecondSU to
43/// prevent them from being scheduled between the FirstSU and the SecondSU
44/// and vice-versa.
45/// Fusing more than 2 instructions is not currently supported.
47 SUnit &SecondSU);
48
49/// Create a DAG scheduling mutation to pair instructions back to back
50/// for instructions that benefit according to the target-specific
51/// shouldScheduleAdjacent predicate function.
52std::unique_ptr<ScheduleDAGMutation>
54
55/// Create a DAG scheduling mutation to pair branch instructions with one
56/// of their predecessors back to back for instructions that benefit according
57/// to the target-specific shouldScheduleAdjacent predicate function.
58std::unique_ptr<ScheduleDAGMutation>
60
61} // end namespace llvm
62
63#endif // LLVM_CODEGEN_MACROFUSION_H
const HexagonInstrInfo * TII
Representation of each machine instruction.
Definition: MachineInstr.h:68
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:242
A ScheduleDAG for scheduling lists of MachineInstr.
TargetInstrInfo - Interface to description of machine instruction set.
TargetSubtargetInfo - Generic base class for all target subtargets.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
std::function< bool(const TargetInstrInfo &TII, const TargetSubtargetInfo &TSI, const MachineInstr *FirstMI, const MachineInstr &SecondMI)> ShouldSchedulePredTy
Check if the instr pair, FirstMI and SecondMI, should be fused together.
Definition: MacroFusion.h:35
bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU, SUnit &SecondSU)
Create an artificial edge between FirstSU and SecondSU.
Definition: MacroFusion.cpp:53
std::unique_ptr< ScheduleDAGMutation > createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent)
Create a DAG scheduling mutation to pair branch instructions with one of their predecessors back to b...
std::unique_ptr< ScheduleDAGMutation > createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent)
Create a DAG scheduling mutation to pair instructions back to back for instructions that benefit acco...
static bool shouldScheduleAdjacent(const TargetInstrInfo &TII, const TargetSubtargetInfo &TSI, const MachineInstr *FirstMI, const MachineInstr &SecondMI)
Check if the instr pair, FirstMI and SecondMI, should be fused together.
bool hasLessThanNumFused(const SUnit &SU, unsigned FuseLimit)
Checks if the number of cluster edges between SU and its predecessors is less than FuseLimit.
Definition: MacroFusion.cpp:46