PPCInstructionSelector.cpp 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. //===- PPCInstructionSelector.cpp --------------------------------*- 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. /// \file
  9. /// This file implements the targeting of the InstructionSelector class for
  10. /// PowerPC.
  11. //===----------------------------------------------------------------------===//
  12. #include "PPCInstrInfo.h"
  13. #include "PPCRegisterBankInfo.h"
  14. #include "PPCSubtarget.h"
  15. #include "PPCTargetMachine.h"
  16. #include "llvm/CodeGen/GlobalISel/InstructionSelector.h"
  17. #include "llvm/CodeGen/GlobalISel/InstructionSelectorImpl.h"
  18. #include "llvm/CodeGen/MachineFunction.h"
  19. #include "llvm/IR/IntrinsicsPowerPC.h"
  20. #include "llvm/Support/Debug.h"
  21. #define DEBUG_TYPE "ppc-gisel"
  22. using namespace llvm;
  23. namespace {
  24. #define GET_GLOBALISEL_PREDICATE_BITSET
  25. #include "PPCGenGlobalISel.inc"
  26. #undef GET_GLOBALISEL_PREDICATE_BITSET
  27. class PPCInstructionSelector : public InstructionSelector {
  28. public:
  29. PPCInstructionSelector(const PPCTargetMachine &TM, const PPCSubtarget &STI,
  30. const PPCRegisterBankInfo &RBI);
  31. bool select(MachineInstr &I) override;
  32. static const char *getName() { return DEBUG_TYPE; }
  33. private:
  34. /// tblgen generated 'select' implementation that is used as the initial
  35. /// selector for the patterns that do not require complex C++.
  36. bool selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const;
  37. const PPCInstrInfo &TII;
  38. const PPCRegisterInfo &TRI;
  39. const PPCRegisterBankInfo &RBI;
  40. #define GET_GLOBALISEL_PREDICATES_DECL
  41. #include "PPCGenGlobalISel.inc"
  42. #undef GET_GLOBALISEL_PREDICATES_DECL
  43. #define GET_GLOBALISEL_TEMPORARIES_DECL
  44. #include "PPCGenGlobalISel.inc"
  45. #undef GET_GLOBALISEL_TEMPORARIES_DECL
  46. };
  47. } // end anonymous namespace
  48. #define GET_GLOBALISEL_IMPL
  49. #include "PPCGenGlobalISel.inc"
  50. #undef GET_GLOBALISEL_IMPL
  51. PPCInstructionSelector::PPCInstructionSelector(const PPCTargetMachine &TM,
  52. const PPCSubtarget &STI,
  53. const PPCRegisterBankInfo &RBI)
  54. : TII(*STI.getInstrInfo()), TRI(*STI.getRegisterInfo()), RBI(RBI),
  55. #define GET_GLOBALISEL_PREDICATES_INIT
  56. #include "PPCGenGlobalISel.inc"
  57. #undef GET_GLOBALISEL_PREDICATES_INIT
  58. #define GET_GLOBALISEL_TEMPORARIES_INIT
  59. #include "PPCGenGlobalISel.inc"
  60. #undef GET_GLOBALISEL_TEMPORARIES_INIT
  61. {
  62. }
  63. bool PPCInstructionSelector::select(MachineInstr &I) {
  64. if (selectImpl(I, *CoverageInfo))
  65. return true;
  66. return false;
  67. }
  68. namespace llvm {
  69. InstructionSelector *
  70. createPPCInstructionSelector(const PPCTargetMachine &TM,
  71. const PPCSubtarget &Subtarget,
  72. const PPCRegisterBankInfo &RBI) {
  73. return new PPCInstructionSelector(TM, Subtarget, RBI);
  74. }
  75. } // end namespace llvm