LLVM  14.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 
20 namespace llvm {
21 
22 class MachineInstr;
23 class ScheduleDAGMutation;
24 class TargetInstrInfo;
25 class TargetSubtargetInfo;
26 class ScheduleDAGInstrs;
27 class 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.
32 using 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
39 bool 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.
46 bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU,
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.
52 std::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.
58 std::unique_ptr<ScheduleDAGMutation>
60 
61 } // end namespace llvm
62 
63 #endif // LLVM_CODEGEN_MACROFUSION_H
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::createBranchMacroFusionDAGMutation
std::unique_ptr< ScheduleDAGMutation > createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent)
Create a DAG scheduling mutation to pair branch instructions with one of their predecessors back to b...
Definition: MacroFusion.cpp:209
TII
const HexagonInstrInfo * TII
Definition: HexagonCopyToCombine.cpp:129
llvm::fuseInstructionPair
bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU, SUnit &SecondSU)
Create an artificial edge between FirstSU and SecondSU.
Definition: MacroFusion.cpp:54
llvm::createMacroFusionDAGMutation
std::unique_ptr< ScheduleDAGMutation > createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent)
Create a DAG scheduling mutation to pair instructions back to back for instructions that benefit acco...
Definition: MacroFusion.cpp:201
llvm::shouldScheduleAdjacent
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.
Definition: ARMMacroFusion.cpp:51
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
function
print Print MemDeps of function
Definition: MemDepPrinter.cpp:83
llvm::hasLessThanNumFused
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:47
llvm::SUnit
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:242
llvm::ScheduleDAGInstrs
A ScheduleDAG for scheduling lists of MachineInstr.
Definition: ScheduleDAGInstrs.h:119
llvm::ShouldSchedulePredTy
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