r190801 - Add error checking to reject neon_vector_type attribute on targets without NEON.

Amara Emerson amara.emerson at arm.com
Mon Sep 16 11:07:35 PDT 2013


Author: aemerson
Date: Mon Sep 16 13:07:35 2013
New Revision: 190801

URL: http://llvm.org/viewvc/llvm-project?rev=190801&view=rev
Log:
Add error checking to reject neon_vector_type attribute on targets without NEON.

Patch by Artyom Skrobov.

Added:
    cfe/trunk/test/Sema/neon-vector-types-support.c
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Basic/Targets.cpp
    cfe/trunk/lib/Sema/SemaType.cpp
    cfe/trunk/test/Analysis/misc-ps-arm.m
    cfe/trunk/test/CodeGen/arm-arguments.c
    cfe/trunk/test/CodeGen/arm-asm-diag.c
    cfe/trunk/test/CodeGen/arm-asm-warn.c
    cfe/trunk/test/CodeGen/struct-init.c
    cfe/trunk/test/CodeGen/struct-matching-constraint.c
    cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp
    cfe/trunk/test/CodeGenCXX/mangle-neon-vectors.cpp
    cfe/trunk/test/Sema/aarch64-neon-vector-types.c
    cfe/trunk/test/Sema/neon-vector-types.c
    cfe/trunk/test/SemaCXX/neon-vector-types.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Sep 16 13:07:35 2013
@@ -1785,6 +1785,8 @@ def err_attribute_too_few_arguments : Er
 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<

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Mon Sep 16 13:07:35 2013
@@ -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?

Modified: cfe/trunk/lib/Sema/SemaType.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaType.cpp?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp (original)
+++ cfe/trunk/lib/Sema/SemaType.cpp Mon Sep 16 13:07:35 2013
@@ -4735,6 +4735,12 @@ static bool isPermittedNeonBaseType(Qual
 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)

Modified: cfe/trunk/test/Analysis/misc-ps-arm.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-arm.m?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-arm.m (original)
+++ cfe/trunk/test/Analysis/misc-ps-arm.m Mon Sep 16 13:07:35 2013
@@ -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

Modified: cfe/trunk/test/CodeGen/arm-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-arguments.c?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/arm-arguments.c (original)
+++ cfe/trunk/test/CodeGen/arm-arguments.c Mon Sep 16 13:07:35 2013
@@ -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()

Modified: cfe/trunk/test/CodeGen/arm-asm-diag.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-asm-diag.c?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/arm-asm-diag.c (original)
+++ cfe/trunk/test/CodeGen/arm-asm-diag.c Mon Sep 16 13:07:35 2013
@@ -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;

Modified: cfe/trunk/test/CodeGen/arm-asm-warn.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-asm-warn.c?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/arm-asm-warn.c (original)
+++ cfe/trunk/test/CodeGen/arm-asm-warn.c Mon Sep 16 13:07:35 2013
@@ -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();
 

Modified: cfe/trunk/test/CodeGen/struct-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/struct-init.c?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/struct-init.c (original)
+++ cfe/trunk/test/CodeGen/struct-init.c Mon Sep 16 13:07:35 2013
@@ -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 {

Modified: cfe/trunk/test/CodeGen/struct-matching-constraint.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/struct-matching-constraint.c?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/struct-matching-constraint.c (original)
+++ cfe/trunk/test/CodeGen/struct-matching-constraint.c Mon Sep 16 13:07:35 2013
@@ -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;
 

Modified: cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/aarch64-mangle-neon-vectors.cpp Mon Sep 16 13:07:35 2013
@@ -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;

Modified: cfe/trunk/test/CodeGenCXX/mangle-neon-vectors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mangle-neon-vectors.cpp?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/mangle-neon-vectors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/mangle-neon-vectors.cpp Mon Sep 16 13:07:35 2013
@@ -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;

Modified: cfe/trunk/test/Sema/aarch64-neon-vector-types.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/aarch64-neon-vector-types.c?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/Sema/aarch64-neon-vector-types.c (original)
+++ cfe/trunk/test/Sema/aarch64-neon-vector-types.c Mon Sep 16 13:07:35 2013
@@ -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;

Added: cfe/trunk/test/Sema/neon-vector-types-support.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/neon-vector-types-support.c?rev=190801&view=auto
==============================================================================
--- cfe/trunk/test/Sema/neon-vector-types-support.c (added)
+++ cfe/trunk/test/Sema/neon-vector-types-support.c Mon Sep 16 13:07:35 2013
@@ -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}}

Modified: cfe/trunk/test/Sema/neon-vector-types.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/neon-vector-types.c?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/Sema/neon-vector-types.c (original)
+++ cfe/trunk/test/Sema/neon-vector-types.c Mon Sep 16 13:07:35 2013
@@ -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;

Modified: cfe/trunk/test/SemaCXX/neon-vector-types.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/neon-vector-types.cpp?rev=190801&r1=190800&r2=190801&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/neon-vector-types.cpp (original)
+++ cfe/trunk/test/SemaCXX/neon-vector-types.cpp Mon Sep 16 13:07:35 2013
@@ -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;





More information about the cfe-commits mailing list