[flang-commits] [flang] [llvm] [mlir] Revert "[mlir] Mark `isa/dyn_cast/cast/...` member functions deprecated. (#89998)" (PR #90250)

via flang-commits flang-commits at lists.llvm.org
Fri Apr 26 12:09:22 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir-core

Author: None (dyung)

<details>
<summary>Changes</summary>

This reverts commit 950b7ce0b88318f9099e9a7c9817d224ebdc6337.

This change is causing build failures on a bot https://lab.llvm.org/buildbot/#/builders/216/builds/38157

---

Patch is 462.14 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/90250.diff


97 Files Affected:

- (modified) flang/include/flang/Lower/Mangler.h (+1-1) 
- (modified) flang/include/flang/Optimizer/Analysis/TBAAForest.h (+1-1) 
- (modified) flang/include/flang/Optimizer/Builder/BoxValue.h (+10-10) 
- (modified) flang/include/flang/Optimizer/Builder/Factory.h (+6-6) 
- (modified) flang/include/flang/Optimizer/Builder/HLFIRTools.h (+7-7) 
- (modified) flang/include/flang/Optimizer/Builder/IntrinsicCall.h (+2-2) 
- (modified) flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h (+3-3) 
- (modified) flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td (+11-12) 
- (modified) flang/include/flang/Optimizer/Dialect/FIROps.td (+6-6) 
- (modified) flang/include/flang/Optimizer/Dialect/FIRType.h (+36-38) 
- (modified) flang/include/flang/Optimizer/Dialect/FIRTypes.td (+1-1) 
- (modified) flang/include/flang/Optimizer/Dialect/FortranVariableInterface.td (+5-5) 
- (modified) flang/include/flang/Optimizer/HLFIR/HLFIRDialect.h (+10-10) 
- (modified) flang/include/flang/Optimizer/Support/Utils.h (+1-3) 
- (modified) flang/include/flang/Tools/PointerModels.h (+2-2) 
- (modified) flang/lib/Lower/Allocatable.cpp (+6-6) 
- (modified) flang/lib/Lower/Bridge.cpp (+19-20) 
- (modified) flang/lib/Lower/CallInterface.cpp (+3-3) 
- (modified) flang/lib/Lower/ConvertArrayConstructor.cpp (+5-6) 
- (modified) flang/lib/Lower/ConvertCall.cpp (+27-29) 
- (modified) flang/lib/Lower/ConvertConstant.cpp (+12-11) 
- (modified) flang/lib/Lower/ConvertExpr.cpp (+91-97) 
- (modified) flang/lib/Lower/ConvertExprToHLFIR.cpp (+14-14) 
- (modified) flang/lib/Lower/ConvertProcedureDesignator.cpp (+3-3) 
- (modified) flang/lib/Lower/ConvertVariable.cpp (+11-11) 
- (modified) flang/lib/Lower/CustomIntrinsicCall.cpp (+17-18) 
- (modified) flang/lib/Lower/DirectivesCommon.h (+11-13) 
- (modified) flang/lib/Lower/HlfirIntrinsics.cpp (+2-2) 
- (modified) flang/lib/Lower/HostAssociations.cpp (+7-7) 
- (modified) flang/lib/Lower/IO.cpp (+27-28) 
- (modified) flang/lib/Lower/OpenACC.cpp (+2-2) 
- (modified) flang/lib/Lower/OpenMP/ClauseProcessor.cpp (+4-4) 
- (modified) flang/lib/Lower/OpenMP/OpenMP.cpp (+5-7) 
- (modified) flang/lib/Lower/OpenMP/ReductionProcessor.cpp (+9-9) 
- (modified) flang/lib/Lower/VectorSubscripts.cpp (+1-1) 
- (modified) flang/lib/Optimizer/Analysis/AliasAnalysis.cpp (+2-2) 
- (modified) flang/lib/Optimizer/Builder/BoxValue.cpp (+2-2) 
- (modified) flang/lib/Optimizer/Builder/Character.cpp (+20-21) 
- (modified) flang/lib/Optimizer/Builder/Complex.cpp (+1-2) 
- (modified) flang/lib/Optimizer/Builder/FIRBuilder.cpp (+53-54) 
- (modified) flang/lib/Optimizer/Builder/HLFIRTools.cpp (+40-38) 
- (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+52-55) 
- (modified) flang/lib/Optimizer/Builder/MutableBox.cpp (+17-18) 
- (modified) flang/lib/Optimizer/Builder/PPCIntrinsicCall.cpp (+23-21) 
- (modified) flang/lib/Optimizer/Builder/Runtime/Allocatable.cpp (+1-1) 
- (modified) flang/lib/Optimizer/Builder/Runtime/Character.cpp (+4-4) 
- (modified) flang/lib/Optimizer/Builder/Runtime/Intrinsics.cpp (+2-4) 
- (modified) flang/lib/Optimizer/Builder/Runtime/Ragged.cpp (+1-2) 
- (modified) flang/lib/Optimizer/Builder/Runtime/Reduction.cpp (+10-10) 
- (modified) flang/lib/Optimizer/CodeGen/BoxedProcedure.cpp (+8-8) 
- (modified) flang/lib/Optimizer/CodeGen/CGOps.cpp (+7-7) 
- (modified) flang/lib/Optimizer/CodeGen/CodeGen.cpp (+96-107) 
- (modified) flang/lib/Optimizer/CodeGen/FIROpPatterns.cpp (+9-9) 
- (modified) flang/lib/Optimizer/CodeGen/PreCGRewrite.cpp (+7-6) 
- (modified) flang/lib/Optimizer/CodeGen/TBAABuilder.cpp (+1-1) 
- (modified) flang/lib/Optimizer/CodeGen/Target.cpp (+2-2) 
- (modified) flang/lib/Optimizer/CodeGen/TargetRewrite.cpp (+10-11) 
- (modified) flang/lib/Optimizer/CodeGen/TypeConverter.cpp (+8-10) 
- (modified) flang/lib/Optimizer/Dialect/FIRAttr.cpp (+7-7) 
- (modified) flang/lib/Optimizer/Dialect/FIROps.cpp (+149-153) 
- (modified) flang/lib/Optimizer/Dialect/FIRType.cpp (+59-62) 
- (modified) flang/lib/Optimizer/Dialect/FortranVariableInterface.cpp (+5-6) 
- (modified) flang/lib/Optimizer/HLFIR/IR/HLFIRDialect.cpp (+14-16) 
- (modified) flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp (+101-91) 
- (modified) flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp (+14-15) 
- (modified) flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp (+23-24) 
- (modified) flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIRIntrinsics.cpp (+1-1) 
- (modified) flang/lib/Optimizer/HLFIR/Transforms/LowerHLFIROrderedAssignments.cpp (+1-1) 
- (modified) flang/lib/Optimizer/HLFIR/Transforms/OptimizedBufferization.cpp (+6-6) 
- (modified) flang/lib/Optimizer/HLFIR/Transforms/SimplifyHLFIRIntrinsics.cpp (+1-2) 
- (modified) flang/lib/Optimizer/Transforms/AbstractResult.cpp (+8-8) 
- (modified) flang/lib/Optimizer/Transforms/AddDebugInfo.cpp (+3-3) 
- (modified) flang/lib/Optimizer/Transforms/AffineDemotion.cpp (+4-5) 
- (modified) flang/lib/Optimizer/Transforms/AffinePromotion.cpp (+5-6) 
- (modified) flang/lib/Optimizer/Transforms/ArrayValueCopy.cpp (+15-15) 
- (modified) flang/lib/Optimizer/Transforms/CharacterConversion.cpp (+2-2) 
- (modified) flang/lib/Optimizer/Transforms/LoopVersioning.cpp (+1-1) 
- (modified) flang/lib/Optimizer/Transforms/MemoryAllocation.cpp (+1-1) 
- (modified) flang/lib/Optimizer/Transforms/PolymorphicOpConversion.cpp (+19-19) 
- (modified) flang/lib/Optimizer/Transforms/SimplifyIntrinsics.cpp (+24-28) 
- (modified) flang/lib/Optimizer/Transforms/StackArrays.cpp (+1-1) 
- (modified) flang/unittests/Optimizer/Builder/ComplexTest.cpp (+1-1) 
- (modified) flang/unittests/Optimizer/Builder/DoLoopHelperTest.cpp (+1-1) 
- (modified) flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp (+23-25) 
- (modified) flang/unittests/Optimizer/RTBuilder.cpp (+1-1) 
- (modified) llvm/include/llvm/ADT/TypeSwitch.h (-3) 
- (modified) mlir/include/mlir/Dialect/Linalg/IR/LinalgOps.td (+2-2) 
- (modified) mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td (+4-4) 
- (modified) mlir/include/mlir/Dialect/XeGPU/IR/XeGPUOps.td (+5-5) 
- (modified) mlir/include/mlir/IR/Attributes.h (-5) 
- (modified) mlir/include/mlir/IR/BuiltinLocationAttributes.td (+5-8) 
- (modified) mlir/include/mlir/IR/Location.h (-3) 
- (modified) mlir/include/mlir/IR/Types.h (-5) 
- (modified) mlir/include/mlir/IR/Value.h (+4-4) 
- (modified) mlir/lib/Conversion/ComplexToStandard/ComplexToStandard.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Polynomial/IR/PolynomialAttributes.cpp (+1-1) 
- (modified) mlir/lib/Dialect/Vector/Transforms/VectorLinearize.cpp (+9-7) 


``````````diff
diff --git a/flang/include/flang/Lower/Mangler.h b/flang/include/flang/Lower/Mangler.h
index 99da96b0d6ba51..41939abe29e5e2 100644
--- a/flang/include/flang/Lower/Mangler.h
+++ b/flang/include/flang/Lower/Mangler.h
@@ -90,7 +90,7 @@ inline std::string mangleArrayLiteral(
   return mangleArrayLiteral(x.values().size() * sizeof(x.values()[0]),
                             x.shape(), Fortran::common::TypeCategory::Derived,
                             /*kind=*/0, /*charLen=*/-1,
-                            mlir::cast<fir::RecordType>(eleTy).getName());
+                            eleTy.cast<fir::RecordType>().getName());
 }
 
 /// Return the compiler-generated name of a static namelist variable descriptor.
