| 1 |
/* { dg-do compile } */ |
| 2 |
/* Verify that atomic op mappings match the PSABI doc's recommended mapping. */ |
| 3 |
/* { dg-options "-O3" } */ |
| 4 |
/* { dg-add-options riscv_zaamo } */ |
| 5 |
/* { dg-add-options riscv_ztso } */ |
| 6 |
/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ |
| 7 |
/* { dg-final { check-function-bodies "**" "" } } */ |
| 8 |
|
| 9 |
/* |
| 10 |
** atomic_add_fetch_int_relaxed: |
| 11 |
** amoadd\.w\tzero,a1,0\(a0\) |
| 12 |
** ret |
| 13 |
*/ |
| 14 |
void atomic_add_fetch_int_relaxed (int* bar, int baz) |
| 15 |
{ |
| 16 |
__atomic_add_fetch(bar, baz, __ATOMIC_RELAXED); |
| 17 |
} |
| 18 |
|
| 19 |
/* |
| 20 |
** atomic_add_fetch_int_acquire: |
| 21 |
** amoadd\.w\tzero,a1,0\(a0\) |
| 22 |
** ret |
| 23 |
*/ |
| 24 |
void atomic_add_fetch_int_acquire (int* bar, int baz) |
| 25 |
{ |
| 26 |
__atomic_add_fetch(bar, baz, __ATOMIC_ACQUIRE); |
| 27 |
} |
| 28 |
|
| 29 |
/* |
| 30 |
** atomic_add_fetch_int_release: |
| 31 |
** amoadd\.w\tzero,a1,0\(a0\) |
| 32 |
** ret |
| 33 |
*/ |
| 34 |
void atomic_add_fetch_int_release (int* bar, int baz) |
| 35 |
{ |
| 36 |
__atomic_add_fetch(bar, baz, __ATOMIC_RELEASE); |
| 37 |
} |
| 38 |
|
| 39 |
/* |
| 40 |
** atomic_add_fetch_int_acq_rel: |
| 41 |
** amoadd\.w\tzero,a1,0\(a0\) |
| 42 |
** ret |
| 43 |
*/ |
| 44 |
void atomic_add_fetch_int_acq_rel (int* bar, int baz) |
| 45 |
{ |
| 46 |
__atomic_add_fetch(bar, baz, __ATOMIC_ACQ_REL); |
| 47 |
} |
| 48 |
|
| 49 |
/* |
| 50 |
** atomic_add_fetch_int_seq_cst: |
| 51 |
** amoadd\.w\tzero,a1,0\(a0\) |
| 52 |
** ret |
| 53 |
*/ |
| 54 |
void atomic_add_fetch_int_seq_cst (int* bar, int baz) |
| 55 |
{ |
| 56 |
__atomic_add_fetch(bar, baz, __ATOMIC_SEQ_CST); |
| 57 |
} |