[Mlir-commits] [mlir] [mlir][TblGen] `get...Mutable` returns `OpOperand &` for single operands (PR #66519)
Matthias Springer
llvmlistbot at llvm.org
Sun Sep 17 00:45:05 PDT 2023
================
@@ -2071,29 +2071,36 @@ void OpEmitter::genNamedOperandSetters() {
continue;
std::string name = op.getGetterName(operand.name);
- auto *m = opClass.addMethod(operand.isVariadicOfVariadic()
- ? "::mlir::MutableOperandRangeRange"
- : "::mlir::MutableOperandRange",
- name + "Mutable");
+ StringRef returnType;
+ if (operand.isVariadicOfVariadic()) {
+ returnType = "::mlir::MutableOperandRangeRange";
+ } else if (operand.isVariableLength()) {
+ returnType = "::mlir::MutableOperandRange";
+ } else {
+ returnType = "::mlir::OpOperand &";
+ }
+ auto *m = opClass.addMethod(returnType, name + "Mutable");
ERROR_IF_PRUNED(m, name, op);
auto &body = m->body();
- body << " auto range = getODSOperandIndexAndLength(" << i << ");\n"
- << " auto mutableRange = "
- "::mlir::MutableOperandRange(getOperation(), "
- "range.first, range.second";
- if (attrSizedOperands) {
- if (emitHelper.hasProperties())
- body << formatv(", ::mlir::MutableOperandRange::OperandSegment({0}u, "
- "{{getOperandSegmentSizesAttrName(), "
- "::mlir::DenseI32ArrayAttr::get(getContext(), "
- "getProperties().operandSegmentSizes)})",
- i);
- else
- body << formatv(
- ", ::mlir::MutableOperandRange::OperandSegment({0}u, *{1})", i,
- emitHelper.getAttr(operandSegmentAttrName, /*isNamed=*/true));
+ body << " auto range = getODSOperandIndexAndLength(" << i << ");\n";
+ if (operand.isVariadicOfVariadic() || operand.isVariableLength()) {
----------------
matthias-springer wrote:
The code inside of the "then" branch is identical to what the original code was coding. So there is no difference in functionality for "variadic of variadic" (or variable-length operands).
https://github.com/llvm/llvm-project/pull/66519
More information about the Mlir-commits
mailing list