[mlir] Use getOperation()->setAttr when generating attribute set
authorRiver Riddle <riddleriver@gmail.com>
Fri, 21 Feb 2020 04:08:33 +0000 (20:08 -0800)
committerRiver Riddle <riddleriver@gmail.com>
Fri, 21 Feb 2020 04:08:33 +0000 (20:08 -0800)
methods.

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

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

index 390725cc7c2a597b13348031f41c9f82227f0ed2..31ccf59bd12de91a1241cf3cdc7f54990371d4a8 100644 (file)
@@ -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
 // ---
index a5962957be778ef61f94166d503d5968ed56c2d8..2d6999275e9a12124216803649ed8815c667df8e 100644 (file)
@@ -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()) {