[clang] [ARM] Change NEON poly type to be unsigned (#56781) (PR #80691)
https://github.com/AlfieRichardsArm created https://github.com/llvm/llvm-project/pull/80691 This is to be inline with the Arm C Language Specification. (https://github.com/ARM-software/acle/releases/download/r2022Q2/acle-2022Q2.pdf) and with GCC. This fixes https://github.com/llvm/llvm-project/issues/56781 >From 0993e1c309a56c7e3813658ae4ebdd87a4573aa3 Mon Sep 17 00:00:00 2001 From: Alfie Richards Date: Mon, 5 Feb 2024 14:25:32 + Subject: [PATCH] [ARM] Change NEON poly type to be unsigned. (#56781) This is to be inline with the Arm C Language Specification. (https://github.com/ARM-software/acle/releases/download/r2022Q2/acle-2022Q2.pdf) and with GCC. This potentially has ABI implications. --- clang/lib/Sema/SemaChecking.cpp | 12 --- clang/lib/Sema/SemaType.cpp | 21 --- clang/test/CodeGenCXX/mangle-neon-vectors.cpp | 5 - clang/test/CodeGenCXX/poly-unsigned.cpp | 13 +--- clang/test/Sema/neon-vector-types.c | 4 ++-- clang/utils/TableGen/NeonEmitter.cpp | 9 ++-- 6 files changed, 17 insertions(+), 47 deletions(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index b071a02ca3713..17fdfb4d448c6 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3017,7 +3017,7 @@ static unsigned RFT(unsigned t, bool shift = false, bool ForceQuad = false) { /// the vector type specified by the NeonTypeFlags. This is used to check /// the pointer arguments for Neon load/store intrinsics. static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, - bool IsPolyUnsigned, bool IsInt64Long) { + bool IsInt64Long) { switch (Flags.getEltType()) { case NeonTypeFlags::Int8: return Flags.isUnsigned() ? Context.UnsignedCharTy : Context.SignedCharTy; @@ -3032,9 +3032,9 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, return Flags.isUnsigned() ? Context.UnsignedLongLongTy : Context.LongLongTy; case NeonTypeFlags::Poly8: -return IsPolyUnsigned ? Context.UnsignedCharTy : Context.SignedCharTy; +return Context.UnsignedCharTy; case NeonTypeFlags::Poly16: -return IsPolyUnsigned ? Context.UnsignedShortTy : Context.ShortTy; +return Context.UnsignedShortTy; case NeonTypeFlags::Poly64: if (IsInt64Long) return Context.UnsignedLongTy; @@ -3399,13 +3399,9 @@ bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI, ExprResult RHS = DefaultFunctionArrayLvalueConversion(Arg); QualType RHSTy = RHS.get()->getType(); -llvm::Triple::ArchType Arch = TI.getTriple().getArch(); -bool IsPolyUnsigned = Arch == llvm::Triple::aarch64 || - Arch == llvm::Triple::aarch64_32 || - Arch == llvm::Triple::aarch64_be; bool IsInt64Long = TI.getInt64Type() == TargetInfo::SignedLong; QualType EltTy = -getNeonEltType(NeonTypeFlags(TV), Context, IsPolyUnsigned, IsInt64Long); +getNeonEltType(NeonTypeFlags(TV), Context, IsInt64Long); if (HasConstPtr) EltTy = EltTy.withConst(); QualType LHSTy = Context.getPointerType(EltTy); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index aee2c9c4a7ded..1531a764de626 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8413,24 +8413,11 @@ static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S) { llvm::Triple Triple = S.Context.getTargetInfo().getTriple(); - // Signed poly is mathematically wrong, but has been baked into some ABIs by - // now. - bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 || -Triple.getArch() == llvm::Triple::aarch64_32 || -Triple.getArch() == llvm::Triple::aarch64_be; if (VecKind == VectorKind::NeonPoly) { -if (IsPolyUnsigned) { - // AArch64 polynomial vectors are unsigned. - return BTy->getKind() == BuiltinType::UChar || - BTy->getKind() == BuiltinType::UShort || - BTy->getKind() == BuiltinType::ULong || - BTy->getKind() == BuiltinType::ULongLong; -} else { - // AArch32 polynomial vectors are signed. - return BTy->getKind() == BuiltinType::SChar || - BTy->getKind() == BuiltinType::Short || - BTy->getKind() == BuiltinType::LongLong; -} +return BTy->getKind() == BuiltinType::UChar || + BTy->getKind() == BuiltinType::UShort || + BTy->getKind() == BuiltinType::ULong || + BTy->getKind() == BuiltinType::ULongLong; } // Non-polynomial vector types: the usual suspects are allowed, as well as diff --git a/clang/test/CodeGenCXX/mangle-neon-vectors.cpp b/clang/test/CodeGenCXX/mangle-neon-vectors.cpp index cb5e40be6a6df..e75273b373a61 100644 --- a/clang/test/CodeGen
[clang] [ARM] Change NEON poly type to be unsigned (#56781) (PR #80691)
AlfieRichardsArm wrote: This could be an ABI break. `poly8_t` will now be `uint8_t` rather than `int8_t`, which also changes the signatures of certain functions. Certainly there were some comments in the effected code as to why this was not done initially referring to ABI. @mmalcomson I was sent your name as someone who might be able to provide some wisdom. https://github.com/llvm/llvm-project/pull/80691 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [ARM] Change NEON poly type to be unsigned (#56781) (PR #80691)
https://github.com/AlfieRichardsArm updated https://github.com/llvm/llvm-project/pull/80691 >From 1897afe4d3568fbe007ab53fae1722ebe831b09e Mon Sep 17 00:00:00 2001 From: Alfie Richards Date: Mon, 5 Feb 2024 14:25:32 + Subject: [PATCH] [ARM] Change NEON poly type to be unsigned. (#56781) This is to be inline with the Arm C Language Specification. (https://github.com/ARM-software/acle/releases/download/r2022Q2/acle-2022Q2.pdf) and with GCC. This potentially has ABI implications. --- clang/lib/Sema/SemaChecking.cpp | 13 clang/lib/Sema/SemaType.cpp | 21 --- clang/test/CodeGenCXX/mangle-neon-vectors.cpp | 5 - clang/test/CodeGenCXX/poly-unsigned.cpp | 13 +--- clang/test/Sema/neon-vector-types.c | 4 ++-- clang/utils/TableGen/NeonEmitter.cpp | 9 ++-- 6 files changed, 17 insertions(+), 48 deletions(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index b071a02ca3713f..9e9c4f1aed1729 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3017,7 +3017,7 @@ static unsigned RFT(unsigned t, bool shift = false, bool ForceQuad = false) { /// the vector type specified by the NeonTypeFlags. This is used to check /// the pointer arguments for Neon load/store intrinsics. static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, - bool IsPolyUnsigned, bool IsInt64Long) { + bool IsInt64Long) { switch (Flags.getEltType()) { case NeonTypeFlags::Int8: return Flags.isUnsigned() ? Context.UnsignedCharTy : Context.SignedCharTy; @@ -3032,9 +3032,9 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, return Flags.isUnsigned() ? Context.UnsignedLongLongTy : Context.LongLongTy; case NeonTypeFlags::Poly8: -return IsPolyUnsigned ? Context.UnsignedCharTy : Context.SignedCharTy; +return Context.UnsignedCharTy; case NeonTypeFlags::Poly16: -return IsPolyUnsigned ? Context.UnsignedShortTy : Context.ShortTy; +return Context.UnsignedShortTy; case NeonTypeFlags::Poly64: if (IsInt64Long) return Context.UnsignedLongTy; @@ -3399,13 +3399,8 @@ bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI, ExprResult RHS = DefaultFunctionArrayLvalueConversion(Arg); QualType RHSTy = RHS.get()->getType(); -llvm::Triple::ArchType Arch = TI.getTriple().getArch(); -bool IsPolyUnsigned = Arch == llvm::Triple::aarch64 || - Arch == llvm::Triple::aarch64_32 || - Arch == llvm::Triple::aarch64_be; bool IsInt64Long = TI.getInt64Type() == TargetInfo::SignedLong; -QualType EltTy = -getNeonEltType(NeonTypeFlags(TV), Context, IsPolyUnsigned, IsInt64Long); +QualType EltTy = getNeonEltType(NeonTypeFlags(TV), Context, IsInt64Long); if (HasConstPtr) EltTy = EltTy.withConst(); QualType LHSTy = Context.getPointerType(EltTy); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index aee2c9c4a7deda..1531a764de626e 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8413,24 +8413,11 @@ static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S) { llvm::Triple Triple = S.Context.getTargetInfo().getTriple(); - // Signed poly is mathematically wrong, but has been baked into some ABIs by - // now. - bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 || -Triple.getArch() == llvm::Triple::aarch64_32 || -Triple.getArch() == llvm::Triple::aarch64_be; if (VecKind == VectorKind::NeonPoly) { -if (IsPolyUnsigned) { - // AArch64 polynomial vectors are unsigned. - return BTy->getKind() == BuiltinType::UChar || - BTy->getKind() == BuiltinType::UShort || - BTy->getKind() == BuiltinType::ULong || - BTy->getKind() == BuiltinType::ULongLong; -} else { - // AArch32 polynomial vectors are signed. - return BTy->getKind() == BuiltinType::SChar || - BTy->getKind() == BuiltinType::Short || - BTy->getKind() == BuiltinType::LongLong; -} +return BTy->getKind() == BuiltinType::UChar || + BTy->getKind() == BuiltinType::UShort || + BTy->getKind() == BuiltinType::ULong || + BTy->getKind() == BuiltinType::ULongLong; } // Non-polynomial vector types: the usual suspects are allowed, as well as diff --git a/clang/test/CodeGenCXX/mangle-neon-vectors.cpp b/clang/test/CodeGenCXX/mangle-neon-vectors.cpp index cb5e40be6a6df2..e75273b373a615 100644 --- a/clang/test/CodeGenCXX/mangle-neon-vectors.cpp +++ b/clang/test/CodeGenCXX/mangle-neon-vectors.cpp @@ -6,13 +6,8 @@ typedef float float32_t; typedef double float64_t; typedef __fp16 float16_t; -#if defined(__aarch64_
[clang] [ARM] Change NEON poly type to be unsigned (#56781) (PR #80691)
https://github.com/AlfieRichardsArm updated https://github.com/llvm/llvm-project/pull/80691 >From 1d956381662f4e20c8fff2655c60862711b6e69d Mon Sep 17 00:00:00 2001 From: Alfie Richards Date: Mon, 5 Feb 2024 14:25:32 + Subject: [PATCH] [ARM] Change NEON poly type to be unsigned. (#56781) This is to be inline with the Arm C Language Specification. (https://github.com/ARM-software/acle/releases/download/r2022Q2/acle-2022Q2.pdf) and with GCC. This potentially has ABI implications. --- clang/lib/Sema/SemaChecking.cpp | 13 clang/lib/Sema/SemaType.cpp | 21 --- clang/test/CodeGenCXX/mangle-neon-vectors.cpp | 5 - clang/test/CodeGenCXX/poly-unsigned.cpp | 18 +--- clang/test/Sema/neon-vector-types.c | 4 ++-- clang/utils/TableGen/NeonEmitter.cpp | 9 ++-- 6 files changed, 17 insertions(+), 53 deletions(-) diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index b071a02ca3713..9e9c4f1aed172 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -3017,7 +3017,7 @@ static unsigned RFT(unsigned t, bool shift = false, bool ForceQuad = false) { /// the vector type specified by the NeonTypeFlags. This is used to check /// the pointer arguments for Neon load/store intrinsics. static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, - bool IsPolyUnsigned, bool IsInt64Long) { + bool IsInt64Long) { switch (Flags.getEltType()) { case NeonTypeFlags::Int8: return Flags.isUnsigned() ? Context.UnsignedCharTy : Context.SignedCharTy; @@ -3032,9 +3032,9 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context, return Flags.isUnsigned() ? Context.UnsignedLongLongTy : Context.LongLongTy; case NeonTypeFlags::Poly8: -return IsPolyUnsigned ? Context.UnsignedCharTy : Context.SignedCharTy; +return Context.UnsignedCharTy; case NeonTypeFlags::Poly16: -return IsPolyUnsigned ? Context.UnsignedShortTy : Context.ShortTy; +return Context.UnsignedShortTy; case NeonTypeFlags::Poly64: if (IsInt64Long) return Context.UnsignedLongTy; @@ -3399,13 +3399,8 @@ bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI, ExprResult RHS = DefaultFunctionArrayLvalueConversion(Arg); QualType RHSTy = RHS.get()->getType(); -llvm::Triple::ArchType Arch = TI.getTriple().getArch(); -bool IsPolyUnsigned = Arch == llvm::Triple::aarch64 || - Arch == llvm::Triple::aarch64_32 || - Arch == llvm::Triple::aarch64_be; bool IsInt64Long = TI.getInt64Type() == TargetInfo::SignedLong; -QualType EltTy = -getNeonEltType(NeonTypeFlags(TV), Context, IsPolyUnsigned, IsInt64Long); +QualType EltTy = getNeonEltType(NeonTypeFlags(TV), Context, IsInt64Long); if (HasConstPtr) EltTy = EltTy.withConst(); QualType LHSTy = Context.getPointerType(EltTy); diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp index aee2c9c4a7ded..1531a764de626 100644 --- a/clang/lib/Sema/SemaType.cpp +++ b/clang/lib/Sema/SemaType.cpp @@ -8413,24 +8413,11 @@ static bool isPermittedNeonBaseType(QualType &Ty, VectorKind VecKind, Sema &S) { llvm::Triple Triple = S.Context.getTargetInfo().getTriple(); - // Signed poly is mathematically wrong, but has been baked into some ABIs by - // now. - bool IsPolyUnsigned = Triple.getArch() == llvm::Triple::aarch64 || -Triple.getArch() == llvm::Triple::aarch64_32 || -Triple.getArch() == llvm::Triple::aarch64_be; if (VecKind == VectorKind::NeonPoly) { -if (IsPolyUnsigned) { - // AArch64 polynomial vectors are unsigned. - return BTy->getKind() == BuiltinType::UChar || - BTy->getKind() == BuiltinType::UShort || - BTy->getKind() == BuiltinType::ULong || - BTy->getKind() == BuiltinType::ULongLong; -} else { - // AArch32 polynomial vectors are signed. - return BTy->getKind() == BuiltinType::SChar || - BTy->getKind() == BuiltinType::Short || - BTy->getKind() == BuiltinType::LongLong; -} +return BTy->getKind() == BuiltinType::UChar || + BTy->getKind() == BuiltinType::UShort || + BTy->getKind() == BuiltinType::ULong || + BTy->getKind() == BuiltinType::ULongLong; } // Non-polynomial vector types: the usual suspects are allowed, as well as diff --git a/clang/test/CodeGenCXX/mangle-neon-vectors.cpp b/clang/test/CodeGenCXX/mangle-neon-vectors.cpp index cb5e40be6a6df..e75273b373a61 100644 --- a/clang/test/CodeGenCXX/mangle-neon-vectors.cpp +++ b/clang/test/CodeGenCXX/mangle-neon-vectors.cpp @@ -6,13 +6,8 @@ typedef float float32_t; typedef double float64_t; typedef __fp16 float16_t; -#if defined(__aarch64__)