diff --git a/mlir/lib/Dialect/Arith/Utils/Utils.cpp b/mlir/lib/Dialect/Arith/Utils/Utils.cpp index 67dcce454f028..0fa7d32184411 100644 --- a/mlir/lib/Dialect/Arith/Utils/Utils.cpp +++ b/mlir/lib/Dialect/Arith/Utils/Utils.cpp @@ -66,7 +66,7 @@ mlir::inferExpandShapeOutputShape(OpBuilder &b, Location loc, int64_t inputIndex = it.index(); // Call get() under the assumption that we're not casting // dynamism. - Value indexGroupSize = inputShape[inputIndex].get(); + Value indexGroupSize = cast(inputShape[inputIndex]); Value indexGroupStaticSizesProduct = b.create(loc, indexGroupStaticSizesProductInt); Value dynamicDimSize = b.createOrFold( diff --git a/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp b/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp index f8a7a22787404..349841f06959c 100644 --- a/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp +++ b/mlir/lib/Dialect/Bufferization/IR/BufferizableOpInterface.cpp @@ -174,7 +174,7 @@ FailureOr bufferization::allocateTensorForShapedValue( resultDims[llvm::cast(shapedValue).getResultNumber()]; for (const auto &dim : enumerate(tensorType.getShape())) if (ShapedType::isDynamic(dim.value())) - dynamicSizes.push_back(shape[dim.index()].get()); + dynamicSizes.push_back(cast(shape[dim.index()])); } } diff --git a/mlir/lib/Dialect/DLTI/DLTI.cpp b/mlir/lib/Dialect/DLTI/DLTI.cpp index 508e50d42e4cf..2510e774f2b2a 100644 --- a/mlir/lib/Dialect/DLTI/DLTI.cpp +++ b/mlir/lib/Dialect/DLTI/DLTI.cpp @@ -312,7 +312,7 @@ combineOneSpec(DataLayoutSpecInterface spec, continue; } - Type typeSample = kvp.second.front().getKey().get(); + Type typeSample = cast(kvp.second.front().getKey()); assert(&typeSample.getDialect() != typeSample.getContext()->getLoadedDialect() && "unexpected data layout entry for built-in type"); @@ -325,7 +325,7 @@ combineOneSpec(DataLayoutSpecInterface spec, } for (const auto &kvp : newEntriesForID) { - StringAttr id = kvp.second.getKey().get(); + StringAttr id = cast(kvp.second.getKey()); Dialect *dialect = id.getReferencedDialect(); if (!entriesForID.count(id)) { entriesForID[id] = kvp.second; @@ -574,7 +574,7 @@ class TargetDataLayoutInterface : public DataLayoutDialectInterface { LogicalResult verifyEntry(DataLayoutEntryInterface entry, Location loc) const final { - StringRef entryName = entry.getKey().get().strref(); + StringRef entryName = cast(entry.getKey()).strref(); if (entryName == DLTIDialect::kDataLayoutEndiannessKey) { auto value = dyn_cast(entry.getValue()); if (value && diff --git a/mlir/lib/Dialect/GPU/TransformOps/Utils.cpp b/mlir/lib/Dialect/GPU/TransformOps/Utils.cpp index 17bda27b55811..f4d36129bae77 100644 --- a/mlir/lib/Dialect/GPU/TransformOps/Utils.cpp +++ b/mlir/lib/Dialect/GPU/TransformOps/Utils.cpp @@ -113,16 +113,17 @@ static GpuIdBuilderFnType commonLinearIdBuilderFn(int64_t multiplicity = 1) { // clang-format on // Return n-D ids for indexing and 1-D size + id for predicate generation. - return IdBuilderResult{ - /*mappingIdOps=*/ids, - /*availableMappingSizes=*/ - SmallVector{computeProduct(originalBasis)}, - // `forallMappingSizes` iterate in the scaled basis, they need to be - // scaled back into the original basis to provide tight - // activeMappingSizes quantities for predication. - /*activeMappingSizes=*/ - SmallVector{computeProduct(forallMappingSizes) * multiplicity}, - /*activeIdOps=*/SmallVector{linearId.get()}}; + return IdBuilderResult{ + /*mappingIdOps=*/ids, + /*availableMappingSizes=*/ + SmallVector{computeProduct(originalBasis)}, + // `forallMappingSizes` iterate in the scaled basis, they need to be + // scaled back into the original basis to provide tight + // activeMappingSizes quantities for predication. + /*activeMappingSizes=*/ + SmallVector{computeProduct(forallMappingSizes) * + multiplicity}, + /*activeIdOps=*/SmallVector{cast(linearId)}}; }; return res; @@ -144,9 +145,8 @@ static GpuIdBuilderFnType common3DIdBuilderFn(int64_t multiplicity = 1) { // In the 3-D mapping case, scale the first dimension by the multiplicity. SmallVector scaledIds = ids; AffineExpr d0 = getAffineDimExpr(0, rewriter.getContext()); - scaledIds[0] = affine::makeComposedFoldedAffineApply( - rewriter, loc, d0.floorDiv(multiplicity), {scaledIds[0]}) - .get(); + scaledIds[0] = cast(affine::makeComposedFoldedAffineApply( + rewriter, loc, d0.floorDiv(multiplicity), {scaledIds[0]})); // In the 3-D mapping case, unscale the first dimension by the multiplicity. SmallVector forallMappingSizeInOriginalBasis(forallMappingSizes); forallMappingSizeInOriginalBasis[0] *= multiplicity; diff --git a/mlir/lib/Dialect/Mesh/Transforms/Transforms.cpp b/mlir/lib/Dialect/Mesh/Transforms/Transforms.cpp index 60c4e07a118cb..447668cc0ea50 100644 --- a/mlir/lib/Dialect/Mesh/Transforms/Transforms.cpp +++ b/mlir/lib/Dialect/Mesh/Transforms/Transforms.cpp @@ -217,7 +217,7 @@ TypedValue createProcessLinearIndex(StringRef mesh, OpFoldResult processInGroupLinearIndex = affine::linearizeIndex( llvm::to_vector_of(processInGroupMultiIndex), llvm::to_vector_of(processGroupShape), builder); - return cast>(processInGroupLinearIndex.get()); + return cast>(cast(processInGroupLinearIndex)); } } // namespace mlir::mesh diff --git a/mlir/lib/Dialect/Ptr/IR/PtrTypes.cpp b/mlir/lib/Dialect/Ptr/IR/PtrTypes.cpp index 2866d4eb10feb..49c8ed977d50c 100644 --- a/mlir/lib/Dialect/Ptr/IR/PtrTypes.cpp +++ b/mlir/lib/Dialect/Ptr/IR/PtrTypes.cpp @@ -33,7 +33,7 @@ static SpecAttr getPointerSpec(DataLayoutEntryListRef params, PtrType type) { for (DataLayoutEntryInterface entry : params) { if (!entry.isTypeEntry()) continue; - if (cast(entry.getKey().get()).getMemorySpace() == + if (cast(cast(entry.getKey())).getMemorySpace() == type.getMemorySpace()) { if (auto spec = dyn_cast(entry.getValue())) return spec; @@ -55,7 +55,7 @@ bool PtrType::areCompatible(DataLayoutEntryListRef oldLayout, continue; uint32_t size = kDefaultPointerSizeBits; uint32_t abi = kDefaultPointerAlignment; - auto newType = llvm::cast(newEntry.getKey().get()); + auto newType = llvm::cast(llvm::cast(newEntry.getKey())); const auto *it = llvm::find_if(oldLayout, [&](DataLayoutEntryInterface entry) { if (auto type = llvm::dyn_cast_if_present(entry.getKey())) { @@ -134,7 +134,7 @@ LogicalResult PtrType::verifyEntries(DataLayoutEntryListRef entries, for (DataLayoutEntryInterface entry : entries) { if (!entry.isTypeEntry()) continue; - auto key = entry.getKey().get(); + auto key = llvm::cast(entry.getKey()); if (!llvm::isa(entry.getValue())) { return emitError(loc) << "expected layout attribute for " << key << " to be a #ptr.spec attribute"; diff --git a/mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp b/mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp index 3e317319b68fc..191bb330df756 100644 --- a/mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp +++ b/mlir/lib/Dialect/SPIRV/IR/ControlFlowOps.cpp @@ -205,7 +205,7 @@ CallInterfaceCallable FunctionCallOp::getCallableForCallee() { } void FunctionCallOp::setCalleeFromCallable(CallInterfaceCallable callee) { - (*this)->setAttr(getCalleeAttrName(), callee.get()); + (*this)->setAttr(getCalleeAttrName(), cast(callee)); } Operation::operand_range FunctionCallOp::getArgOperands() { diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp index cb5874ff45068..ea5533dfc6bac 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.cpp @@ -87,7 +87,7 @@ static Value unFoldOpIntResult(OpBuilder &builder, Location loc, OpFoldResult ofr) { if (std::optional i = getConstantIntValue(ofr); i.has_value()) return constantIndex(builder, loc, *i); - return ofr.get(); + return cast(ofr); } static Value tryFoldTensors(Value t) { diff --git a/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp b/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp index fdd968238667e..1e0ef5add358e 100644 --- a/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp +++ b/mlir/lib/Dialect/Transform/Interfaces/TransformInterfaces.cpp @@ -1475,19 +1475,19 @@ transform::detail::checkApplyToOne(Operation *transformOp, if (ptr.isNull()) continue; if (llvm::isa(res.getType()) && - !ptr.is()) { + !isa(ptr)) { return emitDiag() << "application of " << transformOpName << " expected to produce an Operation * for result #" << res.getResultNumber(); } if (llvm::isa(res.getType()) && - !ptr.is()) { + !isa(ptr)) { return emitDiag() << "application of " << transformOpName << " expected to produce an Attribute for result #" << res.getResultNumber(); } if (llvm::isa(res.getType()) && - !ptr.is()) { + !isa(ptr)) { return emitDiag() << "application of " << transformOpName << " expected to produce a Value for result #" << res.getResultNumber(); @@ -1499,7 +1499,7 @@ transform::detail::checkApplyToOne(Operation *transformOp, template static SmallVector castVector(ArrayRef range) { return llvm::to_vector(llvm::map_range( - range, [](transform::MappedValue value) { return value.get(); })); + range, [](transform::MappedValue value) { return cast(value); })); } void transform::detail::setApplyToOneResults( diff --git a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp index 0b399fba3f263..5c8f6ded39ba4 100644 --- a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp +++ b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp @@ -50,7 +50,7 @@ void dispatchIndexOpFoldResult(OpFoldResult ofr, SmallVectorImpl &staticVec) { auto v = llvm::dyn_cast_if_present(ofr); if (!v) { - APInt apInt = cast(ofr.get()).getValue(); + APInt apInt = cast(cast(ofr)).getValue(); staticVec.push_back(apInt.getSExtValue()); return; } @@ -212,11 +212,11 @@ decomposeMixedValues(const SmallVectorImpl &mixedValues) { SmallVector staticValues; SmallVector dynamicValues; for (const auto &it : mixedValues) { - if (it.is()) { - staticValues.push_back(cast(it.get()).getInt()); + if (auto attr = dyn_cast(it)) { + staticValues.push_back(cast(attr).getInt()); } else { staticValues.push_back(ShapedType::kDynamic); - dynamicValues.push_back(it.get()); + dynamicValues.push_back(cast(it)); } } return {staticValues, dynamicValues}; @@ -294,10 +294,10 @@ LogicalResult foldDynamicIndexList(SmallVectorImpl &ofrs, bool onlyNonNegative, bool onlyNonZero) { bool valuesChanged = false; for (OpFoldResult &ofr : ofrs) { - if (ofr.is()) + if (isa(ofr)) continue; Attribute attr; - if (matchPattern(ofr.get(), m_Constant(&attr))) { + if (matchPattern(cast(ofr), m_Constant(&attr))) { // Note: All ofrs have index type. if (onlyNonNegative && *getConstantIntValue(attr) < 0) continue;