aarch64-neon-vector-types.c revision 651f13cea278ec967336033dd032faef0e9fc2ec
1// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +neon -fsyntax-only -verify
2// RUN: %clang_cc1 %s -triple aarch64-none-linux-gnu -target-feature +neon -DUSE_LONG -fsyntax-only -verify
3
4typedef float float32_t;
5typedef unsigned char poly8_t;
6typedef unsigned short poly16_t;
7
8// Both "long" and "long long" should work for 64-bit arch like aarch64.
9// stdint.h in gnu libc is using "long" for 64-bit arch.
10#if USE_LONG
11typedef long int64_t;
12typedef unsigned long uint64_t;
13#else
14typedef long long int64_t;
15typedef unsigned long long uint64_t;
16#endif
17typedef uint64_t poly64_t;
18
19// Define some valid Neon types.
20typedef __attribute__((neon_vector_type(2))) int int32x2_t;
21typedef __attribute__((neon_vector_type(4))) int int32x4_t;
22typedef __attribute__((neon_vector_type(1))) int64_t int64x1_t;
23typedef __attribute__((neon_vector_type(2))) int64_t int64x2_t;
24typedef __attribute__((neon_vector_type(1))) uint64_t uint64x1_t;
25typedef __attribute__((neon_vector_type(2))) uint64_t uint64x2_t;
26typedef __attribute__((neon_vector_type(2))) float32_t float32x2_t;
27typedef __attribute__((neon_vector_type(4))) float32_t float32x4_t;
28typedef __attribute__((neon_polyvector_type(16))) poly8_t  poly8x16_t;
29typedef __attribute__((neon_polyvector_type(8)))  poly16_t poly16x8_t;
30typedef __attribute__((neon_polyvector_type(1)))  poly64_t poly64x1_t;
31typedef __attribute__((neon_polyvector_type(2)))  poly64_t poly64x2_t;
32
33// The attributes must have a single argument.
34typedef __attribute__((neon_vector_type(2, 4))) int only_one_arg; // expected-error{{attribute takes one argument}}
35
36// The number of elements must be an ICE.
37typedef __attribute__((neon_vector_type(2.0))) int non_int_width; // expected-error{{attribute requires an integer constant}}
38
39// Only certain element types are allowed.
40typedef __attribute__((neon_vector_type(2))) double double_elt;
41typedef __attribute__((neon_vector_type(4))) void* ptr_elt; // expected-error{{invalid vector element type}}
42typedef __attribute__((neon_polyvector_type(4))) float32_t bad_poly_elt; // expected-error{{invalid vector element type}}
43struct aggr { signed char c; };
44typedef __attribute__((neon_vector_type(8))) struct aggr aggregate_elt; // expected-error{{invalid vector element type}}
45
46// The total vector size must be 64 or 128 bits.
47typedef __attribute__((neon_vector_type(1))) int int32x1_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
48typedef __attribute__((neon_vector_type(3))) int int32x3_t; // expected-error{{Neon vector size must be 64 or 128 bits}}
49