[clang][NFC] Refactor VectorType::VectorKind

This patch moves `VectorKind` to namespace scope, and make it complete at the point its bit-field is declared. It also converts it to a scoped enum.
This commit is contained in:
Vlad Serebrennikov 2023-10-31 21:48:42 +03:00
parent 1344b65c90
commit ae7b20b583
23 changed files with 231 additions and 244 deletions

View File

@ -1493,12 +1493,12 @@ public:
///
/// \pre \p VectorType must be a built-in type.
QualType getVectorType(QualType VectorType, unsigned NumElts,
VectorType::VectorKind VecKind) const;
VectorKind VecKind) const;
/// Return the unique reference to the type for a dependently sized vector of
/// the specified element type.
QualType getDependentVectorType(QualType VectorType, Expr *SizeExpr,
SourceLocation AttrLoc,
VectorType::VectorKind VecKind) const;
VectorKind VecKind) const;
/// Return the unique reference to an extended vector type
/// of the specified element type and size.

View File

@ -142,7 +142,7 @@ def TypeOfKind : EnumPropertyType<"TypeOfKind">;
def UInt32 : CountPropertyType<"uint32_t">;
def UInt64 : CountPropertyType<"uint64_t">;
def UnaryTypeTransformKind : EnumPropertyType<"UnaryTransformType::UTTKind">;
def VectorKind : EnumPropertyType<"VectorType::VectorKind">;
def VectorKind : EnumPropertyType<"VectorKind">;
def ExceptionSpecInfo : PropertyType<"FunctionProtoType::ExceptionSpecInfo"> {
let BufferElementTypes = [ QualType ];

View File

@ -1601,6 +1601,35 @@ enum class ElaboratedTypeKeyword {
None
};
enum class VectorKind {
/// not a target-specific vector type
Generic,
/// is AltiVec vector
AltiVecVector,
/// is AltiVec 'vector Pixel'
AltiVecPixel,
/// is AltiVec 'vector bool ...'
AltiVecBool,
/// is ARM Neon vector
Neon,
/// is ARM Neon polynomial vector
NeonPoly,
/// is AArch64 SVE fixed-length data vector
SveFixedLengthData,
/// is AArch64 SVE fixed-length predicate vector
SveFixedLengthPredicate,
/// is RISC-V RVV fixed-length data vector
RVVFixedLengthData,
};
/// The base class of the type hierarchy.
///
/// A central concept with types is that each type always has a canonical
@ -3452,36 +3481,6 @@ public:
/// Since the constructor takes the number of vector elements, the
/// client is responsible for converting the size into the number of elements.
class VectorType : public Type, public llvm::FoldingSetNode {
public:
enum VectorKind {
/// not a target-specific vector type
GenericVector,
/// is AltiVec vector
AltiVecVector,
/// is AltiVec 'vector Pixel'
AltiVecPixel,
/// is AltiVec 'vector bool ...'
AltiVecBool,
/// is ARM Neon vector
NeonVector,
/// is ARM Neon polynomial vector
NeonPolyVector,
/// is AArch64 SVE fixed-length data vector
SveFixedLengthDataVector,
/// is AArch64 SVE fixed-length predicate vector
SveFixedLengthPredicateVector,
/// is RISC-V RVV fixed-length data vector
RVVFixedLengthDataVector,
};
protected:
friend class ASTContext; // ASTContext creates these.
@ -3516,7 +3515,7 @@ public:
ID.AddPointer(ElementType.getAsOpaquePtr());
ID.AddInteger(NumElements);
ID.AddInteger(TypeClass);
ID.AddInteger(VecKind);
ID.AddInteger(llvm::to_underlying(VecKind));
}
static bool classof(const Type *T) {
@ -3541,14 +3540,14 @@ class DependentVectorType : public Type, public llvm::FoldingSetNode {
SourceLocation Loc;
DependentVectorType(QualType ElementType, QualType CanonType, Expr *SizeExpr,
SourceLocation Loc, VectorType::VectorKind vecKind);
SourceLocation Loc, VectorKind vecKind);
public:
Expr *getSizeExpr() const { return SizeExpr; }
QualType getElementType() const { return ElementType; }
SourceLocation getAttributeLoc() const { return Loc; }
VectorType::VectorKind getVectorKind() const {
return VectorType::VectorKind(VectorTypeBits.VecKind);
VectorKind getVectorKind() const {
return VectorKind(VectorTypeBits.VecKind);
}
bool isSugared() const { return false; }
@ -3564,7 +3563,7 @@ public:
static void Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context,
QualType ElementType, const Expr *SizeExpr,
VectorType::VectorKind VecKind);
VectorKind VecKind);
};
/// ExtVectorType - Extended vector type. This type is created using
@ -3577,7 +3576,8 @@ class ExtVectorType : public VectorType {
friend class ASTContext; // ASTContext creates these.
ExtVectorType(QualType vecType, unsigned nElements, QualType canonType)
: VectorType(ExtVector, vecType, nElements, canonType, GenericVector) {}
: VectorType(ExtVector, vecType, nElements, canonType,
VectorKind::Generic) {}
public:
static int getPointAccessorIdx(char c) {

View File

@ -1935,14 +1935,14 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
uint64_t TargetVectorAlign = Target->getMaxVectorAlign();
if (TargetVectorAlign && TargetVectorAlign < Align)
Align = TargetVectorAlign;
if (VT->getVectorKind() == VectorType::SveFixedLengthDataVector)
if (VT->getVectorKind() == VectorKind::SveFixedLengthData)
// Adjust the alignment for fixed-length SVE vectors. This is important
// for non-power-of-2 vector lengths.
Align = 128;
else if (VT->getVectorKind() == VectorType::SveFixedLengthPredicateVector)
else if (VT->getVectorKind() == VectorKind::SveFixedLengthPredicate)
// Adjust the alignment for fixed-length SVE predicates.
Align = 16;
else if (VT->getVectorKind() == VectorType::RVVFixedLengthDataVector)
else if (VT->getVectorKind() == VectorKind::RVVFixedLengthData)
// Adjust the alignment for fixed-length RVV vectors.
Align = std::min<unsigned>(64, Width);
break;
@ -4004,7 +4004,7 @@ QualType ASTContext::getScalableVectorType(QualType EltTy, unsigned NumElts,
/// getVectorType - Return the unique reference to a vector type of
/// the specified element type and size. VectorType must be a built-in type.
QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts,
VectorType::VectorKind VecKind) const {
VectorKind VecKind) const {
assert(vecType->isBuiltinType() ||
(vecType->isBitIntType() &&
// Only support _BitInt elements with byte-sized power of 2 NumBits.
@ -4036,10 +4036,9 @@ QualType ASTContext::getVectorType(QualType vecType, unsigned NumElts,
return QualType(New, 0);
}
QualType
ASTContext::getDependentVectorType(QualType VecType, Expr *SizeExpr,
SourceLocation AttrLoc,
VectorType::VectorKind VecKind) const {
QualType ASTContext::getDependentVectorType(QualType VecType, Expr *SizeExpr,
SourceLocation AttrLoc,
VectorKind VecKind) const {
llvm::FoldingSetNodeID ID;
DependentVectorType::Profile(ID, *this, getCanonicalType(VecType), SizeExpr,
VecKind);
@ -4088,7 +4087,7 @@ QualType ASTContext::getExtVectorType(QualType vecType,
// Check if we've already instantiated a vector of this type.
llvm::FoldingSetNodeID ID;
VectorType::Profile(ID, vecType, NumElts, Type::ExtVector,
VectorType::GenericVector);
VectorKind::Generic);
void *InsertPos = nullptr;
if (VectorType *VTP = VectorTypes.FindNodeOrInsertPos(ID, InsertPos))
return QualType(VTP, 0);
@ -9396,16 +9395,16 @@ bool ASTContext::areCompatibleVectorTypes(QualType FirstVec,
const auto *Second = SecondVec->castAs<VectorType>();
if (First->getNumElements() == Second->getNumElements() &&
hasSameType(First->getElementType(), Second->getElementType()) &&
First->getVectorKind() != VectorType::AltiVecPixel &&
First->getVectorKind() != VectorType::AltiVecBool &&
Second->getVectorKind() != VectorType::AltiVecPixel &&
Second->getVectorKind() != VectorType::AltiVecBool &&
First->getVectorKind() != VectorType::SveFixedLengthDataVector &&
First->getVectorKind() != VectorType::SveFixedLengthPredicateVector &&
Second->getVectorKind() != VectorType::SveFixedLengthDataVector &&
Second->getVectorKind() != VectorType::SveFixedLengthPredicateVector &&
First->getVectorKind() != VectorType::RVVFixedLengthDataVector &&
Second->getVectorKind() != VectorType::RVVFixedLengthDataVector)
First->getVectorKind() != VectorKind::AltiVecPixel &&
First->getVectorKind() != VectorKind::AltiVecBool &&
Second->getVectorKind() != VectorKind::AltiVecPixel &&
Second->getVectorKind() != VectorKind::AltiVecBool &&
First->getVectorKind() != VectorKind::SveFixedLengthData &&
First->getVectorKind() != VectorKind::SveFixedLengthPredicate &&
Second->getVectorKind() != VectorKind::SveFixedLengthData &&
Second->getVectorKind() != VectorKind::SveFixedLengthPredicate &&
First->getVectorKind() != VectorKind::RVVFixedLengthData &&
Second->getVectorKind() != VectorKind::RVVFixedLengthData)
return true;
return false;
@ -9432,12 +9431,12 @@ bool ASTContext::areCompatibleSveTypes(QualType FirstType,
if (const auto *VT = SecondType->getAs<VectorType>()) {
// Predicates have the same representation as uint8 so we also have to
// check the kind to make these types incompatible.
if (VT->getVectorKind() == VectorType::SveFixedLengthPredicateVector)
if (VT->getVectorKind() == VectorKind::SveFixedLengthPredicate)
return BT->getKind() == BuiltinType::SveBool;
else if (VT->getVectorKind() == VectorType::SveFixedLengthDataVector)
else if (VT->getVectorKind() == VectorKind::SveFixedLengthData)
return VT->getElementType().getCanonicalType() ==
FirstType->getSveEltType(*this);
else if (VT->getVectorKind() == VectorType::GenericVector)
else if (VT->getVectorKind() == VectorKind::Generic)
return getTypeSize(SecondType) == getSVETypeSize(*this, BT) &&
hasSameType(VT->getElementType(),
getBuiltinVectorTypeInfo(BT).ElementType);
@ -9463,16 +9462,15 @@ bool ASTContext::areLaxCompatibleSveTypes(QualType FirstType,
return false;
const auto *VecTy = SecondType->getAs<VectorType>();
if (VecTy &&
(VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector ||
VecTy->getVectorKind() == VectorType::GenericVector)) {
if (VecTy && (VecTy->getVectorKind() == VectorKind::SveFixedLengthData ||
VecTy->getVectorKind() == VectorKind::Generic)) {
const LangOptions::LaxVectorConversionKind LVCKind =
getLangOpts().getLaxVectorConversions();
// Can not convert between sve predicates and sve vectors because of
// different size.
if (BT->getKind() == BuiltinType::SveBool &&
VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector)
VecTy->getVectorKind() == VectorKind::SveFixedLengthData)
return false;
// If __ARM_FEATURE_SVE_BITS != N do not allow GNU vector lax conversion.
@ -9480,7 +9478,7 @@ bool ASTContext::areLaxCompatibleSveTypes(QualType FirstType,
// converts to VLAT and VLAT implicitly converts to GNUT."
// ACLE Spec Version 00bet6, 3.7.3.2. Behavior common to vectors and
// predicates.
if (VecTy->getVectorKind() == VectorType::GenericVector &&
if (VecTy->getVectorKind() == VectorKind::Generic &&
getTypeSize(SecondType) != getSVETypeSize(*this, BT))
return false;
@ -9527,8 +9525,8 @@ bool ASTContext::areCompatibleRVVTypes(QualType FirstType,
auto IsValidCast = [this](QualType FirstType, QualType SecondType) {
if (const auto *BT = FirstType->getAs<BuiltinType>()) {
if (const auto *VT = SecondType->getAs<VectorType>()) {
if (VT->getVectorKind() == VectorType::RVVFixedLengthDataVector ||
VT->getVectorKind() == VectorType::GenericVector)
if (VT->getVectorKind() == VectorKind::RVVFixedLengthData ||
VT->getVectorKind() == VectorKind::Generic)
return FirstType->isRVVVLSBuiltinType() &&
getTypeSize(SecondType) == getRVVTypeSize(*this, BT) &&
hasSameType(VT->getElementType(),
@ -9558,7 +9556,7 @@ bool ASTContext::areLaxCompatibleRVVTypes(QualType FirstType,
return false;
const auto *VecTy = SecondType->getAs<VectorType>();
if (VecTy && VecTy->getVectorKind() == VectorType::GenericVector) {
if (VecTy && VecTy->getVectorKind() == VectorKind::Generic) {
const LangOptions::LaxVectorConversionKind LVCKind =
getLangOpts().getLaxVectorConversions();
@ -11398,8 +11396,7 @@ static QualType DecodeTypeFromStr(const char *&Str, const ASTContext &Context,
assert(!RequiresICE && "Can't require vector ICE");
// TODO: No way to make AltiVec vectors in builtins yet.
Type = Context.getVectorType(ElementType, NumElements,
VectorType::GenericVector);
Type = Context.getVectorType(ElementType, NumElements, VectorKind::Generic);
break;
}
case 'E': {

View File

@ -3707,7 +3707,7 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) {
QualType EltType = T->getElementType();
assert(EltType->isBuiltinType() && "Neon vector element not a BuiltinType");
const char *EltName = nullptr;
if (T->getVectorKind() == VectorType::NeonPolyVector) {
if (T->getVectorKind() == VectorKind::NeonPoly) {
switch (cast<BuiltinType>(EltType)->getKind()) {
case BuiltinType::SChar:
case BuiltinType::UChar:
@ -3809,7 +3809,7 @@ void CXXNameMangler::mangleAArch64NeonVectorType(const VectorType *T) {
"Neon vector type not 64 or 128 bits");
StringRef EltName;
if (T->getVectorKind() == VectorType::NeonPolyVector) {
if (T->getVectorKind() == VectorKind::NeonPoly) {
switch (cast<BuiltinType>(EltType)->getKind()) {
case BuiltinType::UChar:
EltName = "Poly8";
@ -3864,8 +3864,8 @@ void CXXNameMangler::mangleAArch64NeonVectorType(const DependentVectorType *T) {
// for the Arm Architecture, see
// https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#appendix-c-mangling
void CXXNameMangler::mangleAArch64FixedSveVectorType(const VectorType *T) {
assert((T->getVectorKind() == VectorType::SveFixedLengthDataVector ||
T->getVectorKind() == VectorType::SveFixedLengthPredicateVector) &&
assert((T->getVectorKind() == VectorKind::SveFixedLengthData ||
T->getVectorKind() == VectorKind::SveFixedLengthPredicate) &&
"expected fixed-length SVE vector!");
QualType EltType = T->getElementType();
@ -3878,7 +3878,7 @@ void CXXNameMangler::mangleAArch64FixedSveVectorType(const VectorType *T) {
TypeName = "__SVInt8_t";
break;
case BuiltinType::UChar: {
if (T->getVectorKind() == VectorType::SveFixedLengthDataVector)
if (T->getVectorKind() == VectorKind::SveFixedLengthData)
TypeName = "__SVUint8_t";
else
TypeName = "__SVBool_t";
@ -3920,7 +3920,7 @@ void CXXNameMangler::mangleAArch64FixedSveVectorType(const VectorType *T) {
unsigned VecSizeInBits = getASTContext().getTypeInfo(T).Width;
if (T->getVectorKind() == VectorType::SveFixedLengthPredicateVector)
if (T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
VecSizeInBits *= 8;
Out << "9__SVE_VLSI" << 'u' << TypeName.size() << TypeName << "Lj"
@ -3937,7 +3937,7 @@ void CXXNameMangler::mangleAArch64FixedSveVectorType(
}
void CXXNameMangler::mangleRISCVFixedRVVVectorType(const VectorType *T) {
assert(T->getVectorKind() == VectorType::RVVFixedLengthDataVector &&
assert(T->getVectorKind() == VectorKind::RVVFixedLengthData &&
"expected fixed-length RVV vector!");
QualType EltType = T->getElementType();
@ -4021,8 +4021,8 @@ void CXXNameMangler::mangleRISCVFixedRVVVectorType(
// ::= p # AltiVec vector pixel
// ::= b # Altivec vector bool
void CXXNameMangler::mangleType(const VectorType *T) {
if ((T->getVectorKind() == VectorType::NeonVector ||
T->getVectorKind() == VectorType::NeonPolyVector)) {
if ((T->getVectorKind() == VectorKind::Neon ||
T->getVectorKind() == VectorKind::NeonPoly)) {
llvm::Triple Target = getASTContext().getTargetInfo().getTriple();
llvm::Triple::ArchType Arch =
getASTContext().getTargetInfo().getTriple().getArch();
@ -4032,26 +4032,26 @@ void CXXNameMangler::mangleType(const VectorType *T) {
else
mangleNeonVectorType(T);
return;
} else if (T->getVectorKind() == VectorType::SveFixedLengthDataVector ||
T->getVectorKind() == VectorType::SveFixedLengthPredicateVector) {
} else if (T->getVectorKind() == VectorKind::SveFixedLengthData ||
T->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
mangleAArch64FixedSveVectorType(T);
return;
} else if (T->getVectorKind() == VectorType::RVVFixedLengthDataVector) {
} else if (T->getVectorKind() == VectorKind::RVVFixedLengthData) {
mangleRISCVFixedRVVVectorType(T);
return;
}
Out << "Dv" << T->getNumElements() << '_';
if (T->getVectorKind() == VectorType::AltiVecPixel)
if (T->getVectorKind() == VectorKind::AltiVecPixel)
Out << 'p';
else if (T->getVectorKind() == VectorType::AltiVecBool)
else if (T->getVectorKind() == VectorKind::AltiVecBool)
Out << 'b';
else
mangleType(T->getElementType());
}
void CXXNameMangler::mangleType(const DependentVectorType *T) {
if ((T->getVectorKind() == VectorType::NeonVector ||
T->getVectorKind() == VectorType::NeonPolyVector)) {
if ((T->getVectorKind() == VectorKind::Neon ||
T->getVectorKind() == VectorKind::NeonPoly)) {
llvm::Triple Target = getASTContext().getTargetInfo().getTriple();
llvm::Triple::ArchType Arch =
getASTContext().getTargetInfo().getTriple().getArch();
@ -4061,11 +4061,11 @@ void CXXNameMangler::mangleType(const DependentVectorType *T) {
else
mangleNeonVectorType(T);
return;
} else if (T->getVectorKind() == VectorType::SveFixedLengthDataVector ||
T->getVectorKind() == VectorType::SveFixedLengthPredicateVector) {
} else if (T->getVectorKind() == VectorKind::SveFixedLengthData ||
T->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
mangleAArch64FixedSveVectorType(T);
return;
} else if (T->getVectorKind() == VectorType::RVVFixedLengthDataVector) {
} else if (T->getVectorKind() == VectorKind::RVVFixedLengthData) {
mangleRISCVFixedRVVVectorType(T);
return;
}
@ -4073,9 +4073,9 @@ void CXXNameMangler::mangleType(const DependentVectorType *T) {
Out << "Dv";
mangleExpression(T->getSizeExpr());
Out << '_';
if (T->getVectorKind() == VectorType::AltiVecPixel)
if (T->getVectorKind() == VectorKind::AltiVecPixel)
Out << 'p';
else if (T->getVectorKind() == VectorType::AltiVecBool)
else if (T->getVectorKind() == VectorKind::AltiVecBool)
Out << 'b';
else
mangleType(T->getElementType());

View File

@ -677,30 +677,30 @@ void JSONNodeDumper::VisitDependentSizedExtVectorType(
void JSONNodeDumper::VisitVectorType(const VectorType *VT) {
JOS.attribute("numElements", VT->getNumElements());
switch (VT->getVectorKind()) {
case VectorType::GenericVector:
case VectorKind::Generic:
break;
case VectorType::AltiVecVector:
case VectorKind::AltiVecVector:
JOS.attribute("vectorKind", "altivec");
break;
case VectorType::AltiVecPixel:
case VectorKind::AltiVecPixel:
JOS.attribute("vectorKind", "altivec pixel");
break;
case VectorType::AltiVecBool:
case VectorKind::AltiVecBool:
JOS.attribute("vectorKind", "altivec bool");
break;
case VectorType::NeonVector:
case VectorKind::Neon:
JOS.attribute("vectorKind", "neon");
break;
case VectorType::NeonPolyVector:
case VectorKind::NeonPoly:
JOS.attribute("vectorKind", "neon poly");
break;
case VectorType::SveFixedLengthDataVector:
case VectorKind::SveFixedLengthData:
JOS.attribute("vectorKind", "fixed-length sve data vector");
break;
case VectorType::SveFixedLengthPredicateVector:
case VectorKind::SveFixedLengthPredicate:
JOS.attribute("vectorKind", "fixed-length sve predicate vector");
break;
case VectorType::RVVFixedLengthDataVector:
case VectorKind::RVVFixedLengthData:
JOS.attribute("vectorKind", "fixed-length rvv data vector");
break;
}

View File

@ -1222,7 +1222,7 @@ public:
void VisitVectorType(const VectorType *T) {
AddQualType(T->getElementType());
ID.AddInteger(T->getNumElements());
ID.AddInteger(T->getVectorKind());
ID.AddInteger(llvm::to_underlying(T->getVectorKind()));
VisitType(T);
}

View File

@ -1587,30 +1587,30 @@ void TextNodeDumper::VisitDependentSizedExtVectorType(
void TextNodeDumper::VisitVectorType(const VectorType *T) {
switch (T->getVectorKind()) {
case VectorType::GenericVector:
case VectorKind::Generic:
break;
case VectorType::AltiVecVector:
case VectorKind::AltiVecVector:
OS << " altivec";
break;
case VectorType::AltiVecPixel:
case VectorKind::AltiVecPixel:
OS << " altivec pixel";
break;
case VectorType::AltiVecBool:
case VectorKind::AltiVecBool:
OS << " altivec bool";
break;
case VectorType::NeonVector:
case VectorKind::Neon:
OS << " neon";
break;
case VectorType::NeonPolyVector:
case VectorKind::NeonPoly:
OS << " neon poly";
break;
case VectorType::SveFixedLengthDataVector:
case VectorKind::SveFixedLengthData:
OS << " fixed-length sve data vector";
break;
case VectorType::SveFixedLengthPredicateVector:
case VectorKind::SveFixedLengthPredicate:
OS << " fixed-length sve predicate vector";
break;
case VectorType::RVVFixedLengthDataVector:
case VectorKind::RVVFixedLengthData:
OS << " fixed-length rvv data vector";
break;
}

View File

@ -246,23 +246,22 @@ void DependentSizedArrayType::Profile(llvm::FoldingSetNodeID &ID,
DependentVectorType::DependentVectorType(QualType ElementType,
QualType CanonType, Expr *SizeExpr,
SourceLocation Loc,
VectorType::VectorKind VecKind)
SourceLocation Loc, VectorKind VecKind)
: Type(DependentVector, CanonType,
TypeDependence::DependentInstantiation |
ElementType->getDependence() |
(SizeExpr ? toTypeDependence(SizeExpr->getDependence())
: TypeDependence::None)),
ElementType(ElementType), SizeExpr(SizeExpr), Loc(Loc) {
VectorTypeBits.VecKind = VecKind;
VectorTypeBits.VecKind = llvm::to_underlying(VecKind);
}
void DependentVectorType::Profile(llvm::FoldingSetNodeID &ID,
const ASTContext &Context,
QualType ElementType, const Expr *SizeExpr,
VectorType::VectorKind VecKind) {
VectorKind VecKind) {
ID.AddPointer(ElementType.getAsOpaquePtr());
ID.AddInteger(VecKind);
ID.AddInteger(llvm::to_underlying(VecKind));
SizeExpr->Profile(ID, Context, true);
}
@ -358,7 +357,7 @@ VectorType::VectorType(QualType vecType, unsigned nElements, QualType canonType,
VectorType::VectorType(TypeClass tc, QualType vecType, unsigned nElements,
QualType canonType, VectorKind vecKind)
: Type(tc, canonType, vecType->getDependence()), ElementType(vecType) {
VectorTypeBits.VecKind = vecKind;
VectorTypeBits.VecKind = llvm::to_underlying(vecKind);
VectorTypeBits.NumElements = nElements;
}

View File

@ -642,28 +642,28 @@ void TypePrinter::printDependentSizedExtVectorAfter(
void TypePrinter::printVectorBefore(const VectorType *T, raw_ostream &OS) {
switch (T->getVectorKind()) {
case VectorType::AltiVecPixel:
case VectorKind::AltiVecPixel:
OS << "__vector __pixel ";
break;
case VectorType::AltiVecBool:
case VectorKind::AltiVecBool:
OS << "__vector __bool ";
printBefore(T->getElementType(), OS);
break;
case VectorType::AltiVecVector:
case VectorKind::AltiVecVector:
OS << "__vector ";
printBefore(T->getElementType(), OS);
break;
case VectorType::NeonVector:
case VectorKind::Neon:
OS << "__attribute__((neon_vector_type("
<< T->getNumElements() << "))) ";
printBefore(T->getElementType(), OS);
break;
case VectorType::NeonPolyVector:
case VectorKind::NeonPoly:
OS << "__attribute__((neon_polyvector_type(" <<
T->getNumElements() << "))) ";
printBefore(T->getElementType(), OS);
break;
case VectorType::GenericVector: {
case VectorKind::Generic: {
// FIXME: We prefer to print the size directly here, but have no way
// to get the size of the type.
OS << "__attribute__((__vector_size__("
@ -674,13 +674,13 @@ void TypePrinter::printVectorBefore(const VectorType *T, raw_ostream &OS) {
printBefore(T->getElementType(), OS);
break;
}
case VectorType::SveFixedLengthDataVector:
case VectorType::SveFixedLengthPredicateVector:
case VectorKind::SveFixedLengthData:
case VectorKind::SveFixedLengthPredicate:
// FIXME: We prefer to print the size directly here, but have no way
// to get the size of the type.
OS << "__attribute__((__arm_sve_vector_bits__(";
if (T->getVectorKind() == VectorType::SveFixedLengthPredicateVector)
if (T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
// Predicates take a bit per byte of the vector size, multiply by 8 to
// get the number of bits passed to the attribute.
OS << T->getNumElements() * 8;
@ -693,7 +693,7 @@ void TypePrinter::printVectorBefore(const VectorType *T, raw_ostream &OS) {
OS << ") * 8))) ";
printBefore(T->getElementType(), OS);
break;
case VectorType::RVVFixedLengthDataVector:
case VectorKind::RVVFixedLengthData:
// FIXME: We prefer to print the size directly here, but have no way
// to get the size of the type.
OS << "__attribute__((__riscv_rvv_vector_bits__(";
@ -716,32 +716,32 @@ void TypePrinter::printVectorAfter(const VectorType *T, raw_ostream &OS) {
void TypePrinter::printDependentVectorBefore(
const DependentVectorType *T, raw_ostream &OS) {
switch (T->getVectorKind()) {
case VectorType::AltiVecPixel:
case VectorKind::AltiVecPixel:
OS << "__vector __pixel ";
break;
case VectorType::AltiVecBool:
case VectorKind::AltiVecBool:
OS << "__vector __bool ";
printBefore(T->getElementType(), OS);
break;
case VectorType::AltiVecVector:
case VectorKind::AltiVecVector:
OS << "__vector ";
printBefore(T->getElementType(), OS);
break;
case VectorType::NeonVector:
case VectorKind::Neon:
OS << "__attribute__((neon_vector_type(";
if (T->getSizeExpr())
T->getSizeExpr()->printPretty(OS, nullptr, Policy);
OS << "))) ";
printBefore(T->getElementType(), OS);
break;
case VectorType::NeonPolyVector:
case VectorKind::NeonPoly:
OS << "__attribute__((neon_polyvector_type(";
if (T->getSizeExpr())
T->getSizeExpr()->printPretty(OS, nullptr, Policy);
OS << "))) ";
printBefore(T->getElementType(), OS);
break;
case VectorType::GenericVector: {
case VectorKind::Generic: {
// FIXME: We prefer to print the size directly here, but have no way
// to get the size of the type.
OS << "__attribute__((__vector_size__(";
@ -753,14 +753,14 @@ void TypePrinter::printDependentVectorBefore(
printBefore(T->getElementType(), OS);
break;
}
case VectorType::SveFixedLengthDataVector:
case VectorType::SveFixedLengthPredicateVector:
case VectorKind::SveFixedLengthData:
case VectorKind::SveFixedLengthPredicate:
// FIXME: We prefer to print the size directly here, but have no way
// to get the size of the type.
OS << "__attribute__((__arm_sve_vector_bits__(";
if (T->getSizeExpr()) {
T->getSizeExpr()->printPretty(OS, nullptr, Policy);
if (T->getVectorKind() == VectorType::SveFixedLengthPredicateVector)
if (T->getVectorKind() == VectorKind::SveFixedLengthPredicate)
// Predicates take a bit per byte of the vector size, multiply by 8 to
// get the number of bits passed to the attribute.
OS << " * 8";
@ -772,7 +772,7 @@ void TypePrinter::printDependentVectorBefore(
OS << "))) ";
printBefore(T->getElementType(), OS);
break;
case VectorType::RVVFixedLengthDataVector:
case VectorKind::RVVFixedLengthData:
// FIXME: We prefer to print the size directly here, but have no way
// to get the size of the type.
OS << "__attribute__((__riscv_rvv_vector_bits__(";

View File

@ -3121,8 +3121,8 @@ llvm::DIType *CGDebugInfo::CreateType(const VectorType *Ty,
uint64_t NumVectorBytes = Size / Ctx.getCharWidth();
// Construct the vector of 'char' type.
QualType CharVecTy = Ctx.getVectorType(Ctx.CharTy, NumVectorBytes,
VectorType::GenericVector);
QualType CharVecTy =
Ctx.getVectorType(Ctx.CharTy, NumVectorBytes, VectorKind::Generic);
return CreateType(CharVecTy->getAs<VectorType>(), Unit);
}

View File

@ -2931,7 +2931,7 @@ Value *ScalarExprEmitter::VisitUnaryLNot(const UnaryOperator *E) {
// Perform vector logical not on comparison with zero vector.
if (E->getType()->isVectorType() &&
E->getType()->castAs<VectorType>()->getVectorKind() ==
VectorType::GenericVector) {
VectorKind::Generic) {
Value *Oper = Visit(E->getSubExpr());
Value *Zero = llvm::Constant::getNullValue(Oper->getType());
Value *Result;

View File

@ -185,7 +185,7 @@ ABIArgInfo AArch64ABIInfo::coerceIllegalVector(QualType Ty) const {
assert(Ty->isVectorType() && "expected vector type!");
const auto *VT = Ty->castAs<VectorType>();
if (VT->getVectorKind() == VectorType::SveFixedLengthPredicateVector) {
if (VT->getVectorKind() == VectorKind::SveFixedLengthPredicate) {
assert(VT->getElementType()->isBuiltinType() && "expected builtin type!");
assert(VT->getElementType()->castAs<BuiltinType>()->getKind() ==
BuiltinType::UChar &&
@ -194,7 +194,7 @@ ABIArgInfo AArch64ABIInfo::coerceIllegalVector(QualType Ty) const {
llvm::Type::getInt1Ty(getVMContext()), 16));
}
if (VT->getVectorKind() == VectorType::SveFixedLengthDataVector) {
if (VT->getVectorKind() == VectorKind::SveFixedLengthData) {
assert(VT->getElementType()->isBuiltinType() && "expected builtin type!");
const auto *BT = VT->getElementType()->castAs<BuiltinType>();
@ -368,8 +368,8 @@ ABIArgInfo AArch64ABIInfo::classifyReturnType(QualType RetTy,
return ABIArgInfo::getIgnore();
if (const auto *VT = RetTy->getAs<VectorType>()) {
if (VT->getVectorKind() == VectorType::SveFixedLengthDataVector ||
VT->getVectorKind() == VectorType::SveFixedLengthPredicateVector)
if (VT->getVectorKind() == VectorKind::SveFixedLengthData ||
VT->getVectorKind() == VectorKind::SveFixedLengthPredicate)
return coerceIllegalVector(RetTy);
}
@ -443,8 +443,8 @@ bool AArch64ABIInfo::isIllegalVectorType(QualType Ty) const {
// Check whether VT is a fixed-length SVE vector. These types are
// represented as scalable vectors in function args/return and must be
// coerced from fixed vectors.
if (VT->getVectorKind() == VectorType::SveFixedLengthDataVector ||
VT->getVectorKind() == VectorType::SveFixedLengthPredicateVector)
if (VT->getVectorKind() == VectorKind::SveFixedLengthData ||
VT->getVectorKind() == VectorKind::SveFixedLengthPredicate)
return true;
// Check whether VT is legal.

View File

@ -318,7 +318,7 @@ ABIArgInfo RISCVABIInfo::coerceVLSVector(QualType Ty) const {
assert(Ty->isVectorType() && "expected vector type!");
const auto *VT = Ty->castAs<VectorType>();
assert(VT->getVectorKind() == VectorType::RVVFixedLengthDataVector &&
assert(VT->getVectorKind() == VectorKind::RVVFixedLengthData &&
"Unexpected vector kind");
assert(VT->getElementType()->isBuiltinType() && "expected builtin type!");
@ -431,7 +431,7 @@ ABIArgInfo RISCVABIInfo::classifyArgumentType(QualType Ty, bool IsFixed,
}
if (const VectorType *VT = Ty->getAs<VectorType>())
if (VT->getVectorKind() == VectorType::RVVFixedLengthDataVector)
if (VT->getVectorKind() == VectorKind::RVVFixedLengthData)
return coerceVLSVector(Ty);
// Aggregates which are <= 2*XLen will be passed in registers if possible,

View File

@ -2682,11 +2682,11 @@ void CastOperation::checkAddressSpaceCast(QualType SrcType, QualType DestType) {
bool Sema::ShouldSplatAltivecScalarInCast(const VectorType *VecTy) {
bool SrcCompatXL = this->getLangOpts().getAltivecSrcCompat() ==
LangOptions::AltivecSrcCompatKind::XL;
VectorType::VectorKind VKind = VecTy->getVectorKind();
VectorKind VKind = VecTy->getVectorKind();
if ((VKind == VectorType::AltiVecVector) ||
(SrcCompatXL && ((VKind == VectorType::AltiVecBool) ||
(VKind == VectorType::AltiVecPixel)))) {
if ((VKind == VectorKind::AltiVecVector) ||
(SrcCompatXL && ((VKind == VectorKind::AltiVecBool) ||
(VKind == VectorKind::AltiVecPixel)))) {
return true;
}
return false;

View File

@ -4645,7 +4645,7 @@ static QualType DecodePPCMMATypeFromStr(ASTContext &Context, const char *&Str,
switch (*Str++) {
case 'V':
return Context.getVectorType(Context.UnsignedCharTy, 16,
VectorType::VectorKind::AltiVecVector);
VectorKind::AltiVecVector);
case 'i': {
char *End;
unsigned size = strtoul(Str, &End, 10);
@ -9153,8 +9153,8 @@ ExprResult Sema::SemaBuiltinShuffleVector(CallExpr *TheCall) {
TheCall->getArg(1)->getEndLoc()));
} else if (numElements != numResElements) {
QualType eltType = LHSType->castAs<VectorType>()->getElementType();
resType = Context.getVectorType(eltType, numResElements,
VectorType::GenericVector);
resType =
Context.getVectorType(eltType, numResElements, VectorKind::Generic);
}
}

View File

@ -4861,7 +4861,7 @@ void Sema::AddModeAttr(Decl *D, const AttributeCommonInfo &CI,
QualType NewTy = NewElemTy;
if (VectorSize.getBoolValue()) {
NewTy = Context.getVectorType(NewTy, VectorSize.getZExtValue(),
VectorType::GenericVector);
VectorKind::Generic);
} else if (const auto *OldVT = OldTy->getAs<VectorType>()) {
// Complex machine mode does not support base vector types.
if (ComplexMode) {

View File

@ -8249,8 +8249,7 @@ bool Sema::isValidSveBitcast(QualType srcTy, QualType destTy) {
return false;
const auto *VecTy = SecondType->getAs<VectorType>();
return VecTy &&
VecTy->getVectorKind() == VectorType::SveFixedLengthDataVector;
return VecTy && VecTy->getVectorKind() == VectorKind::SveFixedLengthData;
};
return ValidScalableConversion(srcTy, destTy) ||
@ -8271,8 +8270,7 @@ bool Sema::isValidRVVBitcast(QualType srcTy, QualType destTy) {
return false;
const auto *VecTy = SecondType->getAs<VectorType>();
return VecTy &&
VecTy->getVectorKind() == VectorType::RVVFixedLengthDataVector;
return VecTy && VecTy->getVectorKind() == VectorKind::RVVFixedLengthData;
};
return ValidScalableConversion(srcTy, destTy) ||
@ -8318,19 +8316,19 @@ bool Sema::anyAltivecTypes(QualType SrcTy, QualType DestTy) {
bool IsSrcTyAltivec =
SrcTy->isVectorType() && ((SrcTy->castAs<VectorType>()->getVectorKind() ==
VectorType::AltiVecVector) ||
VectorKind::AltiVecVector) ||
(SrcTy->castAs<VectorType>()->getVectorKind() ==
VectorType::AltiVecBool) ||
VectorKind::AltiVecBool) ||
(SrcTy->castAs<VectorType>()->getVectorKind() ==
VectorType::AltiVecPixel));
VectorKind::AltiVecPixel));
bool IsDestTyAltivec = DestTy->isVectorType() &&
((DestTy->castAs<VectorType>()->getVectorKind() ==
VectorType::AltiVecVector) ||
VectorKind::AltiVecVector) ||
(DestTy->castAs<VectorType>()->getVectorKind() ==
VectorType::AltiVecBool) ||
VectorKind::AltiVecBool) ||
(DestTy->castAs<VectorType>()->getVectorKind() ==
VectorType::AltiVecPixel));
VectorKind::AltiVecPixel));
return (IsSrcTyAltivec || IsDestTyAltivec);
}
@ -8629,16 +8627,15 @@ ExprResult Sema::BuildVectorLiteral(SourceLocation LParenLoc,
else {
// For OpenCL, when the number of initializers is a single value,
// it will be replicated to all components of the vector.
if (getLangOpts().OpenCL &&
VTy->getVectorKind() == VectorType::GenericVector &&
if (getLangOpts().OpenCL && VTy->getVectorKind() == VectorKind::Generic &&
numExprs == 1) {
QualType ElemTy = VTy->getElementType();
ExprResult Literal = DefaultLvalueConversion(exprs[0]);
if (Literal.isInvalid())
return ExprError();
Literal = ImpCastExprToType(Literal.get(), ElemTy,
PrepareScalarCast(Literal, ElemTy));
return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.get());
QualType ElemTy = VTy->getElementType();
ExprResult Literal = DefaultLvalueConversion(exprs[0]);
if (Literal.isInvalid())
return ExprError();
Literal = ImpCastExprToType(Literal.get(), ElemTy,
PrepareScalarCast(Literal, ElemTy));
return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.get());
}
initExprs.append(exprs, exprs + numExprs);
@ -10229,9 +10226,9 @@ Sema::CheckAssignmentConstraints(QualType LHSType, ExprResult &RHS,
if (VecType && VecType->getNumElements() == 1 &&
isLaxVectorConversion(RHSType, LHSType)) {
if (Context.getTargetInfo().getTriple().isPPC() &&
(VecType->getVectorKind() == VectorType::AltiVecVector ||
VecType->getVectorKind() == VectorType::AltiVecBool ||
VecType->getVectorKind() == VectorType::AltiVecPixel))
(VecType->getVectorKind() == VectorKind::AltiVecVector ||
VecType->getVectorKind() == VectorKind::AltiVecBool ||
VecType->getVectorKind() == VectorKind::AltiVecPixel))
Diag(RHS.get()->getExprLoc(), diag::warn_deprecated_lax_vec_conv_all)
<< RHSType << LHSType;
ExprResult *VecExpr = &RHS;
@ -11096,9 +11093,9 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
// AltiVec-style "vector bool op vector bool" combinations are allowed
// for some operators but not others.
if (!AllowBothBool &&
LHSVecType && LHSVecType->getVectorKind() == VectorType::AltiVecBool &&
RHSVecType && RHSVecType->getVectorKind() == VectorType::AltiVecBool)
if (!AllowBothBool && LHSVecType &&
LHSVecType->getVectorKind() == VectorKind::AltiVecBool && RHSVecType &&
RHSVecType->getVectorKind() == VectorKind::AltiVecBool)
return ReportInvalid ? InvalidOperands(Loc, LHS, RHS) : QualType();
// This operation may not be performed on boolean vectors.
@ -11130,15 +11127,15 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
LHSVecType->getNumElements() == RHSVecType->getNumElements() &&
(Context.getTypeSize(LHSVecType->getElementType()) ==
Context.getTypeSize(RHSVecType->getElementType()))) {
if (LHSVecType->getVectorKind() == VectorType::AltiVecVector &&
if (LHSVecType->getVectorKind() == VectorKind::AltiVecVector &&
LHSVecType->getElementType()->isIntegerType() &&
RHSVecType->getVectorKind() == VectorType::AltiVecBool) {
RHSVecType->getVectorKind() == VectorKind::AltiVecBool) {
RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
return LHSType;
}
if (!IsCompAssign &&
LHSVecType->getVectorKind() == VectorType::AltiVecBool &&
RHSVecType->getVectorKind() == VectorType::AltiVecVector &&
LHSVecType->getVectorKind() == VectorKind::AltiVecBool &&
RHSVecType->getVectorKind() == VectorKind::AltiVecVector &&
RHSVecType->getElementType()->isIntegerType()) {
LHS = ImpCastExprToType(LHS.get(), RHSType, CK_BitCast);
return RHSType;
@ -11152,10 +11149,10 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
const VectorType *VecType = SecondType->getAs<VectorType>();
SVEorRVV = 0;
if (FirstType->isSizelessBuiltinType() && VecType) {
if (VecType->getVectorKind() == VectorType::SveFixedLengthDataVector ||
VecType->getVectorKind() == VectorType::SveFixedLengthPredicateVector)
if (VecType->getVectorKind() == VectorKind::SveFixedLengthData ||
VecType->getVectorKind() == VectorKind::SveFixedLengthPredicate)
return true;
if (VecType->getVectorKind() == VectorType::RVVFixedLengthDataVector) {
if (VecType->getVectorKind() == VectorKind::RVVFixedLengthData) {
SVEorRVV = 1;
return true;
}
@ -11181,14 +11178,12 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
SVEorRVV = 0;
if (FirstVecType && SecondVecType) {
if (FirstVecType->getVectorKind() == VectorType::GenericVector) {
if (SecondVecType->getVectorKind() ==
VectorType::SveFixedLengthDataVector ||
if (FirstVecType->getVectorKind() == VectorKind::Generic) {
if (SecondVecType->getVectorKind() == VectorKind::SveFixedLengthData ||
SecondVecType->getVectorKind() ==
VectorType::SveFixedLengthPredicateVector)
VectorKind::SveFixedLengthPredicate)
return true;
if (SecondVecType->getVectorKind() ==
VectorType::RVVFixedLengthDataVector) {
if (SecondVecType->getVectorKind() == VectorKind::RVVFixedLengthData) {
SVEorRVV = 1;
return true;
}
@ -11197,7 +11192,7 @@ QualType Sema::CheckVectorOperands(ExprResult &LHS, ExprResult &RHS,
}
if (SecondVecType &&
SecondVecType->getVectorKind() == VectorType::GenericVector) {
SecondVecType->getVectorKind() == VectorKind::Generic) {
if (FirstType->isSVESizelessBuiltinType())
return true;
if (FirstType->isRVVSizelessBuiltinType()) {
@ -12413,10 +12408,10 @@ QualType Sema::CheckShiftOperands(ExprResult &LHS, ExprResult &RHS,
// like general shifts, except that neither the LHS nor the RHS is
// allowed to be a "vector bool".
if (auto LHSVecType = LHS.get()->getType()->getAs<VectorType>())
if (LHSVecType->getVectorKind() == VectorType::AltiVecBool)
if (LHSVecType->getVectorKind() == VectorKind::AltiVecBool)
return InvalidOperands(Loc, LHS, RHS);
if (auto RHSVecType = RHS.get()->getType()->getAs<VectorType>())
if (RHSVecType->getVectorKind() == VectorType::AltiVecBool)
if (RHSVecType->getVectorKind() == VectorKind::AltiVecBool)
return InvalidOperands(Loc, LHS, RHS);
}
return checkVectorShift(*this, LHS, RHS, Loc, IsCompAssign);
@ -13585,23 +13580,23 @@ QualType Sema::GetSignedVectorType(QualType V) {
if (TypeSize == Context.getTypeSize(Context.Int128Ty))
return Context.getVectorType(Context.Int128Ty, VTy->getNumElements(),
VectorType::GenericVector);
VectorKind::Generic);
if (TypeSize == Context.getTypeSize(Context.LongLongTy))
return Context.getVectorType(Context.LongLongTy, VTy->getNumElements(),
VectorType::GenericVector);
VectorKind::Generic);
if (TypeSize == Context.getTypeSize(Context.LongTy))
return Context.getVectorType(Context.LongTy, VTy->getNumElements(),
VectorType::GenericVector);
VectorKind::Generic);
if (TypeSize == Context.getTypeSize(Context.IntTy))
return Context.getVectorType(Context.IntTy, VTy->getNumElements(),
VectorType::GenericVector);
VectorKind::Generic);
if (TypeSize == Context.getTypeSize(Context.ShortTy))
return Context.getVectorType(Context.ShortTy, VTy->getNumElements(),
VectorType::GenericVector);
VectorKind::Generic);
assert(TypeSize == Context.getTypeSize(Context.CharTy) &&
"Unhandled vector element size in vector compare");
return Context.getVectorType(Context.CharTy, VTy->getNumElements(),
VectorType::GenericVector);
VectorKind::Generic);
}
QualType Sema::GetSignedSizelessVectorType(QualType V) {
@ -13652,7 +13647,7 @@ QualType Sema::CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS,
// If AltiVec, the comparison results in a numeric type, i.e.
// bool for C++, int for C
if (vType->castAs<VectorType>()->getVectorKind() ==
VectorType::AltiVecVector)
VectorKind::AltiVecVector)
return Context.getLogicalOperationType();
else
Diag(Loc, diag::warn_deprecated_altivec_src_compat);
@ -14879,10 +14874,10 @@ static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op,
// OK! ( C/C++ Language Extensions for CBEA(Version 2.6) 10.3 )
} else if (S.getLangOpts().ZVector && ResType->isVectorType() &&
(ResType->castAs<VectorType>()->getVectorKind() !=
VectorType::AltiVecBool)) {
VectorKind::AltiVecBool)) {
// The z vector extensions allow ++ and -- for non-bool vectors.
} else if(S.getLangOpts().OpenCL && ResType->isVectorType() &&
ResType->castAs<VectorType>()->getElementType()->isIntegerType()) {
} else if (S.getLangOpts().OpenCL && ResType->isVectorType() &&
ResType->castAs<VectorType>()->getElementType()->isIntegerType()) {
// OpenCL V1.2 6.3 says dec/inc ops operate on integer vector types.
} else {
S.Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
@ -15590,7 +15585,7 @@ static bool needsConversionOfHalfVec(bool OpRequiresConversion, ASTContext &Ctx,
// the vectors shouldn't be treated as storage-only types. See the
// discussion here: https://reviews.llvm.org/rG825235c140e7
if (const VectorType *VT = Ty->getAs<VectorType>()) {
if (VT->getVectorKind() == VectorType::NeonVector)
if (VT->getVectorKind() == VectorKind::Neon)
return false;
return VT->getElementType().getCanonicalType() == Ctx.HalfTy;
}
@ -16371,7 +16366,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
// The z vector extensions don't allow + or - with bool vectors.
(!Context.getLangOpts().ZVector ||
resultType->castAs<VectorType>()->getVectorKind() !=
VectorType::AltiVecBool))
VectorKind::AltiVecBool))
break;
else if (resultType->isSveVLSBuiltinType()) // SVE vectors allow + and -
break;
@ -16461,7 +16456,7 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc,
break;
} else if (Context.getLangOpts().CPlusPlus && resultType->isVectorType()) {
const VectorType *VTy = resultType->castAs<VectorType>();
if (VTy->getVectorKind() != VectorType::GenericVector)
if (VTy->getVectorKind() != VectorKind::Generic)
return ExprError(Diag(OpLoc, diag::err_typecheck_unary_expr)
<< resultType << Input.get()->getSourceRange());

View File

@ -6405,7 +6405,7 @@ QualType Sema::CheckVectorConditionalTypes(ExprResult &Cond, ExprResult &LHS,
Context.getExtVectorType(ResultElementTy, CondVT->getNumElements());
else
ResultType = Context.getVectorType(
ResultElementTy, CondVT->getNumElements(), VectorType::GenericVector);
ResultElementTy, CondVT->getNumElements(), VectorKind::Generic);
LHS = ImpCastExprToType(LHS.get(), ResultType, CK_VectorSplat);
RHS = ImpCastExprToType(RHS.get(), ResultType, CK_VectorSplat);

View File

@ -1808,8 +1808,8 @@ void InitListChecker::CheckVectorType(const InitializedEntity &Entity,
bool isBigEndian = SemaRef.Context.getTargetInfo().isBigEndian();
const VectorType *T = Entity.getType()->castAs<VectorType>();
if (isBigEndian && (T->getVectorKind() == VectorType::NeonVector ||
T->getVectorKind() == VectorType::NeonPolyVector)) {
if (isBigEndian && (T->getVectorKind() == VectorKind::Neon ||
T->getVectorKind() == VectorKind::NeonPoly)) {
// The ability to use vector initializer lists is a GNU vector extension
// and is unrelated to the NEON intrinsics in arm_neon.h. On little
// endian machines it works fine, however on big endian machines it

View File

@ -1802,11 +1802,11 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
} else if (DS.isTypeAltiVecVector()) {
unsigned typeSize = static_cast<unsigned>(Context.getTypeSize(Result));
assert(typeSize > 0 && "type size for vector must be greater than 0 bits");
VectorType::VectorKind VecKind = VectorType::AltiVecVector;
VectorKind VecKind = VectorKind::AltiVecVector;
if (DS.isTypeAltiVecPixel())
VecKind = VectorType::AltiVecPixel;
VecKind = VectorKind::AltiVecPixel;
else if (DS.isTypeAltiVecBool())
VecKind = VectorType::AltiVecBool;
VecKind = VectorKind::AltiVecBool;
Result = Context.getVectorType(Result, 128/typeSize, VecKind);
}
@ -2767,7 +2767,7 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr,
if (SizeExpr->isTypeDependent() || SizeExpr->isValueDependent())
return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
VectorType::GenericVector);
VectorKind::Generic);
std::optional<llvm::APSInt> VecSize =
SizeExpr->getIntegerConstantExpr(Context);
@ -2780,7 +2780,7 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr,
if (CurType->isDependentType())
return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
VectorType::GenericVector);
VectorKind::Generic);
// vecSize is specified in bytes - convert to bits.
if (!VecSize->isIntN(61)) {
@ -2811,7 +2811,7 @@ QualType Sema::BuildVectorType(QualType CurType, Expr *SizeExpr,
}
return Context.getVectorType(CurType, VectorSizeBits / TypeSize,
VectorType::GenericVector);
VectorKind::Generic);
}
/// Build an ext-vector type.
@ -8267,8 +8267,7 @@ static void HandleExtVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
CurType = T;
}
static bool isPermittedNeonBaseType(QualType &Ty,
VectorType::VectorKind VecKind, Sema &S) {
static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S) {
const BuiltinType *BTy = Ty->getAs<BuiltinType>();
if (!BTy)
return false;
@ -8280,7 +8279,7 @@ static bool isPermittedNeonBaseType(QualType &Ty,
bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 ||
Triple.getArch() == llvm::Triple::aarch64_32 ||
Triple.getArch() == llvm::Triple::aarch64_be;
if (VecKind == VectorType::NeonPolyVector) {
if (VecKind == VectorKind::NeonPoly) {
if (IsPolyUnsigned) {
// AArch64 polynomial vectors are unsigned.
return BTy->getKind() == BuiltinType::UChar ||
@ -8340,7 +8339,7 @@ static bool verifyValidIntegerConstantExpr(Sema &S, const ParsedAttr &Attr,
/// not the vector size in bytes. The vector width and element type must
/// match one of the standard Neon vector types.
static void HandleNeonVectorTypeAttr(QualType &CurType, const ParsedAttr &Attr,
Sema &S, VectorType::VectorKind VecKind) {
Sema &S, VectorKind VecKind) {
bool IsTargetCUDAAndHostARM = false;
if (S.getLangOpts().CUDAIsDevice) {
const TargetInfo *AuxTI = S.getASTContext().getAuxTargetInfo();
@ -8448,11 +8447,11 @@ static void HandleArmSveVectorBitsTypeAttr(QualType &CurType, ParsedAttr &Attr,
QualType EltType = CurType->getSveEltType(S.Context);
unsigned TypeSize = S.Context.getTypeSize(EltType);
VectorType::VectorKind VecKind = VectorType::SveFixedLengthDataVector;
VectorKind VecKind = VectorKind::SveFixedLengthData;
if (BT->getKind() == BuiltinType::SveBool) {
// Predicates are represented as i8.
VecSize /= S.Context.getCharWidth() * S.Context.getCharWidth();
VecKind = VectorType::SveFixedLengthPredicateVector;
VecKind = VectorKind::SveFixedLengthPredicate;
} else
VecSize /= TypeSize;
CurType = S.Context.getVectorType(EltType, VecSize, VecKind);
@ -8462,7 +8461,7 @@ static void HandleArmMveStrictPolymorphismAttr(TypeProcessingState &State,
QualType &CurType,
ParsedAttr &Attr) {
const VectorType *VT = dyn_cast<VectorType>(CurType);
if (!VT || VT->getVectorKind() != VectorType::NeonVector) {
if (!VT || VT->getVectorKind() != VectorKind::Neon) {
State.getSema().Diag(Attr.getLoc(),
diag::err_attribute_arm_mve_polymorphism);
Attr.setInvalid();
@ -8533,7 +8532,7 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType &CurType,
return;
}
VectorType::VectorKind VecKind = VectorType::RVVFixedLengthDataVector;
VectorKind VecKind = VectorKind::RVVFixedLengthData;
VecSize /= EltSize;
CurType = S.Context.getVectorType(Info.ElementType, VecSize, VecKind);
}
@ -8770,13 +8769,12 @@ static void processTypeAttrs(TypeProcessingState &state, QualType &type,
attr.setUsedAsTypeAttr();
break;
case ParsedAttr::AT_NeonVectorType:
HandleNeonVectorTypeAttr(type, attr, state.getSema(),
VectorType::NeonVector);
HandleNeonVectorTypeAttr(type, attr, state.getSema(), VectorKind::Neon);
attr.setUsedAsTypeAttr();
break;
case ParsedAttr::AT_NeonPolyVectorType:
HandleNeonVectorTypeAttr(type, attr, state.getSema(),
VectorType::NeonPolyVector);
VectorKind::NeonPoly);
attr.setUsedAsTypeAttr();
break;
case ParsedAttr::AT_ArmSveVectorBits:

View File

@ -930,7 +930,7 @@ public:
/// By default, performs semantic analysis when building the vector type.
/// Subclasses may override this routine to provide different behavior.
QualType RebuildVectorType(QualType ElementType, unsigned NumElements,
VectorType::VectorKind VecKind);
VectorKind VecKind);
/// Build a new potentially dependently-sized extended vector type
/// given the element type and number of elements.
@ -938,8 +938,7 @@ public:
/// By default, performs semantic analysis when building the vector type.
/// Subclasses may override this routine to provide different behavior.
QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr,
SourceLocation AttributeLoc,
VectorType::VectorKind);
SourceLocation AttributeLoc, VectorKind);
/// Build a new extended vector type given the element type and
/// number of elements.
@ -14988,10 +14987,9 @@ QualType TreeTransform<Derived>::RebuildDependentAddressSpaceType(
}
template <typename Derived>
QualType
TreeTransform<Derived>::RebuildVectorType(QualType ElementType,
unsigned NumElements,
VectorType::VectorKind VecKind) {
QualType TreeTransform<Derived>::RebuildVectorType(QualType ElementType,
unsigned NumElements,
VectorKind VecKind) {
// FIXME: semantic checking!
return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
}
@ -14999,7 +14997,7 @@ TreeTransform<Derived>::RebuildVectorType(QualType ElementType,
template <typename Derived>
QualType TreeTransform<Derived>::RebuildDependentVectorType(
QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
VectorType::VectorKind VecKind) {
VectorKind VecKind) {
return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
}

View File

@ -6293,7 +6293,7 @@ const char* cases[][2] =
{"_ZN12_GLOBAL__N_117TypeSpecLocFiller22VisitObjCObjectTypeLocEN5clang17ObjCObjectTypeLocE", "(anonymous namespace)::TypeSpecLocFiller::VisitObjCObjectTypeLoc(clang::ObjCObjectTypeLoc)"},
{"_ZN5clang14TypeLocVisitorIN12_GLOBAL__N_117TypeSpecLocFillerEvE5VisitENS_7TypeLocE", "clang::TypeLocVisitor<(anonymous namespace)::TypeSpecLocFiller, void>::Visit(clang::TypeLoc)"},
{"_Z25handleObjCPointerTypeAttrRN12_GLOBAL__N_119TypeProcessingStateERN5clang13AttributeListERNS2_8QualTypeE", "handleObjCPointerTypeAttr((anonymous namespace)::TypeProcessingState&, clang::AttributeList&, clang::QualType&)"},
{"_Z24HandleNeonVectorTypeAttrRN5clang8QualTypeERKNS_13AttributeListERNS_4SemaENS_10VectorType10VectorKindEPKc", "HandleNeonVectorTypeAttr(clang::QualType&, clang::AttributeList const&, clang::Sema&, clang::VectorType::VectorKind, char const*)"},
{"_Z24HandleNeonVectorTypeAttrRN5clang8QualTypeERKNS_13AttributeListERNS_4SemaENS_10VectorType10VectorKindEPKc", "HandleNeonVectorTypeAttr(clang::QualType&, clang::AttributeList const&, clang::Sema&, clang::VectorKind, char const*)"},
{"_Z22handleFunctionTypeAttrRN12_GLOBAL__N_119TypeProcessingStateERN5clang13AttributeListERNS2_8QualTypeE", "handleFunctionTypeAttr((anonymous namespace)::TypeProcessingState&, clang::AttributeList&, clang::QualType&)"},
{"_ZN12_GLOBAL__N_121FunctionTypeUnwrapper4wrapERN5clang10ASTContextENS1_8QualTypeEj", "(anonymous namespace)::FunctionTypeUnwrapper::wrap(clang::ASTContext&, clang::QualType, unsigned int)"},
{"_ZN12_GLOBAL__N_121FunctionTypeUnwrapper4wrapERN5clang10ASTContextEPKNS1_4TypeEj", "(anonymous namespace)::FunctionTypeUnwrapper::wrap(clang::ASTContext&, clang::Type const*, unsigned int)"},
@ -8885,7 +8885,7 @@ const char* cases[][2] =
{"_ZNK5clang10ASTContext26getDependentSizedArrayTypeENS_8QualTypeEPNS_4ExprENS_9ArrayType17ArraySizeModifierEjNS_11SourceRangeE", "clang::ASTContext::getDependentSizedArrayType(clang::QualType, clang::Expr*, clang::ArraySizeModifier, unsigned int, clang::SourceRange) const"},
{"_ZNK5clang10ASTContext20getVariableArrayTypeENS_8QualTypeEPNS_4ExprENS_9ArrayType17ArraySizeModifierEjNS_11SourceRangeE", "clang::ASTContext::getVariableArrayType(clang::QualType, clang::Expr*, clang::ArraySizeModifier, unsigned int, clang::SourceRange) const"},
{"_ZNK5clang10ASTContext22getIncompleteArrayTypeENS_8QualTypeENS_9ArrayType17ArraySizeModifierEj", "clang::ASTContext::getIncompleteArrayType(clang::QualType, clang::ArraySizeModifier, unsigned int) const"},
{"_ZNK5clang10ASTContext13getVectorTypeENS_8QualTypeEjNS_10VectorType10VectorKindE", "clang::ASTContext::getVectorType(clang::QualType, unsigned int, clang::VectorType::VectorKind) const"},
{"_ZNK5clang10ASTContext13getVectorTypeENS_8QualTypeEjNS_10VectorType10VectorKindE", "clang::ASTContext::getVectorType(clang::QualType, unsigned int, clang::VectorKind) const"},
{"_ZNK5clang10ASTContext16getExtVectorTypeENS_8QualTypeEj", "clang::ASTContext::getExtVectorType(clang::QualType, unsigned int) const"},
{"_ZNK5clang10ASTContext30getDependentSizedExtVectorTypeENS_8QualTypeEPNS_4ExprENS_14SourceLocationE", "clang::ASTContext::getDependentSizedExtVectorType(clang::QualType, clang::Expr*, clang::SourceLocation) const"},
{"_ZNK5clang10ASTContext21getCanonicalParamTypeENS_8QualTypeE", "clang::ASTContext::getCanonicalParamType(clang::QualType) const"},
@ -10871,10 +10871,10 @@ const char* cases[][2] =
{"_ZN5clang27DependentSizedExtVectorTypeC1ERKNS_10ASTContextENS_8QualTypeES4_PNS_4ExprENS_14SourceLocationE", "clang::DependentSizedExtVectorType::DependentSizedExtVectorType(clang::ASTContext const&, clang::QualType, clang::QualType, clang::Expr*, clang::SourceLocation)"},
{"_ZN5clang27DependentSizedExtVectorTypeC2ERKNS_10ASTContextENS_8QualTypeES4_PNS_4ExprENS_14SourceLocationE", "clang::DependentSizedExtVectorType::DependentSizedExtVectorType(clang::ASTContext const&, clang::QualType, clang::QualType, clang::Expr*, clang::SourceLocation)"},
{"_ZN5clang27DependentSizedExtVectorType7ProfileERN4llvm16FoldingSetNodeIDERKNS_10ASTContextENS_8QualTypeEPNS_4ExprE", "clang::DependentSizedExtVectorType::Profile(llvm::FoldingSetNodeID&, clang::ASTContext const&, clang::QualType, clang::Expr*)"},
{"_ZN5clang10VectorTypeC1ENS_8QualTypeEjS1_NS0_10VectorKindE", "clang::VectorType::VectorType(clang::QualType, unsigned int, clang::QualType, clang::VectorType::VectorKind)"},
{"_ZN5clang10VectorTypeC2ENS_8QualTypeEjS1_NS0_10VectorKindE", "clang::VectorType::VectorType(clang::QualType, unsigned int, clang::QualType, clang::VectorType::VectorKind)"},
{"_ZN5clang10VectorTypeC1ENS_4Type9TypeClassENS_8QualTypeEjS3_NS0_10VectorKindE", "clang::VectorType::VectorType(clang::Type::TypeClass, clang::QualType, unsigned int, clang::QualType, clang::VectorType::VectorKind)"},
{"_ZN5clang10VectorTypeC2ENS_4Type9TypeClassENS_8QualTypeEjS3_NS0_10VectorKindE", "clang::VectorType::VectorType(clang::Type::TypeClass, clang::QualType, unsigned int, clang::QualType, clang::VectorType::VectorKind)"},
{"_ZN5clang10VectorTypeC1ENS_8QualTypeEjS1_NS0_10VectorKindE", "clang::VectorType::VectorType(clang::QualType, unsigned int, clang::QualType, clang::VectorKind)"},
{"_ZN5clang10VectorTypeC2ENS_8QualTypeEjS1_NS0_10VectorKindE", "clang::VectorType::VectorType(clang::QualType, unsigned int, clang::QualType, clang::VectorKind)"},
{"_ZN5clang10VectorTypeC1ENS_4Type9TypeClassENS_8QualTypeEjS3_NS0_10VectorKindE", "clang::VectorType::VectorType(clang::Type::TypeClass, clang::QualType, unsigned int, clang::QualType, clang::VectorKind)"},
{"_ZN5clang10VectorTypeC2ENS_4Type9TypeClassENS_8QualTypeEjS3_NS0_10VectorKindE", "clang::VectorType::VectorType(clang::Type::TypeClass, clang::QualType, unsigned int, clang::QualType, clang::VectorKind)"},
{"_ZNK5clang4Type29getArrayElementTypeNoTypeQualEv", "clang::Type::getArrayElementTypeNoTypeQual() const"},
{"_ZNK5clang4Type27getUnqualifiedDesugaredTypeEv", "clang::Type::getUnqualifiedDesugaredType() const"},
{"_ZN5clang8QualType16getDesugaredTypeES0_RKNS_10ASTContextE", "clang::QualType::getDesugaredType(clang::QualType, clang::ASTContext const&)"},