1 /* Functional tests for the "target" attribute and pragma.  */
2 
3 /* { dg-do run } */
4 /* { dg-require-effective-target target_attribute } */
5 /* { dg-require-effective-target s390_vx } */
6 /* { dg-options "-march=z13 -mvx -mzarch" } */
7 
8 #define V16 __attribute__ ((vector_size(16)))
9 #pragma GCC push_options
10 #pragma GCC target ("arch=z900,no-vx")
11 __attribute__ ((noinline))
foo(char * d,int * off)12 void foo (char *d, int *off)
13 {
14   typedef struct
15   {
16     char c;
17     V16 char vc;
18   } s_t;
19   s_t s = { 1,{ 0,11,22,33,44,55,66,77,88,99,101,111,121,131,141,151 }};
20   *off = __builtin_offsetof(s_t, vc);
21   __builtin_memcpy(d, &s.vc, 16);
22 }
23 #pragma GCC pop_options
24 
25 #pragma GCC push_options
26 #pragma GCC target ("no-vx")
27 __attribute__ ((noinline))
bar(char * d,int * off)28 void bar (char *d, int *off)
29 {
30   typedef struct
31   {
32     char c;
33     V16 char vc;
34   } s_t;
35   s_t s = { 1,{ 0,11,22,33,44,55,66,77,88,99,101,111,121,131,141,151 }};
36   *off = __builtin_offsetof(s_t, vc);
37   __builtin_memcpy(d, &s.vc, 16);
38 }
39 #pragma GCC pop_options
40 
main(int argc,char ** argv)41 int main(int argc, char **argv)
42 {
43   char buf[16] = { 0 };
44   char buf2[16] = { 0 };
45   int off = 0;
46   int off2 = 0;
47   int rc;
48 
49   rc = 0;
50   foo(buf, &off);
51   if (off != 16)
52     rc += 1;
53   if (buf[7] != 77)
54     rc += 2;
55   bar (buf2, &off2);
56   if (off2 != 16)
57     rc += 4;
58   if (buf2[6] != 66)
59     rc += 8;
60 
61   return rc;
62 }
63