[llvm] [AMDGPU][MC] Allow UC_VERSION_* constant reuse (PR #96461)
Ivan Kosarev via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 2 03:57:35 PDT 2024
================
@@ -1755,18 +1755,25 @@ MCOperand AMDGPUDisassembler::decodeVersionImm(unsigned Imm) const {
if (Encoding::encode(Version, W64, W32, MDP) != Imm)
return MCOperand::createImm(Imm);
- const auto &Versions = AMDGPU::UCVersion::getGFXVersions();
- auto I = find_if(Versions,
- [Version = Version](const AMDGPU::UCVersion::GFXVersion &V) {
- return V.Code == Version;
- });
+ // Locate UC_VERSION symbol matching Version.
MCContext &Ctx = getContext();
- const MCExpr *E;
- if (I == Versions.end())
+ const MCExpr *E = nullptr;
+ for (auto *VersionSym : UCVersionSymbols) {
+ int64_t Val;
+ if (!VersionSym->evaluateAsAbsolute(Val))
----------------
kosarev wrote:
Doing `evaluateAsAbsolute()` here doesn't prevent the symbols from being redefined later, so looks an unnecessary complication.
A proper solution would involve supporting constant symbols. Until then it seems whatever we do, it won't help us where any of the symbols get redefined.
https://github.com/llvm/llvm-project/pull/96461
More information about the llvm-commits
mailing list