ARMRegisterBankInfo.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. //===- ARMRegisterBankInfo.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 RegisterBankInfo class for ARM.
  10. /// \todo This should be generated by TableGen.
  11. //===----------------------------------------------------------------------===//
  12. #include "ARMRegisterBankInfo.h"
  13. #include "ARMInstrInfo.h" // For the register classes
  14. #include "ARMSubtarget.h"
  15. #include "llvm/CodeGen/MachineRegisterInfo.h"
  16. #include "llvm/CodeGen/RegisterBank.h"
  17. #include "llvm/CodeGen/RegisterBankInfo.h"
  18. #include "llvm/CodeGen/TargetRegisterInfo.h"
  19. #define GET_TARGET_REGBANK_IMPL
  20. #include "ARMGenRegisterBank.inc"
  21. using namespace llvm;
  22. // FIXME: TableGen this.
  23. // If it grows too much and TableGen still isn't ready to do the job, extract it
  24. // into an ARMGenRegisterBankInfo.def (similar to AArch64).
  25. namespace llvm {
  26. namespace ARM {
  27. enum PartialMappingIdx {
  28. PMI_GPR,
  29. PMI_SPR,
  30. PMI_DPR,
  31. PMI_Min = PMI_GPR,
  32. };
  33. RegisterBankInfo::PartialMapping PartMappings[]{
  34. // GPR Partial Mapping
  35. {0, 32, GPRRegBank},
  36. // SPR Partial Mapping
  37. {0, 32, FPRRegBank},
  38. // DPR Partial Mapping
  39. {0, 64, FPRRegBank},
  40. };
  41. #ifndef NDEBUG
  42. static bool checkPartMapping(const RegisterBankInfo::PartialMapping &PM,
  43. unsigned Start, unsigned Length,
  44. unsigned RegBankID) {
  45. return PM.StartIdx == Start && PM.Length == Length &&
  46. PM.RegBank->getID() == RegBankID;
  47. }
  48. static void checkPartialMappings() {
  49. assert(
  50. checkPartMapping(PartMappings[PMI_GPR - PMI_Min], 0, 32, GPRRegBankID) &&
  51. "Wrong mapping for GPR");
  52. assert(
  53. checkPartMapping(PartMappings[PMI_SPR - PMI_Min], 0, 32, FPRRegBankID) &&
  54. "Wrong mapping for SPR");
  55. assert(
  56. checkPartMapping(PartMappings[PMI_DPR - PMI_Min], 0, 64, FPRRegBankID) &&
  57. "Wrong mapping for DPR");
  58. }
  59. #endif
  60. enum ValueMappingIdx {
  61. InvalidIdx = 0,
  62. GPR3OpsIdx = 1,
  63. SPR3OpsIdx = 4,
  64. DPR3OpsIdx = 7,
  65. };
  66. RegisterBankInfo::ValueMapping ValueMappings[] = {
  67. // invalid
  68. {nullptr, 0},
  69. // 3 ops in GPRs
  70. {&PartMappings[PMI_GPR - PMI_Min], 1},
  71. {&PartMappings[PMI_GPR - PMI_Min], 1},
  72. {&PartMappings[PMI_GPR - PMI_Min], 1},
  73. // 3 ops in SPRs
  74. {&PartMappings[PMI_SPR - PMI_Min], 1},
  75. {&PartMappings[PMI_SPR - PMI_Min], 1},
  76. {&PartMappings[PMI_SPR - PMI_Min], 1},
  77. // 3 ops in DPRs
  78. {&PartMappings[PMI_DPR - PMI_Min], 1},
  79. {&PartMappings[PMI_DPR - PMI_Min], 1},
  80. {&PartMappings[PMI_DPR - PMI_Min], 1}};
  81. #ifndef NDEBUG
  82. static bool checkValueMapping(const RegisterBankInfo::ValueMapping &VM,
  83. RegisterBankInfo::PartialMapping *BreakDown) {
  84. return VM.NumBreakDowns == 1 && VM.BreakDown == BreakDown;
  85. }
  86. static void checkValueMappings() {
  87. assert(checkValueMapping(ValueMappings[GPR3OpsIdx],
  88. &PartMappings[PMI_GPR - PMI_Min]) &&
  89. "Wrong value mapping for 3 GPR ops instruction");
  90. assert(checkValueMapping(ValueMappings[GPR3OpsIdx + 1],
  91. &PartMappings[PMI_GPR - PMI_Min]) &&
  92. "Wrong value mapping for 3 GPR ops instruction");
  93. assert(checkValueMapping(ValueMappings[GPR3OpsIdx + 2],
  94. &PartMappings[PMI_GPR - PMI_Min]) &&
  95. "Wrong value mapping for 3 GPR ops instruction");
  96. assert(checkValueMapping(ValueMappings[SPR3OpsIdx],
  97. &PartMappings[PMI_SPR - PMI_Min]) &&
  98. "Wrong value mapping for 3 SPR ops instruction");
  99. assert(checkValueMapping(ValueMappings[SPR3OpsIdx + 1],
  100. &PartMappings[PMI_SPR - PMI_Min]) &&
  101. "Wrong value mapping for 3 SPR ops instruction");
  102. assert(checkValueMapping(ValueMappings[SPR3OpsIdx + 2],
  103. &PartMappings[PMI_SPR - PMI_Min]) &&
  104. "Wrong value mapping for 3 SPR ops instruction");
  105. assert(checkValueMapping(ValueMappings[DPR3OpsIdx],
  106. &PartMappings[PMI_DPR - PMI_Min]) &&
  107. "Wrong value mapping for 3 DPR ops instruction");
  108. assert(checkValueMapping(ValueMappings[DPR3OpsIdx + 1],
  109. &PartMappings[PMI_DPR - PMI_Min]) &&
  110. "Wrong value mapping for 3 DPR ops instruction");
  111. assert(checkValueMapping(ValueMappings[DPR3OpsIdx + 2],
  112. &PartMappings[PMI_DPR - PMI_Min]) &&
  113. "Wrong value mapping for 3 DPR ops instruction");
  114. }
  115. #endif
  116. } // end namespace arm
  117. } // end namespace llvm
  118. ARMRegisterBankInfo::ARMRegisterBankInfo(const TargetRegisterInfo &TRI) {
  119. // We have only one set of register banks, whatever the subtarget
  120. // is. Therefore, the initialization of the RegBanks table should be
  121. // done only once. Indeed the table of all register banks
  122. // (ARM::RegBanks) is unique in the compiler. At some point, it
  123. // will get tablegen'ed and the whole constructor becomes empty.
  124. static llvm::once_flag InitializeRegisterBankFlag;
  125. static auto InitializeRegisterBankOnce = [&]() {
  126. const RegisterBank &RBGPR = getRegBank(ARM::GPRRegBankID);
  127. (void)RBGPR;
  128. assert(&ARM::GPRRegBank == &RBGPR && "The order in RegBanks is messed up");
  129. // Initialize the GPR bank.
  130. assert(RBGPR.covers(*TRI.getRegClass(ARM::GPRRegClassID)) &&
  131. "Subclass not added?");
  132. assert(RBGPR.covers(*TRI.getRegClass(ARM::GPRwithAPSRRegClassID)) &&
  133. "Subclass not added?");
  134. assert(RBGPR.covers(*TRI.getRegClass(ARM::GPRnopcRegClassID)) &&
  135. "Subclass not added?");
  136. assert(RBGPR.covers(*TRI.getRegClass(ARM::rGPRRegClassID)) &&
  137. "Subclass not added?");
  138. assert(RBGPR.covers(*TRI.getRegClass(ARM::tGPRRegClassID)) &&
  139. "Subclass not added?");
  140. assert(RBGPR.covers(*TRI.getRegClass(ARM::tcGPRRegClassID)) &&
  141. "Subclass not added?");
  142. assert(RBGPR.covers(*TRI.getRegClass(ARM::GPRnoip_and_tcGPRRegClassID)) &&
  143. "Subclass not added?");
  144. assert(RBGPR.covers(*TRI.getRegClass(
  145. ARM::tGPREven_and_GPRnoip_and_tcGPRRegClassID)) &&
  146. "Subclass not added?");
  147. assert(RBGPR.covers(*TRI.getRegClass(ARM::tGPROdd_and_tcGPRRegClassID)) &&
  148. "Subclass not added?");
  149. assert(RBGPR.getSize() == 32 && "GPRs should hold up to 32-bit");
  150. #ifndef NDEBUG
  151. ARM::checkPartialMappings();
  152. ARM::checkValueMappings();
  153. #endif
  154. };
  155. llvm::call_once(InitializeRegisterBankFlag, InitializeRegisterBankOnce);
  156. }
  157. const RegisterBank &
  158. ARMRegisterBankInfo::getRegBankFromRegClass(const TargetRegisterClass &RC,
  159. LLT) const {
  160. using namespace ARM;
  161. switch (RC.getID()) {
  162. case GPRRegClassID:
  163. case GPRwithAPSRRegClassID:
  164. case GPRnoipRegClassID:
  165. case GPRnopcRegClassID:
  166. case GPRnoip_and_GPRnopcRegClassID:
  167. case rGPRRegClassID:
  168. case GPRspRegClassID:
  169. case GPRnoip_and_tcGPRRegClassID:
  170. case tcGPRRegClassID:
  171. case tGPRRegClassID:
  172. case tGPREvenRegClassID:
  173. case tGPROddRegClassID:
  174. case tGPR_and_tGPREvenRegClassID:
  175. case tGPR_and_tGPROddRegClassID:
  176. case tGPREven_and_tcGPRRegClassID:
  177. case tGPREven_and_GPRnoip_and_tcGPRRegClassID:
  178. case tGPROdd_and_tcGPRRegClassID:
  179. return getRegBank(ARM::GPRRegBankID);
  180. case HPRRegClassID:
  181. case SPR_8RegClassID:
  182. case SPRRegClassID:
  183. case DPR_8RegClassID:
  184. case DPRRegClassID:
  185. case QPRRegClassID:
  186. return getRegBank(ARM::FPRRegBankID);
  187. default:
  188. llvm_unreachable("Unsupported register kind");
  189. }
  190. llvm_unreachable("Switch should handle all register classes");
  191. }
  192. const RegisterBankInfo::InstructionMapping &
  193. ARMRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {
  194. auto Opc = MI.getOpcode();
  195. // Try the default logic for non-generic instructions that are either copies
  196. // or already have some operands assigned to banks.
  197. if (!isPreISelGenericOpcode(Opc) || Opc == TargetOpcode::G_PHI) {
  198. const InstructionMapping &Mapping = getInstrMappingImpl(MI);
  199. if (Mapping.isValid())
  200. return Mapping;
  201. }
  202. using namespace TargetOpcode;
  203. const MachineFunction &MF = *MI.getParent()->getParent();
  204. const MachineRegisterInfo &MRI = MF.getRegInfo();
  205. unsigned NumOperands = MI.getNumOperands();
  206. const ValueMapping *OperandsMapping = &ARM::ValueMappings[ARM::GPR3OpsIdx];
  207. switch (Opc) {
  208. case G_ADD:
  209. case G_SUB: {
  210. // Integer operations where the source and destination are in the
  211. // same register class.
  212. LLT Ty = MRI.getType(MI.getOperand(0).getReg());
  213. OperandsMapping = Ty.getSizeInBits() == 64
  214. ? &ARM::ValueMappings[ARM::DPR3OpsIdx]
  215. : &ARM::ValueMappings[ARM::GPR3OpsIdx];
  216. break;
  217. }
  218. case G_MUL:
  219. case G_AND:
  220. case G_OR:
  221. case G_XOR:
  222. case G_LSHR:
  223. case G_ASHR:
  224. case G_SHL:
  225. case G_SDIV:
  226. case G_UDIV:
  227. case G_SEXT:
  228. case G_ZEXT:
  229. case G_ANYEXT:
  230. case G_PTR_ADD:
  231. case G_INTTOPTR:
  232. case G_PTRTOINT:
  233. case G_CTLZ:
  234. // FIXME: We're abusing the fact that everything lives in a GPR for now; in
  235. // the real world we would use different mappings.
  236. OperandsMapping = &ARM::ValueMappings[ARM::GPR3OpsIdx];
  237. break;
  238. case G_TRUNC: {
  239. // In some cases we may end up with a G_TRUNC from a 64-bit value to a
  240. // 32-bit value. This isn't a real floating point trunc (that would be a
  241. // G_FPTRUNC). Instead it is an integer trunc in disguise, which can appear
  242. // because the legalizer doesn't distinguish between integer and floating
  243. // point values so it may leave some 64-bit integers un-narrowed. Until we
  244. // have a more principled solution that doesn't let such things sneak all
  245. // the way to this point, just map the source to a DPR and the destination
  246. // to a GPR.
  247. LLT LargeTy = MRI.getType(MI.getOperand(1).getReg());
  248. OperandsMapping =
  249. LargeTy.getSizeInBits() <= 32
  250. ? &ARM::ValueMappings[ARM::GPR3OpsIdx]
  251. : getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx],
  252. &ARM::ValueMappings[ARM::DPR3OpsIdx]});
  253. break;
  254. }
  255. case G_LOAD:
  256. case G_STORE: {
  257. LLT Ty = MRI.getType(MI.getOperand(0).getReg());
  258. OperandsMapping =
  259. Ty.getSizeInBits() == 64
  260. ? getOperandsMapping({&ARM::ValueMappings[ARM::DPR3OpsIdx],
  261. &ARM::ValueMappings[ARM::GPR3OpsIdx]})
  262. : &ARM::ValueMappings[ARM::GPR3OpsIdx];
  263. break;
  264. }
  265. case G_FADD:
  266. case G_FSUB:
  267. case G_FMUL:
  268. case G_FDIV:
  269. case G_FNEG: {
  270. LLT Ty = MRI.getType(MI.getOperand(0).getReg());
  271. OperandsMapping =Ty.getSizeInBits() == 64
  272. ? &ARM::ValueMappings[ARM::DPR3OpsIdx]
  273. : &ARM::ValueMappings[ARM::SPR3OpsIdx];
  274. break;
  275. }
  276. case G_FMA: {
  277. LLT Ty = MRI.getType(MI.getOperand(0).getReg());
  278. OperandsMapping =
  279. Ty.getSizeInBits() == 64
  280. ? getOperandsMapping({&ARM::ValueMappings[ARM::DPR3OpsIdx],
  281. &ARM::ValueMappings[ARM::DPR3OpsIdx],
  282. &ARM::ValueMappings[ARM::DPR3OpsIdx],
  283. &ARM::ValueMappings[ARM::DPR3OpsIdx]})
  284. : getOperandsMapping({&ARM::ValueMappings[ARM::SPR3OpsIdx],
  285. &ARM::ValueMappings[ARM::SPR3OpsIdx],
  286. &ARM::ValueMappings[ARM::SPR3OpsIdx],
  287. &ARM::ValueMappings[ARM::SPR3OpsIdx]});
  288. break;
  289. }
  290. case G_FPEXT: {
  291. LLT ToTy = MRI.getType(MI.getOperand(0).getReg());
  292. LLT FromTy = MRI.getType(MI.getOperand(1).getReg());
  293. if (ToTy.getSizeInBits() == 64 && FromTy.getSizeInBits() == 32)
  294. OperandsMapping =
  295. getOperandsMapping({&ARM::ValueMappings[ARM::DPR3OpsIdx],
  296. &ARM::ValueMappings[ARM::SPR3OpsIdx]});
  297. break;
  298. }
  299. case G_FPTRUNC: {
  300. LLT ToTy = MRI.getType(MI.getOperand(0).getReg());
  301. LLT FromTy = MRI.getType(MI.getOperand(1).getReg());
  302. if (ToTy.getSizeInBits() == 32 && FromTy.getSizeInBits() == 64)
  303. OperandsMapping =
  304. getOperandsMapping({&ARM::ValueMappings[ARM::SPR3OpsIdx],
  305. &ARM::ValueMappings[ARM::DPR3OpsIdx]});
  306. break;
  307. }
  308. case G_FPTOSI:
  309. case G_FPTOUI: {
  310. LLT ToTy = MRI.getType(MI.getOperand(0).getReg());
  311. LLT FromTy = MRI.getType(MI.getOperand(1).getReg());
  312. if ((FromTy.getSizeInBits() == 32 || FromTy.getSizeInBits() == 64) &&
  313. ToTy.getSizeInBits() == 32)
  314. OperandsMapping =
  315. FromTy.getSizeInBits() == 64
  316. ? getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx],
  317. &ARM::ValueMappings[ARM::DPR3OpsIdx]})
  318. : getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx],
  319. &ARM::ValueMappings[ARM::SPR3OpsIdx]});
  320. break;
  321. }
  322. case G_SITOFP:
  323. case G_UITOFP: {
  324. LLT ToTy = MRI.getType(MI.getOperand(0).getReg());
  325. LLT FromTy = MRI.getType(MI.getOperand(1).getReg());
  326. if (FromTy.getSizeInBits() == 32 &&
  327. (ToTy.getSizeInBits() == 32 || ToTy.getSizeInBits() == 64))
  328. OperandsMapping =
  329. ToTy.getSizeInBits() == 64
  330. ? getOperandsMapping({&ARM::ValueMappings[ARM::DPR3OpsIdx],
  331. &ARM::ValueMappings[ARM::GPR3OpsIdx]})
  332. : getOperandsMapping({&ARM::ValueMappings[ARM::SPR3OpsIdx],
  333. &ARM::ValueMappings[ARM::GPR3OpsIdx]});
  334. break;
  335. }
  336. case G_FCONSTANT: {
  337. LLT Ty = MRI.getType(MI.getOperand(0).getReg());
  338. OperandsMapping = getOperandsMapping(
  339. {Ty.getSizeInBits() == 64 ? &ARM::ValueMappings[ARM::DPR3OpsIdx]
  340. : &ARM::ValueMappings[ARM::SPR3OpsIdx],
  341. nullptr});
  342. break;
  343. }
  344. case G_CONSTANT:
  345. case G_FRAME_INDEX:
  346. case G_GLOBAL_VALUE:
  347. OperandsMapping =
  348. getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx], nullptr});
  349. break;
  350. case G_SELECT: {
  351. LLT Ty = MRI.getType(MI.getOperand(0).getReg());
  352. (void)Ty;
  353. LLT Ty2 = MRI.getType(MI.getOperand(1).getReg());
  354. (void)Ty2;
  355. assert(Ty.getSizeInBits() == 32 && "Unsupported size for G_SELECT");
  356. assert(Ty2.getSizeInBits() == 1 && "Unsupported size for G_SELECT");
  357. OperandsMapping =
  358. getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx],
  359. &ARM::ValueMappings[ARM::GPR3OpsIdx],
  360. &ARM::ValueMappings[ARM::GPR3OpsIdx],
  361. &ARM::ValueMappings[ARM::GPR3OpsIdx]});
  362. break;
  363. }
  364. case G_ICMP: {
  365. LLT Ty2 = MRI.getType(MI.getOperand(2).getReg());
  366. (void)Ty2;
  367. assert(Ty2.getSizeInBits() == 32 && "Unsupported size for G_ICMP");
  368. OperandsMapping =
  369. getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx], nullptr,
  370. &ARM::ValueMappings[ARM::GPR3OpsIdx],
  371. &ARM::ValueMappings[ARM::GPR3OpsIdx]});
  372. break;
  373. }
  374. case G_FCMP: {
  375. LLT Ty = MRI.getType(MI.getOperand(0).getReg());
  376. (void)Ty;
  377. LLT Ty1 = MRI.getType(MI.getOperand(2).getReg());
  378. LLT Ty2 = MRI.getType(MI.getOperand(3).getReg());
  379. (void)Ty2;
  380. assert(Ty.getSizeInBits() == 1 && "Unsupported size for G_FCMP");
  381. assert(Ty1.getSizeInBits() == Ty2.getSizeInBits() &&
  382. "Mismatched operand sizes for G_FCMP");
  383. unsigned Size = Ty1.getSizeInBits();
  384. assert((Size == 32 || Size == 64) && "Unsupported size for G_FCMP");
  385. auto FPRValueMapping = Size == 32 ? &ARM::ValueMappings[ARM::SPR3OpsIdx]
  386. : &ARM::ValueMappings[ARM::DPR3OpsIdx];
  387. OperandsMapping =
  388. getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx], nullptr,
  389. FPRValueMapping, FPRValueMapping});
  390. break;
  391. }
  392. case G_MERGE_VALUES: {
  393. // We only support G_MERGE_VALUES for creating a double precision floating
  394. // point value out of two GPRs.
  395. LLT Ty = MRI.getType(MI.getOperand(0).getReg());
  396. LLT Ty1 = MRI.getType(MI.getOperand(1).getReg());
  397. LLT Ty2 = MRI.getType(MI.getOperand(2).getReg());
  398. if (Ty.getSizeInBits() != 64 || Ty1.getSizeInBits() != 32 ||
  399. Ty2.getSizeInBits() != 32)
  400. return getInvalidInstructionMapping();
  401. OperandsMapping =
  402. getOperandsMapping({&ARM::ValueMappings[ARM::DPR3OpsIdx],
  403. &ARM::ValueMappings[ARM::GPR3OpsIdx],
  404. &ARM::ValueMappings[ARM::GPR3OpsIdx]});
  405. break;
  406. }
  407. case G_UNMERGE_VALUES: {
  408. // We only support G_UNMERGE_VALUES for splitting a double precision
  409. // floating point value into two GPRs.
  410. LLT Ty = MRI.getType(MI.getOperand(0).getReg());
  411. LLT Ty1 = MRI.getType(MI.getOperand(1).getReg());
  412. LLT Ty2 = MRI.getType(MI.getOperand(2).getReg());
  413. if (Ty.getSizeInBits() != 32 || Ty1.getSizeInBits() != 32 ||
  414. Ty2.getSizeInBits() != 64)
  415. return getInvalidInstructionMapping();
  416. OperandsMapping =
  417. getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx],
  418. &ARM::ValueMappings[ARM::GPR3OpsIdx],
  419. &ARM::ValueMappings[ARM::DPR3OpsIdx]});
  420. break;
  421. }
  422. case G_BR:
  423. OperandsMapping = getOperandsMapping({nullptr});
  424. break;
  425. case G_BRCOND:
  426. OperandsMapping =
  427. getOperandsMapping({&ARM::ValueMappings[ARM::GPR3OpsIdx], nullptr});
  428. break;
  429. case DBG_VALUE: {
  430. SmallVector<const ValueMapping *, 4> OperandBanks(NumOperands);
  431. const MachineOperand &MaybeReg = MI.getOperand(0);
  432. if (MaybeReg.isReg() && MaybeReg.getReg()) {
  433. unsigned Size = MRI.getType(MaybeReg.getReg()).getSizeInBits();
  434. if (Size > 32 && Size != 64)
  435. return getInvalidInstructionMapping();
  436. OperandBanks[0] = Size == 64 ? &ARM::ValueMappings[ARM::DPR3OpsIdx]
  437. : &ARM::ValueMappings[ARM::GPR3OpsIdx];
  438. }
  439. OperandsMapping = getOperandsMapping(OperandBanks);
  440. break;
  441. }
  442. default:
  443. return getInvalidInstructionMapping();
  444. }
  445. #ifndef NDEBUG
  446. for (unsigned i = 0; i < NumOperands; i++) {
  447. for (const auto &Mapping : OperandsMapping[i]) {
  448. assert(
  449. (Mapping.RegBank->getID() != ARM::FPRRegBankID ||
  450. MF.getSubtarget<ARMSubtarget>().hasVFP2Base()) &&
  451. "Trying to use floating point register bank on target without vfp");
  452. }
  453. }
  454. #endif
  455. return getInstructionMapping(DefaultMappingID, /*Cost=*/1, OperandsMapping,
  456. NumOperands);
  457. }