]> granicus.if.org Git - clang/commitdiff
Add error checking to reject neon_vector_type attribute on targets without NEON.
authorAmara Emerson <amara.emerson@arm.com>
Mon, 16 Sep 2013 18:07:35 +0000 (18:07 +0000)
committerAmara Emerson <amara.emerson@arm.com>
Mon, 16 Sep 2013 18:07:35 +0000 (18:07 +0000)
Patch by Artyom Skrobov.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190801 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
include/clang/Basic/DiagnosticSemaKinds.td
lib/Basic/Targets.cpp
lib/Sema/SemaType.cpp
test/Analysis/misc-ps-arm.m
test/CodeGen/arm-arguments.c
test/CodeGen/arm-asm-diag.c
test/CodeGen/arm-asm-warn.c
test/CodeGen/struct-init.c
test/CodeGen/struct-matching-constraint.c
test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp
test/CodeGenCXX/mangle-neon-vectors.cpp
test/Sema/aarch64-neon-vector-types.c
test/Sema/neon-vector-types-support.c [new file with mode: 0644]
test/Sema/neon-vector-types.c
test/SemaCXX/neon-vector-types.cpp

index 2932fe19d69737a2935f7faa2d64a0d280558f9d..fd82f161e6b21e3e6ad8e42b95548eddfaca7779 100644 (file)
@@ -1785,6 +1785,8 @@ def err_attribute_too_few_arguments : Error<
 def err_attribute_invalid_vector_type : Error<"invalid vector element type %0">;
 def err_attribute_bad_neon_vector_size : Error<
   "Neon vector size must be 64 or 128 bits">;
+def err_attribute_unsupported : Error<
+  "%0 attribute is not supported for this target">;
 def err_aligned_attribute_argument_not_int : Error<
   "'aligned' attribute requires integer constant">;
 def err_alignas_attribute_wrong_decl_type : Error<
index b31ec78c7ea25d0bd106cfb1050baf78a60e0b0c..dc31ace06ca1196c3c9313c3f4b8cd079d093e9b 100644 (file)
@@ -3711,9 +3711,7 @@ public:
         .Case("arm", true)
         .Case("softfloat", SoftFloat)
         .Case("thumb", IsThumb)
-        .Case("neon", (FPU & NeonFPU) && !SoftFloat &&
-              (StringRef(getCPUDefineSuffix(CPU)).startswith("7") ||
-               StringRef(getCPUDefineSuffix(CPU)).startswith("8")))
+        .Case("neon", (FPU & NeonFPU) && !SoftFloat)
         .Default(false);
   }
   // FIXME: Should we actually have some table instead of these switches?
