LLVM 20.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"
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.
33 const TargetSubtargetInfo &STI,
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/// predicate functions. shouldScheduleAdjacent will be true if any of the
52/// provided predicates are true.
53/// If BranchOnly is true, only branch instructions with one of their
54/// predecessors will be fused.
55std::unique_ptr<ScheduleDAGMutation>
57 bool BranchOnly = false);
58
59} // end namespace llvm
60
61#endif // LLVM_CODEGEN_MACROFUSION_H
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:69
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::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...
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:35
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