X86GenRegisterBankInfo.def 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. //===- X86GenRegisterBankInfo.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 X86RegisterBankInfo.
  10. /// \todo This should be generated by TableGen.
  11. //===----------------------------------------------------------------------===//
  12. #ifdef GET_TARGET_REGBANK_INFO_IMPL
  13. RegisterBankInfo::PartialMapping X86GenRegisterBankInfo::PartMappings[]{
  14. /* StartIdx, Length, RegBank */
  15. // GPR value
  16. {0, 8, X86::GPRRegBank}, // :0
  17. {0, 16, X86::GPRRegBank}, // :1
  18. {0, 32, X86::GPRRegBank}, // :2
  19. {0, 64, X86::GPRRegBank}, // :3
  20. // FR32/64 , xmm registers
  21. {0, 32, X86::VECRRegBank}, // :4
  22. {0, 64, X86::VECRRegBank}, // :5
  23. // VR128/256/512
  24. {0, 128, X86::VECRRegBank}, // :6
  25. {0, 256, X86::VECRRegBank}, // :7
  26. {0, 512, X86::VECRRegBank}, // :8
  27. };
  28. #endif // GET_TARGET_REGBANK_INFO_IMPL
  29. #ifdef GET_TARGET_REGBANK_INFO_CLASS
  30. enum PartialMappingIdx {
  31. PMI_None = -1,
  32. PMI_GPR8,
  33. PMI_GPR16,
  34. PMI_GPR32,
  35. PMI_GPR64,
  36. PMI_FP32,
  37. PMI_FP64,
  38. PMI_VEC128,
  39. PMI_VEC256,
  40. PMI_VEC512
  41. };
  42. #endif // GET_TARGET_REGBANK_INFO_CLASS
  43. #ifdef GET_TARGET_REGBANK_INFO_IMPL
  44. #define INSTR_3OP(INFO) INFO, INFO, INFO,
  45. #define BREAKDOWN(INDEX, NUM) \
  46. { &X86GenRegisterBankInfo::PartMappings[INDEX], NUM }
  47. // ValueMappings.
  48. RegisterBankInfo::ValueMapping X86GenRegisterBankInfo::ValMappings[]{
  49. /* BreakDown, NumBreakDowns */
  50. // 3-operands instructions (all binary operations should end up with one of
  51. // those mapping).
  52. INSTR_3OP(BREAKDOWN(PMI_GPR8, 1)) // 0: GPR_8
  53. INSTR_3OP(BREAKDOWN(PMI_GPR16, 1)) // 3: GPR_16
  54. INSTR_3OP(BREAKDOWN(PMI_GPR32, 1)) // 6: GPR_32
  55. INSTR_3OP(BREAKDOWN(PMI_GPR64, 1)) // 9: GPR_64
  56. INSTR_3OP(BREAKDOWN(PMI_FP32, 1)) // 12: Fp32
  57. INSTR_3OP(BREAKDOWN(PMI_FP64, 1)) // 15: Fp64
  58. INSTR_3OP(BREAKDOWN(PMI_VEC128, 1)) // 18: Vec128
  59. INSTR_3OP(BREAKDOWN(PMI_VEC256, 1)) // 21: Vec256
  60. INSTR_3OP(BREAKDOWN(PMI_VEC512, 1)) // 24: Vec512
  61. };
  62. #undef INSTR_3OP
  63. #undef BREAKDOWN
  64. #endif // GET_TARGET_REGBANK_INFO_IMPL
  65. #ifdef GET_TARGET_REGBANK_INFO_CLASS
  66. enum ValueMappingIdx {
  67. VMI_None = -1,
  68. VMI_3OpsGpr8Idx = PMI_GPR8 * 3,
  69. VMI_3OpsGpr16Idx = PMI_GPR16 * 3,
  70. VMI_3OpsGpr32Idx = PMI_GPR32 * 3,
  71. VMI_3OpsGpr64Idx = PMI_GPR64 * 3,
  72. VMI_3OpsFp32Idx = PMI_FP32 * 3,
  73. VMI_3OpsFp64Idx = PMI_FP64 * 3,
  74. VMI_3OpsVec128Idx = PMI_VEC128 * 3,
  75. VMI_3OpsVec256Idx = PMI_VEC256 * 3,
  76. VMI_3OpsVec512Idx = PMI_VEC512 * 3,
  77. };
  78. #undef GET_TARGET_REGBANK_INFO_CLASS
  79. #endif // GET_TARGET_REGBANK_INFO_CLASS
  80. #ifdef GET_TARGET_REGBANK_INFO_IMPL
  81. #undef GET_TARGET_REGBANK_INFO_IMPL
  82. const RegisterBankInfo::ValueMapping *
  83. X86GenRegisterBankInfo::getValueMapping(PartialMappingIdx Idx,
  84. unsigned NumOperands) {
  85. // We can use VMI_3Ops Mapping for all the cases.
  86. if (NumOperands <= 3 && (Idx >= PMI_GPR8 && Idx <= PMI_VEC512))
  87. return &ValMappings[(unsigned)Idx * 3];
  88. llvm_unreachable("Unsupported PartialMappingIdx.");
  89. }
  90. #endif // GET_TARGET_REGBANK_INFO_IMPL