Skip to content

Commit 6a16da7

Browse files
authored
[AMDGPU] Avoid referring to specific number of address spaces. NFC. (#137842)
This just avoids some hard coded numbers that would have to be updated every time we add an address space.
1 parent 74593f6 commit 6a16da7

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

llvm/lib/Target/AMDGPU/AMDGPU.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -540,14 +540,11 @@ enum TargetIndex {
540540
};
541541

542542
static inline bool addrspacesMayAlias(unsigned AS1, unsigned AS2) {
543-
static_assert(AMDGPUAS::MAX_AMDGPU_ADDRESS <= 9, "Addr space out of range");
544-
545543
if (AS1 > AMDGPUAS::MAX_AMDGPU_ADDRESS || AS2 > AMDGPUAS::MAX_AMDGPU_ADDRESS)
546544
return true;
547545

548-
// This array is indexed by address space value enum elements 0 ... to 9
549546
// clang-format off
550-
static const bool ASAliasRules[10][10] = {
547+
static const bool ASAliasRules[][AMDGPUAS::MAX_AMDGPU_ADDRESS + 1] = {
551548
/* Flat Global Region Local Constant Private Const32 BufFatPtr BufRsrc BufStrdPtr */
552549
/* Flat */ {true, true, false, true, true, true, true, true, true, true},
553550
/* Global */ {true, true, false, false, true, false, true, true, true, true},
@@ -561,6 +558,7 @@ static inline bool addrspacesMayAlias(unsigned AS1, unsigned AS2) {
561558
/* Buffer Strided Ptr */ {true, true, false, false, true, false, true, true, true, true},
562559
};
563560
// clang-format on
561+
static_assert(std::size(ASAliasRules) == AMDGPUAS::MAX_AMDGPU_ADDRESS + 1);
564562

565563
return ASAliasRules[AS1][AS2];
566564
}

0 commit comments

Comments
 (0)