Skip to content

Commit f174d3e

Browse files
committed
[mlir] Remove deprecated cast member functions
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/.
1 parent d893d12 commit f174d3e

File tree

6 files changed

+0
-191
lines changed

6 files changed

+0
-191
lines changed

mlir/include/mlir/IR/AffineExpr.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,6 @@ class AffineExpr {
8181

8282
bool operator!() const { return expr == nullptr; }
8383

84-
template <typename U>
85-
[[deprecated("Use llvm::isa<U>() instead")]] constexpr bool isa() const;
86-
87-
template <typename U>
88-
[[deprecated("Use llvm::dyn_cast<U>() instead")]] U dyn_cast() const;
89-
90-
template <typename U>
91-
[[deprecated("Use llvm::dyn_cast_or_null<U>() instead")]] U
92-
dyn_cast_or_null() const;
93-
94-
template <typename U>
95-
[[deprecated("Use llvm::cast<U>() instead")]] U cast() const;
96-
9784
MLIRContext *getContext() const;
9885

9986
/// Return the classification for this type.
@@ -288,30 +275,6 @@ AffineExpr getAffineExprFromFlatForm(ArrayRef<int64_t> flatExprs,
288275

289276
raw_ostream &operator<<(raw_ostream &os, AffineExpr expr);
290277

291-
template <typename U>
292-
constexpr bool AffineExpr::isa() const {
293-
if constexpr (std::is_same_v<U, AffineBinaryOpExpr>)
294-
return getKind() <= AffineExprKind::LAST_AFFINE_BINARY_OP;
295-
if constexpr (std::is_same_v<U, AffineDimExpr>)
296-
return getKind() == AffineExprKind::DimId;
297-
if constexpr (std::is_same_v<U, AffineSymbolExpr>)
298-
return getKind() == AffineExprKind::SymbolId;
299-
if constexpr (std::is_same_v<U, AffineConstantExpr>)
300-
return getKind() == AffineExprKind::Constant;
301-
}
302-
template <typename U>
303-
U AffineExpr::dyn_cast() const {
304-
return llvm::dyn_cast<U>(*this);
305-
}
306-
template <typename U>
307-
U AffineExpr::dyn_cast_or_null() const {
308-
return llvm::dyn_cast_or_null<U>(*this);
309-
}
310-
template <typename U>
311-
U AffineExpr::cast() const {
312-
return llvm::cast<U>(*this);
313-
}
314-
315278
/// Simplify an affine expression by flattening and some amount of simple
316279
/// analysis. This has complexity linear in the number of nodes in 'expr'.
317280
/// Returns the simplified expression, which is the same as the input expression

mlir/include/mlir/IR/Attributes.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,6 @@ class Attribute {
4747

4848
bool operator!() const { return impl == nullptr; }
4949

50-
/// Casting utility functions. These are deprecated and will be removed,
51-
/// please prefer using the `llvm` namespace variants instead.
52-
template <typename... Tys>
53-
[[deprecated("Use mlir::isa<U>() instead")]]
54-
bool isa() const;
55-
template <typename... Tys>
56-
[[deprecated("Use mlir::isa_and_nonnull<U>() instead")]]
57-
bool isa_and_nonnull() const;
58-
template <typename U>
59-
[[deprecated("Use mlir::dyn_cast<U>() instead")]]
60-
U dyn_cast() const;
61-
template <typename U>
62-
[[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
63-
U dyn_cast_or_null() const;
64-
template <typename U>
65-
[[deprecated("Use mlir::cast<U>() instead")]]
66-
U cast() const;
67-
6850
/// Return a unique identifier for the concrete attribute type. This is used
6951
/// to support dynamic type casting.
7052
TypeID getTypeID() { return impl->getAbstractAttribute().getTypeID(); }
@@ -170,31 +152,6 @@ inline raw_ostream &operator<<(raw_ostream &os, Attribute attr) {
170152
return os;
171153
}
172154

173-
template <typename... Tys>
174-
bool Attribute::isa() const {
175-
return llvm::isa<Tys...>(*this);
176-
}
177-
178-
template <typename... Tys>
179-
bool Attribute::isa_and_nonnull() const {
180-
return llvm::isa_and_present<Tys...>(*this);
181-
}
182-
183-
template <typename U>
184-
U Attribute::dyn_cast() const {
185-
return llvm::dyn_cast<U>(*this);
186-
}
187-
188-
template <typename U>
189-
U Attribute::dyn_cast_or_null() const {
190-
return llvm::dyn_cast_if_present<U>(*this);
191-
}
192-
193-
template <typename U>
194-
U Attribute::cast() const {
195-
return llvm::cast<U>(*this);
196-
}
197-
198155
inline ::llvm::hash_code hash_value(Attribute arg) {
199156
return DenseMapInfo<const Attribute::ImplType *>::getHashValue(arg.impl);
200157
}

mlir/include/mlir/IR/Location.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -79,23 +79,6 @@ class Location {
7979
operator LocationAttr() const { return impl; }
8080
LocationAttr *operator->() const { return const_cast<LocationAttr *>(&impl); }
8181

82-
/// Type casting utilities on the underlying location.
83-
template <typename U>
84-
[[deprecated("Use mlir::isa<U>() instead")]]
85-
bool isa() const {
86-
return llvm::isa<U>(*this);
87-
}
88-
template <typename U>
89-
[[deprecated("Use mlir::dyn_cast<U>() instead")]]
90-
U dyn_cast() const {
91-
return llvm::dyn_cast<U>(*this);
92-
}
93-
template <typename U>
94-
[[deprecated("Use mlir::cast<U>() instead")]]
95-
U cast() const {
96-
return llvm::cast<U>(*this);
97-
}
98-
9982
/// Comparison operators.
10083
bool operator==(Location rhs) const { return impl == rhs.impl; }
10184
bool operator!=(Location rhs) const { return !(*this == rhs); }

mlir/include/mlir/IR/Types.h

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -96,22 +96,6 @@ class Type {
9696

9797
bool operator!() const { return impl == nullptr; }
9898

99-
template <typename... Tys>
100-
[[deprecated("Use mlir::isa<U>() instead")]]
101-
bool isa() const;
102-
template <typename... Tys>
103-
[[deprecated("Use mlir::isa_and_nonnull<U>() instead")]]
104-
bool isa_and_nonnull() const;
105-
template <typename U>
106-
[[deprecated("Use mlir::dyn_cast<U>() instead")]]
107-
U dyn_cast() const;
108-
template <typename U>
109-
[[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
110-
U dyn_cast_or_null() const;
111-
template <typename U>
112-
[[deprecated("Use mlir::cast<U>() instead")]]
113-
U cast() const;
114-
11599
/// Return a unique identifier for the concrete type. This is used to support
116100
/// dynamic type casting.
117101
TypeID getTypeID() { return impl->getAbstractType().getTypeID(); }
@@ -319,31 +303,6 @@ inline ::llvm::hash_code hash_value(Type arg) {
319303
return DenseMapInfo<const Type::ImplType *>::getHashValue(arg.impl);
320304
}
321305

322-
template <typename... Tys>
323-
bool Type::isa() const {
324-
return llvm::isa<Tys...>(*this);
325-
}
326-
327-
template <typename... Tys>
328-
bool Type::isa_and_nonnull() const {
329-
return llvm::isa_and_present<Tys...>(*this);
330-
}
331-
332-
template <typename U>
333-
U Type::dyn_cast() const {
334-
return llvm::dyn_cast<U>(*this);
335-
}
336-
337-
template <typename U>
338-
U Type::dyn_cast_or_null() const {
339-
return llvm::dyn_cast_or_null<U>(*this);
340-
}
341-
342-
template <typename U>
343-
U Type::cast() const {
344-
return llvm::cast<U>(*this);
345-
}
346-
347306
} // namespace mlir
348307

349308
namespace llvm {

mlir/include/mlir/IR/Value.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -97,30 +97,6 @@ class Value {
9797
public:
9898
constexpr Value(detail::ValueImpl *impl = nullptr) : impl(impl) {}
9999

100-
template <typename U>
101-
[[deprecated("Use mlir::isa<U>() instead")]]
102-
bool isa() const {
103-
return llvm::isa<U>(*this);
104-
}
105-
106-
template <typename U>
107-
[[deprecated("Use mlir::dyn_cast<U>() instead")]]
108-
U dyn_cast() const {
109-
return llvm::dyn_cast<U>(*this);
110-
}
111-
112-
template <typename U>
113-
[[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
114-
U dyn_cast_or_null() const {
115-
return llvm::dyn_cast_or_null<U>(*this);
116-
}
117-
118-
template <typename U>
119-
[[deprecated("Use mlir::cast<U>() instead")]]
120-
U cast() const {
121-
return llvm::cast<U>(*this);
122-
}
123-
124100
explicit operator bool() const { return impl; }
125101
bool operator==(const Value &other) const { return impl == other.impl; }
126102
bool operator!=(const Value &other) const { return !(*this == other); }

mlir/include/mlir/Tools/PDLL/AST/Types.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -62,35 +62,6 @@ class Type {
6262
bool operator!=(const Type &other) const { return !(*this == other); }
6363
explicit operator bool() const { return impl; }
6464

65-
/// Provide type casting support.
66-
template <typename U>
67-
[[deprecated("Use mlir::isa<U>() instead")]]
68-
bool isa() const {
69-
assert(impl && "isa<> used on a null type.");
70-
return U::classof(*this);
71-
}
72-
template <typename U, typename V, typename... Others>
73-
[[deprecated("Use mlir::isa<U>() instead")]]
74-
bool isa() const {
75-
return isa<U>() || isa<V, Others...>();
76-
}
77-
template <typename U>
78-
[[deprecated("Use mlir::dyn_cast<U>() instead")]]
79-
U dyn_cast() const {
80-
return isa<U>() ? U(impl) : U(nullptr);
81-
}
82-
template <typename U>
83-
[[deprecated("Use mlir::dyn_cast_or_null<U>() instead")]]
84-
U dyn_cast_or_null() const {
85-
return (impl && isa<U>()) ? U(impl) : U(nullptr);
86-
}
87-
template <typename U>
88-
[[deprecated("Use mlir::cast<U>() instead")]]
89-
U cast() const {
90-
assert(isa<U>());
91-
return U(impl);
92-
}
93-
9465
/// Return the internal storage instance of this type.
9566
Storage *getImpl() const { return impl; }
9667

0 commit comments

Comments
 (0)