[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.
This commit is contained in:
River Riddle 2020-02-20 20:08:33 -08:00
parent 4b540fa8a1
commit c32c8fd143
2 changed files with 4 additions and 4 deletions

View 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
// ---

View 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()) {