Index: lib/Target/AArch64/AArch64GenRegisterBankInfo.def =================================================================== --- lib/Target/AArch64/AArch64GenRegisterBankInfo.def +++ lib/Target/AArch64/AArch64GenRegisterBankInfo.def @@ -27,7 +27,7 @@ // PartialMappings. enum PartialMappingIdx { PMI_None = -1, - PMI_GPR32 = 0, + PMI_GPR32 = 1, PMI_GPR64, PMI_FPR32, PMI_FPR64, @@ -137,10 +137,11 @@ getValueMapping(PartialMappingIdx RBIdx, unsigned Size) { assert(RBIdx != PartialMappingIdx::PMI_None && "No mapping needed for that"); unsigned ValMappingIdx = First3OpsIdx + - (RBIdx + getRegBankBaseIdxOffset(Size)) * - ValueMappingIdx::DistanceBetweenRegBanks; - assert(ValMappingIdx >= AArch64::First3OpsIdx && - ValMappingIdx <= AArch64::Last3OpsIdx && "Mapping out of bound"); + (RBIdx - AArch64::PartialMappingIdx::PMI_Min + + getRegBankBaseIdxOffset(Size)) * + ValueMappingIdx::DistanceBetweenRegBanks; + assert(ValMappingIdx >= AArch64::First3OpsIdx && + ValMappingIdx <= AArch64::Last3OpsIdx && "Mapping out of bound"); return &ValMappings[ValMappingIdx]; } @@ -160,7 +161,7 @@ assert(Size <= 64 && "GPR cannot handle that size"); unsigned ValMappingIdx = FirstCrossRegCpyIdx + - (DstRBIdx - PMI_FirstGPR + getRegBankBaseIdxOffset(Size)) * + (DstRBIdx - PMI_Min + getRegBankBaseIdxOffset(Size)) * ValueMappingIdx::DistanceBetweenCrossRegCpy; assert(ValMappingIdx >= AArch64::FirstCrossRegCpyIdx && ValMappingIdx <= AArch64::LastCrossRegCpyIdx && Index: lib/Target/AArch64/AArch64RegisterBankInfo.cpp =================================================================== --- lib/Target/AArch64/AArch64RegisterBankInfo.cpp +++ lib/Target/AArch64/AArch64RegisterBankInfo.cpp @@ -115,8 +115,9 @@ #define CHECK_PARTIALMAP(Idx, ValStartIdx, ValLength, RB) \ do { \ const PartialMapping &Map = \ - AArch64::PartMappings[AArch64::PartialMappingIdx::Idx]; \ - (void) Map; \ + AArch64::PartMappings[AArch64::PartialMappingIdx::Idx - \ + AArch64::PartialMappingIdx::PMI_Min]; \ + (void)Map; \ assert(Map.StartIdx == ValStartIdx && Map.Length == ValLength && \ Map.RegBank == &RB && #Idx " is incorrectly initialized"); \ } while (0) @@ -132,12 +133,13 @@ // Check value mapping. #define CHECK_VALUEMAP_IMPL(RBName, Size, Offset) \ do { \ - AArch64::PartialMappingIdx PartialMapBaseIdx = \ - AArch64::PartialMappingIdx::PMI_##RBName##Size; \ - (void) PartialMapBaseIdx; \ - const ValueMapping &Map = \ - AArch64::getValueMapping(AArch64::PMI_First##RBName, Size)[Offset]; \ - (void) Map; \ + unsigned PartialMapBaseIdx = \ + AArch64::PartialMappingIdx::PMI_##RBName##Size - \ + AArch64::PartialMappingIdx::PMI_Min; \ + (void)PartialMapBaseIdx; \ + const ValueMapping &Map = AArch64::getValueMapping( \ + AArch64::PartialMappingIdx::PMI_First##RBName, Size)[Offset]; \ + (void)Map; \ assert(Map.BreakDown == &AArch64::PartMappings[PartialMapBaseIdx] && \ Map.NumBreakDowns == 1 && #RBName #Size \ " " #Offset " is incorrectly initialized"); \ @@ -172,10 +174,10 @@ #define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size) \ do { \ - AArch64::PartialMappingIdx PartialMapDstIdx = \ - AArch64::PartialMappingIdx::PMI_##RBNameDst##Size; \ - AArch64::PartialMappingIdx PartialMapSrcIdx = \ - AArch64::PartialMappingIdx::PMI_##RBNameSrc##Size; \ + unsigned PartialMapDstIdx = \ + AArch64::PMI_##RBNameDst##Size - AArch64::PMI_Min; \ + unsigned PartialMapSrcIdx = \ + AArch64::PMI_##RBNameSrc##Size - AArch64::PMI_Min; \ (void) PartialMapDstIdx; \ (void) PartialMapSrcIdx; \ const ValueMapping *Map = AArch64::getCopyMapping( \