Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit cef5592

Browse files
committed
[globalisel][aarch64] Fix unintended assumptions about PartialMappingIdx. NFC.
Summary: This is NFC but prevents assertions when PartialMappingIdx is tablegen-erated. The assumptions were: 1) FirstGPR is 0 2) FirstGPR is the first of the First* enumerators. GPR32 is changed to 1 to demonstrate that assumption #1 is fixed. #2 will be covered by a subsequent patch that tablegen-erates information and swaps the order of GPR and FPR as a side effect. Depends on D27336 Reviewers: ab, t.p.northover, qcolombet Subscribers: aemerson, rengolin, vkalintiris, dberris, rovka, llvm-commits Differential Revision: https://reviews.llvm.org/D27337 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288812 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 462ab86 commit cef5592

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

lib/Target/AArch64/AArch64GenRegisterBankInfo.def

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ RegisterBank *RegBanks[] = {&GPRRegBank, &FPRRegBank, &CCRRegBank};
2727
// PartialMappings.
2828
enum PartialMappingIdx {
2929
PMI_None = -1,
30-
PMI_GPR32 = 0,
30+
PMI_GPR32 = 1,
3131
PMI_GPR64,
3232
PMI_FPR32,
3333
PMI_FPR64,
@@ -137,10 +137,11 @@ const RegisterBankInfo::ValueMapping *
137137
getValueMapping(PartialMappingIdx RBIdx, unsigned Size) {
138138
assert(RBIdx != PartialMappingIdx::PMI_None && "No mapping needed for that");
139139
unsigned ValMappingIdx = First3OpsIdx +
140-
(RBIdx + getRegBankBaseIdxOffset(Size)) *
141-
ValueMappingIdx::DistanceBetweenRegBanks;
142-
assert(ValMappingIdx >= AArch64::First3OpsIdx &&
143-
ValMappingIdx <= AArch64::Last3OpsIdx && "Mapping out of bound");
140+
(RBIdx - AArch64::PartialMappingIdx::PMI_Min +
141+
getRegBankBaseIdxOffset(Size)) *
142+
ValueMappingIdx::DistanceBetweenRegBanks;
143+
assert(ValMappingIdx >= AArch64::First3OpsIdx &&
144+
ValMappingIdx <= AArch64::Last3OpsIdx && "Mapping out of bound");
144145

145146
return &ValMappings[ValMappingIdx];
146147
}
@@ -160,7 +161,7 @@ getCopyMapping(bool DstIsGPR, bool SrcIsGPR, unsigned Size) {
160161
assert(Size <= 64 && "GPR cannot handle that size");
161162
unsigned ValMappingIdx =
162163
FirstCrossRegCpyIdx +
163-
(DstRBIdx - PMI_FirstGPR + getRegBankBaseIdxOffset(Size)) *
164+
(DstRBIdx - PMI_Min + getRegBankBaseIdxOffset(Size)) *
164165
ValueMappingIdx::DistanceBetweenCrossRegCpy;
165166
assert(ValMappingIdx >= AArch64::FirstCrossRegCpyIdx &&
166167
ValMappingIdx <= AArch64::LastCrossRegCpyIdx &&

lib/Target/AArch64/AArch64RegisterBankInfo.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ AArch64RegisterBankInfo::AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
115115
#define CHECK_PARTIALMAP(Idx, ValStartIdx, ValLength, RB) \
116116
do { \
117117
const PartialMapping &Map = \
118-
AArch64::PartMappings[AArch64::PartialMappingIdx::Idx]; \
119-
(void) Map; \
118+
AArch64::PartMappings[AArch64::PartialMappingIdx::Idx - \
119+
AArch64::PartialMappingIdx::PMI_Min]; \
120+
(void)Map; \
120121
assert(Map.StartIdx == ValStartIdx && Map.Length == ValLength && \
121122
Map.RegBank == &RB && #Idx " is incorrectly initialized"); \
122123
} while (0)
@@ -132,12 +133,13 @@ AArch64RegisterBankInfo::AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
132133
// Check value mapping.
133134
#define CHECK_VALUEMAP_IMPL(RBName, Size, Offset) \
134135
do { \
135-
AArch64::PartialMappingIdx PartialMapBaseIdx = \
136-
AArch64::PartialMappingIdx::PMI_##RBName##Size; \
137-
(void) PartialMapBaseIdx; \
138-
const ValueMapping &Map = \
139-
AArch64::getValueMapping(AArch64::PMI_First##RBName, Size)[Offset]; \
140-
(void) Map; \
136+
unsigned PartialMapBaseIdx = \
137+
AArch64::PartialMappingIdx::PMI_##RBName##Size - \
138+
AArch64::PartialMappingIdx::PMI_Min; \
139+
(void)PartialMapBaseIdx; \
140+
const ValueMapping &Map = AArch64::getValueMapping( \
141+
AArch64::PartialMappingIdx::PMI_First##RBName, Size)[Offset]; \
142+
(void)Map; \
141143
assert(Map.BreakDown == &AArch64::PartMappings[PartialMapBaseIdx] && \
142144
Map.NumBreakDowns == 1 && #RBName #Size \
143145
" " #Offset " is incorrectly initialized"); \
@@ -172,10 +174,10 @@ AArch64RegisterBankInfo::AArch64RegisterBankInfo(const TargetRegisterInfo &TRI)
172174

173175
#define CHECK_VALUEMAP_CROSSREGCPY(RBNameDst, RBNameSrc, Size) \
174176
do { \
175-
AArch64::PartialMappingIdx PartialMapDstIdx = \
176-
AArch64::PartialMappingIdx::PMI_##RBNameDst##Size; \
177-
AArch64::PartialMappingIdx PartialMapSrcIdx = \
178-
AArch64::PartialMappingIdx::PMI_##RBNameSrc##Size; \
177+
unsigned PartialMapDstIdx = \
178+
AArch64::PMI_##RBNameDst##Size - AArch64::PMI_Min; \
179+
unsigned PartialMapSrcIdx = \
180+
AArch64::PMI_##RBNameSrc##Size - AArch64::PMI_Min; \
179181
(void) PartialMapDstIdx; \
180182
(void) PartialMapSrcIdx; \
181183
const ValueMapping *Map = AArch64::getCopyMapping( \

0 commit comments

Comments
 (0)