Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 14 | pmbaty | 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> |
||
| 53 | createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent); |
||
| 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> |
||
| 59 | createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent); |
||
| 60 | |||
| 61 | } // end namespace llvm |
||
| 62 | |||
| 63 | #endif // LLVM_CODEGEN_MACROFUSION_H |