[Mlir-commits] [mlir] c32c8fd - [mlir] Use getOperation()->setAttr when generating attribute set

River Riddle llvmlistbot at llvm.org
Thu Feb 20 20:10:38 PST 2020


Author: River Riddle
Date: 2020-02-20T20:08:33-08:00
New Revision: c32c8fd1437c69f90f48c91c7545a53d33d6ba20

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

LOG: [mlir] Use getOperation()->setAttr when generating attribute set
methods.

This avoids the need to resolve overloads when the current operation
also defines a 'setAttr' method.

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 390725cc7c2a..31ccf59bd12d 100644
--- a/mlir/test/mlir-tblgen/op-attribute.td
+++ b/mlir/test/mlir-tblgen/op-attribute.td
@@ -57,11 +57,11 @@ def AOp : NS_Op<"a_op", []> {
 // ---
 
 // DEF:      void AOp::aAttrAttr(some-attr-kind attr) {
-// DEF-NEXT:   this->setAttr("aAttr", attr);
+// DEF-NEXT:   this->getOperation()->setAttr("aAttr", attr);
 // DEF:      void AOp::bAttrAttr(some-attr-kind attr) {
-// DEF-NEXT:   this->setAttr("bAttr", attr);
+// DEF-NEXT:   this->getOperation()->setAttr("bAttr", attr);
 // DEF:      void AOp::cAttrAttr(some-attr-kind attr) {
-// DEF-NEXT:   this->setAttr("cAttr", attr);
+// DEF-NEXT:   this->getOperation()->setAttr("cAttr", attr);
 
 // Test build methods
 // ---

diff  --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
index a5962957be77..2d6999275e9a 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -393,7 +393,7 @@ void OpEmitter::genAttrSetters() {
     auto &method = opClass.newMethod("void", (name + "Attr").str(),
                                      (attr.getStorageType() + " attr").str());
     auto &body = method.body();
-    body << "  this->setAttr(\"" << name << "\", attr);";
+    body << "  this->getOperation()->setAttr(\"" << name << "\", attr);";
   };
 
   for (auto &namedAttr : op.getAttributes()) {


        


More information about the Mlir-commits mailing list