| 1 |
/* Inspired by 'gcc.target/nvptx/abi-struct-arg.c', 'gcc.target/nvptx/abi-struct-ret.c'. */ |
| 2 |
|
| 3 |
/* See also '../libgomp.c-c++-common/target-abi-struct-1.c'. */ |
| 4 |
|
| 5 |
/* To exercise PR119835 (if optimizations enabled): disable inlining, so that |
| 6 |
GIMPLE passes still see the functions that return aggregate types. */ |
| 7 |
#pragma GCC optimize "-fno-inline" |
| 8 |
|
| 9 |
typedef struct {} empty; /* See 'gcc/doc/extend.texi', "Empty Structures". */ |
| 10 |
typedef struct {char a;} schar; |
| 11 |
typedef struct {short a;} sshort; |
| 12 |
typedef struct {int a;} sint; |
| 13 |
typedef struct {long long a;} slonglong; |
| 14 |
typedef struct {int a, b[12];} sint_13; |
| 15 |
|
| 16 |
#pragma omp declare target |
| 17 |
|
| 18 |
#define M(T) ({T t; t.a = sizeof t; t;}) |
| 19 |
|
| 20 |
static __SIZE_TYPE__ empty_a; |
| 21 |
#pragma acc declare create(empty_a) |
| 22 |
#pragma acc routine |
| 23 |
static empty rempty(void) |
| 24 |
{ |
| 25 |
return ({empty t; empty_a = sizeof t; t;}); |
| 26 |
} |
| 27 |
|
| 28 |
#pragma acc routine |
| 29 |
static schar rschar(void) |
| 30 |
{ |
| 31 |
return M(schar); |
| 32 |
} |
| 33 |
|
| 34 |
#pragma acc routine |
| 35 |
static sshort rsshort(void) |
| 36 |
{ |
| 37 |
return M(sshort); |
| 38 |
} |
| 39 |
|
| 40 |
#pragma acc routine |
| 41 |
static sint rsint(void) |
| 42 |
{ |
| 43 |
return M(sint); |
| 44 |
} |
| 45 |
|
| 46 |
#pragma acc routine |
| 47 |
static slonglong rslonglong(void) |
| 48 |
{ |
| 49 |
return M(slonglong); |
| 50 |
} |
| 51 |
|
| 52 |
#pragma acc routine |
| 53 |
static sint_13 rsint_13(void) |
| 54 |
{ |
| 55 |
return M(sint_13); |
| 56 |
} |
| 57 |
|
| 58 |
#pragma acc routine |
| 59 |
static void aempty(empty empty) |
| 60 |
{ |
| 61 |
(void) empty; |
| 62 |
|
| 63 |
__SIZE_TYPE__ empty_a_exp; |
| 64 |
#ifndef __cplusplus |
| 65 |
empty_a_exp = 0; |
| 66 |
#else |
| 67 |
empty_a_exp = sizeof (char); |
| 68 |
#endif |
| 69 |
if (empty_a != empty_a_exp) |
| 70 |
__builtin_abort(); |
| 71 |
} |
| 72 |
|
| 73 |
#pragma acc routine |
| 74 |
static void aschar(schar schar) |
| 75 |
{ |
| 76 |
if (schar.a != sizeof (char)) |
| 77 |
__builtin_abort(); |
| 78 |
} |
| 79 |
|
| 80 |
#pragma acc routine |
| 81 |
static void asshort(sshort sshort) |
| 82 |
{ |
| 83 |
if (sshort.a != sizeof (short)) |
| 84 |
__builtin_abort(); |
| 85 |
} |
| 86 |
|
| 87 |
#pragma acc routine |
| 88 |
static void asint(sint sint) |
| 89 |
{ |
| 90 |
if (sint.a != sizeof (int)) |
| 91 |
__builtin_abort(); |
| 92 |
} |
| 93 |
|
| 94 |
#pragma acc routine |
| 95 |
static void aslonglong(slonglong slonglong) |
| 96 |
{ |
| 97 |
if (slonglong.a != sizeof (long long)) |
| 98 |
__builtin_abort(); |
| 99 |
} |
| 100 |
|
| 101 |
#pragma acc routine |
| 102 |
static void asint_13(sint_13 sint_13) |
| 103 |
{ |
| 104 |
if (sint_13.a != (sizeof (int) * 13)) |
| 105 |
__builtin_abort(); |
| 106 |
} |
| 107 |
|
| 108 |
#pragma omp end declare target |
| 109 |
|
| 110 |
int main() |
| 111 |
{ |
| 112 |
#pragma omp target |
| 113 |
#pragma acc serial |
| 114 |
/* { dg-bogus {using 'vector_length \(32\)', ignoring 1} {} { target openacc_nvidia_accel_selected xfail *-*-* } .-1 } */ |
| 115 |
{ |
| 116 |
aempty(rempty()); |
| 117 |
aschar(rschar()); |
| 118 |
asshort(rsshort()); |
| 119 |
asint(rsint()); |
| 120 |
aslonglong(rslonglong()); |
| 121 |
asint_13(rsint_13()); |
| 122 |
} |
| 123 |
|
| 124 |
return 0; |
| 125 |
} |