Skip to content

Commit 7aedd7d

Browse files
authored
Revert "[mlir] Mark isa/dyn_cast/cast/... member functions deprecated. (#89998)" (#90250)
This reverts commit 950b7ce. This change is causing build failures on a bot https://lab.llvm.org/buildbot/#/builders/216/builds/38157
1 parent 1b7db40 commit 7aedd7d

File tree

97 files changed

+1275
-1342
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1275
-1342
lines changed

flang/include/flang/Lower/Mangler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ inline std::string mangleArrayLiteral(
9090
return mangleArrayLiteral(x.values().size() * sizeof(x.values()[0]),
9191
x.shape(), Fortran::common::TypeCategory::Derived,
9292
/*kind=*/0, /*charLen=*/-1,
93-
mlir::cast<fir::RecordType>(eleTy).getName());
93+
eleTy.cast<fir::RecordType>().getName());
9494
}
9595

9696
/// Return the compiler-generated name of a static namelist variable descriptor.

flang/include/flang/Optimizer/Analysis/TBAAForest.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class TBAAForrest {
8888
// name must be used so that we add to the tbaa tree added in the FIR pass
8989
mlir::Attribute attr = func->getAttr(getInternalFuncNameAttrName());
9090
if (attr) {
91-
return getFuncTree(mlir::cast<mlir::StringAttr>(attr));
91+
return getFuncTree(attr.cast<mlir::StringAttr>());
9292
}
9393
return getFuncTree(func.getSymNameAttr());
9494
}

