PPCInstructionSelector.cpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. : InstructionSelector(), TII(*STI.getInstrInfo()),
  55. TRI(*STI.getRegisterInfo()), RBI(RBI),
  56. #define GET_GLOBALISEL_PREDICATES_INIT
  57. #include "PPCGenGlobalISel.inc"
  58. #undef GET_GLOBALISEL_PREDICATES_INIT
  59. #define GET_GLOBALISEL_TEMPORARIES_INIT
  60. #include "PPCGenGlobalISel.inc"
  61. #undef GET_GLOBALISEL_TEMPORARIES_INIT
  62. {
  63. }
  64. bool PPCInstructionSelector::select(MachineInstr &I) {
  65. if (selectImpl(I, *CoverageInfo))
  66. return true;
  67. return false;
  68. }
  69. namespace llvm {
  70. InstructionSelector *
  71. createPPCInstructionSelector(const PPCTargetMachine &TM,
  72. const PPCSubtarget &Subtarget,
  73. const PPCRegisterBankInfo &RBI) {
  74. return new PPCInstructionSelector(TM, Subtarget, RBI);
  75. }
  76. } // end namespace llvm