diff --git a/flang/include/flang/Optimizer/Analysis/TBAAForest.h b/flang/include/flang/Optimizer/Analysis/TBAAForest.h
index 619ed4939c51c4..b69e50bbe05c7e 100644
--- a/flang/include/flang/Optimizer/Analysis/TBAAForest.h
+++ b/flang/include/flang/Optimizer/Analysis/TBAAForest.h
@@ -88,7 +88,7 @@ class TBAAForrest {
     // name must be used so that we add to the tbaa tree added in the FIR pass
     mlir::Attribute attr = func->getAttr(getInternalFuncNameAttrName());
     if (attr) {
-      return getFuncTree(mlir::cast<mlir::StringAttr>(attr));
+      return getFuncTree(attr.cast<mlir::StringAttr>());
     }
     return getFuncTree(func.getSymNameAttr());
   }
diff --git a/flang/include/flang/Optimizer/Builder/BoxValue.h b/flang/include/flang/Optimizer/Builder/BoxValue.h
index 5c7e89dbc08f11..2fed2d48a7a080 100644
--- a/flang/include/flang/Optimizer/Builder/BoxValue.h
+++ b/flang/include/flang/Optimizer/Builder/BoxValue.h
@@ -78,7 +78,7 @@ class CharBoxValue : public AbstractBox {
 public:
   CharBoxValue(mlir::Value addr, mlir::Value len)
       : AbstractBox{addr}, len{len} {
-    if (addr && mlir::isa<fir::BoxCharType>(addr.getType()))
+    if (addr && addr.getType().template isa<fir::BoxCharType>())
       fir::emitFatalError(addr.getLoc(),
                           "BoxChar should not be in CharBoxValue");
   }
@@ -221,7 +221,7 @@ class AbstractIrBox : public AbstractBox, public AbstractArrayBox {
     auto type = getAddr().getType();
     if (auto pointedTy = fir::dyn_cast_ptrEleTy(type))
       type = pointedTy;
-    return mlir::cast<fir::BaseBoxType>(type);
+    return type.cast<fir::BaseBoxType>();
   }
   /// Return the part of the address type after memory and box types. That is
   /// the element type, maybe wrapped in a fir.array type.
@@ -243,22 +243,22 @@ class AbstractIrBox : public AbstractBox, public AbstractArrayBox {
   /// Get the scalar type related to the described entity
   mlir::Type getEleTy() const {
     auto type = getBaseTy();
-    if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(type))
+    if (auto seqTy = type.dyn_cast<fir::SequenceType>())
       return seqTy.getEleTy();
     return type;
   }
 
   /// Is the entity an array or an assumed rank ?
-  bool hasRank() const { return mlir::isa<fir::SequenceType>(getBaseTy()); }
+  bool hasRank() const { return getBaseTy().isa<fir::SequenceType>(); }
   /// Is this an assumed rank ?
   bool hasAssumedRank() const {
-    auto seqTy = mlir::dyn_cast<fir::SequenceType>(getBaseTy());
+    auto seqTy = getBaseTy().dyn_cast<fir::SequenceType>();
     return seqTy && seqTy.hasUnknownShape();
   }
   /// Returns the rank of the entity. Beware that zero will be returned for
   /// both scalars and assumed rank.
   unsigned rank() const {
-    if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(getBaseTy()))
+    if (auto seqTy = getBaseTy().dyn_cast<fir::SequenceType>())
       return seqTy.getDimension();
     return 0;
   }
