[Mlir-commits] [mlir] 57b8b2c - Revert "[mlir][ods] Add query for derived attribute"

Stephan Herhut llvmlistbot at llvm.org
Tue Mar 3 01:24:18 PST 2020


Author: Stephan Herhut
Date: 2020-03-03T10:23:38+01:00
New Revision: 57b8b2cc50d0cd8d65728afb5fa7605ee2188843

URL: https://github.com/llvm/llvm-project/commit/57b8b2cc50d0cd8d65728afb5fa7605ee2188843
DIFF: https://github.com/llvm/llvm-project/commit/57b8b2cc50d0cd8d65728afb5fa7605ee2188843.diff

LOG: Revert "[mlir][ods] Add query for derived attribute"

This reverts commit 5aa57c28120127ee526ba702646f5e7239ef08f3.

The source code generated due to this ods change does not compile,
as it passes to few arguments to llvm::is_contained.

Added: 
    

Modified: 
    mlir/test/mlir-tblgen/op-attribute.td
    mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td
index 53f757bdcf9f..44c9a72340f3 100644
--- a/mlir/test/mlir-tblgen/op-attribute.td
+++ b/mlir/test/mlir-tblgen/op-attribute.td
@@ -201,17 +201,6 @@ def DOp : NS_Op<"d_op", []> {
 // DEF: odsState.addAttribute("str_attr", (*odsBuilder).getStringAttr(str_attr));
 // DEF: odsState.addAttribute("dv_str_attr", (*odsBuilder).getStringAttr(dv_str_attr));
 
-// Test derived type attr.
-// ---
-def DerivedTypeAttrOp : NS_Op<"derived_type_attr_op", []> {
-  let results = (outs AnyTensor:$output);
-  DerivedTypeAttr element_dtype = DerivedTypeAttr<"return output().getType();">;
-}
-
-// DECL: bool isDerivedAttribute
-// DEF: bool DerivedTypeAttrOp::isDerivedAttribute(StringRef name) {
-// DEF:  return llvm::is_contained(llvm::makeArrayRef<StringRef>({"element_dtype"}));
-// DEF: }
 
 // Test that only default valued attributes at the end of the arguments
 // list get default values in the builder signature

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index 66c8011c037f..f4d114aaab8f 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -391,27 +391,6 @@ void OpEmitter::genAttrGetters() {
       emitAttrWithReturnType(name, attr);
     }
   }
-
-  // Generate helper method to query whether a named attribute is a derived
-  // attribute. This enables, for example, avoiding adding an attribute that
-  // overlaps with a derived attribute.
-  auto &method =
-      opClass.newMethod("bool", "isDerivedAttribute", "StringRef name");
-  auto &body = method.body();
-  auto derivedAttr = make_filter_range(op.getAttributes(),
-                                       [](const NamedAttribute &namedAttr) {
-                                         return namedAttr.attr.isDerivedAttr();
-                                       });
-  if (derivedAttr.empty()) {
-    body << " return false;";
-  } else {
-    body << " return llvm::is_contained(llvm::makeArrayRef<StringRef>({";
-    mlir::interleaveComma(derivedAttr, body,
-                          [&](const NamedAttribute &namedAttr) {
-                            body << "\"" << namedAttr.name << "\"";
-                          });
-    body << "}));";
-  }
 }
 
 void OpEmitter::genAttrSetters() {


        


More information about the Mlir-commits mailing list