[Mlir-commits] [mlir] aa33561 - Fix ODS verifier emission for DerivedAttr when Properties are enabled
Mehdi Amini
llvmlistbot at llvm.org
Wed Aug 23 17:52:32 PDT 2023
Author: Mehdi Amini
Date: 2023-08-23T17:51:54-07:00
New Revision: aa33561a61225687518d43b5c371f0d2e4cdaeaf
URL: https://github.com/llvm/llvm-project/commit/aa33561a61225687518d43b5c371f0d2e4cdaeaf
DIFF: https://github.com/llvm/llvm-project/commit/aa33561a61225687518d43b5c371f0d2e4cdaeaf.diff
LOG: Fix ODS verifier emission for DerivedAttr when Properties are enabled
Differential Revision: https://reviews.llvm.org/D158679
Added:
Modified:
mlir/test/lib/Dialect/Test/TestOps.td
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
Removed:
################################################################################
diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td
index 11bcb8b0bae84c..bb48278ee6b8b3 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -264,6 +264,16 @@ def DerivedTypeAttrOp : TEST_Op<"derived_type_attr", []> {
"$_builder.getI32IntegerAttr($_self)">;
}
+def TestPropOp : TEST_Op<"prop">,
+ Arguments<(ins Variadic<Index>:$upperInits,
+ I32ElementsAttr:$transforms)>,
+ Results<(outs Variadic<AnyType>:$results)> {
+ DerivedAttr upperLen = DerivedAttr<"uint32_t", [{
+ return getUpperInits().size() / getTransforms().size();
+ }], [{ $_builder.getI32IntegerAttr($_self) }]>;
+}
+
+
def StringElementsAttrOp : TEST_Op<"string_elements_attr"> {
let arguments = (ins
StringElementsAttr:$scalar_string_attr
diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index d1de86f2216282..836f73e49b49f3 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -875,10 +875,12 @@ while (true) {{
if (useProperties) {
for (const std::pair<StringRef, AttributeMetadata> &it :
emitHelper.getAttrMetadata()) {
+ const AttributeMetadata &metadata = it.second;
+ if (metadata.constraint && metadata.constraint->isDerivedAttr())
+ continue;
body << formatv(
"auto tblgen_{0} = getProperties().{0}; (void)tblgen_{0};\n",
it.first);
- const AttributeMetadata &metadata = it.second;
if (metadata.isRequired)
body << formatv(
"if (!tblgen_{0}) return {1}\"requires attribute '{0}'\");\n",
More information about the Mlir-commits
mailing list