[llvm] [AMDGPU][MC] Allow UC_VERSION_* constant reuse (PR #96461)

Ivan Kosarev via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 2 02:38:57 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) {
----------------
kosarev wrote:

There's no need for `UCVersionSymbols`. We already have `getGFXVersions()` that provides the names, and can obtain the symbols from them with `getOrCreateSymbol()`.

https://github.com/llvm/llvm-project/pull/96461


More information about the llvm-commits mailing list