diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -342,12 +342,10 @@ // and results. // - attrGet corresponds to the name of the function to call to get value of // attribute (the generated function call returns an Attribute); -// - operandGet corresponds to the name of the function with which to retrieve -// an operand (the generaed function call returns an OperandRange); -// - reultGet corresponds to the name of the function to get an result (the -// generated function call returns a ValueRange); +// - operands and results are retrieve via their named accessor methods; normal +// and optional operands/results return an Operand/Value, and variadic ones +// return an OperandRange/ValueRange. static void populateSubstitutions(const Operator &op, const char *attrGet, - const char *operandGet, const char *resultGet, FmtContext &ctx) { // Populate substitutions for attributes and named operands. for (const auto &namedAttr : op.getAttributes()) @@ -358,10 +356,7 @@ if (value.name.empty()) continue; - if (value.isVariadic()) - ctx.addSubst(value.name, formatv("{0}({1})", operandGet, i)); - else - ctx.addSubst(value.name, formatv("(*{0}({1}).begin())", operandGet, i)); + ctx.addSubst(value.name, formatv("{0}()", value.name)); } // Populate substitutions for results. @@ -370,10 +365,7 @@ if (value.name.empty()) continue; - if (value.isVariadic()) - ctx.addSubst(value.name, formatv("{0}({1})", resultGet, i)); - else - ctx.addSubst(value.name, formatv("(*{0}({1}).begin())", resultGet, i)); + ctx.addSubst(value.name, formatv("{0}()", value.name)); } } @@ -1740,8 +1732,7 @@ auto *valueInit = def.getValueInit("verifier"); CodeInit *codeInit = dyn_cast(valueInit); bool hasCustomVerify = codeInit && !codeInit->getValue().empty(); - populateSubstitutions(op, "this->getAttr", "this->getODSOperands", - "this->getODSResults", verifyCtx); + populateSubstitutions(op, "this->getAttr", verifyCtx); genAttributeVerifier(op, "this->getAttr", "emitOpError(", /*emitVerificationRequiringOp=*/true, verifyCtx, body); @@ -2137,8 +2128,7 @@ } FmtContext verifyCtx; - populateSubstitutions(op, "odsAttrs.get", "getODSOperands", - "", verifyCtx); + populateSubstitutions(op, "odsAttrs.get", verifyCtx); genAttributeVerifier(op, "odsAttrs.get", Twine("emitError(loc, \"'") + op.getOperationName() + "' op \"",