From c32c8fd1437c69f90f48c91c7545a53d33d6ba20 Mon Sep 17 00:00:00 2001 From: River Riddle Date: Thu, 20 Feb 2020 20:08:33 -0800 Subject: [PATCH] [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. --- mlir/test/mlir-tblgen/op-attribute.td | 6 +++--- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) 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()) {