[llvm] [AMDGPU] Account for inline asm size in inst_pref_size calculation (PR #192306)

Adel Ejjeh via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 27 07:10:06 PDT 2026


================
@@ -190,6 +197,33 @@ bool AMDGPUMCExpr::evaluateOccupancy(MCValue &Res,
   return true;
 }
 
+/// Get the inst_pref_size field width for the given subtarget.
+static unsigned getInstPrefSizeFieldWidth(const MCSubtargetInfo *STI) {
+  auto Version = getIsaVersion(STI->getCPU());
+  assert(Version.Major >= 11 && "inst_pref_size only exists on GFX11+");
+  if (Version.Major == 11)
+    return amdhsa::COMPUTE_PGM_RSRC3_GFX11_INST_PREF_SIZE_WIDTH;
+  return amdhsa::COMPUTE_PGM_RSRC3_GFX12_PLUS_INST_PREF_SIZE_WIDTH;
+}
+
+bool AMDGPUMCExpr::evaluateInstPrefSize(MCValue &Res,
+                                        const MCAssembler *Asm) const {
+  assert(Args.size() == 1 &&
+         "AMDGPUMCExpr Argument count incorrect for InstPrefSize");
----------------
adelejjeh wrote:

zip_equals is already checking that the sizes are equal between Args and Asm inside evaluateMCExprs. This is an extra assertion to check the number of arguments as is the case in all the other evaluateX() functins. Would you suggest we remove all these assertion checks?

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


More information about the llvm-commits mailing list