Legalizer.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //== llvm/CodeGen/GlobalISel/Legalizer.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. //
  14. /// \file A pass to convert the target-illegal operations created by IR -> MIR
  15. /// translation into ones the target expects to be able to select. This may
  16. /// occur in multiple phases, for example G_ADD <2 x i8> -> G_ADD <2 x i16> ->
  17. /// G_ADD <4 x i16>.
  18. ///
  19. /// The LegalizeHelper class is where most of the work happens, and is designed
  20. /// to be callable from other passes that find themselves with an illegal
  21. /// instruction.
  22. //
  23. //===----------------------------------------------------------------------===//
  24. #ifndef LLVM_CODEGEN_GLOBALISEL_LEGALIZER_H
  25. #define LLVM_CODEGEN_GLOBALISEL_LEGALIZER_H
  26. #include "llvm/ADT/ArrayRef.h"
  27. #include "llvm/ADT/StringRef.h"
  28. #include "llvm/CodeGen/MachineFunction.h"
  29. #include "llvm/CodeGen/MachineFunctionPass.h"
  30. namespace llvm {
  31. class LegalizerInfo;
  32. class MachineIRBuilder;
  33. class MachineInstr;
  34. class GISelChangeObserver;
  35. class LostDebugLocObserver;
  36. class Legalizer : public MachineFunctionPass {
  37. public:
  38. static char ID;
  39. struct MFResult {
  40. bool Changed;
  41. const MachineInstr *FailedOn;
  42. };
  43. private:
  44. /// Initialize the field members using \p MF.
  45. void init(MachineFunction &MF);
  46. public:
  47. // Ctor, nothing fancy.
  48. Legalizer();
  49. StringRef getPassName() const override { return "Legalizer"; }
  50. void getAnalysisUsage(AnalysisUsage &AU) const override;
  51. MachineFunctionProperties getRequiredProperties() const override {
  52. return MachineFunctionProperties().set(
  53. MachineFunctionProperties::Property::IsSSA);
  54. }
  55. MachineFunctionProperties getSetProperties() const override {
  56. return MachineFunctionProperties().set(
  57. MachineFunctionProperties::Property::Legalized);
  58. }
  59. MachineFunctionProperties getClearedProperties() const override {
  60. return MachineFunctionProperties().set(
  61. MachineFunctionProperties::Property::NoPHIs);
  62. }
  63. bool runOnMachineFunction(MachineFunction &MF) override;
  64. static MFResult
  65. legalizeMachineFunction(MachineFunction &MF, const LegalizerInfo &LI,
  66. ArrayRef<GISelChangeObserver *> AuxObservers,
  67. LostDebugLocObserver &LocObserver,
  68. MachineIRBuilder &MIRBuilder);
  69. };
  70. } // End namespace llvm.
  71. #endif
  72. #ifdef __GNUC__
  73. #pragma GCC diagnostic pop
  74. #endif