[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:52 PDT 2026
================
@@ -2502,6 +2502,68 @@ def LLVM_InlineAsmOp : LLVM_Op<"inline_asm", [DeclareOpInterfaceMethods<MemoryEf
let hasVerifier = 1;
}
+//===--------------------------------------------------------------------===//
+// MetadataAsValueOp
+//===--------------------------------------------------------------------===//
+
+def LLVM_MetadataAsValueOp : LLVM_Op<"mlir.metadata_as_value", [Pure]> {
+ let summary =
+ "Wraps an LLVM `metadata` constant so it can be used as an SSA value.";
+ let description = [{
+ Materializes an `!llvm.metadata` SSA value that mirrors LLVM IR's
+ `llvm::MetadataAsValue`: a wrapper that lifts an arbitrary
+ `llvm::Metadata` node into the value domain so it can be used as an
+ operand to instructions that take `metadata` arguments (for example the
+ constrained floating-point intrinsics or `llvm.read_register`).
+
+ The wrapped metadata is described by the `metadata` attribute, which
+ must be one of the LLVM dialect's metadata-attribute classes:
+
+ * `#llvm.md_string<"...">` — `llvm::MDString`.
+ * `#llvm.md_const<...>` — `llvm::ConstantAsMetadata`.
+ * `#llvm.md_func<@symbol>` — `llvm::ValueAsMetadata` of a function.
+ * `#llvm.md_node<...>` — `llvm::MDNode` over any of the above.
----------------
gysit wrote:
```suggestion
* `#llvm.md_string<"...">` -> `llvm::MDString`.
* `#llvm.md_const<...>` ->`llvm::ConstantAsMetadata`.
* `#llvm.md_func<@symbol>` -> `llvm::ValueAsMetadata` of a function.
* `#llvm.md_node<...>` -> `llvm::MDNode` over any of the above.
```
nit:
https://github.com/llvm/llvm-project/pull/200308
More information about the Mlir-commits
mailing list