[llvm-branch-commits] [mlir] c4a0405 - Add `Operation* OpState::operator->()` to provide more convenient access to members of Operation.
Christian Sigg via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Dec 2 06:51:15 PST 2020
Author: Christian Sigg
Date: 2020-12-02T15:46:20+01:00
New Revision: c4a04059026b98e8c23981f1195a61494a661cdb
URL: https://github.com/llvm/llvm-project/commit/c4a04059026b98e8c23981f1195a61494a661cdb
DIFF: https://github.com/llvm/llvm-project/commit/c4a04059026b98e8c23981f1195a61494a661cdb.diff
LOG: Add `Operation* OpState::operator->()` to provide more convenient access to members of Operation.
Given that OpState already implicit converts to Operator*, this seems reasonable.
The alternative would be to add more functions to OpState which forward to Operation.
Reviewed By: rriddle, ftynse
Differential Revision: https://reviews.llvm.org/D92266
Added:
Modified:
mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
mlir/include/mlir/Dialect/Vector/VectorTransforms.h
mlir/include/mlir/IR/OpDefinition.h
mlir/include/mlir/Interfaces/VectorInterfaces.td
mlir/lib/Analysis/AffineAnalysis.cpp
mlir/lib/Analysis/BufferAliasAnalysis.cpp
mlir/lib/Analysis/Utils.cpp
mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
mlir/lib/Dialect/Affine/IR/AffineOps.cpp
mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp
mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
mlir/lib/Dialect/Affine/Utils/Utils.cpp
mlir/lib/Dialect/Async/Transforms/AsyncRefCountingOptimization.cpp
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
mlir/lib/Dialect/PDL/IR/PDL.cpp
mlir/lib/Dialect/SCF/SCF.cpp
mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp
mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp
mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp
mlir/lib/Dialect/Vector/VectorOps.cpp
mlir/lib/Dialect/Vector/VectorTransforms.cpp
mlir/lib/IR/BuiltinDialect.cpp
mlir/lib/Parser/Parser.cpp
mlir/lib/Transforms/Inliner.cpp
mlir/lib/Transforms/LoopFusion.cpp
mlir/lib/Transforms/SCCP.cpp
mlir/lib/Transforms/Utils/InliningUtils.cpp
mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
mlir/lib/Transforms/Utils/LoopUtils.cpp
mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
mlir/test/lib/Transforms/TestLoopFusion.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
Removed:
################################################################################
diff --git a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
index 6daccaef7cd3..46d8fe40e5d4 100644
--- a/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
+++ b/mlir/examples/toy/Ch5/mlir/LowerToAffineLoops.cpp
@@ -39,13 +39,13 @@ static Value insertAllocAndDealloc(MemRefType type, Location loc,
auto alloc = rewriter.create<AllocOp>(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<DeallocOp>(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
index 14f68e6176b5..2089b6579ccb 100644
--- a/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
+++ b/mlir/examples/toy/Ch6/mlir/LowerToAffineLoops.cpp
@@ -39,13 +39,13 @@ static Value insertAllocAndDealloc(MemRefType type, Location loc,
auto alloc = rewriter.create<AllocOp>(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<DeallocOp>(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
index 6daccaef7cd3..46d8fe40e5d4 100644
--- a/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
+++ b/mlir/examples/toy/Ch7/mlir/LowerToAffineLoops.cpp
@@ -39,13 +39,13 @@ static Value insertAllocAndDealloc(MemRefType type, Location loc,
auto alloc = rewriter.create<AllocOp>(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<DeallocOp>(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
index 6c7da083d7af..fcf3e86a014d 100644
--- a/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
+++ b/mlir/include/mlir/Dialect/Linalg/IR/LinalgStructuredOpsInterface.td
@@ -848,11 +848,11 @@ def LinalgStructuredInterface : OpInterface<"LinalgOp"> {
"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
index 5c2edecdbc7e..cc0b2841d3f1 100644
--- a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h
+++ b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h
@@ -150,7 +150,7 @@ struct UnrollVectorPattern : public OpRewritePattern<OpTy> {
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
index e594c7ff1d20..2867c4c73290 100644
--- a/mlir/include/mlir/IR/OpDefinition.h
+++ b/mlir/include/mlir/IR/OpDefinition.h
@@ -102,6 +102,9 @@ class OpState {
/// 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
index b60b6b39a2b7..73332afd8825 100644
--- a/mlir/include/mlir/Interfaces/VectorInterfaces.td
+++ b/mlir/include/mlir/Interfaces/VectorInterfaces.td
@@ -33,7 +33,7 @@ def VectorUnrollOpInterface : OpInterface<"VectorUnrollOpInterface"> {
/*args=*/(ins),
/*methodBody=*/"",
/*defaultImplementation=*/[{
- assert($_op.getOperation()->getNumResults() == 1);
+ assert($_op->getNumResults() == 1);
auto vt = $_op.getResult().getType().
template dyn_cast<VectorType>();
if (!vt)
diff --git a/mlir/lib/Analysis/AffineAnalysis.cpp b/mlir/lib/Analysis/AffineAnalysis.cpp
index 434dd12ee7f1..b49e532eec4d 100644
--- a/mlir/lib/Analysis/AffineAnalysis.cpp
+++ b/mlir/lib/Analysis/AffineAnalysis.cpp
@@ -954,7 +954,7 @@ void mlir::getDependenceComponents(
std::vector<SmallVector<DependenceComponent, 2>> *depCompsVec) {
// Collect all load and store ops in loop nest rooted at 'forOp'.
SmallVector<Operation *, 8> loadAndStoreOps;
- forOp.getOperation()->walk([&](Operation *op) {
+ forOp->walk([&](Operation *op) {
if (isa<AffineReadOpInterface, AffineWriteOpInterface>(op))
loadAndStoreOps.push_back(op);
});
diff --git a/mlir/lib/Analysis/BufferAliasAnalysis.cpp b/mlir/lib/Analysis/BufferAliasAnalysis.cpp
index 9d5def4aad23..4aac77ae49ed 100644
--- a/mlir/lib/Analysis/BufferAliasAnalysis.cpp
+++ b/mlir/lib/Analysis/BufferAliasAnalysis.cpp
@@ -58,13 +58,12 @@ void BufferAliasAnalysis::build(Operation *op) {
// 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 @@ void BufferAliasAnalysis::build(Operation *op) {
}
// 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<RegionSuccessor, 2> successorRegions;
diff --git a/mlir/lib/Analysis/Utils.cpp b/mlir/lib/Analysis/Utils.cpp
index 35678432dd16..b51966858175 100644
--- a/mlir/lib/Analysis/Utils.cpp
+++ b/mlir/lib/Analysis/Utils.cpp
@@ -872,8 +872,7 @@ mlir::insertBackwardComputationSlice(Operation *srcOpInst, Operation *dstOpInst,
// Find the op block positions of 'srcOpInst' within 'srcLoopIVs'.
SmallVector<unsigned, 4> 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 @@ Optional<int64_t> mlir::getMemoryFootprintBytes(AffineForOp forOp,
/// at 'forOp'.
void mlir::getSequentialLoops(AffineForOp forOp,
llvm::SmallDenseSet<Value, 8> *sequentialLoops) {
- forOp.getOperation()->walk([&](Operation *op) {
+ forOp->walk([&](Operation *op) {
if (auto innerFor = dyn_cast<AffineForOp>(op))
if (!isLoopParallel(innerFor))
sequentialLoops->insert(innerFor.getInductionVar());
diff --git a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
index 616be4842823..c1daf485501e 100644
--- a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
+++ b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
@@ -58,8 +58,7 @@ matchAndRewriteOneToOne(const ConvertToLLVMPattern &lowering,
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 @@ matchAndRewriteOneToOne(const ConvertToLLVMPattern &lowering,
for (unsigned i = 0; i < numResults; ++i) {
auto type = typeConverter.convertType(op->getResult(i).getType());
results.push_back(rewriter.create<LLVM::ExtractValueOp>(
- 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
index a8e282901f83..edfbdc907551 100644
--- a/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
+++ b/mlir/lib/Conversion/GPUCommon/ConvertLaunchFuncToRuntimeCalls.cpp
@@ -365,8 +365,7 @@ LogicalResult ConvertAllocOpToGpuRuntimeCallPattern::matchAndRewrite(
// 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 @@ LogicalResult ConvertDeallocOpToGpuRuntimeCallPattern::matchAndRewrite(
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<LLVM::BitcastOp>(loc, llvmPointerType, pointer);
@@ -451,7 +450,7 @@ LogicalResult ConvertWaitAsyncOpToGpuRuntimeCallPattern::matchAndRewrite(
} 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 @@ LogicalResult ConvertLaunchFuncOpToGpuRuntimeCallPattern::matchAndRewrite(
loc, rewriter, {module.getResult(0), kernelName});
auto zero = rewriter.create<LLVM::ConstantOp>(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
index 3c2596ae2425..a225699e89f7 100644
--- a/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
+++ b/mlir/lib/Conversion/PDLToPDLInterp/PDLToPDLInterp.cpp
@@ -580,7 +580,7 @@ void PatternLowering::generateOperationResultTypeRewriter(
DenseMap<Value, Value> &rewriteValues,
function_ref<Value(Value)> 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
index 01e7623e8a49..906ee8bafbbb 100644
--- a/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
+++ b/mlir/lib/Conversion/SCFToOpenMP/SCFToOpenMP.cpp
@@ -76,9 +76,9 @@ static void insertOpenMPParallel(FuncOp func) {
auto omp = builder.create<omp::ParallelOp>(parallelOp.getLoc());
Block *block = builder.createBlock(&omp.getRegion());
builder.create<omp::TerminatorOp>(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
index 4e0c9d2109a1..1030f0dbd288 100644
--- a/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
+++ b/mlir/lib/Conversion/SCFToSPIRV/SCFToSPIRV.cpp
@@ -160,7 +160,7 @@ ForOpConversion::matchAndRewrite(scf::ForOp forOp, ArrayRef<Value> operands,
// 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<Value, 8> args(1, forOperands.lowerBound());
diff --git a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
index c19f53c4e999..beecf7541b0e 100644
--- a/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
+++ b/mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
@@ -2293,8 +2293,8 @@ struct CallOpInterfaceLowering : public ConvertOpToLLVMPattern<CallOpType> {
}
auto promoted = this->typeConverter.promoteOperands(
- callOp.getLoc(), /*opOperands=*/callOp.getOperation()->getOperands(),
- operands, rewriter);
+ callOp.getLoc(), /*opOperands=*/callOp->getOperands(), operands,
+ rewriter);
auto newOp = rewriter.create<LLVM::CallOp>(
callOp.getLoc(), packedResult ? TypeRange(packedResult) : TypeRange(),
promoted, callOp.getAttrs());
@@ -2311,7 +2311,7 @@ struct CallOpInterfaceLowering : public ConvertOpToLLVMPattern<CallOpType> {
auto type =
this->typeConverter.convertType(callOp.getResult(i).getType());
results.push_back(rewriter.create<LLVM::ExtractValueOp>(
- callOp.getLoc(), type, newOp.getOperation()->getResult(0),
+ callOp.getLoc(), type, newOp->getResult(0),
rewriter.getI64ArrayAttr(i)));
}
}
@@ -2673,8 +2673,8 @@ struct MemRefReinterpretCastOpLowering
LogicalResult
matchAndRewrite(MemRefReinterpretCastOp castOp, ArrayRef<Value> 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 @@ struct OneToOneLLVMTerminatorLowering
LogicalResult
matchAndRewrite(SourceOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const override {
- rewriter.replaceOpWithNewOp<TargetOp>(
- op, operands, op.getOperation()->getSuccessors(), op.getAttrs());
+ rewriter.replaceOpWithNewOp<TargetOp>(op, operands, op->getSuccessors(),
+ op.getAttrs());
return success();
}
};
@@ -3251,7 +3251,7 @@ struct ReturnOpLowering : public ConvertOpToLLVMPattern<ReturnOp> {
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<MemRefType>()) {
@@ -3837,7 +3837,7 @@ struct GenericAtomicRMWOpLowering
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
index ac8b82dde9b1..6abc82530ae6 100644
--- a/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
+++ b/mlir/lib/Conversion/StandardToSPIRV/ConvertStandardToSPIRV.cpp
@@ -169,7 +169,7 @@ static Value adjustAccessChainForBitwidth(SPIRVTypeConverter &typeConverter,
IntegerAttr attr =
builder.getIntegerAttr(targetType, targetBits / sourceBits);
auto idx = builder.create<spirv::ConstantOp>(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 @@ IntLoadOpPattern::matchAndRewrite(LoadOp loadOp, ArrayRef<Value> operands,
// 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<spirv::ShiftRightArithmeticOp>(
loc, spvLoadOp.getType(), spvLoadOp, offset);
@@ -991,8 +990,7 @@ IntStoreOpPattern::matchAndRewrite(StoreOp storeOp, ArrayRef<Value> operands,
// 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
index b83807475f34..7c3d1b762d7e 100644
--- a/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
+++ b/mlir/lib/Dialect/Affine/IR/AffineOps.cpp
@@ -628,7 +628,7 @@ AffineApplyNormalizer::AffineApplyNormalizer(AffineMap map,
auto affineApply = t.getDefiningOp<AffineApplyOp>();
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<Value, 8> affineApplyOperands(
diff --git a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp
index 133fef4f0a3f..199747342987 100644
--- a/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/AffineLoopInvariantCodeMotion.cpp
@@ -216,7 +216,7 @@ void LoopInvariantCodeMotion::runOnAffineForOp(AffineForOp forOp) {
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 @@ void LoopInvariantCodeMotion::runOnFunction() {
// 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
index 52256deb10bf..d8b535057f6e 100644
--- a/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
+++ b/mlir/lib/Dialect/Affine/Transforms/SuperVectorize.cpp
@@ -1347,7 +1347,7 @@ verifyLoopNesting(const std::vector<SmallVector<AffineForOp, 2>> &loops) {
// 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 @@ verifyLoopNesting(const std::vector<SmallVector<AffineForOp, 2>> &loops) {
// 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
index 75e933f0b984..7892dfbc7a48 100644
--- a/mlir/lib/Dialect/Affine/Utils/Utils.cpp
+++ b/mlir/lib/Dialect/Affine/Utils/Utils.cpp
@@ -29,7 +29,7 @@ static void promoteIfBlock(AffineIfOp ifOp, bool elseBlock) {
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
index cbcb30c5276a..f6bc8e21cc29 100644
--- a/mlir/lib/Dialect/Async/Transforms/AsyncRefCountingOptimization.cpp
+++ b/mlir/lib/Dialect/Async/Transforms/AsyncRefCountingOptimization.cpp
@@ -122,7 +122,7 @@ AsyncRefCountingOptimizationPass::optimizeReferenceCounting(Value value) {
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
index 7e92b18a2e15..4f00a3257b25 100644
--- a/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
+++ b/mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
@@ -836,7 +836,7 @@ static void print(OpAsmPrinter &p, GPUModuleOp op) {
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
index d504530a9ad7..c7be304236c3 100644
--- a/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
+++ b/mlir/lib/Dialect/GPU/Transforms/KernelOutlining.cpp
@@ -239,7 +239,7 @@ class GpuKernelOutliningPass
bool modified = false;
for (auto func : getOperation().getOps<FuncOp>()) {
// 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<Value> operands;
std::string kernelFnName =
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
index 04eccf55b34a..b36d74bad3fb 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Bufferize.cpp
@@ -48,7 +48,7 @@ allocateBuffersForResults(Location loc, LinalgOp linalgOp,
SmallVector<Range, 4> 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 @@ class SubTensorOpConverter : public OpConversionPattern<SubTensorOp> {
LogicalResult
matchAndRewrite(SubTensorOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const final {
- SubTensorOpAdaptor adaptor(operands,
- op.getOperation()->getAttrDictionary());
+ SubTensorOpAdaptor adaptor(operands, op->getAttrDictionary());
Value sourceMemref = adaptor.source();
assert(sourceMemref.getType().isa<MemRefType>());
@@ -293,8 +292,7 @@ class SubTensorInsertOpConverter
LogicalResult
matchAndRewrite(SubTensorInsertOp op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const final {
- SubTensorInsertOpAdaptor adaptor(operands,
- op.getOperation()->getAttrDictionary());
+ SubTensorInsertOpAdaptor adaptor(operands, op->getAttrDictionary());
Value sourceMemRef = adaptor.source();
assert(sourceMemRef.getType().isa<MemRefType>());
diff --git a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
index 2696c4b52d3a..bf488f827f89 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/DropUnitDims.cpp
@@ -158,7 +158,7 @@ LogicalResult replaceBlockArgForUnitDimLoops<IndexedGenericOp>(
IndexedGenericOp op, const DenseSet<unsigned> &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<ConstantIndexOp>(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
index 6ed17c744f8c..681309687d18 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Fusion.cpp
@@ -118,7 +118,7 @@ static LinalgOp cloneWithLoopRanges(OpBuilder &b, Location loc, LinalgOp op,
// Since we do not enforce any canonicalizations on the fly, this is always
// fully dynamic at construction time.
SmallVector<Type, 4> resultTypes;
- resultTypes.reserve(op.getOperation()->getNumResults());
+ resultTypes.reserve(op->getNumResults());
for (RankedTensorType t : op.getOutputTensorTypes()) {
unsigned rank = t.getRank();
SmallVector<int64_t, 4> staticOffsetsVector(
@@ -288,8 +288,7 @@ static bool isStructurallyFusableProducer(LinalgOp producer, Value consumedView,
}
// 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 @@ mlir::linalg::fuseProducerOfBuffer(OpBuilder &b, LinalgOp consumer,
LinalgOp producerOp = cast<LinalgOp>(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 @@ Optional<FusionInfo> mlir::linalg::fuseProducerOfTensor(OpBuilder &b,
}
// 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 @@ Optional<FusionInfo> mlir::linalg::fuseProducerOfTensor(OpBuilder &b,
// `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<TensorCastOp>(fusedProducer.getLoc(), consumerType, def);
@@ -746,8 +743,7 @@ FusableOpDependencesTy mlir::linalg::findAllFusableDependences(
// 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
diff erent basic blocks");
return FusableOpDependencesTy{};
}
diff --git a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
index d2a8a307a5ba..fea80fac76a5 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/FusionOnTensors.cpp
@@ -93,8 +93,8 @@ static void generateFusedTensorOpRegion(PatternRewriter &rewriter,
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 @@ fuseTensorOpsImpl(LinalgOp producer, LinalgOp consumer, unsigned consumerIdx,
LinalgOp fusedOp;
if (isa<GenericOp>(producer.getOperation()) &&
isa<GenericOp>(consumer.getOperation())) {
- fusedOp = rewriter
- .create<GenericOp>(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<IndexedGenericOp>(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<GenericOp>(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<IndexedGenericOp>(
+ 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 @@ fuseTensorOpsImpl(LinalgOp producer, LinalgOp consumer, unsigned consumerIdx,
generateFusedTensorOpRegion(rewriter, fusedOp.getOperation(), producer,
consumer, consumerToProducerLoopsMap, consumerIdx,
consumer.getNumLoops());
- return SmallVector<Value, 1>(fusedOp.getOperation()->getResults());
+ return SmallVector<Value, 1>(fusedOp->getResults());
}
/// Linearize the expressions in `sourceMap` based on the `reassociationMaps`
@@ -558,7 +557,7 @@ fuseWithReshapeByExpansion(LinalgOp linalgOp, TensorReshapeOp reshapeOp,
}
SmallVector<Type, 1> resultTypes;
SmallVector<SmallVector<ReassociationIndices, 4>, 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<ReassociationIndices, 4> reassociation;
@@ -579,8 +578,8 @@ fuseWithReshapeByExpansion(LinalgOp linalgOp, TensorReshapeOp reshapeOp,
/*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<GenericOp>(linalgOp.getOperation())) {
rewriter.cloneRegionBefore(originalRegion, fusedRegion,
@@ -634,15 +633,15 @@ fuseWithReshapeByExpansion(LinalgOp linalgOp, TensorReshapeOp reshapeOp,
// Reshape the result values to their original shape if this is a collapsing
// reshape folded into its consumer.
SmallVector<Value, 1> 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<TensorReshapeOp>(
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 @@ struct FoldProducerReshapeOpByLinearization
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 @@ struct FoldConsumerReshapeOpByLinearization
/*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 @@ struct FoldSplatConstants : public OpRewritePattern<LinalgOpTy> {
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 @@ struct FoldSplatConstants : public OpRewritePattern<LinalgOpTy> {
// 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 @@ struct FuseTensorOps : public OpRewritePattern<LinalgOpTy> {
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<unsigned>(0, op.getOperation()->getNumOperands())) {
- Operation *producer =
- op.getOperation()->getOperand(operandNum).getDefiningOp();
+ for (auto operandNum : llvm::seq<unsigned>(0, op->getNumOperands())) {
+ Operation *producer = op->getOperand(operandNum).getDefiningOp();
if (!producer)
continue;
Optional<SmallVector<Value, 1>> fusedOpResults =
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
index d292f4d9782e..9aeb39e6b565 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Hoisting.cpp
@@ -175,7 +175,7 @@ void mlir::linalg::hoistRedundantVectorTransfers(FuncOp func) {
"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
index 3435820aab40..d4529792624c 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Loops.cpp
@@ -65,10 +65,9 @@ template <typename IndexedValueType, typename OpType>
static void inlineRegionAndEmitStore(OpType op, ArrayRef<Value> indexedValues,
ArrayRef<SmallVector<Value, 8>> indexing,
ArrayRef<Value> 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
index a824f6eb620f..2410df85ad61 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Promotion.cpp
@@ -345,7 +345,7 @@ promoteSubViews(OpBuilder &b, LinalgOp op,
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
index 197bdbc1a99f..2fd7597e9b10 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Tiling.cpp
@@ -414,7 +414,7 @@ tileLinalgOpImpl(OpBuilder &b, LinalgOp op, ValueRange tileSizes,
// 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 @@ tileLinalgOpImpl(OpBuilder &b, LinalgOp op, ValueRange tileSizes,
tiledOperands[op.getNumInputsAndOutputBuffers() + idx];
if (auto subtensor = initTensor.getDefiningOp<SubTensorOp>()) {
tensorResults.push_back(b.create<SubTensorInsertOp>(
- 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
index a855c07cb8d4..97c3dafe57a8 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -128,7 +128,7 @@ LogicalResult mlir::linalg::LinalgBaseTilingPattern::matchAndRewriteBase(
// 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<TiledLinalgOp> res = tileLinalgOp(rewriter, linalgOp, options);
diff --git a/mlir/lib/Dialect/PDL/IR/PDL.cpp b/mlir/lib/Dialect/PDL/IR/PDL.cpp
index ba1eb7b99574..d8baac0d0c39 100644
--- a/mlir/lib/Dialect/PDL/IR/PDL.cpp
+++ b/mlir/lib/Dialect/PDL/IR/PDL.cpp
@@ -219,7 +219,7 @@ static LogicalResult verifyResultTypesAreInferrable(OperationOp op,
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
index 48b1b473f86d..5bff924b8e7d 100644
--- a/mlir/lib/Dialect/SCF/SCF.cpp
+++ b/mlir/lib/Dialect/SCF/SCF.cpp
@@ -732,8 +732,8 @@ struct RemoveUnusedResults : public OpRewritePattern<IfOp> {
[&](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
index cbdf78cad51d..f2fc78e4290e 100644
--- a/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/ParallelLoopFusion.cpp
@@ -59,7 +59,7 @@ static bool haveNoReadsAfterWriteExceptSameIndex(
// 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
index 4ad6d4116a76..bf9f797a118e 100644
--- a/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/StructuralTypeConversions.cpp
@@ -63,7 +63,7 @@ class ConvertForOpTypes : public OpConversionPattern<ForOp> {
}
// 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 @@ class ConvertIfOpTypes : public OpConversionPattern<IfOp> {
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
index 2df9e56a6940..c9ba8a353990 100644
--- a/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
+++ b/mlir/lib/Dialect/SPIRV/Linking/ModuleCombiner/ModuleCombiner.cpp
@@ -84,9 +84,9 @@ emplaceOrGetReplacementSymbol(KeyTy key, SymbolOpTy symbolOp,
/// 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
index a356a391d72b..bc965d1db6aa 100644
--- a/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
+++ b/mlir/lib/Dialect/SPIRV/SPIRVCanonicalization.cpp
@@ -324,7 +324,7 @@ struct ConvertSelectionOpToSelect
auto falseValue = getSrcValue(falseBlock);
auto ptrValue = getDstPtr(trueBlock);
auto storeOpAttributes =
- cast<spirv::StoreOp>(trueBlock->front()).getOperation()->getAttrs();
+ cast<spirv::StoreOp>(trueBlock->front())->getAttrs();
auto selectOp = rewriter.create<spirv::SelectOp>(
selectionOp.getLoc(), trueValue.getType(), brConditionalOp.condition(),
@@ -353,8 +353,7 @@ struct ConvertSelectionOpToSelect
}
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 @@ LogicalResult ConvertSelectionOpToSelect::canCanonicalizeSelection(
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
index 8781b6bf17c4..b7236c17c000 100644
--- a/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
+++ b/mlir/lib/Dialect/SPIRV/Serialization/Serializer.cpp
@@ -103,7 +103,7 @@ static Block *getPhiIncomingBlock(Block *block) {
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 @@ Serializer::processOp<spirv::CopyMemoryOp>(spirv::CopyMemoryOp op) {
SmallVector<uint32_t, 4> operands;
SmallVector<StringRef, 2> 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
index 43554d46c8af..87008315f69f 100644
--- a/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp
+++ b/mlir/lib/Dialect/SPIRV/Transforms/RewriteInsertsPass.cpp
@@ -63,7 +63,7 @@ void RewriteInsertsPass::runOnOperation() {
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
index 1437552f6e2a..b5d5ef703aa0 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -617,7 +617,7 @@ struct SimplifyBrToBlockWithSinglePred : public OpRewritePattern<BranchOp> {
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 @@ struct SimplifyPassThroughBr : public OpRewritePattern<BranchOp> {
// 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 @@ struct SimplifyCondBranchIdenticalSuccessors
// 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
diff er between the two.
@@ -1053,7 +1053,7 @@ struct SimplifyCondBranchFromCondBranchOnSameCondition
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 @@ void mlir::MemRefReinterpretCastOp::build(OpBuilder &b, OperationState &result,
/// ```
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 @@ Type SubViewOp::inferResultType(MemRefType sourceMemRefType,
/// ```
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 @@ OpFoldResult SubViewOp::fold(ArrayRef<Attribute> operands) {
/// ```
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 @@ void SubTensorOp::getCanonicalizationPatterns(OwningRewritePatternList &results,
/// ```
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
index ee4b398379f7..e42860e87942 100644
--- a/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp
+++ b/mlir/lib/Dialect/StandardOps/Transforms/TensorConstantBufferize.cpp
@@ -67,7 +67,7 @@ GlobalCreator::GlobalCreator(ModuleOp module) {
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
index e9eb6e75e8d6..e6610eb59727 100644
--- a/mlir/lib/Dialect/Vector/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/VectorOps.cpp
@@ -2776,7 +2776,7 @@ static void print(OpAsmPrinter &p, TupleOp op) {
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
index c42c429496bc..f15bfe901326 100644
--- a/mlir/lib/Dialect/Vector/VectorTransforms.cpp
+++ b/mlir/lib/Dialect/Vector/VectorTransforms.cpp
@@ -2162,7 +2162,7 @@ LogicalResult mlir::vector::splitFullAndPartialTransferPrecondition(
// 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<scf::IfOp>(xferOp.getOperation()->getParentOp()))
+ if (isa<scf::IfOp>(xferOp->getParentOp()))
return failure();
return success();
}
diff --git a/mlir/lib/IR/BuiltinDialect.cpp b/mlir/lib/IR/BuiltinDialect.cpp
index 867f050c1d2f..5c0a0380f9af 100644
--- a/mlir/lib/IR/BuiltinDialect.cpp
+++ b/mlir/lib/IR/BuiltinDialect.cpp
@@ -155,8 +155,7 @@ void FuncOp::cloneInto(FuncOp dest, BlockAndValueMapping &mapper) {
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
index b6ca531bf9f7..3cccefef9cf8 100644
--- a/mlir/lib/Parser/Parser.cpp
+++ b/mlir/lib/Parser/Parser.cpp
@@ -386,7 +386,7 @@ ParseResult OperationParser::popSSANameScope() {
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 @@ ParseResult ModuleParser::parseModule(ModuleOp module) {
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
index 66b29b6dcd4b..6f144e7a0e83 100644
--- a/mlir/lib/Transforms/Inliner.cpp
+++ b/mlir/lib/Transforms/Inliner.cpp
@@ -408,7 +408,7 @@ struct Inliner : public InlinerInterface {
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
index 6716260aa0d1..6fe112b89baf 100644
--- a/mlir/lib/Transforms/LoopFusion.cpp
+++ b/mlir/lib/Transforms/LoopFusion.cpp
@@ -1541,7 +1541,7 @@ struct GreedyFusion {
// 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 @@ struct GreedyFusion {
auto dstForInst = cast<AffineForOp>(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
index effaae4b075b..919559c8a6df 100644
--- a/mlir/lib/Transforms/SCCP.cpp
+++ b/mlir/lib/Transforms/SCCP.cpp
@@ -435,7 +435,7 @@ void SCCPSolver::initializeSymbolCallables(Operation *op) {
// 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::visitCallableOperation(Operation *op) {
}
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
index 98661cf570e8..8b1e2fa630ec 100644
--- a/mlir/lib/Transforms/Utils/InliningUtils.cpp
+++ b/mlir/lib/Transforms/Utils/InliningUtils.cpp
@@ -307,7 +307,7 @@ LogicalResult mlir::inlineCall(InlinerInterface &interface,
// Make sure that the number of arguments and results matchup between the call
// and the region.
SmallVector<Value, 8> callOperands(call.getArgOperands());
- SmallVector<Value, 8> callResults(call.getOperation()->getResults());
+ SmallVector<Value, 8> 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
index b342f28517e7..77b6744b07a6 100644
--- a/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopFusionUtils.cpp
@@ -137,7 +137,7 @@ static Operation *getLastDependentOpInRange(Operation *opA, Operation *opB) {
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 @@ FusionResult mlir::canFuseLoops(AffineForOp srcForOp, AffineForOp dstForOp,
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
diff erent blocks\n");
return FusionResult::FailPrecondition;
}
@@ -285,7 +285,7 @@ FusionResult mlir::canFuseLoops(AffineForOp srcForOp, AffineForOp dstForOp,
// 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
index 8b66b80c292b..bfbc2211e061 100644
--- a/mlir/lib/Transforms/Utils/LoopUtils.cpp
+++ b/mlir/lib/Transforms/Utils/LoopUtils.cpp
@@ -160,7 +160,7 @@ LogicalResult mlir::promoteIfSingleIteration(AffineForOp forOp) {
// 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<FuncOp>().getBody());
@@ -220,7 +220,7 @@ LogicalResult mlir::promoteIfSingleIteration(scf::ForOp forOp) {
// 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 @@ checkTilingLegalityImpl(MutableArrayRef<mlir::AffineForOp> origLoops) {
// We first find out all dependences we intend to check.
SmallVector<Operation *, 8> loadAndStoreOps;
- origLoops[0].getOperation()->walk([&](Operation *op) {
+ origLoops[0]->walk([&](Operation *op) {
if (isa<AffineReadOpInterface, AffineWriteOpInterface>(op))
loadAndStoreOps.push_back(op);
});
@@ -1124,8 +1124,7 @@ LogicalResult mlir::loopUnrollByFactor(AffineForOp forOp,
// 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<AffineForOp>(builder.clone(*forOp));
AffineMap cleanupMap;
SmallVector<Value, 4> cleanupOperands;
@@ -1234,7 +1233,7 @@ LogicalResult mlir::loopUnrollByFactor(scf::ForOp forOp,
// 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<scf::ForOp>(epilogueBuilder.clone(*forOp));
epilogueForOp.setLowerBound(upperBoundUnrolled);
@@ -1246,8 +1245,7 @@ LogicalResult mlir::loopUnrollByFactor(scf::ForOp forOp,
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 @@ LogicalResult mlir::loopUnrollJamByFactor(AffineForOp forOp,
// 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<AffineForOp>(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 @@ void mlir::interchangeLoops(AffineForOp forOpA, AffineForOp forOpB) {
// 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 @@ unsigned mlir::permuteLoops(MutableArrayRef<AffineForOp> input,
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 @@ unsigned mlir::permuteLoops(MutableArrayRef<AffineForOp> input,
// 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 @@ stripmineSink(AffineForOp forOp, uint64_t factor,
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 @@ findHighestBlockForPlacement(const MemRefRegion ®ion, Block &block,
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 @@ mlir::separateFullTiles(MutableArrayRef<AffineForOp> inputNest,
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
index a6a18d17d1cb..791b354d3711 100644
--- a/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
+++ b/mlir/test/lib/Dialect/SPIRV/TestAvailability.cpp
@@ -32,7 +32,7 @@ void PrintOpAvailability::runOnFunction() {
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
index 9ae17d991a52..1591a7435c72 100644
--- a/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
+++ b/mlir/test/lib/Transforms/TestLinalgFusionTransforms.cpp
@@ -128,7 +128,7 @@ static LogicalResult fuseLinalgOpsGreedily(FuncOp f) {
SmallVector<LinalgOp, 8> 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
index 034abfe603c6..b28e52851a60 100644
--- a/mlir/test/lib/Transforms/TestLoopFusion.cpp
+++ b/mlir/test/lib/Transforms/TestLoopFusion.cpp
@@ -59,8 +59,8 @@ static bool testDependenceCheck(AffineForOp srcForOp, AffineForOp dstForOp,
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 @@ static bool testSliceComputation(AffineForOp forOpA, AffineForOp forOpB,
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
index eabdd06fad5d..6ab92c040c16 100644
--- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2138,10 +2138,8 @@ OpOperandAdaptorEmitter::OpOperandAdaptorEmitter(const Operator &op)
{
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
index 442afc14c291..6919a1032412 100644
--- a/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
+++ b/mlir/tools/mlir-tblgen/SPIRVUtilsGen.cpp
@@ -562,9 +562,7 @@ static void emitArgumentSerialization(const Operator &op, ArrayRef<SMLoc> loc,
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);
More information about the llvm-branch-commits
mailing list