Skip to content

Commit b42e43e

Browse files
committed
[CIR][NFC] Use free function form of cast isa and dyn_cast
1 parent 95dae0d commit b42e43e

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

clang/lib/CIR/CodeGen/CIRGenBuilder.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,7 @@ class CIRGenBuilderTy : public CIRBaseBuilderTy {
799799
mlir::cir::VecShuffleOp
800800
createVecShuffle(mlir::Location loc, mlir::Value vec1, mlir::Value vec2,
801801
llvm::ArrayRef<mlir::Attribute> maskAttrs) {
802-
auto vecType = vec1.getType().cast<mlir::cir::VectorType>();
802+
auto vecType = mlir::cast<mlir::cir::VectorType>(vec1.getType());
803803
auto resultTy = mlir::cir::VectorType::get(
804804
getContext(), vecType.getEltType(), maskAttrs.size());
805805
return CIRBaseBuilderTy::create<mlir::cir::VecShuffleOp>(

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ RValue CIRGenFunction::buildLoadOfLValue(LValue LV, SourceLocation Loc) {
662662

663663
int64_t CIRGenFunction::getAccessedFieldNo(unsigned int idx,
664664
const mlir::ArrayAttr elts) {
665-
auto elt = elts.cast<mlir::ArrayAttr>()[idx].dyn_cast<mlir::IntegerAttr>();
665+
auto elt = mlir::dyn_cast<mlir::IntegerAttr>(elts[idx]);
666666
assert(elt && "The indices should be integer attributes");
667667
return elt.getInt();
668668
}
@@ -675,7 +675,7 @@ RValue CIRGenFunction::buildLoadOfExtVectorElementLValue(LValue LV) {
675675

676676
// HLSL allows treating scalars as one-element vectors. Converting the scalar
677677
// IR value to a vector here allows the rest of codegen to behave as normal.
678-
if (getLangOpts().HLSL && !Vec.getType().isa<mlir::cir::VectorType>()) {
678+
if (getLangOpts().HLSL && !mlir::isa<mlir::cir::VectorType>(Vec.getType())) {
679679
llvm_unreachable("HLSL NYI");
680680
}
681681

@@ -728,7 +728,7 @@ void CIRGenFunction::buildStoreThroughExtVectorComponentLValue(RValue Src,
728728
// To support this we need to handle the case where the destination address is
729729
// a scalar.
730730
Address DstAddr = Dst.getExtVectorAddress();
731-
if (!DstAddr.getElementType().isa<mlir::cir::VectorType>()) {
731+
if (!mlir::isa<mlir::cir::VectorType>(DstAddr.getElementType())) {
732732
llvm_unreachable("HLSL NYI");
733733
}
734734

clang/lib/CIR/CodeGen/CIRGenValue.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ class LValue {
328328
}
329329
mlir::ArrayAttr getExtVectorElts() const {
330330
assert(isExtVectorElt());
331-
return VectorElts.cast<mlir::ArrayAttr>();
331+
return mlir::cast<mlir::ArrayAttr>(VectorElts);
332332
}
333333

334334
static LValue MakeVectorElt(Address vecAddress, mlir::Value Index,

0 commit comments

Comments
 (0)