[llvm] [SPIR-V] Handle ASM with multiple outputs (PR #187128)

Steven Perron via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 24 10:49:43 PDT 2026


================
@@ -79,6 +79,32 @@ static FunctionType *extractFunctionTypeFromMetadata(NamedMDNode *NMD,
   return FunctionType::get(RetTy, PTys, FTy->isVarArg());
 }
 
+static StringRef extractAsmConstraintsFromMetadata(NamedMDNode *NMD,
+                                                   StringRef Constraints,
+                                                   StringRef Name) {
+  // TODO: unify the extractors.
+  if (!NMD)
+    return Constraints;
+
+  auto It = find_if(NMD->operands(), [Name](MDNode *N) {
+    if (auto *MDS = dyn_cast_or_null<MDString>(N->getOperand(0)))
+      return MDS->getString() == Name;
+    return false;
+  });
+
+  if (It == NMD->op_end())
+    return Constraints;
+
+  // By convention, the constraints string is stored in the final MD operand.
----------------
s-perron wrote:

What happens if the constraints empty? Is that not possible? Will the MDNode still exist?

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


More information about the llvm-commits mailing list