flang/include/flang/Optimizer/Builder/BoxValue.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class CharBoxValue : public AbstractBox {
7878
public:
7979
CharBoxValue(mlir::Value addr, mlir::Value len)
8080
: AbstractBox{addr}, len{len} {
81-
if (addr && mlir::isa<fir::BoxCharType>(addr.getType()))
81+
if (addr && addr.getType().template isa<fir::BoxCharType>())
8282
fir::emitFatalError(addr.getLoc(),
8383
"BoxChar should not be in CharBoxValue");
8484
}
@@ -221,7 +221,7 @@ class AbstractIrBox : public AbstractBox, public AbstractArrayBox {
221221
auto type = getAddr().getType();
222222
if (auto pointedTy = fir::dyn_cast_ptrEleTy(type))
223223
type = pointedTy;
224-
return mlir::cast<fir::BaseBoxType>(type);
224+
return type.cast<fir::BaseBoxType>();
225225
}
226226
/// Return the part of the address type after memory and box types. That is
227227
/// the element type, maybe wrapped in a fir.array type.
@@ -243,22 +243,22 @@ class AbstractIrBox : public AbstractBox, public AbstractArrayBox {
243243
/// Get the scalar type related to the described entity
244244
mlir::Type getEleTy() const {
245245
auto type = getBaseTy();
246-
if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(type))
246+
if (auto seqTy = type.dyn_cast<fir::SequenceType>())
247247
return seqTy.getEleTy();
248248
return type;
249249
}
250250

251251
/// Is the entity an array or an assumed rank ?
252-
bool hasRank() const { return mlir::isa<fir::SequenceType>(getBaseTy()); }
252+
bool hasRank() const { return getBaseTy().isa<fir::SequenceType>(); }
253253
/// Is this an assumed rank ?
254254
bool hasAssumedRank() const {
255-
auto seqTy = mlir::dyn_cast<fir::SequenceType>(getBaseTy());
255+
auto seqTy = getBaseTy().dyn_cast<fir::SequenceType>();
256256
return seqTy && seqTy.hasUnknownShape();
257257
}
258258
/// Returns the rank of the entity. Beware that zero will be returned for
259259
/// both scalars and assumed rank.
260260
unsigned rank() const {
261-
if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(getBaseTy()))
261+
if (auto seqTy = getBaseTy().dyn_cast<fir::SequenceType>())
262262
return seqTy.getDimension();
263263
return 0;
264264
}
@@ -267,7 +267,7 @@ class AbstractIrBox : public AbstractBox, public AbstractArrayBox {
267267
bool isCharacter() const { return fir::isa_char(getEleTy()); }
268268

269269
/// Is this a derived type entity ?
270-
bool isDerived() const { return mlir::isa<fir::RecordType>(getEleTy()); }
270+
bool isDerived() const { return getEleTy().isa<fir::RecordType>(); }
271271

272272
bool isDerivedWithLenParameters() const {
273273
return fir::isRecordWithTypeParameters(getEleTy());
@@ -377,11 +377,11 @@ class MutableBoxValue : public AbstractIrBox {
377377
}
378378
/// Is this a Fortran pointer ?
379379
bool isPointer() const {
380-
return mlir::isa<fir::PointerType>(getBoxTy().getEleTy());
380+
return getBoxTy().getEleTy().isa<fir::PointerType>();
381381
}
382382
/// Is this an allocatable ?
383383
bool isAllocatable() const {
384-
return mlir::isa<fir::HeapType>(getBoxTy().getEleTy());
384+
return getBoxTy().getEleTy().isa<fir::HeapType>();
385385
}
386386
// Replace the fir.ref<fir.box>, keeping any non-deferred parameters.
387387
MutableBoxValue clone(mlir::Value newBox) const {
@@ -488,7 +488,7 @@ class ExtendedValue : public details::matcher<ExtendedValue> {
488488
if (const auto *b = getUnboxed()) {
489489
if (*b) {
490490
auto type = b->getType();
491-
if (mlir::isa<fir::BoxCharType>(type))
491+
if (type.template isa<fir::BoxCharType>())
492492
fir::emitFatalError(b->getLoc(), "BoxChar should be unboxed");
493493
type = fir::unwrapSequenceType(fir::unwrapRefType(type));
494494
if (fir::isa_char(type))

flang/include/flang/Optimizer/Builder/Factory.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ template <typename B>
4343
void genCharacterCopy(mlir::Value src, mlir::Value srcLen, mlir::Value dst,
4444
mlir::Value dstLen, B &builder, mlir::Location loc) {
4545
auto srcTy =
46-
mlir::cast<fir::CharacterType>(fir::dyn_cast_ptrEleTy(src.getType()));
46+
fir::dyn_cast_ptrEleTy(src.getType()).template cast<fir::CharacterType>();
4747
auto dstTy =
48-
mlir::cast<fir::CharacterType>(fir::dyn_cast_ptrEleTy(dst.getType()));
48+
fir::dyn_cast_ptrEleTy(dst.getType()).template cast<fir::CharacterType>();
4949
if (!srcLen && !dstLen && srcTy.getFKind() == dstTy.getFKind() &&
5050
srcTy.getLen() == dstTy.getLen()) {
5151
// same size, so just use load and store
@@ -61,8 +61,8 @@ void genCharacterCopy(mlir::Value src, mlir::Value srcLen, mlir::Value dst,
6161
fir::CharacterType::getSingleton(ty.getContext(), ty.getFKind())));
6262
};
6363
auto toEleTy = [&](fir::ReferenceType ty) {
64-
auto seqTy = mlir::cast<fir::SequenceType>(ty.getEleTy());
65-
return mlir::cast<fir::CharacterType>(seqTy.getEleTy());
64+
auto seqTy = ty.getEleTy().cast<fir::SequenceType>();
65+
return seqTy.getEleTy().cast<fir::CharacterType>();
6666
};
6767
auto toCoorTy = [&](fir::ReferenceType ty) {
6868
return fir::ReferenceType::get(toEleTy(ty));
@@ -190,8 +190,8 @@ originateIndices(mlir::Location loc, B &builder, mlir::Type memTy,
190190
if (origins.empty()) {
191191
assert(!shapeVal || mlir::isa<fir::ShapeOp>(shapeVal.getDefiningOp()));
192192
auto ty = fir::dyn_cast_ptrOrBoxEleTy(memTy);
193-
assert(ty && mlir::isa<fir::SequenceType>(ty));
194-
auto seqTy = mlir::cast<fir::SequenceType>(ty);
193+
assert(ty && ty.isa<fir::SequenceType>());
194+
auto seqTy = ty.cast<fir::SequenceType>();
195195
auto one = builder.template create<mlir::arith::ConstantIndexOp>(loc, 1);
196196
const auto dimension = seqTy.getDimension();
197197
if (shapeVal) {

flang/include/flang/Optimizer/Builder/HLFIRTools.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ class Entity : public mlir::Value {
7777
/// Return the rank of this entity or -1 if it is an assumed rank.
7878
int getRank() const {
7979
mlir::Type type = fir::unwrapPassByRefType(fir::unwrapRefType(getType()));
80-
if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(type)) {
80+
if (auto seqTy = type.dyn_cast<fir::SequenceType>()) {
8181
if (seqTy.hasUnknownShape())
8282
return -1;
8383
return seqTy.getDimension();
8484
}
85-
if (auto exprType = mlir::dyn_cast<hlfir::ExprType>(type))
85+
if (auto exprType = type.dyn_cast<hlfir::ExprType>())
8686
return exprType.getRank();
8787
return 0;
8888
}
@@ -99,17 +99,17 @@ class Entity : public mlir::Value {
9999

100100
bool hasLengthParameters() const {
101101
mlir::Type eleTy = getFortranElementType();
102-
return mlir::isa<fir::CharacterType>(eleTy) ||
102+
return eleTy.isa<fir::CharacterType>() ||
103103
fir::isRecordWithTypeParameters(eleTy);
104104
}
105105

106106
bool isCharacter() const {
107-
return mlir::isa<fir::CharacterType>(getFortranElementType());
107+
return getFortranElementType().isa<fir::CharacterType>();
108108
}
109109

110110
bool hasIntrinsicType() const {
111111
mlir::Type eleTy = getFortranElementType();
112-
return fir::isa_trivial(eleTy) || mlir::isa<fir::CharacterType>(eleTy);
112+
return fir::isa_trivial(eleTy) || eleTy.isa<fir::CharacterType>();
113113
}
114114

115115
bool isDerivedWithLengthParameters() const {
@@ -124,8 +124,8 @@ class Entity : public mlir::Value {
124124
if (auto varIface = getIfVariableInterface()) {
125125
if (auto shape = varIface.getShape()) {
126126
auto shapeTy = shape.getType();
127-
return mlir::isa<fir::ShiftType>(shapeTy) ||
128-
mlir::isa<fir::ShapeShiftType>(shapeTy);
127+
return shapeTy.isa<fir::ShiftType>() ||
128+
shapeTy.isa<fir::ShapeShiftType>();
129129
}
130130
return false;
131131
}

flang/include/flang/Optimizer/Builder/IntrinsicCall.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -663,8 +663,8 @@ static inline mlir::FunctionType genFuncType(mlir::MLIRContext *context,
663663
//===----------------------------------------------------------------------===//
664664
static inline mlir::Type getConvertedElementType(mlir::MLIRContext *context,
665665
mlir::Type eleTy) {
666-
if (mlir::isa<mlir::IntegerType>(eleTy) && !eleTy.isSignlessInteger()) {
667-
const auto intTy{mlir::dyn_cast<mlir::IntegerType>(eleTy)};
666+
if (eleTy.isa<mlir::IntegerType>() && !eleTy.isSignlessInteger()) {
667+
const auto intTy{eleTy.dyn_cast<mlir::IntegerType>()};
668668
auto newEleTy{mlir::IntegerType::get(context, intTy.getWidth())};
669669
return newEleTy;
670670
}

flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,10 @@ struct VecTypeInfo {
180180
// Returns a VecTypeInfo with element type and length of given fir vector type.
181181
// Preserves signness of fir vector type if element type of integer.
182182
static inline VecTypeInfo getVecTypeFromFirType(mlir::Type firTy) {
183-
assert(mlir::isa<fir::VectorType>(firTy));
183+
assert(firTy.isa<fir::VectorType>());
184184
VecTypeInfo vecTyInfo;
185-
vecTyInfo.eleTy = mlir::dyn_cast<fir::VectorType>(firTy).getEleTy();
186-
vecTyInfo.len = mlir::dyn_cast<fir::VectorType>(firTy).getLen();
185+
vecTyInfo.eleTy = firTy.dyn_cast<fir::VectorType>().getEleTy();
186+
vecTyInfo.len = firTy.dyn_cast<fir::VectorType>().getLen();
187187
return vecTyInfo;
188188
}
189189

flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,17 @@ include "flang/Optimizer/Dialect/FIROps.td"
2121

2222
def IdenticalTypePred : Constraint<CPred<"$0.getType() == $1.getType()">>;
2323
def IntegerTypePred : Constraint<CPred<"fir::isa_integer($0.getType())">>;
24-
def IndexTypePred : Constraint<CPred<
25-
"mlir::isa<mlir::IndexType>($0.getType())">>;
24+
def IndexTypePred : Constraint<CPred<"$0.getType().isa<mlir::IndexType>()">>;
2625

2726
// Widths are monotonic.
2827
// $0.bits >= $1.bits >= $2.bits or $0.bits <= $1.bits <= $2.bits
2928
def MonotonicTypePred
30-
: Constraint<CPred<"((mlir::isa<mlir::IntegerType>($0.getType()) && "
31-
" mlir::isa<mlir::IntegerType>($1.getType()) && "
32-
" mlir::isa<mlir::IntegerType>($2.getType())) || "
33-
" (mlir::isa<mlir::FloatType>($0.getType()) && "
34-
" mlir::isa<mlir::FloatType>($1.getType()) && "
35-
" mlir::isa<mlir::FloatType>($2.getType()))) && "
29+
: Constraint<CPred<"(($0.getType().isa<mlir::IntegerType>() && "
30+
" $1.getType().isa<mlir::IntegerType>() && "
31+
" $2.getType().isa<mlir::IntegerType>()) || "
32+
" ($0.getType().isa<mlir::FloatType>() && "
33+
" $1.getType().isa<mlir::FloatType>() && "
34+
" $2.getType().isa<mlir::FloatType>())) && "
3635
"(($0.getType().getIntOrFloatBitWidth() <= "
3736
" $1.getType().getIntOrFloatBitWidth() && "
3837
" $1.getType().getIntOrFloatBitWidth() <= "
@@ -43,8 +42,8 @@ def MonotonicTypePred
4342
" $2.getType().getIntOrFloatBitWidth()))">>;
4443

4544
def IntPred : Constraint<CPred<
46-
"mlir::isa<mlir::IntegerType>($0.getType()) && "
47-
"mlir::isa<mlir::IntegerType>($1.getType())">>;
45+
"$0.getType().isa<mlir::IntegerType>() && "
46+
"$1.getType().isa<mlir::IntegerType>()">>;
4847

4948
// If both are int type and the first is smaller than the second.
5049
// $0.bits <= $1.bits
@@ -102,8 +101,8 @@ def CombineConvertTruncOptPattern
102101
def createConstantOp
103102
: NativeCodeCall<"$_builder.create<mlir::arith::ConstantOp>"
104103
"($_loc, $_builder.getIndexType(), "
105-
"rewriter.getIndexAttr("
106-
"mlir::dyn_cast<mlir::IntegerAttr>($1).getInt()))">;
104+
"rewriter.getIndexAttr($1.dyn_cast<mlir::IntegerAttr>()"
105+
".getInt()))">;
107106

108107
def ForwardConstantConvertPattern
109108
: Pat<(fir_ConvertOp:$res (Arith_ConstantOp:$cnt $attr)),

flang/include/flang/Optimizer/Dialect/FIROps.td

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2708,14 +2708,14 @@ def fir_ConvertOp : fir_OneResultOp<"convert", [NoMemoryEffect]> {
27082708
let hasCanonicalizer = 1;
27092709
}
27102710

2711-
def FortranTypeAttr : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
2712-
Or<[CPred<"mlir::isa<fir::CharacterType, fir::ComplexType, "
2713-
"fir::IntegerType, fir::LogicalType, fir::RealType, "
2714-
"fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self).getValue())"
2715-
>]>]>, "Fortran surface type"> {
2711+
def FortranTypeAttr : Attr<And<[CPred<"$_self.isa<mlir::TypeAttr>()">,
2712+
Or<[CPred<"$_self.cast<mlir::TypeAttr>().getValue().isa<fir::CharacterType,"
2713+
"fir::ComplexType, fir::IntegerType, fir::LogicalType,"
2714+
"fir::RealType, fir::RecordType>()">]>]>,
2715+
"Fortran surface type"> {
27162716
let storageType = [{ ::mlir::TypeAttr }];
27172717
let returnType = "mlir::Type";
2718-
let convertFromStorage = "mlir::cast<mlir::Type>($_self.getValue())";
2718+
let convertFromStorage = "$_self.getValue().cast<mlir::Type>()";
27192719
}
27202720

27212721
def fir_TypeDescOp : fir_OneResultOp<"type_desc", [NoMemoryEffect]> {

0 commit comments

Comments
 (0)