diff --git a/mlir/docs/DeclarativeRewrites.md b/mlir/docs/DeclarativeRewrites.md index fd566a2393b63..10cbd6d60e552 100644 --- a/mlir/docs/DeclarativeRewrites.md +++ b/mlir/docs/DeclarativeRewrites.md @@ -704,8 +704,8 @@ For example, we can write def HasNoUseOf: Constraint, "has no use">; def HasSameElementType : Constraint< - CPred<"$0.cast().getElementType() == " - "$1.cast().getElementType()">, + CPred<"cast($0).getElementType() == " + "cast($1).getElementType()">, "has same element type">; def : Pattern<(TwoResultOp:$results $input), diff --git a/mlir/docs/DefiningDialects/Operations.md b/mlir/docs/DefiningDialects/Operations.md index fafda816a3881..b8b0965c3b72e 100644 --- a/mlir/docs/DefiningDialects/Operations.md +++ b/mlir/docs/DefiningDialects/Operations.md @@ -1397,7 +1397,7 @@ is used. They serve as "hooks" to the enclosing environment. This includes information of the current operation. * `$_self` will be replaced with the entity this predicate is attached to. E.g., `BoolAttr` is an attribute constraint that wraps a - `CPred<"$_self.isa()">`. Then for `BoolAttr:$attr`,`$_self` will be + `CPred<"isa($_self)">`. Then for `BoolAttr:$attr`,`$_self` will be replaced by `$attr`. For type constraints, it's a little bit special since we want the constraints on each type definition reads naturally and we want to attach type constraints directly to an operand/result, `$_self` will be @@ -1409,8 +1409,8 @@ to allow referencing operand/result `$-name`s; such `$-name`s can start with underscore. For example, to write an attribute `attr` is an `IntegerAttr`, in C++ you can -just call `attr.isa()`. The code can be wrapped in a `CPred` as -`$_self.isa()`, with `$_self` as the special placeholder to be +just call `isa(attr)`. The code can be wrapped in a `CPred` as +`isa($_self)`, with `$_self` as the special placeholder to be replaced by the current attribute `attr` at expansion time. For more complicated predicates, you can wrap it in a single `CPred`, or you can @@ -1419,10 +1419,10 @@ that an attribute `attr` is a 32-bit or 64-bit integer, you can write it as ```tablegen And<[ - CPred<"$_self.isa()">, + CPred<"$isa(_self)()">, Or<[ - CPred<"$_self.cast().getType().isInteger(32)">, - CPred<"$_self.cast().getType().isInteger(64)"> + CPred<"cast($_self).getType().isInteger(32)">, + CPred<"cast($_self).getType().isInteger(64)"> ]> ]> ``` diff --git a/mlir/docs/DefiningDialects/_index.md b/mlir/docs/DefiningDialects/_index.md index 5196092dfbda1..987b51b4ab4ef 100644 --- a/mlir/docs/DefiningDialects/_index.md +++ b/mlir/docs/DefiningDialects/_index.md @@ -43,7 +43,7 @@ extends to all of the MLIR constructs, including [Interfaces](../Interfaces.md) ```tablegen // Include the definition of the necessary tablegen constructs for defining -// our dialect. +// our dialect. include "mlir/IR/DialectBase.td" // Here is a simple definition of a dialect. @@ -649,7 +649,7 @@ Type MyDialect::parseType(DialectAsmParser &parser) const { return dynType; return Type(); } - + ... } ``` @@ -669,7 +669,7 @@ It is also possible to cast a `Type` known to be defined at runtime to a `DynamicType`. ```c++ -auto dynType = type.cast(); +auto dynType = cast(type); auto typeDef = dynType.getTypeDef(); auto args = dynType.getParams(); ``` @@ -679,7 +679,7 @@ auto args = dynType.getParams(); Similar to types defined at runtime, attributes defined at runtime can only have as argument a list of `Attribute`. -Similarily to types, an attribute is defined at runtime using the class +Similarly to types, an attribute is defined at runtime using the class `DynamicAttrDefinition`, which is created using the `DynamicAttrDefinition::get` functions. An attribute definition requires a name, the dialect that will register the attribute, and a parameter verifier. It can also define optionally @@ -767,7 +767,7 @@ It is also possible to cast an `Attribute` known to be defined at runtime to a `DynamicAttr`. ```c++ -auto dynAttr = attr.cast(); +auto dynAttr = cast(attr); auto attrDef = dynAttr.getAttrDef(); auto args = dynAttr.getParams(); ``` diff --git a/mlir/docs/Diagnostics.md b/mlir/docs/Diagnostics.md index a6d59bdecbdd8..279682f9ff309 100644 --- a/mlir/docs/Diagnostics.md +++ b/mlir/docs/Diagnostics.md @@ -293,7 +293,7 @@ shown below: // function should not recurse into the child location. Recursion into nested // location is performed as necessary by the caller. auto shouldShowFn = [](Location loc) -> bool { - FileLineColLoc fileLoc = loc.dyn_cast(); + FileLineColLoc fileLoc = dyn_cast(loc); // We don't perform any filtering on non-file locations. // Reminder: The caller will recurse into any necessary child locations. diff --git a/mlir/docs/Interfaces.md b/mlir/docs/Interfaces.md index b7e9e64d23d77..521d8f30c6be8 100644 --- a/mlir/docs/Interfaces.md +++ b/mlir/docs/Interfaces.md @@ -256,7 +256,7 @@ struct ExampleTypeInterfaceTraits { struct ExternalModel : public FallbackModel { unsigned exampleInterfaceHook(Type type) const override { // Default implementation can be provided here. - return type.cast().callSomeTypeSpecificMethod(); + return cast(type).callSomeTypeSpecificMethod(); } }; }; diff --git a/mlir/docs/PDLL.md b/mlir/docs/PDLL.md index ee1b615a2dcde..9839d1d0df764 100644 --- a/mlir/docs/PDLL.md +++ b/mlir/docs/PDLL.md @@ -139,8 +139,8 @@ def HasNoUseOf: Constraint, "has no use">; // Check if two values have a ShapedType with the same element type. def HasSameElementType : Constraint< - CPred<"$0.getType().cast().getElementType() == " - "$1.getType().cast().getElementType()">, + CPred<"cast($0.getType()).getElementType() == " + "cast($1.getType()).getElementType()">, "values have same element type">; def : Pattern<(TwoResultOp:$results $input), @@ -161,8 +161,8 @@ Constraint HasNoUseOf(value: Value) [{ return success(value.use_empty()); }]; Constraint HasSameElementType(value1: Value, value2: Value) [{ - return success(value1.getType().cast().getElementType() == - value2.getType().cast().getElementType()); + return success(cast(value1.getType()).getElementType() == + cast(value2.getType()).getElementType()); }]; Pattern { @@ -1105,8 +1105,8 @@ static LogicalResult hasOneUseImpl(PatternRewriter &rewriter, Value value) { } static LogicalResult hasSameElementTypeImpl(PatternRewriter &rewriter, Value value1, Value Value2) { - return success(value1.getType().cast().getElementType() == - value2.getType().cast().getElementType()); + return success(cast(value1.getType()).getElementType() == + cast(value2.getType()).getElementType()); } void registerNativeConstraints(RewritePatternSet &patterns) { @@ -1129,8 +1129,8 @@ Constraint HasOneUse(value: Value) [{ return success(value.hasOneUse()); }]; Constraint HasSameElementType(value1: Value, value2: Value) [{ - return success(value1.getType().cast().getElementType() == - value2.getType().cast().getElementType()); + return success(cast(value1.getType()).getElementType() == + cast(value2.getType()).getElementType()); }]; Pattern { @@ -1160,8 +1160,8 @@ LogicalResult HasOneUse(PatternRewriter &rewriter, Value value) { return success(value.hasOneUse()); } LogicalResult HasSameElementType(Value value1, Value value2) { - return success(value1.getType().cast().getElementType() == - value2.getType().cast().getElementType()); + return success(cast(value1.getType()).getElementType() == + cast(value2.getType()).getElementType()); } ``` diff --git a/mlir/docs/Tutorials/QuickstartRewrites.md b/mlir/docs/Tutorials/QuickstartRewrites.md index 493f9d5687374..0c890659b0eea 100644 --- a/mlir/docs/Tutorials/QuickstartRewrites.md +++ b/mlir/docs/Tutorials/QuickstartRewrites.md @@ -132,7 +132,7 @@ static Value createTFLLeakyRelu(PatternRewriter &rewriter, Operation *op, Value operand, Attribute attr) { return rewriter.create( op->getLoc(), operands[0].getType(), /*arg=*/operands[0], - /*alpha=*/attrs[0].cast()); + /*alpha=*/cast(attrs[0])); } ``` diff --git a/mlir/docs/Tutorials/Toy/Ch-5.md b/mlir/docs/Tutorials/Toy/Ch-5.md index 7d4f95e4e17dc..d483cd8bba21d 100644 --- a/mlir/docs/Tutorials/Toy/Ch-5.md +++ b/mlir/docs/Tutorials/Toy/Ch-5.md @@ -75,8 +75,7 @@ void ToyToAffineLoweringPass::runOnOperation() { // only treat it as `legal` if its operands are legal. target.addIllegalDialect(); target.addDynamicallyLegalOp([](toy::PrintOp op) { - return llvm::none_of(op->getOperandTypes(), - [](Type type) { return type.isa(); }); + return llvm::none_of(op->getOperandTypes(), llvm::IsaPred); }); ... } diff --git a/mlir/docs/Tutorials/Toy/Ch-7.md b/mlir/docs/Tutorials/Toy/Ch-7.md index 2114bf6e039fb..dce3490aeace4 100644 --- a/mlir/docs/Tutorials/Toy/Ch-7.md +++ b/mlir/docs/Tutorials/Toy/Ch-7.md @@ -203,7 +203,7 @@ within the Dialect. A simple example is shown below: // using StructType in a similar way to Tensor or MemRef. We use `DialectType` // to demarcate the StructType as belonging to the Toy dialect. def Toy_StructType : - DialectType()">, + DialectType($_self)">, "Toy struct type">; // Provide a definition of the types that are used within the Toy dialect. @@ -274,7 +274,7 @@ mlir::Type ToyDialect::parseType(mlir::DialectAsmParser &parser) const { return nullptr; // Check that the type is either a TensorType or another StructType. - if (!elementType.isa()) { + if (!isa(elementType)) { parser.emitError(typeLoc, "element type for a struct must either " "be a TensorType or a StructType, got: ") << elementType; @@ -467,7 +467,7 @@ OpFoldResult StructConstantOp::fold(FoldAdaptor adaptor) { /// Fold simple struct access operations that access into a constant. OpFoldResult StructAccessOp::fold(FoldAdaptor adaptor) { - auto structAttr = adaptor.getInput().dyn_cast_or_null(); + auto structAttr = dyn_cast_or_null(adaptor.getInput()); if (!structAttr) return nullptr; @@ -487,11 +487,11 @@ mlir::Operation *ToyDialect::materializeConstant(mlir::OpBuilder &builder, mlir::Attribute value, mlir::Type type, mlir::Location loc) { - if (type.isa()) + if (isa(type)) return builder.create(loc, type, - value.cast()); + cast(value)); return builder.create(loc, type, - value.cast()); + cast(value)); } ``` diff --git a/mlir/docs/Tutorials/UnderstandingTheIRStructure.md b/mlir/docs/Tutorials/UnderstandingTheIRStructure.md index de8e0bea57921..595d6949a03f3 100644 --- a/mlir/docs/Tutorials/UnderstandingTheIRStructure.md +++ b/mlir/docs/Tutorials/UnderstandingTheIRStructure.md @@ -236,7 +236,7 @@ some information about them: } else { // If there is no defining op, the Value is necessarily a Block // argument. - auto blockArg = operand.cast(); + auto blockArg = cast(operand); llvm::outs() << " - Operand produced by Block argument, number " << blockArg.getArgNumber() << "\n"; } diff --git a/mlir/docs/Tutorials/transform/Ch4.md b/mlir/docs/Tutorials/transform/Ch4.md index 81263e10b0984..ac60fcb914685 100644 --- a/mlir/docs/Tutorials/transform/Ch4.md +++ b/mlir/docs/Tutorials/transform/Ch4.md @@ -355,7 +355,7 @@ mlir::transform::HasOperandSatisfyingOp::apply( transform::detail::prepareValueMappings( yieldedMappings, getBody().front().getTerminator()->getOperands(), state); - results.setParams(getPosition().cast(), + results.setParams(cast(getPosition()), {rewriter.getI32IntegerAttr(operand.getOperandNumber())}); for (auto &&[result, mapping] : llvm::zip(getResults(), yieldedMappings)) results.setMappedValues(result, mapping); diff --git a/mlir/examples/transform-opt/mlir-transform-opt.cpp b/mlir/examples/transform-opt/mlir-transform-opt.cpp index 2fec9be92e6e3..1a29913b9e144 100644 --- a/mlir/examples/transform-opt/mlir-transform-opt.cpp +++ b/mlir/examples/transform-opt/mlir-transform-opt.cpp @@ -136,7 +136,7 @@ class DiagnosticHandlerWrapper { /// Verifies the captured "expected-*" diagnostics if required. llvm::LogicalResult verify() const { if (auto *ptr = - handler.dyn_cast()) { + dyn_cast(handler)) { return ptr->verify(); } return mlir::success(); @@ -144,7 +144,7 @@ class DiagnosticHandlerWrapper { /// Destructs the object of the same type as allocated. ~DiagnosticHandlerWrapper() { - if (auto *ptr = handler.dyn_cast()) { + if (auto *ptr = dyn_cast(handler)) { delete ptr; } else { delete cast(handler); diff --git a/mlir/include/mlir/IR/AffineExpr.h b/mlir/include/mlir/IR/AffineExpr.h index a93e74b449cee..94eacdb4735f8 100644 --- a/mlir/include/mlir/IR/AffineExpr.h +++ b/mlir/include/mlir/IR/AffineExpr.h @@ -81,19 +81,6 @@ class AffineExpr { bool operator!() const { return expr == nullptr; } - template - [[deprecated("Use llvm::isa() instead")]] constexpr bool isa() const; - - template - [[deprecated("Use llvm::dyn_cast() instead")]] U dyn_cast() const; - - template - [[deprecated("Use llvm::dyn_cast_or_null() instead")]] U - dyn_cast_or_null() const; - - template - [[deprecated("Use llvm::cast() instead")]] U cast() const; - MLIRContext *getContext() const; /// Return the classification for this type. @@ -288,30 +275,6 @@ AffineExpr getAffineExprFromFlatForm(ArrayRef flatExprs, raw_ostream &operator<<(raw_ostream &os, AffineExpr expr); -template -constexpr bool AffineExpr::isa() const { - if constexpr (std::is_same_v) - return getKind() <= AffineExprKind::LAST_AFFINE_BINARY_OP; - if constexpr (std::is_same_v) - return getKind() == AffineExprKind::DimId; - if constexpr (std::is_same_v) - return getKind() == AffineExprKind::SymbolId; - if constexpr (std::is_same_v) - return getKind() == AffineExprKind::Constant; -} -template -U AffineExpr::dyn_cast() const { - return llvm::dyn_cast(*this); -} -template -U AffineExpr::dyn_cast_or_null() const { - return llvm::dyn_cast_or_null(*this); -} -template -U AffineExpr::cast() const { - return llvm::cast(*this); -} - /// Simplify an affine expression by flattening and some amount of simple /// analysis. This has complexity linear in the number of nodes in 'expr'. /// Returns the simplified expression, which is the same as the input expression diff --git a/mlir/include/mlir/IR/Attributes.h b/mlir/include/mlir/IR/Attributes.h index 262d31b20ab08..6eef0e3f79bae 100644 --- a/mlir/include/mlir/IR/Attributes.h +++ b/mlir/include/mlir/IR/Attributes.h @@ -47,24 +47,6 @@ class Attribute { bool operator!() const { return impl == nullptr; } - /// Casting utility functions. These are deprecated and will be removed, - /// please prefer using the `llvm` namespace variants instead. - template - [[deprecated("Use mlir::isa() instead")]] - bool isa() const; - template - [[deprecated("Use mlir::isa_and_nonnull() instead")]] - bool isa_and_nonnull() const; - template - [[deprecated("Use mlir::dyn_cast() instead")]] - U dyn_cast() const; - template - [[deprecated("Use mlir::dyn_cast_or_null() instead")]] - U dyn_cast_or_null() const; - template - [[deprecated("Use mlir::cast() instead")]] - U cast() const; - /// Return a unique identifier for the concrete attribute type. This is used /// to support dynamic type casting. TypeID getTypeID() { return impl->getAbstractAttribute().getTypeID(); } @@ -170,31 +152,6 @@ inline raw_ostream &operator<<(raw_ostream &os, Attribute attr) { return os; } -template -bool Attribute::isa() const { - return llvm::isa(*this); -} - -template -bool Attribute::isa_and_nonnull() const { - return llvm::isa_and_present(*this); -} - -template -U Attribute::dyn_cast() const { - return llvm::dyn_cast(*this); -} - -template -U Attribute::dyn_cast_or_null() const { - return llvm::dyn_cast_if_present(*this); -} - -template -U Attribute::cast() const { - return llvm::cast(*this); -} - inline ::llvm::hash_code hash_value(Attribute arg) { return DenseMapInfo::getHashValue(arg.impl); } diff --git a/mlir/include/mlir/IR/ExtensibleDialect.h b/mlir/include/mlir/IR/ExtensibleDialect.h index 494f3dfb05a04..955faaad9408b 100644 --- a/mlir/include/mlir/IR/ExtensibleDialect.h +++ b/mlir/include/mlir/IR/ExtensibleDialect.h @@ -149,7 +149,7 @@ class IsDynamicAttr : public TraitBase {}; /// A dynamic attribute instance. This is an attribute whose definition is /// defined at runtime. /// It is possible to check if an attribute is a dynamic attribute using -/// `my_attr.isa()`, and getting the attribute definition of a +/// `isa(myAttr)`, and getting the attribute definition of a /// dynamic attribute using the `DynamicAttr::getAttrDef` method. /// All dynamic attributes have the same storage, which is an array of /// attributes. @@ -306,7 +306,7 @@ class IsDynamicType : public TypeTrait::TraitBase { /// A dynamic type instance. This is a type whose definition is defined at /// runtime. /// It is possible to check if a type is a dynamic type using -/// `my_type.isa()`, and getting the type definition of a dynamic +/// `isa(myType)`, and getting the type definition of a dynamic /// type using the `DynamicType::getTypeDef` method. /// All dynamic types have the same storage, which is an array of attributes. class DynamicType diff --git a/mlir/include/mlir/IR/Location.h b/mlir/include/mlir/IR/Location.h index 8ce36ed415ac1..5b1cf300295e5 100644 --- a/mlir/include/mlir/IR/Location.h +++ b/mlir/include/mlir/IR/Location.h @@ -79,23 +79,6 @@ class Location { operator LocationAttr() const { return impl; } LocationAttr *operator->() const { return const_cast(&impl); } - /// Type casting utilities on the underlying location. - template - [[deprecated("Use mlir::isa() instead")]] - bool isa() const { - return llvm::isa(*this); - } - template - [[deprecated("Use mlir::dyn_cast() instead")]] - U dyn_cast() const { - return llvm::dyn_cast(*this); - } - template - [[deprecated("Use mlir::cast() instead")]] - U cast() const { - return llvm::cast(*this); - } - /// Comparison operators. bool operator==(Location rhs) const { return impl == rhs.impl; } bool operator!=(Location rhs) const { return !(*this == rhs); } diff --git a/mlir/include/mlir/IR/Types.h b/mlir/include/mlir/IR/Types.h index e60f19a1ca585..4ffdbfa5b1224 100644 --- a/mlir/include/mlir/IR/Types.h +++ b/mlir/include/mlir/IR/Types.h @@ -96,22 +96,6 @@ class Type { bool operator!() const { return impl == nullptr; } - template - [[deprecated("Use mlir::isa() instead")]] - bool isa() const; - template - [[deprecated("Use mlir::isa_and_nonnull() instead")]] - bool isa_and_nonnull() const; - template - [[deprecated("Use mlir::dyn_cast() instead")]] - U dyn_cast() const; - template - [[deprecated("Use mlir::dyn_cast_or_null() instead")]] - U dyn_cast_or_null() const; - template - [[deprecated("Use mlir::cast() instead")]] - U cast() const; - /// Return a unique identifier for the concrete type. This is used to support /// dynamic type casting. TypeID getTypeID() { return impl->getAbstractType().getTypeID(); } @@ -319,31 +303,6 @@ inline ::llvm::hash_code hash_value(Type arg) { return DenseMapInfo::getHashValue(arg.impl); } -template -bool Type::isa() const { - return llvm::isa(*this); -} - -template -bool Type::isa_and_nonnull() const { - return llvm::isa_and_present(*this); -} - -template -U Type::dyn_cast() const { - return llvm::dyn_cast(*this); -} - -template -U Type::dyn_cast_or_null() const { - return llvm::dyn_cast_or_null(*this); -} - -template -U Type::cast() const { - return llvm::cast(*this); -} - } // namespace mlir namespace llvm { diff --git a/mlir/include/mlir/IR/Value.h b/mlir/include/mlir/IR/Value.h index a7344c64e6730..d54e3c0ad26dd 100644 --- a/mlir/include/mlir/IR/Value.h +++ b/mlir/include/mlir/IR/Value.h @@ -97,30 +97,6 @@ class Value { public: constexpr Value(detail::ValueImpl *impl = nullptr) : impl(impl) {} - template - [[deprecated("Use mlir::isa() instead")]] - bool isa() const { - return llvm::isa(*this); - } - - template - [[deprecated("Use mlir::dyn_cast() instead")]] - U dyn_cast() const { - return llvm::dyn_cast(*this); - } - - template - [[deprecated("Use mlir::dyn_cast_or_null() instead")]] - U dyn_cast_or_null() const { - return llvm::dyn_cast_or_null(*this); - } - - template - [[deprecated("Use mlir::cast() instead")]] - U cast() const { - return llvm::cast(*this); - } - explicit operator bool() const { return impl; } bool operator==(const Value &other) const { return impl == other.impl; } bool operator!=(const Value &other) const { return !(*this == other); } diff --git a/mlir/include/mlir/Tools/PDLL/AST/Types.h b/mlir/include/mlir/Tools/PDLL/AST/Types.h index 08d15bd764dfe..57161db5fdbad 100644 --- a/mlir/include/mlir/Tools/PDLL/AST/Types.h +++ b/mlir/include/mlir/Tools/PDLL/AST/Types.h @@ -62,35 +62,6 @@ class Type { bool operator!=(const Type &other) const { return !(*this == other); } explicit operator bool() const { return impl; } - /// Provide type casting support. - template - [[deprecated("Use mlir::isa() instead")]] - bool isa() const { - assert(impl && "isa<> used on a null type."); - return U::classof(*this); - } - template - [[deprecated("Use mlir::isa() instead")]] - bool isa() const { - return isa() || isa(); - } - template - [[deprecated("Use mlir::dyn_cast() instead")]] - U dyn_cast() const { - return isa() ? U(impl) : U(nullptr); - } - template - [[deprecated("Use mlir::dyn_cast_or_null() instead")]] - U dyn_cast_or_null() const { - return (impl && isa()) ? U(impl) : U(nullptr); - } - template - [[deprecated("Use mlir::cast() instead")]] - U cast() const { - assert(isa()); - return U(impl); - } - /// Return the internal storage instance of this type. Storage *getImpl() const { return impl; } diff --git a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp index 847e7e2beebe9..1a35d08196459 100644 --- a/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp +++ b/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp @@ -113,7 +113,7 @@ static Value getIndexedPtrs(ConversionPatternRewriter &rewriter, Location loc, /// an LLVM constant op. static Value getAsLLVMValue(OpBuilder &builder, Location loc, OpFoldResult foldResult) { - if (auto attr = foldResult.dyn_cast()) { + if (auto attr = dyn_cast(foldResult)) { auto intAttr = cast(attr); return builder.create(loc, intAttr).getResult(); } diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h index 3e61b5f27fcc2..355804bcc33fb 100644 --- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/LoopEmitter.h @@ -104,7 +104,7 @@ class LoopEmitter { SynTensorBoundSetter synSetter = nullptr); /// Generates code to compute an affine expression whose variables are - /// `LoopId`s (i.e., `a.cast().getPosition()` is a valid + /// `LoopId`s (i.e., `cast(a).getPosition()` is a valid /// `LoopId`). Value genAffine(OpBuilder &builder, Location loc, AffineExpr a); diff --git a/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp b/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp index 232c9c96dd09f..44d82714b894b 100644 --- a/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp +++ b/mlir/lib/Dialect/Transform/Transforms/TransformInterpreterUtils.cpp @@ -210,7 +210,7 @@ LogicalResult transform::applyTransformNamedSequence( << "expected one payload to be bound to the first argument, got " << bindings.at(0).size(); } - auto *payloadRoot = bindings.at(0).front().dyn_cast(); + auto *payloadRoot = dyn_cast(bindings.at(0).front()); if (!payloadRoot) { return transformRoot->emitError() << "expected the object bound to the " "first argument to be an operation"; diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp index 4dadecd4995d4..bee5c1fd6ed58 100644 --- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp +++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp @@ -341,7 +341,7 @@ SmallVector vector::getAsValues(OpBuilder &builder, Location loc, SmallVector values; llvm::transform(foldResults, std::back_inserter(values), [&](OpFoldResult foldResult) { - if (auto attr = foldResult.dyn_cast()) + if (auto attr = dyn_cast(foldResult)) return builder .create( loc, cast(attr).getInt()) @@ -2970,7 +2970,7 @@ LogicalResult InsertOp::verify() { return emitOpError( "expected position attribute rank to match the dest vector rank"); for (auto [idx, pos] : llvm::enumerate(position)) { - if (auto attr = pos.dyn_cast()) { + if (auto attr = dyn_cast(pos)) { int64_t constIdx = cast(attr).getInt(); if (!isValidPositiveIndexOrPoison(constIdx, kPoisonIndex, destVectorType.getDimSize(idx))) { diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp index 5debebd3218ed..8d4dcb2b27bf9 100644 --- a/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp +++ b/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp @@ -300,9 +300,9 @@ static Value dynamicallyExtractSubVector(OpBuilder &rewriter, Location loc, for (int i = 0; i < numElemsToExtract; ++i) { Value extractLoc = - (i == 0) ? offset.dyn_cast() + (i == 0) ? dyn_cast(offset) : rewriter.create( - loc, rewriter.getIndexType(), offset.dyn_cast(), + loc, rewriter.getIndexType(), dyn_cast(offset), rewriter.create(loc, i)); auto extractOp = rewriter.create(loc, src, extractLoc); dest = rewriter.create(loc, extractOp, dest, i); diff --git a/mlir/lib/IR/AffineMap.cpp b/mlir/lib/IR/AffineMap.cpp index 8e8a433f331df..3e3bb314e562f 100644 --- a/mlir/lib/IR/AffineMap.cpp +++ b/mlir/lib/IR/AffineMap.cpp @@ -748,7 +748,7 @@ AffineMap mlir::foldAttributesIntoMap(Builder &b, AffineMap map, SmallVector dimReplacements, symReplacements; int64_t numDims = 0; for (int64_t i = 0; i < map.getNumDims(); ++i) { - if (auto attr = operands[i].dyn_cast()) { + if (auto attr = dyn_cast(operands[i])) { dimReplacements.push_back( b.getAffineConstantExpr(cast(attr).getInt())); } else { @@ -758,7 +758,7 @@ AffineMap mlir::foldAttributesIntoMap(Builder &b, AffineMap map, } int64_t numSymbols = 0; for (int64_t i = 0; i < map.getNumSymbols(); ++i) { - if (auto attr = operands[i + map.getNumDims()].dyn_cast()) { + if (auto attr = dyn_cast(operands[i + map.getNumDims()])) { symReplacements.push_back( b.getAffineConstantExpr(cast(attr).getInt())); } else { diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp index 8fe7d87c71767..7c1cfd91f85e6 100644 --- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp +++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp @@ -515,7 +515,7 @@ bool GreedyPatternRewriteDriver::processWorklist() { bool materializationSucceeded = true; for (auto [ofr, resultType] : llvm::zip_equal(foldResults, op->getResultTypes())) { - if (auto value = ofr.dyn_cast()) { + if (auto value = dyn_cast(ofr)) { assert(value.getType() == resultType && "folder produced value of incorrect type"); replacements.push_back(value); diff --git a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp index ad45376a4fa44..2431807ce463d 100644 --- a/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp +++ b/mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp @@ -1802,7 +1802,7 @@ void OpEmitter::genPropertiesSupportForBytecode( writePropertiesMethod << tgfmt(writeBytecodeSegmentSizeLegacy, &fmtCtxt); } if (const auto *namedProperty = - attrOrProp.dyn_cast()) { + dyn_cast(attrOrProp)) { StringRef name = namedProperty->name; readPropertiesMethod << formatv( R"( diff --git a/mlir/unittests/IR/SymbolTableTest.cpp b/mlir/unittests/IR/SymbolTableTest.cpp index 5dcec749f0f42..cfc3fe0cb1c5b 100644 --- a/mlir/unittests/IR/SymbolTableTest.cpp +++ b/mlir/unittests/IR/SymbolTableTest.cpp @@ -49,8 +49,7 @@ class ReplaceAllSymbolUsesTest : public ::testing::Test { // Check that it got renamed. bool calleeFound = false; fooOp->walk([&](CallOpInterface callOp) { - StringAttr callee = callOp.getCallableForCallee() - .dyn_cast() + StringAttr callee = dyn_cast(callOp.getCallableForCallee()) .getLeafReference(); EXPECT_EQ(callee, "baz"); calleeFound = true;