Skip to content

Commit 7d18f9b

Browse files
[SYCL-MLIR][NFC] use cast<X>(Y) instead of Y.cast<X>() (#8754)
`Y.cast<X>()` is [deprecated](https://mlir.llvm.org/deprecation/). --------- Signed-off-by: Tsang, Whitney <[email protected]>
1 parent f8c057c commit 7d18f9b

File tree

9 files changed

+80
-100
lines changed

9 files changed

+80
-100
lines changed

mlir-sycl/lib/Conversion/SYCLToGPU/SYCLToGPU.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Value createGetOp(OpBuilder &builder, Location loc, Type underlyingArrTy,
7575
Value res, Value index, ArrayAttr argumentTypes,
7676
FlatSymbolRefAttr functionName) {
7777
return TypeSwitch<Type, Value>(
78-
res.getType().cast<MemRefType>().getElementType())
78+
cast<MemRefType>(res.getType()).getElementType())
7979
.Case<IDType, RangeType>([&](auto arg) {
8080
// `this` type
8181
using ArgTy = decltype(arg);

mlir-sycl/lib/Conversion/SYCLToLLVM/SYCLFuncRegistry.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Value SYCLFuncDescriptor::call(FuncId funcId, ValueRange args,
3737
<< funcDesc.funcRef << "\n");
3838

3939
SmallVector<Type, 4> funcOutputTys;
40-
if (!funcDesc.outputTy.isa<LLVM::LLVMVoidType>())
40+
if (!isa<LLVM::LLVMVoidType>(funcDesc.outputTy))
4141
funcOutputTys.emplace_back(funcDesc.outputTy);
4242

4343
LLVMBuilder builder(b, loc);

mlir-sycl/lib/Conversion/SYCLToLLVM/SYCLToLLVM.cpp

Lines changed: 65 additions & 85 deletions
Large diffs are not rendered by default.

mlir-sycl/lib/Conversion/SYCLToSPIRV/SYCLToSPIRV.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Value createGetOp(OpBuilder &builder, Location loc, Type dimMtTy, Value res,
6363
Value index, ArrayAttr argumentTypes,
6464
FlatSymbolRefAttr functionName) {
6565
return TypeSwitch<Type, Value>(
66-
res.getType().cast<MemRefType>().getElementType())
66+
cast<MemRefType>(res.getType()).getElementType())
6767
.Case<IDType, RangeType>([&](auto arg) {
6868
// `this` type
6969
using ArgTy = decltype(arg);

mlir-sycl/lib/Dialect/Analysis/AliasAnalysis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ using namespace mlir;
2121

2222
// Return true if the value \p val is a function argument, and false otherwise.
2323
static bool isFuncArg(Value val) {
24-
auto blockArg = val.dyn_cast<BlockArgument>();
24+
auto blockArg = dyn_cast<BlockArgument>(val);
2525
if (!blockArg)
2626
return false;
2727

@@ -35,7 +35,7 @@ static bool isRestrict(Value val) {
3535
if (!isFuncArg(val))
3636
return false;
3737

38-
auto blockArg = val.cast<BlockArgument>();
38+
auto blockArg = cast<BlockArgument>(val);
3939
auto func = cast<FunctionOpInterface>(blockArg.getOwner()->getParentOp());
4040
return !!func.getArgAttr(blockArg.getArgNumber(),
4141
"local_alias_analysis.restrict");

mlir-sycl/lib/Dialect/IR/SYCLOps.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ bool SYCLCastOp::areCastCompatible(TypeRange Inputs, TypeRange Outputs) {
2020
if (Inputs.size() != 1 || Outputs.size() != 1)
2121
return false;
2222

23-
const auto Input = Inputs.front().dyn_cast<MemRefType>();
24-
const auto Output = Outputs.front().dyn_cast<MemRefType>();
23+
const auto Input = dyn_cast<MemRefType>(Inputs.front());
24+
const auto Output = dyn_cast<MemRefType>(Outputs.front());
2525
if (!Input || !Output)
2626
return false;
2727

@@ -69,8 +69,8 @@ bool SYCLAddrSpaceCastOp::areCastCompatible(TypeRange inputs,
6969
if (inputs.size() != 1 || outputs.size() != 1)
7070
return false;
7171

72-
const auto input = inputs.front().dyn_cast<MemRefType>();
73-
const auto output = outputs.front().dyn_cast<MemRefType>();
72+
const auto input = dyn_cast<MemRefType>(inputs.front());
73+
const auto output = dyn_cast<MemRefType>(outputs.front());
7474
if (!input || !output)
7575
return false;
7676

@@ -133,7 +133,7 @@ LogicalResult SYCLAccessorSubscriptOp::verify() {
133133
[&](auto Ty) { return VerifyElemType(Ty.getElementType()); })
134134
.Case<LLVM::LLVMPointerType>([&](auto Ty) {
135135
const Type ElemType = Ty.getElementType();
136-
return (!ElemType.isa<LLVM::LLVMStructType>())
136+
return (!isa<LLVM::LLVMStructType>(ElemType))
137137
? emitOpError(
138138
"Expecting pointer to struct return type. Got ")
139139
<< ResultType

mlir-sycl/lib/Dialect/IR/SYCLOpsTypes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ mlir::sycl::VecType::verify(llvm::function_ref<InFlightDiagnostic()> EmitError,
220220
}
221221

222222
unsigned mlir::sycl::getDimensions(mlir::Type Type) {
223-
if (auto MemRefTy = Type.dyn_cast<mlir::MemRefType>())
223+
if (auto MemRefTy = dyn_cast<mlir::MemRefType>(Type))
224224
Type = MemRefTy.getElementType();
225225
return TypeSwitch<mlir::Type, unsigned>(Type)
226226
.Case<AccessorType, GroupType, IDType, ItemType, NdItemType, NdRangeType,

mlir-sycl/lib/Dialect/IR/SYCLTraits.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ mlir::LogicalResult mlir::sycl::verifySYCLGetIDTrait(Operation *OpPtr) {
115115
const bool IsSizeTCast = FuncName == "operator unsigned long";
116116
const bool IsSubscript = FuncName == "operator[]";
117117
const mlir::Type RetTy = Op->getResult(0).getType();
118-
const bool IsRetScalar = RetTy.isa<mlir::sycl::IDType>();
118+
const bool IsRetScalar = isa<mlir::sycl::IDType>(RetTy);
119119
// operator size_t cannot be checked the generic way.
120120
if (FuncName != "operator unsigned long") {
121121
const LogicalResult GenericVerification =
@@ -171,7 +171,7 @@ mlir::LogicalResult mlir::sycl::verifySYCLGetGroupTrait(Operation *Op) {
171171
static LogicalResult verifyIndexSpaceTrait(Operation *Op) {
172172
const auto Ty = Op->getResultTypes();
173173
assert(Ty.size() == 1 && "Expecting a single return value");
174-
const auto IsIndex = Ty[0].isa<IndexType>();
174+
const auto IsIndex = isa<IndexType>(Ty[0]);
175175
switch (Op->getNumOperands()) {
176176
case 0:
177177
return !IsIndex ? success()

mlir-sycl/lib/Transforms/Utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ static Value adaptArgumentForSYCLCall(OpBuilder &rewriter, Location loc,
3030
if (original.getType() == targetType)
3131
return original;
3232

33-
const auto mt = targetType.cast<MemRefType>();
34-
const auto thisType = original.getType().cast<MemRefType>();
33+
const auto mt = cast<MemRefType>(targetType);
34+
const auto thisType = cast<MemRefType>(original.getType());
3535
const llvm::ArrayRef<int64_t> targetShape = mt.getShape();
3636
const Type targetElementType = mt.getElementType();
3737
const unsigned targetMemSpace = mt.getMemorySpaceAsInt();

0 commit comments

Comments
 (0)