14 changes: 8 additions & 6 deletions clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3703,13 +3703,15 @@ class TagDecl : public TypeDecl,
return static_cast<TagKind>(TagDeclBits.TagDeclKind);
}

void setTagKind(TagKind TK) { TagDeclBits.TagDeclKind = TK; }
void setTagKind(TagKind TK) {
TagDeclBits.TagDeclKind = llvm::to_underlying(TK);
}

bool isStruct() const { return getTagKind() == TTK_Struct; }
bool isInterface() const { return getTagKind() == TTK_Interface; }
bool isClass() const { return getTagKind() == TTK_Class; }
bool isUnion() const { return getTagKind() == TTK_Union; }
bool isEnum() const { return getTagKind() == TTK_Enum; }
bool isStruct() const { return getTagKind() == TagTypeKind::Struct; }
bool isInterface() const { return getTagKind() == TagTypeKind::Interface; }
bool isClass() const { return getTagKind() == TagTypeKind::Class; }
bool isUnion() const { return getTagKind() == TagTypeKind::Union; }
bool isEnum() const { return getTagKind() == TagTypeKind::Enum; }

/// Is this tag type named, either directly or via being defined in
/// a typedef of this type?
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/DeclBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class alignas(8) Decl {
/// The kind of ownership a declaration has, for visibility purposes.
/// This enumeration is designed such that higher values represent higher
/// levels of name hiding.
enum class ModuleOwnershipKind : unsigned {
enum class ModuleOwnershipKind : unsigned char {
/// This declaration is not owned by a module.
Unowned,

Expand Down
12 changes: 6 additions & 6 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -5718,21 +5718,21 @@ enum class ElaboratedTypeKeyword {
};

/// The kind of a tag type.
enum TagTypeKind {
enum class TagTypeKind {
/// The "struct" keyword.
TTK_Struct,
Struct,

/// The "__interface" keyword.
TTK_Interface,
Interface,

/// The "union" keyword.
TTK_Union,
Union,

/// The "class" keyword.
TTK_Class,
Class,

/// The "enum" keyword.
TTK_Enum
Enum
};

/// A helper class for Type nodes having an ElaboratedTypeKeyword.
Expand Down
47 changes: 47 additions & 0 deletions clang/include/clang/Serialization/ASTReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -2407,6 +2407,53 @@ class ASTReader
bool isProcessingUpdateRecords() { return ProcessingUpdateRecords; }
};

/// A simple helper class to unpack an integer to bits and consuming
/// the bits in order.
class BitsUnpacker {
constexpr static uint32_t BitsIndexUpbound = 32;

public:
BitsUnpacker(uint32_t V) { updateValue(V); }
BitsUnpacker(const BitsUnpacker &) = delete;
BitsUnpacker(BitsUnpacker &&) = delete;
BitsUnpacker operator=(const BitsUnpacker &) = delete;
BitsUnpacker operator=(BitsUnpacker &&) = delete;
~BitsUnpacker() {
#ifndef NDEBUG
while (isValid())
assert(!getNextBit() && "There are unprocessed bits!");
#endif
}

void updateValue(uint32_t V) {
Value = V;
CurrentBitsIndex = 0;
}

bool getNextBit() {
assert(isValid());
return Value & (1 << CurrentBitsIndex++);
}

uint32_t getNextBits(uint32_t Width) {
assert(isValid());
assert(Width < BitsIndexUpbound);
uint32_t Ret = (Value >> CurrentBitsIndex) & ((1 << Width) - 1);
CurrentBitsIndex += Width;
return Ret;
}

bool canGetNextNBits(uint32_t Width) const {
return CurrentBitsIndex + Width < BitsIndexUpbound;
}

private:
bool isValid() const { return CurrentBitsIndex < BitsIndexUpbound; }

uint32_t Value;
uint32_t CurrentBitsIndex = ~0;
};

} // namespace clang

#endif // LLVM_CLANG_SERIALIZATION_ASTREADER_H
53 changes: 53 additions & 0 deletions clang/include/clang/Serialization/ASTWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,59 @@ class PCHGenerator : public SemaConsumer {
bool hasEmittedPCH() const { return Buffer->IsComplete; }
};

/// A simple helper class to pack several bits in order into (a) 32 bit
/// integer(s).
class BitsPacker {
constexpr static uint32_t BitIndexUpbound = 32u;

public:
BitsPacker() = default;
BitsPacker(const BitsPacker &) = delete;
BitsPacker(BitsPacker &&) = delete;
BitsPacker operator=(const BitsPacker &) = delete;
BitsPacker operator=(BitsPacker &&) = delete;
~BitsPacker() {
assert(!hasUnconsumedValues() && "There are unprocessed bits!");
}

void addBit(bool Value) { addBits(Value, 1); }
void addBits(uint32_t Value, uint32_t BitsWidth) {
assert(BitsWidth < BitIndexUpbound);
assert((Value < (1u << BitsWidth)) && "Passing narrower bit width!");

if (CurrentBitIndex + BitsWidth >= BitIndexUpbound) {
Values.push_back(0);
CurrentBitIndex = 0;
}

assert(CurrentBitIndex < BitIndexUpbound);
Values.back() |= Value << CurrentBitIndex;
CurrentBitIndex += BitsWidth;
}

bool hasUnconsumedValues() const {
return ConsumingValueIndex < Values.size();
}
uint32_t getNextValue() {
assert(hasUnconsumedValues());
return Values[ConsumingValueIndex++];
}

// We can convert the packer to an uint32_t if there is only one values.
operator uint32_t() {
assert(Values.size() == 1);
return getNextValue();
}

private:
SmallVector<uint64_t, 4> Values;
uint16_t ConsumingValueIndex = 0;
// Initialize CurrentBitIndex with an invalid value
// to make it easier to update Values. See the implementation
// of `addBits` to see the details.
uint16_t CurrentBitIndex = BitIndexUpbound;
};

} // namespace clang

#endif // LLVM_CLANG_SERIALIZATION_ASTWRITER_H
12 changes: 6 additions & 6 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6525,12 +6525,12 @@ bool ASTContext::isSameEntity(const NamedDecl *X, const NamedDecl *Y) const {
if (const auto *TagX = dyn_cast<TagDecl>(X)) {
const auto *TagY = cast<TagDecl>(Y);
return (TagX->getTagKind() == TagY->getTagKind()) ||
((TagX->getTagKind() == TTK_Struct ||
TagX->getTagKind() == TTK_Class ||
TagX->getTagKind() == TTK_Interface) &&
(TagY->getTagKind() == TTK_Struct ||
TagY->getTagKind() == TTK_Class ||
TagY->getTagKind() == TTK_Interface));
((TagX->getTagKind() == TagTypeKind::Struct ||
TagX->getTagKind() == TagTypeKind::Class ||
TagX->getTagKind() == TagTypeKind::Interface) &&
(TagY->getTagKind() == TagTypeKind::Struct ||
TagY->getTagKind() == TagTypeKind::Class ||
TagY->getTagKind() == TagTypeKind::Interface));
}

// Functions with the same type and linkage match.
Expand Down
12 changes: 6 additions & 6 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4639,8 +4639,8 @@ TagDecl::TagDecl(Kind DK, TagKind TK, const ASTContext &C, DeclContext *DC,
SourceLocation StartL)
: TypeDecl(DK, DC, L, Id, StartL), DeclContext(DK), redeclarable_base(C),
TypedefNameDeclOrQualifier((TypedefNameDecl *)nullptr) {
assert((DK != Enum || TK == TTK_Enum) &&
"EnumDecl not matched with TTK_Enum");
assert((DK != Enum || TK == TagTypeKind::Enum) &&
"EnumDecl not matched with TagTypeKind::Enum");
setPreviousDecl(PrevDecl);
setTagKind(TK);
setCompleteDefinition(false);
Expand Down Expand Up @@ -4773,7 +4773,7 @@ void TagDecl::setTemplateParameterListsInfo(
EnumDecl::EnumDecl(ASTContext &C, DeclContext *DC, SourceLocation StartLoc,
SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl,
bool Scoped, bool ScopedUsingClassTag, bool Fixed)
: TagDecl(Enum, TTK_Enum, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
: TagDecl(Enum, TagTypeKind::Enum, C, DC, IdLoc, Id, PrevDecl, StartLoc) {
assert(Scoped || !ScopedUsingClassTag);
IntegerType = nullptr;
setNumPositiveBits(0);
Expand Down Expand Up @@ -4962,9 +4962,9 @@ RecordDecl *RecordDecl::Create(const ASTContext &C, TagKind TK, DeclContext *DC,
}

RecordDecl *RecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) {
RecordDecl *R =
new (C, ID) RecordDecl(Record, TTK_Struct, C, nullptr, SourceLocation(),
SourceLocation(), nullptr, nullptr);
RecordDecl *R = new (C, ID)
RecordDecl(Record, TagTypeKind::Struct, C, nullptr, SourceLocation(),
SourceLocation(), nullptr, nullptr);
R->setMayHaveOutOfDateDef(C.getLangOpts().Modules);
return R;
}
Expand Down
22 changes: 11 additions & 11 deletions clang/lib/AST/DeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ CXXRecordDecl::CreateLambda(const ASTContext &C, DeclContext *DC,
TypeSourceInfo *Info, SourceLocation Loc,
unsigned DependencyKind, bool IsGeneric,
LambdaCaptureDefault CaptureDefault) {
auto *R = new (C, DC) CXXRecordDecl(CXXRecord, TTK_Class, C, DC, Loc, Loc,
nullptr, nullptr);
auto *R = new (C, DC) CXXRecordDecl(CXXRecord, TagTypeKind::Class, C, DC, Loc,
Loc, nullptr, nullptr);
R->setBeingDefined(true);
R->DefinitionData = new (C) struct LambdaDefinitionData(
R, Info, DependencyKind, IsGeneric, CaptureDefault);
Expand All @@ -162,9 +162,9 @@ CXXRecordDecl::CreateLambda(const ASTContext &C, DeclContext *DC,

CXXRecordDecl *
CXXRecordDecl::CreateDeserialized(const ASTContext &C, unsigned ID) {
auto *R = new (C, ID) CXXRecordDecl(
CXXRecord, TTK_Struct, C, nullptr, SourceLocation(), SourceLocation(),
nullptr, nullptr);
auto *R = new (C, ID)
CXXRecordDecl(CXXRecord, TagTypeKind::Struct, C, nullptr,
SourceLocation(), SourceLocation(), nullptr, nullptr);
R->setMayHaveOutOfDateDef(false);
return R;
}
Expand Down Expand Up @@ -692,11 +692,10 @@ bool CXXRecordDecl::lambdaIsDefaultConstructibleAndAssignable() const {
}

void CXXRecordDecl::addedMember(Decl *D) {
if (!D->isImplicit() &&
!isa<FieldDecl>(D) &&
!isa<IndirectFieldDecl>(D) &&
(!isa<TagDecl>(D) || cast<TagDecl>(D)->getTagKind() == TTK_Class ||
cast<TagDecl>(D)->getTagKind() == TTK_Interface))
if (!D->isImplicit() && !isa<FieldDecl>(D) && !isa<IndirectFieldDecl>(D) &&
(!isa<TagDecl>(D) ||
cast<TagDecl>(D)->getTagKind() == TagTypeKind::Class ||
cast<TagDecl>(D)->getTagKind() == TagTypeKind::Interface))
data().HasOnlyCMembers = false;

// Ignore friends and invalid declarations.
Expand Down Expand Up @@ -1510,7 +1509,8 @@ void CXXRecordDecl::setTrivialForCallFlags(CXXMethodDecl *D) {
}

bool CXXRecordDecl::isCLike() const {
if (getTagKind() == TTK_Class || getTagKind() == TTK_Interface ||
if (getTagKind() == TagTypeKind::Class ||
getTagKind() == TagTypeKind::Interface ||
!TemplateOrInstantiation.isNull())
return false;
if (!hasDefinition())
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/DeclTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK, TagKind TK,

ClassTemplateSpecializationDecl::ClassTemplateSpecializationDecl(ASTContext &C,
Kind DK)
: CXXRecordDecl(DK, TTK_Struct, C, nullptr, SourceLocation(),
: CXXRecordDecl(DK, TagTypeKind::Struct, C, nullptr, SourceLocation(),
SourceLocation(), nullptr, nullptr),
SpecializationKind(TSK_Undeclared) {}

Expand Down
104 changes: 54 additions & 50 deletions clang/lib/AST/MicrosoftMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1312,9 +1312,9 @@ void MicrosoftCXXNameMangler::mangleNestedName(GlobalDecl GD) {
if (PointersAre64Bit)
Out << 'E';
Out << 'A';
mangleArtificialTagType(TTK_Struct,
Discriminate("__block_literal", Discriminator,
ParameterDiscriminator));
mangleArtificialTagType(TagTypeKind::Struct,
Discriminate("__block_literal", Discriminator,
ParameterDiscriminator));
Out << "@Z";

// If the effective context was a Record, we have fully mangled the
Expand Down Expand Up @@ -1974,9 +1974,9 @@ void MicrosoftCXXNameMangler::mangleObjCProtocol(const ObjCProtocolDecl *PD) {

Stream << "?$";
Extra.mangleSourceName("Protocol");
Extra.mangleArtificialTagType(TTK_Struct, PD->getName());
Extra.mangleArtificialTagType(TagTypeKind::Struct, PD->getName());

mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__ObjC"});
mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {"__ObjC"});
}

void MicrosoftCXXNameMangler::mangleObjCLifetime(const QualType Type,
Expand Down Expand Up @@ -2005,7 +2005,7 @@ void MicrosoftCXXNameMangler::mangleObjCLifetime(const QualType Type,
Extra.manglePointerExtQualifiers(Quals, Type);
Extra.mangleType(Type, Range);

mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__ObjC"});
mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {"__ObjC"});
}

void MicrosoftCXXNameMangler::mangleObjCKindOfType(const ObjCObjectType *T,
Expand All @@ -2022,7 +2022,7 @@ void MicrosoftCXXNameMangler::mangleObjCKindOfType(const ObjCObjectType *T,
->castAs<ObjCObjectType>(),
Quals, Range);

mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__ObjC"});
mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {"__ObjC"});
}

void MicrosoftCXXNameMangler::mangleQualifiers(Qualifiers Quals,
Expand Down Expand Up @@ -2223,7 +2223,8 @@ void MicrosoftCXXNameMangler::manglePassObjectSizeArg(
if (Found == FunArgBackReferences.end()) {
std::string Name =
Dynamic ? "__pass_dynamic_object_size" : "__pass_object_size";
mangleArtificialTagType(TTK_Enum, Name + llvm::utostr(Type), {"__clang"});
mangleArtificialTagType(TagTypeKind::Enum, Name + llvm::utostr(Type),
{"__clang"});

if (FunArgBackReferences.size() < 10) {
size_t Size = FunArgBackReferences.size();
Expand Down Expand Up @@ -2304,7 +2305,7 @@ void MicrosoftCXXNameMangler::mangleAddressSpaceType(QualType T,

Extra.mangleType(T, Range, QMM_Escape);
mangleQualifiers(Qualifiers(), false);
mangleArtificialTagType(TTK_Struct, ASMangling, {"__clang"});
mangleArtificialTagType(TagTypeKind::Struct, ASMangling, {"__clang"});
}

void MicrosoftCXXNameMangler::mangleType(QualType T, SourceRange Range,
Expand Down Expand Up @@ -2486,13 +2487,13 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers,
llvm_unreachable("placeholder types shouldn't get to name mangling");

case BuiltinType::ObjCId:
mangleArtificialTagType(TTK_Struct, "objc_object");
mangleArtificialTagType(TagTypeKind::Struct, "objc_object");
break;
case BuiltinType::ObjCClass:
mangleArtificialTagType(TTK_Struct, "objc_class");
mangleArtificialTagType(TagTypeKind::Struct, "objc_class");
break;
case BuiltinType::ObjCSel:
mangleArtificialTagType(TTK_Struct, "objc_selector");
mangleArtificialTagType(TagTypeKind::Struct, "objc_selector");
break;

#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
Expand All @@ -2502,27 +2503,27 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers,
#include "clang/Basic/OpenCLImageTypes.def"
case BuiltinType::OCLSampler:
Out << "PA";
mangleArtificialTagType(TTK_Struct, "ocl_sampler");
mangleArtificialTagType(TagTypeKind::Struct, "ocl_sampler");
break;
case BuiltinType::OCLEvent:
Out << "PA";
mangleArtificialTagType(TTK_Struct, "ocl_event");
mangleArtificialTagType(TagTypeKind::Struct, "ocl_event");
break;
case BuiltinType::OCLClkEvent:
Out << "PA";
mangleArtificialTagType(TTK_Struct, "ocl_clkevent");
mangleArtificialTagType(TagTypeKind::Struct, "ocl_clkevent");
break;
case BuiltinType::OCLQueue:
Out << "PA";
mangleArtificialTagType(TTK_Struct, "ocl_queue");
mangleArtificialTagType(TagTypeKind::Struct, "ocl_queue");
break;
case BuiltinType::OCLReserveID:
Out << "PA";
mangleArtificialTagType(TTK_Struct, "ocl_reserveid");
mangleArtificialTagType(TagTypeKind::Struct, "ocl_reserveid");
break;
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id: \
mangleArtificialTagType(TTK_Struct, "ocl_" #ExtType); \
#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
case BuiltinType::Id: \
mangleArtificialTagType(TagTypeKind::Struct, "ocl_" #ExtType); \
break;
#include "clang/Basic/OpenCLExtensionTypes.def"

Expand All @@ -2531,26 +2532,26 @@ void MicrosoftCXXNameMangler::mangleType(const BuiltinType *T, Qualifiers,
break;

case BuiltinType::Float16:
mangleArtificialTagType(TTK_Struct, "_Float16", {"__clang"});
mangleArtificialTagType(TagTypeKind::Struct, "_Float16", {"__clang"});
break;

case BuiltinType::Half:
if (!getASTContext().getLangOpts().HLSL)
mangleArtificialTagType(TTK_Struct, "_Half", {"__clang"});
mangleArtificialTagType(TagTypeKind::Struct, "_Half", {"__clang"});
else if (getASTContext().getLangOpts().NativeHalfType)
Out << "$f16@";
else
Out << "$halff@";
break;

case BuiltinType::BFloat16:
mangleArtificialTagType(TTK_Struct, "__bf16", {"__clang"});
mangleArtificialTagType(TagTypeKind::Struct, "__bf16", {"__clang"});
break;

#define WASM_REF_TYPE(InternalName, MangledName, Id, SingletonId, AS) \
case BuiltinType::Id: \
mangleArtificialTagType(TTK_Struct, MangledName); \
mangleArtificialTagType(TTK_Struct, MangledName, {"__clang"}); \
mangleArtificialTagType(TagTypeKind::Struct, MangledName); \
mangleArtificialTagType(TagTypeKind::Struct, MangledName, {"__clang"}); \
break;

#include "clang/Basic/WebAssemblyReferenceTypes.def"
Expand Down Expand Up @@ -2917,19 +2918,19 @@ void MicrosoftCXXNameMangler::mangleType(const UnresolvedUsingType *T,
// <enum-type> ::= W4 <name>
void MicrosoftCXXNameMangler::mangleTagTypeKind(TagTypeKind TTK) {
switch (TTK) {
case TTK_Union:
Out << 'T';
break;
case TTK_Struct:
case TTK_Interface:
Out << 'U';
break;
case TTK_Class:
Out << 'V';
break;
case TTK_Enum:
Out << "W4";
break;
case TagTypeKind::Union:
Out << 'T';
break;
case TagTypeKind::Struct:
case TagTypeKind::Interface:
Out << 'U';
break;
case TagTypeKind::Class:
Out << 'V';
break;
case TagTypeKind::Enum:
Out << "W4";
break;
}
}
void MicrosoftCXXNameMangler::mangleType(const EnumType *T, Qualifiers,
Expand Down Expand Up @@ -3139,11 +3140,11 @@ void MicrosoftCXXNameMangler::mangleType(const ComplexType *T, Qualifiers,
Extra.mangleSourceName("_Complex");
Extra.mangleType(ElementType, Range, QMM_Escape);

mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {"__clang"});
}

// Returns true for types that mangleArtificialTagType() gets called for with
// TTK_Union, TTK_Struct, TTK_Class and where compatibility with MSVC's
// TagTypeKind Union, Struct, Class and where compatibility with MSVC's
// mangling matters.
// (It doesn't matter for Objective-C types and the like that cl.exe doesn't
// support.)
Expand Down Expand Up @@ -3176,14 +3177,17 @@ void MicrosoftCXXNameMangler::mangleType(const VectorType *T, Qualifiers Quals,
if (!isa<ExtVectorType>(T)) {
if (getASTContext().getTargetInfo().getTriple().isX86() && ET) {
if (Width == 64 && ET->getKind() == BuiltinType::LongLong) {
mangleArtificialTagType(TTK_Union, "__m64");
mangleArtificialTagType(TagTypeKind::Union, "__m64");
} else if (Width >= 128) {
if (ET->getKind() == BuiltinType::Float)
mangleArtificialTagType(TTK_Union, "__m" + llvm::utostr(Width));
mangleArtificialTagType(TagTypeKind::Union,
"__m" + llvm::utostr(Width));
else if (ET->getKind() == BuiltinType::LongLong)
mangleArtificialTagType(TTK_Union, "__m" + llvm::utostr(Width) + 'i');
mangleArtificialTagType(TagTypeKind::Union,
"__m" + llvm::utostr(Width) + 'i');
else if (ET->getKind() == BuiltinType::Double)
mangleArtificialTagType(TTK_Struct, "__m" + llvm::utostr(Width) + 'd');
mangleArtificialTagType(TagTypeKind::Struct,
"__m" + llvm::utostr(Width) + 'd');
}
}
}
Expand All @@ -3203,7 +3207,7 @@ void MicrosoftCXXNameMangler::mangleType(const VectorType *T, Qualifiers Quals,
Range, QMM_Escape);
Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->getNumElements()));

mangleArtificialTagType(TTK_Union, TemplateMangling, {"__clang"});
mangleArtificialTagType(TagTypeKind::Union, TemplateMangling, {"__clang"});
}
}

Expand Down Expand Up @@ -3259,7 +3263,7 @@ void MicrosoftCXXNameMangler::mangleType(const DependentAddressSpaceType *T,
void MicrosoftCXXNameMangler::mangleType(const ObjCInterfaceType *T, Qualifiers,
SourceRange) {
// ObjC interfaces have structs underlying them.
mangleTagTypeKind(TTK_Struct);
mangleTagTypeKind(TagTypeKind::Struct);
mangleName(T->getDecl());
}

Expand All @@ -3279,7 +3283,7 @@ void MicrosoftCXXNameMangler::mangleType(const ObjCObjectType *T,
TemplateArgBackReferences.swap(OuterTemplateArgsContext);
NameBackReferences.swap(OuterTemplateContext);

mangleTagTypeKind(TTK_Struct);
mangleTagTypeKind(TagTypeKind::Struct);

Out << "?$";
if (T->isObjCId())
Expand Down Expand Up @@ -3427,7 +3431,7 @@ void MicrosoftCXXNameMangler::mangleType(const AtomicType *T, Qualifiers,
Extra.mangleSourceName("_Atomic");
Extra.mangleType(ValueType, Range, QMM_Escape);

mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {"__clang"});
}

void MicrosoftCXXNameMangler::mangleType(const PipeType *T, Qualifiers,
Expand All @@ -3442,7 +3446,7 @@ void MicrosoftCXXNameMangler::mangleType(const PipeType *T, Qualifiers,
Extra.mangleType(ElementType, Range, QMM_Escape);
Extra.mangleIntegerLiteral(llvm::APSInt::get(T->isReadOnly()));

mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {"__clang"});
}

void MicrosoftMangleContextImpl::mangleCXXName(GlobalDecl GD,
Expand Down Expand Up @@ -3482,7 +3486,7 @@ void MicrosoftCXXNameMangler::mangleType(const BitIntType *T, Qualifiers,
Extra.mangleSourceName("_BitInt");
Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->getNumBits()));

mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
mangleArtificialTagType(TagTypeKind::Struct, TemplateMangling, {"__clang"});
}

void MicrosoftCXXNameMangler::mangleType(const DependentBitIntType *T,
Expand Down
9 changes: 6 additions & 3 deletions clang/lib/AST/RecordLayoutBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2267,9 +2267,12 @@ ItaniumRecordLayoutBuilder::updateExternalFieldOffset(const FieldDecl *Field,
/// \returns diagnostic %select index.
static unsigned getPaddingDiagFromTagKind(TagTypeKind Tag) {
switch (Tag) {
case TTK_Struct: return 0;
case TTK_Interface: return 1;
case TTK_Class: return 2;
case TagTypeKind::Struct:
return 0;
case TagTypeKind::Interface:
return 1;
case TagTypeKind::Class:
return 2;
default: llvm_unreachable("Invalid tag kind for field padding diagnostic!");
}
}
Expand Down
35 changes: 20 additions & 15 deletions clang/lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3035,11 +3035,16 @@ TypeWithKeyword::getKeywordForTypeSpec(unsigned TypeSpec) {
TagTypeKind
TypeWithKeyword::getTagTypeKindForTypeSpec(unsigned TypeSpec) {
switch(TypeSpec) {
case TST_class: return TTK_Class;
case TST_struct: return TTK_Struct;
case TST_interface: return TTK_Interface;
case TST_union: return TTK_Union;
case TST_enum: return TTK_Enum;
case TST_class:
return TagTypeKind::Class;
case TST_struct:
return TagTypeKind::Struct;
case TST_interface:
return TagTypeKind::Interface;
case TST_union:
return TagTypeKind::Union;
case TST_enum:
return TagTypeKind::Enum;
}

llvm_unreachable("Type specifier is not a tag type kind.");
Expand All @@ -3048,15 +3053,15 @@ TypeWithKeyword::getTagTypeKindForTypeSpec(unsigned TypeSpec) {
ElaboratedTypeKeyword
TypeWithKeyword::getKeywordForTagTypeKind(TagTypeKind Kind) {
switch (Kind) {
case TTK_Class:
case TagTypeKind::Class:
return ElaboratedTypeKeyword::Class;
case TTK_Struct:
case TagTypeKind::Struct:
return ElaboratedTypeKeyword::Struct;
case TTK_Interface:
case TagTypeKind::Interface:
return ElaboratedTypeKeyword::Interface;
case TTK_Union:
case TagTypeKind::Union:
return ElaboratedTypeKeyword::Union;
case TTK_Enum:
case TagTypeKind::Enum:
return ElaboratedTypeKeyword::Enum;
}
llvm_unreachable("Unknown tag type kind.");
Expand All @@ -3066,15 +3071,15 @@ TagTypeKind
TypeWithKeyword::getTagTypeKindForKeyword(ElaboratedTypeKeyword Keyword) {
switch (Keyword) {
case ElaboratedTypeKeyword::Class:
return TTK_Class;
return TagTypeKind::Class;
case ElaboratedTypeKeyword::Struct:
return TTK_Struct;
return TagTypeKind::Struct;
case ElaboratedTypeKeyword::Interface:
return TTK_Interface;
return TagTypeKind::Interface;
case ElaboratedTypeKeyword::Union:
return TTK_Union;
return TagTypeKind::Union;
case ElaboratedTypeKeyword::Enum:
return TTK_Enum;
return TagTypeKind::Enum;
case ElaboratedTypeKeyword::None: // Fall through.
case ElaboratedTypeKeyword::Typename:
llvm_unreachable("Elaborated type keyword is not a tag type kind.");
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Basic/Targets/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,12 @@ bool AArch64TargetInfo::validateAsmConstraint(
Name += 2;
return true;
}
if (Name[1] == 'c' && (Name[2] == 'i' || Name[2] == 'j')) {
// Gpr registers ("Uci"=w8-11, "Ucj"=w12-15)
Info.setAllowsRegister();
Name += 2;
return true;
}
// Ump: A memory address suitable for ldp/stp in SI, DI, SF and DF modes.
// Utf: A memory address suitable for ldp/stp in TF mode.
// Usa: An absolute symbolic address.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9994,7 +9994,7 @@ Value *CodeGenFunction::EmitAArch64SVEBuiltinExpr(unsigned BuiltinID,
const CallExpr *E) {
llvm::Type *Ty = ConvertType(E->getType());
if (BuiltinID >= SVE::BI__builtin_sve_reinterpret_s8_s8 &&
BuiltinID <= SVE::BI__builtin_sve_reinterpret_f64_f64) {
BuiltinID <= SVE::BI__builtin_sve_reinterpret_f64_f64_x4) {
Value *Val = EmitScalarExpr(E->getArg(0));
return EmitSVEReinterpret(Val, Ty);
}
Expand Down
14 changes: 6 additions & 8 deletions clang/lib/CodeGen/CGObjCMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5757,10 +5757,9 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
// id self;
// Class cls;
// }
RecordDecl *RD = RecordDecl::Create(Ctx, TTK_Struct,
Ctx.getTranslationUnitDecl(),
SourceLocation(), SourceLocation(),
&Ctx.Idents.get("_objc_super"));
RecordDecl *RD = RecordDecl::Create(
Ctx, TagTypeKind::Struct, Ctx.getTranslationUnitDecl(), SourceLocation(),
SourceLocation(), &Ctx.Idents.get("_objc_super"));
RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(),
nullptr, Ctx.getObjCIdType(), nullptr, nullptr,
false, ICIS_NoInit));
Expand Down Expand Up @@ -6110,10 +6109,9 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
// };

// First the clang type for struct _message_ref_t
RecordDecl *RD = RecordDecl::Create(Ctx, TTK_Struct,
Ctx.getTranslationUnitDecl(),
SourceLocation(), SourceLocation(),
&Ctx.Idents.get("_message_ref_t"));
RecordDecl *RD = RecordDecl::Create(
Ctx, TagTypeKind::Struct, Ctx.getTranslationUnitDecl(), SourceLocation(),
SourceLocation(), &Ctx.Idents.get("_message_ref_t"));
RD->addDecl(FieldDecl::Create(Ctx, RD, SourceLocation(), SourceLocation(),
nullptr, Ctx.VoidPtrTy, nullptr, nullptr, false,
ICIS_NoInit));
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGOpenMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3041,7 +3041,7 @@ createKmpTaskTRecordDecl(CodeGenModule &CGM, OpenMPDirectiveKind Kind,
// kmp_int32 liter;
// void * reductions;
// };
RecordDecl *UD = C.buildImplicitRecord("kmp_cmplrdata_t", TTK_Union);
RecordDecl *UD = C.buildImplicitRecord("kmp_cmplrdata_t", TagTypeKind::Union);
UD->startDefinition();
addFieldToRecordDecl(C, UD, KmpInt32Ty);
addFieldToRecordDecl(C, UD, KmpRoutineEntryPointerQTy);
Expand Down
9 changes: 1 addition & 8 deletions clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ void CGOpenMPRuntimeGPU::emitKernelDeinit(CodeGenFunction &CGF,
// This is temporary until we remove the fixed sized buffer.
ASTContext &C = CGM.getContext();
RecordDecl *StaticRD = C.buildImplicitRecord(
"_openmp_teams_reduction_type_$_", RecordDecl::TagKind::TTK_Union);
"_openmp_teams_reduction_type_$_", RecordDecl::TagKind::Union);
StaticRD->startDefinition();
for (const RecordDecl *TeamReductionRec : TeamsReductions) {
QualType RecTy = C.getRecordType(TeamReductionRec);
Expand Down Expand Up @@ -3081,14 +3081,7 @@ void CGOpenMPRuntimeGPU::emitReduction(
++IRHS;
}
};
llvm::Value *EndArgs[] = {ThreadId};
RegionCodeGenTy RCG(CodeGen);
NVPTXActionTy Action(
nullptr, std::nullopt,
OMPBuilder.getOrCreateRuntimeFunction(
CGM.getModule(), OMPRTL___kmpc_nvptx_end_reduce_nowait),
EndArgs);
RCG.setAction(Action);
RCG(CGF);
// There is no need to emit line number for unconditional branch.
(void)ApplyDebugLocation::CreateEmpty(CGF);
Expand Down
37 changes: 18 additions & 19 deletions clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -864,9 +864,9 @@ RewriteModernObjC::getIvarAccessString(ObjCIvarDecl *D) {
CDecl = CatDecl->getClassInterface();
std::string RecName = std::string(CDecl->getName());
RecName += "_IMPL";
RecordDecl *RD =
RecordDecl::Create(*Context, TTK_Struct, TUDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get(RecName));
RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get(RecName));
QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD));
unsigned UnsignedIntSize =
static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
Expand Down Expand Up @@ -2978,9 +2978,9 @@ Stmt *RewriteModernObjC::RewriteObjCDictionaryLiteralExpr(ObjCDictionaryLiteral
// };
QualType RewriteModernObjC::getSuperStructType() {
if (!SuperStructDecl) {
SuperStructDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__rw_objc_super"));
SuperStructDecl = RecordDecl::Create(
*Context, TagTypeKind::Struct, TUDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get("__rw_objc_super"));
QualType FieldTypes[2];

// struct objc_object *object;
Expand All @@ -3006,9 +3006,9 @@ QualType RewriteModernObjC::getSuperStructType() {

QualType RewriteModernObjC::getConstantStringStructType() {
if (!ConstantStringDecl) {
ConstantStringDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__NSConstantStringImpl"));
ConstantStringDecl = RecordDecl::Create(
*Context, TagTypeKind::Struct, TUDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get("__NSConstantStringImpl"));
QualType FieldTypes[4];

// struct objc_object *receiver;
Expand Down Expand Up @@ -3782,10 +3782,9 @@ QualType RewriteModernObjC::SynthesizeBitfieldGroupStructType(
SmallVectorImpl<ObjCIvarDecl *> &IVars) {
std::string StructTagName;
ObjCIvarBitfieldGroupType(IV, StructTagName);
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct,
Context->getTranslationUnitDecl(),
SourceLocation(), SourceLocation(),
&Context->Idents.get(StructTagName));
RecordDecl *RD = RecordDecl::Create(
*Context, TagTypeKind::Struct, Context->getTranslationUnitDecl(),
SourceLocation(), SourceLocation(), &Context->Idents.get(StructTagName));
for (unsigned i=0, e = IVars.size(); i < e; i++) {
ObjCIvarDecl *Ivar = IVars[i];
RD->addDecl(FieldDecl::Create(*Context, RD, SourceLocation(), SourceLocation(),
Expand Down Expand Up @@ -4588,7 +4587,7 @@ Stmt *RewriteModernObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
// FTP will be null for closures that don't take arguments.

RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__block_impl"));
QualType PtrBlock = Context->getPointerType(Context->getTagDeclType(RD));
Expand Down Expand Up @@ -5347,9 +5346,9 @@ Stmt *RewriteModernObjC::SynthBlockInitExpr(BlockExpr *Exp,
RewriteByRefString(RecName, Name, ND, true);
IdentifierInfo *II = &Context->Idents.get(RecName.c_str()
+ sizeof("struct"));
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
II);
RecordDecl *RD =
RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(), II);
assert(RD && "SynthBlockInitExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));

Expand Down Expand Up @@ -7508,8 +7507,8 @@ Stmt *RewriteModernObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
std::string RecName = std::string(CDecl->getName());
RecName += "_IMPL";
RecordDecl *RD = RecordDecl::Create(
*Context, TTK_Struct, TUDecl, SourceLocation(), SourceLocation(),
&Context->Idents.get(RecName));
*Context, TagTypeKind::Struct, TUDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get(RecName));
QualType PtrStructIMPL = Context->getPointerType(Context->getTagDeclType(RD));
unsigned UnsignedIntSize =
static_cast<unsigned>(Context->getTypeSize(Context->UnsignedIntTy));
Expand Down
32 changes: 16 additions & 16 deletions clang/lib/Frontend/Rewrite/RewriteObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2357,7 +2357,7 @@ void RewriteObjC::SynthMsgSendFunctionDecl() {
void RewriteObjC::SynthMsgSendSuperFunctionDecl() {
IdentifierInfo *msgSendIdent = &Context->Idents.get("objc_msgSendSuper");
SmallVector<QualType, 16> ArgTys;
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("objc_super"));
QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
Expand Down Expand Up @@ -2400,7 +2400,7 @@ void RewriteObjC::SynthMsgSendSuperStretFunctionDecl() {
IdentifierInfo *msgSendIdent =
&Context->Idents.get("objc_msgSendSuper_stret");
SmallVector<QualType, 16> ArgTys;
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("objc_super"));
QualType argT = Context->getPointerType(Context->getTagDeclType(RD));
Expand Down Expand Up @@ -2531,7 +2531,7 @@ Stmt *RewriteObjC::RewriteObjCStringLiteral(ObjCStringLiteral *Exp) {
// struct objc_super { struct objc_object *receiver; struct objc_class *super; };
QualType RewriteObjC::getSuperStructType() {
if (!SuperStructDecl) {
SuperStructDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SuperStructDecl = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("objc_super"));
QualType FieldTypes[2];
Expand Down Expand Up @@ -2559,9 +2559,9 @@ QualType RewriteObjC::getSuperStructType() {

QualType RewriteObjC::getConstantStringStructType() {
if (!ConstantStringDecl) {
ConstantStringDecl = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__NSConstantStringImpl"));
ConstantStringDecl = RecordDecl::Create(
*Context, TagTypeKind::Struct, TUDecl, SourceLocation(),
SourceLocation(), &Context->Idents.get("__NSConstantStringImpl"));
QualType FieldTypes[4];

// struct objc_object *receiver;
Expand Down Expand Up @@ -3755,7 +3755,7 @@ Stmt *RewriteObjC::SynthesizeBlockCall(CallExpr *Exp, const Expr *BlockExp) {
const FunctionProtoType *FTP = dyn_cast<FunctionProtoType>(FT);
// FTP will be null for closures that don't take arguments.

RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
RecordDecl *RD = RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(),
&Context->Idents.get("__block_impl"));
QualType PtrBlock = Context->getPointerType(Context->getTagDeclType(RD));
Expand Down Expand Up @@ -4483,9 +4483,9 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
RewriteByRefString(RecName, Name, ND, true);
IdentifierInfo *II = &Context->Idents.get(RecName.c_str()
+ sizeof("struct"));
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
II);
RecordDecl *RD =
RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(), II);
assert(RD && "SynthBlockInitExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));

Expand Down Expand Up @@ -5821,9 +5821,9 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
std::string(clsDeclared->getIdentifier()->getName());
RecName += "_IMPL";
IdentifierInfo *II = &Context->Idents.get(RecName);
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
II);
RecordDecl *RD =
RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,
Expand Down Expand Up @@ -5862,9 +5862,9 @@ Stmt *RewriteObjCFragileABI::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV) {
std::string(clsDeclared->getIdentifier()->getName());
RecName += "_IMPL";
IdentifierInfo *II = &Context->Idents.get(RecName);
RecordDecl *RD = RecordDecl::Create(*Context, TTK_Struct, TUDecl,
SourceLocation(), SourceLocation(),
II);
RecordDecl *RD =
RecordDecl::Create(*Context, TagTypeKind::Struct, TUDecl,
SourceLocation(), SourceLocation(), II);
assert(RD && "RewriteObjCIvarRefExpr(): Can't find RecordDecl");
QualType castT = Context->getPointerType(Context->getTagDeclType(RD));
CastExpr *castExpr = NoTypeInfoCStyleCastExpr(Context, castT,
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/Index/IndexSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@ SymbolInfo index::getSymbolInfo(const Decl *D) {

if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
switch (TD->getTagKind()) {
case TTK_Struct:
case TagTypeKind::Struct:
Info.Kind = SymbolKind::Struct; break;
case TTK_Union:
case TagTypeKind::Union:
Info.Kind = SymbolKind::Union; break;
case TTK_Class:
case TagTypeKind::Class:
Info.Kind = SymbolKind::Class;
Info.Lang = SymbolLanguage::CXX;
break;
case TTK_Interface:
case TagTypeKind::Interface:
Info.Kind = SymbolKind::Protocol;
Info.Lang = SymbolLanguage::CXX;
break;
case TTK_Enum:
case TagTypeKind::Enum:
Info.Kind = SymbolKind::Enum; break;
}

Expand Down
46 changes: 31 additions & 15 deletions clang/lib/Index/USRGeneration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,35 +519,51 @@ void USRGenerator::VisitTagDecl(const TagDecl *D) {
AlreadyStarted = true;

switch (D->getTagKind()) {
case TTK_Interface:
case TTK_Class:
case TTK_Struct: Out << "@ST"; break;
case TTK_Union: Out << "@UT"; break;
case TTK_Enum: llvm_unreachable("enum template");
case TagTypeKind::Interface:
case TagTypeKind::Class:
case TagTypeKind::Struct:
Out << "@ST";
break;
case TagTypeKind::Union:
Out << "@UT";
break;
case TagTypeKind::Enum:
llvm_unreachable("enum template");
}
VisitTemplateParameterList(ClassTmpl->getTemplateParameters());
} else if (const ClassTemplatePartialSpecializationDecl *PartialSpec
= dyn_cast<ClassTemplatePartialSpecializationDecl>(CXXRecord)) {
AlreadyStarted = true;

switch (D->getTagKind()) {
case TTK_Interface:
case TTK_Class:
case TTK_Struct: Out << "@SP"; break;
case TTK_Union: Out << "@UP"; break;
case TTK_Enum: llvm_unreachable("enum partial specialization");
case TagTypeKind::Interface:
case TagTypeKind::Class:
case TagTypeKind::Struct:
Out << "@SP";
break;
case TagTypeKind::Union:
Out << "@UP";
break;
case TagTypeKind::Enum:
llvm_unreachable("enum partial specialization");
}
VisitTemplateParameterList(PartialSpec->getTemplateParameters());
}
}

if (!AlreadyStarted) {
switch (D->getTagKind()) {
case TTK_Interface:
case TTK_Class:
case TTK_Struct: Out << "@S"; break;
case TTK_Union: Out << "@U"; break;
case TTK_Enum: Out << "@E"; break;
case TagTypeKind::Interface:
case TagTypeKind::Class:
case TagTypeKind::Struct:
Out << "@S";
break;
case TagTypeKind::Union:
Out << "@U";
break;
case TagTypeKind::Enum:
Out << "@E";
break;
}
}

Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Sema/HLSLExternalSemaSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ struct BuiltinTypeDeclBuilder {
return;
}

Record = CXXRecordDecl::Create(AST, TagDecl::TagKind::TTK_Class,
HLSLNamespace, SourceLocation(),
SourceLocation(), &II, PrevDecl, true);
Record = CXXRecordDecl::Create(AST, TagDecl::TagKind::Class, HLSLNamespace,
SourceLocation(), SourceLocation(), &II,
PrevDecl, true);
Record->setImplicit(true);
Record->setLexicalDeclContext(HLSLNamespace);
Record->setHasExternalLexicalStorage();
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Sema/Sema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,9 @@ void Sema::Initialize() {
if (getLangOpts().MSVCCompat) {
if (getLangOpts().CPlusPlus &&
IdResolver.begin(&Context.Idents.get("type_info")) == IdResolver.end())
PushOnScopeChains(Context.buildImplicitRecord("type_info", TTK_Class),
TUScope);
PushOnScopeChains(
Context.buildImplicitRecord("type_info", TagTypeKind::Class),
TUScope);

addImplicitTypedef("size_t", Context.getSizeType());
}
Expand Down
27 changes: 14 additions & 13 deletions clang/lib/Sema/SemaCodeComplete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1576,8 +1576,9 @@ bool ResultBuilder::IsClassOrStruct(const NamedDecl *ND) const {

// For purposes of this check, interfaces match too.
if (const auto *RD = dyn_cast<RecordDecl>(ND))
return RD->getTagKind() == TTK_Class || RD->getTagKind() == TTK_Struct ||
RD->getTagKind() == TTK_Interface;
return RD->getTagKind() == TagTypeKind::Class ||
RD->getTagKind() == TagTypeKind::Struct ||
RD->getTagKind() == TagTypeKind::Interface;

return false;
}
Expand All @@ -1589,7 +1590,7 @@ bool ResultBuilder::IsUnion(const NamedDecl *ND) const {
ND = ClassTemplate->getTemplatedDecl();

if (const auto *RD = dyn_cast<RecordDecl>(ND))
return RD->getTagKind() == TTK_Union;
return RD->getTagKind() == TagTypeKind::Union;

return false;
}
Expand Down Expand Up @@ -2018,15 +2019,15 @@ static const char *GetCompletionTypeString(QualType T, ASTContext &Context,
if (TagDecl *Tag = TagT->getDecl())
if (!Tag->hasNameForLinkage()) {
switch (Tag->getTagKind()) {
case TTK_Struct:
case TagTypeKind::Struct:
return "struct <anonymous>";
case TTK_Interface:
case TagTypeKind::Interface:
return "__interface <anonymous>";
case TTK_Class:
case TagTypeKind::Class:
return "class <anonymous>";
case TTK_Union:
case TagTypeKind::Union:
return "union <anonymous>";
case TTK_Enum:
case TagTypeKind::Enum:
return "enum <anonymous>";
}
}
Expand Down Expand Up @@ -4167,14 +4168,14 @@ CXCursorKind clang::getCursorKindForDecl(const Decl *D) {
default:
if (const auto *TD = dyn_cast<TagDecl>(D)) {
switch (TD->getTagKind()) {
case TTK_Interface: // fall through
case TTK_Struct:
case TagTypeKind::Interface: // fall through
case TagTypeKind::Struct:
return CXCursor_StructDecl;
case TTK_Class:
case TagTypeKind::Class:
return CXCursor_ClassDecl;
case TTK_Union:
case TagTypeKind::Union:
return CXCursor_UnionDecl;
case TTK_Enum:
case TagTypeKind::Enum:
return CXCursor_EnumDecl;
}
}
Expand Down
112 changes: 62 additions & 50 deletions clang/lib/Sema/SemaDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,11 +680,16 @@ DeclSpec::TST Sema::isTagName(IdentifierInfo &II, Scope *S) {
if (R.getResultKind() == LookupResult::Found)
if (const TagDecl *TD = R.getAsSingle<TagDecl>()) {
switch (TD->getTagKind()) {
case TTK_Struct: return DeclSpec::TST_struct;
case TTK_Interface: return DeclSpec::TST_interface;
case TTK_Union: return DeclSpec::TST_union;
case TTK_Class: return DeclSpec::TST_class;
case TTK_Enum: return DeclSpec::TST_enum;
case TagTypeKind::Struct:
return DeclSpec::TST_struct;
case TagTypeKind::Interface:
return DeclSpec::TST_interface;
case TagTypeKind::Union:
return DeclSpec::TST_union;
case TagTypeKind::Class:
return DeclSpec::TST_class;
case TagTypeKind::Enum:
return DeclSpec::TST_enum;
}
}

Expand Down Expand Up @@ -860,25 +865,25 @@ static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result,
if (TagDecl *Tag = R.getAsSingle<TagDecl>()) {
StringRef FixItTagName;
switch (Tag->getTagKind()) {
case TTK_Class:
FixItTagName = "class ";
break;
case TagTypeKind::Class:
FixItTagName = "class ";
break;

case TTK_Enum:
FixItTagName = "enum ";
break;
case TagTypeKind::Enum:
FixItTagName = "enum ";
break;

case TTK_Struct:
FixItTagName = "struct ";
break;
case TagTypeKind::Struct:
FixItTagName = "struct ";
break;

case TTK_Interface:
FixItTagName = "__interface ";
break;
case TagTypeKind::Interface:
FixItTagName = "__interface ";
break;

case TTK_Union:
FixItTagName = "union ";
break;
case TagTypeKind::Union:
FixItTagName = "union ";
break;
}

StringRef TagName = FixItTagName.drop_back();
Expand Down Expand Up @@ -5268,8 +5273,8 @@ Decl *Sema::ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS,
if (DS.isModulePrivateSpecified() &&
Tag && Tag->getDeclContext()->isFunctionOrMethod())
Diag(DS.getModulePrivateSpecLoc(), diag::err_module_private_local_class)
<< Tag->getTagKind()
<< FixItHint::CreateRemoval(DS.getModulePrivateSpecLoc());
<< llvm::to_underlying(Tag->getTagKind())
<< FixItHint::CreateRemoval(DS.getModulePrivateSpecLoc());

ActOnDocumentableDecl(TagD);

Expand Down Expand Up @@ -7667,14 +7672,15 @@ NamedDecl *Sema::ActOnVariableDeclarator(
// members.
Diag(D.getIdentifierLoc(),
diag::err_static_data_member_not_allowed_in_local_class)
<< Name << RD->getDeclName() << RD->getTagKind();
<< Name << RD->getDeclName()
<< llvm::to_underlying(RD->getTagKind());
} else if (AnonStruct) {
// C++ [class.static.data]p4: Unnamed classes and classes contained
// directly or indirectly within unnamed classes shall not contain
// static data members.
Diag(D.getIdentifierLoc(),
diag::err_static_data_member_not_allowed_in_anon_struct)
<< Name << AnonStruct->getTagKind();
<< Name << llvm::to_underlying(AnonStruct->getTagKind());
Invalid = true;
} else if (RD->isUnion()) {
// C++98 [class.union]p1: If a union contains a static data member,
Expand Down Expand Up @@ -16766,9 +16772,12 @@ bool Sema::CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped,
/// \returns diagnostic %select index.
static unsigned getRedeclDiagFromTagKind(TagTypeKind Tag) {
switch (Tag) {
case TTK_Struct: return 0;
case TTK_Interface: return 1;
case TTK_Class: return 2;
case TagTypeKind::Struct:
return 0;
case TagTypeKind::Interface:
return 1;
case TagTypeKind::Class:
return 2;
default: llvm_unreachable("Invalid tag kind for redecl diagnostic!");
}
}
Expand All @@ -16779,7 +16788,8 @@ static unsigned getRedeclDiagFromTagKind(TagTypeKind Tag) {
/// \returns true iff the tag kind is compatible.
static bool isClassCompatTagKind(TagTypeKind Tag)
{
return Tag == TTK_Struct || Tag == TTK_Class || Tag == TTK_Interface;
return Tag == TagTypeKind::Struct || Tag == TagTypeKind::Class ||
Tag == TagTypeKind::Interface;
}

Sema::NonTagKind Sema::getNonTagTypeDeclKind(const Decl *PrevDecl,
Expand All @@ -16795,13 +16805,13 @@ Sema::NonTagKind Sema::getNonTagTypeDeclKind(const Decl *PrevDecl,
else if (isa<TemplateTemplateParmDecl>(PrevDecl))
return NTK_TemplateTemplateArgument;
switch (TTK) {
case TTK_Struct:
case TTK_Interface:
case TTK_Class:
case TagTypeKind::Struct:
case TagTypeKind::Interface:
case TagTypeKind::Class:
return getLangOpts().CPlusPlus ? NTK_NonClass : NTK_NonStruct;
case TTK_Union:
case TagTypeKind::Union:
return NTK_NonUnion;
case TTK_Enum:
case TagTypeKind::Enum:
return NTK_NonEnum;
}
llvm_unreachable("invalid TTK");
Expand Down Expand Up @@ -17037,7 +17047,7 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
MatchTemplateParametersToScopeSpecifier(
KWLoc, NameLoc, SS, nullptr, TemplateParameterLists,
TUK == TUK_Friend, isMemberSpecialization, Invalid)) {
if (Kind == TTK_Enum) {
if (Kind == TagTypeKind::Enum) {
Diag(KWLoc, diag::err_enum_template);
return true;
}
Expand Down Expand Up @@ -17075,7 +17085,7 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
bool IsFixed = !UnderlyingType.isUnset() || ScopedEnum;

if (Kind == TTK_Enum) {
if (Kind == TagTypeKind::Enum) {
if (UnderlyingType.isInvalid() || (!UnderlyingType.get() && ScopedEnum)) {
// No underlying type explicitly specified, or we failed to parse the
// type, default to int.
Expand Down Expand Up @@ -17125,7 +17135,7 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
SourceLocation Loc = NameLoc.isValid() ? NameLoc : KWLoc;
TagDecl *New = nullptr;

if (Kind == TTK_Enum) {
if (Kind == TagTypeKind::Enum) {
New = EnumDecl::Create(Context, SearchDC, KWLoc, Loc, Name, nullptr,
ScopedEnum, ScopedEnumUsesClassTag, IsFixed);
// If this is an undefined enum, bail.
Expand Down Expand Up @@ -17218,7 +17228,7 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,

// A tag 'foo::bar' must already exist.
Diag(NameLoc, diag::err_not_tag_in_scope)
<< Kind << Name << DC << SS.getRange();
<< llvm::to_underlying(Kind) << Name << DC << SS.getRange();
Name = nullptr;
Invalid = true;
goto CreateNewDecl;
Expand Down Expand Up @@ -17478,9 +17488,9 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind,
TUK == TUK_Definition, KWLoc,
Name)) {
bool SafeToContinue
= (PrevTagDecl->getTagKind() != TTK_Enum &&
Kind != TTK_Enum);
bool SafeToContinue =
(PrevTagDecl->getTagKind() != TagTypeKind::Enum &&
Kind != TagTypeKind::Enum);
if (SafeToContinue)
Diag(KWLoc, diag::err_use_with_wrong_tag)
<< Name
Expand All @@ -17500,7 +17510,8 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
}
}

if (Kind == TTK_Enum && PrevTagDecl->getTagKind() == TTK_Enum) {
if (Kind == TagTypeKind::Enum &&
PrevTagDecl->getTagKind() == TagTypeKind::Enum) {
const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
if (TUK == TUK_Reference || TUK == TUK_Friend)
return PrevTagDecl;
Expand Down Expand Up @@ -17670,8 +17681,8 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
if ((TUK == TUK_Reference || TUK == TUK_Friend) &&
!Previous.isForRedeclaration()) {
NonTagKind NTK = getNonTagTypeDeclKind(PrevDecl, Kind);
Diag(NameLoc, diag::err_tag_reference_non_tag) << PrevDecl << NTK
<< Kind;
Diag(NameLoc, diag::err_tag_reference_non_tag)
<< PrevDecl << NTK << llvm::to_underlying(Kind);
Diag(PrevDecl->getLocation(), diag::note_declared_at);
Invalid = true;

Expand Down Expand Up @@ -17729,7 +17740,7 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
// PrevDecl.
TagDecl *New;

if (Kind == TTK_Enum) {
if (Kind == TagTypeKind::Enum) {
// FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
// enum X { A, B, C } D; D should chain to X.
New = EnumDecl::Create(Context, SearchDC, KWLoc, Loc, Name,
Expand Down Expand Up @@ -17864,7 +17875,7 @@ Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc,
// If we're declaring or defining a tag in function prototype scope in C,
// note that this type can only be used within the function and add it to
// the list of decls to inject into the function definition scope.
if ((Name || Kind == TTK_Enum) &&
if ((Name || Kind == TagTypeKind::Enum) &&
getNonFieldDeclScope(S)->isFunctionPrototypeScope()) {
if (getLangOpts().CPlusPlus) {
// C++ [dcl.fct]p6:
Expand Down Expand Up @@ -19038,7 +19049,8 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
unsigned DiagID = 0;
if (!Record->isUnion() && !IsLastField) {
Diag(FD->getLocation(), diag::err_flexible_array_not_at_end)
<< FD->getDeclName() << FD->getType() << Record->getTagKind();
<< FD->getDeclName() << FD->getType()
<< llvm::to_underlying(Record->getTagKind());
Diag((*(i + 1))->getLocation(), diag::note_next_field_declaration);
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
Expand All @@ -19057,19 +19069,19 @@ void Sema::ActOnFields(Scope *S, SourceLocation RecLoc, Decl *EnclosingDecl,
: diag::err_flexible_array_empty_aggregate;

if (DiagID)
Diag(FD->getLocation(), DiagID) << FD->getDeclName()
<< Record->getTagKind();
Diag(FD->getLocation(), DiagID)
<< FD->getDeclName() << llvm::to_underlying(Record->getTagKind());
// While the layout of types that contain virtual bases is not specified
// by the C++ standard, both the Itanium and Microsoft C++ ABIs place
// virtual bases after the derived members. This would make a flexible
// array member declared at the end of an object not adjacent to the end
// of the type.
if (CXXRecord && CXXRecord->getNumVBases() != 0)
Diag(FD->getLocation(), diag::err_flexible_array_virtual_base)
<< FD->getDeclName() << Record->getTagKind();
<< FD->getDeclName() << llvm::to_underlying(Record->getTagKind());
if (!getLangOpts().C99)
Diag(FD->getLocation(), diag::ext_c99_flexible_array_member)
<< FD->getDeclName() << Record->getTagKind();
<< FD->getDeclName() << llvm::to_underlying(Record->getTagKind());

// If the element type has a non-trivial destructor, we would not
// implicitly destroy the elements, so disallow it for now.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDeclAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ static inline bool isCFStringType(QualType T, ASTContext &Ctx) {
return false;

const RecordDecl *RD = RT->getDecl();
if (RD->getTagKind() != TTK_Struct)
if (RD->getTagKind() != TagTypeKind::Struct)
return false;

return RD->getIdentifier() == &Ctx.Idents.get("__CFString");
Expand Down
25 changes: 14 additions & 11 deletions clang/lib/Sema/SemaDeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1781,9 +1781,12 @@ static bool CheckConstexprReturnType(Sema &SemaRef, const FunctionDecl *FD,
/// \returns diagnostic %select index.
static unsigned getRecordDiagFromTagKind(TagTypeKind Tag) {
switch (Tag) {
case TTK_Struct: return 0;
case TTK_Interface: return 1;
case TTK_Class: return 2;
case TagTypeKind::Struct:
return 0;
case TagTypeKind::Interface:
return 1;
case TagTypeKind::Class:
return 2;
default: llvm_unreachable("Invalid tag kind for record diagnostic!");
}
}
Expand Down Expand Up @@ -2680,7 +2683,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
TypeSourceInfo *TInfo,
SourceLocation EllipsisLoc) {
// In HLSL, unspecified class access is public rather than private.
if (getLangOpts().HLSL && Class->getTagKind() == TTK_Class &&
if (getLangOpts().HLSL && Class->getTagKind() == TagTypeKind::Class &&
Access == AS_none)
Access = AS_public;

Expand Down Expand Up @@ -2733,9 +2736,9 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
// emitted.
if (!Class->getTypeForDecl()->isDependentType())
Class->setInvalidDecl();
return new (Context) CXXBaseSpecifier(SpecifierRange, Virtual,
Class->getTagKind() == TTK_Class,
Access, TInfo, EllipsisLoc);
return new (Context) CXXBaseSpecifier(
SpecifierRange, Virtual, Class->getTagKind() == TagTypeKind::Class,
Access, TInfo, EllipsisLoc);
}

// Base specifiers must be record types.
Expand Down Expand Up @@ -2821,9 +2824,9 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class,
Class->setInvalidDecl();

// Create the base specifier.
return new (Context) CXXBaseSpecifier(SpecifierRange, Virtual,
Class->getTagKind() == TTK_Class,
Access, TInfo, EllipsisLoc);
return new (Context) CXXBaseSpecifier(
SpecifierRange, Virtual, Class->getTagKind() == TagTypeKind::Class,
Access, TInfo, EllipsisLoc);
}

/// ActOnBaseSpecifier - Parsed a base specifier. A base specifier is
Expand Down Expand Up @@ -7010,7 +7013,7 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) {
(F->getType().isConstQualified() && F->getType()->isScalarType())) {
if (!Complained) {
Diag(Record->getLocation(), diag::warn_no_constructor_for_refconst)
<< Record->getTagKind() << Record;
<< llvm::to_underlying(Record->getTagKind()) << Record;
Complained = true;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaDeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3884,7 +3884,7 @@ static void DiagnoseVariableSizedIvars(Sema &S, ObjCContainerDecl *OCD) {
if (IvarTy->isIncompleteArrayType()) {
S.Diag(ivar->getLocation(), diag::err_flexible_array_not_at_end)
<< ivar->getDeclName() << IvarTy
<< TTK_Class; // Use "class" for Obj-C.
<< llvm::to_underlying(TagTypeKind::Class); // Use "class" for Obj-C.
IsInvalidIvar = true;
} else if (const RecordType *RecordTy = IvarTy->getAs<RecordType>()) {
if (RecordTy->getDecl()->hasFlexibleArrayMember()) {
Expand Down
9 changes: 4 additions & 5 deletions clang/lib/Sema/SemaExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3035,11 +3035,10 @@ void Sema::DeclareGlobalNewDelete() {
if (!StdBadAlloc && !getLangOpts().CPlusPlus11) {
// The "std::bad_alloc" class has not yet been declared, so build it
// implicitly.
StdBadAlloc = CXXRecordDecl::Create(Context, TTK_Class,
getOrCreateStdNamespace(),
SourceLocation(), SourceLocation(),
&PP.getIdentifierTable().get("bad_alloc"),
nullptr);
StdBadAlloc = CXXRecordDecl::Create(
Context, TagTypeKind::Class, getOrCreateStdNamespace(),
SourceLocation(), SourceLocation(),
&PP.getIdentifierTable().get("bad_alloc"), nullptr);
getStdBadAlloc()->setImplicit(true);

// The implicitly declared "std::bad_alloc" should live in global module
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Sema/SemaStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4692,10 +4692,11 @@ Sema::CreateCapturedStmtRecordDecl(CapturedDecl *&CD, SourceLocation Loc,

RecordDecl *RD = nullptr;
if (getLangOpts().CPlusPlus)
RD = CXXRecordDecl::Create(Context, TTK_Struct, DC, Loc, Loc,
RD = CXXRecordDecl::Create(Context, TagTypeKind::Struct, DC, Loc, Loc,
/*Id=*/nullptr);
else
RD = RecordDecl::Create(Context, TTK_Struct, DC, Loc, Loc, /*Id=*/nullptr);
RD = RecordDecl::Create(Context, TagTypeKind::Struct, DC, Loc, Loc,
/*Id=*/nullptr);

RD->setCapturedRecord();
DC->addDecl(RD);
Expand Down
16 changes: 10 additions & 6 deletions clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,8 @@ DeclResult Sema::CheckClassTemplate(
return true;

TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec);
assert(Kind != TTK_Enum && "can't build template of enumerated type");
assert(Kind != TagTypeKind::Enum &&
"can't build template of enumerated type");

// There is no such thing as an unnamed class template.
if (!Name) {
Expand Down Expand Up @@ -4292,7 +4293,7 @@ TypeResult Sema::ActOnTagTemplateIdType(TagUseKind TUK,
// resolves to an alias template specialization, the
// elaborated-type-specifier is ill-formed.
Diag(TemplateLoc, diag::err_tag_reference_non_tag)
<< TAT << NTK_TypeAliasTemplate << TagKind;
<< TAT << NTK_TypeAliasTemplate << llvm::to_underlying(TagKind);
Diag(TAT->getLocation(), diag::note_declared_at);
}

Expand Down Expand Up @@ -8722,7 +8723,8 @@ DeclResult Sema::ActOnClassTemplateSpecialization(
// Check that the specialization uses the same tag kind as the
// original template.
TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec);
assert(Kind != TTK_Enum && "Invalid enum tag in class template spec!");
assert(Kind != TagTypeKind::Enum &&
"Invalid enum tag in class template spec!");
if (!isAcceptableTagRedeclaration(ClassTemplate->getTemplatedDecl(),
Kind, TUK == TUK_Definition, KWLoc,
ClassTemplate->getIdentifier())) {
Expand Down Expand Up @@ -9968,14 +9970,15 @@ DeclResult Sema::ActOnExplicitInstantiation(
// Check that the specialization uses the same tag kind as the
// original template.
TagTypeKind Kind = TypeWithKeyword::getTagTypeKindForTypeSpec(TagSpec);
assert(Kind != TTK_Enum &&
assert(Kind != TagTypeKind::Enum &&
"Invalid enum tag in class template explicit instantiation!");

ClassTemplateDecl *ClassTemplate = dyn_cast<ClassTemplateDecl>(TD);

if (!ClassTemplate) {
NonTagKind NTK = getNonTagTypeDeclKind(TD, Kind);
Diag(TemplateNameLoc, diag::err_tag_reference_non_tag) << TD << NTK << Kind;
Diag(TemplateNameLoc, diag::err_tag_reference_non_tag)
<< TD << NTK << llvm::to_underlying(Kind);
Diag(TD->getLocation(), diag::note_previous_use);
return true;
}
Expand Down Expand Up @@ -10800,7 +10803,8 @@ Sema::ActOnDependentTag(Scope *S, unsigned TagSpec, TagUseKind TUK,

if (TUK == TUK_Declaration || TUK == TUK_Definition) {
Diag(NameLoc, diag::err_dependent_tag_decl)
<< (TUK == TUK_Definition) << Kind << SS.getRange();
<< (TUK == TUK_Definition) << llvm::to_underlying(Kind)
<< SS.getRange();
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1662,8 +1662,8 @@ Decl *TemplateDeclInstantiator::VisitClassTemplateDecl(ClassTemplateDecl *D) {

if (!PrevClassTemplate && QualifierLoc) {
SemaRef.Diag(Pattern->getLocation(), diag::err_not_tag_in_scope)
<< D->getTemplatedDecl()->getTagKind() << Pattern->getDeclName() << DC
<< QualifierLoc.getSourceRange();
<< llvm::to_underlying(D->getTemplatedDecl()->getTagKind())
<< Pattern->getDeclName() << DC << QualifierLoc.getSourceRange();
return nullptr;
}
}
Expand Down
30 changes: 21 additions & 9 deletions clang/lib/Sema/SemaType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3667,11 +3667,20 @@ static QualType GetDeclSpecTypeForDeclarator(TypeProcessingState &state,
Error = 6; // Interface member.
} else {
switch (cast<TagDecl>(SemaRef.CurContext)->getTagKind()) {
case TTK_Enum: llvm_unreachable("unhandled tag kind");
case TTK_Struct: Error = Cxx ? 1 : 2; /* Struct member */ break;
case TTK_Union: Error = Cxx ? 3 : 4; /* Union member */ break;
case TTK_Class: Error = 5; /* Class member */ break;
case TTK_Interface: Error = 6; /* Interface member */ break;
case TagTypeKind::Enum:
llvm_unreachable("unhandled tag kind");
case TagTypeKind::Struct:
Error = Cxx ? 1 : 2; /* Struct member */
break;
case TagTypeKind::Union:
Error = Cxx ? 3 : 4; /* Union member */
break;
case TagTypeKind::Class:
Error = 5; /* Class member */
break;
case TagTypeKind::Interface:
Error = 6; /* Interface member */
break;
}
}
if (D.getDeclSpec().isFriendSpecified())
Expand Down Expand Up @@ -4413,7 +4422,7 @@ bool Sema::isCFError(RecordDecl *RD) {
// NSError. CFErrorRef used to be declared with "objc_bridge" but is now
// declared with "objc_bridge_mutable", so look for either one of the two
// attributes.
if (RD->getTagKind() == TTK_Struct) {
if (RD->getTagKind() == TagTypeKind::Struct) {
IdentifierInfo *bridgedType = nullptr;
if (auto bridgeAttr = RD->getAttr<ObjCBridgeAttr>())
bridgedType = bridgeAttr->getBridgedType();
Expand Down Expand Up @@ -9417,9 +9426,12 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T,
/// \returns diagnostic %select index.
static unsigned getLiteralDiagFromTagKind(TagTypeKind Tag) {
switch (Tag) {
case TTK_Struct: return 0;
case TTK_Interface: return 1;
case TTK_Class: return 2;
case TagTypeKind::Struct:
return 0;
case TagTypeKind::Interface:
return 1;
case TagTypeKind::Class:
return 2;
default: llvm_unreachable("Invalid tag kind for literal type diagnostic!");
}
}
Expand Down
10 changes: 6 additions & 4 deletions clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -1209,14 +1209,15 @@ class TreeTransform {
case LookupResult::FoundUnresolvedValue: {
NamedDecl *SomeDecl = Result.getRepresentativeDecl();
Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << SomeDecl
<< NTK << Kind;
SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag)
<< SomeDecl << NTK << llvm::to_underlying(Kind);
SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
break;
}
default:
SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
<< Kind << Id << DC << QualifierLoc.getSourceRange();
<< llvm::to_underlying(Kind) << Id << DC
<< QualifierLoc.getSourceRange();
break;
}
return QualType();
Expand Down Expand Up @@ -7029,7 +7030,8 @@ TreeTransform<Derived>::TransformElaboratedType(TypeLocBuilder &TLB,
SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(),
diag::err_tag_reference_non_tag)
<< TAT << Sema::NTK_TypeAliasTemplate
<< ElaboratedType::getTagTypeKindForKeyword(T->getKeyword());
<< llvm::to_underlying(
ElaboratedType::getTagTypeKindForKeyword(T->getKeyword()));
SemaRef.Diag(TAT->getLocation(), diag::note_declared_at);
}
}
Expand Down
233 changes: 135 additions & 98 deletions clang/lib/Serialization/ASTReaderDecl.cpp

Large diffs are not rendered by default.

34 changes: 23 additions & 11 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5333,7 +5333,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
Record.push_back(false);
}
}
Record.push_back(RD->getTagKind());
Record.push_back(llvm::to_underlying(RD->getTagKind()));
Record.AddSourceLocation(RD->getLocation());
Record.AddSourceLocation(RD->getBeginLoc());
Record.AddSourceRange(RD->getBraceRange());
Expand Down Expand Up @@ -5996,11 +5996,17 @@ void ASTRecordWriter::AddCXXCtorInitializers(

void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
auto &Data = D->data();

Record->push_back(Data.IsLambda);

#define FIELD(Name, Width, Merge) \
Record->push_back(Data.Name);
#include "clang/AST/CXXRecordDeclDefinitionBits.def"
BitsPacker DefinitionBits;

#define FIELD(Name, Width, Merge) DefinitionBits.addBits(Data.Name, Width);
#include "clang/AST/CXXRecordDeclDefinitionBits.def"
#undef FIELD

while (DefinitionBits.hasUnconsumedValues())
Record->push_back(DefinitionBits.getNextValue());

// getODRHash will compute the ODRHash if it has not been previously computed.
Record->push_back(D->getODRHash());
Expand Down Expand Up @@ -6032,12 +6038,16 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
AddDeclRef(D->getFirstFriend());
} else {
auto &Lambda = D->getLambdaData();
Record->push_back(Lambda.DependencyKind);
Record->push_back(Lambda.IsGenericLambda);
Record->push_back(Lambda.CaptureDefault);
Record->push_back(Lambda.NumCaptures);

BitsPacker LambdaBits;
LambdaBits.addBits(Lambda.DependencyKind, /*Width=*/2);
LambdaBits.addBit(Lambda.IsGenericLambda);
LambdaBits.addBits(Lambda.CaptureDefault, /*Width=*/2);
LambdaBits.addBits(Lambda.NumCaptures, /*Width=*/15);
LambdaBits.addBit(Lambda.HasKnownInternalLinkage);
Record->push_back(LambdaBits.getNextValue());

Record->push_back(Lambda.NumExplicitCaptures);
Record->push_back(Lambda.HasKnownInternalLinkage);
Record->push_back(Lambda.ManglingNumber);
Record->push_back(D->getDeviceLambdaManglingNumber());
// The lambda context declaration and index within the context are provided
Expand All @@ -6046,8 +6056,10 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
const LambdaCapture &Capture = Lambda.Captures.front()[I];
AddSourceLocation(Capture.getLocation());
Record->push_back(Capture.isImplicit());
Record->push_back(Capture.getCaptureKind());
BitsPacker CaptureBits;
CaptureBits.addBit(Capture.isImplicit());
CaptureBits.addBits(Capture.getCaptureKind(), /*Width=*/3);
Record->push_back(CaptureBits);
switch (Capture.getCaptureKind()) {
case LCK_StarThis:
case LCK_This:
Expand Down
448 changes: 207 additions & 241 deletions clang/lib/Serialization/ASTWriterDecl.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class NoUncountedMemberChecker

const auto Kind = RD->getTagKind();
// FIMXE: Should we check union members too?
if (Kind != TTK_Struct && Kind != TTK_Class)
if (Kind != TagTypeKind::Struct && Kind != TagTypeKind::Class)
return true;

// Ignore CXXRecords that come from system headers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class RefCntblBaseVirtualDtorChecker
return true;

const auto Kind = RD->getTagKind();
if (Kind != TTK_Struct && Kind != TTK_Class)
if (Kind != TagTypeKind::Struct && Kind != TagTypeKind::Class)
return true;

// Ignore CXXRecords that come from system headers.
Expand Down
15 changes: 15 additions & 0 deletions clang/test/CodeGen/aarch64-inline-asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,18 @@ void test_tied_earlyclobber(void) {
asm("" : "+&r"(a));
// CHECK: call i32 asm "", "=&{x1},0"(i32 %0)
}

void test_reduced_gpr_constraints(int var32, long var64) {
asm("add w0, w0, %0" : : "Uci"(var32) : "w0");
// CHECK: [[ARG1:%.+]] = load i32, ptr
// CHECK: call void asm sideeffect "add w0, w0, $0", "@3Uci,~{w0}"(i32 [[ARG1]])
asm("add x0, x0, %0" : : "Uci"(var64) : "x0");
// CHECK: [[ARG1:%.+]] = load i64, ptr
// CHECK: call void asm sideeffect "add x0, x0, $0", "@3Uci,~{x0}"(i64 [[ARG1]])
asm("add w0, w0, %0" : : "Ucj"(var32) : "w0");
// CHECK: [[ARG2:%.+]] = load i32, ptr
// CHECK: call void asm sideeffect "add w0, w0, $0", "@3Ucj,~{w0}"(i32 [[ARG2]])
asm("add x0, x0, %0" : : "Ucj"(var64) : "x0");
// CHECK: [[ARG2:%.+]] = load i64, ptr
// CHECK: call void asm sideeffect "add x0, x0, $0", "@3Ucj,~{x0}"(i64 [[ARG2]])
}
807 changes: 758 additions & 49 deletions clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_reinterpret-bfloat.c

Large diffs are not rendered by default.

4,035 changes: 3,789 additions & 246 deletions clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_reinterpret.c

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions clang/test/Modules/decl-params-determinisim.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,23 @@
/// op13 encodes the anonymous decl number which should be in order.
// CHECK: <TYPE_FUNCTION_PROTO
// CHECK-NEXT: <DECL_PARM_VAR
// CHECK-SAME: op13=2
// CHECK-SAME: op11=4024
// CHECK-NEXT: <DECL_PARM_VAR
// CHECK-SAME: op13=3
// CHECK-SAME: op11=4032
// CHECK-NEXT: <DECL_PARM_VAR
// CHECK-SAME: op13=4
// CHECK-SAME: op11=4040
// CHECK-NEXT: <DECL_PARM_VAR
// CHECK-SAME: op13=5
// CHECK-SAME: op11=4048

/// Decl records start at 43
// CHECK: <DECL_RECORD
// CHECK-SAME: op13=43
// CHECK-SAME: op9=4352
// CHECK-NEXT: <DECL_RECORD
// CHECK-SAME: op13=44
// CHECK-SAME: op9=4360
// CHECK-NEXT: <DECL_RECORD
// CHECK-SAME: op13=45
// CHECK-SAME: op9=4368
// CHECK-NEXT: <DECL_RECORD
// CHECK-SAME: op13=46
// CHECK-SAME: op9=4376

//--- headers/a.h
void f(struct A0 *a0,
Expand Down
9 changes: 0 additions & 9 deletions clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ int bar(int n){
// CHECK-64-NEXT: [[TMP8:%.*]] = load double, ptr [[E1]], align 8
// CHECK-64-NEXT: [[ADD2:%.*]] = fadd double [[TMP7]], [[TMP8]]
// CHECK-64-NEXT: store double [[ADD2]], ptr [[TMP0]], align 8
// CHECK-64-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP3]])
// CHECK-64-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK-64: .omp.reduction.done:
// CHECK-64-NEXT: ret void
Expand Down Expand Up @@ -353,7 +352,6 @@ int bar(int n){
// CHECK-64-NEXT: [[TMP13:%.*]] = load float, ptr [[D2]], align 4
// CHECK-64-NEXT: [[MUL8:%.*]] = fmul float [[TMP12]], [[TMP13]]
// CHECK-64-NEXT: store float [[MUL8]], ptr [[TMP1]], align 4
// CHECK-64-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP5]])
// CHECK-64-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK-64: .omp.reduction.done:
// CHECK-64-NEXT: ret void
Expand Down Expand Up @@ -609,7 +607,6 @@ int bar(int n){
// CHECK-64: cond.end11:
// CHECK-64-NEXT: [[COND12:%.*]] = phi i16 [ [[TMP15]], [[COND_TRUE9]] ], [ [[TMP16]], [[COND_FALSE10]] ]
// CHECK-64-NEXT: store i16 [[COND12]], ptr [[TMP1]], align 2
// CHECK-64-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP6]])
// CHECK-64-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK-64: .omp.reduction.done:
// CHECK-64-NEXT: ret void
Expand Down Expand Up @@ -824,7 +821,6 @@ int bar(int n){
// CHECK-32-NEXT: [[TMP8:%.*]] = load double, ptr [[E1]], align 8
// CHECK-32-NEXT: [[ADD2:%.*]] = fadd double [[TMP7]], [[TMP8]]
// CHECK-32-NEXT: store double [[ADD2]], ptr [[TMP0]], align 8
// CHECK-32-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP3]])
// CHECK-32-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK-32: .omp.reduction.done:
// CHECK-32-NEXT: ret void
Expand Down Expand Up @@ -1029,7 +1025,6 @@ int bar(int n){
// CHECK-32-NEXT: [[TMP13:%.*]] = load float, ptr [[D2]], align 4
// CHECK-32-NEXT: [[MUL8:%.*]] = fmul float [[TMP12]], [[TMP13]]
// CHECK-32-NEXT: store float [[MUL8]], ptr [[TMP1]], align 4
// CHECK-32-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP5]])
// CHECK-32-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK-32: .omp.reduction.done:
// CHECK-32-NEXT: ret void
Expand Down Expand Up @@ -1285,7 +1280,6 @@ int bar(int n){
// CHECK-32: cond.end11:
// CHECK-32-NEXT: [[COND12:%.*]] = phi i16 [ [[TMP15]], [[COND_TRUE9]] ], [ [[TMP16]], [[COND_FALSE10]] ]
// CHECK-32-NEXT: store i16 [[COND12]], ptr [[TMP1]], align 2
// CHECK-32-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP6]])
// CHECK-32-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK-32: .omp.reduction.done:
// CHECK-32-NEXT: ret void
Expand Down Expand Up @@ -1500,7 +1494,6 @@ int bar(int n){
// CHECK-32-EX-NEXT: [[TMP8:%.*]] = load double, ptr [[E1]], align 8
// CHECK-32-EX-NEXT: [[ADD2:%.*]] = fadd double [[TMP7]], [[TMP8]]
// CHECK-32-EX-NEXT: store double [[ADD2]], ptr [[TMP0]], align 8
// CHECK-32-EX-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP3]])
// CHECK-32-EX-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK-32-EX: .omp.reduction.done:
// CHECK-32-EX-NEXT: ret void
Expand Down Expand Up @@ -1705,7 +1698,6 @@ int bar(int n){
// CHECK-32-EX-NEXT: [[TMP13:%.*]] = load float, ptr [[D2]], align 4
// CHECK-32-EX-NEXT: [[MUL8:%.*]] = fmul float [[TMP12]], [[TMP13]]
// CHECK-32-EX-NEXT: store float [[MUL8]], ptr [[TMP1]], align 4
// CHECK-32-EX-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP5]])
// CHECK-32-EX-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK-32-EX: .omp.reduction.done:
// CHECK-32-EX-NEXT: ret void
Expand Down Expand Up @@ -1961,7 +1953,6 @@ int bar(int n){
// CHECK-32-EX: cond.end11:
// CHECK-32-EX-NEXT: [[COND12:%.*]] = phi i16 [ [[TMP15]], [[COND_TRUE9]] ], [ [[TMP16]], [[COND_FALSE10]] ]
// CHECK-32-EX-NEXT: store i16 [[COND12]], ptr [[TMP1]], align 2
// CHECK-32-EX-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP6]])
// CHECK-32-EX-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK-32-EX: .omp.reduction.done:
// CHECK-32-EX-NEXT: ret void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ void test() {
// CHECK1-NEXT: br i1 [[TMP37]], label [[DOTOMP_REDUCTION_THEN:%.*]], label [[DOTOMP_REDUCTION_DONE:%.*]]
// CHECK1: .omp.reduction.then:
// CHECK1-NEXT: [[CALL21:%.*]] = call nonnull align 4 dereferenceable(8) ptr @_ZNSt7complexIfEpLIfEERS0_RKS_IT_E(ptr nonnull align 4 dereferenceable(8) [[TMP2]], ptr nonnull align 4 dereferenceable(8) [[PARTIAL_SUM5]]) #[[ATTR12]]
// CHECK1-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP34]])
// CHECK1-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK1: .omp.reduction.done:
// CHECK1-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr [[I7]]) #[[ATTR4]]
Expand Down Expand Up @@ -832,7 +831,6 @@ void test() {
// CHECK1-NEXT: br i1 [[TMP37]], label [[DOTOMP_REDUCTION_THEN:%.*]], label [[DOTOMP_REDUCTION_DONE:%.*]]
// CHECK1: .omp.reduction.then:
// CHECK1-NEXT: [[CALL21:%.*]] = call nonnull align 8 dereferenceable(16) ptr @_ZNSt7complexIdEpLIdEERS0_RKS_IT_E(ptr nonnull align 8 dereferenceable(16) [[TMP2]], ptr nonnull align 8 dereferenceable(16) [[PARTIAL_SUM5]]) #[[ATTR12]]
// CHECK1-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP34]])
// CHECK1-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK1: .omp.reduction.done:
// CHECK1-NEXT: call void @llvm.lifetime.end.p0(i64 4, ptr [[I7]]) #[[ATTR4]]
Expand Down
12 changes: 0 additions & 12 deletions clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ int bar(int n){
// CHECK1-NEXT: [[TMP8:%.*]] = load double, ptr [[E1]], align 8
// CHECK1-NEXT: [[ADD2:%.*]] = fadd double [[TMP7]], [[TMP8]]
// CHECK1-NEXT: store double [[ADD2]], ptr [[TMP0]], align 8
// CHECK1-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP3]])
// CHECK1-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK1: .omp.reduction.done:
// CHECK1-NEXT: call void @__kmpc_free_shared(ptr [[E1]], i64 8)
Expand Down Expand Up @@ -402,7 +401,6 @@ int bar(int n){
// CHECK1-NEXT: [[TMP13:%.*]] = load float, ptr [[D2]], align 4
// CHECK1-NEXT: [[MUL8:%.*]] = fmul float [[TMP12]], [[TMP13]]
// CHECK1-NEXT: store float [[MUL8]], ptr [[TMP1]], align 4
// CHECK1-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP5]])
// CHECK1-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK1: .omp.reduction.done:
// CHECK1-NEXT: call void @__kmpc_free_shared(ptr [[D2]], i64 4)
Expand Down Expand Up @@ -751,7 +749,6 @@ int bar(int n){
// CHECK1: cond.end:
// CHECK1-NEXT: [[COND:%.*]] = phi i16 [ [[TMP14]], [[COND_TRUE]] ], [ [[TMP15]], [[COND_FALSE]] ]
// CHECK1-NEXT: store i16 [[COND]], ptr [[TMP1]], align 2
// CHECK1-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP5]])
// CHECK1-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK1: .omp.reduction.done:
// CHECK1-NEXT: ret void
Expand Down Expand Up @@ -821,7 +818,6 @@ int bar(int n){
// CHECK1: cond.end11:
// CHECK1-NEXT: [[COND12:%.*]] = phi i16 [ [[TMP15]], [[COND_TRUE9]] ], [ [[TMP16]], [[COND_FALSE10]] ]
// CHECK1-NEXT: store i16 [[COND12]], ptr [[TMP1]], align 2
// CHECK1-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP6]])
// CHECK1-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK1: .omp.reduction.done:
// CHECK1-NEXT: ret void
Expand Down Expand Up @@ -1303,7 +1299,6 @@ int bar(int n){
// CHECK2-NEXT: [[TMP8:%.*]] = load double, ptr [[E1]], align 8
// CHECK2-NEXT: [[ADD2:%.*]] = fadd double [[TMP7]], [[TMP8]]
// CHECK2-NEXT: store double [[ADD2]], ptr [[TMP0]], align 8
// CHECK2-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP3]])
// CHECK2-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK2: .omp.reduction.done:
// CHECK2-NEXT: call void @__kmpc_free_shared(ptr [[E1]], i32 8)
Expand Down Expand Up @@ -1599,7 +1594,6 @@ int bar(int n){
// CHECK2-NEXT: [[TMP13:%.*]] = load float, ptr [[D2]], align 4
// CHECK2-NEXT: [[MUL8:%.*]] = fmul float [[TMP12]], [[TMP13]]
// CHECK2-NEXT: store float [[MUL8]], ptr [[TMP1]], align 4
// CHECK2-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP5]])
// CHECK2-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK2: .omp.reduction.done:
// CHECK2-NEXT: call void @__kmpc_free_shared(ptr [[D2]], i32 4)
Expand Down Expand Up @@ -1948,7 +1942,6 @@ int bar(int n){
// CHECK2: cond.end:
// CHECK2-NEXT: [[COND:%.*]] = phi i16 [ [[TMP14]], [[COND_TRUE]] ], [ [[TMP15]], [[COND_FALSE]] ]
// CHECK2-NEXT: store i16 [[COND]], ptr [[TMP1]], align 2
// CHECK2-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP5]])
// CHECK2-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK2: .omp.reduction.done:
// CHECK2-NEXT: ret void
Expand Down Expand Up @@ -2018,7 +2011,6 @@ int bar(int n){
// CHECK2: cond.end11:
// CHECK2-NEXT: [[COND12:%.*]] = phi i16 [ [[TMP15]], [[COND_TRUE9]] ], [ [[TMP16]], [[COND_FALSE10]] ]
// CHECK2-NEXT: store i16 [[COND12]], ptr [[TMP1]], align 2
// CHECK2-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP6]])
// CHECK2-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK2: .omp.reduction.done:
// CHECK2-NEXT: ret void
Expand Down Expand Up @@ -2500,7 +2492,6 @@ int bar(int n){
// CHECK3-NEXT: [[TMP8:%.*]] = load double, ptr [[E1]], align 8
// CHECK3-NEXT: [[ADD2:%.*]] = fadd double [[TMP7]], [[TMP8]]
// CHECK3-NEXT: store double [[ADD2]], ptr [[TMP0]], align 8
// CHECK3-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP3]])
// CHECK3-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK3: .omp.reduction.done:
// CHECK3-NEXT: call void @__kmpc_free_shared(ptr [[E1]], i32 8)
Expand Down Expand Up @@ -2796,7 +2787,6 @@ int bar(int n){
// CHECK3-NEXT: [[TMP13:%.*]] = load float, ptr [[D2]], align 4
// CHECK3-NEXT: [[MUL8:%.*]] = fmul float [[TMP12]], [[TMP13]]
// CHECK3-NEXT: store float [[MUL8]], ptr [[TMP1]], align 4
// CHECK3-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP5]])
// CHECK3-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK3: .omp.reduction.done:
// CHECK3-NEXT: call void @__kmpc_free_shared(ptr [[D2]], i32 4)
Expand Down Expand Up @@ -3145,7 +3135,6 @@ int bar(int n){
// CHECK3: cond.end:
// CHECK3-NEXT: [[COND:%.*]] = phi i16 [ [[TMP14]], [[COND_TRUE]] ], [ [[TMP15]], [[COND_FALSE]] ]
// CHECK3-NEXT: store i16 [[COND]], ptr [[TMP1]], align 2
// CHECK3-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP5]])
// CHECK3-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK3: .omp.reduction.done:
// CHECK3-NEXT: ret void
Expand Down Expand Up @@ -3215,7 +3204,6 @@ int bar(int n){
// CHECK3: cond.end11:
// CHECK3-NEXT: [[COND12:%.*]] = phi i16 [ [[TMP15]], [[COND_TRUE9]] ], [ [[TMP16]], [[COND_FALSE10]] ]
// CHECK3-NEXT: store i16 [[COND12]], ptr [[TMP1]], align 2
// CHECK3-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP6]])
// CHECK3-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK3: .omp.reduction.done:
// CHECK3-NEXT: ret void
Expand Down
1 change: 0 additions & 1 deletion clang/test/OpenMP/reduction_implicit_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ int main()
// CHECK-NEXT: [[TMP15:%.*]] = load double, ptr [[E2]], align 8
// CHECK-NEXT: [[ADD:%.*]] = fadd double [[TMP14]], [[TMP15]]
// CHECK-NEXT: store double [[ADD]], ptr [[ARRAYIDX]], align 8
// CHECK-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP10]])
// CHECK-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK: .omp.reduction.done:
// CHECK-NEXT: ret void
Expand Down
4 changes: 0 additions & 4 deletions clang/test/OpenMP/target_teams_generic_loop_codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ int foo() {
// CHECK-NEXT: [[OMP_ARRAYCPY_DONE16:%.*]] = icmp eq ptr [[OMP_ARRAYCPY_DEST_ELEMENT15]], [[TMP43]]
// CHECK-NEXT: br i1 [[OMP_ARRAYCPY_DONE16]], label [[OMP_ARRAYCPY_DONE17]], label [[OMP_ARRAYCPY_BODY]]
// CHECK: omp.arraycpy.done17:
// CHECK-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP38]])
// CHECK-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK: .omp.reduction.done:
// CHECK-NEXT: ret void
Expand Down Expand Up @@ -759,7 +758,6 @@ int foo() {
// CHECK-NEXT: [[OMP_ARRAYCPY_DONE18:%.*]] = icmp eq ptr [[OMP_ARRAYCPY_DEST_ELEMENT17]], [[TMP25]]
// CHECK-NEXT: br i1 [[OMP_ARRAYCPY_DONE18]], label [[OMP_ARRAYCPY_DONE19]], label [[OMP_ARRAYCPY_BODY]]
// CHECK: omp.arraycpy.done19:
// CHECK-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP21]])
// CHECK-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// CHECK: .omp.reduction.done:
// CHECK-NEXT: [[TMP28:%.*]] = load i32, ptr [[DOTOMP_IS_LAST_ASCAST]], align 4
Expand Down Expand Up @@ -1348,7 +1346,6 @@ int foo() {
// IR-GPU-NEXT: [[OMP_ARRAYCPY_DONE16:%.*]] = icmp eq ptr [[OMP_ARRAYCPY_DEST_ELEMENT15]], [[TMP42]]
// IR-GPU-NEXT: br i1 [[OMP_ARRAYCPY_DONE16]], label [[OMP_ARRAYCPY_DONE17]], label [[OMP_ARRAYCPY_BODY]]
// IR-GPU: omp.arraycpy.done17:
// IR-GPU-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP38]])
// IR-GPU-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// IR-GPU: .omp.reduction.done:
// IR-GPU-NEXT: ret void
Expand Down Expand Up @@ -1495,7 +1492,6 @@ int foo() {
// IR-GPU-NEXT: [[OMP_ARRAYCPY_DONE18:%.*]] = icmp eq ptr [[OMP_ARRAYCPY_DEST_ELEMENT17]], [[TMP25]]
// IR-GPU-NEXT: br i1 [[OMP_ARRAYCPY_DONE18]], label [[OMP_ARRAYCPY_DONE19]], label [[OMP_ARRAYCPY_BODY]]
// IR-GPU: omp.arraycpy.done19:
// IR-GPU-NEXT: call void @__kmpc_nvptx_end_reduce_nowait(i32 [[TMP21]])
// IR-GPU-NEXT: br label [[DOTOMP_REDUCTION_DONE]]
// IR-GPU: .omp.reduction.done:
// IR-GPU-NEXT: [[TMP28:%.*]] = load i32, ptr [[DOTOMP_IS_LAST_ASCAST]], align 4
Expand Down
14 changes: 9 additions & 5 deletions clang/tools/libclang/CIndexCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ enum CXCursorKind clang_getTemplateCursorKind(CXCursor C) {
= dyn_cast_or_null<ClassTemplatePartialSpecializationDecl>(
getCursorDecl(C))) {
switch (PartialSpec->getTagKind()) {
case TTK_Interface:
case TTK_Struct: return CXCursor_StructDecl;
case TTK_Class: return CXCursor_ClassDecl;
case TTK_Union: return CXCursor_UnionDecl;
case TTK_Enum: return CXCursor_NoDeclFound;
case TagTypeKind::Interface:
case TagTypeKind::Struct:
return CXCursor_StructDecl;
case TagTypeKind::Class:
return CXCursor_ClassDecl;
case TagTypeKind::Union:
return CXCursor_UnionDecl;
case TagTypeKind::Enum:
return CXCursor_NoDeclFound;
}
}
break;
Expand Down
5 changes: 3 additions & 2 deletions clang/unittests/AST/ASTImporterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7705,8 +7705,9 @@ TEST_P(ImportWithExternalSource, CompleteRecordBeforeImporting) {

// Create a dummy class by hand with external lexical storage.
IdentifierInfo &Ident = Context.Idents.get("test_class");
auto *Record = CXXRecordDecl::Create(
Context, TTK_Class, FromTU, SourceLocation(), SourceLocation(), &Ident);
auto *Record =
CXXRecordDecl::Create(Context, TagTypeKind::Class, FromTU,
SourceLocation(), SourceLocation(), &Ident);
Record->setHasExternalLexicalStorage();
FromTU->addDecl(Record);

Expand Down
10 changes: 5 additions & 5 deletions clang/utils/ClangVisualizers/clang.natvis
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,11 @@ For later versions of Visual Studio, no setup is required-->
<DisplayString IncludeView="implicit"></DisplayString>
<DisplayString IncludeView="modifiers">{*this,view(implicit)nd}</DisplayString>
<DisplayString IncludeView="cpp">{*this,view(modifiers)}{Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Struct">{*this,view(modifiers)nd}struct {Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Interface">{*this,view(modifiers)nd}interface {Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Union">{*this,view(modifiers)nd}union {Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Class">{*this,view(modifiers)nd}class {Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::TTK_Enum">{*this,view(modifiers)nd}enum {Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::Struct">{*this,view(modifiers)nd}struct {Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::Interface">{*this,view(modifiers)nd}interface {Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::Union">{*this,view(modifiers)nd}union {Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::Class">{*this,view(modifiers)nd}class {Name,view(cpp)}</DisplayString>
<DisplayString Condition="TagDeclBits.TagDeclKind==clang::TagTypeKind::Enum">{*this,view(modifiers)nd}enum {Name,view(cpp)}</DisplayString>
<Expand>
<ExpandedItem>(clang::DeclContext *)this</ExpandedItem>
</Expand>
Expand Down
6 changes: 3 additions & 3 deletions clang/utils/TableGen/ClangAttrEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static StringRef NormalizeNameForSpellingComparison(StringRef Name) {
// Normalize the spelling of a GNU attribute (i.e. "x" in "__attribute__((x))"),
// removing "__" if it appears at the beginning and end of the attribute's name.
static StringRef NormalizeGNUAttrSpelling(StringRef AttrSpelling) {
if (AttrSpelling.startswith("__") && AttrSpelling.endswith("__")) {
if (AttrSpelling.starts_with("__") && AttrSpelling.ends_with("__")) {
AttrSpelling = AttrSpelling.substr(2, AttrSpelling.size() - 4);
}

Expand Down Expand Up @@ -356,7 +356,7 @@ namespace {
}

void writeDump(raw_ostream &OS) const override {
if (StringRef(type).endswith("Decl *")) {
if (StringRef(type).ends_with("Decl *")) {
OS << " OS << \" \";\n";
OS << " dumpBareDeclRef(SA->get" << getUpperName() << "());\n";
} else if (type == "IdentifierInfo *") {
Expand Down Expand Up @@ -4537,7 +4537,7 @@ void EmitClangAttrParsedAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
continue;
ArgNames.push_back(Arg->getValueAsString("Name").str());
for (const auto &Class : Arg->getSuperClasses()) {
if (Class.first->getName().startswith("Variadic")) {
if (Class.first->getName().starts_with("Variadic")) {
ArgNames.back().append("...");
break;
}
Expand Down
12 changes: 6 additions & 6 deletions clang/utils/TableGen/NeonEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,17 +736,17 @@ Type Type::fromTypedefName(StringRef Name) {
Name = Name.drop_front();
}

if (Name.startswith("float")) {
if (Name.starts_with("float")) {
T.Kind = Float;
Name = Name.drop_front(5);
} else if (Name.startswith("poly")) {
} else if (Name.starts_with("poly")) {
T.Kind = Poly;
Name = Name.drop_front(4);
} else if (Name.startswith("bfloat")) {
} else if (Name.starts_with("bfloat")) {
T.Kind = BFloat16;
Name = Name.drop_front(6);
} else {
assert(Name.startswith("int"));
assert(Name.starts_with("int"));
Name = Name.drop_front(3);
}

Expand Down Expand Up @@ -787,7 +787,7 @@ Type Type::fromTypedefName(StringRef Name) {
Name = Name.drop_front(I);
}

assert(Name.startswith("_t") && "Malformed typedef!");
assert(Name.starts_with("_t") && "Malformed typedef!");
return T;
}

Expand Down Expand Up @@ -1655,7 +1655,7 @@ std::pair<Type, std::string> Intrinsic::DagEmitter::emitDagShuffle(DagInit *DI){
std::string S = "__builtin_shufflevector(" + Arg1.second + ", " + Arg2.second;
for (auto &E : Elts) {
StringRef Name = E->getName();
assert_with_loc(Name.startswith("sv"),
assert_with_loc(Name.starts_with("sv"),
"Incorrect element kind in shuffle mask!");
S += ", " + Name.drop_front(2).str();
}
Expand Down
111 changes: 69 additions & 42 deletions clang/utils/TableGen/SveEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,17 @@
//
//===----------------------------------------------------------------------===//

#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/TableGen/Record.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/TableGen/Error.h"
#include <string>
#include <sstream>
#include <set>
#include "llvm/TableGen/Record.h"
#include <array>
#include <cctype>
#include <set>
#include <sstream>
#include <string>
#include <tuple>

using namespace llvm;
Expand Down Expand Up @@ -64,26 +65,29 @@ class ImmCheck {
};

class SVEType {
TypeSpec TS;
bool Float, Signed, Immediate, Void, Constant, Pointer, BFloat;
bool DefaultType, IsScalable, Predicate, PredicatePattern, PrefetchOp,
Svcount;
unsigned Bitwidth, ElementBitwidth, NumVectors;

public:
SVEType() : SVEType(TypeSpec(), 'v') {}
SVEType() : SVEType("", 'v') {}

SVEType(TypeSpec TS, char CharMod, unsigned NumVectors = 1)
: TS(TS), Float(false), Signed(true), Immediate(false), Void(false),
SVEType(StringRef TS, char CharMod, unsigned NumVectors = 1)
: Float(false), Signed(true), Immediate(false), Void(false),
Constant(false), Pointer(false), BFloat(false), DefaultType(false),
IsScalable(true), Predicate(false), PredicatePattern(false),
PrefetchOp(false), Svcount(false), Bitwidth(128), ElementBitwidth(~0U),
NumVectors(NumVectors) {
if (!TS.empty())
applyTypespec();
applyTypespec(TS);
applyModifier(CharMod);
}

SVEType(const SVEType &Base, unsigned NumV) : SVEType(Base) {
NumVectors = NumV;
}

bool isPointer() const { return Pointer; }
bool isVoidPointer() const { return Pointer && Void; }
bool isSigned() const { return Signed; }
Expand Down Expand Up @@ -129,13 +133,12 @@ class SVEType {

private:
/// Creates the type based on the typespec string in TS.
void applyTypespec();
void applyTypespec(StringRef TS);

/// Applies a prototype modifier to the type.
void applyModifier(char Mod);
};


class SVEEmitter;

/// The main grunt class. This represents an instantiation of an intrinsic with
Expand Down Expand Up @@ -263,17 +266,11 @@ class SVEEmitter {
// which is inconvenient to specify in the arm_sve.td file or
// generate in CGBuiltin.cpp.
struct ReinterpretTypeInfo {
SVEType BaseType;
const char *Suffix;
const char *Type;
const char *BuiltinType;
};
SmallVector<ReinterpretTypeInfo, 12> Reinterprets = {
{"s8", "svint8_t", "q16Sc"}, {"s16", "svint16_t", "q8Ss"},
{"s32", "svint32_t", "q4Si"}, {"s64", "svint64_t", "q2SWi"},
{"u8", "svuint8_t", "q16Uc"}, {"u16", "svuint16_t", "q8Us"},
{"u32", "svuint32_t", "q4Ui"}, {"u64", "svuint64_t", "q2UWi"},
{"f16", "svfloat16_t", "q8h"}, {"bf16", "svbfloat16_t", "q8y"},
{"f32", "svfloat32_t", "q4f"}, {"f64", "svfloat64_t", "q2d"}};

static const std::array<ReinterpretTypeInfo, 12> Reinterprets;

RecordKeeper &Records;
llvm::StringMap<uint64_t> EltTypes;
Expand Down Expand Up @@ -383,6 +380,20 @@ class SVEEmitter {
SmallVectorImpl<std::unique_ptr<Intrinsic>> &Out);
};

const std::array<SVEEmitter::ReinterpretTypeInfo, 12> SVEEmitter::Reinterprets =
{{{SVEType("c", 'd'), "s8"},
{SVEType("Uc", 'd'), "u8"},
{SVEType("s", 'd'), "s16"},
{SVEType("Us", 'd'), "u16"},
{SVEType("i", 'd'), "s32"},
{SVEType("Ui", 'd'), "u32"},
{SVEType("l", 'd'), "s64"},
{SVEType("Ul", 'd'), "u64"},
{SVEType("h", 'd'), "f16"},
{SVEType("b", 'd'), "bf16"},
{SVEType("f", 'd'), "f32"},
{SVEType("d", 'd'), "f64"}}};

} // end anonymous namespace


Expand Down Expand Up @@ -497,7 +508,8 @@ std::string SVEType::str() const {

return S;
}
void SVEType::applyTypespec() {

void SVEType::applyTypespec(StringRef TS) {
for (char I : TS) {
switch (I) {
case 'Q':
Expand Down Expand Up @@ -1315,21 +1327,28 @@ void SVEEmitter::createHeader(raw_ostream &OS) {
"__nodebug__, __overloadable__))\n\n";

// Add reinterpret functions.
for (auto ShortForm : { false, true } )
for (const ReinterpretTypeInfo &From : Reinterprets)
for (auto [N, Suffix] :
std::initializer_list<std::pair<unsigned, const char *>>{
{1, ""}, {2, "_x2"}, {3, "_x3"}, {4, "_x4"}}) {
for (auto ShortForm : {false, true})
for (const ReinterpretTypeInfo &To : Reinterprets) {
if (ShortForm) {
OS << "__aio __attribute__((target(\"sve\"))) " << From.Type
<< " svreinterpret_" << From.Suffix;
OS << "(" << To.Type << " op) __arm_streaming_compatible {\n";
OS << " return __builtin_sve_reinterpret_" << From.Suffix << "_"
<< To.Suffix << "(op);\n";
OS << "}\n\n";
} else
OS << "#define svreinterpret_" << From.Suffix << "_" << To.Suffix
<< "(...) __builtin_sve_reinterpret_" << From.Suffix << "_"
<< To.Suffix << "(__VA_ARGS__)\n";
SVEType ToV(To.BaseType, N);
for (const ReinterpretTypeInfo &From : Reinterprets) {
SVEType FromV(From.BaseType, N);
if (ShortForm) {
OS << "__aio __attribute__((target(\"sve\"))) " << ToV.str()
<< " svreinterpret_" << To.Suffix;
OS << "(" << FromV.str() << " op) __arm_streaming_compatible {\n";
OS << " return __builtin_sve_reinterpret_" << To.Suffix << "_"
<< From.Suffix << Suffix << "(op);\n";
OS << "}\n\n";
} else
OS << "#define svreinterpret_" << To.Suffix << "_" << From.Suffix
<< Suffix << "(...) __builtin_sve_reinterpret_" << To.Suffix
<< "_" << From.Suffix << Suffix << "(__VA_ARGS__)\n";
}
}
}

SmallVector<std::unique_ptr<Intrinsic>, 128> Defs;
std::vector<Record *> RV = Records.getAllDerivedDefinitions("Inst");
Expand Down Expand Up @@ -1394,12 +1413,20 @@ void SVEEmitter::createBuiltins(raw_ostream &OS) {
<< "\")\n";
}

// Add reinterpret builtins
for (const ReinterpretTypeInfo &From : Reinterprets)
for (const ReinterpretTypeInfo &To : Reinterprets)
OS << "TARGET_BUILTIN(__builtin_sve_reinterpret_" << From.Suffix << "_"
<< To.Suffix << +", \"" << From.BuiltinType << To.BuiltinType
<< "\", \"n\", \"sve\")\n";
// Add reinterpret functions.
for (auto [N, Suffix] :
std::initializer_list<std::pair<unsigned, const char *>>{
{1, ""}, {2, "_x2"}, {3, "_x3"}, {4, "_x4"}}) {
for (const ReinterpretTypeInfo &To : Reinterprets) {
SVEType ToV(To.BaseType, N);
for (const ReinterpretTypeInfo &From : Reinterprets) {
SVEType FromV(From.BaseType, N);
OS << "TARGET_BUILTIN(__builtin_sve_reinterpret_" << To.Suffix << "_"
<< From.Suffix << Suffix << +", \"" << ToV.builtin_str()
<< FromV.builtin_str() << "\", \"n\", \"sve\")\n";
}
}
}

OS << "#endif\n\n";
}
Expand Down
Loading