LLVM 24.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;
25class TargetInstrInfo;
28class SUnit;
29class SDep;
30
31/// Check if the instr pair, FirstMI and SecondMI, should be fused
32/// together, based on the dependency between them, Dep. Given SecondMI, when
33/// FirstMI is unspecified, then check if SecondMI may be part of a fused pair
34/// at all.
36 const TargetSubtargetInfo &STI,
37 const MachineInstr *FirstMI,
38 const MachineInstr &SecondMI,
39 const SDep *Dep);
40
41/// Checks if the number of cluster edges between SU and its predecessors is
42/// less than FuseLimit
43LLVM_ABI bool hasLessThanNumFused(const SUnit &SU, unsigned FuseLimit);
44
45/// Returns true if \p Dep is a non-null non-data dependency.
46LLVM_ABI bool isNonDataDep(const SDep *Dep);
47
48/// Create an artificial edge between FirstSU and SecondSU.
49/// Make data dependencies from the FirstSU also dependent on the SecondSU to
50/// prevent them from being scheduled between the FirstSU and the SecondSU
51/// and vice-versa.
52/// Fusing more than 2 instructions is not currently supported.
54 SUnit &SecondSU);
55
56/// Create a DAG scheduling mutation to pair instructions back to back
57/// for instructions that benefit according to the target-specific
58/// predicate functions. shouldScheduleAdjacent will be true if any of the
59/// provided predicates are true.
60/// If BranchOnly is true, only branch instructions with one of their
61/// predecessors will be fused.
62LLVM_ABI std::unique_ptr<ScheduleDAGMutation>
64 bool BranchOnly = false);
65
66} // end namespace llvm
67
68#endif // LLVM_CODEGEN_MACROFUSION_H
#define LLVM_ABI
Definition Compiler.h:215
const HexagonInstrInfo * TII
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Representation of each machine instruction.
Scheduling dependency.
Definition ScheduleDAG.h:52
Scheduling unit. This is a node in the scheduling DAG.
A ScheduleDAG for scheduling lists of MachineInstr.
Mutate the DAG as a postpass after normal DAG building.
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.
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.
LLVM_ABI bool isNonDataDep(const SDep *Dep)
Returns true if Dep is a non-null non-data dependency.
bool(*)(const TargetInstrInfo &TII, const TargetSubtargetInfo &STI, const MachineInstr *FirstMI, const MachineInstr &SecondMI, const SDep *Dep) MacroFusionPredTy
Check if the instr pair, FirstMI and SecondMI, should be fused together, based on the dependency betw...
Definition MacroFusion.h:35
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.