[clang] 1e44731 - [ARM] Add poly64_t on AArch32.

Ties Stuij via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 5 05:04:37 PDT 2020


Author: Ties Stuij
Date: 2020-06-05T13:04:21+01:00
New Revision: 1e447318339a6e740819ec1568002f4751527efe

URL: https://github.com/llvm/llvm-project/commit/1e447318339a6e740819ec1568002f4751527efe
DIFF: https://github.com/llvm/llvm-project/commit/1e447318339a6e740819ec1568002f4751527efe.diff

LOG: [ARM] Add poly64_t on AArch32.

Summary:
The poly64 types are guarded with ifdefs for AArch64 only. This is wrong. This
was also incorrectly documented in the ACLE spec, but this has been rectified in
the latest release. See paragraph 13.1.2 "Vector data types":

https://developer.arm.com/docs/101028/latest

This patch was written by Alexandros Lamprineas.

Reviewers: ostannard, sdesmalen, fpetrogalli, labrinea, t.p.northover, LukeGeeson

Reviewed By: ostannard

Subscribers: pbarrio, LukeGeeson, kristof.beyls, danielkiss, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D79711

Added: 
    clang/test/CodeGen/arm-poly64.c

Modified: 
    clang/include/clang/Basic/TargetBuiltins.h
    clang/lib/AST/ItaniumMangle.cpp
    clang/lib/Sema/SemaType.cpp
    clang/utils/TableGen/NeonEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h
index b20a544b7889..5fa5f9f0bcef 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -157,7 +157,7 @@ namespace clang {
     EltType getEltType() const { return (EltType)(Flags & EltTypeMask); }
     bool isPoly() const {
       EltType ET = getEltType();
-      return ET == Poly8 || ET == Poly16;
+      return ET == Poly8 || ET == Poly16 || ET == Poly64;
     }
     bool isUnsigned() const { return (Flags & UnsignedFlag) != 0; }
     bool isQuad() const { return (Flags & QuadFlag) != 0; }

diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index aae33c5962e0..46815e5a107e 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3167,6 +3167,7 @@ void CXXNameMangler::mangleNeonVectorType(const VectorType *T) {
     case BuiltinType::UShort:
       EltName = "poly16_t";
       break;
+    case BuiltinType::LongLong:
     case BuiltinType::ULongLong:
       EltName = "poly64_t";
       break;

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 93bb2e15c4da..46fa8bc0608b 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7650,15 +7650,16 @@ static bool isPermittedNeonBaseType(QualType &Ty,
                         Triple.getArch() == llvm::Triple::aarch64_be;
   if (VecKind == VectorType::NeonPolyVector) {
     if (IsPolyUnsigned) {
-      // AArch64 polynomial vectors are unsigned and support poly64.
+      // 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 vector are signed.
+      // AArch32 polynomial vectors are signed.
       return BTy->getKind() == BuiltinType::SChar ||
-             BTy->getKind() == BuiltinType::Short;
+             BTy->getKind() == BuiltinType::Short ||
+             BTy->getKind() == BuiltinType::LongLong;
     }
   }
 

diff  --git a/clang/test/CodeGen/arm-poly64.c b/clang/test/CodeGen/arm-poly64.c
new file mode 100644
index 000000000000..52c757f0acbb
--- /dev/null
+++ b/clang/test/CodeGen/arm-poly64.c
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple armv8.2a-arm-none-eabi -target-feature +neon \
+// RUN:  -emit-llvm -o - %s | FileCheck %s
+
+// Test that we can use the poly64 type on AArch32
+
+#include <arm_neon.h>
+
+// CHECK-LABEL: @test_poly64
+// CHECK: ret i64 %0
+poly64_t test_poly64(poly64_t a) {
+  return a;
+}

diff  --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index 625954fe8a04..e93c4c653edf 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -2233,6 +2233,7 @@ void NeonEmitter::run(raw_ostream &OS) {
   OS << "#else\n";
   OS << "typedef int8_t poly8_t;\n";
   OS << "typedef int16_t poly16_t;\n";
+  OS << "typedef int64_t poly64_t;\n";
   OS << "#endif\n";
 
   // Emit Neon vector typedefs.
@@ -2245,7 +2246,7 @@ void NeonEmitter::run(raw_ostream &OS) {
   for (auto &TS : TDTypeVec) {
     bool IsA64 = false;
     Type T(TS, ".");
-    if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+    if (T.isDouble())
       IsA64 = true;
 
     if (InIfdef && !IsA64) {
@@ -2278,7 +2279,7 @@ void NeonEmitter::run(raw_ostream &OS) {
     for (auto &TS : TDTypeVec) {
       bool IsA64 = false;
       Type T(TS, ".");
-      if (T.isDouble() || (T.isPoly() && T.getElementSizeInBits() == 64))
+      if (T.isDouble())
         IsA64 = true;
 
       if (InIfdef && !IsA64) {


        


More information about the cfe-commits mailing list