[llvm] [AMDGPU] Avoid referring to specific number of address spaces. NFC. (PR #137842)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 29 09:35:10 PDT 2025
https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/137842
This just avoids some hard coded numbers that would have to be updated
every time we add an address space.
>From 632b44dd2b53e17db7217306635678cfebe2d0ba Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Tue, 29 Apr 2025 17:33:20 +0100
Subject: [PATCH] [AMDGPU] Avoid referring to specific number of address
spaces. NFC.
This just avoids some hard coded numbers that would have to be updated
every time we add an address space.
---
llvm/lib/Target/AMDGPU/AMDGPU.h | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 4ff761ec19b3c..11f4240581b7b 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -540,14 +540,11 @@ enum TargetIndex {
};
static inline bool addrspacesMayAlias(unsigned AS1, unsigned AS2) {
- static_assert(AMDGPUAS::MAX_AMDGPU_ADDRESS <= 9, "Addr space out of range");
-
if (AS1 > AMDGPUAS::MAX_AMDGPU_ADDRESS || AS2 > AMDGPUAS::MAX_AMDGPU_ADDRESS)
return true;
- // This array is indexed by address space value enum elements 0 ... to 9
// clang-format off
- static const bool ASAliasRules[10][10] = {
+ static const bool ASAliasRules[][AMDGPUAS::MAX_AMDGPU_ADDRESS + 1] = {
/* Flat Global Region Local Constant Private Const32 BufFatPtr BufRsrc BufStrdPtr */
/* Flat */ {true, true, false, true, true, true, true, true, true, true},
/* Global */ {true, true, false, false, true, false, true, true, true, true},
@@ -561,6 +558,7 @@ static inline bool addrspacesMayAlias(unsigned AS1, unsigned AS2) {
/* Buffer Strided Ptr */ {true, true, false, false, true, false, true, true, true, true},
};
// clang-format on
+ static_assert(std::size(ASAliasRules) == AMDGPUAS::MAX_AMDGPU_ADDRESS + 1);
return ASAliasRules[AS1][AS2];
}
More information about the llvm-commits
mailing list