[llvm-branch-commits] [mlir] 5e47fe1 - Fix ODS verifier emission for DerivedAttr when Properties are enabled
Tobias Hieta via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Aug 25 00:43:26 PDT 2023
Author: Mehdi Amini
Date: 2023-08-25T09:42:01+02:00
New Revision: 5e47fe1945952aa7719f1a139cdabd7b37cf6511
URL: https://github.com/llvm/llvm-project/commit/5e47fe1945952aa7719f1a139cdabd7b37cf6511
DIFF: https://github.com/llvm/llvm-project/commit/5e47fe1945952aa7719f1a139cdabd7b37cf6511.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 4eb19e6dd6fe27..12a02cf72d2b34 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 4e07bc3d482721..a3b9c71048422e 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -868,10 +868,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 llvm-branch-commits
mailing list