Debian Codegraph @

gcc/testsuite/gcc.target/riscv/amo/zacas-rvwmo-compare-exchange-compatability-mapping.cc

raw
1 /*
2 ** Verify that atomic op mappings match the PSABI doc's recommended mapping.
3 ** compare_exchange ops with seq_cst failure ordering need a leading fence
4 ** to remain compatible with Table A.6 (A6C).
5 */
6 /* { dg-do compile } */
7 /* { dg-options "-O3 -std=c++17" } */
8 /* { dg-add-options riscv_zacas } */
9 /* { dg-remove-options riscv_ztso } */
10 /* { dg-final { check-function-bodies "**" "" } } */
11
12 /*
13 ** atomic_compare_exchange_weak_int_relaxed_seq_cst:
14 ** ...
15 ** fence\trw,rw
16 ** amoadd\.w\.aqrl\t[atx][0-9]+,a2,0\(a0\)
17 ** ...
18 */
19 void atomic_compare_exchange_weak_int_relaxed_seq_cst (int *bar, int *baz, int qux)
20 {
21 __atomic_compare_exchange_n(bar, baz, qux, 0, __ATOMIC_RELAXED, __ATOMIC_SEQ_CST);
22 }
23
24 /*
25 ** atomic_compare_exchange_weak_int_seq_cst_seq_cst:
26 ** ...
27 ** fence\trw,rw
28 ** amoadd\.w\.aqrl\t[atx][0-9]+,a2,0\(a0\)
29 ** ...
30 */
31 void atomic_compare_exchange_weak_int_seq_cst_seq_cst (int *bar, int *baz, int qux)
32 {
33 __atomic_compare_exchange_n(bar, baz, qux, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
34 }
35
36 /*
37 ** atomic_compare_exchange_strong_int_relaxed_seq_cst:
38 ** ...
39 ** fence\trw,rw
40 ** amoadd\.w\.aqrl\t[atx][0-9]+,a2,0\(a0\)
41 ** ...
42 */
43 void atomic_compare_exchange_strong_int_relaxed_seq_cst (int *bar, int *baz, int qux)
44 {
45 __atomic_compare_exchange_n(bar, baz, qux, 1, __ATOMIC_RELAXED, __ATOMIC_SEQ_CST);
46 }
47
48 /*
49 ** atomic_compare_exchange_strong_int_seq_cst_seq_cst:
50 ** ...
51 ** fence\trw,rw
52 ** amoadd\.w\.aqrl\t[atx][0-9]+,a2,0\(a0\)
53 ** ...
54 */
55 void atomic_compare_exchange_strong_int_seq_cst_seq_cst (int *bar, int *baz, int qux)
56 {
57 __atomic_compare_exchange_n(bar, baz, qux, 1, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
58 }