index 0154a129af845af3dd9d0b7f8543ea98ac67ce9f..bce612a2a7989b605419d24ba035948c37a3f8dc 100644 (file)
@@ -4735,6 +4735,12 @@ static bool isPermittedNeonBaseType(QualType &Ty,
 static void HandleNeonVectorTypeAttr(QualType& CurType,
                                      const AttributeList &Attr, Sema &S,
                                      VectorType::VectorKind VecKind) {
+  // Target must have NEON
+  if (!S.Context.getTargetInfo().hasFeature("neon")) {
+    S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr.getName();
+    Attr.setInvalid();
+    return;
+  }
   // Check the attribute arguments.
   if (Attr.getNumArgs() != 1) {
     S.Diag(Attr.getLoc(), diag::err_attribute_wrong_number_arguments)
index 1ff0f17cea5f9ef97a6fc5bb48ab4657be38e6af..a9ea3274ae4bdc31bab60f7bcd9fa7653b725a0c 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple thumbv7-apple-ios0.0.0 -analyze -analyzer-checker=core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
+// RUN: %clang_cc1 -triple thumbv7-apple-ios0.0.0 -target-feature +neon -analyze -analyzer-checker=core -analyzer-store=region -verify -fblocks -analyzer-opt-analyze-nested-blocks -Wno-objc-root-class %s
 // expected-no-diagnostics
 
 // <rdar://problem/11405978> - Handle casts of vectors to structs, and loading
index d02a217de4f40e701418ae2400b7c14ac8a97915..b6bac9ac44af332d2b689844b7bbfc2e75954144 100644 (file)
@@ -1,6 +1,6 @@
 // REQUIRES: arm-registered-target
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=APCS-GNU %s
-// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=AAPCS %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-feature +neon -target-abi apcs-gnu -emit-llvm -w -o - %s | FileCheck -check-prefix=APCS-GNU %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin9 -target-feature +neon -target-abi aapcs -emit-llvm -w -o - %s | FileCheck -check-prefix=AAPCS %s
 
 // APCS-GNU-LABEL: define signext i8 @f0()
 // AAPCS-LABEL: define arm_aapcscc signext i8 @f0()
index 925de46c8017d3763e544a7bc7208bd66d106336..944a271e6cbad7cd742e35c31232424ed9f0acce 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: arm-registered-target
-// RUN: not %clang_cc1 -triple armv7 %s -S -o /dev/null 2>&1 | FileCheck %s
+// RUN: not %clang_cc1 -triple armv7 -target-feature +neon %s -S -o /dev/null 2>&1 | FileCheck %s
 
 // rdar://13446483
 typedef __attribute__((neon_vector_type(2))) long long int64x2_t;
index 6112b19d28c00e986032d92515359f21e72a8fae..a580700661e4bf05eeca149566000965b01dbe3a 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: arm-registered-target
-// RUN: %clang_cc1 -triple armv7 %s -emit-llvm -o /dev/null
+// RUN: %clang_cc1 -triple armv7 -target-feature +neon %s -emit-llvm -o /dev/null
 
 char bar();
 
index 5273138e4e5e9076c4134c1b5b9bd83f1ee0c22b..30834acec736b116af74f300e540e3194d4670ee 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: arm-registered-target
-// RUN: %clang_cc1 -S -triple armv7-apple-darwin %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -S -triple armv7-apple-darwin -target-feature +neon %s -emit-llvm -o - | FileCheck %s
 
 typedef struct _zend_ini_entry zend_ini_entry;
 struct _zend_ini_entry {
index bdd11c8b90004a5f13093355b9b0cbcef976547c..dfc3014c5d9a5757d7cea43be0012a899518d815 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: arm-registered-target
-// RUN: %clang_cc1 -S -emit-llvm -triple armv7a-apple-darwin %s -o /dev/null
+// RUN: %clang_cc1 -S -emit-llvm -triple armv7a-apple-darwin -target-feature +neon %s -o /dev/null
 typedef unsigned short uint16_t;
 typedef __attribute__((neon_vector_type(8))) uint16_t uint16x8_t;
 
index 86509a0739d46955cd90d4e95319a0ab8b713e7b..2514704f1d8860713788f85c5a8383ab23c9c1c1 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: aarch64-registered-target
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu  %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon %s -emit-llvm -o - | FileCheck %s
 
 typedef unsigned char uint8_t;
 typedef unsigned short uint16_t;
index 793c89803fc4794b4468dfacd62481060bffb3d2..249ec2e99b69421e8b133c12cb663aa8459807df 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple arm-none-linux-gnueabi %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -triple arm-none-linux-gnueabi -target-feature +neon %s -emit-llvm -o - | FileCheck %s
 
 typedef float float32_t;
 typedef __fp16 float16_t;
index f4d58ffd09359090b4e081817cf7074528681853..ddfafbcc58bf2fde556a01a69c7658294e50fc75 100644 (file)
@@ -1,5 +1,5 @@
 // REQUIRES: aarch64-registered-target
-// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +neon -fsyntax-only -verify
 
 typedef float float32_t;
 typedef unsigned char poly8_t;
diff --git a/test/Sema/neon-vector-types-support.c b/test/Sema/neon-vector-types-support.c
new file mode 100644 (file)
index 0000000..6bf8539
--- /dev/null
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
+
+typedef __attribute__((neon_vector_type(2))) int int32x2_t; // expected-error{{'neon_vector_type' attribute is not supported for this target}}
+typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // expected-error{{'neon_polyvector_type' attribute is not supported for this target}}
index d15a50d28f0bc3c21c7d36e9e5687d48e8e5bd0e..d8dd41225a32a08e4e9db4b907ea779603ff0189 100644 (file)
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 %s -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv7 -target-feature +neon -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv8 -target-feature +neon -fsyntax-only -verify
 
 typedef float float32_t;
 typedef signed char poly8_t;
index 336fcd4f18d6aa01fac692b0e3fad0ee660e5e60..c2953d713b2a967b015420f32b75fe318d5c1627 100644 (file)
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify "-triple" "thumbv7-apple-ios3.0.0" %s
+// RUN: %clang_cc1 -fsyntax-only -verify "-triple" "thumbv7-apple-ios3.0.0" -target-feature +neon %s
 // rdar://9208404
 
 typedef int MP4Err;