PPCGenRegisterBankInfo.def 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. //===- PPCGenRegisterBankInfo.def -------------------------------*- 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 defines all the static objects used by PPCRegisterBankInfo.
  10. /// \todo This should be generated by TableGen, because the logic here can be
  11. /// derived from register bank definition. Not yet implemented.
  12. //===----------------------------------------------------------------------===//
  13. namespace llvm {
  14. RegisterBankInfo::PartialMapping PPCGenRegisterBankInfo::PartMappings[]{
  15. /* StartIdx, Length, RegBank */
  16. // 0: GPR 32-bit value.
  17. {0, 32, PPC::GPRRegBank},
  18. // 1: GPR 64-bit value.
  19. {0, 64, PPC::GPRRegBank},
  20. // 2: FPR 32-bit value
  21. {0, 32, PPC::FPRRegBank},
  22. // 3: FPR 64-bit value
  23. {0, 64, PPC::FPRRegBank},
  24. // 4: CR 4-bit value
  25. {0, 4, PPC::CRRegBank},
  26. };
  27. // ValueMappings.
  28. // Pointers to the entries in this array are returned by getValueMapping() and
  29. // getCopyMapping().
  30. //
  31. // The array has the following structure:
  32. // - At index 0 is the invalid entry.
  33. // - After that, the mappings for the register types from PartialMappingIdx
  34. // follow. Each mapping consists of 3 entries, which is needed to cover
  35. // 3-operands instructions.
  36. // - Last, mappings for cross-register bank moves follow. Since COPY has only
  37. // 2 operands, a mapping consists of 2 entries.
  38. RegisterBankInfo::ValueMapping PPCGenRegisterBankInfo::ValMappings[]{
  39. /* BreakDown, NumBreakDowns */
  40. // 0: invalid
  41. {nullptr, 0},
  42. // 1: GPR 32-bit value.
  43. {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR32 - PMI_Min], 1},
  44. {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR32 - PMI_Min], 1},
  45. {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR32 - PMI_Min], 1},
  46. // 4: GPR 64-bit value.
  47. {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR64 - PMI_Min], 1},
  48. {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR64 - PMI_Min], 1},
  49. {&PPCGenRegisterBankInfo::PartMappings[PMI_GPR64 - PMI_Min], 1},
  50. // 7: FPR 32-bit value.
  51. {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR32 - PMI_Min], 1},
  52. {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR32 - PMI_Min], 1},
  53. {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR32 - PMI_Min], 1},
  54. // 10: FPR 64-bit value.
  55. {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR64 - PMI_Min], 1},
  56. {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR64 - PMI_Min], 1},
  57. {&PPCGenRegisterBankInfo::PartMappings[PMI_FPR64 - PMI_Min], 1},
  58. // 13: CR 4-bit value.
  59. {&PPCGenRegisterBankInfo::PartMappings[PMI_CR - PMI_Min], 1},
  60. };
  61. // TODO Too simple!
  62. const RegisterBankInfo::ValueMapping *
  63. PPCGenRegisterBankInfo::getValueMapping(PartialMappingIdx RBIdx) {
  64. assert(RBIdx != PartialMappingIdx::PMI_None && "No mapping needed for that");
  65. unsigned ValMappingIdx = RBIdx - PMI_Min;
  66. return &ValMappings[1 + 3 * ValMappingIdx];
  67. }
  68. // TODO Too simple!
  69. const RegisterBankInfo::ValueMapping *
  70. PPCGenRegisterBankInfo::getCopyMapping(unsigned DstBankID, unsigned SrcBankID,
  71. unsigned Size) {
  72. assert(DstBankID < PPC::NumRegisterBanks && "Invalid bank ID");
  73. assert(SrcBankID < PPC::NumRegisterBanks && "Invalid bank ID");
  74. return &ValMappings[1];
  75. }
  76. } // namespace llvm