diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td --- a/flang/include/flang/Optimizer/Dialect/FIROps.td +++ b/flang/include/flang/Optimizer/Dialect/FIROps.td @@ -250,7 +250,7 @@ p << ", "; p.printOperand(sh); } - p.printOptionalAttrDict(getAttrs(), {inType(), lenpName()}); + p.printOptionalAttrDict((*this)->getAttrs(), {inType(), lenpName()}); }]; string extraAllocClassDeclaration = [{ @@ -431,7 +431,7 @@ let printer = [{ p << getOperationName() << ' '; p.printOperand(memref()); - p.printOptionalAttrDict(getAttrs(), {}); + p.printOptionalAttrDict((*this)->getAttrs(), {}); p << " : " << memref().getType(); }]; @@ -483,7 +483,7 @@ p.printOperand(value()); p << " to "; p.printOperand(memref()); - p.printOptionalAttrDict(getAttrs(), {}); + p.printOptionalAttrDict((*this)->getAttrs(), {}); p << " : " << memref().getType(); }]; diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -121,7 +121,7 @@ /// strings, attributes, operands, types, etc. static void print(mlir::OpAsmPrinter &printer, ConstantOp op) { printer << "toy.constant "; - printer.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{"value"}); + printer.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/{"value"}); printer << op.value(); } diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -190,7 +190,7 @@ /// strings, attributes, operands, types, etc. static void print(mlir::OpAsmPrinter &printer, ConstantOp op) { printer << "toy.constant "; - printer.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{"value"}); + printer.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/{"value"}); printer << op.value(); } diff --git a/mlir/include/mlir/IR/OpDefinition.h b/mlir/include/mlir/IR/OpDefinition.h --- a/mlir/include/mlir/IR/OpDefinition.h +++ b/mlir/include/mlir/IR/OpDefinition.h @@ -124,7 +124,11 @@ void setLoc(Location loc) { state->setLoc(loc); } /// Return all of the attributes on this operation. - ArrayRef getAttrs() { return state->getAttrs(); } + LLVM_ATTRIBUTE_DEPRECATED( + ArrayRef getAttrs(), + "Use Operation::getAttrs() instead (replace '.' with '->').") { + return state->getAttrs(); + } /// A utility iterator that filters out non-dialect attributes. using dialect_attr_iterator = Operation::dialect_attr_iterator; diff --git a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/SPIRVToLLVM.cpp @@ -420,7 +420,7 @@ return success(); } rewriter.replaceOpWithNewOp(constOp, dstType, operands, - constOp.getAttrs()); + constOp->getAttrs()); return success(); } }; @@ -625,7 +625,7 @@ if (!dstType) return failure(); rewriter.template replaceOpWithNewOp(operation, dstType, operands, - operation.getAttrs()); + operation->getAttrs()); return success(); } }; @@ -799,14 +799,14 @@ ConversionPatternRewriter &rewriter) const override { if (callOp.getNumResults() == 0) { rewriter.replaceOpWithNewOp(callOp, llvm::None, operands, - callOp.getAttrs()); + callOp->getAttrs()); return success(); } // Function returns a single result. auto dstType = typeConverter.convertType(callOp.getType(0)); rewriter.replaceOpWithNewOp(callOp, dstType, operands, - callOp.getAttrs()); + callOp->getAttrs()); return success(); } }; diff --git a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp --- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp +++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp @@ -506,7 +506,7 @@ p << AffineApplyOp::getOperationName() << " " << op.mapAttr(); printDimAndSymbolList(op.operand_begin(), op.operand_end(), op.getAffineMap().getNumDims(), p); - p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{"map"}); + p.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/{"map"}); } static LogicalResult verify(AffineApplyOp op) { @@ -1516,7 +1516,7 @@ p.printRegion(op.region(), /*printEntryBlockArgs=*/false, printBlockTerminators); - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/{op.getLowerBoundAttrName(), op.getUpperBoundAttrName(), op.getStepAttrName()}); @@ -1969,7 +1969,7 @@ } // Print the attribute list. - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/op.getConditionAttrName()); } @@ -2100,7 +2100,8 @@ op->getAttrOfType(op.getMapAttrName())) p.printAffineMapOfSSAIds(mapAttr, op.getMapOperands()); p << ']'; - p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{op.getMapAttrName()}); + p.printOptionalAttrDict(op->getAttrs(), + /*elidedAttrs=*/{op.getMapAttrName()}); p << " : " << op.getMemRefType(); } @@ -2216,7 +2217,8 @@ op->getAttrOfType(op.getMapAttrName())) p.printAffineMapOfSSAIds(mapAttr, op.getMapOperands()); p << ']'; - p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{op.getMapAttrName()}); + p.printOptionalAttrDict(op->getAttrs(), + /*elidedAttrs=*/{op.getMapAttrName()}); p << " : " << op.getMemRefType(); } @@ -2268,7 +2270,7 @@ if (operands.size() != numDims) p << '[' << operands.drop_front(numDims) << ']'; - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/{T::getMapAttrName()}); } @@ -2422,7 +2424,7 @@ << "locality<" << op.localityHint() << ">, " << (op.isDataCache() ? "data" : "instr"); p.printOptionalAttrDict( - op.getAttrs(), + op->getAttrs(), /*elidedAttrs=*/{op.getMapAttrName(), op.getLocalityHintAttrName(), op.getIsDataCacheAttrName(), op.getIsWriteAttrName()}); p << " : " << op.getMemRefType(); @@ -2738,7 +2740,7 @@ p.printRegion(op.region(), /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/op.getNumResults()); p.printOptionalAttrDict( - op.getAttrs(), + op->getAttrs(), /*elidedAttrs=*/{AffineParallelOp::getReductionsAttrName(), AffineParallelOp::getLowerBoundsMapAttrName(), AffineParallelOp::getUpperBoundsMapAttrName(), @@ -2938,7 +2940,8 @@ op->getAttrOfType(op.getMapAttrName())) p.printAffineMapOfSSAIds(mapAttr, op.getMapOperands()); p << ']'; - p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{op.getMapAttrName()}); + p.printOptionalAttrDict(op->getAttrs(), + /*elidedAttrs=*/{op.getMapAttrName()}); p << " : " << op.getMemRefType() << ", " << op.getType(); } @@ -3026,7 +3029,8 @@ op->getAttrOfType(op.getMapAttrName())) p.printAffineMapOfSSAIds(mapAttr, op.getMapOperands()); p << ']'; - p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{op.getMapAttrName()}); + p.printOptionalAttrDict(op->getAttrs(), + /*elidedAttrs=*/{op.getMapAttrName()}); p << " : " << op.getMemRefType() << ", " << op.getValueToStore().getType(); } diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp --- a/mlir/lib/Dialect/Async/IR/Async.cpp +++ b/mlir/lib/Dialect/Async/IR/Async.cpp @@ -135,7 +135,8 @@ // -> (!async.value, ...) p.printOptionalArrowTypeList(op.getResultTypes().drop_front(1)); - p.printOptionalAttrDictWithKeyword(op.getAttrs(), {kOperandSegmentSizesAttr}); + p.printOptionalAttrDictWithKeyword(op->getAttrs(), + {kOperandSegmentSizesAttr}); p.printRegion(op.body(), /*printEntryBlockArgs=*/false); } diff --git a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp --- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp +++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp @@ -344,7 +344,7 @@ op.getThreadIds()); p.printRegion(op.body(), /*printEntryBlockArgs=*/false); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); } // Parse the size assignment blocks for blocks and threads. These have the form @@ -837,7 +837,7 @@ static void print(OpAsmPrinter &p, GPUModuleOp op) { p << op.getOperationName() << ' '; p.printSymbolName(op.getName()); - p.printOptionalAttrDictWithKeyword(op.getAttrs(), + p.printOptionalAttrDictWithKeyword(op->getAttrs(), {SymbolTable::getSymbolAttrName()}); p.printRegion(op->getRegion(0), /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/false); diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -88,14 +88,14 @@ static void printICmpOp(OpAsmPrinter &p, ICmpOp &op) { p << op.getOperationName() << " \"" << stringifyICmpPredicate(op.predicate()) << "\" " << op.getOperand(0) << ", " << op.getOperand(1); - p.printOptionalAttrDict(op.getAttrs(), {"predicate"}); + p.printOptionalAttrDict(op->getAttrs(), {"predicate"}); p << " : " << op.lhs().getType(); } static void printFCmpOp(OpAsmPrinter &p, FCmpOp &op) { p << op.getOperationName() << " \"" << stringifyFCmpPredicate(op.predicate()) << "\" " << op.getOperand(0) << ", " << op.getOperand(1); - p.printOptionalAttrDict(processFMFAttr(op.getAttrs()), {"predicate"}); + p.printOptionalAttrDict(processFMFAttr(op->getAttrs()), {"predicate"}); p << " : " << op.lhs().getType(); } @@ -172,9 +172,9 @@ p << op.getOperationName() << ' ' << op.arraySize() << " x " << elemTy; if (op.alignment().hasValue() && *op.alignment() != 0) - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); else - p.printOptionalAttrDict(op.getAttrs(), {"alignment"}); + p.printOptionalAttrDict(op->getAttrs(), {"alignment"}); p << " : " << funcTy; } @@ -402,7 +402,7 @@ if (op.volatile_()) p << "volatile "; p << op.addr(); - p.printOptionalAttrDict(op.getAttrs(), {kVolatileAttrName}); + p.printOptionalAttrDict(op->getAttrs(), {kVolatileAttrName}); p << " : " << op.addr().getType(); } @@ -460,7 +460,7 @@ if (op.volatile_()) p << "volatile "; p << op.value() << ", " << op.addr(); - p.printOptionalAttrDict(op.getAttrs(), {kVolatileAttrName}); + p.printOptionalAttrDict(op->getAttrs(), {kVolatileAttrName}); p << " : " << op.addr().getType(); } @@ -536,7 +536,7 @@ p << " unwind "; p.printSuccessorAndUseList(op.unwindDest(), op.unwindDestOperands()); - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), {InvokeOp::getOperandSegmentSizeAttr(), "callee"}); p << " : "; p.printFunctionalType( @@ -694,7 +694,7 @@ << value.getType() << ") "; } - p.printOptionalAttrDict(op.getAttrs(), {"cleanup"}); + p.printOptionalAttrDict(op->getAttrs(), {"cleanup"}); p << ": " << op.getType(); } @@ -816,7 +816,7 @@ auto args = op.getOperands().drop_front(isDirect ? 0 : 1); p << '(' << args << ')'; - p.printOptionalAttrDict(processFMFAttr(op.getAttrs()), {"callee"}); + p.printOptionalAttrDict(processFMFAttr(op->getAttrs()), {"callee"}); // Reconstruct the function MLIR function type from operand and result types. p << " : " @@ -922,7 +922,7 @@ static void printExtractElementOp(OpAsmPrinter &p, ExtractElementOp &op) { p << op.getOperationName() << ' ' << op.vector() << "[" << op.position() << " : " << op.position().getType() << "]"; - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); p << " : " << op.vector().getType(); } @@ -954,7 +954,7 @@ static void printExtractValueOp(OpAsmPrinter &p, ExtractValueOp &op) { p << op.getOperationName() << ' ' << op.container() << op.position(); - p.printOptionalAttrDict(op.getAttrs(), {"position"}); + p.printOptionalAttrDict(op->getAttrs(), {"position"}); p << " : " << op.container().getType(); } @@ -1037,7 +1037,7 @@ static void printInsertElementOp(OpAsmPrinter &p, InsertElementOp &op) { p << op.getOperationName() << ' ' << op.value() << ", " << op.vector() << "[" << op.position() << " : " << op.position().getType() << "]"; - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); p << " : " << op.vector().getType(); } @@ -1079,7 +1079,7 @@ static void printInsertValueOp(OpAsmPrinter &p, InsertValueOp &op) { p << op.getOperationName() << ' ' << op.value() << ", " << op.container() << op.position(); - p.printOptionalAttrDict(op.getAttrs(), {"position"}); + p.printOptionalAttrDict(op->getAttrs(), {"position"}); p << " : " << op.container().getType(); } @@ -1121,7 +1121,7 @@ static void printReturnOp(OpAsmPrinter &p, ReturnOp op) { p << op.getOperationName(); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); assert(op.getNumOperands() <= 1); if (op.getNumOperands() == 0) @@ -1258,7 +1258,7 @@ if (auto value = op.getValueOrNull()) p.printAttribute(value); p << ')'; - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), {SymbolTable::getSymbolAttrName(), "type", "constant", "value", getLinkageAttrName()}); @@ -1641,7 +1641,7 @@ static void printShuffleVectorOp(OpAsmPrinter &p, ShuffleVectorOp &op) { p << op.getOperationName() << ' ' << op.v1() << ", " << op.v2() << " " << op.mask(); - p.printOptionalAttrDict(op.getAttrs(), {"mask"}); + p.printOptionalAttrDict(op->getAttrs(), {"mask"}); p << " : " << op.v1().getType() << ", " << op.v2().getType(); } @@ -1983,7 +1983,7 @@ p << op.getOperationName() << ' ' << stringifyAtomicBinOp(op.bin_op()) << ' ' << op.ptr() << ", " << op.val() << ' ' << stringifyAtomicOrdering(op.ordering()) << ' '; - p.printOptionalAttrDict(op.getAttrs(), {"bin_op", "ordering"}); + p.printOptionalAttrDict(op->getAttrs(), {"bin_op", "ordering"}); p << " : " << op.res().getType(); } @@ -2054,7 +2054,7 @@ p << op.getOperationName() << ' ' << op.ptr() << ", " << op.cmp() << ", " << op.val() << ' ' << stringifyAtomicOrdering(op.success_ordering()) << ' ' << stringifyAtomicOrdering(op.failure_ordering()); - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), {"success_ordering", "failure_ordering"}); p << " : " << op.val().getType(); } diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -457,7 +457,7 @@ llvm::StringSet<> genericAttrNamesSet; genericAttrNamesSet.insert(genericAttrNames.begin(), genericAttrNames.end()); SmallVector genericAttrs; - for (auto attr : op.getAttrs()) + for (auto attr : op->getAttrs()) if (genericAttrNamesSet.count(attr.first.strref()) > 0) genericAttrs.push_back(attr); if (!genericAttrs.empty()) { @@ -472,13 +472,13 @@ genericAttrNamesSet.insert(genericAttrNames.back()); bool hasExtraAttrs = false; - for (NamedAttribute n : op.getAttrs()) { + for (NamedAttribute n : op->getAttrs()) { if ((hasExtraAttrs = !genericAttrNamesSet.contains(n.first.strref()))) break; } if (hasExtraAttrs) { p << " attrs = "; - p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/genericAttrNames); + p.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/genericAttrNames); } // Print region. @@ -1635,7 +1635,7 @@ p << op.getOperationName(); if (op.getNumOperands() > 0) p << ' ' << op.getOperands(); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); if (op.getNumOperands() > 0) p << " : " << op.getOperandTypes(); } @@ -1754,8 +1754,8 @@ p.printRegion(op.region(), /*printEntryBlockArgs=*/false); p.printOptionalAttrDict( - op.getAttrs(), /*elidedAttrs=*/{TiledLoopOp::getOperandSegmentSizeAttr(), - getIteratorTypesAttrName()}); + op->getAttrs(), /*elidedAttrs=*/{TiledLoopOp::getOperandSegmentSizeAttr(), + getIteratorTypesAttrName()}); } static ParseResult parseTiledLoopOp(OpAsmParser &parser, @@ -2294,7 +2294,7 @@ template static void printNamedStructuredOp(OpAsmPrinter &p, NamedStructuredOpType op) { p << op.getOperationName(); - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/{"operand_segment_sizes"}); // Printing is shared with generic ops, except for the region and diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -445,7 +445,7 @@ /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/true); printer.printOptionalAttrDictWithKeyword( - op.getAttrs(), ParallelOp::getOperandSegmentSizeAttr()); + op->getAttrs(), ParallelOp::getOperandSegmentSizeAttr()); } //===----------------------------------------------------------------------===// @@ -608,8 +608,8 @@ /*printBlockTerminators=*/true); printer.printOptionalAttrDictWithKeyword( - op.getAttrs(), {LoopOp::getExecutionMappingAttrName(), - LoopOp::getOperandSegmentSizeAttr()}); + op->getAttrs(), {LoopOp::getExecutionMappingAttrName(), + LoopOp::getOperandSegmentSizeAttr()}); } static LogicalResult verifyLoopOp(acc::LoopOp loopOp) { diff --git a/mlir/lib/Dialect/PDL/IR/PDL.cpp b/mlir/lib/Dialect/PDL/IR/PDL.cpp --- a/mlir/lib/Dialect/PDL/IR/PDL.cpp +++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp @@ -183,7 +183,7 @@ // Print the result type constraints of the operation. if (!op.results().empty()) p << " -> " << op.types(); - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), {"attributeNames", "name", "operand_segment_sizes"}); } diff --git a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp --- a/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp +++ b/mlir/lib/Dialect/PDLInterp/IR/PDLInterp.cpp @@ -92,7 +92,7 @@ static void print(OpAsmPrinter &p, CreateOperationOp op) { p << "pdl_interp.create_operation "; - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), {"attributeNames", "name", "operand_segment_sizes"}); p << '"' << op.name() << "\"(" << op.operands() << ')'; diff --git a/mlir/lib/Dialect/SCF/SCF.cpp b/mlir/lib/Dialect/SCF/SCF.cpp --- a/mlir/lib/Dialect/SCF/SCF.cpp +++ b/mlir/lib/Dialect/SCF/SCF.cpp @@ -172,7 +172,7 @@ p.printRegion(op.region(), /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/op.hasIterOperands()); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); } static ParseResult parseForOp(OpAsmParser &parser, OperationState &result) { @@ -679,7 +679,7 @@ /*printBlockTerminators=*/printBlockTerminators); } - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); } /// Given the region at `index`, or the parent operation if `index` is None, @@ -996,7 +996,7 @@ p.printOptionalArrowTypeList(op.getResultTypes()); p.printRegion(op.region(), /*printEntryBlockArgs=*/false); p.printOptionalAttrDict( - op.getAttrs(), /*elidedAttrs=*/ParallelOp::getOperandSegmentSizeAttr()); + op->getAttrs(), /*elidedAttrs=*/ParallelOp::getOperandSegmentSizeAttr()); } Region &ParallelOp::getLoopBody() { return region(); } @@ -1266,7 +1266,7 @@ p.printRegion(op.before(), /*printEntryBlockArgs=*/false); p << " do"; p.printRegion(op.after()); - p.printOptionalAttrDictWithKeyword(op.getAttrs()); + p.printOptionalAttrDictWithKeyword(op->getAttrs()); } /// Verifies that two ranges of types match, i.e. have the same number of diff --git a/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/DecorateCompositeTypeLayoutPass.cpp @@ -43,7 +43,7 @@ spirv::PointerType::get(structType, ptrType.getStorageClass()); // Save all named attributes except "type" attribute. - for (const auto &attr : op.getAttrs()) { + for (const auto &attr : op->getAttrs()) { if (attr.first == "type") { continue; } diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -250,7 +250,7 @@ p.printRegion(op.doRegion(), /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/yieldsResults); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); } namespace { @@ -415,7 +415,7 @@ static void print(OpAsmPrinter &p, ConstShapeOp &op) { p << "shape.const_shape "; - p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{"shape"}); + p.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/{"shape"}); p << "["; interleaveComma(op.shape().getValues(), p, [&](int64_t i) { p << i; }); @@ -723,7 +723,7 @@ p << op.getOperationName() << ' '; p.printSymbolName(op.getName()); p.printOptionalAttrDictWithKeyword( - op.getAttrs(), {SymbolTable::getSymbolAttrName(), "mapping"}); + op->getAttrs(), {SymbolTable::getSymbolAttrName(), "mapping"}); p.printRegion(op.getOperation()->getRegion(0), /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/false); p << " mapping "; @@ -1100,7 +1100,7 @@ << ") : " << op.shape().getType(); p.printOptionalArrowTypeList(op.getResultTypes()); p.printRegion(op.region()); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); } #define GET_OP_CLASSES diff --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp --- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp +++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp @@ -603,7 +603,7 @@ p << op.getOperationName() << ' ' << op.memref() << "[" << op.indices() << "] : " << op.memref().getType(); p.printRegion(op.body()); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); } //===----------------------------------------------------------------------===// @@ -1164,9 +1164,9 @@ static void print(OpAsmPrinter &p, ConstantOp &op) { p << "constant "; - p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{"value"}); + p.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/{"value"}); - if (op.getAttrs().size() > 1) + if (op->getAttrs().size() > 1) p << ' '; p << op.getValue(); @@ -1599,7 +1599,7 @@ if (isStrided()) p << ", " << getStride() << ", " << getNumElementsPerStride(); - p.printOptionalAttrDict(getAttrs()); + p.printOptionalAttrDict((*this)->getAttrs()); p << " : " << getSrcMemRef().getType() << ", " << getDstMemRef().getType() << ", " << getTagMemRef().getType(); } @@ -1763,7 +1763,7 @@ void DmaWaitOp::print(OpAsmPrinter &p) { p << "dma_wait " << getTagMemRef() << '[' << getTagIndices() << "], " << getNumElements(); - p.printOptionalAttrDict(getAttrs()); + p.printOptionalAttrDict((*this)->getAttrs()); p << " : " << getTagMemRef().getType(); } @@ -2337,7 +2337,7 @@ p << ", locality<" << op.localityHint(); p << ">, " << (op.isDataCache() ? "data" : "instr"); p.printOptionalAttrDict( - op.getAttrs(), + op->getAttrs(), /*elidedAttrs=*/{"localityHint", "isWrite", "isDataCache"}); p << " : " << op.getMemRefType(); } @@ -2454,7 +2454,7 @@ static void print(OpAsmPrinter &p, SelectOp op) { p << "select " << op.getOperands(); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); p << " : "; if (ShapedType condType = op.getCondition().getType().dyn_cast()) p << condType << ", "; @@ -3914,7 +3914,7 @@ // transpose $in $permutation attr-dict : type($in) `to` type(results) static void print(OpAsmPrinter &p, TransposeOp op) { p << "transpose " << op.in() << " " << op.permutation(); - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), {TransposeOp::getPermutationAttrName()}); p << " : " << op.in().getType() << " to " << op.getType(); } @@ -4069,7 +4069,7 @@ p << op.getOperationName() << ' ' << op.getOperand(0) << '['; p.printOperand(op.byte_shift()); p << "][" << op.sizes() << ']'; - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); p << " : " << op.getOperand(0).getType() << " to " << op.getType(); } diff --git a/mlir/lib/Dialect/Vector/VectorOps.cpp b/mlir/lib/Dialect/Vector/VectorOps.cpp --- a/mlir/lib/Dialect/Vector/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/VectorOps.cpp @@ -376,7 +376,7 @@ llvm::StringSet<> traitAttrsSet; traitAttrsSet.insert(attrNames.begin(), attrNames.end()); SmallVector attrs; - for (auto attr : op.getAttrs()) + for (auto attr : op->getAttrs()) if (traitAttrsSet.count(attr.first.strref()) > 0) attrs.push_back(attr); @@ -386,7 +386,7 @@ if (op.masks().size() == 2) p << ", " << op.masks(); - p.printOptionalAttrDict(op.getAttrs(), attrNames); + p.printOptionalAttrDict(op->getAttrs(), attrNames); p << " : " << op.lhs().getType() << ", " << op.rhs().getType() << " into " << op.getResultType(); } @@ -776,7 +776,7 @@ static void print(OpAsmPrinter &p, vector::ExtractOp op) { p << op.getOperationName() << " " << op.vector() << op.position(); - p.printOptionalAttrDict(op.getAttrs(), {"position"}); + p.printOptionalAttrDict(op->getAttrs(), {"position"}); p << " : " << op.vector().getType(); } @@ -1351,7 +1351,7 @@ static void print(OpAsmPrinter &p, ShuffleOp op) { p << op.getOperationName() << " " << op.v1() << ", " << op.v2() << " " << op.mask(); - p.printOptionalAttrDict(op.getAttrs(), {ShuffleOp::getMaskAttrName()}); + p.printOptionalAttrDict(op->getAttrs(), {ShuffleOp::getMaskAttrName()}); p << " : " << op.v1().getType() << ", " << op.v2().getType(); } @@ -1708,7 +1708,7 @@ p << op.getOperationName() << " " << op.lhs() << ", " << op.rhs(); if (!op.acc().empty()) { p << ", " << op.acc(); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); } p << " : " << op.lhs().getType() << ", " << op.rhs().getType(); } @@ -2307,7 +2307,7 @@ } if (elideMasked) elidedAttrs.push_back(op.getMaskedAttrName()); - p.printOptionalAttrDict(op.getAttrs(), elidedAttrs); + p.printOptionalAttrDict(op->getAttrs(), elidedAttrs); } static void print(OpAsmPrinter &p, TransferReadOp op) { @@ -3217,7 +3217,7 @@ static void print(OpAsmPrinter &p, TupleOp op) { p << op.getOperationName() << ' '; p.printOperands(op.getOperands()); - p.printOptionalAttrDict(op.getAttrs()); + p.printOptionalAttrDict(op->getAttrs()); p << " : "; llvm::interleaveComma(op->getOperandTypes(), p); } @@ -3362,7 +3362,7 @@ static void print(OpAsmPrinter &p, TupleGetOp op) { p << op.getOperationName() << ' ' << op.getOperand() << ", " << op.index(); - p.printOptionalAttrDict(op.getAttrs(), + p.printOptionalAttrDict(op->getAttrs(), /*elidedAttrs=*/{TupleGetOp::getIndexAttrName()}); p << " : " << op.getOperand().getType(); } diff --git a/mlir/lib/IR/BuiltinDialect.cpp b/mlir/lib/IR/BuiltinDialect.cpp --- a/mlir/lib/IR/BuiltinDialect.cpp +++ b/mlir/lib/IR/BuiltinDialect.cpp @@ -162,9 +162,9 @@ void FuncOp::cloneInto(FuncOp dest, BlockAndValueMapping &mapper) { // Add the attributes of this function to dest. llvm::MapVector newAttrs; - for (auto &attr : dest.getAttrs()) + for (const auto &attr : dest->getAttrs()) newAttrs.insert(attr); - for (auto &attr : getAttrs()) + for (const auto &attr : (*this)->getAttrs()) newAttrs.insert(attr); dest->setAttrs(DictionaryAttr::get(getContext(), newAttrs.takeVector())); @@ -233,7 +233,7 @@ static LogicalResult verify(ModuleOp op) { // Check that none of the attributes are non-dialect attributes, except for // the symbol related attributes. - for (auto attr : op.getAttrs()) { + for (auto attr : op->getAttrs()) { if (!attr.first.strref().contains('.') && !llvm::is_contained( ArrayRef{mlir::SymbolTable::getSymbolAttrName(),