MacroFusion.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #ifndef LLVM_CODEGEN_MACROFUSION_H
  14. #define LLVM_CODEGEN_MACROFUSION_H
  15. #include <functional>
  16. #include <memory>
  17. namespace llvm {
  18. class MachineInstr;
  19. class ScheduleDAGMutation;
  20. class TargetInstrInfo;
  21. class TargetSubtargetInfo;
  22. /// Check if the instr pair, FirstMI and SecondMI, should be fused
  23. /// together. Given SecondMI, when FirstMI is unspecified, then check if
  24. /// SecondMI may be part of a fused pair at all.
  25. using ShouldSchedulePredTy = std::function<bool(const TargetInstrInfo &TII,
  26. const TargetSubtargetInfo &TSI,
  27. const MachineInstr *FirstMI,
  28. const MachineInstr &SecondMI)>;
  29. /// Create a DAG scheduling mutation to pair instructions back to back
  30. /// for instructions that benefit according to the target-specific
  31. /// shouldScheduleAdjacent predicate function.
  32. std::unique_ptr<ScheduleDAGMutation>
  33. createMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
  34. /// Create a DAG scheduling mutation to pair branch instructions with one
  35. /// of their predecessors back to back for instructions that benefit according
  36. /// to the target-specific shouldScheduleAdjacent predicate function.
  37. std::unique_ptr<ScheduleDAGMutation>
  38. createBranchMacroFusionDAGMutation(ShouldSchedulePredTy shouldScheduleAdjacent);
  39. } // end namespace llvm
  40. #endif // LLVM_CODEGEN_MACROFUSION_H