-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[AArch64] Add missing Neon Types #126945
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AArch64] Add missing Neon Types #126945
Conversation
@llvm/pr-subscribers-debuginfo @llvm/pr-subscribers-clang Author: Tomas Matheson (tmatheson-arm) ChangesThe AAPCS64 adds a number of vector types to the C unconditionally: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#11appendix-support-for-advanced-simd-extensions The equivalent SVE types are already available in clang: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#12appendix-support-for-scalable-vectors __mfp8 is defined in the ACLE I'm not sure whether __mfp8 should be defined for A32. For now I have left it as it is. Patch is 21.38 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/126945.diff 17 Files Affected:
diff --git a/clang/include/clang/Basic/AArch64SVEACLETypes.def b/clang/include/clang/Basic/AArch64SVEACLETypes.def
index 6a6f51c95ebd0..6d0a9ef4eba59 100644
--- a/clang/include/clang/Basic/AArch64SVEACLETypes.def
+++ b/clang/include/clang/Basic/AArch64SVEACLETypes.def
@@ -57,6 +57,10 @@
// - IsBF true for vector of brain float elements.
//===----------------------------------------------------------------------===//
+#ifndef SVE_TYPE
+#define SVE_TYPE(Name, Id, SingletonId)
+#endif
+
#ifndef SVE_SCALAR_TYPE
#define SVE_SCALAR_TYPE(Name, MangledName, Id, SingletonId, Bits) \
SVE_TYPE(Name, Id, SingletonId)
@@ -201,6 +205,39 @@ SVE_OPAQUE_TYPE(__SVCount_t, __SVCount_t, SveCount, SveCountTy)
SVE_SCALAR_TYPE(__mfp8, __mfp8, MFloat8, MFloat8Ty, 8)
+#ifndef NEON_VECTOR_TYPE
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind)
+#endif
+NEON_VECTOR_TYPE(__Int8x8_t, CharTy, 8, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int16x4_t, ShortTy, 16, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int32x2_t, IntTy, 32, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint8x8_t, CharTy, 8, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint16x4_t, UnsignedShortTy, 16, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint32x2_t, UnsignedIntTy, 32, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float16x4_t, Float16Ty, 16, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float32x2_t, FloatTy, 32, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Poly8x8_t, CharTy, 8, 8, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Poly16x4_t, UnsignedShortTy, 16, 4, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Bfloat16x4_t, BFloat16Ty, 16, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int8x16_t, CharTy, 18, 6, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int16x8_t, ShortTy, 16, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int32x4_t, IntTy, 32, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Int64x2_t, LongLongTy, 64, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint8x16_t, CharTy, 18, 6, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint16x8_t, UnsignedShortTy, 16, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint32x4_t, UnsignedIntTy, 32, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Uint64x2_t, UnsignedLongLongTy, 64, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float16x8_t, Float16Ty, 16, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float32x4_t, FloatTy, 32, 4, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Float64x2_t, DoubleTy, 64, 2, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Poly8x16_t, CharTy, 18, 6, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Poly16x8_t, UnsignedShortTy, 16, 8, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Poly64x2_t, UnsignedLongLongTy, 64, 2, VectorKind::NeonPoly)
+NEON_VECTOR_TYPE(__Bfloat16x8_t, BFloat16Ty, 16, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Mfloat8x8_t, MFloat8Ty, 8, 8, VectorKind::Neon)
+NEON_VECTOR_TYPE(__Mfloat8x16_t, MFloat8Ty, 16, 8, VectorKind::Neon)
+
+#undef NEON_VECTOR_TYPE
#undef SVE_VECTOR_TYPE
#undef SVE_VECTOR_TYPE_MFLOAT
#undef SVE_VECTOR_TYPE_BFLOAT
diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def
index cb55f09acc076..a2d39f1f837e5 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -463,6 +463,7 @@ COMPATIBLE_VALUE_LANGOPT(FunctionAlignment, 5, 0, "Default alignment for functio
COMPATIBLE_VALUE_LANGOPT(LoopAlignment, 32, 0, "Default alignment for loops")
LANGOPT(FixedPoint, 1, 0, "fixed point types")
+LANGOPT(ACLE, 1, 0, "Arm C Language Extensions")
LANGOPT(PaddingOnUnsignedFixedPoint, 1, 0,
"unsigned fixed point types having one extra padding bit")
diff --git a/clang/include/clang/Basic/Specifiers.h b/clang/include/clang/Basic/Specifiers.h
index 9c089908fdc13..51264fec647e7 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -98,6 +98,11 @@ namespace clang {
#define GENERIC_IMAGE_TYPE(ImgType, Id) \
TST_##ImgType##_t, // OpenCL image types
#include "clang/Basic/OpenCLImageTypes.def"
+
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ TST_##Name,
+#include "clang/Basic/AArch64SVEACLETypes.def"
+
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
TST_##Name, // HLSL Intangible Types
#include "clang/Basic/HLSLIntangibleTypes.def"
diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def
index 8902a20b07ffa..a9639192b4a77 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -679,6 +679,11 @@ KEYWORD(__bool , KEYALTIVEC|KEYZVECTOR)
ALIAS("__fp16", half , KEYALL)
KEYWORD(__bf16 , KEYALL)
+// ARM NEON types
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ KEYWORD(Name, KEYACLE)
+#include "clang/Basic/AArch64SVEACLETypes.def"
+
// OpenCL Extension.
KEYWORD(half , HALFSUPPORT)
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index 5f5df3a45d41d..d77467ad13751 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -322,6 +322,11 @@ class DeclSpec {
#define GENERIC_IMAGE_TYPE(ImgType, Id) \
static const TST TST_##ImgType##_t = clang::TST_##ImgType##_t;
#include "clang/Basic/OpenCLImageTypes.def"
+
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ static const TST TST_##Name = clang::TST_##Name;
+#include "clang/Basic/AArch64SVEACLETypes.def"
+
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
static const TST TST_##Name = clang::TST_##Name;
#include "clang/Basic/HLSLIntangibleTypes.def"
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 2dc96691f1da7..f32ab3c8a7b4f 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1440,11 +1440,19 @@ void ASTContext::InitBuiltinTypes(const TargetInfo &Target,
if (Target.hasAArch64SVETypes() ||
(AuxTarget && AuxTarget->hasAArch64SVETypes())) {
-#define SVE_TYPE(Name, Id, SingletonId) \
+ #define SVE_VECTOR_TYPE(Name, MangledName, Id, SingletonId) \
+ InitBuiltinType(SingletonId, BuiltinType::Id);
+ #define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
+ InitBuiltinType(SingletonId, BuiltinType::Id);
+ #define SVE_OPAQUE_TYPE(Name, MangledName, Id, SingletonId) \
InitBuiltinType(SingletonId, BuiltinType::Id);
#include "clang/Basic/AArch64SVEACLETypes.def"
}
+ if (LangOpts.ACLE) {
+ InitBuiltinType(MFloat8Ty, BuiltinType::MFloat8);
+ }
+
if (Target.getTriple().isPPC64()) {
#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
InitBuiltinType(Id##Ty, BuiltinType::Id);
@@ -4429,7 +4437,6 @@ ASTContext::getBuiltinVectorTypeInfo(const BuiltinType *Ty) const {
#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
case BuiltinType::Id: \
return {BoolTy, llvm::ElementCount::getScalable(NumEls), NF};
-#define SVE_TYPE(Name, Id, SingletonId)
#include "clang/Basic/AArch64SVEACLETypes.def"
#define RVV_VECTOR_TYPE_INT(Name, Id, SingletonId, NumEls, ElBits, NF, \
@@ -4500,7 +4507,6 @@ QualType ASTContext::getScalableVectorType(QualType EltTy, unsigned NumElts,
#define SVE_PREDICATE_TYPE_ALL(Name, MangledName, Id, SingletonId, NumEls, NF) \
if (EltTy->isBooleanType() && NumElts == (NumEls * NF) && NumFields == 1) \
return SingletonId;
-#define SVE_TYPE(Name, Id, SingletonId)
#include "clang/Basic/AArch64SVEACLETypes.def"
} else if (Target->hasRISCVVTypes()) {
uint64_t EltTySize = getTypeSize(EltTy);
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 8c11ec2e1fe24..ee464bbd65f1d 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2527,7 +2527,6 @@ bool Type::isSVESizelessBuiltinType() const {
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
case BuiltinType::Id: \
return true;
-#define SVE_TYPE(Name, Id, SingletonId)
#include "clang/Basic/AArch64SVEACLETypes.def"
default:
return false;
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp
index 16151c94464f9..15bb3f2289ff6 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -111,7 +111,8 @@ enum TokenKey : unsigned {
KEYNOZOS = 0x4000000,
KEYHLSL = 0x8000000,
KEYFIXEDPOINT = 0x10000000,
- KEYMAX = KEYFIXEDPOINT, // The maximum key
+ KEYACLE = 0x20000000, // Enable Arm Neon vector type keywords
+ KEYMAX = KEYACLE, // The maximum key
KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20,
KEYALL = (KEYMAX | (KEYMAX - 1)) & ~KEYNOMS18 & ~KEYNOOPENCL &
~KEYNOZOS // KEYNOMS18, KEYNOOPENCL, KEYNOZOS are excluded.
@@ -216,6 +217,8 @@ static KeywordStatus getKeywordStatusHelper(const LangOptions &LangOpts,
return KS_Unknown;
case KEYFIXEDPOINT:
return LangOpts.FixedPoint ? KS_Enabled : KS_Disabled;
+ case KEYACLE:
+ return LangOpts.ACLE ? KS_Enabled : KS_Disabled;
default:
llvm_unreachable("Unknown KeywordStatus flag");
}
diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index e3037ec819add..3ffdaacde1c0d 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -203,6 +203,11 @@ void LangOptions::setLangDefaults(LangOptions &Opts, Language Lang,
Opts.setDefaultFPContractMode(LangOptions::FPM_Fast);
}
+ if (T.isARM() || T.isAArch64()) {
+ Opts.ACLE = true;
+ }
+
+
// OpenCL, C++ and C23 have bool, true, false keywords.
Opts.Bool = Opts.OpenCL || Opts.CPlusPlus || Opts.C23;
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index 405242e97e75c..01631d7ad53c6 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -505,7 +505,6 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
case BuiltinType::Id:
#define SVE_PREDICATE_TYPE(Name, MangledName, Id, SingletonId) \
case BuiltinType::Id:
-#define SVE_TYPE(Name, Id, SingletonId)
#include "clang/Basic/AArch64SVEACLETypes.def"
{
ASTContext::BuiltinVectorTypeInfo Info =
diff --git a/clang/lib/CodeGen/Targets/AArch64.cpp b/clang/lib/CodeGen/Targets/AArch64.cpp
index e2e434815d43a..789839b165d84 100644
--- a/clang/lib/CodeGen/Targets/AArch64.cpp
+++ b/clang/lib/CodeGen/Targets/AArch64.cpp
@@ -766,7 +766,6 @@ bool AArch64ABIInfo::passAsPureScalableType(
case BuiltinType::Id: \
isPredicate = true; \
break;
-#define SVE_TYPE(Name, Id, SingletonId)
#include "clang/Basic/AArch64SVEACLETypes.def"
default:
return false;
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 75b5e11f8327c..f0fa5e753896d 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -4684,6 +4684,14 @@ void Parser::ParseDeclarationSpecifiers(
goto DoneWithDeclSpec; \
break;
#include "clang/Basic/OpenCLImageTypes.def"
+
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ case tok::kw_##Name: \
+ isInvalid = DS.SetTypeSpecType(DeclSpec::TST_##Name, Loc, PrevSpec, \
+ DiagID, Policy); \
+ break;
+#include "clang/Basic/AArch64SVEACLETypes.def"
+
case tok::kw___unknown_anytype:
isInvalid = DS.SetTypeSpecType(TST_unknown_anytype, Loc,
PrevSpec, DiagID, Policy);
@@ -6283,6 +6291,9 @@ bool Parser::isDeclarationSpecifier(
case tok::kw___read_only:
case tok::kw___read_write:
case tok::kw___write_only:
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ case tok::kw_##Name:
+#include "clang/Basic/AArch64SVEACLETypes.def"
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp
index ff27ef70944a4..8cf1f60b8d4a6 100644
--- a/clang/lib/Parse/ParseTentative.cpp
+++ b/clang/lib/Parse/ParseTentative.cpp
@@ -1805,6 +1805,9 @@ Parser::isCXXDeclarationSpecifier(ImplicitTypenameContext AllowImplicitTypename,
case tok::kw__Fract:
case tok::kw__Sat:
case tok::annot_pack_indexing_type:
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ case tok::kw_##Name:
+#include "clang/Basic/AArch64SVEACLETypes.def"
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
@@ -1933,6 +1936,9 @@ bool Parser::isCXXDeclarationSpecifierAType() {
case tok::kw__Accum:
case tok::kw__Fract:
case tok::kw__Sat:
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ case tok::kw_##Name:
+#include "clang/Basic/AArch64SVEACLETypes.def"
#define GENERIC_IMAGE_TYPE(ImgType, Id) case tok::kw_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case tok::kw_##Name:
diff --git a/clang/lib/Sema/DeclSpec.cpp b/clang/lib/Sema/DeclSpec.cpp
index 95e14ca0fa3b7..43302bae4d0f2 100644
--- a/clang/lib/Sema/DeclSpec.cpp
+++ b/clang/lib/Sema/DeclSpec.cpp
@@ -374,6 +374,9 @@ bool Declarator::isDeclarationOfFunction() const {
case TST_typename_pack_indexing:
#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ case TST_##Name:
+#include "clang/Basic/AArch64SVEACLETypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name:
#include "clang/Basic/HLSLIntangibleTypes.def"
return false;
@@ -607,6 +610,10 @@ const char *DeclSpec::getSpecifierName(DeclSpec::TST T,
case DeclSpec::TST_##ImgType##_t: \
return #ImgType "_t";
#include "clang/Basic/OpenCLImageTypes.def"
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ case DeclSpec::TST_##Name: \
+ return #Name;
+#include "clang/Basic/AArch64SVEACLETypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
case DeclSpec::TST_##Name: \
return #Name;
diff --git a/clang/lib/Sema/SemaTemplateVariadic.cpp b/clang/lib/Sema/SemaTemplateVariadic.cpp
index 3c56794722dcc..7bcfce47dd35b 100644
--- a/clang/lib/Sema/SemaTemplateVariadic.cpp
+++ b/clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -1081,6 +1081,9 @@ bool Sema::containsUnexpandedParameterPacks(Declarator &D) {
case TST_BFloat16:
#define GENERIC_IMAGE_TYPE(ImgType, Id) case TST_##ImgType##_t:
#include "clang/Basic/OpenCLImageTypes.def"
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ case TST_##Name:
+#include "clang/Basic/AArch64SVEACLETypes.def"
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case TST_##Name:
#include "clang/Basic/HLSLIntangibleTypes.def"
case TST_unknown_anytype:
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 1fa5239a597c8..2bf4f76c714cb 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -1366,6 +1366,12 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) {
break;
#include "clang/Basic/OpenCLImageTypes.def"
+#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \
+ case DeclSpec::TST_##Name: \
+ Result = Context.getVectorType(Context.BaseType, ElBits, VectorKind); \
+ break;
+#include "clang/Basic/AArch64SVEACLETypes.def"
+
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) \
case DeclSpec::TST_##Name: \
Result = Context.SingletonId; \
diff --git a/clang/test/AST/ast-dump-aarch64-neon-types.c b/clang/test/AST/ast-dump-aarch64-neon-types.c
new file mode 100644
index 0000000000000..5c0175096c450
--- /dev/null
+++ b/clang/test/AST/ast-dump-aarch64-neon-types.c
@@ -0,0 +1,128 @@
+// Test that NEON types are defined, even when arm_neon.h is not included.
+// as required by AAPCS64 "Support for Advanced SIMD Extensions".
+
+// RUN: %clang_cc1 -ast-dump -triple arm-linux-gnu -D A32 %s -x c | FileCheck --check-prefixes=CHECK %s
+// RUN: %clang_cc1 -ast-dump -triple arm-linux-gnu -D A32 %s -x c++ | FileCheck --check-prefixes=CHECK %s
+// RUN: %clang_cc1 -ast-dump -triple aarch64-linux-gnu %s -x c | FileCheck --check-prefixes=CHECK,A64 %s
+// RUN: %clang_cc1 -ast-dump -triple aarch64-linux-gnu %s -x c++ | FileCheck --check-prefixes=CHECK,A64 %s
+// RUN: %clang_cc1 -verify -verify-ignore-unexpected=note -triple x86_64 %s -x c
+// RUN: %clang_cc1 -verify -verify-ignore-unexpected=note -triple x86_64 %s -x c++
+
+__Int8x8_t Int8x8;
+// CHECK: Int8x8 '__attribute__((neon_vector_type(8))) char'
+// expected-error@-2{{unknown type name '__Int8x8_t'}}
+
+__Int16x4_t Int16x4;
+// CHECK: Int16x4 '__attribute__((neon_vector_type(16))) short'
+// expected-error@-2{{unknown type name '__Int16x4_t'}}
+
+__Int32x2_t Int32x2;
+// CHECK: Int32x2 '__attribute__((neon_vector_type(32))) int'
+// expected-error@-2{{unknown type name '__Int32x2_t'}}
+
+__Uint8x8_t Uint8x8;
+// CHECK: Uint8x8 '__attribute__((neon_vector_type(8))) char'
+// expected-error@-2{{unknown type name '__Uint8x8_t'}}
+
+__Uint16x4_t Uint16x4;
+// CHECK: Uint16x4 '__attribute__((neon_vector_type(16))) unsigned short'
+// expected-error@-2{{unknown type name '__Uint16x4_t'}}
+
+__Uint32x2_t Uint32x2;
+// CHECK: Uint32x2 '__attribute__((neon_vector_type(32))) unsigned int'
+// expected-error@-2{{unknown type name '__Uint32x2_t'}}
+
+__Float16x4_t Float16x4;
+// CHECK: Float16x4 '__attribute__((neon_vector_type(16))) _Float16'
+// expected-error@-2{{unknown type name '__Float16x4_t'}}
+
+__Float32x2_t Float32x2;
+// CHECK: Float32x2 '__attribute__((neon_vector_type(32))) float'
+// expected-error@-2{{unknown type name '__Float32x2_t'}}
+
+__Poly8x8_t Poly8x8;
+// CHECK: Poly8x8 '__attribute__((neon_polyvector_type(8))) char'
+// expected-error@-2{{unknown type name '__Poly8x8_t'}}
+
+__Poly16x4_t Poly16x4;
+// CHECK: Poly16x4 '__attribute__((neon_polyvector_type(16))) unsigned short'
+// expected-error@-2{{unknown type name '__Poly16x4_t'}}
+
+__Bfloat16x4_t Bfloat16x4;
+// CHECK: Bfloat16x4 '__attribute__((neon_vector_type(16))) __bf16'
+// expected-error@-2{{unknown type name '__Bfloat16x4_t'}}
+
+__Int8x16_t Int8x16;
+// CHECK: Int8x16 '__attribute__((neon_vector_type(18))) char'
+// expected-error@-2{{unknown type name '__Int8x16_t'}}
+
+__Int16x8_t Int16x8;
+// CHECK: Int16x8 '__attribute__((neon_vector_type(16))) short'
+// expected-error@-2{{unknown type name '__Int16x8_t'}}
+
+__Int32x4_t Int32x4;
+// CHECK: Int32x4 '__attribute__((neon_vector_type(32))) int'
+// expected-error@-2{{unknown type name '__Int32x4_t'}}
+
+__Int64x2_t Int64x2;
+// CHECK: Int64x2 '__attribute__((neon_vector_type(64))) long long'
+// expected-error@-2{{unknown type name '__Int64x2_t'}}
+
+__Uint8x16_t Uint8x16;
+// CHECK: Uint8x16 '__attribute__((neon_vector_type(18))) char'
+// expected-error@-2{{unknown type name '__Uint8x16_t'}}
+
+__Uint16x8_t Uint16x8;
+// CHECK: Uint16x8 '__attribute__((neon_vector_type(16))) unsigned short'
+// expected-error@-2{{unknown type name '__Uint16x8_t'}}
+
+__Uint32x4_t Uint32x4;
+// CHECK: Uint32x4 '__attribute__((neon_vector_type(32))) unsigned int'
+// expected-error@-2{{unknown type name '__Uint32x4_t'}}
+
+__Uint64x2_t Uint64x2;
+// CHECK: Uint64x2 '__attribute__((neon_vector_type(64))) unsigned long long'
+// expected-error@-2{{unknown type name '__Uint64x2_t'}}
+
+__Float16x8_t Float16x8;
+// CHECK: Float16x8 '__attribute__((neon_vector_type(16))) _Float16'
+// expected-erro...
[truncated]
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
That's pretty much how I imagined it too, so I'm happy, but let's see what others think. |
I believe this fixes #113297, right? |
Yes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi - I tried this with the latest https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/config/cpu/aarch64/opt/ext/opt_random.h and it seemed to need some fixes and then it might have failed to mangle the types if they were used? I can provide a reproducer if that would be helpful, it looked like it nearly worked, it worked until I added the rng() call.
(It is essentially a file like this, on aarch64, on a machine with ext/opt_random.h from the link above, compiled with clang++ -S -o - random.cpp -I. -O3
)
#include <random>
#include <ext/random>
int main(int argc, char** argv) {
__gnu_cxx::sfmt19937 rng;
return rng();
}
NEON_VECTOR_TYPE(__Poly8x8_t, CharTy, 8, 8, VectorKind::NeonPoly) | ||
NEON_VECTOR_TYPE(__Poly16x4_t, UnsignedShortTy, 16, 4, VectorKind::NeonPoly) | ||
NEON_VECTOR_TYPE(__Bfloat16x4_t, BFloat16Ty, 16, 4, VectorKind::Neon) | ||
NEON_VECTOR_TYPE(__Int8x16_t, CharTy, 18, 6, VectorKind::Neon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
18, 6 -> 8, 16
NEON_VECTOR_TYPE(__Int16x8_t, ShortTy, 16, 8, VectorKind::Neon) | ||
NEON_VECTOR_TYPE(__Int32x4_t, IntTy, 32, 4, VectorKind::Neon) | ||
NEON_VECTOR_TYPE(__Int64x2_t, LongLongTy, 64, 2, VectorKind::Neon) | ||
NEON_VECTOR_TYPE(__Uint8x16_t, CharTy, 18, 6, VectorKind::Neon) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
NEON_VECTOR_TYPE(__Float16x8_t, Float16Ty, 16, 8, VectorKind::Neon) | ||
NEON_VECTOR_TYPE(__Float32x4_t, FloatTy, 32, 4, VectorKind::Neon) | ||
NEON_VECTOR_TYPE(__Float64x2_t, DoubleTy, 64, 2, VectorKind::Neon) | ||
NEON_VECTOR_TYPE(__Poly8x16_t, CharTy, 18, 6, VectorKind::NeonPoly) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
clang/lib/Sema/SemaType.cpp
Outdated
@@ -1366,6 +1366,13 @@ static QualType ConvertDeclSpecToType(TypeProcessingState &state) { | |||
break; | |||
#include "clang/Basic/OpenCLImageTypes.def" | |||
|
|||
#define NEON_VECTOR_TYPE(Name, BaseType, ElBits, NumEls, VectorKind) \ | |||
case DeclSpec::TST_##Name: \ | |||
Result = Context.getVectorType(Context.BaseType, ElBits, VectorKind); \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ElBits -> NumEls
I was discussing with @tmatheson-arm and he said I could take this over. I've updated this branch (apparently that does work), trying to address the issues and clean things up a bit. The new types are not longer a keyword, but that seems to be OK providing we mark them as implicit typedefs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with one nitpick. I've run this through a fuzzer which tests ABI compatibility with GCC and didn't find any problems.
The AAPCS64 adds a number of vector types to the C unconditionally: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#11appendix-support-for-advanced-simd-extensions The equivalent SVE types are already available in clang: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#12appendix-support-for-scalable-vectors __mfp8 is defined in the ACLE https://arm-software.github.io/acle/main/acle.html#data-types I'm not sure whether __mfp8 should be defined for A32. For now I have left it as it is.
Thanks for the review and the extra testing! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/6505 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/144/builds/26632 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/133/builds/17137 Here is the relevant piece of the build log for the reference
|
Update the new test added in #126945
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/24246 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/46/builds/17772 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/3/builds/16870 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/27/builds/10942 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/13/builds/7503 Here is the relevant piece of the build log for the reference
|
The AAPCS64 adds a number of vector types to the C unconditionally: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#11appendix-support-for-advanced-simd-extensions The equivalent SVE types are already available in clang: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#12appendix-support-for-scalable-vectors __mfp8 is defined in the ACLE https://arm-software.github.io/acle/main/acle.html#data-types --------- Co-authored-by: David Green <[email protected]>
Update the new test added in llvm#126945
This updates the element types used in the new __Int8x8_t types added in llvm#126945, mostly to allow C++ name mangling in ItaniumMangling mangleAArch64VectorBase to work correctly. Char is replaced by SignedCharTy or UnsignedCharTy as required and Float16Ty is better using HalfTy to match the vector types. Same for Long types.
This updates the element types used in the new __Int8x8_t types added in #126945, mostly to allow C++ name mangling in ItaniumMangling mangleAArch64VectorBase to work correctly. Char is replaced by SignedCharTy or UnsignedCharTy as required and Float16Ty is better using HalfTy to match the vector types. Same for Long types.
This updates the element types used in the new __Int8x8_t types added in llvm#126945, mostly to allow C++ name mangling in ItaniumMangling mangleAArch64VectorBase to work correctly. Char is replaced by SignedCharTy or UnsignedCharTy as required and Float16Ty is better using HalfTy to match the vector types. Same for Long types.
The AAPCS64 adds a number of vector types to the C unconditionally: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#11appendix-support-for-advanced-simd-extensions The equivalent SVE types are already available in clang: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#12appendix-support-for-scalable-vectors __mfp8 is defined in the ACLE https://arm-software.github.io/acle/main/acle.html#data-types --------- Co-authored-by: David Green <[email protected]>
Update the new test added in llvm#126945
The AAPCS64 adds a number of vector types to the C unconditionally: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#11appendix-support-for-advanced-simd-extensions
The equivalent SVE types are already available in clang: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#12appendix-support-for-scalable-vectors
__mfp8 is defined in the ACLE
https://arm-software.github.io/acle/main/acle.html#data-types