Skip to content

Commit

Permalink
Remove deprecated methods (isa, cast, and dyn_cast)
Browse files Browse the repository at this point in the history
  • Loading branch information
sitio-couto committed Jun 29, 2024
1 parent 302b790 commit 92b5444
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ bool classifyReturnType(const CIRCXXABI &CXXABI, LowerFunctionInfo &FI,
const ABIInfo &Info) {
Type Ty = FI.getReturnType();

if (const auto RT = Ty.dyn_cast<StructType>()) {
if (const auto RT = dyn_cast<StructType>(Ty)) {
llvm_unreachable("NYI");
}

return CXXABI.classifyReturnType(FI);
}

Type useFirstFieldIfTransparentUnion(Type Ty) {
if (auto RT = Ty.dyn_cast<StructType>()) {
if (auto RT = dyn_cast<StructType>(Ty)) {
if (RT.isUnion())
llvm_unreachable("NYI");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ clang::TypeInfo CIRLowerContext::getTypeInfoImpl(const Type T) const {
// TODO(cir): We should implement a better way to identify type kinds and use
// builting data layout interface for this.
auto typeKind = clang::Type::Builtin;
if (T.isa<IntType>()) {
if (isa<IntType>(T)) {
typeKind = clang::Type::Builtin;
} else {
llvm_unreachable("Unhandled type class");
Expand All @@ -66,7 +66,7 @@ clang::TypeInfo CIRLowerContext::getTypeInfoImpl(const Type T) const {
// current level of CIR.
switch (typeKind) {
case clang::Type::Builtin: {
if (auto intTy = T.dyn_cast<IntType>()) {
if (auto intTy = dyn_cast<IntType>(T)) {
// NOTE(cir): This assumes int types are already ABI-specific.
// FIXME(cir): Use data layout interface here instead.
Width = intTy.getWidth();
Expand Down Expand Up @@ -139,8 +139,8 @@ bool CIRLowerContext::isPromotableIntegerType(Type T) const {
// FIXME(cir): CIR does not distinguish between char, short, etc. So we just
// assume it is promotable if smaller than 32 bits. This is wrong since, for
// example, Char32 is promotable. Improve CIR or add an AST query here.
if (auto intTy = T.dyn_cast<IntType>()) {
return T.cast<IntType>().getWidth() < 32;
if (auto intTy = dyn_cast<IntType>(T)) {
return cast<IntType>(T).getWidth() < 32;
}

// Enumerated types are promotable to their compatible integer types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ItaniumCXXABI : public CIRCXXABI {
} // namespace

bool ItaniumCXXABI::classifyReturnType(LowerFunctionInfo &FI) const {
const StructType RD = FI.getReturnType().dyn_cast<StructType>();
const StructType RD = dyn_cast<StructType>(FI.getReturnType());
if (!RD)
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ LowerFunction::buildFunctionProlog(const LowerFunctionInfo &FI, FuncOp Fn,
// Prepare parameter attributes. So far, only attributes for pointer
// parameters are prepared. See
// http://llvm.org/docs/LangRef.html#paramattrs.
if (ArgI.getDirectOffset() == 0 && LTy.isa<PointerType>() &&
ArgI.getCoerceToType().isa<PointerType>()) {
if (ArgI.getDirectOffset() == 0 && isa<PointerType>(LTy) &&
isa<PointerType>(ArgI.getCoerceToType())) {
llvm_unreachable("NYI");
}

Expand Down Expand Up @@ -413,7 +413,7 @@ Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo,
// NOTE(cir): While booleans are lowered directly as `i1`s in the
// original codegen, in CIR they require a trivial bitcast. This is
// handled here.
if (info_it->type.isa<BoolType>()) {
if (isa<BoolType>(info_it->type)) {
IRCallArgs[FirstIRArg] =
createBitcast(*I, ArgInfo.getCoerceToType(), *this);
break;
Expand All @@ -424,7 +424,7 @@ Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo,
ArgInfo.getDirectOffset() == 0) {
assert(NumIRArgs == 1);
Value V;
if (!I->getType().isa<StructType>()) {
if (isa<StructType>(!I->getType())) {
V = *I;
} else {
llvm_unreachable("NYI");
Expand All @@ -435,7 +435,7 @@ Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo,
}

if (ArgInfo.getCoerceToType() != V.getType() &&
V.getType().isa<IntType>())
isa<IntType>(V.getType()))
llvm_unreachable("NYI");

if (FirstIRArg < IRFuncTy.getNumInputs() &&
Expand Down Expand Up @@ -517,7 +517,7 @@ Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo,
// NOTE(cir): While booleans are lowered directly as `i1`s in the
// original codegen, in CIR they require a trivial bitcast. This is
// handled here.
assert(!RetTy.isa<BoolType>());
assert(!isa<BoolType>(RetTy));

Type RetIRTy = RetTy;
if (RetAI.getCoerceToType() == RetIRTy && RetAI.getDirectOffset() == 0) {
Expand Down Expand Up @@ -553,7 +553,7 @@ Value LowerFunction::rewriteCallOp(const LowerFunctionInfo &CallInfo,
// NOTE(cir): This method has partial parity to CodeGenFunction's
// GetUndefRValue defined in CGExpr.cpp.
Value LowerFunction::getUndefRValue(Type Ty) {
if (Ty.isa<VoidType>())
if (isa<VoidType>(Ty))
return nullptr;

llvm::outs() << "Missing undef handler for value type: " << Ty << "\n";
Expand All @@ -562,9 +562,9 @@ Value LowerFunction::getUndefRValue(Type Ty) {

::cir::TypeEvaluationKind LowerFunction::getEvaluationKind(Type type) {
// FIXME(cir): Implement type classes for CIR types.
if (type.isa<StructType>())
if (isa<StructType>(type))
return ::cir::TypeEvaluationKind::TEK_Aggregate;
if (type.isa<IntType, SingleType, DoubleType>())
if (isa<IntType, SingleType, DoubleType>(type))
return ::cir::TypeEvaluationKind::TEK_Scalar;
llvm_unreachable("NYI");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ mlir::Type LowerTypes::convertType(Type T) {
/// keeping it here for parity's sake.

// Certain CIR types are already ABI-specific, so we just return them.
if (T.isa<IntType>()) {
if (isa<IntType>(T)) {
return T;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class AArch64TargetLoweringInfo : public TargetLoweringInfo {

ABIArgInfo AArch64ABIInfo::classifyReturnType(Type RetTy,
bool IsVariadic) const {
if (RetTy.isa<VoidType>())
if (isa<VoidType>(RetTy))
return ABIArgInfo::getIgnore();

llvm_unreachable("NYI");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ mlir::Value LoweringPrepareAArch64CXXABI::lowerAAPCSVAArg(
auto opResTy = op.getType();
// front end should not produce non-scalar type of VAArgOp
bool isSupportedType =
opResTy.isa<mlir::cir::IntType, mlir::cir::SingleType,
mlir::cir::PointerType, mlir::cir::BoolType,
mlir::cir::DoubleType, mlir::cir::ArrayType>();
isa<mlir::cir::IntType, mlir::cir::SingleType, mlir::cir::PointerType,
mlir::cir::BoolType, mlir::cir::DoubleType, mlir::cir::ArrayType>(
opResTy);

// Homogenous Aggregate type not supported and indirect arg
// passing not supported yet. And for these supported types,
Expand All @@ -82,7 +82,7 @@ mlir::Value LoweringPrepareAArch64CXXABI::lowerAAPCSVAArg(
// but it depends on arg type indirectness and coercion defined by ABI.
auto baseTy = opResTy;

if (baseTy.isa<mlir::cir::ArrayType>()) {
if (isa<mlir::cir::ArrayType>(baseTy)) {
llvm_unreachable("ArrayType VAArg loweing NYI");
}
// numRegs may not be 1 if ArrayType is supported.
Expand Down Expand Up @@ -340,7 +340,7 @@ mlir::Value LoweringPrepareAArch64CXXABI::lowerAAPCSVAArg(
builder.setInsertionPoint(op);
contBlock->addArgument(onStackPtr.getType(), loc);
auto resP = contBlock->getArgument(0);
assert(resP.getType().isa<mlir::cir::PointerType>());
assert(isa<mlir::cir::PointerType>(resP.getType()));
auto opResPTy = mlir::cir::PointerType::get(builder.getContext(), opResTy);
auto castResP = builder.createBitcast(resP, opResPTy);
auto res = builder.create<mlir::cir::LoadOp>(loc, castResP);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static mlir::Value buildDynamicCastAfterNullCheck(CIRBaseBuilderTy &builder,
dynCastFuncArgs)
.getResult();

assert(castedPtr.getType().isa<mlir::cir::PointerType>() &&
assert(isa<mlir::cir::PointerType>(castedPtr.getType()) &&
"the return value of __dynamic_cast should be a ptr");

/// C++ [expr.dynamic.cast]p9:
Expand Down
14 changes: 7 additions & 7 deletions clang/lib/CIR/Dialect/Transforms/TargetLowering/Targets/X86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,15 @@ void X86_64ABIInfo::classify(Type Ty, uint64_t OffsetBase, Class &Lo, Class &Hi,
// FIXME(cir): There's currently no direct way to identify if a type is a
// builtin.
if (/*isBuitinType=*/true) {
if (Ty.isa<VoidType>()) {
if (isa<VoidType>(Ty)) {
Current = Class::NoClass;
} else if (Ty.isa<IntType>()) {
} else if (isa<IntType>(Ty)) {

// FIXME(cir): Clang's BuiltinType::Kind allow comparisons (GT, LT, etc).
// We should implement this in CIR to simplify the conditions below. BTW,
// I'm not sure if the comparisons below are truly equivalent to the ones
// in Clang.
if (Ty.isa<IntType>()) {
if (isa<IntType>(Ty)) {
Current = Class::Integer;
}
return;
Expand Down Expand Up @@ -226,12 +226,12 @@ ::cir::ABIArgInfo X86_64ABIInfo::classifyReturnType(Type RetTy) const {

// If we have a sign or zero extended integer, make sure to return Extend
// so that the parameter gets the right LLVM IR attributes.
if (Hi == Class::NoClass && resType.isa<IntType>()) {
if (Hi == Class::NoClass && isa<IntType>(resType)) {
// NOTE(cir): We skip enum types handling here since CIR represents
// enums directly as their unerlying integer types. NOTE(cir): For some
// reason, Clang does not set the coerce type here and delays it to
// arrangeLLVMFunctionInfo. We do the same to keep parity.
if (RetTy.isa<IntType>() && isPromotableIntegerTypeForABI(RetTy))
if (isa<IntType>(RetTy) && isPromotableIntegerTypeForABI(RetTy))
return ABIArgInfo::getExtend(RetTy);
}
break;
Expand Down Expand Up @@ -291,12 +291,12 @@ ABIArgInfo X86_64ABIInfo::classifyArgumentType(Type Ty, unsigned freeIntRegs,

// If we have a sign or zero extended integer, make sure to return Extend
// so that the parameter gets the right LLVM IR attributes.
if (Hi == Class::NoClass && ResType.isa<IntType>()) {
if (Hi == Class::NoClass && isa<IntType>(ResType)) {
// NOTE(cir): We skip enum types handling here since CIR represents
// enums directly as their unerlying integer types. NOTE(cir): For some
// reason, Clang does not set the coerce type here and delays it to
// arrangeLLVMFunctionInfo. We do the same to keep parity.
if (Ty.isa<IntType, BoolType>() && isPromotableIntegerTypeForABI(Ty))
if (isa<IntType, BoolType>(Ty) && isPromotableIntegerTypeForABI(Ty))
return ABIArgInfo::getExtend(Ty);
}

Expand Down

0 comments on commit 92b5444

Please sign in to comment.