[Mlir-commits] [mlir] [MLIR][LLVMIR] Add support for intrinsics with metadata arguments (PR #200308)
Tobias Gysi
llvmlistbot at llvm.org
Thu Jun 4 07:44:08 PDT 2026
================
@@ -1904,14 +1970,29 @@ FailureOr<Value> ModuleImport::convertConstantExpr(llvm::Constant *constant) {
}
FailureOr<Value> ModuleImport::convertValue(llvm::Value *value) {
- assert(!isa<llvm::MetadataAsValue>(value) &&
- "expected value to not be metadata");
-
// Return the mapped value if it has been converted before.
auto it = valueMapping.find(value);
if (it != valueMapping.end())
return it->getSecond();
+ // `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.
+ if (auto *mdAsVal = dyn_cast<llvm::MetadataAsValue>(value)) {
+ llvm::Metadata *md = mdAsVal->getMetadata();
+ Attribute mdAttr = convertMetadataToAttr(context, md);
+ if (!mdAttr)
+ return emitError(mlirModule.getLoc())
+ << "unsupported metadata: " << diagMD(md, llvmModule.get());
+ auto op =
----------------
gysit wrote:
```suggestion
Value result =
```
ultra nit:
https://github.com/llvm/llvm-project/pull/200308
More information about the Mlir-commits
mailing list