Skip to content

Commit

Permalink
[clang][SVE] Rename isVLSTBuiltinType, NFC
Browse files Browse the repository at this point in the history
Since we also have VLST for rvv now, it is not clear to keep using `isVLSTBuiltinType`, so I added prefix SVE to it.

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D158045
  • Loading branch information
jacquesguan committed Aug 17, 2023
1 parent 4c89277 commit 28741a2
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
/// Determines if this is a sizeless type supported by the
/// 'arm_sve_vector_bits' type attribute, which can be applied to a single
/// SVE vector or predicate, excluding tuple types such as svint32x4_t.
bool isVLSTBuiltinType() const;
bool isSveVLSBuiltinType() const;

/// Returns the representative type for the element of an SVE builtin type.
/// This is used to represent fixed-length SVE vectors created with the
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9461,7 +9461,7 @@ bool ASTContext::areCompatibleVectorTypes(QualType FirstVec,

/// getSVETypeSize - Return SVE vector or predicate register size.
static uint64_t getSVETypeSize(ASTContext &Context, const BuiltinType *Ty) {
assert(Ty->isVLSTBuiltinType() && "Invalid SVE Type");
assert(Ty->isSveVLSBuiltinType() && "Invalid SVE Type");
if (Ty->getKind() == BuiltinType::SveBool ||
Ty->getKind() == BuiltinType::SveCount)
return (Context.getLangOpts().VScaleMin * 128) / Context.getCharWidth();
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8572,7 +8572,7 @@ bool LValueExprEvaluator::VisitMemberExpr(const MemberExpr *E) {
bool LValueExprEvaluator::VisitArraySubscriptExpr(const ArraySubscriptExpr *E) {
// FIXME: Deal with vectors as array subscript bases.
if (E->getBase()->getType()->isVectorType() ||
E->getBase()->getType()->isVLSTBuiltinType())
E->getBase()->getType()->isSveVLSBuiltinType())
return Error(E);

APSInt Index;
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1962,7 +1962,7 @@ bool Type::hasAutoForTrailingReturnType() const {
bool Type::hasIntegerRepresentation() const {
if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
return VT->getElementType()->isIntegerType();
if (CanonicalType->isVLSTBuiltinType()) {
if (CanonicalType->isSveVLSBuiltinType()) {
const auto *VT = cast<BuiltinType>(CanonicalType);
return VT->getKind() == BuiltinType::SveBool ||
(VT->getKind() >= BuiltinType::SveInt8 &&
Expand Down Expand Up @@ -2179,7 +2179,7 @@ bool Type::hasUnsignedIntegerRepresentation() const {
return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
if (const auto *VT = dyn_cast<MatrixType>(CanonicalType))
return VT->getElementType()->isUnsignedIntegerOrEnumerationType();
if (CanonicalType->isVLSTBuiltinType()) {
if (CanonicalType->isSveVLSBuiltinType()) {
const auto *VT = cast<BuiltinType>(CanonicalType);
return VT->getKind() >= BuiltinType::SveUint8 &&
VT->getKind() <= BuiltinType::SveUint64;
Expand Down Expand Up @@ -2433,7 +2433,7 @@ bool Type::isRVVSizelessBuiltinType() const {
return false;
}

bool Type::isVLSTBuiltinType() const {
bool Type::isSveVLSBuiltinType() const {
if (const BuiltinType *BT = getAs<BuiltinType>()) {
switch (BT->getKind()) {
case BuiltinType::SveInt8:
Expand All @@ -2460,7 +2460,7 @@ bool Type::isVLSTBuiltinType() const {
}

QualType Type::getSveEltType(const ASTContext &Ctx) const {
assert(isVLSTBuiltinType() && "unsupported type!");
assert(isSveVLSBuiltinType() && "unsupported type!");

const BuiltinType *BTy = castAs<BuiltinType>();
if (BTy->getKind() == BuiltinType::SveBool)
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,7 @@ Value *ScalarExprEmitter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
// careful, because the base of a vector subscript is occasionally an rvalue,
// so we can't get it as an lvalue.
if (!E->getBase()->getType()->isVectorType() &&
!E->getBase()->getType()->isVLSTBuiltinType())
!E->getBase()->getType()->isSveVLSBuiltinType())
return EmitLoadOfLValue(E);

// Handle the vector case. The base must be a vector, the index must be an
Expand Down Expand Up @@ -4858,7 +4858,7 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
}

if (condExpr->getType()->isVectorType() ||
condExpr->getType()->isVLSTBuiltinType()) {
condExpr->getType()->isSveVLSBuiltinType()) {
CGF.incrementProfileCounter(E);

llvm::Value *CondV = CGF.EmitScalarExpr(condExpr);
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14827,7 +14827,7 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,

// Strip vector types.
if (isa<VectorType>(Source)) {
if (Target->isVLSTBuiltinType() &&
if (Target->isSveVLSBuiltinType() &&
(S.Context.areCompatibleSveTypes(QualType(Target, 0),
QualType(Source, 0)) ||
S.Context.areLaxCompatibleSveTypes(QualType(Target, 0),
Expand Down Expand Up @@ -14878,7 +14878,7 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
const BuiltinType *TargetBT = dyn_cast<BuiltinType>(Target);

// Strip SVE vector types
if (SourceBT && SourceBT->isVLSTBuiltinType()) {
if (SourceBT && SourceBT->isSveVLSBuiltinType()) {
// Need the original target type for vector type checks
const Type *OriginalTarget = S.Context.getCanonicalType(T).getTypePtr();
// Handle conversion from scalable to fixed when msve-vector-bits is
Expand All @@ -14897,7 +14897,7 @@ static void CheckImplicitConversion(Sema &S, Expr *E, QualType T,
Source = SourceBT->getSveEltType(S.Context).getTypePtr();
}

if (TargetBT && TargetBT->isVLSTBuiltinType())
if (TargetBT && TargetBT->isSveVLSBuiltinType())
Target = TargetBT->getSveEltType(S.Context).getTypePtr();

// If the source is floating point...
Expand Down
66 changes: 33 additions & 33 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5945,7 +5945,7 @@ Sema::CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc,
if (Combined != MemberQuals)
ResultType = Context.getQualifiedType(ResultType, Combined);
} else if (LHSTy->isBuiltinType() &&
LHSTy->getAs<BuiltinType>()->isVLSTBuiltinType()) {
LHSTy->getAs<BuiltinType>()->isSveVLSBuiltinType()) {
const BuiltinType *BTy = LHSTy->getAs<BuiltinType>();
if (BTy->isSVEBool())
return ExprError(Diag(LLoc, diag::err_subscript_svbool_t)
Expand Down Expand Up @@ -10934,7 +10934,7 @@ static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar,
assert(!isa<ExtVectorType>(VT) &&
"ExtVectorTypes should not be handled here!");
VectorEltTy = VT->getElementType();
} else if (VectorTy->isVLSTBuiltinType()) {
} else if (VectorTy->isSveVLSBuiltinType()) {
VectorEltTy =
VectorTy->castAs<BuiltinType>()->getSveEltType(S.getASTContext());
} else {
Expand Down Expand Up @@ -11297,25 +11297,25 @@ QualType Sema::CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS,
if (Context.hasSameType(LHSType, RHSType))
return LHSType;

if (LHSType->isVLSTBuiltinType() && !RHSType->isVLSTBuiltinType()) {
if (LHSType->isSveVLSBuiltinType() && !RHSType->isSveVLSBuiltinType()) {
if (!tryGCCVectorConvertAndSplat(*this, &RHS, &LHS))
return LHSType;
}
if (RHSType->isVLSTBuiltinType() && !LHSType->isVLSTBuiltinType()) {
if (RHSType->isSveVLSBuiltinType() && !LHSType->isSveVLSBuiltinType()) {
if (LHS.get()->isLValue() ||
!tryGCCVectorConvertAndSplat(*this, &LHS, &RHS))
return RHSType;
}

if ((!LHSType->isVLSTBuiltinType() && !LHSType->isRealType()) ||
(!RHSType->isVLSTBuiltinType() && !RHSType->isRealType())) {
if ((!LHSType->isSveVLSBuiltinType() && !LHSType->isRealType()) ||
(!RHSType->isSveVLSBuiltinType() && !RHSType->isRealType())) {
Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
<< LHSType << RHSType << LHS.get()->getSourceRange()
<< RHS.get()->getSourceRange();
return QualType();
}

if (LHSType->isVLSTBuiltinType() && RHSType->isVLSTBuiltinType() &&
if (LHSType->isSveVLSBuiltinType() && RHSType->isSveVLSBuiltinType() &&
Context.getBuiltinVectorTypeInfo(LHSBuiltinTy).EC !=
Context.getBuiltinVectorTypeInfo(RHSBuiltinTy).EC) {
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
Expand All @@ -11324,11 +11324,11 @@ QualType Sema::CheckSizelessVectorOperands(ExprResult &LHS, ExprResult &RHS,
return QualType();
}

if (LHSType->isVLSTBuiltinType() || RHSType->isVLSTBuiltinType()) {
QualType Scalar = LHSType->isVLSTBuiltinType() ? RHSType : LHSType;
QualType Vector = LHSType->isVLSTBuiltinType() ? LHSType : RHSType;
if (LHSType->isSveVLSBuiltinType() || RHSType->isSveVLSBuiltinType()) {
QualType Scalar = LHSType->isSveVLSBuiltinType() ? RHSType : LHSType;
QualType Vector = LHSType->isSveVLSBuiltinType() ? LHSType : RHSType;
bool ScalarOrVector =
LHSType->isVLSTBuiltinType() && RHSType->isVLSTBuiltinType();
LHSType->isSveVLSBuiltinType() && RHSType->isSveVLSBuiltinType();

Diag(Loc, diag::err_typecheck_vector_not_convertable_implict_truncation)
<< ScalarOrVector << Scalar << Vector;
Expand Down Expand Up @@ -11454,7 +11454,7 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS,
/*AllowBoolConversions*/ false,
/*AllowBooleanOperation*/ false,
/*ReportInvalid*/ true);
if (LHSTy->isVLSTBuiltinType() || RHSTy->isVLSTBuiltinType())
if (LHSTy->isSveVLSBuiltinType() || RHSTy->isSveVLSBuiltinType())
return CheckSizelessVectorOperands(LHS, RHS, Loc, IsCompAssign,
ACK_Arithmetic);
if (!IsDiv &&
Expand Down Expand Up @@ -11496,8 +11496,8 @@ QualType Sema::CheckRemainderOperands(
return InvalidOperands(Loc, LHS, RHS);
}

if (LHS.get()->getType()->isVLSTBuiltinType() ||
RHS.get()->getType()->isVLSTBuiltinType()) {
if (LHS.get()->getType()->isSveVLSBuiltinType() ||
RHS.get()->getType()->isSveVLSBuiltinType()) {
if (LHS.get()->getType()->hasIntegerRepresentation() &&
RHS.get()->getType()->hasIntegerRepresentation())
return CheckSizelessVectorOperands(LHS, RHS, Loc, IsCompAssign,
Expand Down Expand Up @@ -11815,8 +11815,8 @@ QualType Sema::CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS,
return compType;
}

if (LHS.get()->getType()->isVLSTBuiltinType() ||
RHS.get()->getType()->isVLSTBuiltinType()) {
if (LHS.get()->getType()->isSveVLSBuiltinType() ||
RHS.get()->getType()->isSveVLSBuiltinType()) {
QualType compType =
CheckSizelessVectorOperands(LHS, RHS, Loc, CompLHSTy, ACK_Arithmetic);
if (CompLHSTy)
Expand Down Expand Up @@ -11930,8 +11930,8 @@ QualType Sema::CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS,
return compType;
}

if (LHS.get()->getType()->isVLSTBuiltinType() ||
RHS.get()->getType()->isVLSTBuiltinType()) {
if (LHS.get()->getType()->isSveVLSBuiltinType() ||
RHS.get()->getType()->isSveVLSBuiltinType()) {
QualType compType =
CheckSizelessVectorOperands(LHS, RHS, Loc, CompLHSTy, ACK_Arithmetic);
if (CompLHSTy)
Expand Down Expand Up @@ -12270,14 +12270,14 @@ static QualType checkSizelessVectorShift(Sema &S, ExprResult &LHS,

QualType LHSType = LHS.get()->getType();
const BuiltinType *LHSBuiltinTy = LHSType->castAs<BuiltinType>();
QualType LHSEleType = LHSType->isVLSTBuiltinType()
QualType LHSEleType = LHSType->isSveVLSBuiltinType()
? LHSBuiltinTy->getSveEltType(S.getASTContext())
: LHSType;

// Note that RHS might not be a vector
QualType RHSType = RHS.get()->getType();
const BuiltinType *RHSBuiltinTy = RHSType->castAs<BuiltinType>();
QualType RHSEleType = RHSType->isVLSTBuiltinType()
QualType RHSEleType = RHSType->isSveVLSBuiltinType()
? RHSBuiltinTy->getSveEltType(S.getASTContext())
: RHSType;

Expand All @@ -12300,7 +12300,7 @@ static QualType checkSizelessVectorShift(Sema &S, ExprResult &LHS,
return QualType();
}

if (LHSType->isVLSTBuiltinType() && RHSType->isVLSTBuiltinType() &&
if (LHSType->isSveVLSBuiltinType() && RHSType->isSveVLSBuiltinType() &&
(S.Context.getBuiltinVectorTypeInfo(LHSBuiltinTy).EC !=
S.Context.getBuiltinVectorTypeInfo(RHSBuiltinTy).EC)) {
S.Diag(Loc, diag::err_typecheck_invalid_operands)
Expand All @@ -12309,8 +12309,8 @@ static QualType checkSizelessVectorShift(Sema &S, ExprResult &LHS,
return QualType();
}

if (!LHSType->isVLSTBuiltinType()) {
assert(RHSType->isVLSTBuiltinType());
if (!LHSType->isSveVLSBuiltinType()) {
assert(RHSType->isSveVLSBuiltinType());
if (IsCompAssign)
return RHSType;
if (LHSEleType != RHSEleType) {
Expand All @@ -12323,7 +12323,7 @@ static QualType checkSizelessVectorShift(Sema &S, ExprResult &LHS,
S.Context.getScalableVectorType(LHSEleType, VecSize.getKnownMinValue());
LHS = S.ImpCastExprToType(LHS.get(), VecTy, clang::CK_VectorSplat);
LHSType = VecTy;
} else if (RHSBuiltinTy && RHSBuiltinTy->isVLSTBuiltinType()) {
} else if (RHSBuiltinTy && RHSBuiltinTy->isSveVLSBuiltinType()) {
if (S.Context.getTypeSize(RHSBuiltinTy) !=
S.Context.getTypeSize(LHSBuiltinTy)) {
S.Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
Expand Down Expand Up @@ -12369,8 +12369,8 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS,
return checkVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
}

if (LHS.get()->getType()->isVLSTBuiltinType() ||
RHS.get()->getType()->isVLSTBuiltinType())
if (LHS.get()->getType()->isSveVLSBuiltinType() ||
RHS.get()->getType()->isSveVLSBuiltinType())
return checkSizelessVectorShift(*this, LHS, RHS, Loc, IsCompAssign);

// Shifts don't perform usual arithmetic conversions, they just do integer
Expand Down Expand Up @@ -13059,8 +13059,8 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
RHS.get()->getType()->isVectorType())
return CheckVectorCompareOperands(LHS, RHS, Loc, Opc);

if (LHS.get()->getType()->isVLSTBuiltinType() ||
RHS.get()->getType()->isVLSTBuiltinType())
if (LHS.get()->getType()->isSveVLSBuiltinType() ||
RHS.get()->getType()->isSveVLSBuiltinType())
return CheckSizelessVectorCompareOperands(LHS, RHS, Loc, Opc);

diagnoseLogicalNotOnLHSofCheck(*this, LHS, RHS, Loc, Opc);
Expand Down Expand Up @@ -13935,17 +13935,17 @@ inline QualType Sema::CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS,
return InvalidOperands(Loc, LHS, RHS);
}

if (LHS.get()->getType()->isVLSTBuiltinType() ||
RHS.get()->getType()->isVLSTBuiltinType()) {
if (LHS.get()->getType()->isSveVLSBuiltinType() ||
RHS.get()->getType()->isSveVLSBuiltinType()) {
if (LHS.get()->getType()->hasIntegerRepresentation() &&
RHS.get()->getType()->hasIntegerRepresentation())
return CheckSizelessVectorOperands(LHS, RHS, Loc, IsCompAssign,
ACK_BitwiseOp);
return InvalidOperands(Loc, LHS, RHS);
}

if (LHS.get()->getType()->isVLSTBuiltinType() ||
RHS.get()->getType()->isVLSTBuiltinType()) {
if (LHS.get()->getType()->isSveVLSBuiltinType() ||
RHS.get()->getType()->isSveVLSBuiltinType()) {
if (LHS.get()->getType()->hasIntegerRepresentation() &&
RHS.get()->getType()->hasIntegerRepresentation())
return CheckSizelessVectorOperands(LHS, RHS, Loc, IsCompAssign,
Expand Down Expand Up @@ -16309,7 +16309,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
resultType->castAs<VectorType>()->getVectorKind() !=
VectorType::AltiVecBool))
break;
else if (resultType->isVLSTBuiltinType()) // SVE vectors allow + and -
else if (resultType->isSveVLSBuiltinType()) // SVE vectors allow + and -
break;
else if (getLangOpts().CPlusPlus && // C++ [expr.unary.op]p6
Opc == UO_Plus &&
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6305,7 +6305,7 @@ static bool isValidVectorForConditionalCondition(ASTContext &Ctx,

static bool isValidSizelessVectorForConditionalCondition(ASTContext &Ctx,
QualType CondTy) {
if (!CondTy->isVLSTBuiltinType())
if (!CondTy->isSveVLSBuiltinType())
return false;
const QualType EltTy =
cast<BuiltinType>(CondTy.getCanonicalType())->getSveEltType(Ctx);
Expand Down Expand Up @@ -6417,10 +6417,10 @@ QualType Sema::CheckSizelessVectorConditionalTypes(ExprResult &Cond,

QualType LHSType = LHS.get()->getType();
const auto *LHSBT =
LHSType->isVLSTBuiltinType() ? LHSType->getAs<BuiltinType>() : nullptr;
LHSType->isSveVLSBuiltinType() ? LHSType->getAs<BuiltinType>() : nullptr;
QualType RHSType = RHS.get()->getType();
const auto *RHSBT =
RHSType->isVLSTBuiltinType() ? RHSType->getAs<BuiltinType>() : nullptr;
RHSType->isSveVLSBuiltinType() ? RHSType->getAs<BuiltinType>() : nullptr;

QualType ResultType;

Expand Down Expand Up @@ -6462,7 +6462,7 @@ QualType Sema::CheckSizelessVectorConditionalTypes(ExprResult &Cond,
RHS = ImpCastExprToType(RHS.get(), ResultType, CK_VectorSplat);
}

assert(!ResultType.isNull() && ResultType->isVLSTBuiltinType() &&
assert(!ResultType.isNull() && ResultType->isSveVLSBuiltinType() &&
"Result should have been a vector type");
auto *ResultBuiltinTy = ResultType->castAs<BuiltinType>();
QualType ResultElementTy = ResultBuiltinTy->getSveEltType(Context);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8363,7 +8363,7 @@ static void HandleArmSveVectorBitsTypeAttr(QualType &CurType, ParsedAttr &Attr,
}

// Attribute can only be attached to a single SVE vector or predicate type.
if (!CurType->isVLSTBuiltinType()) {
if (!CurType->isSveVLSBuiltinType()) {
S.Diag(Attr.getLoc(), diag::err_attribute_invalid_sve_type)
<< Attr << CurType;
Attr.setInvalid();
Expand Down

0 comments on commit 28741a2

Please sign in to comment.