[PATCH] D27339: [globalisel][aarch64] Make getCopyMapping() take register banks ID's rather than IsGPR booleans

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 6 07:24:24 PST 2016


dsanders updated this revision to Diff 80418.
dsanders added a comment.

Rebase following changes to the previous patches


https://reviews.llvm.org/D27339

Files:
  lib/Target/AArch64/AArch64GenRegisterBankInfo.def
  lib/Target/AArch64/AArch64RegisterBankInfo.cpp


Index: lib/Target/AArch64/AArch64RegisterBankInfo.cpp
===================================================================
--- lib/Target/AArch64/AArch64RegisterBankInfo.cpp
+++ lib/Target/AArch64/AArch64RegisterBankInfo.cpp
@@ -119,8 +119,7 @@
     (void) PartialMapDstIdx;                                                   \
     (void) PartialMapSrcIdx;                                                   \
     const ValueMapping *Map = AArch64::getCopyMapping(                         \
-        AArch64::PMI_First##RBNameDst == AArch64::PMI_FirstGPR,                \
-        AArch64::PMI_First##RBNameSrc == AArch64::PMI_FirstGPR, Size);         \
+        AArch64::RBNameDst##RegBankID, AArch64::RBNameSrc##RegBankID, Size);   \
     (void) Map;                                                                \
     assert(Map[0].BreakDown == &AArch64::PartMappings[PartialMapDstIdx] &&     \
            Map[0].NumBreakDowns == 1 && #RBNameDst #Size                       \
@@ -248,21 +247,25 @@
     InstructionMappings AltMappings;
     InstructionMapping GPRMapping(
         /*ID*/ 1, /*Cost*/ 1,
-        AArch64::getCopyMapping(/*DstIsGPR*/ true, /*SrcIsGPR*/ true, Size),
+        AArch64::getCopyMapping(AArch64::GPRRegBankID, AArch64::GPRRegBankID,
+                                Size),
         /*NumOperands*/ 2);
     InstructionMapping FPRMapping(
         /*ID*/ 2, /*Cost*/ 1,
-        AArch64::getCopyMapping(/*DstIsGPR*/ false, /*SrcIsGPR*/ false, Size),
+        AArch64::getCopyMapping(AArch64::FPRRegBankID, AArch64::FPRRegBankID,
+                                Size),
         /*NumOperands*/ 2);
     InstructionMapping GPRToFPRMapping(
         /*ID*/ 3,
         /*Cost*/ copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size),
-        AArch64::getCopyMapping(/*DstIsGPR*/ false, /*SrcIsGPR*/ true, Size),
+        AArch64::getCopyMapping(AArch64::FPRRegBankID, AArch64::GPRRegBankID,
+                                Size),
         /*NumOperands*/ 2);
     InstructionMapping FPRToGPRMapping(
         /*ID*/ 3,
         /*Cost*/ copyCost(AArch64::GPRRegBank, AArch64::FPRRegBank, Size),
-        AArch64::getCopyMapping(/*DstIsGPR*/ true, /*SrcIsGPR*/ false, Size),
+        AArch64::getCopyMapping(AArch64::GPRRegBankID, AArch64::FPRRegBankID,
+                                Size),
         /*NumOperands*/ 2);
 
     AltMappings.emplace_back(std::move(GPRMapping));
@@ -428,9 +431,10 @@
         DstIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
     const RegisterBank &SrcRB =
         SrcIsGPR ? AArch64::GPRRegBank : AArch64::FPRRegBank;
-    return InstructionMapping{DefaultMappingID, copyCost(DstRB, SrcRB, Size),
-                              AArch64::getCopyMapping(DstIsGPR, SrcIsGPR, Size),
-                              /*NumOperands*/ 2};
+    return InstructionMapping{
+        DefaultMappingID, copyCost(DstRB, SrcRB, Size),
+        AArch64::getCopyMapping(DstRB.getID(), SrcRB.getID(), Size),
+        /*NumOperands*/ 2};
   }
   default:
     break;
Index: lib/Target/AArch64/AArch64GenRegisterBankInfo.def
===================================================================
--- lib/Target/AArch64/AArch64GenRegisterBankInfo.def
+++ lib/Target/AArch64/AArch64GenRegisterBankInfo.def
@@ -140,16 +140,28 @@
   return &ValMappings[ValMappingIdx];
 }
 
+PartialMappingIdx BankIDToCopyMapIdx[] {
+  PMI_None, // CCR
+  PMI_FirstFPR, // FPR
+  PMI_FirstGPR, // GPR
+  PMI_None,
+};
+
 /// Get the pointer to the ValueMapping of the operands of a copy
 /// instruction from a GPR or FPR register to a GPR or FPR register
 /// with a size of \p Size.
 ///
 /// If \p DstIsGPR is true, the destination of the copy is on GPR,
 /// otherwise it is on FPR. Same thing for \p SrcIsGPR.
 const RegisterBankInfo::ValueMapping *
-getCopyMapping(bool DstIsGPR, bool SrcIsGPR, unsigned Size) {
-  PartialMappingIdx DstRBIdx = DstIsGPR ? PMI_FirstGPR : PMI_FirstFPR;
-  PartialMappingIdx SrcRBIdx = SrcIsGPR ? PMI_FirstGPR : PMI_FirstFPR;
+getCopyMapping(unsigned DstBankID, unsigned SrcBankID, unsigned Size) {
+  assert(DstBankID < NumRegisterBanks && "Invalid bank ID");
+  assert(SrcBankID < NumRegisterBanks && "Invalid bank ID");
+  PartialMappingIdx DstRBIdx = BankIDToCopyMapIdx[DstBankID];
+  PartialMappingIdx SrcRBIdx = BankIDToCopyMapIdx[SrcBankID];
+  assert(DstRBIdx != PMI_None && "No such mapping");
+  assert(SrcRBIdx != PMI_None && "No such mapping");
+
   if (DstRBIdx == SrcRBIdx)
     return getValueMapping(DstRBIdx, Size);
   assert(Size <= 64 && "GPR cannot handle that size");


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27339.80418.patch
Type: text/x-patch
Size: 4554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161206/63dc385e/attachment.bin>


More information about the llvm-commits mailing list