diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp @@ -39,13 +39,13 @@ auto alloc = rewriter.create(loc, type); // Make sure to allocate at the beginning of the block. - auto *parentBlock = alloc.getOperation()->getBlock(); - alloc.getOperation()->moveBefore(&parentBlock->front()); + auto *parentBlock = alloc->getBlock(); + alloc->moveBefore(&parentBlock->front()); // Make sure to deallocate this alloc at the end of the block. This is fine // as toy functions have no control flow. auto dealloc = rewriter.create(loc, alloc); - dealloc.getOperation()->moveBefore(&parentBlock->back()); + dealloc->moveBefore(&parentBlock->back()); return alloc; } diff --git a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp @@ -39,13 +39,13 @@ auto alloc = rewriter.create(loc, type); // Make sure to allocate at the beginning of the block. - auto *parentBlock = alloc.getOperation()->getBlock(); - alloc.getOperation()->moveBefore(&parentBlock->front()); + auto *parentBlock = alloc->getBlock(); + alloc->moveBefore(&parentBlock->front()); // Make sure to deallocate this alloc at the end of the block. This is fine // as toy functions have no control flow. auto dealloc = rewriter.create(loc, alloc); - dealloc.getOperation()->moveBefore(&parentBlock->back()); + dealloc->moveBefore(&parentBlock->back()); return alloc; } diff --git a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp --- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp @@ -39,13 +39,13 @@ auto alloc = rewriter.create(loc, type); // Make sure to allocate at the beginning of the block. - auto *parentBlock = alloc.getOperation()->getBlock(); - alloc.getOperation()->moveBefore(&parentBlock->front()); + auto *parentBlock = alloc->getBlock(); + alloc->moveBefore(&parentBlock->front()); // Make sure to deallocate this alloc at the end of the block. This is fine // as toy functions have no control flow. auto dealloc = rewriter.create(loc, alloc); - dealloc.getOperation()->moveBefore(&parentBlock->back()); + dealloc->moveBefore(&parentBlock->back()); return alloc; } diff --git a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td --- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td +++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td @@ -848,11 +848,11 @@ "ValueRange":$operands), [{ BlockAndValueMapping map; - unsigned numRegions = $_op.getOperation()->getNumRegions(); + unsigned numRegions = $_op->getNumRegions(); Operation *res = create(b, loc, resultTypes, operands, $_op.getAttrs()); assert(res->getNumRegions() == numRegions && "inconsistent # regions"); for (unsigned ridx = 0; ridx < numRegions; ++ridx) - $_op.getOperation()->getRegion(ridx).cloneInto( + $_op->getRegion(ridx).cloneInto( &res->getRegion(ridx), map); return res; }] diff --git a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h --- a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h +++ b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h @@ -150,7 +150,7 @@ rewriter.eraseOp(op); return success(); } - if (op.getOperation()->getNumResults() != 1) + if (op->getNumResults() != 1) return failure(); auto resultVector = unrollSingleResultVectorOp(rewriter, op, *targetShape); if (resultVector.size() != 1) 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 @@ -102,6 +102,9 @@ /// This implicitly converts to Operation*. operator Operation *() const { return state; } + /// Shortcut of `->` to access a member of Operation. + Operation *operator->() const { return state; } + /// Return the operation that this refers to. Operation *getOperation() { return state; } diff --git a/mlir/include/mlir/Interfaces/VectorInterfaces.td b/mlir/include/mlir/Interfaces/VectorInterfaces.td --- a/mlir/include/mlir/Interfaces/VectorInterfaces.td +++ b/mlir/include/mlir/Interfaces/VectorInterfaces.td @@ -33,7 +33,7 @@ /*args=*/(ins), /*methodBody=*/"", /*defaultImplementation=*/[{ - assert($_op.getOperation()->getNumResults() == 1); + assert($_op->getNumResults() == 1); auto vt = $_op.getResult().getType(). template dyn_cast(); if (!vt) diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp --- a/mlir/lib/Analysis/AffineAnalysis.cpp +++ b/mlir/lib/Analysis/AffineAnalysis.cpp @@ -954,7 +954,7 @@ std::vector> *depCompsVec) { // Collect all load and store ops in loop nest rooted at 'forOp'. SmallVector loadAndStoreOps; - forOp.getOperation()->walk([&](Operation *op) { + forOp->walk([&](Operation *op) { if (isa(op)) loadAndStoreOps.push_back(op); }); diff --git a/mlir/lib/Analysis/BufferAliasAnalysis.cpp b/mlir/lib/Analysis/BufferAliasAnalysis.cpp --- a/mlir/lib/Analysis/BufferAliasAnalysis.cpp +++ b/mlir/lib/Analysis/BufferAliasAnalysis.cpp @@ -58,13 +58,12 @@ // Add additional aliases created by view changes to the alias list. op->walk([&](ViewLikeOpInterface viewInterface) { - aliases[viewInterface.getViewSource()].insert( - viewInterface.getOperation()->getResult(0)); + aliases[viewInterface.getViewSource()].insert(viewInterface->getResult(0)); }); // Query all branch interfaces to link block argument aliases. op->walk([&](BranchOpInterface branchInterface) { - Block *parentBlock = branchInterface.getOperation()->getBlock(); + Block *parentBlock = branchInterface->getBlock(); for (auto it = parentBlock->succ_begin(), e = parentBlock->succ_end(); it != e; ++it) { // Query the branch op interface to get the successor operands. @@ -93,7 +92,7 @@ } // Wire flow between regions and from region exits. - for (Region ®ion : regionInterface.getOperation()->getRegions()) { + for (Region ®ion : regionInterface->getRegions()) { // Iterate over all successor region entries that are reachable from the // current region. SmallVector successorRegions; diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp --- a/mlir/lib/Analysis/Utils.cpp +++ b/mlir/lib/Analysis/Utils.cpp @@ -872,8 +872,7 @@ // Find the op block positions of 'srcOpInst' within 'srcLoopIVs'. SmallVector positions; // TODO: This code is incorrect since srcLoopIVs can be 0-d. - findInstPosition(srcOpInst, srcLoopIVs[0].getOperation()->getBlock(), - &positions); + findInstPosition(srcOpInst, srcLoopIVs[0]->getBlock(), &positions); // Clone src loop nest and insert it a the beginning of the operation block // of the loop at 'dstLoopDepth' in 'dstLoopIVs'. @@ -1043,7 +1042,7 @@ /// at 'forOp'. void mlir::getSequentialLoops(AffineForOp forOp, llvm::SmallDenseSet *sequentialLoops) { - forOp.getOperation()->walk([&](Operation *op) { + forOp->walk([&](Operation *op) { if (auto innerFor = dyn_cast(op)) if (!isLoopParallel(innerFor)) sequentialLoops->insert(innerFor.getInductionVar()); diff --git a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp --- a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp +++ b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp @@ -58,8 +58,7 @@ if (numResults == 0) return rewriter.eraseOp(op), success(); if (numResults == 1) - return rewriter.replaceOp(op, newOp.getOperation()->getResult(0)), - success(); + return rewriter.replaceOp(op, newOp->getResult(0)), success(); // Otherwise, it had been converted to an operation producing a structure. // Extract individual results from the structure and return them as list. @@ -68,8 +67,7 @@ for (unsigned i = 0; i < numResults; ++i) { auto type = typeConverter.convertType(op->getResult(i).getType()); results.push_back(rewriter.create( - op->getLoc(), type, newOp.getOperation()->getResult(0), - rewriter.getI64ArrayAttr(i))); + op->getLoc(), type, newOp->getResult(0), rewriter.getI64ArrayAttr(i))); } rewriter.replaceOp(op, results); return success(); diff --git a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp --- a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp +++ b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp @@ -365,8 +365,7 @@ // Allocate the underlying buffer and store a pointer to it in the MemRef // descriptor. Type elementPtrType = this->getElementPtrType(memRefType); - auto adaptor = gpu::AllocOpAdaptor( - operands, allocOp.getOperation()->getAttrDictionary()); + auto adaptor = gpu::AllocOpAdaptor(operands, allocOp->getAttrDictionary()); auto stream = adaptor.asyncDependencies().front(); Value allocatedPtr = allocCallBuilder.create(loc, rewriter, {sizeBytes, stream}).getResult(0); @@ -394,8 +393,8 @@ Location loc = deallocOp.getLoc(); - auto adaptor = gpu::DeallocOpAdaptor( - operands, deallocOp.getOperation()->getAttrDictionary()); + auto adaptor = + gpu::DeallocOpAdaptor(operands, deallocOp->getAttrDictionary()); Value pointer = MemRefDescriptor(adaptor.memref()).allocatedPtr(rewriter, loc); auto casted = rewriter.create(loc, llvmPointerType, pointer); @@ -451,7 +450,7 @@ } else { // If we can't find the defining op, we record the event at block start, // which is late and therefore misses parallelism, but still valid. - rewriter.setInsertionPointToStart(waitOp.getOperation()->getBlock()); + rewriter.setInsertionPointToStart(waitOp->getBlock()); } auto event = eventCreateCallBuilder.create(loc, rewriter, {}).getResult(0); auto stream = std::get<1>(pair); @@ -610,8 +609,8 @@ loc, rewriter, {module.getResult(0), kernelName}); auto zero = rewriter.create(loc, llvmInt32Type, rewriter.getI32IntegerAttr(0)); - auto adaptor = gpu::LaunchFuncOpAdaptor( - operands, launchOp.getOperation()->getAttrDictionary()); + auto adaptor = + gpu::LaunchFuncOpAdaptor(operands, launchOp->getAttrDictionary()); Value stream = adaptor.asyncDependencies().empty() ? streamCreateCallBuilder.create(loc, rewriter, {}).getResult(0) diff --git a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp --- a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp +++ b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp @@ -580,7 +580,7 @@ DenseMap &rewriteValues, function_ref mapRewriteValue) { // Functor that returns if the given use can be used to infer a type. - Block *rewriterBlock = op.getOperation()->getBlock(); + Block *rewriterBlock = op->getBlock(); auto getReplacedOperationFrom = [&](OpOperand &use) -> Operation * { // Check that the use corresponds to a ReplaceOp and that it is the // replacement value, not the operation being replaced. diff --git a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp --- a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp +++ b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp @@ -76,9 +76,9 @@ auto omp = builder.create(parallelOp.getLoc()); Block *block = builder.createBlock(&omp.getRegion()); builder.create(parallelOp.getLoc()); - block->getOperations().splice( - block->begin(), parallelOp.getOperation()->getBlock()->getOperations(), - parallelOp.getOperation()); + block->getOperations().splice(block->begin(), + parallelOp->getBlock()->getOperations(), + parallelOp.getOperation()); } } diff --git a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp --- a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp +++ b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp @@ -160,7 +160,7 @@ // Move the blocks from the forOp into the loopOp. This is the body of the // loopOp. - rewriter.inlineRegionBefore(forOp.getOperation()->getRegion(0), loopOp.body(), + rewriter.inlineRegionBefore(forOp->getRegion(0), loopOp.body(), std::next(loopOp.body().begin(), 2)); SmallVector args(1, forOperands.lowerBound()); diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp --- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp +++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp @@ -2293,8 +2293,8 @@ } auto promoted = this->typeConverter.promoteOperands( - callOp.getLoc(), /*opOperands=*/callOp.getOperation()->getOperands(), - operands, rewriter); + callOp.getLoc(), /*opOperands=*/callOp->getOperands(), operands, + rewriter); auto newOp = rewriter.create( callOp.getLoc(), packedResult ? TypeRange(packedResult) : TypeRange(), promoted, callOp.getAttrs()); @@ -2311,7 +2311,7 @@ auto type = this->typeConverter.convertType(callOp.getResult(i).getType()); results.push_back(rewriter.create( - callOp.getLoc(), type, newOp.getOperation()->getResult(0), + callOp.getLoc(), type, newOp->getResult(0), rewriter.getI64ArrayAttr(i))); } } @@ -2673,8 +2673,8 @@ LogicalResult matchAndRewrite(MemRefReinterpretCastOp castOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - MemRefReinterpretCastOp::Adaptor adaptor( - operands, castOp.getOperation()->getAttrDictionary()); + MemRefReinterpretCastOp::Adaptor adaptor(operands, + castOp->getAttrDictionary()); Type srcType = castOp.source().getType(); Value descriptor; @@ -3226,8 +3226,8 @@ LogicalResult matchAndRewrite(SourceOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const override { - rewriter.replaceOpWithNewOp( - op, operands, op.getOperation()->getSuccessors(), op.getAttrs()); + rewriter.replaceOpWithNewOp(op, operands, op->getSuccessors(), + op.getAttrs()); return success(); } }; @@ -3251,7 +3251,7 @@ if (typeConverter.getOptions().useBarePtrCallConv) { // For the bare-ptr calling convention, extract the aligned pointer to // be returned from the memref descriptor. - for (auto it : llvm::zip(op.getOperation()->getOperands(), operands)) { + for (auto it : llvm::zip(op->getOperands(), operands)) { Type oldTy = std::get<0>(it).getType(); Value newOperand = std::get<1>(it); if (oldTy.isa()) { @@ -3837,7 +3837,7 @@ loopBlock->getParent(), std::next(Region::iterator(loopBlock))); // Operations range to be moved to `endBlock`. - auto opsToMoveStart = atomicOp.getOperation()->getIterator(); + auto opsToMoveStart = atomicOp->getIterator(); auto opsToMoveEnd = initBlock->back().getIterator(); // Compute the loaded value and branch to the loop block. diff --git a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp --- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp +++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp @@ -169,7 +169,7 @@ IntegerAttr attr = builder.getIntegerAttr(targetType, targetBits / sourceBits); auto idx = builder.create(loc, targetType, attr); - auto lastDim = op.getOperation()->getOperand(op.getNumOperands() - 1); + auto lastDim = op->getOperand(op.getNumOperands() - 1); auto indices = llvm::to_vector<4>(op.indices()); // There are two elements if this is a 1-D tensor. assert(indices.size() == 2); @@ -874,8 +874,7 @@ // Shift the bits to the rightmost. // ____XXXX________ -> ____________XXXX - Value lastDim = accessChainOp.getOperation()->getOperand( - accessChainOp.getNumOperands() - 1); + Value lastDim = accessChainOp->getOperand(accessChainOp.getNumOperands() - 1); Value offset = getOffsetForBitwidth(loc, lastDim, srcBits, dstBits, rewriter); Value result = rewriter.create( loc, spvLoadOp.getType(), spvLoadOp, offset); @@ -991,8 +990,7 @@ // The step 1 to step 3 are done by AtomicAnd as one atomic step, and the step // 4 to step 6 are done by AtomicOr as another atomic step. assert(accessChainOp.indices().size() == 2); - Value lastDim = accessChainOp.getOperation()->getOperand( - accessChainOp.getNumOperands() - 1); + Value lastDim = accessChainOp->getOperand(accessChainOp.getNumOperands() - 1); Value offset = getOffsetForBitwidth(loc, lastDim, srcBits, dstBits, rewriter); // Create a mask to clear the destination. E.g., if it is the second i8 in 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 @@ -628,7 +628,7 @@ auto affineApply = t.getDefiningOp(); if (affineApply) { // a. Compose affine.apply operations. - LLVM_DEBUG(affineApply.getOperation()->print( + LLVM_DEBUG(affineApply->print( dbgs() << "\nCompose AffineApplyOp recursively: ")); AffineMap affineApplyMap = affineApply.getAffineMap(); SmallVector affineApplyOperands( diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp --- a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp @@ -216,7 +216,7 @@ op->moveBefore(forOp); } - LLVM_DEBUG(forOp.getOperation()->print(llvm::dbgs() << "Modified loop\n")); + LLVM_DEBUG(forOp->print(llvm::dbgs() << "Modified loop\n")); } void LoopInvariantCodeMotion::runOnFunction() { @@ -224,7 +224,7 @@ // way, we first LICM from the inner loop, and place the ops in // the outer loop, which in turn can be further LICM'ed. getFunction().walk([&](AffineForOp op) { - LLVM_DEBUG(op.getOperation()->print(llvm::dbgs() << "\nOriginal loop\n")); + LLVM_DEBUG(op->print(llvm::dbgs() << "\nOriginal loop\n")); runOnAffineForOp(op); }); } diff --git a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp --- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp +++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp @@ -1347,7 +1347,7 @@ // the previous level. bool parentFound = false; for (AffineForOp maybeParent : loops[i - 1]) { - if (maybeParent.getOperation()->isProperAncestor(loop)) { + if (maybeParent->isProperAncestor(loop)) { parentFound = true; break; } @@ -1358,7 +1358,7 @@ // this level. #ifndef NDEBUG for (AffineForOp sibling : loops[i]) - assert(!sibling.getOperation()->isProperAncestor(loop) && + assert(!sibling->isProperAncestor(loop) && "Loops at the same level are nested"); #endif } diff --git a/mlir/lib/Dialect/Affine/Utils/Utils.cpp b/mlir/lib/Dialect/Affine/Utils/Utils.cpp --- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp @@ -29,7 +29,7 @@ if (elseBlock) assert(ifOp.hasElse() && "else block expected"); - Block *destBlock = ifOp.getOperation()->getBlock(); + Block *destBlock = ifOp->getBlock(); Block *srcBlock = elseBlock ? ifOp.getElseBlock() : ifOp.getThenBlock(); destBlock->getOperations().splice( Block::iterator(ifOp), srcBlock->getOperations(), srcBlock->begin(), diff --git a/mlir/lib/Dialect/Async/Transforms/AsyncRefCountingOptimization.cpp b/mlir/lib/Dialect/Async/Transforms/AsyncRefCountingOptimization.cpp --- a/mlir/lib/Dialect/Async/Transforms/AsyncRefCountingOptimization.cpp +++ b/mlir/lib/Dialect/Async/Transforms/AsyncRefCountingOptimization.cpp @@ -122,7 +122,7 @@ for (DropRefOp dropRef : info.dropRefs) { // `drop_ref` operation after the `add_ref` with matching count. if (dropRef.count() != addRef.count() || - dropRef.getOperation()->isBeforeInBlock(addRef.getOperation())) + dropRef->isBeforeInBlock(addRef.getOperation())) continue; // `drop_ref` was already marked for removal. 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 @@ -836,7 +836,7 @@ p.printSymbolName(op.getName()); p.printOptionalAttrDictWithKeyword(op.getAttrs(), {SymbolTable::getSymbolAttrName()}); - p.printRegion(op.getOperation()->getRegion(0), /*printEntryBlockArgs=*/false, + p.printRegion(op->getRegion(0), /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/false); } diff --git a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp --- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp @@ -239,7 +239,7 @@ bool modified = false; for (auto func : getOperation().getOps()) { // Insert just after the function. - Block::iterator insertPt(func.getOperation()->getNextNode()); + Block::iterator insertPt(func->getNextNode()); auto funcWalkResult = func.walk([&](gpu::LaunchOp op) { llvm::SetVector operands; std::string kernelFnName = diff --git a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp @@ -48,7 +48,7 @@ SmallVector loopRanges; // Allocate a buffer for every tensor result. - for (auto en : llvm::enumerate(linalgOp.getOperation()->getResultTypes())) { + for (auto en : llvm::enumerate(linalgOp->getResultTypes())) { size_t resultIndex = en.index(); Type resultType = en.value(); @@ -250,8 +250,7 @@ LogicalResult matchAndRewrite(SubTensorOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { - SubTensorOpAdaptor adaptor(operands, - op.getOperation()->getAttrDictionary()); + SubTensorOpAdaptor adaptor(operands, op->getAttrDictionary()); Value sourceMemref = adaptor.source(); assert(sourceMemref.getType().isa()); @@ -293,8 +292,7 @@ LogicalResult matchAndRewrite(SubTensorInsertOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { - SubTensorInsertOpAdaptor adaptor(operands, - op.getOperation()->getAttrDictionary()); + SubTensorInsertOpAdaptor adaptor(operands, op->getAttrDictionary()); Value sourceMemRef = adaptor.source(); assert(sourceMemRef.getType().isa()); diff --git a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp @@ -158,7 +158,7 @@ IndexedGenericOp op, const DenseSet &unitDims, PatternRewriter &rewriter) { OpBuilder::InsertionGuard guard(rewriter); - Block *entryBlock = &op.getOperation()->getRegion(0).front(); + Block *entryBlock = &op->getRegion(0).front(); rewriter.setInsertionPointToStart(entryBlock); Value zero = rewriter.create(op.getLoc(), 0); for (unsigned unitDimLoop : unitDims) { diff --git a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp @@ -118,7 +118,7 @@ // Since we do not enforce any canonicalizations on the fly, this is always // fully dynamic at construction time. SmallVector resultTypes; - resultTypes.reserve(op.getOperation()->getNumResults()); + resultTypes.reserve(op->getNumResults()); for (RankedTensorType t : op.getOutputTensorTypes()) { unsigned rank = t.getRank(); SmallVector staticOffsetsVector( @@ -288,8 +288,7 @@ } // Only fuse when the producer block dominates. DominanceInfo dom(producer.getOperation()); - if (!dom.dominates(producer.getOperation()->getBlock(), - consumer.getOperation()->getBlock())) { + if (!dom.dominates(producer->getBlock(), consumer->getBlock())) { LLVM_DEBUG( llvm::dbgs() << "\nNot structurally fusable (producer block does not dominate)"); @@ -435,8 +434,7 @@ LinalgOp producerOp = cast(fusableDependence->dependentOpView.op); // If producer is already in the same block as consumer, we are done. - if (consumer.getOperation()->getBlock() == - producerOp.getOperation()->getBlock()) + if (consumer->getBlock() == producerOp->getBlock()) return {}; unsigned producerIdx = fusableDependence->dependentOpView.operandIndex - @@ -505,8 +503,7 @@ } // If producer is already in the same block as consumer, we are done. - if (consumer.getOperation()->getBlock() == - producerOp.getOperation()->getBlock()) + if (consumer->getBlock() == producerOp->getBlock()) return {}; // Insert fused `producer` just before `consumer`. @@ -522,8 +519,8 @@ // `fusedProducer`. In the tensor case this can result in temporary type // mismatches. Insert a `tensor_cast` op to propagate the transformation // invariant that types are compatible. - Value def = fusedProducer.getOperation()->getResult(producerIdx); - OpOperand &use = consumer.getOperation()->getOpOperand(consumerIdx); + Value def = fusedProducer->getResult(producerIdx); + OpOperand &use = consumer->getOpOperand(consumerIdx); Type consumerType = use.get().getType(); if (consumerType != def.getType()) def = b.create(fusedProducer.getLoc(), consumerType, def); @@ -746,8 +743,7 @@ // Do not fuse dependences that are to operations not in the same basic // block. This avoid moving fused operations across loops that might // themselves carry dependency making the fusion illegal. - if (producerOp.getOperation()->getBlock() != - op.getOperation()->getBlock()) { + if (producerOp->getBlock() != op->getBlock()) { op.emitRemark("unhandled fusion of ops in different basic blocks"); return FusableOpDependencesTy{}; } diff --git a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp @@ -93,8 +93,8 @@ AffineMap consumerToProducerLoopsMap, unsigned consumerIdx, unsigned nloops) { // Build the region of the fused op. - Block &producerBlock = producer.getOperation()->getRegion(0).front(); - Block &consumerBlock = consumer.getOperation()->getRegion(0).front(); + Block &producerBlock = producer->getRegion(0).front(); + Block &consumerBlock = consumer->getRegion(0).front(); Block *fusedBlock = new Block(); fusedOp->getRegion(0).push_back(fusedBlock); BlockAndValueMapping mapper; @@ -217,32 +217,31 @@ LinalgOp fusedOp; if (isa(producer.getOperation()) && isa(consumer.getOperation())) { - fusedOp = rewriter - .create(consumer.getLoc(), - consumer.getOperation()->getResultTypes(), - /*inputs=*/fusedOperands, - /*outputBuffers=*/ValueRange{}, - /*initTensors=*/ValueRange{}, - rewriter.getArrayAttr(fusedIndexMaps), - consumer.iterator_types(), - /*doc=*/nullptr, - /*library_call=*/nullptr, - /*sparse=*/nullptr) - .getOperation(); - } else { fusedOp = rewriter - .create(consumer.getLoc(), - consumer.getOperation()->getResultTypes(), - /*inputs=*/fusedOperands, - /*outputBuffers=*/ValueRange{}, - /*initTensors=*/ValueRange{}, - rewriter.getArrayAttr(fusedIndexMaps), - consumer.iterator_types(), - /*doc=*/nullptr, - /*library_call=*/nullptr, - /*sparse=*/nullptr) + .create(consumer.getLoc(), consumer->getResultTypes(), + /*inputs=*/fusedOperands, + /*outputBuffers=*/ValueRange{}, + /*initTensors=*/ValueRange{}, + rewriter.getArrayAttr(fusedIndexMaps), + consumer.iterator_types(), + /*doc=*/nullptr, + /*library_call=*/nullptr, + /*sparse=*/nullptr) .getOperation(); + } else { + fusedOp = rewriter + .create( + consumer.getLoc(), consumer->getResultTypes(), + /*inputs=*/fusedOperands, + /*outputBuffers=*/ValueRange{}, + /*initTensors=*/ValueRange{}, + rewriter.getArrayAttr(fusedIndexMaps), + consumer.iterator_types(), + /*doc=*/nullptr, + /*library_call=*/nullptr, + /*sparse=*/nullptr) + .getOperation(); } // Construct an AffineMap from consumer loops to producer loops. @@ -262,7 +261,7 @@ generateFusedTensorOpRegion(rewriter, fusedOp.getOperation(), producer, consumer, consumerToProducerLoopsMap, consumerIdx, consumer.getNumLoops()); - return SmallVector(fusedOp.getOperation()->getResults()); + return SmallVector(fusedOp->getResults()); } /// Linearize the expressions in `sourceMap` based on the `reassociationMaps` @@ -558,7 +557,7 @@ } SmallVector resultTypes; SmallVector, 1> resultReassociation; - for (auto result : llvm::enumerate(linalgOp.getOperation()->getResults())) { + for (auto result : llvm::enumerate(linalgOp->getResults())) { AffineMap indexingMap = linalgOp.getIndexingMap(linalgOp.getNumInputs() + result.index()); SmallVector reassociation; @@ -579,8 +578,8 @@ /*inputs=*/expandedOpOperands, /*outputBuffers=*/ValueRange{}, /*initTensors=*/ValueRange{}, expandedOpIndexingMaps, iteratorTypes); - Region &fusedRegion = fusedOp.getOperation()->getRegion(0); - Region &originalRegion = linalgOp.getOperation()->getRegion(0); + Region &fusedRegion = fusedOp->getRegion(0); + Region &originalRegion = linalgOp->getRegion(0); if (isa(linalgOp.getOperation())) { rewriter.cloneRegionBefore(originalRegion, fusedRegion, @@ -634,15 +633,15 @@ // Reshape the result values to their original shape if this is a collapsing // reshape folded into its consumer. SmallVector resultVals; - for (auto result : llvm::enumerate(linalgOp.getOperation()->getResults())) { + for (auto result : llvm::enumerate(linalgOp->getResults())) { if (!isExpanding && resultTypes[result.index()] != result.value().getType()) { resultVals.push_back(rewriter.create( linalgOp.getLoc(), result.value().getType(), - fusedOp.getOperation()->getResult(result.index()), + fusedOp->getResult(result.index()), resultReassociation[result.index()])); } else { - resultVals.push_back(fusedOp.getOperation()->getResult(result.index())); + resultVals.push_back(fusedOp->getResult(result.index())); } } // Assuming a single result. @@ -722,7 +721,7 @@ return op.emitRemark("fused op loop bound computation failed"); rewriter.startRootUpdate(op); - op.getOperation()->setOperands(fusedOperands); + op->setOperands(fusedOperands); op.indexing_mapsAttr(rewriter.getAffineMapArrayAttr(fusedIndexMaps)); rewriter.finalizeRootUpdate(op); if (reshapeOp.use_empty()) @@ -819,10 +818,10 @@ /*doc=*/nullptr, /*library_call=*/nullptr, /*sparse=*/nullptr); - auto &fusedRegion = fusedOp.getOperation()->getRegion(0); - rewriter.cloneRegionBefore(producer.getOperation()->getRegion(0), - fusedRegion, fusedRegion.begin()); - rewriter.replaceOp(reshapeOp, fusedOp.getOperation()->getResults()); + auto &fusedRegion = fusedOp->getRegion(0); + rewriter.cloneRegionBefore(producer->getRegion(0), fusedRegion, + fusedRegion.begin()); + rewriter.replaceOp(reshapeOp, fusedOp->getResults()); if (producer.use_empty()) rewriter.eraseOp(producer); return success(); @@ -893,7 +892,7 @@ LinalgOp fusedOp = createLinalgOpOfSameType( linalgOp, rewriter, rewriter.getUnknownLoc(), - linalgOp.getOperation()->getResultTypes(), + linalgOp->getResultTypes(), /*inputs=*/fusedOperands, /*outputBuffers=*/ValueRange{}, /*initTensors=*/ValueRange{}, // no init tensors for now. @@ -905,16 +904,16 @@ // Map the block argument corresponding to the replaced argument with the // scalar constant. - Region &linalgOpRegion = linalgOp.getOperation()->getRegion(0); + Region &linalgOpRegion = linalgOp->getRegion(0); Block &entryBlock = *linalgOpRegion.begin(); unsigned argIndex = entryBlock.getNumArguments() - linalgOp.getNumInputs() + operand.index(); BlockAndValueMapping mapping; mapping.map(entryBlock.getArgument(argIndex), scalarConstant); - Region &fusedRegion = fusedOp.getOperation()->getRegion(0); + Region &fusedRegion = fusedOp->getRegion(0); rewriter.cloneRegionBefore(linalgOpRegion, fusedRegion, fusedRegion.begin(), mapping); - rewriter.replaceOp(linalgOp, fusedOp.getOperation()->getResults()); + rewriter.replaceOp(linalgOp, fusedOp->getResults()); if (constantOp.use_empty()) rewriter.eraseOp(constantOp); return success(); @@ -951,10 +950,8 @@ LogicalResult matchAndRewrite(LinalgOpTy op, PatternRewriter &rewriter) const override { // Find the first operand that is defined by another generic op on tensors. - for (auto operandNum : - llvm::seq(0, op.getOperation()->getNumOperands())) { - Operation *producer = - op.getOperation()->getOperand(operandNum).getDefiningOp(); + for (auto operandNum : llvm::seq(0, op->getNumOperands())) { + Operation *producer = op->getOperand(operandNum).getDefiningOp(); if (!producer) continue; Optional> fusedOpResults = diff --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp @@ -175,7 +175,7 @@ "Unexpected failure to move transfer read out of loop"); // Hoist write after. - transferWrite.getOperation()->moveAfter(loop); + transferWrite->moveAfter(loop); // Rewrite `loop` with new yields by cloning and erase the original loop. OpBuilder b(transferRead); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp @@ -65,10 +65,9 @@ static void inlineRegionAndEmitStore(OpType op, ArrayRef indexedValues, ArrayRef> indexing, ArrayRef outputBuffers) { - assert(op.getOperation()->getNumRegions() == 1 && - "Expected single region op"); + assert(op->getNumRegions() == 1 && "Expected single region op"); auto &b = ScopedContext::getBuilderRef(); - auto &block = op.getOperation()->getRegion(0).front(); + auto &block = op->getRegion(0).front(); BlockAndValueMapping map; map.map(block.getArguments(), indexedValues); for (auto &op : block.without_terminator()) { diff --git a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp @@ -345,7 +345,7 @@ opViews.push_back(view.value()); } } - op.getOperation()->setOperands(0, opViews.size(), opViews); + op->setOperands(0, opViews.size(), opViews); OpBuilder::InsertionGuard guard(b); b.setInsertionPointAfter(op); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp @@ -414,7 +414,7 @@ // This would not be the case with a special terminator op that // generates the whole tensor (instead of inserting a subtensor). But // the generator-based abstraction has other issues. - assert(op.getNumInitTensors() == op.getOperation()->getNumResults() && + assert(op.getNumInitTensors() == op->getNumResults() && "expected same number of init tensors as number of results"); // Handle init tensor operands. @@ -434,13 +434,12 @@ tiledOperands[op.getNumInputsAndOutputBuffers() + idx]; if (auto subtensor = initTensor.getDefiningOp()) { tensorResults.push_back(b.create( - loc, subtensor.source().getType(), - res.getOperation()->getResult(idx), subtensor.source(), - subtensor.offsets(), subtensor.sizes(), subtensor.strides(), - subtensor.static_offsets(), subtensor.static_sizes(), - subtensor.static_strides())); + loc, subtensor.source().getType(), res->getResult(idx), + subtensor.source(), subtensor.offsets(), subtensor.sizes(), + subtensor.strides(), subtensor.static_offsets(), + subtensor.static_sizes(), subtensor.static_strides())); } else { - tensorResults.push_back(res.getOperation()->getResult(idx)); + tensorResults.push_back(res->getResult(idx)); } } return scf::ValueVector(tensorResults.begin(), tensorResults.end()); diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp @@ -128,7 +128,7 @@ // This would not be the case with a special terminator op that generates the // whole tensor (instead of inserting a subtensor). But the generator-based // abstraction has other issues. - if (linalgOp.getNumInitTensors() != linalgOp.getOperation()->getNumResults()) + if (linalgOp.getNumInitTensors() != linalgOp->getNumResults()) return failure(); Optional res = tileLinalgOp(rewriter, linalgOp, options); 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 @@ -219,7 +219,7 @@ ResultRange opResults, OperandRange resultTypes) { // Functor that returns if the given use can be used to infer a type. - Block *rewriterBlock = op.getOperation()->getBlock(); + Block *rewriterBlock = op->getBlock(); auto canInferTypeFromUse = [&](OpOperand &use) { // If the use is within a ReplaceOp and isn't the operation being replaced // (i.e. is not the first operand of the replacement), we can infer a type. 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 @@ -732,8 +732,8 @@ [&](OpResult result) { return yieldOp.getOperand(result.getResultNumber()); }); - rewriter.updateRootInPlace( - yieldOp, [&]() { yieldOp.getOperation()->setOperands(usedOperands); }); + rewriter.updateRootInPlace(yieldOp, + [&]() { yieldOp->setOperands(usedOperands); }); } LogicalResult matchAndRewrite(IfOp op, diff --git a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp --- a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp @@ -59,7 +59,7 @@ // Stop if the memref is defined in secondPloop body. Careful alias analysis // is needed. auto *memrefDef = load.getMemRef().getDefiningOp(); - if (memrefDef && memrefDef->getBlock() == load.getOperation()->getBlock()) + if (memrefDef && memrefDef->getBlock() == load->getBlock()) return WalkResult::interrupt(); auto write = bufferStores.find(load.getMemRef()); diff --git a/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp b/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp --- a/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp @@ -63,7 +63,7 @@ } // Change the clone to use the updated operands. We could have cloned with // a BlockAndValueMapping, but this seems a bit more direct. - newOp.getOperation()->setOperands(operands); + newOp->setOperands(operands); // Update the result types to the new converted types. for (auto t : llvm::zip(newOp.getResults(), newResultTypes)) std::get<0>(t).setType(std::get<1>(t)); @@ -108,7 +108,7 @@ newOp.elseRegion().end()); // Update the operands and types. - newOp.getOperation()->setOperands(operands); + newOp->setOperands(operands); for (auto t : llvm::zip(newOp.getResults(), newResultTypes)) std::get<0>(t).setType(std::get<1>(t)); rewriter.replaceOp(op, newOp.getResults()); diff --git a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp --- a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp +++ b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp @@ -84,9 +84,9 @@ /// binding and spec_id, repectively, happen to hash to the same value. static llvm::hash_code computeHash(SymbolOpInterface symbolOp) { llvm::hash_code hashCode(0); - hashCode = llvm::hash_combine(symbolOp.getOperation()->getName()); + hashCode = llvm::hash_combine(symbolOp->getName()); - for (auto attr : symbolOp.getOperation()->getAttrs()) { + for (auto attr : symbolOp->getAttrs()) { if (attr.first == SymbolTable::getSymbolAttrName()) continue; hashCode = llvm::hash_combine(hashCode, attr); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp b/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp --- a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp @@ -324,7 +324,7 @@ auto falseValue = getSrcValue(falseBlock); auto ptrValue = getDstPtr(trueBlock); auto storeOpAttributes = - cast(trueBlock->front()).getOperation()->getAttrs(); + cast(trueBlock->front())->getAttrs(); auto selectOp = rewriter.create( selectionOp.getLoc(), trueValue.getType(), brConditionalOp.condition(), @@ -353,8 +353,7 @@ } bool isSameAttrList(spirv::StoreOp lhs, spirv::StoreOp rhs) const { - return lhs.getOperation()->getAttrDictionary() == - rhs.getOperation()->getAttrDictionary(); + return lhs->getAttrDictionary() == rhs->getAttrDictionary(); } @@ -408,8 +407,8 @@ return failure(); } - if ((trueBrBranchOp.getOperation()->getSuccessor(0) != mergeBlock) || - (falseBrBranchOp.getOperation()->getSuccessor(0) != mergeBlock)) { + if ((trueBrBranchOp->getSuccessor(0) != mergeBlock) || + (falseBrBranchOp->getSuccessor(0) != mergeBlock)) { return failure(); } diff --git a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp --- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp +++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp @@ -103,7 +103,7 @@ return incomingBlock; // Or the enclosing block itself if no structured control flow ops // exists before this loop. - return loopOp.getOperation()->getBlock(); + return loopOp->getBlock(); } } @@ -2065,7 +2065,7 @@ SmallVector operands; SmallVector elidedAttrs; - for (Value operand : op.getOperation()->getOperands()) { + for (Value operand : op->getOperands()) { auto id = getValueID(operand); assert(id && "use before def!"); operands.push_back(id); diff --git a/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp @@ -63,7 +63,7 @@ location, compositeType, operands); lastCompositeInsertOp.replaceAllUsesWith( - compositeConstructOp.getOperation()->getResult(0)); + compositeConstructOp->getResult(0)); // Erase ops. for (auto insertOp : llvm::reverse(insertions)) { 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 @@ -617,7 +617,7 @@ PatternRewriter &rewriter) const override { // Check that the successor block has a single predecessor. Block *succ = op.getDest(); - Block *opParent = op.getOperation()->getBlock(); + Block *opParent = op->getBlock(); if (succ == opParent || !llvm::hasSingleElement(succ->getPredecessors())) return failure(); @@ -645,7 +645,7 @@ // Try to collapse the successor if it points somewhere other than this // block. - if (dest == op.getOperation()->getBlock() || + if (dest == op->getBlock() || failed(collapseBranch(dest, destOperands, destOperandStorage))) return failure(); @@ -1010,7 +1010,7 @@ // Otherwise, if the current block is the only predecessor insert selects // for any mismatched branch operands. - if (trueDest->getUniquePredecessor() != condbr.getOperation()->getBlock()) + if (trueDest->getUniquePredecessor() != condbr->getBlock()) return failure(); // Generate a select for any operands that differ between the two. @@ -1053,7 +1053,7 @@ LogicalResult matchAndRewrite(CondBranchOp condbr, PatternRewriter &rewriter) const override { // Check that we have a single distinct predecessor. - Block *currentBlock = condbr.getOperation()->getBlock(); + Block *currentBlock = condbr->getBlock(); Block *predecessor = currentBlock->getSinglePredecessor(); if (!predecessor) return failure(); @@ -2357,7 +2357,7 @@ /// ``` static void print(OpAsmPrinter &p, MemRefReinterpretCastOp op) { int stdDotLen = StandardOpsDialect::getDialectNamespace().size() + 1; - p << op.getOperation()->getName().getStringRef().drop_front(stdDotLen) << ' '; + p << op->getName().getStringRef().drop_front(stdDotLen) << ' '; p << op.source() << " "; printOffsetsSizesAndStrides( p, op, /*offsetPrefix=*/"to offset: ", /*sizePrefix=*/", sizes: ", @@ -3079,7 +3079,7 @@ /// ``` static void print(OpAsmPrinter &p, SubViewOp op) { int stdDotLen = StandardOpsDialect::getDialectNamespace().size() + 1; - p << op.getOperation()->getName().getStringRef().drop_front(stdDotLen) << ' '; + p << op->getName().getStringRef().drop_front(stdDotLen) << ' '; p << op.source(); printOffsetsSizesAndStrides(p, op); p << " : " << op.getSourceType() << " to " << op.getType(); @@ -3688,7 +3688,7 @@ /// ``` static void print(OpAsmPrinter &p, SubTensorOp op) { int stdDotLen = StandardOpsDialect::getDialectNamespace().size() + 1; - p << op.getOperation()->getName().getStringRef().drop_front(stdDotLen) << ' '; + p << op->getName().getStringRef().drop_front(stdDotLen) << ' '; p << op.source(); printOffsetsSizesAndStrides(p, op); p << " : " << op.getSourceType() << " to " << op.getType(); @@ -3802,7 +3802,7 @@ /// ``` static void print(OpAsmPrinter &p, SubTensorInsertOp op) { int stdDotLen = StandardOpsDialect::getDialectNamespace().size() + 1; - p << op.getOperation()->getName().getStringRef().drop_front(stdDotLen) << ' '; + p << op->getName().getStringRef().drop_front(stdDotLen) << ' '; p << op.source() << " into " << op.dest(); printOffsetsSizesAndStrides(p, op); p << " : " << op.getSourceType() << " into " << op.getType(); diff --git a/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp b/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp --- a/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp +++ b/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp @@ -67,7 +67,7 @@ symbolTable.insert(global); // The symbol table inserts at the end of the module, but globals are a bit // nicer if they are at the beginning. - global.getOperation()->moveBefore(&module.front()); + global->moveBefore(&module.front()); globals[op.getValue()] = global; }); } 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 @@ -2776,7 +2776,7 @@ p.printOperands(op.getOperands()); p.printOptionalAttrDict(op.getAttrs()); p << " : "; - llvm::interleaveComma(op.getOperation()->getOperandTypes(), p); + llvm::interleaveComma(op->getOperandTypes(), p); } static LogicalResult verify(TupleOp op) { return success(); } diff --git a/mlir/lib/Dialect/Vector/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/VectorTransforms.cpp --- a/mlir/lib/Dialect/Vector/VectorTransforms.cpp +++ b/mlir/lib/Dialect/Vector/VectorTransforms.cpp @@ -2162,7 +2162,7 @@ // Don't split transfer operations directly under IfOp, this avoids applying // the pattern recursively. // TODO: improve the filtering condition to make it more applicable. - if (isa(xferOp.getOperation()->getParentOp())) + if (isa(xferOp->getParentOp())) return failure(); return success(); } 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 @@ -155,8 +155,7 @@ newAttrs.insert(attr); for (auto &attr : getAttrs()) newAttrs.insert(attr); - dest.getOperation()->setAttrs( - DictionaryAttr::get(newAttrs.takeVector(), getContext())); + dest->setAttrs(DictionaryAttr::get(newAttrs.takeVector(), getContext())); // Clone the body. getBody().cloneInto(&dest.getBody(), mapper); diff --git a/mlir/lib/Parser/Parser.cpp b/mlir/lib/Parser/Parser.cpp --- a/mlir/lib/Parser/Parser.cpp +++ b/mlir/lib/Parser/Parser.cpp @@ -386,7 +386,7 @@ for (auto entry : forwardRefInCurrentScope) { errors.push_back({entry.second.getPointer(), entry.first}); // Add this block to the top-level region to allow for automatic cleanup. - moduleOp.getOperation()->getRegion(0).push_back(entry.first); + moduleOp->getRegion(0).push_back(entry.first); } llvm::array_pod_sort(errors.begin(), errors.end()); @@ -2032,7 +2032,7 @@ if (nested && std::next(operations.begin(), 2) == operations.end()) { // Merge the data of the nested module operation into 'module'. module.setLoc(nested.getLoc()); - module.setAttrs(nested.getOperation()->getMutableAttrDict()); + module.setAttrs(nested->getMutableAttrDict()); bodyBlocks.splice(bodyBlocks.end(), nested.getBodyRegion().getBlocks()); // Erase the original module body. diff --git a/mlir/lib/Transforms/Inliner.cpp b/mlir/lib/Transforms/Inliner.cpp --- a/mlir/lib/Transforms/Inliner.cpp +++ b/mlir/lib/Transforms/Inliner.cpp @@ -408,7 +408,7 @@ static bool shouldInline(ResolvedCall &resolvedCall) { // Don't allow inlining terminator calls. We currently don't support this // case. - if (resolvedCall.call.getOperation()->isKnownTerminator()) + if (resolvedCall.call->isKnownTerminator()) return false; // Don't allow inlining if the target is an ancestor of the call. This diff --git a/mlir/lib/Transforms/LoopFusion.cpp b/mlir/lib/Transforms/LoopFusion.cpp --- a/mlir/lib/Transforms/LoopFusion.cpp +++ b/mlir/lib/Transforms/LoopFusion.cpp @@ -1541,7 +1541,7 @@ // Move 'dstAffineForOp' before 'insertPointInst' if needed. if (insertPointInst != dstAffineForOp.getOperation()) - dstAffineForOp.getOperation()->moveBefore(insertPointInst); + dstAffineForOp->moveBefore(insertPointInst); // Update edges between 'srcNode' and 'dstNode'. mdg->updateEdges(srcNode->id, dstNode->id, memref, @@ -1732,7 +1732,7 @@ auto dstForInst = cast(dstNode->op); // Update operation position of fused loop nest (if needed). if (insertPointInst != dstForInst.getOperation()) { - dstForInst.getOperation()->moveBefore(insertPointInst); + dstForInst->moveBefore(insertPointInst); } // Update data dependence graph state post fusion. updateStateAfterSiblingFusion(sibNode, dstNode); diff --git a/mlir/lib/Transforms/SCCP.cpp b/mlir/lib/Transforms/SCCP.cpp --- a/mlir/lib/Transforms/SCCP.cpp +++ b/mlir/lib/Transforms/SCCP.cpp @@ -435,7 +435,7 @@ // We only need to record the call in the lattice if it produces any // values. - if (callOp.getOperation()->getNumResults()) + if (callOp->getNumResults()) callableLatticeIt->second.addSymbolCall(callOp); } continue; @@ -572,7 +572,7 @@ } void SCCPSolver::visitCallOperation(CallOpInterface op) { - ResultRange callResults = op.getOperation()->getResults(); + ResultRange callResults = op->getResults(); // Resolve the callable operation for this call. Operation *callableOp = nullptr; diff --git a/mlir/lib/Transforms/Utils/InliningUtils.cpp b/mlir/lib/Transforms/Utils/InliningUtils.cpp --- a/mlir/lib/Transforms/Utils/InliningUtils.cpp +++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp @@ -307,7 +307,7 @@ // Make sure that the number of arguments and results matchup between the call // and the region. SmallVector callOperands(call.getArgOperands()); - SmallVector callResults(call.getOperation()->getResults()); + SmallVector callResults(call->getResults()); if (callOperands.size() != entryBlock->getNumArguments() || callResults.size() != callableResultTypes.size()) return failure(); diff --git a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp --- a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp @@ -137,7 +137,7 @@ static Operation *getFusedLoopNestInsertionPoint(AffineForOp srcForOp, AffineForOp dstForOp) { bool isSrcForOpBeforeDstForOp = - srcForOp.getOperation()->isBeforeInBlock(dstForOp.getOperation()); + srcForOp->isBeforeInBlock(dstForOp.getOperation()); auto forOpA = isSrcForOpBeforeDstForOp ? srcForOp : dstForOp; auto forOpB = isSrcForOpBeforeDstForOp ? dstForOp : srcForOp; @@ -270,8 +270,8 @@ return FusionResult::FailPrecondition; } // Return 'failure' if 'srcForOp' and 'dstForOp' are not in the same block. - auto *block = srcForOp.getOperation()->getBlock(); - if (block != dstForOp.getOperation()->getBlock()) { + auto *block = srcForOp->getBlock(); + if (block != dstForOp->getBlock()) { LLVM_DEBUG(llvm::dbgs() << "Cannot fuse loop nests in different blocks\n"); return FusionResult::FailPrecondition; } @@ -285,7 +285,7 @@ // Check if 'srcForOp' precedes 'dstForOp' in 'block'. bool isSrcForOpBeforeDstForOp = - srcForOp.getOperation()->isBeforeInBlock(dstForOp.getOperation()); + srcForOp->isBeforeInBlock(dstForOp.getOperation()); // 'forOpA' executes before 'forOpB' in 'block'. auto forOpA = isSrcForOpBeforeDstForOp ? srcForOp : dstForOp; auto forOpB = isSrcForOpBeforeDstForOp ? dstForOp : srcForOp; diff --git a/mlir/lib/Transforms/Utils/LoopUtils.cpp b/mlir/lib/Transforms/Utils/LoopUtils.cpp --- a/mlir/lib/Transforms/Utils/LoopUtils.cpp +++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp @@ -160,7 +160,7 @@ // Replaces all IV uses to its single iteration value. auto iv = forOp.getInductionVar(); - auto *parentBlock = forOp.getOperation()->getBlock(); + auto *parentBlock = forOp->getBlock(); if (!iv.use_empty()) { if (forOp.hasConstantLowerBound()) { OpBuilder topBuilder(forOp.getParentOfType().getBody()); @@ -220,7 +220,7 @@ // Move the loop body operations, except for its terminator, to the loop's // containing block. - auto *parentBlock = forOp.getOperation()->getBlock(); + auto *parentBlock = forOp->getBlock(); forOp.getBody()->getTerminator()->erase(); parentBlock->getOperations().splice(Block::iterator(forOp), forOp.getBody()->getOperations()); @@ -439,7 +439,7 @@ // We first find out all dependences we intend to check. SmallVector loadAndStoreOps; - origLoops[0].getOperation()->walk([&](Operation *op) { + origLoops[0]->walk([&](Operation *op) { if (isa(op)) loadAndStoreOps.push_back(op); }); @@ -1124,8 +1124,7 @@ // Generate the cleanup loop if trip count isn't a multiple of unrollFactor. if (getLargestDivisorOfTripCount(forOp) % unrollFactor != 0) { - OpBuilder builder(forOp.getOperation()->getBlock(), - std::next(Block::iterator(forOp))); + OpBuilder builder(forOp->getBlock(), std::next(Block::iterator(forOp))); auto cleanupForOp = cast(builder.clone(*forOp)); AffineMap cleanupMap; SmallVector cleanupOperands; @@ -1234,7 +1233,7 @@ // Create epilogue clean up loop starting at 'upperBoundUnrolled'. if (generateEpilogueLoop) { - OpBuilder epilogueBuilder(forOp.getOperation()->getBlock(), + OpBuilder epilogueBuilder(forOp->getBlock(), std::next(Block::iterator(forOp))); auto epilogueForOp = cast(epilogueBuilder.clone(*forOp)); epilogueForOp.setLowerBound(upperBoundUnrolled); @@ -1246,8 +1245,7 @@ for (auto e : llvm::zip(results, epilogueResults, epilogueIterOperands)) { std::get<0>(e).replaceAllUsesWith(std::get<1>(e)); - epilogueForOp.getOperation()->replaceUsesOfWith(std::get<2>(e), - std::get<0>(e)); + epilogueForOp->replaceUsesOfWith(std::get<2>(e), std::get<0>(e)); } promoteIfSingleIteration(epilogueForOp); } @@ -1348,8 +1346,7 @@ // unrollJamFactor. if (getLargestDivisorOfTripCount(forOp) % unrollJamFactor != 0) { // Insert the cleanup loop right after 'forOp'. - OpBuilder builder(forOp.getOperation()->getBlock(), - std::next(Block::iterator(forOp))); + OpBuilder builder(forOp->getBlock(), std::next(Block::iterator(forOp))); auto cleanupAffineForOp = cast(builder.clone(*forOp)); // Adjust the lower bound of the cleanup loop; its upper bound is the same // as the original loop's upper bound. @@ -1412,16 +1409,15 @@ // 1) Splice forOpA's non-terminator operations (which is just forOpB) just // before forOpA (in ForOpA's parent's block) this should leave 'forOpA's // body containing only the terminator. - forOpA.getOperation()->getBlock()->getOperations().splice( - Block::iterator(forOpA), forOpABody, forOpABody.begin(), - std::prev(forOpABody.end())); + forOpA->getBlock()->getOperations().splice(Block::iterator(forOpA), + forOpABody, forOpABody.begin(), + std::prev(forOpABody.end())); // 2) Splice forOpB's non-terminator operations into the beginning of forOpA's // body (this leaves forOpB's body containing only the terminator). forOpABody.splice(forOpABody.begin(), forOpBBody, forOpBBody.begin(), std::prev(forOpBBody.end())); // 3) Splice forOpA into the beginning of forOpB's body. - forOpBBody.splice(forOpBBody.begin(), - forOpA.getOperation()->getBlock()->getOperations(), + forOpBBody.splice(forOpBBody.begin(), forOpA->getBlock()->getOperations(), Block::iterator(forOpA)); } @@ -1543,11 +1539,10 @@ if (i == 0) continue; // Make input[i] the new outermost loop moving it into parentBlock. - auto *parentBlock = input[0].getOperation()->getBlock(); - parentBlock->getOperations().splice( - Block::iterator(input[0]), - input[i].getOperation()->getBlock()->getOperations(), - Block::iterator(input[i])); + auto *parentBlock = input[0]->getBlock(); + parentBlock->getOperations().splice(Block::iterator(input[0]), + input[i]->getBlock()->getOperations(), + Block::iterator(input[i])); continue; } @@ -1559,9 +1554,9 @@ // Move input[i] to its surrounding loop in the transformed nest. auto *destBody = input[parentPosInInput].getBody(); - destBody->getOperations().splice( - destBody->begin(), input[i].getOperation()->getBlock()->getOperations(), - Block::iterator(input[i])); + destBody->getOperations().splice(destBody->begin(), + input[i]->getBlock()->getOperations(), + Block::iterator(input[i])); } return invPermMap[0].second; @@ -1657,8 +1652,7 @@ auto scaledStep = originalStep * factor; forOp.setStep(scaledStep); - OpBuilder b(forOp.getOperation()->getBlock(), - std::next(Block::iterator(forOp))); + OpBuilder b(forOp->getBlock(), std::next(Block::iterator(forOp))); // Lower-bound map creation. auto lbMap = forOp.getLowerBoundMap(); @@ -2167,7 +2161,7 @@ auto lastInvariantIV = *std::prev(it); *copyInPlacementStart = Block::iterator(lastInvariantIV.getOperation()); *copyOutPlacementStart = std::next(*copyInPlacementStart); - *copyPlacementBlock = lastInvariantIV.getOperation()->getBlock(); + *copyPlacementBlock = lastInvariantIV->getBlock(); } else { *copyInPlacementStart = begin; *copyOutPlacementStart = end; @@ -3107,16 +3101,15 @@ AffineForOp outermostFullTileLoop = fullTileLoops[0]; thenBlock->getOperations().splice( std::prev(thenBlock->end()), - outermostFullTileLoop.getOperation()->getBlock()->getOperations(), + outermostFullTileLoop->getBlock()->getOperations(), Block::iterator(outermostFullTileLoop)); // Move the partial tile into the else block. The partial tile is the same as // the original loop nest. Block *elseBlock = ifOp.getElseBlock(); - elseBlock->getOperations().splice( - std::prev(elseBlock->end()), - firstLoop.getOperation()->getBlock()->getOperations(), - Block::iterator(firstLoop)); + elseBlock->getOperations().splice(std::prev(elseBlock->end()), + firstLoop->getBlock()->getOperations(), + Block::iterator(firstLoop)); if (fullTileNest) *fullTileNest = std::move(fullTileLoops); diff --git a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp --- a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp +++ b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp @@ -32,7 +32,7 @@ Dialect *spvDialect = getContext().getLoadedDialect("spv"); - f.getOperation()->walk([&](Operation *op) { + f->walk([&](Operation *op) { if (op->getDialect() != spvDialect) return WalkResult::advance(); diff --git a/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp b/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp --- a/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp +++ b/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp @@ -128,7 +128,7 @@ SmallVector linalgOps; f.walk([&](LinalgOp op) { // TODO: support multi-results. - if (op.getOperation()->getNumResults() <= 1) + if (op->getNumResults() <= 1) linalgOps.push_back(op); }); diff --git a/mlir/test/lib/Transforms/TestLoopFusion.cpp b/mlir/test/lib/Transforms/TestLoopFusion.cpp --- a/mlir/test/lib/Transforms/TestLoopFusion.cpp +++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp @@ -59,8 +59,8 @@ FusionResult result = mlir::canFuseLoops(srcForOp, dstForOp, d, &sliceUnion); if (result.value == FusionResult::FailBlockDependence) { - srcForOp.getOperation()->emitRemark("block-level dependence preventing" - " fusion of loop nest ") + srcForOp->emitRemark("block-level dependence preventing" + " fusion of loop nest ") << i << " into loop nest " << j << " at depth " << loopDepth; } } @@ -110,7 +110,7 @@ mlir::ComputationSliceState sliceUnion; FusionResult result = mlir::canFuseLoops(forOpA, forOpB, d, &sliceUnion); if (result.value == FusionResult::Success) { - forOpB.getOperation()->emitRemark("slice (") + forOpB->emitRemark("slice (") << " src loop: " << i << ", dst loop: " << j << ", depth: " << d << " : " << getSliceStr(sliceUnion) << ")"; } 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 @@ -2138,10 +2138,8 @@ { auto *constructor = adaptor.addConstructorAndPrune( llvm::formatv("{0}&", op.getCppClassName()).str(), "op"); - constructor->addMemberInitializer("odsOperands", - "op.getOperation()->getOperands()"); - constructor->addMemberInitializer("odsAttrs", - "op.getOperation()->getAttrDictionary()"); + constructor->addMemberInitializer("odsOperands", "op->getOperands()"); + constructor->addMemberInitializer("odsAttrs", "op->getAttrDictionary()"); } std::string sizeAttrInit = diff --git a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp --- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp +++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp @@ -562,9 +562,7 @@ if (areOperandsAheadOfAttrs) { if (op.getNumOperands() != 0) { os << tabs - << formatv( - "for (Value operand : {0}.getOperation()->getOperands()) {{\n", - opVar); + << formatv("for (Value operand : {0}->getOperands()) {{\n", opVar); os << tabs << " auto id = getValueID(operand);\n"; os << tabs << " assert(id && \"use before def!\");\n"; os << tabs << formatv(" {0}.push_back(id);\n", operands);