MacroFusion.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- MacroFusion.h - Macro Fusion -----------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. /// \file This file contains the definition of the DAG scheduling mutation to
  15. /// pair instructions back to back.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_MACROFUSION_H
  19. #define LLVM_CODEGEN_MACROFUSION_H
  20. #include <functional>
  21. #include <memory>
  22. namespace llvm {
  23. class MachineInstr;
  24. class ScheduleDAGMutation;
  25. class TargetInstrInfo;
  26. class TargetSubtargetInfo;
  27. class ScheduleDAGInstrs;
  28. class SUnit;
  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. /// Checks if the number of cluster edges between SU and its predecessors is
  37. /// less than FuseLimit
  38. bool hasLessThanNumFused(const SUnit &SU, unsigned FuseLimit);
  39. /// Create an artificial edge between FirstSU and SecondSU.
  40. /// Make data dependencies from the FirstSU also dependent on the SecondSU to
  41. /// prevent them from being scheduled between the FirstSU and the SecondSU
  42. /// and vice-versa.
  43. /// Fusing more than 2 instructions is not currently supported.
  44. bool fuseInstructionPair(ScheduleDAGInstrs &DAG, SUnit &FirstSU,
  45. SUnit &SecondSU);
  46. /// Create a DAG scheduling mutation to pair instructions back to back
  47. /// for instructions that benefit according to the target-specific
  48. /// shouldScheduleAdjacent predicate function.
  49. std::unique_ptr<ScheduleDAGMutation>
  50. createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
  51. /// Create a DAG scheduling mutation to pair branch instructions with one
  52. /// of their predecessors back to back for instructions that benefit according
  53. /// to the target-specific shouldScheduleAdjacent predicate function.
  54. std::unique_ptr<ScheduleDAGMutation>
  55. createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
  56. } // end namespace llvm
  57. #endif // LLVM_CODEGEN_MACROFUSION_H
  58. #ifdef __GNUC__
  59. #pragma GCC diagnostic pop
  60. #endif