ARMRegisterBankInfo.cpp 18 KB

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