[PATCH] [ARM] Fix AArch32 and pre-v8 poly types to be unsigned

Bradley Smith bradley.smith at arm.com
Wed Oct 2 08:09:22 PDT 2013


All poly types should be of unsigned type, this is true for all ARM ISAs, AArch64 currently has this behavior however AArch32 and pre-v8 do not.

Also update test/CodeGenCXX/mangle-neon-vectors.cpp to test as thoroughly as the AArch64 version.

http://llvm-reviews.chandlerc.com/D1810

Files:
  lib/AST/ItaniumMangle.cpp
  lib/Sema/SemaType.cpp
  test/CodeGenCXX/mangle-neon-vectors.cpp
  test/Sema/neon-vector-types.c
  utils/TableGen/NeonEmitter.cpp

Index: lib/AST/ItaniumMangle.cpp
===================================================================
--- lib/AST/ItaniumMangle.cpp
+++ lib/AST/ItaniumMangle.cpp
@@ -2188,8 +2188,8 @@
   const char *EltName = 0;
   if (T->getVectorKind() == VectorType::NeonPolyVector) {
     switch (cast<BuiltinType>(EltType)->getKind()) {
-    case BuiltinType::SChar:     EltName = "poly8_t"; break;
-    case BuiltinType::Short:     EltName = "poly16_t"; break;
+    case BuiltinType::UChar:     EltName = "poly8_t"; break;
+    case BuiltinType::UShort:    EltName = "poly16_t"; break;
     default: llvm_unreachable("unexpected Neon polynomial vector element type");
     }
   } else {
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4754,15 +4754,8 @@
     return false;
 
   if (VecKind == VectorType::NeonPolyVector) {
-    if (IsAArch64) {
-      // AArch64 polynomial vectors are unsigned
-      return BTy->getKind() == BuiltinType::UChar ||
-             BTy->getKind() == BuiltinType::UShort;
-    } else {
-      // AArch32 polynomial vector are signed.
-      return BTy->getKind() == BuiltinType::SChar ||
-             BTy->getKind() == BuiltinType::Short;
-    }
+    return BTy->getKind() == BuiltinType::UChar ||
+           BTy->getKind() == BuiltinType::UShort;
   }
 
   // Non-polynomial vector types: the usual suspects are allowed, as well as
Index: test/CodeGenCXX/mangle-neon-vectors.cpp
===================================================================
--- test/CodeGenCXX/mangle-neon-vectors.cpp
+++ test/CodeGenCXX/mangle-neon-vectors.cpp
@@ -2,38 +2,80 @@
 
 typedef float float32_t;
 typedef __fp16 float16_t;
-typedef signed char poly8_t;
-typedef short poly16_t;
+typedef unsigned char poly8_t;
+typedef unsigned short poly16_t;
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef signed char int8_t;
+typedef signed short int16_t;
+typedef signed long long int64_t;
 typedef unsigned long long uint64_t;
 
+typedef __attribute__((neon_vector_type(8))) int8_t int8x8_t;
+typedef __attribute__((neon_vector_type(16))) int8_t int8x16_t;
+typedef __attribute__((neon_vector_type(4))) int16_t int16x4_t;
+typedef __attribute__((neon_vector_type(8))) int16_t int16x8_t;
 typedef __attribute__((neon_vector_type(2))) int int32x2_t;
 typedef __attribute__((neon_vector_type(4))) int int32x4_t;
 typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
+typedef __attribute__((neon_vector_type(2))) int64_t int64x2_t;
+typedef __attribute__((neon_vector_type(8))) uint8_t uint8x8_t;
+typedef __attribute__((neon_vector_type(16))) uint8_t uint8x16_t;
+typedef __attribute__((neon_vector_type(4))) uint16_t uint16x4_t;
+typedef __attribute__((neon_vector_type(8))) uint16_t uint16x8_t;
+typedef __attribute__((neon_vector_type(2))) unsigned int uint32x2_t;
+typedef __attribute__((neon_vector_type(4))) unsigned int uint32x4_t;
 typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t;
 typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t;
 typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
 typedef __attribute__((neon_vector_type(4))) float16_t float16x4_t;
 typedef __attribute__((neon_vector_type(8))) float16_t float16x8_t;
+typedef __attribute__((neon_polyvector_type(8))) poly8_t poly8x8_t;
 typedef __attribute__((neon_polyvector_type(16))) poly8_t poly8x16_t;
+typedef __attribute__((neon_polyvector_type(4))) poly16_t poly16x4_t;
 typedef __attribute__((neon_polyvector_type(8))) poly16_t poly16x8_t;
 
+// CHECK: 15__simd64_int8_t
+void f1(int8x8_t) {}
+// CHECK: 16__simd64_int16_t
+void f2(int16x4_t) {}
 // CHECK: 16__simd64_int32_t
-void f1(int32x2_t v) { }
-// CHECK: 17__simd128_int32_t
-void f2(int32x4_t v) { }
-// CHECK: 17__simd64_uint64_t
-void f3(uint64x1_t v) { }
-// CHECK: 18__simd128_uint64_t
-void f4(uint64x2_t v) { }
-// CHECK: 18__simd64_float32_t
-void f5(float32x2_t v) { }
-// CHECK: 19__simd128_float32_t
-void f6(float32x4_t v) { }
+void f3(int32x2_t) {}
+// CHECK: 16__simd64_uint8_t
+void f4(uint8x8_t) {}
+// CHECK: 17__simd64_uint16_t
+void f5(uint16x4_t) {}
 // CHECK: 18__simd64_float16_t
-void f7(float16x4_t v) {}
+void f6(float16x4_t) {}
 // CHECK: 19__simd128_float16_t
-void f8(float16x8_t v) {}
+void f7(float16x8_t) {}
+// CHECK: 17__simd64_uint32_t
+void f8(uint32x2_t) {}
+// CHECK: 18__simd64_float32_t
+void f9(float32x2_t) {}
+// CHECK: 19__simd128_float32_t
+void f10(float32x4_t) {}
+// CHECK: 16__simd64_poly8_t
+void f11(poly8x8_t) {}
+// CHECK: 17__simd64_poly16_t
+void f12(poly16x4_t) {}
 // CHECK: 17__simd128_poly8_t
-void f9(poly8x16_t v) {}
+void f13(poly8x16_t) {}
 // CHECK: 18__simd128_poly16_t
-void f10(poly16x8_t v) {}
+void f14(poly16x8_t) {}
+// CHECK: 16__simd128_int8_t
+void f15(int8x16_t) {}
+// CHECK: 17__simd128_int16_t
+void f16(int16x8_t) {}
+// CHECK: 17__simd128_int32_t
+void f17(int32x4_t) {}
+// CHECK: 17__simd128_uint8_t
+void f18(uint8x16_t) {}
+// CHECK: 18__simd128_uint16_t
+void f19(uint16x8_t) {}
+// CHECK: 18__simd128_uint32_t
+void f20(uint32x4_t) {}
+// CHECK: 17__simd128_int64_t
+void f21(int64x2_t) {}
+// CHECK: 18__simd128_uint64_t
+void f22(uint64x2_t) {}
Index: test/Sema/neon-vector-types.c
===================================================================
--- test/Sema/neon-vector-types.c
+++ test/Sema/neon-vector-types.c
@@ -2,8 +2,8 @@
 // RUN: %clang_cc1 %s -triple armv8 -target-feature +neon -fsyntax-only -verify
 
 typedef float float32_t;
-typedef signed char poly8_t;
-typedef short poly16_t;
+typedef unsigned char poly8_t;
+typedef unsigned short poly16_t;
 typedef unsigned long long uint64_t;
 
 // Define some valid Neon types.
Index: utils/TableGen/NeonEmitter.cpp
===================================================================
--- utils/TableGen/NeonEmitter.cpp
+++ utils/TableGen/NeonEmitter.cpp
@@ -2061,14 +2061,8 @@
   OS << "typedef double float64_t;\n";
   OS << "#endif\n\n";
 
-  // For now, signedness of polynomial types depends on target
-  OS << "#ifdef __aarch64__\n";
   OS << "typedef uint8_t poly8_t;\n";
   OS << "typedef uint16_t poly16_t;\n";
-  OS << "#else\n";
-  OS << "typedef int8_t poly8_t;\n";
-  OS << "typedef int16_t poly16_t;\n";
-  OS << "#endif\n";
 
   // Emit Neon vector typedefs.
   std::string TypedefTypes(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1810.1.patch
Type: text/x-patch
Size: 6368 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131002/648cafca/attachment.bin>


More information about the cfe-commits mailing list