[Mlir-commits] [mlir] [MLIR][LLVMIR] Add support for intrinsics with metadata arguments (PR #200308)

Tobias Gysi llvmlistbot at llvm.org
Fri May 29 00:42:55 PDT 2026


================
@@ -1980,10 +2016,29 @@ LogicalResult ModuleImport::convertIntrinsicArguments(
     value = nullptr;
   }
 
+  // Convert a single intrinsic operand into an MLIR value.
+  // `llvm::MetadataAsValue` operands (e.g. the rounding-mode / FP-exception
+  // MDString arguments used by the constrained floating-point intrinsics, or
+  // the named-register MDNode used by `llvm.read_register`) are lifted into a
+  // `llvm.mlir.metadata_as_value` SSA op carrying the corresponding metadata
+  // attribute. All other operands go through the standard `convertValue` path,
+  // which rejects metadata values.
+  auto convertOperand = [&](llvm::Value *value) -> FailureOr<Value> {
+    if (auto *mdAsVal = dyn_cast<llvm::MetadataAsValue>(value)) {
----------------
gysit wrote:

Could we move this logic into the `convertValue` function where we currently assert?

https://github.com/llvm/llvm-project/blob/01c93f511b4b5f734ac420709266036497610014/mlir/lib/Target/LLVMIR/ModuleImport.cpp#L1907

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


More information about the Mlir-commits mailing list