[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
Thu Apr 16 10:49:17 PDT 2026


================
@@ -218,6 +222,30 @@ bool AMDGPUMCExpr::evaluateOccupancy(MCValue &Res,
   return true;
 }
 
+bool AMDGPUMCExpr::evaluateInstPrefSize(MCValue &Res,
+                                        const MCAssembler *Asm) const {
+  auto TryGetMCExprValue = [&](const MCExpr *Arg, uint64_t &ConstantValue) {
+    MCValue MCVal;
+    if (!Arg->evaluateAsRelocatable(MCVal, Asm) || !MCVal.isAbsolute())
+      return false;
+
+    ConstantValue = MCVal.getConstant();
+    return true;
+  };
+
+  assert(Args.size() == 2 &&
+         "AMDGPUMCExpr Argument count incorrect for InstPrefSize");
+  uint64_t CodeSizeInBytes = 0, FieldWidth = 0;
+  if (!TryGetMCExprValue(Args[0], CodeSizeInBytes) ||
+      !TryGetMCExprValue(Args[1], FieldWidth))
+    return false;
+
+  uint64_t CodeSizeInLines = divideCeil(CodeSizeInBytes, (uint64_t)128);
----------------
adelejjeh wrote:

I made a change that addresses this.

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


More information about the llvm-commits mailing list