LLVM 22.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 "llvm/ADT/ArrayRef.h"
19#include <memory>
20
21namespace llvm {
22
23class MachineInstr;
24class ScheduleDAGMutation;
25class TargetInstrInfo;
26class TargetSubtargetInfo;
27class ScheduleDAGInstrs;
28class SUnit;
29
30/// Check if the instr pair, FirstMI and SecondMI, should be fused
31/// together. Given SecondMI, when FirstMI is unspecified, then check if
32/// SecondMI may be part of a fused pair at all.
34 const TargetSubtargetInfo &STI,
35 const MachineInstr *FirstMI,
36 const MachineInstr &SecondMI);
37
38/// Checks if the number of cluster edges between SU and its predecessors is
39/// less than FuseLimit
40LLVM_ABI bool hasLessThanNumFused(const SUnit &SU, unsigned FuseLimit);
41
42/// Create an artificial edge between FirstSU and SecondSU.
43/// Make data dependencies from the FirstSU also dependent on the SecondSU to
44/// prevent them from being scheduled between the FirstSU and the SecondSU
45/// and vice-versa.
46/// Fusing more than 2 instructions is not currently supported.
48 SUnit &SecondSU);
49
50/// Create a DAG scheduling mutation to pair instructions back to back
51/// for instructions that benefit according to the target-specific
52/// predicate functions. shouldScheduleAdjacent will be true if any of the
53/// provided predicates are true.
54/// If BranchOnly is true, only branch instructions with one of their
55/// predecessors will be fused.
56LLVM_ABI std::unique_ptr<ScheduleDAGMutation>
58 bool BranchOnly = false);
59
60} // end namespace llvm
61
62#endif // LLVM_CODEGEN_MACROFUSION_H
#define LLVM_ABI
Definition: Compiler.h:213
const HexagonInstrInfo * TII
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Representation of each machine instruction.
Definition: MachineInstr.h:72
Scheduling unit. This is a node in the scheduling DAG.
Definition: ScheduleDAG.h:249
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
LLVM_ABI std::unique_ptr< ScheduleDAGMutation > createMacroFusionDAGMutation(ArrayRef< MacroFusionPredTy > Predicates, bool BranchOnly=false)
Create a DAG scheduling mutation to pair instructions back to back for instructions that benefit acco...
LLVM_ABI bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU, SUnit &SecondSU)
Create an artificial edge between FirstSU and SecondSU.
Definition: MacroFusion.cpp:53
bool(*)(const TargetInstrInfo &TII, const TargetSubtargetInfo &STI, const MachineInstr *FirstMI, const MachineInstr &SecondMI) MacroFusionPredTy
Check if the instr pair, FirstMI and SecondMI, should be fused together.
Definition: MacroFusion.h:36
LLVM_ABI 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