@@ -267,7 +267,7 @@ class AbstractIrBox : public AbstractBox, public AbstractArrayBox {
   bool isCharacter() const { return fir::isa_char(getEleTy()); }
 
   /// Is this a derived type entity ?
-  bool isDerived() const { return mlir::isa<fir::RecordType>(getEleTy()); }
+  bool isDerived() const { return getEleTy().isa<fir::RecordType>(); }
 
   bool isDerivedWithLenParameters() const {
     return fir::isRecordWithTypeParameters(getEleTy());
@@ -377,11 +377,11 @@ class MutableBoxValue : public AbstractIrBox {
   }
   /// Is this a Fortran pointer ?
   bool isPointer() const {
-    return mlir::isa<fir::PointerType>(getBoxTy().getEleTy());
+    return getBoxTy().getEleTy().isa<fir::PointerType>();
   }
   /// Is this an allocatable ?
   bool isAllocatable() const {
-    return mlir::isa<fir::HeapType>(getBoxTy().getEleTy());
+    return getBoxTy().getEleTy().isa<fir::HeapType>();
   }
   // Replace the fir.ref<fir.box>, keeping any non-deferred parameters.
   MutableBoxValue clone(mlir::Value newBox) const {
@@ -488,7 +488,7 @@ class ExtendedValue : public details::matcher<ExtendedValue> {
     if (const auto *b = getUnboxed()) {
       if (*b) {
         auto type = b->getType();
-        if (mlir::isa<fir::BoxCharType>(type))
+        if (type.template isa<fir::BoxCharType>())
           fir::emitFatalError(b->getLoc(), "BoxChar should be unboxed");
         type = fir::unwrapSequenceType(fir::unwrapRefType(type));
         if (fir::isa_char(type))
diff --git a/flang/include/flang/Optimizer/Builder/Factory.h b/flang/include/flang/Optimizer/Builder/Factory.h
index 4e5c52ac44e07e..ec294d26ac961c 100644
--- a/flang/include/flang/Optimizer/Builder/Factory.h
+++ b/flang/include/flang/Optimizer/Builder/Factory.h
@@ -43,9 +43,9 @@ template <typename B>
 void genCharacterCopy(mlir::Value src, mlir::Value srcLen, mlir::Value dst,
                       mlir::Value dstLen, B &builder, mlir::Location loc) {
   auto srcTy =
-      mlir::cast<fir::CharacterType>(fir::dyn_cast_ptrEleTy(src.getType()));
+      fir::dyn_cast_ptrEleTy(src.getType()).template cast<fir::CharacterType>();
   auto dstTy =
-      mlir::cast<fir::CharacterType>(fir::dyn_cast_ptrEleTy(dst.getType()));
+      fir::dyn_cast_ptrEleTy(dst.getType()).template cast<fir::CharacterType>();
   if (!srcLen && !dstLen && srcTy.getFKind() == dstTy.getFKind() &&
       srcTy.getLen() == dstTy.getLen()) {
     // same size, so just use load and store
@@ -61,8 +61,8 @@ void genCharacterCopy(mlir::Value src, mlir::Value srcLen, mlir::Value dst,
         fir::CharacterType::getSingleton(ty.getContext(), ty.getFKind())));
   };
   auto toEleTy = [&](fir::ReferenceType ty) {
-    auto seqTy = mlir::cast<fir::SequenceType>(ty.getEleTy());
-    return mlir::cast<fir::CharacterType>(seqTy.getEleTy());
+    auto seqTy = ty.getEleTy().cast<fir::SequenceType>();
+    return seqTy.getEleTy().cast<fir::CharacterType>();
   };
   auto toCoorTy = [&](fir::ReferenceType ty) {
     return fir::ReferenceType::get(toEleTy(ty));
@@ -190,8 +190,8 @@ originateIndices(mlir::Location loc, B &builder, mlir::Type memTy,
   if (origins.empty()) {
     assert(!shapeVal || mlir::isa<fir::ShapeOp>(shapeVal.getDefiningOp()));
     auto ty = fir::dyn_cast_ptrOrBoxEleTy(memTy);
-    assert(ty && mlir::isa<fir::SequenceType>(ty));
-    auto seqTy = mlir::cast<fir::SequenceType>(ty);
+    assert(ty && ty.isa<fir::SequenceType>());
+    auto seqTy = ty.cast<fir::SequenceType>();
     auto one = builder.template create<mlir::arith::ConstantIndexOp>(loc, 1);
     const auto dimension = seqTy.getDimension();
     if (shapeVal) {
diff --git a/flang/include/flang/Optimizer/Builder/HLFIRTools.h b/flang/include/flang/Optimizer/Builder/HLFIRTools.h
index 6c36f7e84db688..035035601e2f25 100644
--- a/flang/include/flang/Optimizer/Builder/HLFIRTools.h
+++ b/flang/include/flang/Optimizer/Builder/HLFIRTools.h
@@ -77,12 +77,12 @@ class Entity : public mlir::Value {
   /// Return the rank of this entity or -1 if it is an assumed rank.
   int getRank() const {
     mlir::Type type = fir::unwrapPassByRefType(fir::unwrapRefType(getType()));
-    if (auto seqTy = mlir::dyn_cast<fir::SequenceType>(type)) {
+    if (auto seqTy = type.dyn_cast<fir::SequenceType>()) {
       if (seqTy.hasUnknownShape())
         return -1;
       return seqTy.getDimension();
     }
-    if (auto exprType = mlir::dyn_cast<hlfir::ExprType>(type))
+    if (auto exprType = type.dyn_cast<hlfir::ExprType>())
       return exprType.getRank();
     return 0;
   }
@@ -99,17 +99,17 @@ class Entity : public mlir::Value {
 
   bool hasLengthParameters() const {
     mlir::Type eleTy = getFortranElementType();
-    return mlir::isa<fir::CharacterType>(eleTy) ||
+    return eleTy.isa<fir::CharacterType>() ||
            fir::isRecordWithTypeParameters(eleTy);
   }
 
   bool isCharacter() const {
-    return mlir::isa<fir::CharacterType>(getFortranElementType());
+    return getFortranElementType().isa<fir::CharacterType>();
   }
 
   bool hasIntrinsicType() const {
     mlir::Type eleTy = getFortranElementType();
-    return fir::isa_trivial(eleTy) || mlir::isa<fir::CharacterType>(eleTy);
+    return fir::isa_trivial(eleTy) || eleTy.isa<fir::CharacterType>();
   }
 
   bool isDerivedWithLengthParameters() const {
@@ -124,8 +124,8 @@ class Entity : public mlir::Value {
     if (auto varIface = getIfVariableInterface()) {
       if (auto shape = varIface.getShape()) {
         auto shapeTy = shape.getType();
-        return mlir::isa<fir::ShiftType>(shapeTy) ||
-               mlir::isa<fir::ShapeShiftType>(shapeTy);
+        return shapeTy.isa<fir::ShiftType>() ||
+               shapeTy.isa<fir::ShapeShiftType>();
       }
       return false;
     }
diff --git a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
index b7d06092676132..604f2bd969eed5 100644
--- a/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/IntrinsicCall.h
@@ -663,8 +663,8 @@ static inline mlir::FunctionType genFuncType(mlir::MLIRContext *context,
 //===----------------------------------------------------------------------===//
 static inline mlir::Type getConvertedElementType(mlir::MLIRContext *context,
                                                  mlir::Type eleTy) {
-  if (mlir::isa<mlir::IntegerType>(eleTy) && !eleTy.isSignlessInteger()) {
-    const auto intTy{mlir::dyn_cast<mlir::IntegerType>(eleTy)};
+  if (eleTy.isa<mlir::IntegerType>() && !eleTy.isSignlessInteger()) {
+    const auto intTy{eleTy.dyn_cast<mlir::IntegerType>()};
     auto newEleTy{mlir::IntegerType::get(context, intTy.getWidth())};
     return newEleTy;
   }
diff --git a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
index a7c4c075d818ee..1e87bf0f6ad159 100644
--- a/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
+++ b/flang/include/flang/Optimizer/Builder/PPCIntrinsicCall.h
@@ -180,10 +180,10 @@ struct VecTypeInfo {
 // Returns a VecTypeInfo with element type and length of given fir vector type.
 // Preserves signness of fir vector type if element type of integer.
 static inline VecTypeInfo getVecTypeFromFirType(mlir::Type firTy) {
-  assert(mlir::isa<fir::VectorType>(firTy));
+  assert(firTy.isa<fir::VectorType>());
   VecTypeInfo vecTyInfo;
-  vecTyInfo.eleTy = mlir::dyn_cast<fir::VectorType>(firTy).getEleTy();
-  vecTyInfo.len = mlir::dyn_cast<fir::VectorType>(firTy).getLen();
+  vecTyInfo.eleTy = firTy.dyn_cast<fir::VectorType>().getEleTy();
+  vecTyInfo.len = firTy.dyn_cast<fir::VectorType>().getLen();
   return vecTyInfo;
 }
 
diff --git a/flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td b/flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td
index 0ef37a37ce94f8..544fc3cdf75eab 100644
--- a/flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td
+++ b/flang/include/flang/Optimizer/Dialect/CanonicalizationPatterns.td
@@ -21,18 +21,17 @@ include "flang/Optimizer/Dialect/FIROps.td"
 
 def IdenticalTypePred : Constraint<CPred<"$0.getType() == $1.getType()">>;
 def IntegerTypePred : Constraint<CPred<"fir::isa_integer($0.getType())">>;
-def IndexTypePred : Constraint<CPred<
-                       "mlir::isa<mlir::IndexType>($0.getType())">>;
+def IndexTypePred : Constraint<CPred<"$0.getType().isa<mlir::IndexType>()">>;
 
 // Widths are monotonic.
 //   $0.bits >= $1.bits >= $2.bits or $0.bits <= $1.bits <= $2.bits
 def MonotonicTypePred
-    : Constraint<CPred<"((mlir::isa<mlir::IntegerType>($0.getType()) && "
-                       "  mlir::isa<mlir::IntegerType>($1.getType()) && "
-                       "  mlir::isa<mlir::IntegerType>($2.getType())) || "
-                       " (mlir::isa<mlir::FloatType>($0.getType()) && "
-                       "  mlir::isa<mlir::FloatType>($1.getType()) && "
-                       "  mlir::isa<mlir::FloatType>($2.getType()))) && "
+    : Constraint<CPred<"(($0.getType().isa<mlir::IntegerType>() && "
+                       "  $1.getType().isa<mlir::IntegerType>() && "
+                       "  $2.getType().isa<mlir::IntegerType>()) || "
+                       " ($0.getType().isa<mlir::FloatType>() && "
+                       "  $1.getType().isa<mlir::FloatType>() && "
+                       "  $2.getType().isa<mlir::FloatType>())) && "
                        "(($0.getType().getIntOrFloatBitWidth() <= "
                        "  $1.getType().getIntOrFloatBitWidth() && "
                        "  $1.getType().getIntOrFloatBitWidth() <= "
@@ -43,8 +42,8 @@ def MonotonicTypePred
                        "  $2.getType().getIntOrFloatBitWidth()))">>;
 
 def IntPred : Constraint<CPred<
-                       "mlir::isa<mlir::IntegerType>($0.getType()) && "
-                       "mlir::isa<mlir::IntegerType>($1.getType())">>;
+                       "$0.getType().isa<mlir::IntegerType>() && "
+                       "$1.getType().isa<mlir::IntegerType>()">>;
                        
 // If both are int type and the first is smaller than the second.
 //   $0.bits <= $1.bits
@@ -102,8 +101,8 @@ def CombineConvertTruncOptPattern
 def createConstantOp
     : NativeCodeCall<"$_builder.create<mlir::arith::ConstantOp>"
                      "($_loc, $_builder.getIndexType(), "
-                     "rewriter.getIndexAttr("
-                     "mlir::dyn_cast<mlir::IntegerAttr>($1).getInt()))">;
+                     "rewriter.getIndexAttr($1.dyn_cast<mlir::IntegerAttr>()"
+                     ".getInt()))">;
 
 def ForwardConstantConvertPattern
     : Pat<(fir_ConvertOp:$res (Arith_ConstantOp:$cnt $attr)),
diff --git a/flang/include/flang/Optimizer/Dialect/FIROps.td b/flang/include/flang/Optimizer/Dialect/FIROps.td
index 496193e25cab61..92790a691e4731 100644
--- a/flang/include/flang/Optimizer/Dialect/FIROps.td
+++ b/flang/include/flang/Optimizer/Dialect/FIROps.td
@@ -2708,14 +2708,14 @@ def fir_ConvertOp : fir_OneResultOp<"convert", [NoMemoryEffect]> {
   let hasCanonicalizer = 1;
 }
 
-def FortranTypeAttr : Attr<And<[CPred<"mlir::isa<mlir::TypeAttr>($_self)">,
-    Or<[CPred<"mlir::isa<fir::CharacterType, fir::ComplexType, "
-              "fir::IntegerType, fir::LogicalType, fir::RealType, "
-              "fir::RecordType>(mlir::cast<mlir::TypeAttr>($_self).getValue())"
-    >]>]>, "Fortran surface type"> {
+def FortranTypeAttr : Attr<And<[CPred<"$_self.isa<mlir::TypeAttr>()">,
+    Or<[CPred<"$_self.cast<mlir::TypeAttr>().getValue().isa<fir::CharacterType,"
+              "fir::ComplexType, fir::IntegerType, fir::LogicalType,"
+              "fir::RealType, fir::RecordType>()">]>]>,
+    "Fortran surface type"> {
   let storageType = [{ ::mlir::TypeAttr }];
   let returnType = "mlir::Type";
-  let convertFromStorage = "mlir::cast<mlir::Type>($_self.getValue())";
+  let convertFromStorage = "$_self.getValue().cast<mlir::Type>()";
 }
 
 def fir_TypeDescOp : fir_OneResultOp<"type_desc", [NoMemoryEffect]> {
diff --git a/flang/include/flang/Optimizer/Dialect/FIRType.h b/flang/include/flang/Optimizer/Dialect/FIRType.h
index b4344435db9f5f..7fcd9c1babf24f 100644
--- a/flang/include/flang/Optimizer/Dialect/FIRType.h
+++ b/flang/include/flang/Optimizer/Dialect/FIRType.h
@@ -97,36 +97,35 @@ bool isa_fir_or_std_type(mlir::Type t);
 
 /// Is `t` a FIR dialect type that implies a memory (de)reference?
 inline bool isa_ref_type(mlir::Type t) {
-  return mlir::isa<fir::ReferenceType, fir::PointerType, fir::HeapType,
-                   fir::LLVMPointerType>(t);
+  return t.isa<fir::ReferenceType, fir::PointerType, fir::HeapType,
+               fir::LLVMPointerType>();
 }
 
 /// Is `t` a boxed type?
 inline bool isa_box_type(mlir::Type t) {
-  return mlir::isa<fir::BaseBoxType, fir::BoxCharType, fir::BoxProcType>(t);
+  return t.isa<fir::BaseBoxType, fir::BoxCharType, fir::BoxProcType>();
 }
 
 /// Is `t` a type that is always trivially pass-by-reference? Specifically, this
 /// is testing if `t` is a ReferenceType or any box type. Compare this to
 /// conformsWithPassByRef(), which includes pointers and allocatables.
 inline bool isa_passbyref_type(mlir::Type t) {
-  return mlir::isa<fir::ReferenceType, mlir::FunctionType>(t) ||
-         isa_box_type(t);
+  return t.isa<fir::ReferenceType, mlir::FunctionType>() || isa_box_type(t);
 }
 
 /// Is `t` a type that can conform to be pass-by-reference? Depending on the
 /// context, these types may simply demote to pass-by-reference or a reference
 /// to them may have to be passed instead. Functions are always referent.
 inline bool conformsWithPassByRef(mlir::Type t) {
-  return isa_ref_type(t) || isa_box_type(t) || mlir::isa<mlir::FunctionType>(t);
+  return isa_ref_type(t) || isa_box_type(t) || t.isa<mlir::FunctionType>();
 }
 
 /// Is `t` a derived (record) type?
-inline bool isa_derived(mlir::Type t) { return mlir::isa<fir::RecordType>(t); }
+inline bool isa_derived(mlir::Type t) { return t.isa<fir::RecordType>(); }
 
 /// Is `t` type(c_ptr) or type(c_funptr)?
 inline bool isa_builtin_cptr_type(mlir::Type t) {
-  if (auto recTy = mlir::dyn_cast_or_null<fir::RecordType>(t))
+  if (auto recTy = t.dyn_cast_or_null<fir::RecordType>())
     return recTy.getName().ends_with("T__builtin_c_ptr") ||
            recTy.getName().ends_with("T__builtin_c_funptr");
   return false;
@@ -134,7 +133,7 @@ inline bool isa_builtin_cptr_type(mlir::Type t) {
 
 /// Is `t` a FIR dialect aggregate type?
 inline bool isa_aggregate(mlir::Type t) {
-  return mlir::isa<SequenceType, mlir::TupleType>(t) || fir::isa_derived(t);
+  return t.isa<SequenceType, mlir::TupleType>() || fir::isa_derived(t);
 }
 
 /// Extract the `Type` pointed to from a FIR memory reference type. If `t` is
@@ -147,17 +146,17 @@ mlir::Type dyn_cast_ptrOrBoxEleTy(mlir::Type t);
 
 /// Is `t` a FIR Real or MLIR Float type?
 inline bool isa_real(mlir::Type t) {
-  return mlir::isa<fir::RealType, mlir::FloatType>(t);
+  return t.isa<fir::RealType, mlir::FloatType>();
 }
 
 /// Is `t` an integral type?
 inline bool isa_integer(mlir::Type t) {
-  return mlir::isa<mlir::IndexType, mlir::IntegerType, fir::IntegerType>(t);
+  return t.isa<mlir::IndexType, mlir::IntegerType, fir::IntegerType>();
 }
 
 /// Is `t` a vector type?
 inline bool isa_vector(mlir::Type t) {
-  return mlir::isa<mlir::VectorType, fir::VectorType>(t);
+  return t.isa<mlir::VectorType, fir::VectorType>();
 }
 
 mlir::Type parseFirType(FIROpsDialect *, mlir::DialectAsmParser &parser);
@@ -170,22 +169,22 @@ void verifyIntegralType(mlir::Type type);
 
 /// Is `t` a FIR or MLIR Complex type?
 inline bool isa_complex(mlir::Type t) {
-  return mlir::isa<fir::ComplexType, mlir::ComplexType>(t);
+  return t.isa<fir::ComplexType, mlir::ComplexType>();
 }
 
 /// Is `t` a CHARACTER type? Does not check the length.
-inline bool isa_char(mlir::Type t) { return mlir::isa<fir::CharacterType>(t); }
+inline bool isa_char(mlir::Type t) { return t.isa<fir::CharacterType>(); }
 
 /// Is `t` a trivial intrinsic type? CHARACTER is <em>excluded</em> because it
 /// is a dependent type.
 inline bool isa_trivial(mlir::Type t) {
   return isa_integer(t) || isa_real(t) || isa_complex(t) || isa_vector(t) ||
-         mlir::isa<fir::LogicalType>(t);
+         t.isa<fir::LogicalType>();
 }
 
 /// Is `t` a CHARACTER type with a LEN other than 1?
 inline bool isa_char_string(mlir::Type t) {
-  if (auto ct = mlir::dyn_cast_or_null<fir::CharacterType>(t))
+  if (auto ct = t.dyn_cast_or_null<fir::CharacterType>())
     return ct.getLen() != fir::CharacterType::singleton();
   return false;
 }
@@ -199,7 +198,7 @@ bool isa_unknown_size_box(mlir::Type t);
 
 /// Returns true iff `t` is a fir.char type and has an unknown length.
 inline bool characterWithDynamicLen(mlir::Type t) {
-  if (auto charTy = mlir::d...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/90250


More information about the flang-commits mailing list