| 1 |
/* Check alignment convention in the vector ABI. */ |
| 2 |
|
| 3 |
/* { dg-do compile { target { s390*-*-* } } } */ |
| 4 |
/* { dg-options "-O3 -mzarch -march=z13" } */ |
| 5 |
|
| 6 |
#include <stddef.h> |
| 7 |
|
| 8 |
/* Vector types get an 8 byte alignment. */ |
| 9 |
typedef double v2df __attribute__((vector_size(16))); |
| 10 |
typedef struct |
| 11 |
{ |
| 12 |
char a; |
| 13 |
v2df b; |
| 14 |
} A; |
| 15 |
char c1[offsetof (A, b) == 8 ? 0 : -1]; |
| 16 |
|
| 17 |
/* Smaller vector allow for smaller alignments. */ |
| 18 |
typedef char v4qi __attribute__((vector_size(4))); |
| 19 |
typedef struct |
| 20 |
{ |
| 21 |
char a; |
| 22 |
v4qi b; |
| 23 |
} B; |
| 24 |
char c2[offsetof (B, b) == 4 ? 0 : -1]; |
| 25 |
|
| 26 |
|
| 27 |
typedef double v4df __attribute__((vector_size(32))); |
| 28 |
typedef struct |
| 29 |
{ |
| 30 |
char a; |
| 31 |
v4df b; |
| 32 |
} C; |
| 33 |
char c3[offsetof (C, b) == 8 ? 0 : -1]; |
| 34 |
|
| 35 |
/* However, we allow the programmer to chose a bigger alignment. */ |
| 36 |
typedef struct |
| 37 |
{ |
| 38 |
char a; |
| 39 |
v2df b __attribute__((aligned(16))); |
| 40 |
} D; |
| 41 |
char c4[offsetof (D, b) == 16 ? 0 : -1]; |
| 42 |
|
| 43 |
typedef struct |
| 44 |
{ |
| 45 |
char a; |
| 46 |
v2df b; |
| 47 |
} __attribute__((packed)) E; |
| 48 |
char c5[offsetof (E, b) == 1 ? 0 : -1]; |