diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td --- a/flang/include/flang/Optimizer/Dialect/FIROps.td +++ b/flang/include/flang/Optimizer/Dialect/FIROps.td @@ -270,7 +270,7 @@ bool hasLenParams() { return bool{getAttr(lenpName())}; } unsigned numLenParams() { - if (auto val = getAttrOfType(lenpName())) + if (auto val = (*this)->getAttrOfType(lenpName())) return val.getInt(); return 0; } @@ -291,7 +291,7 @@ /// Get the input type of the allocation mlir::Type getInType() { - return getAttrOfType(inType()).getValue(); + return (*this)->getAttrOfType(inType()).getValue(); } }]; @@ -567,7 +567,7 @@ // The number of destination conditions that may be tested unsigned getNumConditions() { - return getAttrOfType(getCasesAttr()).size(); + return (*this)->getAttrOfType(getCasesAttr()).size(); } // The selector is the value being tested to determine the destination @@ -577,7 +577,7 @@ } // The number of blocks that may be branched to - unsigned getNumDest() { return getOperation()->getNumSuccessors(); } + unsigned getNumDest() { return (*this)->getNumSuccessors(); } llvm::Optional getCompareOperands(unsigned cond); llvm::Optional> getCompareOperands( @@ -1561,11 +1561,11 @@ let parser = "return parseCoordinateOp(parser, result);"; let printer = [{ - p << getOperationName() << ' ' << getOperation()->getOperands(); + p << getOperationName() << ' ' << (*this)->getOperands(); p.printOptionalAttrDict(getAttrs(), /*elidedAttrs=*/{baseType()}); p << " : "; - p.printFunctionalType(getOperation()->getOperandTypes(), - getOperation()->getResultTypes()); + p.printFunctionalType((*this)->getOperandTypes(), + (*this)->getResultTypes()); }]; let verifier = [{ @@ -1940,9 +1940,9 @@ return getOperands().drop_front(getNumControlOperands()); } - void setLowerBound(Value bound) { getOperation()->setOperand(0, bound); } - void setUpperBound(Value bound) { getOperation()->setOperand(1, bound); } - void setStep(Value step) { getOperation()->setOperand(2, step); } + void setLowerBound(Value bound) { (*this)->setOperand(0, bound); } + void setUpperBound(Value bound) { (*this)->setOperand(1, bound); } + void setStep(Value step) { (*this)->setOperand(2, step); } /// Number of region arguments for loop-carried values unsigned getNumRegionIterArgs() { @@ -1952,18 +1952,18 @@ unsigned getNumControlOperands() { return 3; } /// Does the operation hold operands for loop-carried values bool hasIterOperands() { - return getOperation()->getNumOperands() > getNumControlOperands(); + return (*this)->getNumOperands() > getNumControlOperands(); } /// Get Number of loop-carried values unsigned getNumIterOperands() { - return getOperation()->getNumOperands() - getNumControlOperands(); + return (*this)->getNumOperands() - getNumControlOperands(); } /// Get the body of the loop mlir::Block *getBody() { return ®ion().front(); } void setUnordered() { - getOperation()->setAttr(unorderedAttrName(), + (*this)->setAttr(unorderedAttrName(), mlir::UnitAttr::get(getContext())); } }]; @@ -2062,9 +2062,9 @@ return getOperands().drop_front(getNumControlOperands()); } - void setLowerBound(Value bound) { getOperation()->setOperand(0, bound); } - void setUpperBound(Value bound) { getOperation()->setOperand(1, bound); } - void setStep(mlir::Value step) { getOperation()->setOperand(2, step); } + void setLowerBound(Value bound) { (*this)->setOperand(0, bound); } + void setUpperBound(Value bound) { (*this)->setOperand(1, bound); } + void setStep(mlir::Value step) { (*this)->setOperand(2, step); } /// Number of region arguments for loop-carried values unsigned getNumRegionIterArgs() { @@ -2074,11 +2074,11 @@ unsigned getNumControlOperands() { return 3; } /// Does the operation hold operands for loop-carried values bool hasIterOperands() { - return getOperation()->getNumOperands() > getNumControlOperands(); + return (*this)->getNumOperands() > getNumControlOperands(); } /// Get Number of loop-carried values unsigned getNumIterOperands() { - return getOperation()->getNumOperands() - getNumControlOperands(); + return (*this)->getNumOperands() - getNumControlOperands(); } }]; } @@ -2705,7 +2705,7 @@ p << " : "; p.printType(getType()); if (hasInitializationBody()) - p.printRegion(getOperation()->getRegion(0), /*printEntryBlockArgs=*/false, + p.printRegion((*this)->getRegion(0), /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/true); }]; @@ -2754,7 +2754,7 @@ void appendInitialValue(mlir::Operation *op); /// A GlobalOp has one region. - mlir::Region &getRegion() { return getOperation()->getRegion(0); } + mlir::Region &getRegion() { return (*this)->getRegion(0); } /// A GlobalOp has one block. mlir::Block &getBlock() { return getRegion().front(); } @@ -2763,7 +2763,7 @@ static mlir::ParseResult verifyValidLinkage(StringRef linkage); bool hasInitializationBody() { - return (getOperation()->getNumRegions() == 1) && !getRegion().empty() && + return ((*this)->getNumRegions() == 1) && !getRegion().empty() && !isa(getBlock().front()); } @@ -2869,7 +2869,7 @@ mlir::SymbolTable::getSymbolAttrName()).getValue(); p << getOperationName() << " @" << tableName; - Region &body = getOperation()->getRegion(0); + Region &body = (*this)->getRegion(0); if (!body.empty()) p.printRegion(body, /*printEntryBlockArgs=*/false, /*printBlockTerminators=*/false); @@ -2900,7 +2900,7 @@ void appendTableEntry(mlir::Operation *op); mlir::Region &getRegion() { - return this->getOperation()->getRegion(0); + return (*this)->getRegion(0); } mlir::Block &getBlock() { diff --git a/mlir/examples/toy/Ch2/mlir/Dialect.cpp b/mlir/examples/toy/Ch2/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch2/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch2/mlir/Dialect.cpp @@ -191,7 +191,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // We know that the parent operation is a function, because of the 'HasParent' // trait attached to the operation definition. - auto function = cast(op.getParentOp()); + auto function = cast(op->getParentOp()); /// ReturnOps can only have a single optional operand. if (op.getNumOperands() > 1) diff --git a/mlir/examples/toy/Ch3/mlir/Dialect.cpp b/mlir/examples/toy/Ch3/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch3/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch3/mlir/Dialect.cpp @@ -191,7 +191,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // We know that the parent operation is a function, because of the 'HasParent' // trait attached to the operation definition. - auto function = cast(op.getParentOp()); + auto function = cast(op->getParentOp()); /// ReturnOps can only have a single optional operand. if (op.getNumOperands() > 1) diff --git a/mlir/examples/toy/Ch4/mlir/Dialect.cpp b/mlir/examples/toy/Ch4/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch4/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch4/mlir/Dialect.cpp @@ -246,7 +246,7 @@ /// Return the callee of the generic call operation, this is required by the /// call interface. CallInterfaceCallable GenericCallOp::getCallableForCallee() { - return getAttrOfType("callee"); + return (*this)->getAttrOfType("callee"); } /// Get the argument operands to the called function, this is required by the @@ -272,7 +272,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // We know that the parent operation is a function, because of the 'HasParent' // trait attached to the operation definition. - auto function = cast(op.getParentOp()); + auto function = cast(op->getParentOp()); /// ReturnOps can only have a single optional operand. if (op.getNumOperands() > 1) diff --git a/mlir/examples/toy/Ch5/mlir/Dialect.cpp b/mlir/examples/toy/Ch5/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch5/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch5/mlir/Dialect.cpp @@ -246,7 +246,7 @@ /// Return the callee of the generic call operation, this is required by the /// call interface. CallInterfaceCallable GenericCallOp::getCallableForCallee() { - return getAttrOfType("callee"); + return (*this)->getAttrOfType("callee"); } /// Get the argument operands to the called function, this is required by the @@ -272,7 +272,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // We know that the parent operation is a function, because of the 'HasParent' // trait attached to the operation definition. - auto function = cast(op.getParentOp()); + auto function = cast(op->getParentOp()); /// ReturnOps can only have a single optional operand. if (op.getNumOperands() > 1) diff --git a/mlir/examples/toy/Ch6/mlir/Dialect.cpp b/mlir/examples/toy/Ch6/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch6/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch6/mlir/Dialect.cpp @@ -246,7 +246,7 @@ /// Return the callee of the generic call operation, this is required by the /// call interface. CallInterfaceCallable GenericCallOp::getCallableForCallee() { - return getAttrOfType("callee"); + return (*this)->getAttrOfType("callee"); } /// Get the argument operands to the called function, this is required by the @@ -272,7 +272,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // We know that the parent operation is a function, because of the 'HasParent' // trait attached to the operation definition. - auto function = cast(op.getParentOp()); + auto function = cast(op->getParentOp()); /// ReturnOps can only have a single optional operand. if (op.getNumOperands() > 1) diff --git a/mlir/examples/toy/Ch7/mlir/Dialect.cpp b/mlir/examples/toy/Ch7/mlir/Dialect.cpp --- a/mlir/examples/toy/Ch7/mlir/Dialect.cpp +++ b/mlir/examples/toy/Ch7/mlir/Dialect.cpp @@ -298,7 +298,7 @@ /// Return the callee of the generic call operation, this is required by the /// call interface. CallInterfaceCallable GenericCallOp::getCallableForCallee() { - return getAttrOfType("callee"); + return (*this)->getAttrOfType("callee"); } /// Get the argument operands to the called function, this is required by the @@ -324,7 +324,7 @@ static mlir::LogicalResult verify(ReturnOp op) { // We know that the parent operation is a function, because of the 'HasParent' // trait attached to the operation definition. - auto function = cast(op.getParentOp()); + auto function = cast(op->getParentOp()); /// ReturnOps can only have a single optional operand. if (op.getNumOperands() > 1) diff --git a/mlir/include/mlir/Dialect/GPU/GPUOps.td b/mlir/include/mlir/Dialect/GPU/GPUOps.td --- a/mlir/include/mlir/Dialect/GPU/GPUOps.td +++ b/mlir/include/mlir/Dialect/GPU/GPUOps.td @@ -207,8 +207,8 @@ /// Returns `true` if the GPU function defined by this Op is a kernel, i.e. /// it is intended to be launched from host. bool isKernel() { - return getAttrOfType(GPUDialect::getKernelFuncAttrName()) != - nullptr; + return (*this)->getAttrOfType( + GPUDialect::getKernelFuncAttrName()) != nullptr; } /// Change the type of this function in place. This is an extremely @@ -223,8 +223,8 @@ /// Returns the number of buffers located in the workgroup memory. unsigned getNumWorkgroupAttributions() { - return getAttrOfType(getNumWorkgroupAttributionsAttrName()) - .getInt(); + return (*this)->getAttrOfType( + getNumWorkgroupAttributionsAttrName()).getInt(); } /// Returns a list of block arguments that correspond to buffers located in diff --git a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td @@ -766,7 +766,7 @@ Block *addEntryBlock(); LLVMType getType() { - return getAttrOfType(getTypeAttrName()) + return (*this)->getAttrOfType(getTypeAttrName()) .getValue().cast(); } bool isVarArg() { diff --git a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td --- a/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td +++ b/mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td @@ -107,7 +107,7 @@ let parser = [{ return parseNVVMShflSyncBflyOp(parser, result); }]; let printer = [{ printNVVMIntrinsicOp(p, this->getOperation()); }]; let verifier = [{ - if (!getAttrOfType("return_value_and_is_valid")) + if (!(*this)->getAttrOfType("return_value_and_is_valid")) return success(); auto type = getType().cast(); if (!type.isStructTy() || type.getStructNumElements() != 2 || diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.h @@ -59,7 +59,9 @@ static void build(OpBuilder &builder, OperationState &result, const APFloat &value, FloatType type); - APFloat getValue() { return getAttrOfType("value").getValue(); } + APFloat getValue() { + return (*this)->getAttrOfType("value").getValue(); + } static bool classof(Operation *op); }; @@ -81,7 +83,9 @@ static void build(OpBuilder &builder, OperationState &result, int64_t value, Type type); - int64_t getValue() { return getAttrOfType("value").getInt(); } + int64_t getValue() { + return (*this)->getAttrOfType("value").getInt(); + } static bool classof(Operation *op); }; @@ -98,7 +102,9 @@ /// Build a constant int op producing an index. static void build(OpBuilder &builder, OperationState &result, int64_t value); - int64_t getValue() { return getAttrOfType("value").getInt(); } + int64_t getValue() { + return (*this)->getAttrOfType("value").getInt(); + } static bool classof(Operation *op); }; @@ -159,8 +165,8 @@ } // Returns the source memref indices for this DMA operation. operand_range getSrcIndices() { - return {getOperation()->operand_begin() + 1, - getOperation()->operand_begin() + 1 + getSrcMemRefRank()}; + return {(*this)->operand_begin() + 1, + (*this)->operand_begin() + 1 + getSrcMemRefRank()}; } // Returns the destination MemRefType for this DMA operations. @@ -178,8 +184,8 @@ // Returns the destination memref indices for this DMA operation. operand_range getDstIndices() { - return {getOperation()->operand_begin() + 1 + getSrcMemRefRank() + 1, - getOperation()->operand_begin() + 1 + getSrcMemRefRank() + 1 + + return {(*this)->operand_begin() + 1 + getSrcMemRefRank() + 1, + (*this)->operand_begin() + 1 + getSrcMemRefRank() + 1 + getDstMemRefRank()}; } @@ -201,9 +207,8 @@ operand_range getTagIndices() { unsigned tagIndexStartPos = 1 + getSrcMemRefRank() + 1 + getDstMemRefRank() + 1 + 1; - return {getOperation()->operand_begin() + tagIndexStartPos, - getOperation()->operand_begin() + tagIndexStartPos + - getTagMemRefRank()}; + return {(*this)->operand_begin() + tagIndexStartPos, + (*this)->operand_begin() + tagIndexStartPos + getTagMemRefRank()}; } /// Returns true if this is a DMA from a faster memory space to a slower one. @@ -279,8 +284,8 @@ // Returns the tag memref index for this DMA operation. operand_range getTagIndices() { - return {getOperation()->operand_begin() + 1, - getOperation()->operand_begin() + 1 + getTagMemRefRank()}; + return {(*this)->operand_begin() + 1, + (*this)->operand_begin() + 1 + getTagMemRefRank()}; } // Returns the rank (number of indices) of the tag memref. diff --git a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td --- a/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td +++ b/mlir/include/mlir/Dialect/StandardOps/IR/Ops.td @@ -820,7 +820,7 @@ /// Return the callee of this operation. CallInterfaceCallable getCallableForCallee() { - return getAttrOfType("callee"); + return (*this)->getAttrOfType("callee"); } }]; @@ -1040,8 +1040,8 @@ static CmpFPredicate getPredicateByName(StringRef name); CmpFPredicate getPredicate() { - return (CmpFPredicate)getAttrOfType(getPredicateAttrName()) - .getInt(); + return (CmpFPredicate)(*this)->getAttrOfType( + getPredicateAttrName()).getInt(); } }]; @@ -1162,8 +1162,8 @@ static CmpIPredicate getPredicateByName(StringRef name); CmpIPredicate getPredicate() { - return (CmpIPredicate)getAttrOfType(getPredicateAttrName()) - .getInt(); + return (CmpIPredicate)(*this)->getAttrOfType( + getPredicateAttrName()).getInt(); } }]; diff --git a/mlir/include/mlir/Dialect/Vector/VectorOps.td b/mlir/include/mlir/Dialect/Vector/VectorOps.td --- a/mlir/include/mlir/Dialect/Vector/VectorOps.td +++ b/mlir/include/mlir/Dialect/Vector/VectorOps.td @@ -1937,7 +1937,8 @@ return getResult().getType().cast(); } int64_t getIndex() { - return getAttrOfType("index").getValue().getSExtValue(); + auto index = (*this)->getAttrOfType("index"); + return index.getValue().getSExtValue(); } static StringRef getIndexAttrName() { return "index"; } }]; diff --git a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp --- a/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp +++ b/mlir/lib/Conversion/AsyncToLLVM/AsyncToLLVM.cpp @@ -466,7 +466,7 @@ // Note that this is not reversible transformation. static std::pair outlineExecuteOp(SymbolTable &symbolTable, ExecuteOp execute) { - ModuleOp module = execute.getParentOfType(); + ModuleOp module = execute->getParentOfType(); MLIRContext *ctx = module.getContext(); Location loc = execute.getLoc(); @@ -727,7 +727,7 @@ return failure(); // Check if await operation is inside the outlined coroutine function. - auto func = await.template getParentOfType(); + auto func = await->template getParentOfType(); auto outlined = outlinedFunctions.find(func); const bool isInCoroutine = outlined != outlinedFunctions.end(); 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 @@ -587,7 +587,8 @@ launchOp, launchOp.getKernelModuleName()); assert(kernelModule && "expected a kernel module"); - auto binaryAttr = kernelModule.getAttrOfType(gpuBinaryAnnotation); + auto binaryAttr = + kernelModule->getAttrOfType(gpuBinaryAnnotation); if (!binaryAttr) { kernelModule.emitOpError() << "missing " << gpuBinaryAnnotation << " attribute"; diff --git a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp --- a/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp +++ b/mlir/lib/Conversion/GPUToVulkan/ConvertLaunchFuncToVulkanCalls.cpp @@ -186,7 +186,7 @@ // Check that `kSPIRVBinary` and `kSPIRVEntryPoint` are present in attributes // for the given vulkan launch call. auto spirvBlobAttr = - vulkanLaunchCallOp.getAttrOfType(kSPIRVBlobAttrName); + vulkanLaunchCallOp->getAttrOfType(kSPIRVBlobAttrName); if (!spirvBlobAttr) { vulkanLaunchCallOp.emitError() << "missing " << kSPIRVBlobAttrName << " attribute"; @@ -194,7 +194,7 @@ } auto spirvEntryPointNameAttr = - vulkanLaunchCallOp.getAttrOfType(kSPIRVEntryPointAttrName); + vulkanLaunchCallOp->getAttrOfType(kSPIRVEntryPointAttrName); if (!spirvEntryPointNameAttr) { vulkanLaunchCallOp.emitError() << "missing " << kSPIRVEntryPointAttrName << " attribute"; diff --git a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp --- a/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp @@ -381,7 +381,7 @@ // TODO: Verify that this is a valid GPU mapping. // processor ids: 0-2 block [x/y/z], 3-5 -> thread [x/y/z], 6-> sequential ArrayAttr mapping = - parallelOp.getAttrOfType(gpu::getMappingAttrName()); + parallelOp->getAttrOfType(gpu::getMappingAttrName()); // TODO: Support reductions. if (!mapping || parallelOp.getNumResults() != 0) @@ -390,7 +390,7 @@ Location loc = parallelOp.getLoc(); auto launchIndependent = [&launchOp](Value val) { - return val.getParentRegion()->isAncestor(launchOp.getParentRegion()); + return val.getParentRegion()->isAncestor(launchOp->getParentRegion()); }; auto ensureLaunchIndependent = [&rewriter, @@ -568,7 +568,7 @@ PatternRewriter &rewriter) const { // We can only transform starting at the outer-most loop. Launches inside of // parallel loops are not supported. - if (auto parentLoop = parallelOp.getParentOfType()) + if (auto parentLoop = parallelOp->getParentOfType()) return failure(); // Create a launch operation. We start with bound one for all grid/block // sizes. Those will be refined later as we discover them from mappings. 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 @@ -66,7 +66,7 @@ SmallVector topLevelParallelOps; func.walk([&topLevelParallelOps](scf::ParallelOp parallelOp) { // Ignore ops that are already within OpenMP parallel construct. - if (!parallelOp.getParentOfType()) + if (!parallelOp->getParentOfType()) topLevelParallelOps.push_back(parallelOp); }); @@ -87,7 +87,7 @@ ConversionTarget target(*func.getContext()); target.addIllegalOp(); target.addDynamicallyLegalOp( - [](scf::YieldOp op) { return !isa(op.getParentOp()); }); + [](scf::YieldOp op) { return !isa(op->getParentOp()); }); target.addLegalDialect(); OwningRewritePatternList patterns; 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 @@ -269,11 +269,11 @@ // VariableOp created during lowering of the parent region. if (!operands.empty()) { auto loc = terminatorOp.getLoc(); - auto &allocas = scfToSPIRVContext->outputVars[terminatorOp.getParentOp()]; + auto &allocas = scfToSPIRVContext->outputVars[terminatorOp->getParentOp()]; assert(allocas.size() == operands.size()); for (unsigned i = 0, e = operands.size(); i < e; i++) rewriter.create(loc, allocas[i], operands[i]); - if (isa(terminatorOp.getParentOp())) { + if (isa(terminatorOp->getParentOp())) { // For loops we also need to update the branch jumping back to the header. auto br = cast(rewriter.getInsertionBlock()->getTerminator()); diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertLaunchFuncToLLVMCalls.cpp @@ -52,7 +52,7 @@ /// i -> (0, i) /// which is implemented under `LowerABIAttributesPass`. static unsigned calculateGlobalIndex(spirv::GlobalVariableOp op) { - IntegerAttr binding = op.getAttrOfType(bindingName()); + IntegerAttr binding = op->getAttrOfType(bindingName()); return binding.getInt(); } @@ -75,8 +75,8 @@ createGlobalVariableWithBindName(spirv::GlobalVariableOp op, StringRef kernelModuleName) { IntegerAttr descriptorSet = - op.getAttrOfType(descriptorSetName()); - IntegerAttr binding = op.getAttrOfType(bindingName()); + op->getAttrOfType(descriptorSetName()); + IntegerAttr binding = op->getAttrOfType(bindingName()); return llvm::formatv("{0}_{1}_descriptor_set{2}_binding{3}", kernelModuleName.str(), op.sym_name().str(), std::to_string(descriptorSet.getInt()), @@ -87,8 +87,8 @@ /// and a binding number. static bool hasDescriptorSetAndBinding(spirv::GlobalVariableOp op) { IntegerAttr descriptorSet = - op.getAttrOfType(descriptorSetName()); - IntegerAttr binding = op.getAttrOfType(bindingName()); + op->getAttrOfType(descriptorSetName()); + IntegerAttr binding = op->getAttrOfType(bindingName()); return descriptorSet && binding; } @@ -155,7 +155,7 @@ ConversionPatternRewriter &rewriter) const override { auto *op = launchOp.getOperation(); MLIRContext *context = rewriter.getContext(); - auto module = launchOp.getParentOfType(); + auto module = launchOp->getParentOfType(); // Get the SPIR-V module that represents the gpu kernel module. The module // is named: diff --git a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp --- a/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp +++ b/mlir/lib/Conversion/SPIRVToLLVM/ConvertSPIRVToLLVM.cpp @@ -647,7 +647,7 @@ // First, create the global struct's name that would be associated with // this entry point's execution mode. We set it to be: // __spv__{SPIR-V module name}_{function name}_execution_mode_info - ModuleOp module = op.getParentOfType(); + ModuleOp module = op->getParentOfType(); std::string moduleName; if (module.getName().hasValue()) moduleName = "_" + module.getName().getValue().str(); @@ -1530,8 +1530,9 @@ auto spvModules = module.getOps(); for (auto spvModule : spvModules) { spvModule.walk([&](spirv::GlobalVariableOp op) { - IntegerAttr descriptorSet = op.getAttrOfType(kDescriptorSet); - IntegerAttr binding = op.getAttrOfType(kBinding); + IntegerAttr descriptorSet = + op->getAttrOfType(kDescriptorSet); + IntegerAttr binding = op->getAttrOfType(kBinding); // For every global variable in the module, get the ones with descriptor // set and binding numbers. if (descriptorSet && binding) { 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 @@ -1349,7 +1349,7 @@ ConversionPatternRewriter &rewriter) const { // Convert the original function arguments. They are converted using the // LLVMTypeConverter provided to this legalization pattern. - auto varargsAttr = funcOp.getAttrOfType("std.varargs"); + auto varargsAttr = funcOp->getAttrOfType("std.varargs"); TypeConverter::SignatureConversion result(funcOp.getNumArguments()); auto llvmType = getTypeConverter()->convertFunctionSignature( funcOp.getType(), varargsAttr && varargsAttr.getValue(), result); @@ -1407,7 +1407,7 @@ return failure(); if (getTypeConverter()->getOptions().emitCWrappers || - funcOp.getAttrOfType(kEmitIfaceAttrName)) { + funcOp->getAttrOfType(kEmitIfaceAttrName)) { if (newFuncOp.isExternal()) wrapExternalFunction(rewriter, funcOp.getLoc(), *getTypeConverter(), funcOp, newFuncOp); @@ -1717,7 +1717,7 @@ AssertOp::Adaptor transformed(operands); // Insert the `abort` declaration if necessary. - auto module = op.getParentOfType(); + auto module = op->getParentOfType(); auto abortFunc = module.lookupSymbol("abort"); if (!abortFunc) { OpBuilder::InsertionGuard guard(rewriter); @@ -2056,7 +2056,7 @@ Type elementPtrType = this->getElementPtrType(memRefType); Value allocatedPtr = createAllocCall(loc, "malloc", elementPtrType, {sizeBytes}, - allocOp.getParentOfType(), rewriter); + allocOp->getParentOfType(), rewriter); Value alignedPtr = allocatedPtr; if (alignment) { @@ -2138,7 +2138,7 @@ Type elementPtrType = this->getElementPtrType(memRefType); Value allocatedPtr = createAllocCall( loc, "aligned_alloc", elementPtrType, {allocAlignment, sizeBytes}, - allocOp.getParentOfType(), rewriter); + allocOp->getParentOfType(), rewriter); return std::make_tuple(allocatedPtr, allocatedPtr); } @@ -2363,11 +2363,11 @@ // Insert the `free` declaration if it is not already present. auto freeFunc = - op.getParentOfType().lookupSymbol("free"); + op->getParentOfType().lookupSymbol("free"); if (!freeFunc) { OpBuilder::InsertionGuard guard(rewriter); rewriter.setInsertionPointToStart( - op.getParentOfType().getBody()); + op->getParentOfType().getBody()); freeFunc = rewriter.create( rewriter.getUnknownLoc(), "free", LLVM::LLVMType::getFunctionTy(getVoidType(), getVoidPtrType(), 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 @@ -280,7 +280,7 @@ // Insert spv.globalVariable for this allocation. Operation *parent = - SymbolTable::getNearestSymbolTable(operation.getParentOp()); + SymbolTable::getNearestSymbolTable(operation->getParentOp()); if (!parent) return failure(); Location loc = operation.getLoc(); @@ -868,9 +868,9 @@ srcBits, dstBits, rewriter); Value spvLoadOp = rewriter.create( loc, dstType, adjustedPtr, - loadOp.getAttrOfType( + loadOp->getAttrOfType( spirv::attributeName()), - loadOp.getAttrOfType("alignment")); + loadOp->getAttrOfType("alignment")); // Shift the bits to the rightmost. // ____XXXX________ -> ____________XXXX 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 @@ -1670,7 +1670,7 @@ newOperands.append(ubOperands.begin(), ubOperands.end()); auto iterOperands = getIterOperands(); newOperands.append(iterOperands.begin(), iterOperands.end()); - getOperation()->setOperands(newOperands); + (*this)->setOperands(newOperands); setAttr(getLowerBoundAttrName(), AffineMapAttr::get(map)); } @@ -1683,7 +1683,7 @@ newOperands.append(ubOperands.begin(), ubOperands.end()); auto iterOperands = getIterOperands(); newOperands.append(iterOperands.begin(), iterOperands.end()); - getOperation()->setOperands(newOperands); + (*this)->setOperands(newOperands); setAttr(getUpperBoundAttrName(), AffineMapAttr::get(map)); } @@ -1902,7 +1902,7 @@ static LogicalResult verify(AffineIfOp op) { // Verify that we have a condition attribute. auto conditionAttr = - op.getAttrOfType(op.getConditionAttrName()); + op->getAttrOfType(op.getConditionAttrName()); if (!conditionAttr) return op.emitOpError( "requires an integer set attribute named 'condition'"); @@ -1975,7 +1975,7 @@ static void print(OpAsmPrinter &p, AffineIfOp op) { auto conditionAttr = - op.getAttrOfType(op.getConditionAttrName()); + op->getAttrOfType(op.getConditionAttrName()); p << "affine.if " << conditionAttr; printDimAndSymbolList(op.operand_begin(), op.operand_end(), conditionAttr.getValue().getNumDims(), p); @@ -1999,7 +1999,9 @@ } IntegerSet AffineIfOp::getIntegerSet() { - return getAttrOfType(getConditionAttrName()).getValue(); + return (*this) + ->getAttrOfType(getConditionAttrName()) + .getValue(); } void AffineIfOp::setIntegerSet(IntegerSet newSet) { setAttr(getConditionAttrName(), IntegerSetAttr::get(newSet)); @@ -2007,7 +2009,7 @@ void AffineIfOp::setConditional(IntegerSet set, ValueRange operands) { setIntegerSet(set); - getOperation()->setOperands(operands); + (*this)->setOperands(operands); } void AffineIfOp::build(OpBuilder &builder, OperationState &result, @@ -2120,7 +2122,7 @@ static void print(OpAsmPrinter &p, AffineLoadOp op) { p << "affine.load " << op.getMemRef() << '['; if (AffineMapAttr mapAttr = - op.getAttrOfType(op.getMapAttrName())) + op->getAttrOfType(op.getMapAttrName())) p.printAffineMapOfSSAIds(mapAttr, op.getMapOperands()); p << ']'; p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{op.getMapAttrName()}); @@ -2163,7 +2165,7 @@ if (failed(verifyMemoryOpIndexing( op.getOperation(), - op.getAttrOfType(op.getMapAttrName()), + op->getAttrOfType(op.getMapAttrName()), op.getMapOperands(), memrefType, /*numIndexOperands=*/op.getNumOperands() - 1))) return failure(); @@ -2236,7 +2238,7 @@ p << "affine.store " << op.getValueToStore(); p << ", " << op.getMemRef() << '['; if (AffineMapAttr mapAttr = - op.getAttrOfType(op.getMapAttrName())) + op->getAttrOfType(op.getMapAttrName())) p.printAffineMapOfSSAIds(mapAttr, op.getMapOperands()); p << ']'; p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{op.getMapAttrName()}); @@ -2252,7 +2254,7 @@ if (failed(verifyMemoryOpIndexing( op.getOperation(), - op.getAttrOfType(op.getMapAttrName()), + op->getAttrOfType(op.getMapAttrName()), op.getMapOperands(), memrefType, /*numIndexOperands=*/op.getNumOperands() - 2))) return failure(); @@ -2438,7 +2440,7 @@ static void print(OpAsmPrinter &p, AffinePrefetchOp op) { p << AffinePrefetchOp::getOperationName() << " " << op.memref() << '['; - AffineMapAttr mapAttr = op.getAttrOfType(op.getMapAttrName()); + AffineMapAttr mapAttr = op->getAttrOfType(op.getMapAttrName()); if (mapAttr) { SmallVector operands(op.getMapOperands()); p.printAffineMapOfSSAIds(mapAttr, operands); @@ -2454,7 +2456,7 @@ } static LogicalResult verify(AffinePrefetchOp op) { - auto mapAttr = op.getAttrOfType(op.getMapAttrName()); + auto mapAttr = op->getAttrOfType(op.getMapAttrName()); if (mapAttr) { AffineMap map = mapAttr.getValue(); if (map.getNumResults() != op.getMemRefType().getRank()) @@ -2624,7 +2626,7 @@ SmallVector newOperands(lbOperands); newOperands.append(ubOperands.begin(), ubOperands.end()); - getOperation()->setOperands(newOperands); + (*this)->setOperands(newOperands); lowerBoundsMapAttr(AffineMapAttr::get(map)); } @@ -2636,7 +2638,7 @@ SmallVector newOperands(getLowerBoundsOperands()); newOperands.append(ubOperands.begin(), ubOperands.end()); - getOperation()->setOperands(newOperands); + (*this)->setOperands(newOperands); upperBoundsMapAttr(AffineMapAttr::get(map)); } @@ -2880,7 +2882,7 @@ //===----------------------------------------------------------------------===// static LogicalResult verify(AffineYieldOp op) { - auto *parentOp = op.getParentOp(); + auto *parentOp = op->getParentOp(); auto results = parentOp->getResults(); auto operands = op.getOperands(); @@ -2960,7 +2962,7 @@ static void print(OpAsmPrinter &p, AffineVectorLoadOp op) { p << "affine.vector_load " << op.getMemRef() << '['; if (AffineMapAttr mapAttr = - op.getAttrOfType(op.getMapAttrName())) + op->getAttrOfType(op.getMapAttrName())) p.printAffineMapOfSSAIds(mapAttr, op.getMapOperands()); p << ']'; p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{op.getMapAttrName()}); @@ -2981,7 +2983,7 @@ MemRefType memrefType = op.getMemRefType(); if (failed(verifyMemoryOpIndexing( op.getOperation(), - op.getAttrOfType(op.getMapAttrName()), + op->getAttrOfType(op.getMapAttrName()), op.getMapOperands(), memrefType, /*numIndexOperands=*/op.getNumOperands() - 1))) return failure(); @@ -3048,7 +3050,7 @@ p << "affine.vector_store " << op.getValueToStore(); p << ", " << op.getMemRef() << '['; if (AffineMapAttr mapAttr = - op.getAttrOfType(op.getMapAttrName())) + op->getAttrOfType(op.getMapAttrName())) p.printAffineMapOfSSAIds(mapAttr, op.getMapOperands()); p << ']'; p.printOptionalAttrDict(op.getAttrs(), /*elidedAttrs=*/{op.getMapAttrName()}); @@ -3059,7 +3061,7 @@ MemRefType memrefType = op.getMemRefType(); if (failed(verifyMemoryOpIndexing( op.getOperation(), - op.getAttrOfType(op.getMapAttrName()), + op->getAttrOfType(op.getMapAttrName()), op.getMapOperands(), memrefType, /*numIndexOperands=*/op.getNumOperands() - 2))) return failure(); 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 @@ -221,7 +221,7 @@ // Canonicalize to remove dead else blocks (happens whenever an 'if' moves up // a sequence of affine.fors that are all perfectly nested). applyPatternsAndFoldGreedily( - hoistedIfOp.getParentWithTrait(), + hoistedIfOp->getParentWithTrait(), frozenPatterns); return success(); diff --git a/mlir/lib/Dialect/Async/IR/Async.cpp b/mlir/lib/Dialect/Async/IR/Async.cpp --- a/mlir/lib/Dialect/Async/IR/Async.cpp +++ b/mlir/lib/Dialect/Async/IR/Async.cpp @@ -102,7 +102,7 @@ static LogicalResult verify(YieldOp op) { // Get the underlying value types from async values returned from the // parent `async.execute` operation. - auto executeOp = op.getParentOfType(); + auto executeOp = op->getParentOfType(); auto types = llvm::map_range(executeOp.results(), [](const OpResult &result) { return result.getType().cast().getValueType(); }); 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 @@ -80,13 +80,13 @@ auto walkResult = module.walk([&module](LaunchFuncOp launchOp) -> WalkResult { // Ignore launches that are nested more or less deep than functions in the // module we are currently checking. - if (!launchOp.getParentOp() || - launchOp.getParentOp()->getParentOp() != module) + if (!launchOp->getParentOp() || + launchOp->getParentOp()->getParentOp() != module) return success(); // Ignore launch ops with missing attributes here. The errors will be // reported by the verifiers of those ops. - if (!launchOp.getAttrOfType( + if (!launchOp->getAttrOfType( LaunchFuncOp::getKernelAttrName())) return success(); @@ -434,7 +434,7 @@ result.addOperands({gridSize.x, gridSize.y, gridSize.z, blockSize.x, blockSize.y, blockSize.z}); result.addOperands(kernelOperands); - auto kernelModule = kernelFunc.getParentOfType(); + auto kernelModule = kernelFunc->getParentOfType(); auto kernelSymbol = builder.getSymbolRefAttr( kernelModule.getName(), {builder.getSymbolRefAttr(kernelFunc.getName())}); result.addAttribute(getKernelAttrName(), kernelSymbol); @@ -470,16 +470,17 @@ } static LogicalResult verify(LaunchFuncOp op) { - auto module = op.getParentOfType(); + auto module = op->getParentOfType(); if (!module) return op.emitOpError("expected to belong to a module"); - if (!module.getAttrOfType(GPUDialect::getContainerModuleAttrName())) + if (!module->getAttrOfType( + GPUDialect::getContainerModuleAttrName())) return op.emitOpError( "expected the closest surrounding module to have the '" + GPUDialect::getContainerModuleAttrName() + "' attribute"); - auto kernelAttr = op.getAttrOfType(op.getKernelAttrName()); + auto kernelAttr = op->getAttrOfType(op.getKernelAttrName()); if (!kernelAttr) return op.emitOpError("symbol reference attribute '" + op.getKernelAttrName() + "' must be specified"); @@ -522,7 +523,7 @@ /// workgroup memory. BlockArgument GPUFuncOp::addWorkgroupAttribution(Type type) { auto attrName = getNumWorkgroupAttributionsAttrName(); - auto attr = getAttrOfType(attrName); + auto attr = (*this)->getAttrOfType(attrName); setAttr(attrName, IntegerAttr::get(attr.getType(), attr.getValue() + 1)); return getBody().insertArgument(getType().getNumInputs() + attr.getInt(), type); @@ -777,7 +778,7 @@ } static LogicalResult verify(gpu::ReturnOp returnOp) { - GPUFuncOp function = returnOp.getParentOfType(); + GPUFuncOp function = returnOp->getParentOfType(); FunctionType funType = function.getType(); diff --git a/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp b/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp --- a/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/AsyncRegionRewriter.cpp @@ -140,7 +140,7 @@ ~DeferWaitCallback() { for (size_t i = 0; i < worklist.size(); ++i) { auto waitOp = worklist[i]; - auto executeOp = waitOp.getParentOfType(); + auto executeOp = waitOp->getParentOfType(); auto numDependencies = waitOp.asyncDependencies().size(); // Erase `gpu.wait` and return async dependencies from region instead. 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 @@ -243,7 +243,7 @@ auto funcWalkResult = func.walk([&](gpu::LaunchOp op) { llvm::SetVector operands; std::string kernelFnName = - Twine(op.getParentOfType().getName(), "_kernel").str(); + Twine(op->getParentOfType().getName(), "_kernel").str(); // Pull in instructions that can be sunk if (failed(sinkOperationsIntoLaunchOp(op))) diff --git a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp --- a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp @@ -123,7 +123,7 @@ MappingLevel mappingLevel = MapGrid) { // Do not try to add a mapping to already mapped loops or nested loops. if (parallelOp.getAttr(getMappingAttrName()) || - ((mappingLevel == MapGrid) && parallelOp.getParentOfType())) + ((mappingLevel == MapGrid) && parallelOp->getParentOfType())) return; MLIRContext *ctx = parallelOp.getContext(); diff --git a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp @@ -457,7 +457,7 @@ static LogicalResult verify(LandingpadOp op) { Value value; - if (LLVMFuncOp func = op.getParentOfType()) { + if (LLVMFuncOp func = op->getParentOfType()) { if (!func.personality().hasValue()) return op.emitError( "llvm.landingpad needs to be in a function with a personality"); @@ -985,11 +985,13 @@ } GlobalOp AddressOfOp::getGlobal() { - return lookupSymbolInModule(getParentOp(), global_name()); + return lookupSymbolInModule((*this)->getParentOp(), + global_name()); } LLVMFuncOp AddressOfOp::getFunction() { - return lookupSymbolInModule(getParentOp(), global_name()); + return lookupSymbolInModule((*this)->getParentOp(), + global_name()); } static LogicalResult verify(AddressOfOp op) { @@ -1203,7 +1205,7 @@ if (!LLVMPointerType::isValidElementType(op.getType())) return op.emitOpError( "expects type to be a valid element type for an LLVM pointer"); - if (op.getParentOp() && !satisfiesLLVMModule(op.getParentOp())) + if (op->getParentOp() && !satisfiesLLVMModule(op->getParentOp())) return op.emitOpError("must appear at the module level"); if (auto strAttr = op.getValueOrNull().dyn_cast_or_null()) { diff --git a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp --- a/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp +++ b/mlir/lib/Dialect/LLVMIR/IR/NVVMDialect.cpp @@ -109,8 +109,8 @@ "s or 8 floats"); } - auto alayout = op.getAttrOfType("alayout"); - auto blayout = op.getAttrOfType("blayout"); + auto alayout = op->getAttrOfType("alayout"); + auto blayout = op->getAttrOfType("blayout"); if (!(alayout && blayout) || !(alayout.getValue() == "row" || alayout.getValue() == "col") || diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -1139,7 +1139,7 @@ } static LogicalResult verify(linalg::YieldOp op) { - auto *parentOp = op.getParentOp(); + auto *parentOp = op->getParentOp(); if (parentOp->getNumRegions() != 1 || parentOp->getRegion(0).empty()) return op.emitOpError("expected single non-empty parent region"); diff --git a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp --- a/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp +++ b/mlir/lib/Dialect/Linalg/Transforms/CodegenStrategy.cpp @@ -67,7 +67,7 @@ // Post staged patterns transforms //===--------------------------------------------------------------------===// - ModuleOp module = func.getParentOfType(); + ModuleOp module = func->getParentOfType(); // Programmatic splitting of slow/fast path vector transfers. OwningRewritePatternList patterns; 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 @@ -89,8 +89,8 @@ func.walk([&](vector::TransferReadOp transferRead) { LLVM_DEBUG(DBGS() << "Candidate for hoisting: " << *transferRead.getOperation() << "\n"); - auto loop = dyn_cast(transferRead.getParentOp()); - LLVM_DEBUG(DBGS() << "Parent op: " << *transferRead.getParentOp() + auto loop = dyn_cast(transferRead->getParentOp()); + LLVM_DEBUG(DBGS() << "Parent op: " << *transferRead->getParentOp() << "\n"); if (!loop) return WalkResult::advance(); 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 @@ -97,7 +97,7 @@ Value attrType = op.type(); Optional attrValue = op.value(); - if (!attrValue && isa(op.getParentOp())) + if (!attrValue && isa(op->getParentOp())) return op.emitOpError("expected constant value when specified within a " "`pdl.rewrite`"); if (attrValue && attrType) @@ -273,7 +273,7 @@ } static LogicalResult verify(OperationOp op) { - bool isWithinRewrite = isa(op.getParentOp()); + bool isWithinRewrite = isa(op->getParentOp()); if (isWithinRewrite && !op.name()) return op.emitOpError("must have an operation name when nested within " "a `pdl.rewrite`"); 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 @@ -1172,7 +1172,7 @@ static LogicalResult verify(ReduceReturnOp op) { // The type of the return value should be the same type as the type of the // operand of the enclosing ReduceOp. - auto reduceOp = cast(op.getParentOp()); + auto reduceOp = cast(op->getParentOp()); Type reduceType = reduceOp.operand().getType(); if (reduceType != op.result().getType()) return op.emitOpError() << "needs to have type " << reduceType 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 @@ -144,7 +144,7 @@ target.addDynamicallyLegalOp([&](scf::YieldOp op) { // We only have conversions for a subset of ops that use scf.yield // terminators. - if (!isa(op.getParentOp())) + if (!isa(op->getParentOp())) return true; return typeConverter.isLegal(op.getOperandTypes()); }); diff --git a/mlir/lib/Dialect/SCF/Transforms/Utils.cpp b/mlir/lib/Dialect/SCF/Transforms/Utils.cpp --- a/mlir/lib/Dialect/SCF/Transforms/Utils.cpp +++ b/mlir/lib/Dialect/SCF/Transforms/Utils.cpp @@ -89,7 +89,7 @@ // Outline before current function. OpBuilder::InsertionGuard g(b); - b.setInsertionPoint(ifOp.getParentOfType()); + b.setInsertionPoint(ifOp->getParentOfType()); llvm::SetVector captures; getUsedValuesDefinedAbove(ifOrElseRegion, captures); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp --- a/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVLowering.cpp @@ -523,7 +523,7 @@ // Look through all global variables in the given `body` block and check if // there is a spv.globalVariable that has the same `builtin` attribute. for (auto varOp : body.getOps()) { - if (auto builtinAttr = varOp.getAttrOfType( + if (auto builtinAttr = varOp->getAttrOfType( spirv::SPIRVDialect::getAttributeName( spirv::Decoration::BuiltIn))) { auto varBuiltIn = spirv::symbolizeBuiltIn(builtinAttr.getValue()); diff --git a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp --- a/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp +++ b/mlir/lib/Dialect/SPIRV/SPIRVOps.cpp @@ -1046,7 +1046,7 @@ static LogicalResult verify(spirv::AddressOfOp addressOfOp) { auto varOp = dyn_cast_or_null( - SymbolTable::lookupNearestSymbolFrom(addressOfOp.getParentOp(), + SymbolTable::lookupNearestSymbolFrom(addressOfOp->getParentOp(), addressOfOp.variable())); if (!varOp) { return addressOfOp.emitOpError("expected spv.globalVariable symbol"); @@ -1849,7 +1849,7 @@ auto funcOp = dyn_cast_or_null(SymbolTable::lookupNearestSymbolFrom( - functionCallOp.getParentOp(), fnName)); + functionCallOp->getParentOp(), fnName)); if (!funcOp) { return functionCallOp.emitOpError("callee function '") << fnName << "' not found in nearest symbol table"; @@ -1898,7 +1898,7 @@ } CallInterfaceCallable spirv::FunctionCallOp::getCallableForCallee() { - return getAttrOfType(kCallee); + return (*this)->getAttrOfType(kCallee); } Operation::operand_range spirv::FunctionCallOp::getArgOperands() { @@ -2005,9 +2005,9 @@ } if (auto init = - varOp.getAttrOfType(kInitializerAttrName)) { + varOp->getAttrOfType(kInitializerAttrName)) { Operation *initOp = SymbolTable::lookupNearestSymbolFrom( - varOp.getParentOp(), init.getValue()); + varOp->getParentOp(), init.getValue()); // TODO: Currently only variable initialization with specialization // constants and other variables is supported. They could be normal // constants in the module scope as well. @@ -2066,7 +2066,7 @@ // SPIR-V spec: "Before version 1.5, Id must come from a // constant instruction. auto targetEnv = spirv::getDefaultTargetEnv(broadcastOp.getContext()); - if (auto spirvModule = broadcastOp.getParentOfType()) + if (auto spirvModule = broadcastOp->getParentOfType()) targetEnv = spirv::lookupTargetEnvOrDefault(spirvModule); if (targetEnv.getVersion() < spirv::Version::V_1_5) { @@ -2407,12 +2407,12 @@ //===----------------------------------------------------------------------===// static LogicalResult verify(spirv::MergeOp mergeOp) { - auto *parentOp = mergeOp.getParentOp(); + auto *parentOp = mergeOp->getParentOp(); if (!parentOp || !isa(parentOp)) return mergeOp.emitOpError( "expected parent op to be 'spv.selection' or 'spv.loop'"); - Block &parentLastBlock = mergeOp.getParentRegion()->back(); + Block &parentLastBlock = mergeOp->getParentRegion()->back(); if (mergeOp.getOperation() != parentLastBlock.getTerminator()) return mergeOp.emitOpError( "can only be used in the last block of 'spv.selection' or 'spv.loop'"); @@ -2577,7 +2577,7 @@ static LogicalResult verify(spirv::ReferenceOfOp referenceOfOp) { auto *specConstSym = SymbolTable::lookupNearestSymbolFrom( - referenceOfOp.getParentOp(), referenceOfOp.spec_const()); + referenceOfOp->getParentOp(), referenceOfOp.spec_const()); Type constType; auto specConstOp = dyn_cast_or_null(specConstSym); @@ -2792,13 +2792,13 @@ static void print(spirv::SpecConstantOp constOp, OpAsmPrinter &printer) { printer << spirv::SpecConstantOp::getOperationName() << ' '; printer.printSymbolName(constOp.sym_name()); - if (auto specID = constOp.getAttrOfType(kSpecIdAttrName)) + if (auto specID = constOp->getAttrOfType(kSpecIdAttrName)) printer << ' ' << kSpecIdAttrName << '(' << specID.getInt() << ')'; printer << " = " << constOp.default_value(); } static LogicalResult verify(spirv::SpecConstantOp constOp) { - if (auto specID = constOp.getAttrOfType(kSpecIdAttrName)) + if (auto specID = constOp->getAttrOfType(kSpecIdAttrName)) if (specID.getValue().isNegative()) return constOp.emitOpError("SpecId cannot be negative"); @@ -3383,7 +3383,7 @@ auto constituentSpecConstOp = dyn_cast(SymbolTable::lookupNearestSymbolFrom( - constOp.getParentOp(), constituent.getValue())); + constOp->getParentOp(), constituent.getValue())); if (constituentSpecConstOp.default_value().getType() != cType.getElementType(index)) @@ -3400,7 +3400,7 @@ //===----------------------------------------------------------------------===// static LogicalResult verify(spirv::YieldOp yieldOp) { - Operation *parentOp = yieldOp.getParentOp(); + Operation *parentOp = yieldOp->getParentOp(); if (!parentOp || !isa(parentOp)) return yieldOp.emitOpError( 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 @@ -638,8 +638,8 @@ } void Serializer::processMemoryModel() { - uint32_t mm = module.getAttrOfType("memory_model").getInt(); - uint32_t am = module.getAttrOfType("addressing_model").getInt(); + uint32_t mm = module->getAttrOfType("memory_model").getInt(); + uint32_t am = module->getAttrOfType("addressing_model").getInt(); encodeInstructionInto(memoryModel, spirv::Opcode::OpMemoryModel, {am, mm}); } @@ -656,7 +656,7 @@ if (auto resultID = prepareConstantScalar(op.getLoc(), op.default_value(), /*isSpec=*/true)) { // Emit the OpDecorate instruction for SpecId. - if (auto specID = op.getAttrOfType("spec_id")) { + if (auto specID = op->getAttrOfType("spec_id")) { auto val = static_cast(specID.getInt()); emitDecoration(resultID, spirv::Decoration::SpecId, {val}); } @@ -1973,7 +1973,7 @@ SmallVector operands; for (auto argName : argNames) { - auto argIntAttr = op.getAttrOfType(argName); + auto argIntAttr = op->getAttrOfType(argName); auto operand = prepareConstantInt(op.getLoc(), argIntAttr); if (!operand) { return failure(); @@ -2020,7 +2020,7 @@ SmallVector operands; for (auto argName : argNames) { - auto argIntAttr = op.getAttrOfType(argName); + auto argIntAttr = op->getAttrOfType(argName); auto operand = prepareConstantInt(op.getLoc(), argIntAttr); if (!operand) { return failure(); diff --git a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/DecorateSPIRVCompositeTypeLayoutPass.cpp @@ -63,7 +63,7 @@ LogicalResult matchAndRewrite(spirv::AddressOfOp op, PatternRewriter &rewriter) const override { - auto spirvModule = op.getParentOfType(); + auto spirvModule = op->getParentOfType(); auto varName = op.variable(); auto varOp = spirvModule.lookupSymbol(varName); diff --git a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp --- a/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp +++ b/mlir/lib/Dialect/SPIRV/Transforms/LowerABIAttributesPass.cpp @@ -27,7 +27,7 @@ createGlobalVarForEntryPointArgument(OpBuilder &builder, spirv::FuncOp funcOp, unsigned argIndex, spirv::InterfaceVarABIAttr abiInfo) { - auto spirvModule = funcOp.getParentOfType(); + auto spirvModule = funcOp->getParentOfType(); if (!spirvModule) return nullptr; @@ -70,7 +70,7 @@ static LogicalResult getInterfaceVariables(spirv::FuncOp funcOp, SmallVectorImpl &interfaceVars) { - auto module = funcOp.getParentOfType(); + auto module = funcOp->getParentOfType(); if (!module) { return failure(); } @@ -108,13 +108,13 @@ OpBuilder &builder) { auto entryPointAttrName = spirv::getEntryPointABIAttrName(); auto entryPointAttr = - funcOp.getAttrOfType(entryPointAttrName); + funcOp->getAttrOfType(entryPointAttrName); if (!entryPointAttr) { return failure(); } OpBuilder::InsertionGuard moduleInsertionGuard(builder); - auto spirvModule = funcOp.getParentOfType(); + auto spirvModule = funcOp->getParentOfType(); builder.setInsertionPoint(spirvModule.body().front().getTerminator()); // Adds the spv.EntryPointOp after collecting all the interface variables @@ -169,7 +169,7 @@ LogicalResult ProcessInterfaceVarABI::matchAndRewrite( spirv::FuncOp funcOp, ArrayRef operands, ConversionPatternRewriter &rewriter) const { - if (!funcOp.getAttrOfType( + if (!funcOp->getAttrOfType( spirv::getEntryPointABIAttrName())) { // TODO: Non-entry point functions are not handled. return failure(); @@ -271,7 +271,7 @@ SmallVector entryPointFns; auto entryPointAttrName = spirv::getEntryPointABIAttrName(); module.walk([&](spirv::FuncOp funcOp) { - if (funcOp.getAttrOfType(entryPointAttrName)) { + if (funcOp->getAttrOfType(entryPointAttrName)) { entryPointFns.push_back(funcOp); } }); diff --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp b/mlir/lib/Dialect/Shape/IR/Shape.cpp --- a/mlir/lib/Dialect/Shape/IR/Shape.cpp +++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp @@ -832,7 +832,7 @@ //===----------------------------------------------------------------------===// static LogicalResult verify(shape::YieldOp op) { - auto *parentOp = op.getParentOp(); + auto *parentOp = op->getParentOp(); auto results = parentOp->getResults(); auto operands = op.getOperands(); diff --git a/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp b/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp --- a/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp +++ b/mlir/lib/Dialect/Shape/Transforms/ShapeToShapeLowering.cpp @@ -34,7 +34,7 @@ PatternRewriter &rewriter) const { auto loc = op.getLoc(); Type valueType = op.getResult().getType(); - Value init = op.getDialect() + Value init = op->getDialect() ->materializeConstant(rewriter, rewriter.getIndexAttr(1), valueType, loc) ->getResult(0); 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 @@ -287,7 +287,7 @@ static LogicalResult verify(AllocaOp op) { // An alloca op needs to have an ancestor with an allocation scope trait. - if (!op.getParentWithTrait()) + if (!op->getParentWithTrait()) return op.emitOpError( "requires an ancestor op with AutomaticAllocationScope trait"); @@ -547,7 +547,7 @@ //===----------------------------------------------------------------------===// static LogicalResult verify(AtomicYieldOp op) { - Type parentType = op.getParentOp()->getResultTypes().front(); + Type parentType = op->getParentOp()->getResultTypes().front(); Type resultType = op.result().getType(); if (parentType != resultType) return op.emitOpError() << "types mismatch between yield op: " << resultType @@ -660,9 +660,7 @@ void BranchOp::setDest(Block *block) { return setSuccessor(block); } -void BranchOp::eraseOperand(unsigned index) { - getOperation()->eraseOperand(index); -} +void BranchOp::eraseOperand(unsigned index) { (*this)->eraseOperand(index); } void BranchOp::getCanonicalizationPatterns(OwningRewritePatternList &results, MLIRContext *context) { @@ -684,7 +682,7 @@ LogicalResult CallOp::verifySymbolUses(SymbolTableCollection &symbolTable) { // Check that the callee attribute was specified. - auto fnAttr = getAttrOfType("callee"); + auto fnAttr = (*this)->getAttrOfType("callee"); if (!fnAttr) return emitOpError("requires a 'callee' symbol reference attribute"); FuncOp fn = symbolTable.lookupNearestSymbolFrom(*this, fnAttr); @@ -1176,7 +1174,7 @@ // Try to find the referenced function. auto fn = - op.getParentOfType().lookupSymbol(fnAttr.getValue()); + op->getParentOfType().lookupSymbol(fnAttr.getValue()); if (!fn) return op.emitOpError() << "reference to undefined function '" << fnAttr.getValue() << "'"; @@ -2626,7 +2624,7 @@ //===----------------------------------------------------------------------===// static LogicalResult verify(ReturnOp op) { - auto function = cast(op.getParentOp()); + auto function = cast(op->getParentOp()); // The operand number and types must match the function signature. const auto &results = function.getType().getResults(); diff --git a/mlir/lib/Dialect/Vector/VectorTransferOpTransforms.cpp b/mlir/lib/Dialect/Vector/VectorTransferOpTransforms.cpp --- a/mlir/lib/Dialect/Vector/VectorTransferOpTransforms.cpp +++ b/mlir/lib/Dialect/Vector/VectorTransferOpTransforms.cpp @@ -190,7 +190,7 @@ if (lastwrite == nullptr) return; - Region *topRegion = lastwrite.getParentRegion(); + Region *topRegion = lastwrite->getParentRegion(); Operation *readAncestor = findAncestorOpInRegion(topRegion, read); assert(readAncestor && "read op should be recursively part of the top region"); 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 @@ -2417,7 +2417,7 @@ // Top of the function `alloc` for transient storage. Value alloc; { - FuncOp funcOp = xferOp.getParentOfType(); + FuncOp funcOp = xferOp->getParentOfType(); OpBuilder::InsertionGuard guard(b); b.setInsertionPointToStart(&funcOp.getRegion().front()); auto shape = xferOp.getVectorType().getShape(); diff --git a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp --- a/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp +++ b/mlir/lib/Target/LLVMIR/ConvertToROCDLIR.cpp @@ -86,7 +86,8 @@ // 2. Insert amdgpu-flat-workgroup-size(1, 1024) attribute. for (auto func : ModuleTranslation::getModuleBody(m).getOps()) { - if (!func.getAttrOfType(gpu::GPUDialect::getKernelFuncAttrName())) + if (!func->getAttrOfType( + gpu::GPUDialect::getKernelFuncAttrName())) continue; auto *llvmFunc = llvmModule->getFunction(func.getName()); 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 @@ -414,7 +414,7 @@ // Don't allow inlining if the target is an ancestor of the call. This // prevents inlining recursively. if (resolvedCall.targetNode->getCallableRegion()->isAncestor( - resolvedCall.call.getParentRegion())) + resolvedCall.call->getParentRegion())) return false; // Otherwise, inline. diff --git a/mlir/lib/Transforms/LoopCoalescing.cpp b/mlir/lib/Transforms/LoopCoalescing.cpp --- a/mlir/lib/Transforms/LoopCoalescing.cpp +++ b/mlir/lib/Transforms/LoopCoalescing.cpp @@ -25,7 +25,7 @@ func.walk([](scf::ForOp op) { // Ignore nested loops. - if (op.getParentOfType()) + if (op->getParentOfType()) return; SmallVector loops; 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 @@ -329,7 +329,7 @@ // Builder used for any conversion operations that need to be materialized. OpBuilder castBuilder(call); Location castLoc = call.getLoc(); - auto *callInterface = interface.getInterfaceFor(call.getDialect()); + const auto *callInterface = interface.getInterfaceFor(call->getDialect()); // Map the provided call operands to the arguments of the region. BlockAndValueMapping mapper; 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 @@ -402,7 +402,7 @@ bool mlir::getLoopNestStats(AffineForOp forOpRoot, LoopNestStats *stats) { auto walkResult = forOpRoot.walk([&](AffineForOp forOp) { auto *childForOp = forOp.getOperation(); - auto *parentForOp = forOp.getParentOp(); + auto *parentForOp = forOp->getParentOp(); if (!llvm::isa(parentForOp)) { if (!isa(parentForOp)) { LLVM_DEBUG(llvm::dbgs() << "Expected parent AffineForOp"); 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 @@ -163,7 +163,7 @@ auto *parentBlock = forOp->getBlock(); if (!iv.use_empty()) { if (forOp.hasConstantLowerBound()) { - OpBuilder topBuilder(forOp.getParentOfType().getBody()); + OpBuilder topBuilder(forOp->getParentOfType().getBody()); auto constOp = topBuilder.create( forOp.getLoc(), forOp.getConstantLowerBound()); iv.replaceAllUsesWith(constOp); @@ -1484,7 +1484,7 @@ auto enclosingLoop = loops.front(); for (auto loop : loops.drop_front()) { - auto parentForOp = dyn_cast(loop.getParentOp()); + auto parentForOp = dyn_cast(loop->getParentOp()); // parentForOp's body should be just this loop and the terminator. if (parentForOp != enclosingLoop || !hasTwoElements(parentForOp.getBody())) return false; @@ -3073,7 +3073,7 @@ // Each successive for op has to be nested in the other. auto prevLoop = firstLoop; for (auto loop : inputNest.drop_front(1)) { - assert(loop.getParentOp() == prevLoop && "input not contiguously nested"); + assert(loop->getParentOp() == prevLoop && "input not contiguously nested"); prevLoop = loop; } diff --git a/mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp b/mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp --- a/mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp +++ b/mlir/test/lib/Dialect/Shape/TestShapeFunctions.cpp @@ -57,7 +57,7 @@ module.getBodyRegion().walk([&](FuncOp func) { // Skip ops in the shape function library. - if (isa(func.getParentOp())) + if (isa(func->getParentOp())) return; func.walk([&](Operation *op) { remarkShapeFn(op); }); diff --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp b/mlir/test/lib/Dialect/Test/TestDialect.cpp --- a/mlir/test/lib/Dialect/Test/TestDialect.cpp +++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp @@ -726,7 +726,7 @@ void SideEffectOp::getEffects( SmallVectorImpl &effects) { // Check for an effects attribute on the op instance. - ArrayAttr effectsAttr = getAttrOfType("effects"); + ArrayAttr effectsAttr = (*this)->getAttrOfType("effects"); if (!effectsAttr) return; @@ -761,7 +761,7 @@ void SideEffectOp::getEffects( SmallVectorImpl &effects) { - auto effectsAttr = getAttrOfType("effect_parameter"); + auto effectsAttr = (*this)->getAttrOfType("effect_parameter"); if (!effectsAttr) return; diff --git a/mlir/test/lib/Dialect/Test/TestOps.td b/mlir/test/lib/Dialect/Test/TestOps.td --- a/mlir/test/lib/Dialect/Test/TestOps.td +++ b/mlir/test/lib/Dialect/Test/TestOps.td @@ -321,7 +321,7 @@ /// Return the callee of this operation. CallInterfaceCallable getCallableForCallee() { - return getAttrOfType("callee"); + return (*this)->getAttrOfType("callee"); } }]; } diff --git a/mlir/test/lib/Dialect/Test/TestPatterns.cpp b/mlir/test/lib/Dialect/Test/TestPatterns.cpp --- a/mlir/test/lib/Dialect/Test/TestPatterns.cpp +++ b/mlir/test/lib/Dialect/Test/TestPatterns.cpp @@ -899,7 +899,7 @@ matchAndRewrite(SingleBlockImplicitTerminatorOp op, ArrayRef operands, ConversionPatternRewriter &rewriter) const final { SingleBlockImplicitTerminatorOp parentOp = - op.getParentOfType(); + op->getParentOfType(); if (!parentOp) return failure(); Block &innerBlock = op.region().front(); @@ -936,14 +936,14 @@ /// Only allow `test.br` within test.merge_blocks op. target.addDynamicallyLegalOp([&](TestBranchOp op) -> bool { - return op.getParentOfType(); + return op->getParentOfType(); }); /// Expect that all nested test.SingleBlockImplicitTerminator ops are /// inlined. target.addDynamicallyLegalOp( [&](SingleBlockImplicitTerminatorOp op) -> bool { - return !op.getParentOfType(); + return !op->getParentOfType(); }); DenseSet unlegalizedOps; diff --git a/mlir/test/lib/IR/TestFunc.cpp b/mlir/test/lib/IR/TestFunc.cpp --- a/mlir/test/lib/IR/TestFunc.cpp +++ b/mlir/test/lib/IR/TestFunc.cpp @@ -68,7 +68,7 @@ SymbolTable symbolTable(module); for (FuncOp func : module.getOps()) { - auto sym = func.getAttrOfType("test.set_type_from"); + auto sym = func->getAttrOfType("test.set_type_from"); if (!sym) continue; func.setType(symbolTable.lookup(sym.getValue()).getType()); diff --git a/mlir/test/lib/Transforms/TestAffineLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestAffineLoopParametricTiling.cpp --- a/mlir/test/lib/Transforms/TestAffineLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestAffineLoopParametricTiling.cpp @@ -33,7 +33,7 @@ assert(!band.empty() && "no loops in input band"); AffineForOp topLoop = band[0]; - if (FuncOp funcOp = dyn_cast(topLoop.getParentOp())) + if (FuncOp funcOp = dyn_cast(topLoop->getParentOp())) assert(funcOp.getNumArguments() >= band.size() && "Too few tile sizes"); } @@ -44,7 +44,7 @@ static void getTilingParameters(ArrayRef band, SmallVectorImpl &tilingParameters) { AffineForOp topLoop = band[0]; - Region *funcOpRegion = topLoop.getParentRegion(); + Region *funcOpRegion = topLoop->getParentRegion(); unsigned nestDepth = band.size(); for (BlockArgument blockArgument : 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 @@ -192,7 +192,7 @@ pm.addPass(createLoopInvariantCodeMotionPass()); pm.addPass(createCanonicalizerPass()); pm.addPass(createCSEPass()); - LogicalResult res = pm.run(getFunction().getParentOfType()); + LogicalResult res = pm.run(getFunction()->getParentOfType()); if (failed(res)) this->signalPassFailure(); } diff --git a/mlir/test/lib/Transforms/TestLoopMapping.cpp b/mlir/test/lib/Transforms/TestLoopMapping.cpp --- a/mlir/test/lib/Transforms/TestLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestLoopMapping.cpp @@ -43,7 +43,7 @@ func.walk([&processorIds, &numProcessors](scf::ForOp op) { // Ignore nested loops. - if (op.getParentRegion()->getParentOfType()) + if (op->getParentRegion()->getParentOfType()) return; mapLoopToProcessorIds(op, processorIds, numProcessors); }); diff --git a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp --- a/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp +++ b/mlir/test/lib/Transforms/TestLoopParametricTiling.cpp @@ -35,7 +35,7 @@ FuncOp func = getFunction(); func.walk([this](scf::ForOp op) { // Ignore nested loops. - if (op.getParentRegion()->getParentOfType()) + if (op->getParentRegion()->getParentOfType()) return; extractFixedOuterLoops(op, sizes); }); diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -71,11 +71,11 @@ // --- // DEF: void AOp::aAttrAttr(some-attr-kind attr) { -// DEF-NEXT: this->getOperation()->setAttr("aAttr", attr); +// DEF-NEXT: (*this)->setAttr("aAttr", attr); // DEF: void AOp::bAttrAttr(some-attr-kind attr) { -// DEF-NEXT: this->getOperation()->setAttr("bAttr", attr); +// DEF-NEXT: (*this)->setAttr("bAttr", attr); // DEF: void AOp::cAttrAttr(some-attr-kind attr) { -// DEF-NEXT: this->getOperation()->setAttr("cAttr", attr); +// DEF-NEXT: (*this)->setAttr("cAttr", attr); // Test build methods // --- 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 @@ -90,7 +90,8 @@ auto sizeAttr = odsAttrs.get("{0}").cast<::mlir::DenseIntElementsAttr>(); )"; const char *opSegmentSizeAttrInitCode = R"( - auto sizeAttr = getAttrOfType<::mlir::DenseIntElementsAttr>("{0}"); + auto sizeAttr = + getOperation()->getAttrOfType<::mlir::DenseIntElementsAttr>("{0}"); )"; const char *attrSizedSegmentValueRangeCalcCode = R"( unsigned start = 0; @@ -614,7 +615,7 @@ if (!method) return; auto &body = method->body(); - body << " this->getOperation()->setAttr(\"" << name << "\", attr);"; + body << " (*this)->setAttr(\"" << name << "\", attr);"; }; for (auto &namedAttr : op.getAttributes()) {