From: Tres Popp Date: Thu, 25 May 2023 14:35:45 +0000 (+0200) Subject: [mlir] Update cast/isa method calls to function calls X-Git-Tag: upstream/17.0.6~7113 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d46a135db54f6589a77628437aa7115cb90c80db;p=platform%2Fupstream%2Fllvm.git [mlir] Update cast/isa method calls to function calls This updates the rest (at implementation) of MLIR's use of cast/isa method calls where function calls are possible and automatic refactoring is not. These changes occured in .td files or in macros. Context: - https://mlir.llvm.org/deprecation/ at "Use the free function variants for dyn_cast/cast/isa/…" - Original discussion at https://discourse.llvm.org/t/preferred-casting-style-going-forward/68443 --- diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td index 281f009..6f83c05 100644 --- a/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPOpsInterfaces.td @@ -158,7 +158,7 @@ def OffloadModuleInterface : OpInterface<"OffloadModuleInterface"> { /*methodName=*/"getFlags", (ins), [{}], [{ if (Attribute flags = $_op->getAttr("omp.flags")) - return flags.dyn_cast_or_null(); + return ::llvm::dyn_cast_or_null(flags); return nullptr; }]>, InterfaceMethod< @@ -188,7 +188,7 @@ def OffloadModuleInterface : OpInterface<"OffloadModuleInterface"> { /*methodName=*/"getTarget", (ins), [{}], [{ if (Attribute flags = $_op->getAttr("omp.target")) - return flags.dyn_cast_or_null(); + return ::llvm::dyn_cast_or_null(flags); return nullptr; }]>, InterfaceMethod< diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td index 3273485..075eee4 100644 --- a/mlir/include/mlir/IR/BuiltinAttributes.td +++ b/mlir/include/mlir/IR/BuiltinAttributes.td @@ -562,8 +562,8 @@ def Builtin_DictionaryAttr : Builtin_Attr<"Dictionary"> { /// `AttrClass`, null otherwise. template AttrClass getAs(NameClass &&name) const { - return get(std::forward(name)) - .template dyn_cast_or_null(); + return llvm::dyn_cast_or_null( + get(std::forward(name))); } private: diff --git a/mlir/include/mlir/IR/EnumAttr.td b/mlir/include/mlir/IR/EnumAttr.td index 64a2ea1..485c526 100644 --- a/mlir/include/mlir/IR/EnumAttr.td +++ b/mlir/include/mlir/IR/EnumAttr.td @@ -168,7 +168,7 @@ class EnumAttrInfo< // Override Attr class fields for specialized class let predicate = !if(genSpecializedAttr, - CPred<"$_self.isa<" # cppNamespace # "::" # specializedAttrClassName # ">()">, + CPred<"::llvm::isa<" # cppNamespace # "::" # specializedAttrClassName # ">($_self)">, baseAttrClass.predicate); let storageType = !if(genSpecializedAttr, cppNamespace # "::" # specializedAttrClassName, diff --git a/mlir/include/mlir/IR/FunctionInterfaces.td b/mlir/include/mlir/IR/FunctionInterfaces.td index 17bbdcc..48145e5 100644 --- a/mlir/include/mlir/IR/FunctionInterfaces.td +++ b/mlir/include/mlir/IR/FunctionInterfaces.td @@ -445,11 +445,11 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface", [Symbol]> { template AttrClass getArgAttrOfType(unsigned index, StringAttr name) { - return getArgAttr(index, name).template dyn_cast_or_null(); + return ::llvm::dyn_cast_or_null(getArgAttr(index, name)); } template AttrClass getArgAttrOfType(unsigned index, StringRef name) { - return getArgAttr(index, name).template dyn_cast_or_null(); + return ::llvm::dyn_cast_or_null(getArgAttr(index, name)); } /// Set the attributes held by the argument at 'index'. @@ -534,11 +534,11 @@ def FunctionOpInterface : OpInterface<"FunctionOpInterface", [Symbol]> { template AttrClass getResultAttrOfType(unsigned index, StringAttr name) { - return getResultAttr(index, name).template dyn_cast_or_null(); + return ::llvm::dyn_cast_or_null(getResultAttr(index, name)); } template AttrClass getResultAttrOfType(unsigned index, StringRef name) { - return getResultAttr(index, name).template dyn_cast_or_null(); + return ::llvm::dyn_cast_or_null(getResultAttr(index, name)); } /// Set the attributes held by the result at 'index'. diff --git a/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp b/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp index a4f20c6..2bc1e36 100644 --- a/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp +++ b/mlir/lib/Conversion/VectorToSPIRV/VectorToSPIRV.cpp @@ -350,10 +350,10 @@ struct VectorReductionPattern final #define INT_AND_FLOAT_CASE(kind, iop, fop) \ case vector::CombiningKind::kind: \ - if (resultType.isa()) { \ + if (llvm::isa(resultType)) { \ result = rewriter.create(loc, resultType, result, next); \ } else { \ - assert(resultType.isa()); \ + assert(llvm::isa(resultType)); \ result = rewriter.create(loc, resultType, result, next); \ } \ break diff --git a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp index cbf615a..fc2e17a2 100644 --- a/mlir/lib/Dialect/EmitC/IR/EmitC.cpp +++ b/mlir/lib/Dialect/EmitC/IR/EmitC.cpp @@ -100,7 +100,7 @@ LogicalResult emitc::CallOp::verify() { // Args with elements of type ArrayAttr must have a type. } else if (llvm::isa( - arg) /*&& arg.getType().isa()*/) { + arg) /*&& llvm::isa(arg.getType())*/) { // FIXME: Array attributes never have types return emitOpError("array argument has no type"); } diff --git a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp index a70749e..e95e628 100644 --- a/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp +++ b/mlir/lib/Dialect/Tosa/IR/TosaCanonicalizations.cpp @@ -826,7 +826,7 @@ OpFoldResult ConstOp::fold(FoldAdaptor adaptor) { return getValueAttr(); } #define REDUCE_FOLDER(OP) \ OpFoldResult OP::fold(FoldAdaptor adaptor) { \ - ShapedType inputTy = getInput().getType().cast(); \ + ShapedType inputTy = llvm::cast(getInput().getType()); \ if (!inputTy.hasRank()) \ return {}; \ if (inputTy.getDimSize(getAxis()) == 1) \ diff --git a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp index d2c732c..69bce52 100644 --- a/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp +++ b/mlir/lib/Dialect/Tosa/IR/TosaOps.cpp @@ -154,7 +154,7 @@ LogicalResult tosa::AvgPool2dOp::verify() { resultETy = quantType.getStorageType(); auto accType = getAccType(); - if (inputETy.isa() && !accType.isInteger(32)) + if (llvm::isa(inputETy) && !accType.isInteger(32)) return emitOpError("accumulator type for integer tensor is not i32"); if ((inputETy.isBF16() || inputETy.isF16()) && @@ -984,7 +984,7 @@ static LogicalResult ReduceInferReturnTypes( OpaqueProperties properties, RegionRange regions, \ SmallVectorImpl &inferredReturnShapes) { \ Type inputType = \ - operands.getType()[0].cast().getElementType(); \ + llvm::cast(operands.getType()[0]).getElementType(); \ return ReduceInferReturnTypes(operands.getShape(0), inputType, \ properties.as()->axis, \ inferredReturnShapes); \ diff --git a/mlir/lib/Dialect/Tosa/Utils/QuantUtils.cpp b/mlir/lib/Dialect/Tosa/Utils/QuantUtils.cpp index a164135..eb81446 100644 --- a/mlir/lib/Dialect/Tosa/Utils/QuantUtils.cpp +++ b/mlir/lib/Dialect/Tosa/Utils/QuantUtils.cpp @@ -108,9 +108,9 @@ void mlir::tosa::computeMultiplierAndShift(double scale, int32_t &multiplier, } #define GET_UQTYPE(input_type) \ - ((input_type).getElementType().dyn_cast()) + (llvm::dyn_cast((input_type).getElementType())) #define GET_QTYPE(input_type) \ - ((input_type).getElementType().dyn_cast()) + (llvm::dyn_cast((input_type).getElementType())) /// Method to build ConvOpQuantizationAttr, called from /// ConvOpQuantInfoBuilder/TransConvOpQuantInfoBuilder: diff --git a/mlir/test/python/python_test_ops.td b/mlir/test/python/python_test_ops.td index 1be8415..21bb95dd 100644 --- a/mlir/test/python/python_test_ops.td +++ b/mlir/test/python/python_test_ops.td @@ -122,7 +122,7 @@ def InferShapedTypeComponentsOp : TestOp<"infer_shaped_type_components_op", ::mlir::ShapedTypeComponents>& inferredShapedTypeComponents) { $cppClass::Adaptor adaptor(operands, attributes, properties, regions); auto operandType = - adaptor.getOperand().getType().cast<::mlir::ShapedType>(); + ::llvm::cast<::mlir::ShapedType>(adaptor.getOperand().getType()); if (operandType.hasRank()) { inferredShapedTypeComponents.emplace_back(operandType.getShape(), operandType.getElementType());