-
Notifications
You must be signed in to change notification settings - Fork 13.2k
[mlir] Remove deprecated cast member functions #135556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
These have been deprecated for over two years now in favor of free functions. See the relevant discourse thread: https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 and the deprecation notice: https://mlir.llvm.org/deprecation/.
@llvm/pr-subscribers-mlir-vector @llvm/pr-subscribers-mlir-core Author: Jakub Kuderski (kuhar) ChangesThese have been deprecated for over two years now in favor of free functions. See the relevant discourse thread: Full diff: https://github.com/llvm/llvm-project/pull/135556.diff 6 Files Affected:
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 <typename U>
- [[deprecated("Use llvm::isa<U>() instead")]] constexpr bool isa() const;
-
- template <typename U>
- [[deprecated("Use llvm::dyn_cast<U>() instead")]] U dyn_cast() const;
-
- template <typename U>
- [[deprecated("Use llvm::dyn_cast_or_null<U>() instead")]] U
- dyn_cast_or_null() const;
-
- template <typename U>
- [[deprecated("Use llvm::cast<U>() instead")]] U cast() const;
-
MLIRContext *getContext() const;
/// Return the classification for this type.
@@ -288,30 +275,6 @@ AffineExpr getAffineExprFromFlatForm(ArrayRef<int64_t> flatExprs,
raw_ostream &operator<<(raw_ostream &os, AffineExpr expr);
-template <typename U>
-constexpr bool AffineExpr::isa() const {
- if constexpr (std::is_same_v<U, AffineBinaryOpExpr>)
- return getKind() <= AffineExprKind::LAST_AFFINE_BINARY_OP;
- if constexpr (std::is_same_v<U, AffineDimExpr>)
- return getKind() == AffineExprKind::DimId;
- if constexpr (std::is_same_v<U, AffineSymbolExpr>)
- return getKind() == AffineExprKind::SymbolId;
- if constexpr (std::is_same_v<U, AffineConstantExpr>)
- return getKind() == AffineExprKind::Constant;
-}
-template <typename U>
-U AffineExpr::dyn_cast() const {
- return llvm::dyn_cast<U>(*this);
-}
-template <typename U>
-U AffineExpr::dyn_cast_or_null() const {
- return llvm::dyn_cast_or_null<U>(*this);
-}
-template <typename U>
-U AffineExpr::cast() const {
- return llvm::cast<U>(*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 <typename... Tys>
- [[deprecated("Use mlir::isa<U>() instead")]]
- bool isa() const;
- template <typename... Tys>
- [[deprecated("Use mlir::isa_and_nonnull<U>() instead")]]
- bool isa_and_nonnull() const;
- template <typename U>
- [[deprecated("Use mlir::dyn_cast<U>() instead")]]
- U dyn_cast() const;
- template <typename U>
- [[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
- U dyn_cast_or_null() const;
- template <typename U>
- [[deprecated("Use mlir::cast<U>() 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 <typename... Tys>
-bool Attribute::isa() const {
- return llvm::isa<Tys...>(*this);
-}
-
-template <typename... Tys>
-bool Attribute::isa_and_nonnull() const {
- return llvm::isa_and_present<Tys...>(*this);
-}
-
-template <typename U>
-U Attribute::dyn_cast() const {
- return llvm::dyn_cast<U>(*this);
-}
-
-template <typename U>
-U Attribute::dyn_cast_or_null() const {
- return llvm::dyn_cast_if_present<U>(*this);
-}
-
-template <typename U>
-U Attribute::cast() const {
- return llvm::cast<U>(*this);
-}
-
inline ::llvm::hash_code hash_value(Attribute arg) {
return DenseMapInfo<const Attribute::ImplType *>::getHashValue(arg.impl);
}
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<LocationAttr *>(&impl); }
- /// Type casting utilities on the underlying location.
- template <typename U>
- [[deprecated("Use mlir::isa<U>() instead")]]
- bool isa() const {
- return llvm::isa<U>(*this);
- }
- template <typename U>
- [[deprecated("Use mlir::dyn_cast<U>() instead")]]
- U dyn_cast() const {
- return llvm::dyn_cast<U>(*this);
- }
- template <typename U>
- [[deprecated("Use mlir::cast<U>() instead")]]
- U cast() const {
- return llvm::cast<U>(*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 <typename... Tys>
- [[deprecated("Use mlir::isa<U>() instead")]]
- bool isa() const;
- template <typename... Tys>
- [[deprecated("Use mlir::isa_and_nonnull<U>() instead")]]
- bool isa_and_nonnull() const;
- template <typename U>
- [[deprecated("Use mlir::dyn_cast<U>() instead")]]
- U dyn_cast() const;
- template <typename U>
- [[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
- U dyn_cast_or_null() const;
- template <typename U>
- [[deprecated("Use mlir::cast<U>() 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<const Type::ImplType *>::getHashValue(arg.impl);
}
-template <typename... Tys>
-bool Type::isa() const {
- return llvm::isa<Tys...>(*this);
-}
-
-template <typename... Tys>
-bool Type::isa_and_nonnull() const {
- return llvm::isa_and_present<Tys...>(*this);
-}
-
-template <typename U>
-U Type::dyn_cast() const {
- return llvm::dyn_cast<U>(*this);
-}
-
-template <typename U>
-U Type::dyn_cast_or_null() const {
- return llvm::dyn_cast_or_null<U>(*this);
-}
-
-template <typename U>
-U Type::cast() const {
- return llvm::cast<U>(*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 <typename U>
- [[deprecated("Use mlir::isa<U>() instead")]]
- bool isa() const {
- return llvm::isa<U>(*this);
- }
-
- template <typename U>
- [[deprecated("Use mlir::dyn_cast<U>() instead")]]
- U dyn_cast() const {
- return llvm::dyn_cast<U>(*this);
- }
-
- template <typename U>
- [[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
- U dyn_cast_or_null() const {
- return llvm::dyn_cast_or_null<U>(*this);
- }
-
- template <typename U>
- [[deprecated("Use mlir::cast<U>() instead")]]
- U cast() const {
- return llvm::cast<U>(*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 <typename U>
- [[deprecated("Use mlir::isa<U>() instead")]]
- bool isa() const {
- assert(impl && "isa<> used on a null type.");
- return U::classof(*this);
- }
- template <typename U, typename V, typename... Others>
- [[deprecated("Use mlir::isa<U>() instead")]]
- bool isa() const {
- return isa<U>() || isa<V, Others...>();
- }
- template <typename U>
- [[deprecated("Use mlir::dyn_cast<U>() instead")]]
- U dyn_cast() const {
- return isa<U>() ? U(impl) : U(nullptr);
- }
- template <typename U>
- [[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
- U dyn_cast_or_null() const {
- return (impl && isa<U>()) ? U(impl) : U(nullptr);
- }
- template <typename U>
- [[deprecated("Use mlir::cast<U>() instead")]]
- U cast() const {
- assert(isa<U>());
- return U(impl);
- }
-
/// Return the internal storage instance of this type.
Storage *getImpl() const { return impl; }
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the cleanup!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
At long last. We should do a scrub and remove |
This was deleted in the upstream: llvm/llvm-project#135556 PiperOrigin-RevId: 747927733
These have been deprecated for over two years now in favor of free functions.
See the relevant discourse thread:
https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 and the deprecation notice: https://mlir.llvm.org/deprecation/.