Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:32

0001 //===- MacroFusion.h - Macro Fusion -----------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 /// \file This file contains the definition of the DAG scheduling mutation to
0010 /// pair instructions back to back.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_CODEGEN_MACROFUSION_H
0015 #define LLVM_CODEGEN_MACROFUSION_H
0016 
0017 #include "llvm/ADT/ArrayRef.h"
0018 #include <memory>
0019 
0020 namespace llvm {
0021 
0022 class MachineInstr;
0023 class ScheduleDAGMutation;
0024 class TargetInstrInfo;
0025 class TargetSubtargetInfo;
0026 class ScheduleDAGInstrs;
0027 class SUnit;
0028 
0029 /// Check if the instr pair, FirstMI and SecondMI, should be fused
0030 /// together. Given SecondMI, when FirstMI is unspecified, then check if
0031 /// SecondMI may be part of a fused pair at all.
0032 using MacroFusionPredTy = bool (*)(const TargetInstrInfo &TII,
0033                                    const TargetSubtargetInfo &STI,
0034                                    const MachineInstr *FirstMI,
0035                                    const MachineInstr &SecondMI);
0036 
0037 /// Checks if the number of cluster edges between SU and its predecessors is
0038 /// less than FuseLimit
0039 bool hasLessThanNumFused(const SUnit &SU, unsigned FuseLimit);
0040 
0041 /// Create an artificial edge between FirstSU and SecondSU.
0042 /// Make data dependencies from the FirstSU also dependent on the SecondSU to
0043 /// prevent them from being scheduled between the FirstSU and the SecondSU
0044 /// and vice-versa.
0045 /// Fusing more than 2 instructions is not currently supported.
0046 bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU,
0047                          SUnit &SecondSU);
0048 
0049 /// Create a DAG scheduling mutation to pair instructions back to back
0050 /// for instructions that benefit according to the target-specific
0051 /// predicate functions. shouldScheduleAdjacent will be true if any of the
0052 /// provided predicates are true.
0053 /// If BranchOnly is true, only branch instructions with one of their
0054 /// predecessors will be fused.
0055 std::unique_ptr<ScheduleDAGMutation>
0056 createMacroFusionDAGMutation(ArrayRef<MacroFusionPredTy> Predicates,
0057                              bool BranchOnly = false);
0058 
0059 } // end namespace llvm
0060 
0061 #endif // LLVM_CODEGEN_MACROFUSION_H