Index: clang/docs/LanguageExtensions.rst =================================================================== --- clang/docs/LanguageExtensions.rst +++ clang/docs/LanguageExtensions.rst @@ -3968,55 +3968,10 @@ Extended Integer Types ====================== -Clang supports a set of extended integer types under the syntax ``_ExtInt(N)`` -where ``N`` is an integer that specifies the number of bits that are used to represent -the type, including the sign bit. The keyword ``_ExtInt`` is a type specifier, thus -it can be used in any place a type can, including as a non-type-template-parameter, -as the type of a bitfield, and as the underlying type of an enumeration. - -An extended integer can be declared either signed, or unsigned by using the -``signed``/``unsigned`` keywords. If no sign specifier is used or if the ``signed`` -keyword is used, the extended integer type is a signed integer and can represent -negative values. - -The ``N`` expression is an integer constant expression, which specifies the number -of bits used to represent the type, following normal integer representations for -both signed and unsigned types. Both a signed and unsigned extended integer of the -same ``N`` value will have the same number of bits in its representation. Many -architectures don't have a way of representing non power-of-2 integers, so these -architectures emulate these types using larger integers. In these cases, they are -expected to follow the 'as-if' rule and do math 'as-if' they were done at the -specified number of bits. - -In order to be consistent with the C language specification, and make the extended -integer types useful for their intended purpose, extended integers follow the C -standard integer conversion ranks. An extended integer type has a greater rank than -any integer type with less precision. However, they have lower rank than any -of the built in or other integer types (such as __int128). Usual arithmetic conversions -also work the same, where the smaller ranked integer is converted to the larger. - -The one exception to the C rules for integers for these types is Integer Promotion. -Unary +, -, and ~ operators typically will promote operands to ``int``. Doing these -promotions would inflate the size of required hardware on some platforms, so extended -integer types aren't subject to the integer promotion rules in these cases. - -In languages (such as OpenCL) that define shift by-out-of-range behavior as a mask, -non-power-of-two versions of these types use an unsigned remainder operation to constrain -the value to the proper range, preventing undefined behavior. - -Extended integer types are aligned to the next greatest power-of-2 up to 64 bits. -The size of these types for the purposes of layout and ``sizeof`` are the number of -bits aligned to this calculated alignment. This permits the use of these types in -allocated arrays using common ``sizeof(Array)/sizeof(ElementType)`` pattern. - -Extended integer types work with the C _Atomic type modifier, however only precisions -that are powers-of-2 greater than 8 bit are accepted. - -Extended integer types align with existing calling conventions. They have the same size -and alignment as the smallest basic type that can contain them. Types that are larger -than 64 bits are handled in the same way as _int128 is handled; they are conceptually -treated as struct of register size chunks. They number of chunks are the smallest -number that can contain the types which does not necessarily mean a power-of-2 size. +Clang supports the C23 ``_BitInt`` feature as an extension in older C modes and +in C++. This type was previously implemented in Clang with the same semantics, +but spelled ``_ExtInt``. This spelling has been deprecated in favor of the +standard type. Intrinsics Support within Constant Expressions ============================================== Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -104,6 +104,14 @@ are now ill-formed in all language modes. The motivation for this change is outlined in `P2362 `_. +- Clang now supports the ``_BitInt(N)`` family of bit-precise integer types + from C23. This type was previously exposed as ``_ExtInt(N)``, which is now a + deprecated alias for ``_BitInt(N)`` (so diagnostics will mention ``_BitInt`` + even if source uses ``_ExtInt``). ``_BitInt(N)`` and ``_ExtInt(N)`` are the + same types in all respects beyond spelling and the deprecation warning. + ``_BitInt(N)`` is supported as an extension in older C modes and in all C++ + modes. + C++ Language Changes in Clang ----------------------------- @@ -134,6 +142,11 @@ ABI Changes in Clang -------------------- +- The ``_ExtInt(N)`` family of types have been replaced with the C2X + standardized version of the feature, ``_BitInt(N)``. Therefore, source that + previously used the ``_ExtInt`` types will now be mangled to instead use the + ``_BitInt(N)`` spelling in both the Microsoft and Itanium ABIs. + OpenMP Support in Clang ----------------------- Index: clang/include/clang/AST/ASTContext.h =================================================================== --- clang/include/clang/AST/ASTContext.h +++ clang/include/clang/AST/ASTContext.h @@ -241,8 +241,8 @@ mutable llvm::FoldingSet AtomicTypes; llvm::FoldingSet AttributedTypes; mutable llvm::FoldingSet PipeTypes; - mutable llvm::FoldingSet ExtIntTypes; - mutable llvm::FoldingSet DependentExtIntTypes; + mutable llvm::FoldingSet BitIntTypes; + mutable llvm::FoldingSet DependentBitIntTypes; mutable llvm::FoldingSet QualifiedTemplateNames; mutable llvm::FoldingSet DependentTemplateNames; @@ -1322,13 +1322,13 @@ /// Return a write_only pipe type for the specified type. QualType getWritePipeType(QualType T) const; - /// Return an extended integer type with the specified signedness and bit + /// Return a bit-precise integer type with the specified signedness and bit /// count. - QualType getExtIntType(bool Unsigned, unsigned NumBits) const; + QualType getBitIntType(bool Unsigned, unsigned NumBits) const; - /// Return a dependent extended integer type with the specified signedness and - /// bit count. - QualType getDependentExtIntType(bool Unsigned, Expr *BitsExpr) const; + /// Return a dependent bit-precise integer type with the specified signedness + /// and bit count. + QualType getDependentBitIntType(bool Unsigned, Expr *BitsExpr) const; /// Gets the struct used to keep track of the extended descriptor for /// pointer to blocks. Index: clang/include/clang/AST/RecursiveASTVisitor.h =================================================================== --- clang/include/clang/AST/RecursiveASTVisitor.h +++ clang/include/clang/AST/RecursiveASTVisitor.h @@ -1072,8 +1072,8 @@ DEF_TRAVERSE_TYPE(PipeType, { TRY_TO(TraverseType(T->getElementType())); }) -DEF_TRAVERSE_TYPE(ExtIntType, {}) -DEF_TRAVERSE_TYPE(DependentExtIntType, +DEF_TRAVERSE_TYPE(BitIntType, {}) +DEF_TRAVERSE_TYPE(DependentBitIntType, { TRY_TO(TraverseStmt(T->getNumBitsExpr())); }) #undef DEF_TRAVERSE_TYPE @@ -1358,8 +1358,8 @@ DEF_TRAVERSE_TYPELOC(PipeType, { TRY_TO(TraverseTypeLoc(TL.getValueLoc())); }) -DEF_TRAVERSE_TYPELOC(ExtIntType, {}) -DEF_TRAVERSE_TYPELOC(DependentExtIntType, { +DEF_TRAVERSE_TYPELOC(BitIntType, {}) +DEF_TRAVERSE_TYPELOC(DependentBitIntType, { TRY_TO(TraverseStmt(TL.getTypePtr()->getNumBitsExpr())); }) Index: clang/include/clang/AST/Type.h =================================================================== --- clang/include/clang/AST/Type.h +++ clang/include/clang/AST/Type.h @@ -2127,7 +2127,7 @@ bool isOCLExtOpaqueType() const; // Any OpenCL extension type bool isPipeType() const; // OpenCL pipe type - bool isExtIntType() const; // Extended Int Type + bool isBitIntType() const; // Bit-precise integer type bool isOpenCLSpecificType() const; // Any OpenCL specific type /// Determines if this type, which must satisfy @@ -6307,13 +6307,13 @@ }; /// A fixed int type of a specified bitwidth. -class ExtIntType final : public Type, public llvm::FoldingSetNode { +class BitIntType final : public Type, public llvm::FoldingSetNode { friend class ASTContext; unsigned IsUnsigned : 1; unsigned NumBits : 24; protected: - ExtIntType(bool isUnsigned, unsigned NumBits); + BitIntType(bool isUnsigned, unsigned NumBits); public: bool isUnsigned() const { return IsUnsigned; } @@ -6333,16 +6333,16 @@ ID.AddInteger(NumBits); } - static bool classof(const Type *T) { return T->getTypeClass() == ExtInt; } + static bool classof(const Type *T) { return T->getTypeClass() == BitInt; } }; -class DependentExtIntType final : public Type, public llvm::FoldingSetNode { +class DependentBitIntType final : public Type, public llvm::FoldingSetNode { friend class ASTContext; const ASTContext &Context; llvm::PointerIntPair ExprAndUnsigned; protected: - DependentExtIntType(const ASTContext &Context, bool IsUnsigned, + DependentBitIntType(const ASTContext &Context, bool IsUnsigned, Expr *NumBits); public: @@ -6360,7 +6360,7 @@ bool IsUnsigned, Expr *NumBitsExpr); static bool classof(const Type *T) { - return T->getTypeClass() == DependentExtInt; + return T->getTypeClass() == DependentBitInt; } }; @@ -6891,8 +6891,8 @@ return isa(CanonicalType); } -inline bool Type::isExtIntType() const { - return isa(CanonicalType); +inline bool Type::isBitIntType() const { + return isa(CanonicalType); } #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ @@ -6994,7 +6994,7 @@ return IsEnumDeclComplete(ET->getDecl()) && !IsEnumDeclScoped(ET->getDecl()); } - return isExtIntType(); + return isBitIntType(); } inline bool Type::isFixedPointType() const { @@ -7052,7 +7052,7 @@ isa(CanonicalType) || isa(CanonicalType) || isa(CanonicalType) || - isExtIntType(); + isBitIntType(); } inline bool Type::isIntegralOrEnumerationType() const { @@ -7065,7 +7065,7 @@ if (const auto *ET = dyn_cast(CanonicalType)) return IsEnumDeclComplete(ET->getDecl()); - return isExtIntType(); + return isBitIntType(); } inline bool Type::isBooleanType() const { Index: clang/include/clang/AST/TypeLoc.h =================================================================== --- clang/include/clang/AST/TypeLoc.h +++ clang/include/clang/AST/TypeLoc.h @@ -2562,12 +2562,12 @@ } return Cur.getAs(); } -class ExtIntTypeLoc final - : public InheritingConcreteTypeLoc {}; -class DependentExtIntTypeLoc final - : public InheritingConcreteTypeLoc {}; +class BitIntTypeLoc final + : public InheritingConcreteTypeLoc {}; +class DependentBitIntTypeLoc final + : public InheritingConcreteTypeLoc {}; } // namespace clang Index: clang/include/clang/AST/TypeProperties.td =================================================================== --- clang/include/clang/AST/TypeProperties.td +++ clang/include/clang/AST/TypeProperties.td @@ -882,7 +882,7 @@ }]>; } -let Class = ExtIntType in { +let Class = BitIntType in { def : Property<"isUnsigned", Bool> { let Read = [{ node->isUnsigned() }]; } @@ -891,11 +891,11 @@ } def : Creator<[{ - return ctx.getExtIntType(isUnsigned, numBits); + return ctx.getBitIntType(isUnsigned, numBits); }]>; } -let Class = DependentExtIntType in { +let Class = DependentBitIntType in { def : Property<"isUnsigned", Bool> { let Read = [{ node->isUnsigned() }]; } @@ -903,6 +903,6 @@ let Read = [{ node->getNumBitsExpr() }]; } def : Creator<[{ - return ctx.getDependentExtIntType(isUnsigned, numBitsExpr); + return ctx.getDependentBitIntType(isUnsigned, numBitsExpr); }]>; } Index: clang/include/clang/Basic/DiagnosticGroups.td =================================================================== --- clang/include/clang/Basic/DiagnosticGroups.td +++ clang/include/clang/Basic/DiagnosticGroups.td @@ -186,6 +186,7 @@ def DeprecatedWritableStr : DiagGroup<"deprecated-writable-strings", [CXX11CompatDeprecatedWritableStr]>; def DeprecatedPragma : DiagGroup<"deprecated-pragma">; +def DeprecatedType : DiagGroup<"deprecated-type">; // FIXME: Why is DeprecatedImplementations not in this group? def Deprecated : DiagGroup<"deprecated", [DeprecatedAnonEnumEnumConversion, DeprecatedArrayCompare, @@ -203,6 +204,7 @@ DeprecatedPragma, DeprecatedRegister, DeprecatedThisCapture, + DeprecatedType, DeprecatedVolatile, DeprecatedWritableStr]>, DiagCategory<"Deprecations">; Index: clang/include/clang/Basic/DiagnosticParseKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticParseKinds.td +++ clang/include/clang/Basic/DiagnosticParseKinds.td @@ -1480,6 +1480,15 @@ def err_pragma_cannot_end_force_cuda_host_device : Error< "force_cuda_host_device end pragma without matching " "force_cuda_host_device begin">; + +def warn_ext_int_deprecated : Warning< + "'_ExtInt' is deprecated; use '_BitInt' instead">, InGroup; +def ext_bit_int : Extension< + "'_BitInt' in %select{C17 and earlier|C++}0 is a Clang extension">, + InGroup>; +def warn_c17_compat_bit_int : Warning< + "'_BitInt' is incompatible with C standards before C2x">, + InGroup, DefaultIgnore; } // end of Parse Issue category. let CategoryName = "Modules Issue" in { Index: clang/include/clang/Basic/DiagnosticSemaKinds.td =================================================================== --- clang/include/clang/Basic/DiagnosticSemaKinds.td +++ clang/include/clang/Basic/DiagnosticSemaKinds.td @@ -8313,8 +8313,8 @@ " 1,2,4 or 8 byte type (%0 invalid)">; def err_atomic_builtin_ext_int_size : Error< "Atomic memory operand must have a power-of-two size">; -def err_atomic_builtin_ext_int_prohibit : Error< - "argument to atomic builtin of type '_ExtInt' is not supported">; +def err_atomic_builtin_bit_int_prohibit : Error< + "argument to atomic builtin of type '_BitInt' is not supported">; def err_atomic_op_needs_atomic : Error< "address argument to atomic operation must be a pointer to _Atomic " "type (%0 invalid)">; @@ -8350,8 +8350,8 @@ def err_overflow_builtin_must_be_ptr_int : Error< "result argument to overflow builtin must be a pointer " "to a non-const integer (%0 invalid)">; -def err_overflow_builtin_ext_int_max_size : Error< - "__builtin_mul_overflow does not support signed _ExtInt operands of more " +def err_overflow_builtin_bit_int_max_size : Error< + "__builtin_mul_overflow does not support 'signed _BitInt' operands of more " "than %0 bits">; def err_atomic_load_store_uses_lib : Error< @@ -11331,9 +11331,9 @@ "function template with 'sycl_kernel' attribute must have a 'void' return type">, InGroup; -def err_ext_int_bad_size : Error<"%select{signed|unsigned}0 _ExtInt must " +def err_bit_int_bad_size : Error<"%select{signed|unsigned}0 _BitInt must " "have a bit size of at least %select{2|1}0">; -def err_ext_int_max_size : Error<"%select{signed|unsigned}0 _ExtInt of bit " +def err_bit_int_max_size : Error<"%select{signed|unsigned}0 _BitInt of bit " "sizes greater than %1 not supported">; // errors of expect.with.probability Index: clang/include/clang/Basic/Specifiers.h =================================================================== --- clang/include/clang/Basic/Specifiers.h +++ clang/include/clang/Basic/Specifiers.h @@ -50,7 +50,7 @@ TST_char32, // C++11 char32_t TST_int, TST_int128, - TST_extint, // Extended Int types. + TST_bitint, // Bit-precise integer types. TST_half, // OpenCL half, ARM NEON __fp16 TST_Float16, // C11 extension ISO/IEC TS 18661-3 TST_Accum, // ISO/IEC JTC1 SC22 WG14 N1169 Extension Index: clang/include/clang/Basic/TargetInfo.h =================================================================== --- clang/include/clang/Basic/TargetInfo.h +++ clang/include/clang/Basic/TargetInfo.h @@ -576,9 +576,13 @@ return (getPointerWidth(0) >= 64) || getTargetOpts().ForceEnableInt128; } // FIXME - /// Determine whether the _ExtInt type is supported on this target. This + /// Determine whether the _BitInt type is supported on this target. This /// limitation is put into place for ABI reasons. - virtual bool hasExtIntType() const { + /// FIXME: _BitInt is a required type in C23, so there's not much utility in + /// asking whether the target supported it or not; I think this should be + /// removed once backends have been alerted to the type and have had the + /// chance to do implementation work if needed. + virtual bool hasBitIntType() const { return false; } Index: clang/include/clang/Basic/TokenKinds.def =================================================================== --- clang/include/clang/Basic/TokenKinds.def +++ clang/include/clang/Basic/TokenKinds.def @@ -300,6 +300,7 @@ KEYWORD(inline , KEYC99|KEYCXX|KEYGNU) KEYWORD(int , KEYALL) KEYWORD(_ExtInt , KEYALL) +KEYWORD(_BitInt , KEYALL) KEYWORD(long , KEYALL) KEYWORD(register , KEYALL) KEYWORD(restrict , KEYC99) Index: clang/include/clang/Basic/TypeNodes.td =================================================================== --- clang/include/clang/Basic/TypeNodes.td +++ clang/include/clang/Basic/TypeNodes.td @@ -107,5 +107,5 @@ def ObjCObjectPointerType : TypeNode; def PipeType : TypeNode; def AtomicType : TypeNode; -def ExtIntType : TypeNode; -def DependentExtIntType : TypeNode, AlwaysDependent; +def BitIntType : TypeNode; +def DependentBitIntType : TypeNode, AlwaysDependent; Index: clang/include/clang/Parse/Parser.h =================================================================== --- clang/include/clang/Parse/Parser.h +++ clang/include/clang/Parse/Parser.h @@ -2559,6 +2559,10 @@ /// full validation of the syntactic structure of attributes. bool TrySkipAttributes(); + /// Diagnoses use of _ExtInt as being deprecated, and diagnoses use of + /// _BitInt as an extension when appropriate. + void DiagnoseBitIntUse(const Token &Tok); + public: TypeResult ParseTypeName(SourceRange *Range = nullptr, Index: clang/include/clang/Sema/DeclSpec.h =================================================================== --- clang/include/clang/Sema/DeclSpec.h +++ clang/include/clang/Sema/DeclSpec.h @@ -266,7 +266,7 @@ static const TST TST_char32 = clang::TST_char32; static const TST TST_int = clang::TST_int; static const TST TST_int128 = clang::TST_int128; - static const TST TST_extint = clang::TST_extint; + static const TST TST_bitint = clang::TST_bitint; static const TST TST_half = clang::TST_half; static const TST TST_BFloat16 = clang::TST_BFloat16; static const TST TST_float = clang::TST_float; @@ -403,7 +403,7 @@ T == TST_underlyingType || T == TST_atomic); } static bool isExprRep(TST T) { - return (T == TST_typeofExpr || T == TST_decltype || T == TST_extint); + return (T == TST_typeofExpr || T == TST_decltype || T == TST_bitint); } static bool isTemplateIdRep(TST T) { return (T == TST_auto || T == TST_decltype_auto); @@ -702,7 +702,7 @@ bool SetTypePipe(bool isPipe, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy); - bool SetExtIntType(SourceLocation KWLoc, Expr *BitWidth, + bool SetBitIntType(SourceLocation KWLoc, Expr *BitWidth, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy); bool SetTypeSpecSat(SourceLocation Loc, const char *&PrevSpec, Index: clang/include/clang/Sema/Sema.h =================================================================== --- clang/include/clang/Sema/Sema.h +++ clang/include/clang/Sema/Sema.h @@ -2003,7 +2003,7 @@ SourceLocation Loc); QualType BuildWritePipeType(QualType T, SourceLocation Loc); - QualType BuildExtIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc); + QualType BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc); TypeSourceInfo *GetTypeForDeclarator(Declarator &D, Scope *S); TypeSourceInfo *GetTypeForDeclaratorCast(Declarator &D, QualType FromTy); Index: clang/include/clang/Serialization/TypeBitCodes.def =================================================================== --- clang/include/clang/Serialization/TypeBitCodes.def +++ clang/include/clang/Serialization/TypeBitCodes.def @@ -58,8 +58,8 @@ TYPE_BIT_CODE(DependentAddressSpace, DEPENDENT_ADDRESS_SPACE, 47) TYPE_BIT_CODE(DependentVector, DEPENDENT_SIZED_VECTOR, 48) TYPE_BIT_CODE(MacroQualified, MACRO_QUALIFIED, 49) -TYPE_BIT_CODE(ExtInt, EXT_INT, 50) -TYPE_BIT_CODE(DependentExtInt, DEPENDENT_EXT_INT, 51) +TYPE_BIT_CODE(BitInt, BIT_INT, 50) +TYPE_BIT_CODE(DependentBitInt, DEPENDENT_BIT_INT, 51) TYPE_BIT_CODE(ConstantMatrix, CONSTANT_MATRIX, 52) TYPE_BIT_CODE(DependentSizedMatrix, DEPENDENT_SIZE_MATRIX, 53) Index: clang/lib/AST/ASTContext.cpp =================================================================== --- clang/lib/AST/ASTContext.cpp +++ clang/lib/AST/ASTContext.cpp @@ -2273,8 +2273,8 @@ Align = toBits(Layout.getAlignment()); break; } - case Type::ExtInt: { - const auto *EIT = cast(T); + case Type::BitInt: { + const auto *EIT = cast(T); Align = std::min(static_cast(std::max( getCharWidth(), llvm::PowerOf2Ceil(EIT->getNumBits()))), @@ -3528,8 +3528,8 @@ case Type::Auto: case Type::DeducedTemplateSpecialization: case Type::PackExpansion: - case Type::ExtInt: - case Type::DependentExtInt: + case Type::BitInt: + case Type::DependentBitInt: llvm_unreachable("type should never be variably-modified"); // These types can be variably-modified but should never need to @@ -4441,34 +4441,34 @@ return getPipeType(T, false); } -QualType ASTContext::getExtIntType(bool IsUnsigned, unsigned NumBits) const { +QualType ASTContext::getBitIntType(bool IsUnsigned, unsigned NumBits) const { llvm::FoldingSetNodeID ID; - ExtIntType::Profile(ID, IsUnsigned, NumBits); + BitIntType::Profile(ID, IsUnsigned, NumBits); void *InsertPos = nullptr; - if (ExtIntType *EIT = ExtIntTypes.FindNodeOrInsertPos(ID, InsertPos)) + if (BitIntType *EIT = BitIntTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(EIT, 0); - auto *New = new (*this, TypeAlignment) ExtIntType(IsUnsigned, NumBits); - ExtIntTypes.InsertNode(New, InsertPos); + auto *New = new (*this, TypeAlignment) BitIntType(IsUnsigned, NumBits); + BitIntTypes.InsertNode(New, InsertPos); Types.push_back(New); return QualType(New, 0); } -QualType ASTContext::getDependentExtIntType(bool IsUnsigned, +QualType ASTContext::getDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr) const { assert(NumBitsExpr->isInstantiationDependent() && "Only good for dependent"); llvm::FoldingSetNodeID ID; - DependentExtIntType::Profile(ID, *this, IsUnsigned, NumBitsExpr); + DependentBitIntType::Profile(ID, *this, IsUnsigned, NumBitsExpr); void *InsertPos = nullptr; - if (DependentExtIntType *Existing = - DependentExtIntTypes.FindNodeOrInsertPos(ID, InsertPos)) + if (DependentBitIntType *Existing = + DependentBitIntTypes.FindNodeOrInsertPos(ID, InsertPos)) return QualType(Existing, 0); auto *New = new (*this, TypeAlignment) - DependentExtIntType(*this, IsUnsigned, NumBitsExpr); - DependentExtIntTypes.InsertNode(New, InsertPos); + DependentBitIntType(*this, IsUnsigned, NumBitsExpr); + DependentBitIntTypes.InsertNode(New, InsertPos); Types.push_back(New); return QualType(New, 0); @@ -6348,7 +6348,7 @@ // Results in this 'losing' to any type of the same size, but winning if // larger. - if (const auto *EIT = dyn_cast(T)) + if (const auto *EIT = dyn_cast(T)) return 0 + (EIT->getNumBits() << 3); switch (cast(T)->getKind()) { @@ -7788,7 +7788,7 @@ return; case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: #define ABSTRACT_TYPE(KIND, BASE) #define TYPE(KIND, BASE) #define DEPENDENT_TYPE(KIND, BASE) \ @@ -10000,12 +10000,12 @@ assert(LHS != RHS && "Equivalent pipe types should have already been handled!"); return {}; - case Type::ExtInt: { - // Merge two ext-int types, while trying to preserve typedef info. - bool LHSUnsigned = LHS->castAs()->isUnsigned(); - bool RHSUnsigned = RHS->castAs()->isUnsigned(); - unsigned LHSBits = LHS->castAs()->getNumBits(); - unsigned RHSBits = RHS->castAs()->getNumBits(); + case Type::BitInt: { + // Merge two bit-precise int types, while trying to preserve typedef info. + bool LHSUnsigned = LHS->castAs()->isUnsigned(); + bool RHSUnsigned = RHS->castAs()->isUnsigned(); + unsigned LHSBits = LHS->castAs()->getNumBits(); + unsigned RHSBits = RHS->castAs()->getNumBits(); // Like unsigned/int, shouldn't have a type if they dont match. if (LHSUnsigned != RHSUnsigned) @@ -10155,7 +10155,7 @@ T = ET->getDecl()->getIntegerType(); if (T->isBooleanType()) return 1; - if(const auto *EIT = T->getAs()) + if (const auto *EIT = T->getAs()) return EIT->getNumBits(); // For builtin types, just use the standard type sizing method return (unsigned)getTypeSize(T); @@ -10170,9 +10170,9 @@ return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()), VTy->getNumElements(), VTy->getVectorKind()); - // For _ExtInt, return an unsigned _ExtInt with same width. - if (const auto *EITy = T->getAs()) - return getExtIntType(/*IsUnsigned=*/true, EITy->getNumBits()); + // For _BitInt, return an unsigned _BitInt with same width. + if (const auto *EITy = T->getAs()) + return getBitIntType(/*IsUnsigned=*/true, EITy->getNumBits()); // For enums, get the underlying integer type of the enum, and let the general // integer type signchanging code handle it. @@ -10238,9 +10238,9 @@ return getVectorType(getCorrespondingSignedType(VTy->getElementType()), VTy->getNumElements(), VTy->getVectorKind()); - // For _ExtInt, return a signed _ExtInt with same width. - if (const auto *EITy = T->getAs()) - return getExtIntType(/*IsUnsigned=*/false, EITy->getNumBits()); + // For _BitInt, return a signed _BitInt with same width. + if (const auto *EITy = T->getAs()) + return getBitIntType(/*IsUnsigned=*/false, EITy->getNumBits()); // For enums, get the underlying integer type of the enum, and let the general // integer type signchanging code handle it. Index: clang/lib/AST/ASTStructuralEquivalence.cpp =================================================================== --- clang/lib/AST/ASTStructuralEquivalence.cpp +++ clang/lib/AST/ASTStructuralEquivalence.cpp @@ -1205,18 +1205,18 @@ cast(T2)->getElementType())) return false; break; - case Type::ExtInt: { - const auto *Int1 = cast(T1); - const auto *Int2 = cast(T2); + case Type::BitInt: { + const auto *Int1 = cast(T1); + const auto *Int2 = cast(T2); if (Int1->isUnsigned() != Int2->isUnsigned() || Int1->getNumBits() != Int2->getNumBits()) return false; break; } - case Type::DependentExtInt: { - const auto *Int1 = cast(T1); - const auto *Int2 = cast(T2); + case Type::DependentBitInt: { + const auto *Int1 = cast(T1); + const auto *Int2 = cast(T2); if (Int1->isUnsigned() != Int2->isUnsigned() || !IsStructurallyEquivalent(Context, Int1->getNumBitsExpr(), Index: clang/lib/AST/ExprConstant.cpp =================================================================== --- clang/lib/AST/ExprConstant.cpp +++ clang/lib/AST/ExprConstant.cpp @@ -11062,7 +11062,7 @@ case Type::ObjCInterface: case Type::ObjCObjectPointer: case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: // GCC classifies vectors as None. We follow its lead and classify all // other types that don't fit into the regular classification the same way. return GCCTypeClass::None; Index: clang/lib/AST/ItaniumMangle.cpp =================================================================== --- clang/lib/AST/ItaniumMangle.cpp +++ clang/lib/AST/ItaniumMangle.cpp @@ -2256,8 +2256,8 @@ case Type::Atomic: case Type::Pipe: case Type::MacroQualified: - case Type::ExtInt: - case Type::DependentExtInt: + case Type::BitInt: + case Type::DependentBitInt: llvm_unreachable("type is illegal as a nested name specifier"); case Type::SubstTemplateTypeParmPack: @@ -3954,26 +3954,22 @@ Out << "8ocl_pipe"; } -void CXXNameMangler::mangleType(const ExtIntType *T) { - Out << "U7_ExtInt"; - llvm::APSInt BW(32, true); - BW = T->getNumBits(); - TemplateArgument TA(Context.getASTContext(), BW, getASTContext().IntTy); - mangleTemplateArgs(TemplateName(), &TA, 1); - if (T->isUnsigned()) - Out << "j"; - else - Out << "i"; +void CXXNameMangler::mangleType(const BitIntType *T) { + // FIXME: this is proposed to the Itanium ABI group but not yet accepted. + // 5.1.5.2 Builtin types + // ::= DB _ + // ::= DU _ + Out << "D" << (T->isUnsigned() ? "U" : "B") << T->getNumBits() << "_"; } -void CXXNameMangler::mangleType(const DependentExtIntType *T) { - Out << "U7_ExtInt"; - TemplateArgument TA(T->getNumBitsExpr()); - mangleTemplateArgs(TemplateName(), &TA, 1); - if (T->isUnsigned()) - Out << "j"; - else - Out << "i"; +void CXXNameMangler::mangleType(const DependentBitIntType *T) { + // FIXME: this is proposed to the Itanium ABI group but not yet accepted. + // 5.1.5.2 Builtin types + // ::= DB _ + // ::= DU _ + Out << "D" << (T->isUnsigned() ? "U" : "B"); + mangleExpression(T->getNumBitsExpr()); + Out << "_"; } void CXXNameMangler::mangleIntegerLiteral(QualType T, Index: clang/lib/AST/MicrosoftMangle.cpp =================================================================== --- clang/lib/AST/MicrosoftMangle.cpp +++ clang/lib/AST/MicrosoftMangle.cpp @@ -3335,26 +3335,26 @@ return Mangler.mangle(D); } -void MicrosoftCXXNameMangler::mangleType(const ExtIntType *T, Qualifiers, +void MicrosoftCXXNameMangler::mangleType(const BitIntType *T, Qualifiers, SourceRange Range) { llvm::SmallString<64> TemplateMangling; llvm::raw_svector_ostream Stream(TemplateMangling); MicrosoftCXXNameMangler Extra(Context, Stream); Stream << "?$"; if (T->isUnsigned()) - Extra.mangleSourceName("_UExtInt"); + Extra.mangleSourceName("_UBitInt"); else - Extra.mangleSourceName("_ExtInt"); + Extra.mangleSourceName("_BitInt"); Extra.mangleIntegerLiteral(llvm::APSInt::getUnsigned(T->getNumBits())); mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"}); } -void MicrosoftCXXNameMangler::mangleType(const DependentExtIntType *T, +void MicrosoftCXXNameMangler::mangleType(const DependentBitIntType *T, Qualifiers, SourceRange Range) { DiagnosticsEngine &Diags = Context.getDiags(); unsigned DiagID = Diags.getCustomDiagID( - DiagnosticsEngine::Error, "cannot mangle this DependentExtInt type yet"); + DiagnosticsEngine::Error, "cannot mangle this DependentBitInt type yet"); Diags.Report(Range.getBegin(), DiagID) << Range; } Index: clang/lib/AST/Type.cpp =================================================================== --- clang/lib/AST/Type.cpp +++ clang/lib/AST/Type.cpp @@ -338,25 +338,25 @@ VectorTypeBits.NumElements = nElements; } -ExtIntType::ExtIntType(bool IsUnsigned, unsigned NumBits) - : Type(ExtInt, QualType{}, TypeDependence::None), IsUnsigned(IsUnsigned), +BitIntType::BitIntType(bool IsUnsigned, unsigned NumBits) + : Type(BitInt, QualType{}, TypeDependence::None), IsUnsigned(IsUnsigned), NumBits(NumBits) {} -DependentExtIntType::DependentExtIntType(const ASTContext &Context, +DependentBitIntType::DependentBitIntType(const ASTContext &Context, bool IsUnsigned, Expr *NumBitsExpr) - : Type(DependentExtInt, QualType{}, + : Type(DependentBitInt, QualType{}, toTypeDependence(NumBitsExpr->getDependence())), Context(Context), ExprAndUnsigned(NumBitsExpr, IsUnsigned) {} -bool DependentExtIntType::isUnsigned() const { +bool DependentBitIntType::isUnsigned() const { return ExprAndUnsigned.getInt(); } -clang::Expr *DependentExtIntType::getNumBitsExpr() const { +clang::Expr *DependentBitIntType::getNumBitsExpr() const { return ExprAndUnsigned.getPointer(); } -void DependentExtIntType::Profile(llvm::FoldingSetNodeID &ID, +void DependentBitIntType::Profile(llvm::FoldingSetNodeID &ID, const ASTContext &Context, bool IsUnsigned, Expr *NumBitsExpr) { ID.AddBoolean(IsUnsigned); @@ -1925,7 +1925,7 @@ if (const auto *ET = dyn_cast(CanonicalType)) return ET->getDecl()->isComplete(); - return isExtIntType(); + return isBitIntType(); } bool Type::isIntegralOrUnscopedEnumerationType() const { @@ -1933,7 +1933,7 @@ return BT->getKind() >= BuiltinType::Bool && BT->getKind() <= BuiltinType::Int128; - if (isExtIntType()) + if (isBitIntType()) return true; return isUnscopedEnumerationType(); @@ -2016,7 +2016,9 @@ return ET->getDecl()->getIntegerType()->isSignedIntegerType(); } - if (const ExtIntType *IT = dyn_cast(CanonicalType)) + if (const auto *IT = dyn_cast(CanonicalType)) + return IT->isSigned(); + if (const auto *IT = dyn_cast(CanonicalType)) return IT->isSigned(); return false; @@ -2033,9 +2035,10 @@ return ET->getDecl()->getIntegerType()->isSignedIntegerType(); } - if (const ExtIntType *IT = dyn_cast(CanonicalType)) + if (const auto *IT = dyn_cast(CanonicalType)) + return IT->isSigned(); + if (const auto *IT = dyn_cast(CanonicalType)) return IT->isSigned(); - return false; } @@ -2063,7 +2066,9 @@ return ET->getDecl()->getIntegerType()->isUnsignedIntegerType(); } - if (const ExtIntType *IT = dyn_cast(CanonicalType)) + if (const auto *IT = dyn_cast(CanonicalType)) + return IT->isUnsigned(); + if (const auto *IT = dyn_cast(CanonicalType)) return IT->isUnsigned(); return false; @@ -2080,7 +2085,9 @@ return ET->getDecl()->getIntegerType()->isUnsignedIntegerType(); } - if (const ExtIntType *IT = dyn_cast(CanonicalType)) + if (const auto *IT = dyn_cast(CanonicalType)) + return IT->isUnsigned(); + if (const auto *IT = dyn_cast(CanonicalType)) return IT->isUnsigned(); return false; @@ -2122,7 +2129,7 @@ BT->getKind() <= BuiltinType::Float128; if (const auto *ET = dyn_cast(CanonicalType)) return ET->getDecl()->isComplete() && !ET->getDecl()->isScoped(); - return isExtIntType(); + return isBitIntType(); } bool Type::isArithmeticType() const { @@ -2138,7 +2145,7 @@ // false for scoped enumerations since that will disable any // unwanted implicit conversions. return !ET->getDecl()->isScoped() && ET->getDecl()->isComplete(); - return isa(CanonicalType) || isExtIntType(); + return isa(CanonicalType) || isBitIntType(); } Type::ScalarTypeKind Type::getScalarTypeKind() const { @@ -2167,7 +2174,7 @@ if (CT->getElementType()->isRealFloatingType()) return STK_FloatingComplex; return STK_IntegralComplex; - } else if (isExtIntType()) { + } else if (isBitIntType()) { return STK_Integral; } @@ -2374,7 +2381,7 @@ case Type::MemberPointer: case Type::Vector: case Type::ExtVector: - case Type::ExtInt: + case Type::BitInt: return true; case Type::Enum: @@ -3841,7 +3848,7 @@ // here in error recovery. return CachedProperties(ExternalLinkage, false); - case Type::ExtInt: + case Type::BitInt: case Type::Builtin: // C++ [basic.link]p8: // A type is said to have linkage if and only if: @@ -3941,7 +3948,7 @@ assert(T->isInstantiationDependentType()); return LinkageInfo::external(); - case Type::ExtInt: + case Type::BitInt: case Type::Builtin: return LinkageInfo::external(); @@ -4161,8 +4168,8 @@ case Type::ObjCInterface: case Type::Atomic: case Type::Pipe: - case Type::ExtInt: - case Type::DependentExtInt: + case Type::BitInt: + case Type::DependentBitInt: return false; } llvm_unreachable("bad type kind!"); Index: clang/lib/AST/TypePrinter.cpp =================================================================== --- clang/lib/AST/TypePrinter.cpp +++ clang/lib/AST/TypePrinter.cpp @@ -231,8 +231,8 @@ case Type::ObjCInterface: case Type::Atomic: case Type::Pipe: - case Type::ExtInt: - case Type::DependentExtInt: + case Type::BitInt: + case Type::DependentBitInt: CanPrefixQualifiers = true; break; @@ -1199,26 +1199,26 @@ void TypePrinter::printPipeAfter(const PipeType *T, raw_ostream &OS) {} -void TypePrinter::printExtIntBefore(const ExtIntType *T, raw_ostream &OS) { +void TypePrinter::printBitIntBefore(const BitIntType *T, raw_ostream &OS) { if (T->isUnsigned()) OS << "unsigned "; - OS << "_ExtInt(" << T->getNumBits() << ")"; + OS << "_BitInt(" << T->getNumBits() << ")"; spaceBeforePlaceHolder(OS); } -void TypePrinter::printExtIntAfter(const ExtIntType *T, raw_ostream &OS) {} +void TypePrinter::printBitIntAfter(const BitIntType *T, raw_ostream &OS) {} -void TypePrinter::printDependentExtIntBefore(const DependentExtIntType *T, +void TypePrinter::printDependentBitIntBefore(const DependentBitIntType *T, raw_ostream &OS) { if (T->isUnsigned()) OS << "unsigned "; - OS << "_ExtInt("; + OS << "_BitInt("; T->getNumBitsExpr()->printPretty(OS, nullptr, Policy); OS << ")"; spaceBeforePlaceHolder(OS); } -void TypePrinter::printDependentExtIntAfter(const DependentExtIntType *T, +void TypePrinter::printDependentBitIntAfter(const DependentBitIntType *T, raw_ostream &OS) {} /// Appends the given scope to the end of a string. Index: clang/lib/Basic/Targets/AArch64.h =================================================================== --- clang/lib/Basic/Targets/AArch64.h +++ clang/lib/Basic/Targets/AArch64.h @@ -143,7 +143,7 @@ const char *getBFloat16Mangling() const override { return "u6__bf16"; }; bool hasInt128Type() const override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; class LLVM_LIBRARY_VISIBILITY AArch64leTargetInfo : public AArch64TargetInfo { Index: clang/lib/Basic/Targets/AMDGPU.h =================================================================== --- clang/lib/Basic/Targets/AMDGPU.h +++ clang/lib/Basic/Targets/AMDGPU.h @@ -419,7 +419,7 @@ void setAuxTarget(const TargetInfo *Aux) override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } // Record offload arch features since they are needed for defining the // pre-defined macros. Index: clang/lib/Basic/Targets/ARC.h =================================================================== --- clang/lib/Basic/Targets/ARC.h +++ clang/lib/Basic/Targets/ARC.h @@ -66,7 +66,7 @@ return false; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } bool isCLZForZeroUndef() const override { return false; } }; Index: clang/lib/Basic/Targets/ARM.h =================================================================== --- clang/lib/Basic/Targets/ARM.h +++ clang/lib/Basic/Targets/ARM.h @@ -187,8 +187,8 @@ bool hasSjLjLowering() const override; - bool hasExtIntType() const override { return true; } - + bool hasBitIntType() const override { return true; } + const char *getBFloat16Mangling() const override { return "u6__bf16"; }; }; Index: clang/lib/Basic/Targets/Hexagon.h =================================================================== --- clang/lib/Basic/Targets/Hexagon.h +++ clang/lib/Basic/Targets/Hexagon.h @@ -139,7 +139,7 @@ return CPU.find('t') != std::string::npos; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/Lanai.h =================================================================== --- clang/lib/Basic/Targets/Lanai.h +++ clang/lib/Basic/Targets/Lanai.h @@ -87,7 +87,7 @@ const char *getClobbers() const override { return ""; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/Mips.h =================================================================== --- clang/lib/Basic/Targets/Mips.h +++ clang/lib/Basic/Targets/Mips.h @@ -406,7 +406,7 @@ unsigned getUnwindWordWidth() const override; bool validateTarget(DiagnosticsEngine &Diags) const override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/NVPTX.h =================================================================== --- clang/lib/Basic/Targets/NVPTX.h +++ clang/lib/Basic/Targets/NVPTX.h @@ -175,7 +175,7 @@ return CCCR_Warning; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/PNaCl.h =================================================================== --- clang/lib/Basic/Targets/PNaCl.h +++ clang/lib/Basic/Targets/PNaCl.h @@ -69,7 +69,7 @@ const char *getClobbers() const override { return ""; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; // We attempt to use PNaCl (le32) frontend and Mips32EL backend. Index: clang/lib/Basic/Targets/PPC.h =================================================================== --- clang/lib/Basic/Targets/PPC.h +++ clang/lib/Basic/Targets/PPC.h @@ -348,7 +348,7 @@ } const char *getFloat128Mangling() const override { return "u9__ieee128"; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } bool isSPRegName(StringRef RegName) const override { return RegName.equals("r1") || RegName.equals("x1"); Index: clang/lib/Basic/Targets/RISCV.h =================================================================== --- clang/lib/Basic/Targets/RISCV.h +++ clang/lib/Basic/Targets/RISCV.h @@ -110,7 +110,7 @@ bool handleTargetFeatures(std::vector &Features, DiagnosticsEngine &Diags) override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo { public: Index: clang/lib/Basic/Targets/SPIR.h =================================================================== --- clang/lib/Basic/Targets/SPIR.h +++ clang/lib/Basic/Targets/SPIR.h @@ -153,7 +153,7 @@ supportAllOpenCLOpts(); } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } bool hasInt128Type() const override { return false; } }; Index: clang/lib/Basic/Targets/Sparc.h =================================================================== --- clang/lib/Basic/Targets/Sparc.h +++ clang/lib/Basic/Targets/Sparc.h @@ -181,7 +181,7 @@ MacroBuilder &Builder) const override; bool hasSjLjLowering() const override { return true; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; // SPARCV8el is the 32-bit little-endian mode selected by Triple::sparcel. @@ -234,7 +234,7 @@ return getCPUGeneration(CPU) == CG_V9; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/Basic/Targets/SystemZ.h =================================================================== --- clang/lib/Basic/Targets/SystemZ.h +++ clang/lib/Basic/Targets/SystemZ.h @@ -160,7 +160,7 @@ const char *getLongDoubleMangling() const override { return "g"; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } int getEHDataRegisterNumber(unsigned RegNo) const override { return RegNo < 4 ? 6 + RegNo : -1; Index: clang/lib/Basic/Targets/WebAssembly.h =================================================================== --- clang/lib/Basic/Targets/WebAssembly.h +++ clang/lib/Basic/Targets/WebAssembly.h @@ -136,7 +136,7 @@ } } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } bool hasProtectedVisibility() const override { return false; } Index: clang/lib/Basic/Targets/X86.h =================================================================== --- clang/lib/Basic/Targets/X86.h +++ clang/lib/Basic/Targets/X86.h @@ -460,7 +460,7 @@ ArrayRef getTargetBuiltins() const override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; class LLVM_LIBRARY_VISIBILITY NetBSDI386TargetInfo @@ -767,7 +767,7 @@ ArrayRef getTargetBuiltins() const override; - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; // x86-64 Windows target Index: clang/lib/Basic/Targets/XCore.h =================================================================== --- clang/lib/Basic/Targets/XCore.h +++ clang/lib/Basic/Targets/XCore.h @@ -76,7 +76,7 @@ bool allowsLargerPreferedTypeAlignment() const override { return false; } - bool hasExtIntType() const override { return true; } + bool hasBitIntType() const override { return true; } }; } // namespace targets } // namespace clang Index: clang/lib/CodeGen/ABIInfo.h =================================================================== --- clang/lib/CodeGen/ABIInfo.h +++ clang/lib/CodeGen/ABIInfo.h @@ -105,7 +105,7 @@ uint64_t &Members) const; // Implement the Type::IsPromotableIntegerType for ABI specific needs. The - // only difference is that this considers _ExtInt as well. + // only difference is that this considers bit-precise integer types as well. bool isPromotableIntegerTypeForABI(QualType Ty) const; /// A convenience method to return an indirect ABIArgInfo with an Index: clang/lib/CodeGen/CGBuiltin.cpp =================================================================== --- clang/lib/CodeGen/CGBuiltin.cpp +++ clang/lib/CodeGen/CGBuiltin.cpp @@ -666,7 +666,7 @@ const clang::QualType Type) { assert(Type->isIntegerType() && "Given type is not an integer."); unsigned Width = Type->isBooleanType() ? 1 - : Type->isExtIntType() ? context.getIntWidth(Type) + : Type->isBitIntType() ? context.getIntWidth(Type) : context.getTypeInfo(Type).Width; bool Signed = Type->isSignedIntegerType(); return {Width, Signed}; Index: clang/lib/CodeGen/CGCall.cpp =================================================================== --- clang/lib/CodeGen/CGCall.cpp +++ clang/lib/CodeGen/CGCall.cpp @@ -1954,7 +1954,7 @@ // there's no internal padding (typeSizeEqualsStoreSize). return false; } - if (QTy->isExtIntType()) + if (QTy->isBitIntType()) return true; if (QTy->isReferenceType()) return true; Index: clang/lib/CodeGen/CGDebugInfo.h =================================================================== --- clang/lib/CodeGen/CGDebugInfo.h +++ clang/lib/CodeGen/CGDebugInfo.h @@ -177,7 +177,7 @@ llvm::DIType *CreateType(const BuiltinType *Ty); llvm::DIType *CreateType(const ComplexType *Ty); llvm::DIType *CreateType(const AutoType *Ty); - llvm::DIType *CreateType(const ExtIntType *Ty); + llvm::DIType *CreateType(const BitIntType *Ty); llvm::DIType *CreateQualifiedType(QualType Ty, llvm::DIFile *Fg); llvm::DIType *CreateType(const TypedefType *Ty, llvm::DIFile *Fg); llvm::DIType *CreateType(const TemplateSpecializationType *Ty, Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -893,9 +893,9 @@ return DBuilder.createUnspecifiedType("auto"); } -llvm::DIType *CGDebugInfo::CreateType(const ExtIntType *Ty) { +llvm::DIType *CGDebugInfo::CreateType(const BitIntType *Ty) { - StringRef Name = Ty->isUnsigned() ? "unsigned _ExtInt" : "_ExtInt"; + StringRef Name = Ty->isUnsigned() ? "unsigned _BitInt" : "_BitInt"; llvm::dwarf::TypeKind Encoding = Ty->isUnsigned() ? llvm::dwarf::DW_ATE_unsigned : llvm::dwarf::DW_ATE_signed; @@ -3346,8 +3346,8 @@ case Type::Atomic: return CreateType(cast(Ty), Unit); - case Type::ExtInt: - return CreateType(cast(Ty)); + case Type::BitInt: + return CreateType(cast(Ty)); case Type::Pipe: return CreateType(cast(Ty), Unit); Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -242,7 +242,7 @@ case Type::Enum: case Type::ObjCObjectPointer: case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: return TEK_Scalar; // Complexes. @@ -2164,7 +2164,7 @@ case Type::ObjCObject: case Type::ObjCInterface: case Type::ObjCObjectPointer: - case Type::ExtInt: + case Type::BitInt: llvm_unreachable("type class is never variably-modified!"); case Type::Adjusted: Index: clang/lib/CodeGen/CodeGenTBAA.cpp =================================================================== --- clang/lib/CodeGen/CodeGenTBAA.cpp +++ clang/lib/CodeGen/CodeGenTBAA.cpp @@ -209,12 +209,12 @@ return createScalarTypeNode(OutName, getChar(), Size); } - if (const auto *EIT = dyn_cast(Ty)) { + if (const auto *EIT = dyn_cast(Ty)) { SmallString<256> OutName; llvm::raw_svector_ostream Out(OutName); // Don't specify signed/unsigned since integer types can alias despite sign // differences. - Out << "_ExtInt(" << EIT->getNumBits() << ')'; + Out << "_BitInt(" << EIT->getNumBits() << ')'; return createScalarTypeNode(OutName, getChar(), Size); } Index: clang/lib/CodeGen/CodeGenTypes.cpp =================================================================== --- clang/lib/CodeGen/CodeGenTypes.cpp +++ clang/lib/CodeGen/CodeGenTypes.cpp @@ -97,10 +97,10 @@ llvm::Type *R = ConvertType(T); - // If this is a bool type, or an ExtIntType in a bitfield representation, - // map this integer to the target-specified size. - if ((ForBitField && T->isExtIntType()) || - (!T->isExtIntType() && R->isIntegerTy(1))) + // If this is a bool type, or a bit-precise integer type in a bitfield + // representation, map this integer to the target-specified size. + if ((ForBitField && T->isBitIntType()) || + (!T->isBitIntType() && R->isIntegerTy(1))) return llvm::IntegerType::get(getLLVMContext(), (unsigned)Context.getTypeSize(T)); @@ -785,8 +785,8 @@ ResultType = CGM.getOpenCLRuntime().getPipeType(cast(Ty)); break; } - case Type::ExtInt: { - const auto &EIT = cast(Ty); + case Type::BitInt: { + const auto &EIT = cast(Ty); ResultType = llvm::Type::getIntNTy(getLLVMContext(), EIT->getNumBits()); break; } Index: clang/lib/CodeGen/ItaniumCXXABI.cpp =================================================================== --- clang/lib/CodeGen/ItaniumCXXABI.cpp +++ clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -3520,7 +3520,7 @@ llvm_unreachable("Pipe types shouldn't get here"); case Type::Builtin: - case Type::ExtInt: + case Type::BitInt: // GCC treats vector and complex types as fundamental types. case Type::Vector: case Type::ExtVector: @@ -3793,7 +3793,7 @@ case Type::Pipe: break; - case Type::ExtInt: + case Type::BitInt: break; case Type::ConstantArray: Index: clang/lib/CodeGen/TargetInfo.cpp =================================================================== --- clang/lib/CodeGen/TargetInfo.cpp +++ clang/lib/CodeGen/TargetInfo.cpp @@ -104,7 +104,7 @@ if (Ty->isPromotableIntegerType()) return true; - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() < getContext().getTypeSize(getContext().IntTy)) return true; @@ -732,7 +732,7 @@ Ty = EnumTy->getDecl()->getIntegerType(); ASTContext &Context = getContext(); - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > Context.getTypeSize(Context.getTargetInfo().hasInt128Type() ? Context.Int128Ty @@ -754,7 +754,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > getContext().getTypeSize(getContext().getTargetInfo().hasInt128Type() ? getContext().Int128Ty @@ -978,8 +978,9 @@ } else if (Ty->isFloatingType()) { // Floating-point types don't go inreg. return ABIArgInfo::getDirect(); - } else if (const auto *EIT = Ty->getAs()) { - // Treat extended integers as integers if <=64, otherwise pass indirectly. + } else if (const auto *EIT = Ty->getAs()) { + // Treat bit-precise integers as integers if <= 64, otherwise pass + // indirectly. if (EIT->getNumBits() > 64) return getNaturalAlignIndirect(Ty); return ABIArgInfo::getDirect(); @@ -997,8 +998,8 @@ if (isAggregateTypeForABI(RetTy)) return getNaturalAlignIndirect(RetTy); - // Treat extended integers as integers if <=64, otherwise pass indirectly. - if (const auto *EIT = RetTy->getAs()) { + // Treat bit-precise integers as integers if <= 64, otherwise pass indirectly. + if (const auto *EIT = RetTy->getAs()) { if (EIT->getNumBits() > 64) return getNaturalAlignIndirect(RetTy); return ABIArgInfo::getDirect(); @@ -1559,7 +1560,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 64) return getIndirectReturnResult(RetTy, State); @@ -1895,7 +1896,7 @@ return ABIArgInfo::getExtend(Ty); } - if (const auto * EIT = Ty->getAs()) { + if (const auto *EIT = Ty->getAs()) { if (EIT->getNumBits() <= 64) { if (InReg) return ABIArgInfo::getDirectInReg(); @@ -2978,7 +2979,7 @@ return; } - if (const auto *EITy = Ty->getAs()) { + if (const auto *EITy = Ty->getAs()) { if (EITy->getNumBits() <= 64) Current = Integer; else if (EITy->getNumBits() <= 128) @@ -3169,7 +3170,7 @@ if (const EnumType *EnumTy = Ty->getAs()) Ty = EnumTy->getDecl()->getIntegerType(); - if (Ty->isExtIntType()) + if (Ty->isBitIntType()) return getNaturalAlignIndirect(Ty); return (isPromotableIntegerTypeForABI(Ty) ? ABIArgInfo::getExtend(Ty) @@ -3206,7 +3207,7 @@ // but this code would be much safer if we could mark the argument with // 'onstack'. See PR12193. if (!isAggregateTypeForABI(Ty) && !IsIllegalVectorType(Ty) && - !Ty->isExtIntType()) { + !Ty->isBitIntType()) { // Treat an enum type as its underlying type. if (const EnumType *EnumTy = Ty->getAs()) Ty = EnumTy->getDecl()->getIntegerType(); @@ -4353,12 +4354,12 @@ } } - if (Ty->isExtIntType()) { + if (Ty->isBitIntType()) { // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is // not 1, 2, 4, or 8 bytes, must be passed by reference." - // However, non-power-of-two _ExtInts will be passed as 1,2,4 or 8 bytes - // anyway as long is it fits in them, so we don't have to check the power of - // 2. + // However, non-power-of-two bit-precise integers will be passed as 1, 2, 4, + // or 8 bytes anyway as long is it fits in them, so we don't have to check + // the power of 2. if (Width <= 64) return ABIArgInfo::getDirect(); return ABIArgInfo::getIndirect(Align, /*ByVal=*/false); @@ -5054,7 +5055,7 @@ break; } - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() < 64) return true; @@ -5273,7 +5274,7 @@ } } - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 128) return getNaturalAlignIndirect(Ty, /*ByVal=*/true); @@ -5349,7 +5350,7 @@ } } - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 128) return getNaturalAlignIndirect(RetTy, /*ByVal=*/false); @@ -5726,7 +5727,7 @@ if (const EnumType *EnumTy = Ty->getAs()) Ty = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 128) return getNaturalAlignIndirect(Ty); @@ -5828,7 +5829,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 128) return getNaturalAlignIndirect(RetTy); @@ -6552,7 +6553,7 @@ Ty = EnumTy->getDecl()->getIntegerType(); } - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 64) return getNaturalAlignIndirect(Ty, /*ByVal=*/true); @@ -6754,7 +6755,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 64) return getNaturalAlignIndirect(RetTy, /*ByVal=*/false); @@ -7091,7 +7092,7 @@ (T->isFloat128Type() || (T->isRealFloatingType() && Context.getTypeSize(T) == 128))) return true; - if (const auto *EIT = T->getAs()) + if (const auto *EIT = T->getAs()) return EIT->getNumBits() > (Context.getTargetInfo().hasInt128Type() ? 128U : 64U); if (!Context.getTargetInfo().hasInt128Type() && T->isIntegerType() && @@ -7168,7 +7169,7 @@ return getNaturalAlignIndirect(Ty, /* byval */ true); } - if (const auto *EIT = Ty->getAs()) { + if (const auto *EIT = Ty->getAs()) { if ((EIT->getNumBits() > 128) || (!getContext().getTargetInfo().hasInt128Type() && EIT->getNumBits() > 64)) @@ -7382,7 +7383,7 @@ if (ABIInfo::isPromotableIntegerTypeForABI(Ty)) return true; - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() < 64) return true; @@ -7985,7 +7986,7 @@ Ty = EnumTy->getDecl()->getIntegerType(); // Make sure we pass indirectly things that are too large. - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 128 || (EIT->getNumBits() > 64 && !getContext().getTargetInfo().hasInt128Type())) @@ -8076,7 +8077,7 @@ RetTy = EnumTy->getDecl()->getIntegerType(); // Make sure we pass indirectly things that are too large. - if (const auto *EIT = RetTy->getAs()) + if (const auto *EIT = RetTy->getAs()) if (EIT->getNumBits() > 128 || (EIT->getNumBits() > 64 && !getContext().getTargetInfo().hasInt128Type())) @@ -8451,7 +8452,7 @@ if (Size <= 64) HexagonAdjustRegsLeft(Size, RegsLeft); - if (Size > 64 && Ty->isExtIntType()) + if (Size > 64 && Ty->isBitIntType()) return getNaturalAlignIndirect(Ty, /*ByVal=*/true); return isPromotableIntegerTypeForABI(Ty) ? ABIArgInfo::getExtend(Ty) @@ -8507,7 +8508,7 @@ if (const EnumType *EnumTy = RetTy->getAs()) RetTy = EnumTy->getDecl()->getIntegerType(); - if (Size > 64 && RetTy->isExtIntType()) + if (Size > 64 && RetTy->isBitIntType()) return getNaturalAlignIndirect(RetTy, /*ByVal=*/false); return isPromotableIntegerTypeForABI(RetTy) ? ABIArgInfo::getExtend(RetTy) @@ -8878,7 +8879,7 @@ bool InReg = shouldUseInReg(Ty, State); // Don't pass >64 bit integers in registers. - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 64) return getIndirectResult(Ty, /*ByVal=*/true, State); @@ -9589,7 +9590,7 @@ if (Size < 64 && Ty->isIntegerType()) return ABIArgInfo::getExtend(Ty); - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() < 64) return ABIArgInfo::getExtend(Ty); @@ -9843,7 +9844,7 @@ ABIArgInfo::getDirect(Result, 0, nullptr, false); } - if (const auto *EIT = Ty->getAs()) + if (const auto *EIT = Ty->getAs()) if (EIT->getNumBits() > 64) return getIndirectByValue(Ty); @@ -10924,7 +10925,7 @@ return extendType(Ty); } - if (const auto *EIT = Ty->getAs()) { + if (const auto *EIT = Ty->getAs()) { if (EIT->getNumBits() < XLen && !MustUseStack) return extendType(Ty); if (EIT->getNumBits() > 128 || Index: clang/lib/Parse/ParseDecl.cpp =================================================================== --- clang/lib/Parse/ParseDecl.cpp +++ clang/lib/Parse/ParseDecl.cpp @@ -2879,7 +2879,8 @@ } ExprResult Parser::ParseExtIntegerArgument() { - assert(Tok.is(tok::kw__ExtInt) && "Not an extended int type"); + assert(Tok.isOneOf(tok::kw__ExtInt, tok::kw__BitInt) && + "Not an extended int type"); ConsumeToken(); BalancedDelimiterTracker T(*this, tok::l_paren); @@ -3870,11 +3871,13 @@ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_int, Loc, PrevSpec, DiagID, Policy); break; - case tok::kw__ExtInt: { + case tok::kw__ExtInt: + case tok::kw__BitInt: { + DiagnoseBitIntUse(Tok); ExprResult ER = ParseExtIntegerArgument(); if (ER.isInvalid()) continue; - isInvalid = DS.SetExtIntType(Loc, ER.get(), PrevSpec, DiagID, Policy); + isInvalid = DS.SetBitIntType(Loc, ER.get(), PrevSpec, DiagID, Policy); ConsumedEnd = PrevTokLocation; break; } @@ -4999,6 +5002,7 @@ case tok::kw_char32_t: case tok::kw_int: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw___bf16: case tok::kw_half: case tok::kw_float: @@ -5080,6 +5084,7 @@ case tok::kw_char32_t: case tok::kw_int: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw_half: case tok::kw___bf16: case tok::kw_float: @@ -5250,6 +5255,7 @@ case tok::kw_int: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw_half: case tok::kw___bf16: case tok::kw_float: @@ -7457,3 +7463,24 @@ } return false; } + +void Parser::DiagnoseBitIntUse(const Token &Tok) { + // If the token is for _ExtInt, diagnose it as being deprecated. Otherwise, + // the token is about _BitInt and gets (potentially) diagnosed as use of an + // extension. + assert(Tok.isOneOf(tok::kw__ExtInt, tok::kw__BitInt) && + "expected either an _ExtInt or _BitInt token!"); + + SourceLocation Loc = Tok.getLocation(); + if (Tok.is(tok::kw__ExtInt)) { + Diag(Loc, diag::warn_ext_int_deprecated) + << FixItHint::CreateReplacement(Loc, "_BitInt"); + } else { + // In C2x mode, diagnose that the use is not compatible with pre-C2x modes. + // Otherwise, diagnose that the use is a Clang extension. + if (getLangOpts().C2x) + Diag(Loc, diag::warn_c17_compat_bit_int); + else + Diag(Loc, diag::ext_bit_int) << getLangOpts().CPlusPlus; + } +} Index: clang/lib/Parse/ParseExpr.cpp =================================================================== --- clang/lib/Parse/ParseExpr.cpp +++ clang/lib/Parse/ParseExpr.cpp @@ -1513,6 +1513,7 @@ case tok::kw___int64: case tok::kw___int128: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw_signed: case tok::kw_unsigned: case tok::kw_half: Index: clang/lib/Parse/ParseExprCXX.cpp =================================================================== --- clang/lib/Parse/ParseExprCXX.cpp +++ clang/lib/Parse/ParseExprCXX.cpp @@ -2164,12 +2164,14 @@ return; } - case tok::kw__ExtInt: { + case tok::kw__ExtInt: + case tok::kw__BitInt: { + DiagnoseBitIntUse(Tok); ExprResult ER = ParseExtIntegerArgument(); if (ER.isInvalid()) DS.SetTypeSpecError(); else - DS.SetExtIntType(Loc, ER.get(), PrevSpec, DiagID, Policy); + DS.SetBitIntType(Loc, ER.get(), PrevSpec, DiagID, Policy); // Do this here because we have already consumed the close paren. DS.SetRangeEnd(PrevTokLocation); Index: clang/lib/Parse/ParseTentative.cpp =================================================================== --- clang/lib/Parse/ParseTentative.cpp +++ clang/lib/Parse/ParseTentative.cpp @@ -1689,6 +1689,7 @@ case tok::kw__Atomic: return TPResult::True; + case tok::kw__BitInt: case tok::kw__ExtInt: { if (NextToken().isNot(tok::l_paren)) return TPResult::Error; @@ -1740,6 +1741,7 @@ case tok::kw_short: case tok::kw_int: case tok::kw__ExtInt: + case tok::kw__BitInt: case tok::kw_long: case tok::kw___int64: case tok::kw___int128: Index: clang/lib/Sema/DeclSpec.cpp =================================================================== --- clang/lib/Sema/DeclSpec.cpp +++ clang/lib/Sema/DeclSpec.cpp @@ -364,7 +364,7 @@ case TST_half: case TST_int: case TST_int128: - case TST_extint: + case TST_bitint: case TST_struct: case TST_interface: case TST_union: @@ -550,7 +550,7 @@ case DeclSpec::TST_char32: return "char32_t"; case DeclSpec::TST_int: return "int"; case DeclSpec::TST_int128: return "__int128"; - case DeclSpec::TST_extint: return "_ExtInt"; + case DeclSpec::TST_bitint: return "_BitInt"; case DeclSpec::TST_half: return "half"; case DeclSpec::TST_float: return "float"; case DeclSpec::TST_double: return "double"; @@ -931,7 +931,7 @@ return false; } -bool DeclSpec::SetExtIntType(SourceLocation KWLoc, Expr *BitsExpr, +bool DeclSpec::SetBitIntType(SourceLocation KWLoc, Expr *BitsExpr, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy) { assert(BitsExpr && "no expression provided!"); @@ -944,7 +944,7 @@ return true; } - TypeSpecType = TST_extint; + TypeSpecType = TST_bitint; ExprRep = BitsExpr; TSTLoc = KWLoc; TSTNameLoc = KWLoc; @@ -1245,7 +1245,7 @@ TypeSpecType = TST_int; // unsigned -> unsigned int, signed -> signed int. else if (TypeSpecType != TST_int && TypeSpecType != TST_int128 && TypeSpecType != TST_char && TypeSpecType != TST_wchar && - !IsFixedPointType && TypeSpecType != TST_extint) { + !IsFixedPointType && TypeSpecType != TST_bitint) { S.Diag(TSSLoc, diag::err_invalid_sign_spec) << getSpecifierName((TST)TypeSpecType, Policy); // signed double -> double. @@ -1295,7 +1295,7 @@ " double"); TypeSpecType = TST_double; // _Complex -> _Complex double. } else if (TypeSpecType == TST_int || TypeSpecType == TST_char || - TypeSpecType == TST_extint) { + TypeSpecType == TST_bitint) { // Note that this intentionally doesn't include _Complex _Bool. if (!S.getLangOpts().CPlusPlus) S.Diag(TSTLoc, diag::ext_integer_complex); Index: clang/lib/Sema/Sema.cpp =================================================================== --- clang/lib/Sema/Sema.cpp +++ clang/lib/Sema/Sema.cpp @@ -1884,8 +1884,8 @@ if (Ty->isDependentType()) return; - if (Ty->isExtIntType()) { - if (!Context.getTargetInfo().hasExtIntType()) { + if (Ty->isBitIntType()) { + if (!Context.getTargetInfo().hasBitIntType()) { targetDiag(Loc, diag::err_device_unsupported_type, FD) << D << false /*show bit size*/ << 0 /*bitsize*/ << Ty << Context.getTargetInfo().getTriple().str(); Index: clang/lib/Sema/SemaChecking.cpp =================================================================== --- clang/lib/Sema/SemaChecking.cpp +++ clang/lib/Sema/SemaChecking.cpp @@ -325,17 +325,17 @@ } } - // Disallow signed ExtIntType args larger than 128 bits to mul function until - // we improve backend support. + // Disallow signed bit-precise integer args larger than 128 bits to mul + // function until we improve backend support. if (BuiltinID == Builtin::BI__builtin_mul_overflow) { for (unsigned I = 0; I < 3; ++I) { const auto Arg = TheCall->getArg(I); // Third argument will be a pointer. auto Ty = I < 2 ? Arg->getType() : Arg->getType()->getPointeeType(); - if (Ty->isExtIntType() && Ty->isSignedIntegerType() && + if (Ty->isBitIntType() && Ty->isSignedIntegerType() && S.getASTContext().getIntWidth(Ty) > 128) return S.Diag(Arg->getBeginLoc(), - diag::err_overflow_builtin_ext_int_max_size) + diag::err_overflow_builtin_bit_int_max_size) << 128; } } @@ -5719,8 +5719,8 @@ ? 0 : 1); - if (ValType->isExtIntType()) { - Diag(Ptr->getExprLoc(), diag::err_atomic_builtin_ext_int_prohibit); + if (ValType->isBitIntType()) { + Diag(Ptr->getExprLoc(), diag::err_atomic_builtin_bit_int_prohibit); return ExprError(); } @@ -6117,11 +6117,11 @@ // gracefully. TheCall->setType(ResultType); - // Prohibit use of _ExtInt with atomic builtins. - // The arguments would have already been converted to the first argument's - // type, so only need to check the first argument. - const auto *ExtIntValType = ValType->getAs(); - if (ExtIntValType && !llvm::isPowerOf2_64(ExtIntValType->getNumBits())) { + // Prohibit problematic uses of bit-precise integer types with atomic + // builtins. The arguments would have already been converted to the first + // argument's type, so only need to check the first argument. + const auto *BitIntValType = ValType->getAs(); + if (BitIntValType && !llvm::isPowerOf2_64(BitIntValType->getNumBits())) { Diag(FirstArg->getExprLoc(), diag::err_atomic_builtin_ext_int_size); return ExprError(); } @@ -11102,7 +11102,7 @@ false/*NonNegative*/); } - if (const auto *EIT = dyn_cast(T)) + if (const auto *EIT = dyn_cast(T)) return IntRange(EIT->getNumBits(), EIT->isUnsigned()); const BuiltinType *BT = cast(T); @@ -11128,7 +11128,7 @@ if (const EnumType *ET = dyn_cast(T)) T = C.getCanonicalType(ET->getDecl()->getIntegerType()).getTypePtr(); - if (const auto *EIT = dyn_cast(T)) + if (const auto *EIT = dyn_cast(T)) return IntRange(EIT->getNumBits(), EIT->isUnsigned()); const BuiltinType *BT = cast(T); Index: clang/lib/Sema/SemaDecl.cpp =================================================================== --- clang/lib/Sema/SemaDecl.cpp +++ clang/lib/Sema/SemaDecl.cpp @@ -15253,7 +15253,7 @@ if (BT->isInteger()) return false; - if (T->isExtIntType()) + if (T->isBitIntType()) return false; return Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T; Index: clang/lib/Sema/SemaDeclAttr.cpp =================================================================== --- clang/lib/Sema/SemaDeclAttr.cpp +++ clang/lib/Sema/SemaDeclAttr.cpp @@ -4326,7 +4326,7 @@ return; } bool IntegralOrAnyEnumType = (OldElemTy->isIntegralOrEnumerationType() && - !OldElemTy->isExtIntType()) || + !OldElemTy->isBitIntType()) || OldElemTy->getAs(); if (!OldElemTy->getAs() && !OldElemTy->isComplexType() && Index: clang/lib/Sema/SemaExpr.cpp =================================================================== --- clang/lib/Sema/SemaExpr.cpp +++ clang/lib/Sema/SemaExpr.cpp @@ -4427,7 +4427,7 @@ case Type::ObjCObjectPointer: case Type::ObjCTypeParam: case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: llvm_unreachable("type class is never variably-modified!"); case Type::Adjusted: T = cast(Ty)->getOriginalType(); @@ -8425,9 +8425,10 @@ // If both operands have arithmetic type, do the usual arithmetic conversions // to find a common type: C99 6.5.15p3,5. if (LHSTy->isArithmeticType() && RHSTy->isArithmeticType()) { - // Disallow invalid arithmetic conversions, such as those between ExtInts of - // different sizes, or between ExtInts and other types. - if (ResTy.isNull() && (LHSTy->isExtIntType() || RHSTy->isExtIntType())) { + // Disallow invalid arithmetic conversions, such as those between bit- + // precise integers types of different sizes, or between a bit-precise + // integer and another type. + if (ResTy.isNull() && (LHSTy->isBitIntType() || RHSTy->isBitIntType())) { Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy << LHS.get()->getSourceRange() << RHS.get()->getSourceRange(); @@ -11011,7 +11012,7 @@ QualType LHSExprType = LHS.get()->getType(); uint64_t LeftSize = S.Context.getTypeSize(LHSExprType); - if (LHSExprType->isExtIntType()) + if (LHSExprType->isBitIntType()) LeftSize = S.Context.getIntWidth(LHSExprType); else if (LHSExprType->isFixedPointType()) { auto FXSema = S.Context.getFixedPointSemantics(LHSExprType); Index: clang/lib/Sema/SemaLookup.cpp =================================================================== --- clang/lib/Sema/SemaLookup.cpp +++ clang/lib/Sema/SemaLookup.cpp @@ -2935,7 +2935,7 @@ case Type::ExtVector: case Type::ConstantMatrix: case Type::Complex: - case Type::ExtInt: + case Type::BitInt: break; // Non-deduced auto types only get here for error cases. Index: clang/lib/Sema/SemaStmtAsm.cpp =================================================================== --- clang/lib/Sema/SemaStmtAsm.cpp +++ clang/lib/Sema/SemaStmtAsm.cpp @@ -296,9 +296,9 @@ checkExprMemoryConstraintCompat(*this, OutputExpr, Info, false)) return StmtError(); - // Disallow _ExtInt, since the backends tend to have difficulties with - // non-normal sizes. - if (OutputExpr->getType()->isExtIntType()) + // Disallow bit-precise integer types, since the backends tend to have + // difficulties with abnormal sizes. + if (OutputExpr->getType()->isBitIntType()) return StmtError( Diag(OutputExpr->getBeginLoc(), diag::err_asm_invalid_type) << OutputExpr->getType() << 0 /*Input*/ @@ -428,7 +428,7 @@ } } - if (InputExpr->getType()->isExtIntType()) + if (InputExpr->getType()->isBitIntType()) return StmtError( Diag(InputExpr->getBeginLoc(), diag::err_asm_invalid_type) << InputExpr->getType() << 1 /*Output*/ @@ -923,7 +923,7 @@ setFunctionHasBranchProtectedScope(); for (uint64_t I = 0; I < NumOutputs + NumInputs; ++I) { - if (Exprs[I]->getType()->isExtIntType()) + if (Exprs[I]->getType()->isBitIntType()) return StmtError( Diag(Exprs[I]->getBeginLoc(), diag::err_asm_invalid_type) << Exprs[I]->getType() << (I < NumOutputs) Index: clang/lib/Sema/SemaTemplate.cpp =================================================================== --- clang/lib/Sema/SemaTemplate.cpp +++ clang/lib/Sema/SemaTemplate.cpp @@ -6151,12 +6151,12 @@ return false; } -bool UnnamedLocalNoLinkageFinder::VisitExtIntType(const ExtIntType *T) { +bool UnnamedLocalNoLinkageFinder::VisitBitIntType(const BitIntType *T) { return false; } -bool UnnamedLocalNoLinkageFinder::VisitDependentExtIntType( - const DependentExtIntType *T) { +bool UnnamedLocalNoLinkageFinder::VisitDependentBitIntType( + const DependentBitIntType *T) { return false; } @@ -7098,7 +7098,7 @@ QualType IntegerType = ParamType; if (const EnumType *Enum = IntegerType->getAs()) IntegerType = Enum->getDecl()->getIntegerType(); - Value = Value.extOrTrunc(IntegerType->isExtIntType() + Value = Value.extOrTrunc(IntegerType->isBitIntType() ? Context.getIntWidth(IntegerType) : Context.getTypeSize(IntegerType)); @@ -7193,7 +7193,7 @@ // Coerce the template argument's value to the value it will have // based on the template parameter's type. - unsigned AllowedBits = IntegerType->isExtIntType() + unsigned AllowedBits = IntegerType->isBitIntType() ? Context.getIntWidth(IntegerType) : Context.getTypeSize(IntegerType); if (Value.getBitWidth() != AllowedBits) Index: clang/lib/Sema/SemaTemplateDeduction.cpp =================================================================== --- clang/lib/Sema/SemaTemplateDeduction.cpp +++ clang/lib/Sema/SemaTemplateDeduction.cpp @@ -1636,7 +1636,7 @@ case Type::ObjCObject: case Type::ObjCInterface: case Type::ObjCObjectPointer: - case Type::ExtInt: + case Type::BitInt: if (TDF & TDF_SkipNonDependent) return Sema::TDK_Success; @@ -2259,10 +2259,10 @@ return Sema::TDK_NonDeducedMismatch; } - case Type::DependentExtInt: { - const auto *IntParam = cast(Param); + case Type::DependentBitInt: { + const auto *IntParam = cast(Param); - if (const auto *IntArg = dyn_cast(Arg)){ + if (const auto *IntArg = dyn_cast(Arg)) { if (IntParam->isUnsigned() != IntArg->isUnsigned()) return Sema::TDK_NonDeducedMismatch; @@ -2279,7 +2279,7 @@ Deduced); } - if (const auto *IntArg = dyn_cast(Arg)) { + if (const auto *IntArg = dyn_cast(Arg)) { if (IntParam->isUnsigned() != IntArg->isUnsigned()) return Sema::TDK_NonDeducedMismatch; return Sema::TDK_Success; @@ -6074,9 +6074,9 @@ cast(T)->getDeducedType(), OnlyDeduced, Depth, Used); break; - case Type::DependentExtInt: + case Type::DependentBitInt: MarkUsedTemplateParameters(Ctx, - cast(T)->getNumBitsExpr(), + cast(T)->getNumBitsExpr(), OnlyDeduced, Depth, Used); break; @@ -6091,7 +6091,7 @@ case Type::ObjCObjectPointer: case Type::UnresolvedUsing: case Type::Pipe: - case Type::ExtInt: + case Type::BitInt: #define TYPE(Class, Base) #define ABSTRACT_TYPE(Class, Base) #define DEPENDENT_TYPE(Class, Base) Index: clang/lib/Sema/SemaTemplateVariadic.cpp =================================================================== --- clang/lib/Sema/SemaTemplateVariadic.cpp +++ clang/lib/Sema/SemaTemplateVariadic.cpp @@ -871,7 +871,7 @@ case TST_typeofExpr: case TST_decltype: - case TST_extint: + case TST_bitint: if (DS.getRepAsExpr() && DS.getRepAsExpr()->containsUnexpandedParameterPack()) return true; Index: clang/lib/Sema/SemaType.cpp =================================================================== --- clang/lib/Sema/SemaType.cpp +++ clang/lib/Sema/SemaType.cpp @@ -1436,12 +1436,11 @@ } break; } - case DeclSpec::TST_extint: { - if (!S.Context.getTargetInfo().hasExtIntType()) - S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) - << "_ExtInt"; + case DeclSpec::TST_bitint: { + if (!S.Context.getTargetInfo().hasBitIntType()) + S.Diag(DS.getTypeSpecTypeLoc(), diag::err_type_unsupported) << "_BitInt"; Result = - S.BuildExtIntType(DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned, + S.BuildBitIntType(DS.getTypeSpecSign() == TypeSpecifierSign::Unsigned, DS.getRepAsExpr(), DS.getBeginLoc()); if (Result.isNull()) { Result = Context.IntTy; @@ -2232,7 +2231,7 @@ return Context.getWritePipeType(T); } -/// Build a extended int type. +/// Build a bit-precise integer type. /// /// \param IsUnsigned Boolean representing the signedness of the type. /// @@ -2240,10 +2239,10 @@ /// that. /// /// \param Loc Location of the keyword. -QualType Sema::BuildExtIntType(bool IsUnsigned, Expr *BitWidth, +QualType Sema::BuildBitIntType(bool IsUnsigned, Expr *BitWidth, SourceLocation Loc) { if (BitWidth->isInstantiationDependent()) - return Context.getDependentExtIntType(IsUnsigned, BitWidth); + return Context.getDependentBitIntType(IsUnsigned, BitWidth); llvm::APSInt Bits(32); ExprResult ICE = @@ -2254,22 +2253,22 @@ int64_t NumBits = Bits.getSExtValue(); if (!IsUnsigned && NumBits < 2) { - Diag(Loc, diag::err_ext_int_bad_size) << 0; + Diag(Loc, diag::err_bit_int_bad_size) << 0; return QualType(); } if (IsUnsigned && NumBits < 1) { - Diag(Loc, diag::err_ext_int_bad_size) << 1; + Diag(Loc, diag::err_bit_int_bad_size) << 1; return QualType(); } if (NumBits > llvm::IntegerType::MAX_INT_BITS) { - Diag(Loc, diag::err_ext_int_max_size) << IsUnsigned - << llvm::IntegerType::MAX_INT_BITS; + Diag(Loc, diag::err_bit_int_max_size) + << IsUnsigned << llvm::IntegerType::MAX_INT_BITS; return QualType(); } - return Context.getExtIntType(IsUnsigned, NumBits); + return Context.getBitIntType(IsUnsigned, NumBits); } /// Check whether the specified array bound can be evaluated using the relevant @@ -6069,11 +6068,11 @@ TL.getValueLoc().initializeFullCopy(TInfo->getTypeLoc()); } - void VisitExtIntTypeLoc(ExtIntTypeLoc TL) { + void VisitExtIntTypeLoc(BitIntTypeLoc TL) { TL.setNameLoc(DS.getTypeSpecTypeLoc()); } - void VisitDependentExtIntTypeLoc(DependentExtIntTypeLoc TL) { + void VisitDependentExtIntTypeLoc(DependentBitIntTypeLoc TL) { TL.setNameLoc(DS.getTypeSpecTypeLoc()); } @@ -6203,7 +6202,7 @@ assert(Chunk.Kind == DeclaratorChunk::Pipe); TL.setKWLoc(Chunk.Loc); } - void VisitExtIntTypeLoc(ExtIntTypeLoc TL) { + void VisitBitIntTypeLoc(BitIntTypeLoc TL) { TL.setNameLoc(Chunk.Loc); } void VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) { @@ -9046,9 +9045,8 @@ else if (!T.isTriviallyCopyableType(Context)) // Some other non-trivially-copyable type (probably a C++ class) DisallowedKind = 7; - else if (T->isExtIntType()) { - DisallowedKind = 8; - } + else if (T->isBitIntType()) + DisallowedKind = 8; if (DisallowedKind != -1) { Diag(Loc, diag::err_atomic_specifier_bad_type) << DisallowedKind << T; Index: clang/lib/Sema/TreeTransform.h =================================================================== --- clang/lib/Sema/TreeTransform.h +++ clang/lib/Sema/TreeTransform.h @@ -1195,12 +1195,12 @@ QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc, bool isReadPipe); - /// Build an extended int given its value type. - QualType RebuildExtIntType(bool IsUnsigned, unsigned NumBits, + /// Build a bit-precise int given its value type. + QualType RebuildBitIntType(bool IsUnsigned, unsigned NumBits, SourceLocation Loc); - /// Build a dependent extended int given its value type. - QualType RebuildDependentExtIntType(bool IsUnsigned, Expr *NumBitsExpr, + /// Build a dependent bit-precise int given its value type. + QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc); /// Build a new template name given a nested name specifier, a flag @@ -6405,27 +6405,27 @@ } template -QualType TreeTransform::TransformExtIntType(TypeLocBuilder &TLB, - ExtIntTypeLoc TL) { - const ExtIntType *EIT = TL.getTypePtr(); +QualType TreeTransform::TransformBitIntType(TypeLocBuilder &TLB, + BitIntTypeLoc TL) { + const BitIntType *EIT = TL.getTypePtr(); QualType Result = TL.getType(); if (getDerived().AlwaysRebuild()) { - Result = getDerived().RebuildExtIntType(EIT->isUnsigned(), + Result = getDerived().RebuildBitIntType(EIT->isUnsigned(), EIT->getNumBits(), TL.getNameLoc()); if (Result.isNull()) return QualType(); } - ExtIntTypeLoc NewTL = TLB.push(Result); + BitIntTypeLoc NewTL = TLB.push(Result); NewTL.setNameLoc(TL.getNameLoc()); return Result; } template -QualType TreeTransform::TransformDependentExtIntType( - TypeLocBuilder &TLB, DependentExtIntTypeLoc TL) { - const DependentExtIntType *EIT = TL.getTypePtr(); +QualType TreeTransform::TransformDependentBitIntType( + TypeLocBuilder &TLB, DependentBitIntTypeLoc TL) { + const DependentBitIntType *EIT = TL.getTypePtr(); EnterExpressionEvaluationContext Unevaluated( SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated); @@ -6438,18 +6438,18 @@ QualType Result = TL.getType(); if (getDerived().AlwaysRebuild() || BitsExpr.get() != EIT->getNumBitsExpr()) { - Result = getDerived().RebuildDependentExtIntType( + Result = getDerived().RebuildDependentBitIntType( EIT->isUnsigned(), BitsExpr.get(), TL.getNameLoc()); if (Result.isNull()) return QualType(); } - if (isa(Result)) { - DependentExtIntTypeLoc NewTL = TLB.push(Result); + if (isa(Result)) { + DependentBitIntTypeLoc NewTL = TLB.push(Result); NewTL.setNameLoc(TL.getNameLoc()); } else { - ExtIntTypeLoc NewTL = TLB.push(Result); + BitIntTypeLoc NewTL = TLB.push(Result); NewTL.setNameLoc(TL.getNameLoc()); } return Result; @@ -14484,20 +14484,20 @@ } template -QualType TreeTransform::RebuildExtIntType(bool IsUnsigned, +QualType TreeTransform::RebuildBitIntType(bool IsUnsigned, unsigned NumBits, SourceLocation Loc) { llvm::APInt NumBitsAP(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy), NumBits, true); IntegerLiteral *Bits = IntegerLiteral::Create(SemaRef.Context, NumBitsAP, SemaRef.Context.IntTy, Loc); - return SemaRef.BuildExtIntType(IsUnsigned, Bits, Loc); + return SemaRef.BuildBitIntType(IsUnsigned, Bits, Loc); } template -QualType TreeTransform::RebuildDependentExtIntType( +QualType TreeTransform::RebuildDependentBitIntType( bool IsUnsigned, Expr *NumBitsExpr, SourceLocation Loc) { - return SemaRef.BuildExtIntType(IsUnsigned, NumBitsExpr, Loc); + return SemaRef.BuildBitIntType(IsUnsigned, NumBitsExpr, Loc); } template Index: clang/lib/Serialization/ASTReader.cpp =================================================================== --- clang/lib/Serialization/ASTReader.cpp +++ clang/lib/Serialization/ASTReader.cpp @@ -6791,11 +6791,11 @@ TL.setKWLoc(readSourceLocation()); } -void TypeLocReader::VisitExtIntTypeLoc(clang::ExtIntTypeLoc TL) { +void TypeLocReader::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) { TL.setNameLoc(readSourceLocation()); } -void TypeLocReader::VisitDependentExtIntTypeLoc( - clang::DependentExtIntTypeLoc TL) { +void TypeLocReader::VisitDependentBitIntTypeLoc( + clang::DependentBitIntTypeLoc TL) { TL.setNameLoc(readSourceLocation()); } Index: clang/lib/Serialization/ASTWriter.cpp =================================================================== --- clang/lib/Serialization/ASTWriter.cpp +++ clang/lib/Serialization/ASTWriter.cpp @@ -497,11 +497,11 @@ Record.AddSourceLocation(TL.getKWLoc()); } -void TypeLocWriter::VisitExtIntTypeLoc(clang::ExtIntTypeLoc TL) { +void TypeLocWriter::VisitBitIntTypeLoc(clang::BitIntTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } -void TypeLocWriter::VisitDependentExtIntTypeLoc( - clang::DependentExtIntTypeLoc TL) { +void TypeLocWriter::VisitDependentBitIntTypeLoc( + clang::DependentBitIntTypeLoc TL) { Record.AddSourceLocation(TL.getNameLoc()); } Index: clang/test/CXX/temp/temp.param/p7.cpp =================================================================== --- clang/test/CXX/temp/temp.param/p7.cpp +++ clang/test/CXX/temp/temp.param/p7.cpp @@ -30,7 +30,7 @@ // arbitrary scalar types; we generally include complex types in that list template<_Complex float ci> struct ComplexFloat; // cxx17-error {{cannot have type '_Complex float' before C++20}} template<_Complex int ci> struct ComplexInt; // cxx17-error {{cannot have type '_Complex int' before C++20}} -template<_ExtInt(42) ei> struct ExtInt; +template<_BitInt(42) ei> struct ExtInt; // atomic types aren't scalar types template<_Atomic float ci> struct AtomicFloat; // expected-error {{cannot have type '_Atomic(float)'}} @@ -63,7 +63,7 @@ RRef &ref_to_bad = *ptr_to_bad; _Complex int ci; _Complex float cf; - _ExtInt(42) ei; + _BitInt(42) ei; VI4 vi4; VF4 vf4; }; Index: clang/test/CodeGen/attr-noundef.cpp =================================================================== --- clang/test/CodeGen/attr-noundef.cpp +++ clang/test/CodeGen/attr-noundef.cpp @@ -131,12 +131,12 @@ } void pass_npt(nullptr_t t) { } -_ExtInt(3) ret_extint() { +_BitInt(3) ret_BitInt() { return 0; } -void pass_extint(_ExtInt(3) e) { +void pass_BitInt(_BitInt(3) e) { } -void pass_large_extint(_ExtInt(127) e) { +void pass_large_BitInt(_BitInt(127) e) { } // Pointers to arrays/functions are always noundef @@ -153,10 +153,10 @@ // CHECK: [[DEFINE]] void @{{.*}}pass_npt{{.*}}(i8* % // TODO: for now, ExtInt is only noundef if it is sign/zero-extended -// CHECK-INTEL: [[DEFINE]] noundef signext i3 @{{.*}}ret_extint{{.*}}() -// CHECK-AARCH: [[DEFINE]] i3 @{{.*}}ret_extint{{.*}}() -// CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_extint{{.*}}(i3 noundef signext % -// CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_extint{{.*}}(i3 % -// CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_large_extint{{.*}}(i64 %{{.*}}, i64 % -// CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_large_extint{{.*}}(i127 % +// CHECK-INTEL: [[DEFINE]] noundef signext i3 @{{.*}}ret_BitInt{{.*}}() +// CHECK-AARCH: [[DEFINE]] i3 @{{.*}}ret_BitInt{{.*}}() +// CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_BitInt{{.*}}(i3 noundef signext % +// CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_BitInt{{.*}}(i3 % +// CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_large_BitInt{{.*}}(i64 %{{.*}}, i64 % +// CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_large_BitInt{{.*}}(i127 % } // namespace check_exotic Index: clang/test/CodeGen/builtins-overflow.c =================================================================== --- clang/test/CodeGen/builtins-overflow.c +++ clang/test/CodeGen/builtins-overflow.c @@ -41,7 +41,7 @@ return r; } -int test_add_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) { +int test_add_overflow_xint31_xint31_xint31(_BitInt(31) x, _BitInt(31) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_add_overflow_xint31_xint31_xint31({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.sadd.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}}) @@ -49,7 +49,7 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0 // CHECK: store i31 [[Q]], i31* // CHECK: br i1 [[C]] - _ExtInt(31) r; + _BitInt(31) r; if (__builtin_add_overflow(x, y, &r)) overflowed(); return r; @@ -83,7 +83,7 @@ return r; } -int test_sub_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) { +int test_sub_overflow_xint31_xint31_xint31(_BitInt(31) x, _BitInt(31) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_sub_overflow_xint31_xint31_xint31({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.ssub.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}}) @@ -91,7 +91,7 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0 // CHECK: store i31 [[Q]], i31* // CHECK: br i1 [[C]] - _ExtInt(31) r; + _BitInt(31) r; if (__builtin_sub_overflow(x, y, &r)) overflowed(); return r; @@ -170,7 +170,7 @@ return r; } -int test_mul_overflow_xint31_xint31_xint31(_ExtInt(31) x, _ExtInt(31) y) { +int test_mul_overflow_xint31_xint31_xint31(_BitInt(31) x, _BitInt(31) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint31_xint31_xint31({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i31, i1 } @llvm.smul.with.overflow.i31(i31 %{{.+}}, i31 %{{.+}}) @@ -178,13 +178,13 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i31, i1 } [[S]], 0 // CHECK: store i31 [[Q]], i31* // CHECK: br i1 [[C]] - _ExtInt(31) r; + _BitInt(31) r; if (__builtin_mul_overflow(x, y, &r)) overflowed(); return r; } -int test_mul_overflow_xint127_xint127_xint127(_ExtInt(127) x, _ExtInt(127) y) { +int test_mul_overflow_xint127_xint127_xint127(_BitInt(127) x, _BitInt(127) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint127_xint127_xint127({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i127, i1 } @llvm.smul.with.overflow.i127(i127 %{{.+}}, i127 %{{.+}}) @@ -192,13 +192,13 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i127, i1 } [[S]], 0 // CHECK: store i127 [[Q]], i127* // CHECK: br i1 [[C]] - _ExtInt(127) r; + _BitInt(127) r; if (__builtin_mul_overflow(x, y, &r)) overflowed(); return r; } -int test_mul_overflow_xint128_xint128_xint128(_ExtInt(128) x, _ExtInt(128) y) { +int test_mul_overflow_xint128_xint128_xint128(_BitInt(128) x, _BitInt(128) y) { // CHECK-LABEL: define {{(dso_local )?}}i32 @test_mul_overflow_xint128_xint128_xint128({{.+}}) // CHECK-NOT: ext // CHECK: [[S:%.+]] = call { i128, i1 } @llvm.smul.with.overflow.i128(i128 %{{.+}}, i128 %{{.+}}) @@ -206,7 +206,7 @@ // CHECK-DAG: [[Q:%.+]] = extractvalue { i128, i1 } [[S]], 0 // CHECK: store i128 [[Q]], i128* // CHECK: br i1 [[C]] - _ExtInt(128) r; + _BitInt(128) r; if (__builtin_mul_overflow(x, y, &r)) overflowed(); return r; Index: clang/test/CodeGen/ext-int-cc.c =================================================================== --- clang/test/CodeGen/ext-int-cc.c +++ clang/test/CodeGen/ext-int-cc.c @@ -30,7 +30,7 @@ // Make sure 128 and 64 bit versions are passed like integers, and that >128 // is passed indirectly. -void ParamPassing(_ExtInt(129) a, _ExtInt(128) b, _ExtInt(64) c) {} +void ParamPassing(_BitInt(129) a, _BitInt(128) b, _BitInt(64) c) {} // LIN64: define{{.*}} void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}) // WIN64: define dso_local void @ParamPassing(i129* %{{.+}}, i128* %{{.+}}, i64 %{{.+}}) // LIN32: define{{.*}} void @ParamPassing(i129* %{{.+}}, i128* %{{.+}}, i64 %{{.+}}) @@ -59,7 +59,7 @@ // AARCH64DARWIN: define{{.*}} void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128 %{{.+}}, i64 %{{.+}}) // ARM: define{{.*}} arm_aapcscc void @ParamPassing(i129* byval(i129) align 8 %{{.+}}, i128* byval(i128) align 8 %{{.+}}, i64 %{{.+}}) -void ParamPassing2(_ExtInt(129) a, _ExtInt(127) b, _ExtInt(63) c) {} +void ParamPassing2(_BitInt(129) a, _BitInt(127) b, _BitInt(63) c) {} // LIN64: define{{.*}} void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}, i64 %{{.+}}) // WIN64: define dso_local void @ParamPassing2(i129* %{{.+}}, i127* %{{.+}}, i63 %{{.+}}) // LIN32: define{{.*}} void @ParamPassing2(i129* %{{.+}}, i127* %{{.+}}, i63 %{{.+}}) @@ -89,7 +89,7 @@ // ARM: define{{.*}} arm_aapcscc void @ParamPassing2(i129* byval(i129) align 8 %{{.+}}, i127* byval(i127) align 8 %{{.+}}, i63 %{{.+}}) // Make sure we follow the signext rules for promotable integer types. -void ParamPassing3(_ExtInt(15) a, _ExtInt(31) b) {} +void ParamPassing3(_BitInt(15) a, _BitInt(31) b) {} // LIN64: define{{.*}} void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) // WIN64: define dso_local void @ParamPassing3(i15 %{{.+}}, i31 %{{.+}}) // LIN32: define{{.*}} void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) @@ -118,7 +118,7 @@ // AARCH64DARWIN: define{{.*}} void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) // ARM: define{{.*}} arm_aapcscc void @ParamPassing3(i15 signext %{{.+}}, i31 signext %{{.+}}) -_ExtInt(63) ReturnPassing(){} +_BitInt(63) ReturnPassing(){} // LIN64: define{{.*}} i64 @ReturnPassing( // WIN64: define dso_local i63 @ReturnPassing( // LIN32: define{{.*}} i63 @ReturnPassing( @@ -147,7 +147,7 @@ // AARCH64DARWIN: define{{.*}} i63 @ReturnPassing( // ARM: define{{.*}} arm_aapcscc i63 @ReturnPassing( -_ExtInt(64) ReturnPassing2(){} +_BitInt(64) ReturnPassing2(){} // LIN64: define{{.*}} i64 @ReturnPassing2( // WIN64: define dso_local i64 @ReturnPassing2( // LIN32: define{{.*}} i64 @ReturnPassing2( @@ -176,7 +176,7 @@ // AARCH64DARWIN: define{{.*}} i64 @ReturnPassing2( // ARM: define{{.*}} arm_aapcscc i64 @ReturnPassing2( -_ExtInt(127) ReturnPassing3(){} +_BitInt(127) ReturnPassing3(){} // LIN64: define{{.*}} { i64, i64 } @ReturnPassing3( // WIN64: define dso_local void @ReturnPassing3(i127* noalias sret // LIN32: define{{.*}} void @ReturnPassing3(i127* noalias sret @@ -207,7 +207,7 @@ // AARCH64DARWIN: define{{.*}} i127 @ReturnPassing3( // ARM: define{{.*}} arm_aapcscc void @ReturnPassing3(i127* noalias sret -_ExtInt(128) ReturnPassing4(){} +_BitInt(128) ReturnPassing4(){} // LIN64: define{{.*}} { i64, i64 } @ReturnPassing4( // WIN64: define dso_local void @ReturnPassing4(i128* noalias sret // LIN32: define{{.*}} void @ReturnPassing4(i128* noalias sret @@ -236,7 +236,7 @@ // AARCH64DARWIN: define{{.*}} i128 @ReturnPassing4( // ARM: define{{.*}} arm_aapcscc void @ReturnPassing4(i128* noalias sret -_ExtInt(129) ReturnPassing5(){} +_BitInt(129) ReturnPassing5(){} // LIN64: define{{.*}} void @ReturnPassing5(i129* noalias sret // WIN64: define dso_local void @ReturnPassing5(i129* noalias sret // LIN32: define{{.*}} void @ReturnPassing5(i129* noalias sret @@ -267,7 +267,7 @@ // SparcV9 is odd in that it has a return-size limit of 256, not 128 or 64 // like other platforms, so test to make sure this behavior will still work. -_ExtInt(256) ReturnPassing6() {} +_BitInt(256) ReturnPassing6() {} // SPARCV9: define{{.*}} i256 @ReturnPassing6( -_ExtInt(257) ReturnPassing7() {} +_BitInt(257) ReturnPassing7() {} // SPARCV9: define{{.*}} void @ReturnPassing7(i257* noalias sret Index: clang/test/CodeGen/ext-int-sanitizer.cpp =================================================================== --- clang/test/CodeGen/ext-int-sanitizer.cpp +++ clang/test/CodeGen/ext-int-sanitizer.cpp @@ -1,8 +1,8 @@ // RUN: %clang_cc1 -triple x86_64-gnu-linux -fsanitize=array-bounds,enum,float-cast-overflow,integer-divide-by-zero,implicit-unsigned-integer-truncation,implicit-signed-integer-truncation,implicit-integer-sign-change,unsigned-integer-overflow,signed-integer-overflow,shift-base,shift-exponent -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s -// CHECK: define{{.*}} void @_Z6BoundsRA10_KiU7_ExtIntILi15EEi -void Bounds(const int (&Array)[10], _ExtInt(15) Index) { +// CHECK: define{{.*}} void @_Z6BoundsRA10_KiDB15_ +void Bounds(const int (&Array)[10], _BitInt(15) Index) { int I1 = Array[Index]; // CHECK: %[[SEXT:.+]] = sext i15 %{{.+}} to i64 // CHECK: %[[CMP:.+]] = icmp ult i64 %[[SEXT]], 10 @@ -19,17 +19,17 @@ enum E3 { e3a = (1u << 31) - 1 } e3; - _ExtInt(34) a = e1; + _BitInt(34) a = e1; // CHECK: %[[E1:.+]] = icmp ule i32 %{{.*}}, 127 // CHECK: br i1 %[[E1]] // CHECK: call void @__ubsan_handle_load_invalid_value_abort - _ExtInt(34) b = e2; + _BitInt(34) b = e2; // CHECK: %[[E2HI:.*]] = icmp sle i32 {{.*}}, 127 // CHECK: %[[E2LO:.*]] = icmp sge i32 {{.*}}, -128 // CHECK: %[[E2:.*]] = and i1 %[[E2HI]], %[[E2LO]] // CHECK: br i1 %[[E2]] // CHECK: call void @__ubsan_handle_load_invalid_value_abort - _ExtInt(34) c = e3; + _BitInt(34) c = e3; // CHECK: %[[E3:.*]] = icmp ule i32 {{.*}}, 2147483647 // CHECK: br i1 %[[E3]] // CHECK: call void @__ubsan_handle_load_invalid_value_abort @@ -37,22 +37,22 @@ // CHECK: define{{.*}} void @_Z13FloatOverflowfd void FloatOverflow(float f, double d) { - _ExtInt(10) E = f; + _BitInt(10) E = f; // CHECK: fcmp ogt float %{{.+}}, -5.130000e+02 // CHECK: fcmp olt float %{{.+}}, 5.120000e+02 - _ExtInt(10) E2 = d; + _BitInt(10) E2 = d; // CHECK: fcmp ogt double %{{.+}}, -5.130000e+02 // CHECK: fcmp olt double %{{.+}}, 5.120000e+02 - _ExtInt(7) E3 = f; + _BitInt(7) E3 = f; // CHECK: fcmp ogt float %{{.+}}, -6.500000e+01 // CHECK: fcmp olt float %{{.+}}, 6.400000e+01 - _ExtInt(7) E4 = d; + _BitInt(7) E4 = d; // CHECK: fcmp ogt double %{{.+}}, -6.500000e+01 // CHECK: fcmp olt double %{{.+}}, 6.400000e+01 } -// CHECK: define{{.*}} void @_Z14UIntTruncationU7_ExtIntILi35EEjjy -void UIntTruncation(unsigned _ExtInt(35) E, unsigned int i, unsigned long long ll) { +// CHECK: define{{.*}} void @_Z14UIntTruncationDU35_jy +void UIntTruncation(unsigned _BitInt(35) E, unsigned int i, unsigned long long ll) { i = E; // CHECK: %[[LOADE:.+]] = load i35 @@ -73,8 +73,8 @@ // CHECK: call void @__ubsan_handle_implicit_conversion_abort } -// CHECK: define{{.*}} void @_Z13IntTruncationU7_ExtIntILi35EEiU7_ExtIntILi42EEjij -void IntTruncation(_ExtInt(35) E, unsigned _ExtInt(42) UE, int i, unsigned j) { +// CHECK: define{{.*}} void @_Z13IntTruncationDB35_DU42_ij +void IntTruncation(_BitInt(35) E, unsigned _BitInt(42) UE, int i, unsigned j) { j = E; // CHECK: %[[LOADE:.+]] = load i35 @@ -119,8 +119,8 @@ // CHECK: call void @__ubsan_handle_implicit_conversion_abort } -// CHECK: define{{.*}} void @_Z15SignChangeCheckU7_ExtIntILi39EEjU7_ExtIntILi39EEi -void SignChangeCheck(unsigned _ExtInt(39) UE, _ExtInt(39) E) { +// CHECK: define{{.*}} void @_Z15SignChangeCheckDU39_DB39_ +void SignChangeCheck(unsigned _BitInt(39) UE, _BitInt(39) E) { UE = E; // CHECK: %[[LOADEU:.+]] = load i39 // CHECK: %[[LOADE:.+]] = load i39 @@ -140,8 +140,8 @@ // CHECK: call void @__ubsan_handle_implicit_conversion_abort } -// CHECK: define{{.*}} void @_Z9DivByZeroU7_ExtIntILi11EEii -void DivByZero(_ExtInt(11) E, int i) { +// CHECK: define{{.*}} void @_Z9DivByZeroDB11_i +void DivByZero(_BitInt(11) E, int i) { // Also triggers signed integer overflow. E / E; @@ -159,8 +159,8 @@ // TODO: //-fsanitize=shift: (shift-base, shift-exponent) Shift operators where the amount shifted is greater or equal to the promoted bit-width of the left hand side or less than zero, or where the left hand side is negative. For a signed left shift, also checks for signed overflow in C, and for unsigned overflow in C++. You can use -fsanitize=shift-base or -fsanitize=shift-exponent to check only left-hand side or right-hand side of shift operation, respectively. -// CHECK: define{{.*}} void @_Z6ShiftsU7_ExtIntILi9EEi -void Shifts(_ExtInt(9) E) { +// CHECK: define{{.*}} void @_Z6ShiftsDB9_ +void Shifts(_BitInt(9) E) { E >> E; // CHECK: %[[EADDR:.+]] = alloca i9 // CHECK: %[[LHSE:.+]] = load i9, i9* %[[EADDR]] @@ -183,10 +183,10 @@ // CHECK: call void @__ubsan_handle_shift_out_of_bounds_abort } -// CHECK: define{{.*}} void @_Z21SignedIntegerOverflowU7_ExtIntILi93EEiU7_ExtIntILi4EEiU7_ExtIntILi31EEi -void SignedIntegerOverflow(_ExtInt(93) BiggestE, - _ExtInt(4) SmallestE, - _ExtInt(31) JustRightE) { +// CHECK: define{{.*}} void @_Z21SignedIntegerOverflowDB93_DB4_DB31_ +void SignedIntegerOverflow(_BitInt(93) BiggestE, + _BitInt(4) SmallestE, + _BitInt(31) JustRightE) { BiggestE + BiggestE; // CHECK: %[[LOADBIGGESTE2:.+]] = load i93 // CHECK: store i93 %[[LOADBIGGESTE2]], i93* %[[BIGGESTEADDR:.+]] @@ -220,10 +220,10 @@ // CHECK: call void @__ubsan_handle_mul_overflow_abort } -// CHECK: define{{.*}} void @_Z23UnsignedIntegerOverflowjU7_ExtIntILi23EEjU7_ExtIntILi35EEj +// CHECK: define{{.*}} void @_Z23UnsignedIntegerOverflowjDU23_DU35_ void UnsignedIntegerOverflow(unsigned u, - unsigned _ExtInt(23) SmallE, - unsigned _ExtInt(35) BigE) { + unsigned _BitInt(23) SmallE, + unsigned _BitInt(35) BigE) { u = SmallE + SmallE; // CHECK: %[[BIGGESTEADDR:.+]] = alloca i23 // CHECK: %[[LOADE1:.+]] = load i23, i23* %[[BIGGESTEADDR]] Index: clang/test/CodeGen/ext-int.c =================================================================== --- clang/test/CodeGen/ext-int.c +++ clang/test/CodeGen/ext-int.c @@ -3,17 +3,17 @@ // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN32 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN32 -void GenericTest(_ExtInt(3) a, unsigned _ExtInt(3) b, _ExtInt(4) c) { +void GenericTest(_BitInt(3) a, unsigned _BitInt(3) b, _BitInt(4) c) { // CHECK: define {{.*}}void @GenericTest - int which = _Generic(a, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3); + int which = _Generic(a, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3); // CHECK: store i32 1 - int which2 = _Generic(b, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3); + int which2 = _Generic(b, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3); // CHECK: store i32 2 - int which3 = _Generic(c, _ExtInt(3): 1, unsigned _ExtInt(3) : 2, _ExtInt(4) : 3); + int which3 = _Generic(c, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3); // CHECK: store i32 3 } -void VLATest(_ExtInt(3) A, _ExtInt(99) B, _ExtInt(123456) C) { +void VLATest(_BitInt(3) A, _BitInt(99) B, _BitInt(123456) C) { // CHECK: define {{.*}}void @VLATest int AR1[A]; // CHECK: %[[A:.+]] = zext i3 %{{.+}} to i[[INDXSIZE:[0-9]+]] @@ -27,9 +27,9 @@ } struct S { - _ExtInt(17) A; - _ExtInt(16777200) B; - _ExtInt(17) C; + _BitInt(17) A; + _BitInt(16777200) B; + _BitInt(17) C; }; void OffsetOfTest() { @@ -46,12 +46,12 @@ // WIN32: store i32 2097160, i32* %{{.+}} } -void Size1ExtIntParam(unsigned _ExtInt(1) A) { +void Size1ExtIntParam(unsigned _BitInt(1) A) { // CHECK: define {{.*}}void @Size1ExtIntParam(i1{{.*}} %[[PARAM:.+]]) // CHECK: %[[PARAM_ADDR:.+]] = alloca i1 // CHECK: %[[B:.+]] = alloca [5 x i1] // CHECK: store i1 %[[PARAM]], i1* %[[PARAM_ADDR]] - unsigned _ExtInt(1) B[5]; + unsigned _BitInt(1) B[5]; // CHECK: %[[PARAM_LOAD:.+]] = load i1, i1* %[[PARAM_ADDR]] // CHECK: %[[IDX:.+]] = getelementptr inbounds [5 x i1], [5 x i1]* %[[B]] Index: clang/test/CodeGen/extend-arg-64.c =================================================================== --- clang/test/CodeGen/extend-arg-64.c +++ clang/test/CodeGen/extend-arg-64.c @@ -26,7 +26,7 @@ unsigned char u8; signed char s8; long long ll; -_ExtInt(23) ei23; +_BitInt(23) ei23; float ff; double dd; #ifdef D128 Index: clang/test/CodeGenCXX/ext-int.cpp =================================================================== --- clang/test/CodeGenCXX/ext-int.cpp +++ clang/test/CodeGenCXX/ext-int.cpp @@ -9,54 +9,54 @@ // Ensure that the layout for these structs is the same as the normal bitfield // layouts. struct BitFieldsByte { - _ExtInt(7) A : 3; - _ExtInt(7) B : 3; - _ExtInt(7) C : 2; + _BitInt(7) A : 3; + _BitInt(7) B : 3; + _BitInt(7) C : 2; }; // CHECK: %struct.BitFieldsByte = type { i8 } struct BitFieldsShort { - _ExtInt(15) A : 3; - _ExtInt(15) B : 3; - _ExtInt(15) C : 2; + _BitInt(15) A : 3; + _BitInt(15) B : 3; + _BitInt(15) C : 2; }; // LIN: %struct.BitFieldsShort = type { i8, i8 } // WIN: %struct.BitFieldsShort = type { i16 } struct BitFieldsInt { - _ExtInt(31) A : 3; - _ExtInt(31) B : 3; - _ExtInt(31) C : 2; + _BitInt(31) A : 3; + _BitInt(31) B : 3; + _BitInt(31) C : 2; }; // LIN: %struct.BitFieldsInt = type { i8, [3 x i8] } // WIN: %struct.BitFieldsInt = type { i32 } struct BitFieldsLong { - _ExtInt(63) A : 3; - _ExtInt(63) B : 3; - _ExtInt(63) C : 2; + _BitInt(63) A : 3; + _BitInt(63) B : 3; + _BitInt(63) C : 2; }; // LIN: %struct.BitFieldsLong = type { i8, [7 x i8] } // WIN: %struct.BitFieldsLong = type { i64 } -struct HasExtIntFirst { - _ExtInt(35) A; +struct HasBitIntFirst { + _BitInt(35) A; int B; }; -// CHECK: %struct.HasExtIntFirst = type { i35, i32 } +// CHECK: %struct.HasBitIntFirst = type { i35, i32 } -struct HasExtIntLast { +struct HasBitIntLast { int A; - _ExtInt(35) B; + _BitInt(35) B; }; -// CHECK: %struct.HasExtIntLast = type { i32, i35 } +// CHECK: %struct.HasBitIntLast = type { i32, i35 } -struct HasExtIntMiddle { +struct HasBitIntMiddle { int A; - _ExtInt(35) B; + _BitInt(35) B; int C; }; -// CHECK: %struct.HasExtIntMiddle = type { i32, i35, i32 } +// CHECK: %struct.HasBitIntMiddle = type { i32, i35, i32 } // Force emitting of the above structs. void StructEmit() { @@ -65,9 +65,9 @@ BitFieldsInt C; BitFieldsLong D; - HasExtIntFirst E; - HasExtIntLast F; - HasExtIntMiddle G; + HasBitIntFirst E; + HasBitIntLast F; + HasBitIntMiddle G; } void BitfieldAssignment() { @@ -93,7 +93,7 @@ // CHECK: %[[SETC:.+]] = or i8 %[[CLEARC]], 64 } -enum AsEnumUnderlyingType : _ExtInt(9) { +enum AsEnumUnderlyingType : _BitInt(9) { A,B,C }; @@ -105,37 +105,43 @@ // CHECK: store i9 %{{.*}}, align 2 } -unsigned _ExtInt(33) ManglingTestRetParam(unsigned _ExtInt(33) Param) { -// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEj(i64 % -// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_UExtInt@$0CB@@__clang@@U12@@Z"(i33 +unsigned _BitInt(33) ManglingTestRetParam(unsigned _BitInt(33) Param) { +// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamDU33_(i64 % +// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_UBitInt@$0CB@@__clang@@U12@@Z"(i33 return 0; } -_ExtInt(33) ManglingTestRetParam(_ExtInt(33) Param) { -// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamU7_ExtIntILi33EEi(i64 % -// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_ExtInt@$0CB@@__clang@@U12@@Z"(i33 +_BitInt(33) ManglingTestRetParam(_BitInt(33) Param) { +// LIN: define{{.*}} i64 @_Z20ManglingTestRetParamDB33_(i64 % +// WIN: define dso_local i33 @"?ManglingTestRetParam@@YAU?$_BitInt@$0CB@@__clang@@U12@@Z"(i33 return 0; } template void ManglingTestTemplateParam(T&); -template<_ExtInt(99) T> +template<_BitInt(99) T> void ManglingTestNTTP(); +template +auto ManglingDependent() -> decltype(_BitInt(N){}); + void ManglingInstantiator() { // LIN: define{{.*}} void @_Z20ManglingInstantiatorv() // WIN: define dso_local void @"?ManglingInstantiator@@YAXXZ"() - _ExtInt(93) A; + _BitInt(93) A; ManglingTestTemplateParam(A); -// LIN: call void @_Z25ManglingTestTemplateParamIU7_ExtIntILi93EEiEvRT_(i93* -// WIN: call void @"??$ManglingTestTemplateParam@U?$_ExtInt@$0FN@@__clang@@@@YAXAEAU?$_ExtInt@$0FN@@__clang@@@Z"(i93* - constexpr _ExtInt(93) B = 993; + // LIN: call void @_Z25ManglingTestTemplateParamIDB93_EvRT_(i93* + // WIN: call void @"??$ManglingTestTemplateParam@U?$_BitInt@$0FN@@__clang@@@@YAXAEAU?$_BitInt@$0FN@@__clang@@@Z"(i93* + constexpr _BitInt(93) B = 993; ManglingTestNTTP<38>(); -// LIN: call void @_Z16ManglingTestNTTPILU7_ExtIntILi99EEi38EEvv() -// WIN: call void @"??$ManglingTestNTTP@$0CG@@@YAXXZ"() + // LIN: call void @_Z16ManglingTestNTTPILDB99_38EEvv() + // WIN: call void @"??$ManglingTestNTTP@$0CG@@@YAXXZ"() ManglingTestNTTP(); -// LIN: call void @_Z16ManglingTestNTTPILU7_ExtIntILi99EEi993EEvv() -// WIN: call void @"??$ManglingTestNTTP@$0DOB@@@YAXXZ"() + // LIN: call void @_Z16ManglingTestNTTPILDB99_993EEvv() + // WIN: call void @"??$ManglingTestNTTP@$0DOB@@@YAXXZ"() + ManglingDependent<4>(); + // LIN: call signext i4 @_Z17ManglingDependentILi4EEDTtlDBT__EEv() + // WIN: call i4 @"??$ManglingDependent@$03@@YAU?$_BitInt@$03@__clang@@XZ"() } void TakesVarargs(int i, ...) { @@ -153,7 +159,7 @@ // WIN: %[[ARGSSTART:.+]] = bitcast i8** %[[ARGS]] to i8* // WIN: call void @llvm.va_start(i8* %[[ARGSSTART]]) - _ExtInt(92) A = __builtin_va_arg(args, _ExtInt(92)); + _BitInt(92) A = __builtin_va_arg(args, _BitInt(92)); // LIN: %[[AD1:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P1:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD1]], i32 0, i32 0 // LIN: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P1]] @@ -171,7 +177,7 @@ // WIN: %[[LOADV1:.+]] = load i92, i92* %[[LOADP1]] // WIN: store i92 %[[LOADV1]], i92* - _ExtInt(31) B = __builtin_va_arg(args, _ExtInt(31)); + _BitInt(31) B = __builtin_va_arg(args, _BitInt(31)); // LIN: %[[AD2:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P2:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD2]], i32 0, i32 0 // LIN: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P2]] @@ -188,7 +194,7 @@ // WIN: %[[LOADV2:.+]] = load i31, i31* %[[BC2]] // WIN: store i31 %[[LOADV2]], i31* - _ExtInt(16) C = __builtin_va_arg(args, _ExtInt(16)); + _BitInt(16) C = __builtin_va_arg(args, _BitInt(16)); // LIN: %[[AD3:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P3:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD3]], i32 0, i32 0 // LIN: %[[GPOFFSET:.+]] = load i32, i32* %[[OFA_P3]] @@ -205,7 +211,7 @@ // WIN: %[[LOADV3:.+]] = load i16, i16* %[[BC3]] // WIN: store i16 %[[LOADV3]], i16* - _ExtInt(129) D = __builtin_va_arg(args, _ExtInt(129)); + _BitInt(129) D = __builtin_va_arg(args, _BitInt(129)); // LIN: %[[AD4:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P4:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD4]], i32 0, i32 2 // LIN: %[[OFA4:.+]] = load i8*, i8** %[[OFA_P4]] @@ -223,7 +229,7 @@ // WIN: %[[LOADV4:.+]] = load i129, i129* %[[LOADP4]] // WIN: store i129 %[[LOADV4]], i129* - _ExtInt(16777200) E = __builtin_va_arg(args, _ExtInt(16777200)); + _BitInt(16777200) E = __builtin_va_arg(args, _BitInt(16777200)); // LIN: %[[AD5:.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %[[ARGS]] // LIN: %[[OFA_P5:.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* %[[AD5]], i32 0, i32 2 // LIN: %[[OFA5:.+]] = load i8*, i8** %[[OFA_P5]] @@ -251,36 +257,36 @@ void typeid_tests() { // LIN: define{{.*}} void @_Z12typeid_testsv() // WIN: define dso_local void @"?typeid_tests@@YAXXZ"() - unsigned _ExtInt(33) U33_1, U33_2; - _ExtInt(33) S33_1, S33_2; - _ExtInt(32) S32_1, S32_2; + unsigned _BitInt(33) U33_1, U33_2; + _BitInt(33) S33_1, S33_2; + _BitInt(32) S32_1, S32_2; auto A = typeid(U33_1); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDU33_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UBitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) auto B = typeid(U33_2); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEj to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDU33_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor28* @"??_R0U?$_UBitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) auto C = typeid(S33_1); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDB33_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) auto D = typeid(S33_2); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi33EEi to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDB33_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CB@@__clang@@@8" to %"class.std::type_info"*)) auto E = typeid(S32_1); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDB32_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) auto F = typeid(S32_2); - // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIU7_ExtIntILi32EEi to %"class.std::type_info"*)) - // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_ExtInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) + // LIN: call void @_ZNSt9type_infoC1ERKS_(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast ({ i8*, i8* }* @_ZTIDB32_ to %"class.std::type_info"*)) + // WIN: call %"class.std::type_info"* @"??0type_info@std@@QEAA@AEBV01@@Z"(%"class.std::type_info"* {{[^,]*}} %{{.+}}, %"class.std::type_info"* nonnull align 8 dereferenceable(16) bitcast (%rtti.TypeDescriptor27* @"??_R0U?$_BitInt@$0CA@@__clang@@@8" to %"class.std::type_info"*)) } void ExplicitCasts() { // LIN: define{{.*}} void @_Z13ExplicitCastsv() // WIN: define dso_local void @"?ExplicitCasts@@YAXXZ"() - _ExtInt(33) a; - _ExtInt(31) b; + _BitInt(33) a; + _BitInt(31) b; int i; a = i; @@ -294,9 +300,9 @@ } struct S { - _ExtInt(17) A; - _ExtInt(16777200) B; - _ExtInt(17) C; + _BitInt(17) A; + _BitInt(16777200) B; + _BitInt(17) C; }; void OffsetOfTest() { @@ -312,9 +318,9 @@ } -void ShiftExtIntByConstant(_ExtInt(28) Ext) { -// LIN: define{{.*}} void @_Z21ShiftExtIntByConstantU7_ExtIntILi28EEi -// WIN: define dso_local void @"?ShiftExtIntByConstant@@YAXU?$_ExtInt@$0BM@@__clang@@@Z" +void ShiftBitIntByConstant(_BitInt(28) Ext) { +// LIN: define{{.*}} void @_Z21ShiftBitIntByConstantDB28_ +// WIN: define dso_local void @"?ShiftBitIntByConstant@@YAXU?$_BitInt@$0BM@@__clang@@@Z" Ext << 7; // CHECK: shl i28 %{{.+}}, 7 Ext >> 7; @@ -331,9 +337,9 @@ // CHECK: ashr i28 %{{.+}}, 29 } -void ConstantShiftByExtInt(_ExtInt(28) Ext, _ExtInt(65) LargeExt) { - // LIN: define{{.*}} void @_Z21ConstantShiftByExtIntU7_ExtIntILi28EEiU7_ExtIntILi65EEi - // WIN: define dso_local void @"?ConstantShiftByExtInt@@YAXU?$_ExtInt@$0BM@@__clang@@U?$_ExtInt@$0EB@@2@@Z" +void ConstantShiftByBitInt(_BitInt(28) Ext, _BitInt(65) LargeExt) { + // LIN: define{{.*}} void @_Z21ConstantShiftByBitIntDB28_DB65_ + // WIN: define dso_local void @"?ConstantShiftByBitInt@@YAXU?$_BitInt@$0BM@@__clang@@U?$_BitInt@$0EB@@2@@Z" 10 << Ext; // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32 // CHECK: shl i32 10, %[[PROMO]] @@ -348,9 +354,9 @@ // CHECK: ashr i32 10, %[[PROMO]] } -void Shift(_ExtInt(28) Ext, _ExtInt(65) LargeExt, int i) { - // LIN: define{{.*}} void @_Z5ShiftU7_ExtIntILi28EEiU7_ExtIntILi65EEii - // WIN: define dso_local void @"?Shift@@YAXU?$_ExtInt@$0BM@@__clang@@U?$_ExtInt@$0EB@@2@H@Z" +void Shift(_BitInt(28) Ext, _BitInt(65) LargeExt, int i) { + // LIN: define{{.*}} void @_Z5ShiftDB28_DB65_ + // WIN: define dso_local void @"?Shift@@YAXU?$_BitInt@$0BM@@__clang@@U?$_BitInt@$0EB@@2@H@Z" i << Ext; // CHECK: %[[PROMO:.+]] = zext i28 %{{.+}} to i32 // CHECK: shl i32 {{.+}}, %[[PROMO]] @@ -394,10 +400,9 @@ // CHECK: ashr i65 {{.+}}, %[[PROMO]] } -void ComplexTest(_Complex _ExtInt(12) first, - _Complex _ExtInt(33) second) { - // LIN: define{{.*}} void @_Z11ComplexTestCU7_ExtIntILi12EEiCU7_ExtIntILi33EEi - // WIN: define dso_local void @"?ComplexTest@@YAXU?$_Complex@U?$_ExtInt@$0M@@__clang@@@__clang@@U?$_Complex@U?$_ExtInt@$0CB@@__clang@@@2@@Z" +void ComplexTest(_Complex _BitInt(12) first, _Complex _BitInt(33) second) { + // LIN: define{{.*}} void @_Z11ComplexTestCDB12_CDB33_ + // WIN: define dso_local void @"?ComplexTest@@YAXU?$_Complex@U?$_BitInt@$0M@@__clang@@@__clang@@U?$_Complex@U?$_BitInt@$0CB@@__clang@@@2@@Z" first + second; // CHECK: %[[FIRST_REALP:.+]] = getelementptr inbounds { i12, i12 }, { i12, i12 }* %{{.+}}, i32 0, i32 0 // CHECK: %[[FIRST_REAL:.+]] = load i12, i12* %[[FIRST_REALP]] @@ -414,9 +419,9 @@ } // Ensure that these types don't alias the normal int types. -void TBAATest(_ExtInt(sizeof(int) * 8) ExtInt, - unsigned _ExtInt(sizeof(int) * 8) ExtUInt, - _ExtInt(6) Other) { +void TBAATest(_BitInt(sizeof(int) * 8) ExtInt, + unsigned _BitInt(sizeof(int) * 8) ExtUInt, + _BitInt(6) Other) { // CHECK-DAG: store i32 %{{.+}}, i32* %{{.+}}, align 4, !tbaa ![[EXTINT_TBAA:.+]] // CHECK-DAG: store i32 %{{.+}}, i32* %{{.+}}, align 4, !tbaa ![[EXTINT_TBAA]] // CHECK-DAG: store i6 %{{.+}}, i6* %{{.+}}, align 1, !tbaa ![[EXTINT6_TBAA:.+]] @@ -428,13 +433,13 @@ // NoNewStructPathTBAA-DAG: ![[CHAR_TBAA_ROOT:.+]] = !{!"omnipotent char", ![[TBAA_ROOT:.+]], i64 0} // NoNewStructPathTBAA-DAG: ![[TBAA_ROOT]] = !{!"Simple C++ TBAA"} // NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA]] = !{![[EXTINT_TBAA_ROOT:.+]], ![[EXTINT_TBAA_ROOT]], i64 0} -// NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{!"_ExtInt(32)", ![[CHAR_TBAA_ROOT]], i64 0} +// NoNewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{!"_BitInt(32)", ![[CHAR_TBAA_ROOT]], i64 0} // NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA]] = !{![[EXTINT6_TBAA_ROOT:.+]], ![[EXTINT6_TBAA_ROOT]], i64 0} -// NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{!"_ExtInt(6)", ![[CHAR_TBAA_ROOT]], i64 0} +// NoNewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{!"_BitInt(6)", ![[CHAR_TBAA_ROOT]], i64 0} // NewStructPathTBAA-DAG: ![[CHAR_TBAA_ROOT:.+]] = !{![[TBAA_ROOT:.+]], i64 1, !"omnipotent char"} // NewStructPathTBAA-DAG: ![[TBAA_ROOT]] = !{!"Simple C++ TBAA"} // NewStructPathTBAA-DAG: ![[EXTINT_TBAA]] = !{![[EXTINT_TBAA_ROOT:.+]], ![[EXTINT_TBAA_ROOT]], i64 0, i64 4} -// NewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 4, !"_ExtInt(32)"} +// NewStructPathTBAA-DAG: ![[EXTINT_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 4, !"_BitInt(32)"} // NewStructPathTBAA-DAG: ![[EXTINT6_TBAA]] = !{![[EXTINT6_TBAA_ROOT:.+]], ![[EXTINT6_TBAA_ROOT]], i64 0, i64 1} -// NewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 1, !"_ExtInt(6)"} +// NewStructPathTBAA-DAG: ![[EXTINT6_TBAA_ROOT]] = !{![[CHAR_TBAA_ROOT]], i64 1, !"_BitInt(6)"} Index: clang/test/CodeGenOpenCL/ext-int-shift.cl =================================================================== --- clang/test/CodeGenOpenCL/ext-int-shift.cl +++ clang/test/CodeGenOpenCL/ext-int-shift.cl @@ -1,6 +1,6 @@ // RUN: %clang -cc1 -triple x86_64-linux-pc -O3 -disable-llvm-passes %s -emit-llvm -o - | FileCheck %s -void Shifts(_ExtInt(12) E, int i) { +void Shifts(_BitInt(12) E, int i) { E << 99; // CHECK: shl i12 %{{.+}}, 3 Index: clang/test/OpenMP/nvptx_unsupported_type_messages.cpp =================================================================== --- clang/test/OpenMP/nvptx_unsupported_type_messages.cpp +++ clang/test/OpenMP/nvptx_unsupported_type_messages.cpp @@ -261,6 +261,6 @@ typedef typename A_type::type type; }; -void bar(_ExtInt(66) a) { +void bar(_BitInt(66) a) { auto b = a; } Index: clang/test/Parser/ext-int.cpp =================================================================== --- clang/test/Parser/ext-int.cpp +++ clang/test/Parser/ext-int.cpp @@ -5,11 +5,11 @@ // expected-error@+3{{expected unqualified-id}} // expected-error@+2{{extraneous closing brace}} // expected-error@+1{{C++ requires a type specifier for all declarations}} -_ExtInt(32} a; +_BitInt(32} a; // expected-error@+2{{expected expression}} // expected-error@+1{{C++ requires a type specifier for all declarations}} -_ExtInt(32* ) b; +_BitInt(32* ) b; // expected-error@+3{{expected '('}} // expected-error@+2{{expected unqualified-id}} // expected-error@+1{{C++ requires a type specifier for all declarations}} -_ExtInt{32} c; +_BitInt{32} c; Index: clang/test/Sema/builtins-overflow.c =================================================================== --- clang/test/Sema/builtins-overflow.c +++ clang/test/Sema/builtins-overflow.c @@ -21,21 +21,21 @@ __builtin_add_overflow(1, 1, &q); // expected-error {{result argument to overflow builtin must be a pointer to a non-const integer ('const unsigned int *' invalid)}} { - _ExtInt(128) x = 1; - _ExtInt(128) y = 1; - _ExtInt(128) result; + _BitInt(128) x = 1; + _BitInt(128) y = 1; + _BitInt(128) result; _Bool status = __builtin_mul_overflow(x, y, &result); // expect ok } { - unsigned _ExtInt(129) x = 1; - unsigned _ExtInt(129) y = 1; - unsigned _ExtInt(129) result; + unsigned _BitInt(129) x = 1; + unsigned _BitInt(129) y = 1; + unsigned _BitInt(129) result; _Bool status = __builtin_mul_overflow(x, y, &result); // expect ok } { - _ExtInt(129) x = 1; - _ExtInt(129) y = 1; - _ExtInt(129) result; - _Bool status = __builtin_mul_overflow(x, y, &result); // expected-error {{__builtin_mul_overflow does not support signed _ExtInt operands of more than 128 bits}} + _BitInt(129) x = 1; + _BitInt(129) y = 1; + _BitInt(129) result; + _Bool status = __builtin_mul_overflow(x, y, &result); // expected-error {{__builtin_mul_overflow does not support 'signed _BitInt' operands of more than 128 bits}} } } Index: clang/test/Sema/builtins.c =================================================================== --- clang/test/Sema/builtins.c +++ clang/test/Sema/builtins.c @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wstrlcpy-strlcat-size -Wno-string-plus-int -triple=i686-apple-darwin9 +// RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wstrlcpy-strlcat-size -Wno-string-plus-int -Wno-bit-int-extension -triple=i686-apple-darwin9 // This test needs to set the target because it uses __builtin_ia32_vec_ext_v4si int test1(float a, int b) { @@ -281,41 +281,41 @@ __atomic_fetch_add(ptr, 1, 0); // expected-error {{address argument to atomic operation must be a pointer to non-const type ('const int *' invalid)}} } -void test_ei_i42i(_ExtInt(42) *ptr, int value) { +void test_ei_i42i(_BitInt(42) *ptr, int value) { __sync_fetch_and_add(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}} // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}} - __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_ExtInt' is not supported}} + __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_BitInt' is not supported}} } -void test_ei_i64i(_ExtInt(64) *ptr, int value) { +void test_ei_i64i(_BitInt(64) *ptr, int value) { __sync_fetch_and_add(ptr, value); // expect success // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expect success - __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_ExtInt' is not supported}} + __atomic_fetch_add(ptr, 1, 0); // expected-error {{argument to atomic builtin of type '_BitInt' is not supported}} } -void test_ei_ii42(int *ptr, _ExtInt(42) value) { +void test_ei_ii42(int *ptr, _BitInt(42) value) { __sync_fetch_and_add(ptr, value); // expect success // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expect success } -void test_ei_ii64(int *ptr, _ExtInt(64) value) { +void test_ei_ii64(int *ptr, _BitInt(64) value) { __sync_fetch_and_add(ptr, value); // expect success // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expect success } -void test_ei_i42i42(_ExtInt(42) *ptr, _ExtInt(42) value) { +void test_ei_i42i42(_BitInt(42) *ptr, _BitInt(42) value) { __sync_fetch_and_add(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}} // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expected-error {{Atomic memory operand must have a power-of-two size}} } -void test_ei_i64i64(_ExtInt(64) *ptr, _ExtInt(64) value) { +void test_ei_i64i64(_BitInt(64) *ptr, _BitInt(64) value) { __sync_fetch_and_add(ptr, value); // expect success // expected-warning@+1 {{the semantics of this intrinsic changed with GCC version 4.4 - the newer semantics are provided here}} __sync_nand_and_fetch(ptr, value); // expect success Index: clang/test/Sema/ext-int.c =================================================================== --- clang/test/Sema/ext-int.c +++ clang/test/Sema/ext-int.c @@ -1,9 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -Wimplicit-int-conversion -Wno-unused -triple x86_64-gnu-linux -typedef _ExtInt(31) EI31; +typedef _BitInt(31) EI31; -void Ternary(_ExtInt(30) s30, EI31 s31a, _ExtInt(31) s31b, - _ExtInt(32) s32, int b) { +void Ternary(_BitInt(30) s30, EI31 s31a, _BitInt(31) s31b, + _BitInt(32) s32, int b) { b ? s30 : s31a; b ? s31a : s30; b ? s32 : 0; @@ -12,42 +12,42 @@ } struct CursedBitField { - _ExtInt(4) A : 8; // expected-error {{width of bit-field 'A' (8 bits) exceeds the width of its type (4 bits)}} + _BitInt(4) A : 8; // expected-error {{width of bit-field 'A' (8 bits) exceeds the width of its type (4 bits)}} }; #define EXPR_HAS_TYPE(EXPR, TYPE) _Generic((EXPR), default : 0, TYPE : 1) void Ops(void) { - _ExtInt(4) x4_s = 1; - _ExtInt(32) x32_s = 1; - _ExtInt(43) x43_s = 1; - unsigned _ExtInt(4) x4_u = 1; - unsigned _ExtInt(43) x43_u = 1; - unsigned _ExtInt(32) x32_u = 1; + _BitInt(4) x4_s = 1; + _BitInt(32) x32_s = 1; + _BitInt(43) x43_s = 1; + unsigned _BitInt(4) x4_u = 1; + unsigned _BitInt(43) x43_u = 1; + unsigned _BitInt(32) x32_u = 1; int x_int = 1; unsigned x_uint = 1; // Same size/sign ops don't change type. - _Static_assert(EXPR_HAS_TYPE(x43_s + x43_s, _ExtInt(43)), ""); - _Static_assert(EXPR_HAS_TYPE(x4_s - x4_s, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(x43_u * x43_u, unsigned _ExtInt(43)), ""); - _Static_assert(EXPR_HAS_TYPE(x4_u / x4_u, unsigned _ExtInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(x43_s + x43_s, _BitInt(43)), ""); + _Static_assert(EXPR_HAS_TYPE(x4_s - x4_s, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(x43_u * x43_u, unsigned _BitInt(43)), ""); + _Static_assert(EXPR_HAS_TYPE(x4_u / x4_u, unsigned _BitInt(4)), ""); // Unary ops shouldn't go through integer promotions. - _Static_assert(EXPR_HAS_TYPE(x4_s++, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(++x4_s, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(x4_u++, unsigned _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(++x4_u, unsigned _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(+x4_s, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(-x4_s, _ExtInt(4)), ""); - _Static_assert(EXPR_HAS_TYPE(~x4_u, unsigned _ExtInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(x4_s++, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(++x4_s, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(x4_u++, unsigned _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(++x4_u, unsigned _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(+x4_s, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(-x4_s, _BitInt(4)), ""); + _Static_assert(EXPR_HAS_TYPE(~x4_u, unsigned _BitInt(4)), ""); // This one really does convert to a different result type though. _Static_assert(EXPR_HAS_TYPE(!x4_u, int), ""); // Test binary ops pick the correct common type. - _Static_assert(EXPR_HAS_TYPE(x43_s + x_int, _ExtInt(43)), ""); - _Static_assert(EXPR_HAS_TYPE(x43_u + x_int, unsigned _ExtInt(43)), ""); + _Static_assert(EXPR_HAS_TYPE(x43_s + x_int, _BitInt(43)), ""); + _Static_assert(EXPR_HAS_TYPE(x43_u + x_int, unsigned _BitInt(43)), ""); _Static_assert(EXPR_HAS_TYPE(x32_s + x_int, int), ""); _Static_assert(EXPR_HAS_TYPE(x32_u + x_int, unsigned int), ""); _Static_assert(EXPR_HAS_TYPE(x32_s + x_uint, unsigned int), ""); @@ -60,16 +60,16 @@ void FromPaper1(void) { // Test the examples of conversion and promotion rules from C2x 6.3.1.8. - _ExtInt(2) a2 = 1; - _ExtInt(3) a3 = 2; - _ExtInt(33) a33 = 1; + _BitInt(2) a2 = 1; + _BitInt(3) a3 = 2; + _BitInt(33) a33 = 1; char c = 3; - _Static_assert(EXPR_HAS_TYPE(a2 * a3, _ExtInt(3)), ""); + _Static_assert(EXPR_HAS_TYPE(a2 * a3, _BitInt(3)), ""); _Static_assert(EXPR_HAS_TYPE(a2 * c, int), ""); - _Static_assert(EXPR_HAS_TYPE(a33 * c, _ExtInt(33)), ""); + _Static_assert(EXPR_HAS_TYPE(a33 * c, _BitInt(33)), ""); } -void FromPaper2(_ExtInt(8) a1, _ExtInt(24) a2) { - _Static_assert(EXPR_HAS_TYPE(a1 * (_ExtInt(32))a2, _ExtInt(32)), ""); +void FromPaper2(_BitInt(8) a1, _BitInt(24) a2) { + _Static_assert(EXPR_HAS_TYPE(a1 * (_BitInt(32))a2, _BitInt(32)), ""); } Index: clang/test/Sema/invalid-bitwidth-expr.mm =================================================================== --- clang/test/Sema/invalid-bitwidth-expr.mm +++ clang/test/Sema/invalid-bitwidth-expr.mm @@ -34,6 +34,6 @@ constexpr int ssss = sizeof(Z); struct Z2 { - int X : sizeof(_ExtInt(invalid())); // expected-error {{use of undeclared identifier}} + int X : sizeof(_BitInt(invalid())); // expected-error {{use of undeclared identifier}} }; constexpr int sssss = sizeof(Z2); Index: clang/test/SemaCXX/ext-int-asm.cpp =================================================================== --- clang/test/SemaCXX/ext-int-asm.cpp +++ clang/test/SemaCXX/ext-int-asm.cpp @@ -1,11 +1,11 @@ // REQUIRES: x86-registered-target // RUN: %clang_cc1 -fsyntax-only -verify %s -Wimplicit-int-conversion -triple x86_64-gnu-linux -fasm-blocks -void NotAllowedInInlineAsm(_ExtInt(9) in, _ExtInt(9) out) { - __asm { mov eax, in} // expected-error{{invalid type '_ExtInt(9)' in asm input}} - __asm { mov out, eax} // expected-error{{invalid type '_ExtInt(9)' in asm output}} +void NotAllowedInInlineAsm(_BitInt(9) in, _BitInt(9) out) { + __asm { mov eax, in} // expected-error{{invalid type '_BitInt(9)' in asm input}} + __asm { mov out, eax} // expected-error{{invalid type '_BitInt(9)' in asm output}} - asm("" : "=g" (in));// expected-error{{invalid type '_ExtInt(9)' in asm input}} - asm("" :: "r" (out));// expected-error{{invalid type '_ExtInt(9)' in asm output}} + asm("" : "=g" (in));// expected-error{{invalid type '_BitInt(9)' in asm input}} + asm("" :: "r" (out));// expected-error{{invalid type '_BitInt(9)' in asm output}} } Index: clang/test/SemaCXX/ext-int-compat.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/ext-int-compat.cpp @@ -0,0 +1,8 @@ +// RUN: %clang_cc1 -fsyntax-only -std=c2x -Wpre-c2x-compat -verify=precompat -x c %s +// RUN: %clang_cc1 -fsyntax-only -std=c17 -Wbit-int-extension -verify=cext -x c %s +// RUN: %clang_cc1 -fsyntax-only -Wbit-int-extension -verify=cppext %s + +_BitInt(5) Val; // precompat-warning {{'_BitInt' is incompatible with C standards before C2x}} \ + cext-warning {{'_BitInt' in C17 and earlier is a Clang extension}} \ + cppext-warning {{'_BitInt' in C++ is a Clang extension}} + Index: clang/test/SemaCXX/ext-int-fixit.cpp =================================================================== --- /dev/null +++ clang/test/SemaCXX/ext-int-fixit.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s + +// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:12-[[@LINE+1]]:19}:"_BitInt" +void Fixit(_ExtInt(8) foo) { // expected-warning {{'_ExtInt' is deprecated; use '_BitInt' instead}} + // CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:12-[[@LINE+1]]:19}:"_BitInt" + unsigned _ExtInt(33) bar; // expected-warning {{'_ExtInt' is deprecated; use '_BitInt' instead}} +} + +// CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:11-[[@LINE+1]]:18}:"_BitInt" +template <_ExtInt(32) Val> // expected-warning {{'_ExtInt' is deprecated; use '_BitInt' instead}} +void Func(); + +template +void OtherFunc(Ty); + +void Instantiate() { + // CHECK: fix-it:"{{.*}}":{[[@LINE+1]]:23-[[@LINE+1]]:30}:"_BitInt" + OtherFunc((unsigned _ExtInt(24) const){0}); // expected-warning {{'_ExtInt' is deprecated; use '_BitInt' instead}} +} Index: clang/test/SemaCXX/ext-int.cpp =================================================================== --- clang/test/SemaCXX/ext-int.cpp +++ clang/test/SemaCXX/ext-int.cpp @@ -2,72 +2,72 @@ template struct HasExtInt { - _ExtInt(Bounds) b; - unsigned _ExtInt(Bounds) b2; + _BitInt(Bounds) b; + unsigned _BitInt(Bounds) b2; }; // Delcaring variables: -_ExtInt(33) Declarations(_ExtInt(48) &Param) { // Useable in params and returns. - short _ExtInt(43) a; // expected-error {{'short _ExtInt' is invalid}} - _ExtInt(43) long b; // expected-error {{'long _ExtInt' is invalid}} +_BitInt(33) Declarations(_BitInt(48) &Param) { // Useable in params and returns. + short _BitInt(43) a; // expected-error {{'short _BitInt' is invalid}} + _BitInt(43) long b; // expected-error {{'long _BitInt' is invalid}} // These should all be fine: - const _ExtInt(5) c = 3; - const unsigned _ExtInt(5) d; // expected-error {{default initialization of an object of const type 'const unsigned _ExtInt(5)'}} - unsigned _ExtInt(5) e = 5; - _ExtInt(5) unsigned f; - - _ExtInt(-3) g; // expected-error{{signed _ExtInt must have a bit size of at least 2}} - _ExtInt(0) h; // expected-error{{signed _ExtInt must have a bit size of at least 2}} - _ExtInt(1) i; // expected-error{{signed _ExtInt must have a bit size of at least 2}} - _ExtInt(2) j;; - unsigned _ExtInt(0) k;// expected-error{{unsigned _ExtInt must have a bit size of at least 1}} - unsigned _ExtInt(1) l; - signed _ExtInt(1) m; // expected-error{{signed _ExtInt must have a bit size of at least 2}} - - constexpr _ExtInt(6) n = 33; // expected-warning{{implicit conversion from 'int' to 'const _ExtInt(6)' changes value from 33 to -31}} - constexpr _ExtInt(7) o = 33; + const _BitInt(5) c = 3; + const unsigned _BitInt(5) d; // expected-error {{default initialization of an object of const type 'const unsigned _BitInt(5)'}} + unsigned _BitInt(5) e = 5; + _BitInt(5) unsigned f; + + _BitInt(-3) g; // expected-error{{signed _BitInt must have a bit size of at least 2}} + _BitInt(0) h; // expected-error{{signed _BitInt must have a bit size of at least 2}} + _BitInt(1) i; // expected-error{{signed _BitInt must have a bit size of at least 2}} + _BitInt(2) j;; + unsigned _BitInt(0) k;// expected-error{{unsigned _BitInt must have a bit size of at least 1}} + unsigned _BitInt(1) l; + signed _BitInt(1) m; // expected-error{{signed _BitInt must have a bit size of at least 2}} + + constexpr _BitInt(6) n = 33; // expected-warning{{implicit conversion from 'int' to 'const _BitInt(6)' changes value from 33 to -31}} + constexpr _BitInt(7) o = 33; // Check LLVM imposed max size. - _ExtInt(0xFFFFFFFFFF) p; // expected-error {{signed _ExtInt of bit sizes greater than 16777215 not supported}} - unsigned _ExtInt(0xFFFFFFFFFF) q; // expected-error {{unsigned _ExtInt of bit sizes greater than 16777215 not supported}} + _BitInt(0xFFFFFFFFFF) p; // expected-error {{signed _BitInt of bit sizes greater than 16777215 not supported}} + unsigned _BitInt(0xFFFFFFFFFF) q; // expected-error {{unsigned _BitInt of bit sizes greater than 16777215 not supported}} // Ensure template params are instantiated correctly. - // expected-error@5{{signed _ExtInt must have a bit size of at least 2}} - // expected-error@6{{unsigned _ExtInt must have a bit size of at least 1}} + // expected-error@5{{signed _BitInt must have a bit size of at least 2}} + // expected-error@6{{unsigned _BitInt must have a bit size of at least 1}} // expected-note@+1{{in instantiation of template class }} HasExtInt<-1> r; - // expected-error@5{{signed _ExtInt must have a bit size of at least 2}} - // expected-error@6{{unsigned _ExtInt must have a bit size of at least 1}} + // expected-error@5{{signed _BitInt must have a bit size of at least 2}} + // expected-error@6{{unsigned _BitInt must have a bit size of at least 1}} // expected-note@+1{{in instantiation of template class }} HasExtInt<0> s; - // expected-error@5{{signed _ExtInt must have a bit size of at least 2}} + // expected-error@5{{signed _BitInt must have a bit size of at least 2}} // expected-note@+1{{in instantiation of template class }} HasExtInt<1> t; HasExtInt<2> u; - _ExtInt(-3.0) v; // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'double'}} - _ExtInt(3.0) x; // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'double'}} + _BitInt(-3.0) v; // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'double'}} + _BitInt(3.0) x; // expected-error {{integral constant expression must have integral or unscoped enumeration type, not 'double'}} return 0; } -template <_ExtInt(5) I> +template <_BitInt(5) I> struct ExtIntTemplParam { - static constexpr _ExtInt(5) Var = I; + static constexpr _BitInt(5) Var = I; }; template void deduced_whole_type(T){} template -void deduced_bound(_ExtInt(I)){} +void deduced_bound(_BitInt(I)){} // Ensure ext-int can be used in template places. void Templates() { ExtIntTemplParam<13> a; - constexpr _ExtInt(3) b = 1; + constexpr _BitInt(3) b = 1; ExtIntTemplParam c; - constexpr _ExtInt(9) d = 1; + constexpr _BitInt(9) d = 1; ExtIntTemplParam e; deduced_whole_type(b); @@ -84,28 +84,28 @@ }; // Reject vector types: -// expected-error@+1{{invalid vector element type '_ExtInt(32)'}} -typedef _ExtInt(32) __attribute__((vector_size(16))) VecTy; +// expected-error@+1{{invalid vector element type '_BitInt(32)'}} +typedef _BitInt(32) __attribute__((vector_size(16))) VecTy; // Allow _Complex: -_Complex _ExtInt(3) Cmplx; +_Complex _BitInt(3) Cmplx; // Reject cases of _Atomic: -// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(4)'}} -_Atomic _ExtInt(4) TooSmallAtomic; -// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(9)'}} -_Atomic _ExtInt(9) NotPow2Atomic; -// expected-error@+1{{_Atomic cannot be applied to integer type '_ExtInt(128)'}} -_Atomic _ExtInt(128) JustRightAtomic; +// expected-error@+1{{_Atomic cannot be applied to integer type '_BitInt(4)'}} +_Atomic _BitInt(4) TooSmallAtomic; +// expected-error@+1{{_Atomic cannot be applied to integer type '_BitInt(9)'}} +_Atomic _BitInt(9) NotPow2Atomic; +// expected-error@+1{{_Atomic cannot be applied to integer type '_BitInt(128)'}} +_Atomic _BitInt(128) JustRightAtomic; // Test result types of Unary/Bitwise/Binary Operations: void Ops() { - _ExtInt(43) x43_s = 1, y43_s = 1; - _ExtInt(sizeof(int) * 8) x32_s = 1, y32_s = 1; - unsigned _ExtInt(sizeof(unsigned) * 8) x32_u = 1, y32_u = 1; - _ExtInt(4) x4_s = 1, y4_s = 1; - unsigned _ExtInt(43) x43_u = 1, y43_u = 1; - unsigned _ExtInt(4) x4_u = 1, y4_u = 1; + _BitInt(43) x43_s = 1, y43_s = 1; + _BitInt(sizeof(int) * 8) x32_s = 1, y32_s = 1; + unsigned _BitInt(sizeof(unsigned) * 8) x32_u = 1, y32_u = 1; + _BitInt(4) x4_s = 1, y4_s = 1; + unsigned _BitInt(43) x43_u = 1, y43_u = 1; + unsigned _BitInt(4) x4_u = 1, y4_u = 1; int x_int = 1, y_int = 1; unsigned x_uint = 1, y_uint = 1; bool b; @@ -135,8 +135,8 @@ x4_u - b; x43_s + b; x43_u - b; - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); static_assert(is_same::value, ""); static_assert(is_same::value, ""); static_assert(is_same::value, ""); @@ -157,71 +157,71 @@ // Comparisons. x43_s > 33; - x4_s > 33; // expected-warning {{result of comparison of constant 33 with expression of type '_ExtInt(4)' is always false}} + x4_s > 33; // expected-warning {{result of comparison of constant 33 with expression of type '_BitInt(4)' is always false}} // Same size/sign ops don't change type. - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); // Unary ops shouldn't go through integer promotions. - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); - static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same::value,""); // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}} - static_assert(is_same::value,""); + static_assert(is_same::value,""); // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}} - static_assert(is_same::value,""); + static_assert(is_same::value,""); // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}} - static_assert(is_same::value,""); + static_assert(is_same::value,""); // expected-warning@+1{{expression with side effects has no effect in an unevaluated context}} - static_assert(is_same::value,""); - static_assert(is_same> 1), _ExtInt(4)>::value,""); - static_assert(is_same::value,""); + static_assert(is_same::value,""); + static_assert(is_same> 1), _BitInt(4)>::value,""); + static_assert(is_same::value,""); static_assert(sizeof(x43_s) == 8, ""); static_assert(sizeof(x4_s) == 1, ""); - static_assert(sizeof(_ExtInt(3340)) == 424, ""); // 424 * 8 == 3392. - static_assert(sizeof(_ExtInt(1049)) == 136, ""); // 136 * 8 == 1088. + static_assert(sizeof(_BitInt(3340)) == 424, ""); // 424 * 8 == 3392. + static_assert(sizeof(_BitInt(1049)) == 136, ""); // 136 * 8 == 1088. static_assert(alignof(decltype(x43_s)) == 8, ""); static_assert(alignof(decltype(x4_s)) == 1, ""); - static_assert(alignof(_ExtInt(3340)) == 8, ""); - static_assert(alignof(_ExtInt(1049)) == 8, ""); + static_assert(alignof(_BitInt(3340)) == 8, ""); + static_assert(alignof(_BitInt(1049)) == 8, ""); } constexpr int func() { return 42;} void ConstexprBitsize() { - _ExtInt(func()) F; - static_assert(is_same::value, ""); + _BitInt(func()) F; + static_assert(is_same::value, ""); } // Useable as an underlying type. -enum AsEnumUnderlyingType : _ExtInt(33) { +enum AsEnumUnderlyingType : _BitInt(33) { }; void overloaded(int); -void overloaded(_ExtInt(32)); -void overloaded(_ExtInt(33)); +void overloaded(_BitInt(32)); +void overloaded(_BitInt(33)); void overloaded(short); //expected-note@+1{{candidate function}} -void overloaded2(_ExtInt(32)); +void overloaded2(_BitInt(32)); //expected-note@+1{{candidate function}} -void overloaded2(_ExtInt(33)); +void overloaded2(_BitInt(33)); //expected-note@+1{{candidate function}} void overloaded2(short); void overload_use() { int i; - _ExtInt(32) i32; - _ExtInt(33) i33; + _BitInt(32) i32; + _BitInt(33) i33; short s; // All of these get their corresponding exact matches. @@ -239,19 +239,19 @@ // no errors expected, this should 'just work'. struct UsedAsBitField { - _ExtInt(3) F : 3; - _ExtInt(3) G : 3; - _ExtInt(3) H : 3; + _BitInt(3) F : 3; + _BitInt(3) G : 3; + _BitInt(3) H : 3; }; struct CursedBitField { - _ExtInt(4) A : 8; // expected-warning {{width of bit-field 'A' (8 bits) exceeds the width of its type; value will be truncated to 4 bits}} + _BitInt(4) A : 8; // expected-warning {{width of bit-field 'A' (8 bits) exceeds the width of its type; value will be truncated to 4 bits}} }; // expected-error@+1{{mode attribute only supported for integer and floating-point types}} -typedef _ExtInt(33) IllegalMode __attribute__((mode(DI))); +typedef _BitInt(33) IllegalMode __attribute__((mode(DI))); -void ImplicitCasts(_ExtInt(31) s31, _ExtInt(33) s33, int i) { +void ImplicitCasts(_BitInt(31) s31, _BitInt(33) s33, int i) { // expected-warning@+1{{implicit conversion loses integer precision}} s31 = i; // expected-warning@+1{{implicit conversion loses integer precision}} @@ -263,31 +263,31 @@ i = s33; } -void Ternary(_ExtInt(30) s30, _ExtInt(31) s31a, _ExtInt(31) s31b, - _ExtInt(32) s32, bool b) { +void Ternary(_BitInt(30) s30, _BitInt(31) s31a, _BitInt(31) s31b, + _BitInt(32) s32, bool b) { b ? s30 : s31a; b ? s31a : s30; b ? s32 : (int)0; (void)(b ? s31a : s31b); (void)(s30 ? s31a : s31b); - static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); static_assert(is_same::value, ""); } void FromPaper1() { // Test the examples of conversion and promotion rules from C2x 6.3.1.8. - _ExtInt(2) a2 = 1; - _ExtInt(3) a3 = 2; - _ExtInt(33) a33 = 1; + _BitInt(2) a2 = 1; + _BitInt(3) a3 = 2; + _BitInt(33) a33 = 1; char c = 3; - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); static_assert(is_same::value, ""); - static_assert(is_same::value, ""); + static_assert(is_same::value, ""); } -void FromPaper2(_ExtInt(8) a1, _ExtInt(24) a2) { - static_assert(is_same::value, ""); +void FromPaper2(_BitInt(8) a1, _BitInt(24) a2) { + static_assert(is_same::value, ""); } Index: clang/tools/libclang/CIndex.cpp =================================================================== --- clang/tools/libclang/CIndex.cpp +++ clang/tools/libclang/CIndex.cpp @@ -1815,8 +1815,8 @@ DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParm, Type) DEFAULT_TYPELOC_IMPL(SubstTemplateTypeParmPack, Type) DEFAULT_TYPELOC_IMPL(Auto, Type) -DEFAULT_TYPELOC_IMPL(ExtInt, Type) -DEFAULT_TYPELOC_IMPL(DependentExtInt, Type) +DEFAULT_TYPELOC_IMPL(BitInt, Type) +DEFAULT_TYPELOC_IMPL(DependentBitInt, Type) bool CursorVisitor::VisitCXXRecordDecl(CXXRecordDecl *D) { // Visit the nested-name-specifier, if present.