CombinerInfo.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/CodeGen/GlobalISel/CombinerInfo.h ------*- 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. /// \file
  14. /// Interface for Targets to specify which operations are combined how and when.
  15. ///
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_CODEGEN_GLOBALISEL_COMBINERINFO_H
  18. #define LLVM_CODEGEN_GLOBALISEL_COMBINERINFO_H
  19. #include <cassert>
  20. namespace llvm {
  21. class GISelChangeObserver;
  22. class LegalizerInfo;
  23. class MachineInstr;
  24. class MachineIRBuilder;
  25. // Contains information relevant to enabling/disabling various combines for a
  26. // pass.
  27. class CombinerInfo {
  28. public:
  29. CombinerInfo(bool AllowIllegalOps, bool ShouldLegalizeIllegal,
  30. const LegalizerInfo *LInfo, bool OptEnabled, bool OptSize,
  31. bool MinSize)
  32. : IllegalOpsAllowed(AllowIllegalOps),
  33. LegalizeIllegalOps(ShouldLegalizeIllegal), LInfo(LInfo),
  34. EnableOpt(OptEnabled), EnableOptSize(OptSize), EnableMinSize(MinSize) {
  35. assert(((AllowIllegalOps || !LegalizeIllegalOps) || LInfo) &&
  36. "Expecting legalizerInfo when illegalops not allowed");
  37. }
  38. virtual ~CombinerInfo() = default;
  39. /// If \p IllegalOpsAllowed is false, the CombinerHelper will make use of
  40. /// the legalizerInfo to check for legality before each transformation.
  41. bool IllegalOpsAllowed; // TODO: Make use of this.
  42. /// If \p LegalizeIllegalOps is true, the Combiner will also legalize the
  43. /// illegal ops that are created.
  44. bool LegalizeIllegalOps; // TODO: Make use of this.
  45. const LegalizerInfo *LInfo;
  46. /// Whether optimizations should be enabled. This is to distinguish between
  47. /// uses of the combiner unconditionally and only when optimizations are
  48. /// specifically enabled/
  49. bool EnableOpt;
  50. /// Whether we're optimizing for size.
  51. bool EnableOptSize;
  52. /// Whether we're optimizing for minsize (-Oz).
  53. bool EnableMinSize;
  54. /// Attempt to combine instructions using MI as the root.
  55. ///
  56. /// Use Observer to report the creation, modification, and erasure of
  57. /// instructions. GISelChangeObserver will automatically report certain
  58. /// kinds of operations. These operations are:
  59. /// * Instructions that are newly inserted into the MachineFunction
  60. /// * Instructions that are erased from the MachineFunction.
  61. ///
  62. /// However, it is important to report instruction modification and this is
  63. /// not automatic.
  64. virtual bool combine(GISelChangeObserver &Observer, MachineInstr &MI,
  65. MachineIRBuilder &B) const = 0;
  66. };
  67. } // namespace llvm
  68. #endif
  69. #ifdef __GNUC__
  70. #pragma GCC diagnostic pop
  71. #endif