-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[AMDGPU] Avoid referring to specific number of address spaces. NFC. #137842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This just avoids some hard coded numbers that would have to be updated every time we add an address space.
|
@llvm/pr-subscribers-backend-amdgpu Author: Jay Foad (jayfoad) ChangesThis just avoids some hard coded numbers that would have to be updated Full diff: https://github.com/llvm/llvm-project/pull/137842.diff 1 Files Affected:
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];
}
|
You can test this locally with the following command:git-clang-format --diff HEAD~1 HEAD --extensions h -- llvm/lib/Target/AMDGPU/AMDGPU.hView the diff from clang-format here.diff --git a/llvm/lib/Target/AMDGPU/AMDGPU.h b/llvm/lib/Target/AMDGPU/AMDGPU.h
index 11f424058..9526faf4f 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.h
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.h
@@ -562,7 +562,6 @@ static inline bool addrspacesMayAlias(unsigned AS1, unsigned AS2) {
return ASAliasRules[AS1][AS2];
}
-
}
} // End namespace llvm
|
| // 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] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: constexpr const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separate change
…lvm#137842) This just avoids some hard coded numbers that would have to be updated every time we add an address space.
…lvm#137842) This just avoids some hard coded numbers that would have to be updated every time we add an address space.
This just avoids some hard coded numbers that would have to be updated
every time we add an address space.