aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/bpf/atomic-fetch-op-1.c
blob: 533e955fe88353ddc70e62b5886f8a7109471e56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* Test 64-bit atomic-fetch-op instructions.  */

/* { dg-do compile } */
/* { dg-options "-mv3-atomics -O2" } */

long val;

long
test_atomic_fetch_add (long x)
{
  return __atomic_fetch_add (&val, x, __ATOMIC_ACQUIRE);
}

long
test_atomic_fetch_sub (long x)
{
  return __atomic_fetch_sub (&val, x, __ATOMIC_RELEASE);
}

long
test_atomic_fetch_and (long x)
{
  return __atomic_fetch_and (&val, x, __ATOMIC_ACQUIRE);
}

long
test_atomic_fetch_nand (long x)
{
  return __atomic_fetch_nand (&val, x, __ATOMIC_ACQUIRE);
}

long
test_atomic_fetch_or (long x)
{
  return __atomic_fetch_or (&val, x, __ATOMIC_ACQUIRE);
}

long
test_atomic_fetch_xor (long x)
{
  return __atomic_fetch_xor (&val, x, __ATOMIC_ACQUIRE);
}

/* sub implemented in terms of add */
/* { dg-final { scan-assembler-times "afadd\t" 2 } } */
/* { dg-final { scan-assembler-times "afand\t" 1 } } */
/* nand must use a compare-exchange loop */
/* { dg-final { scan-assembler "acmp\t" } } */
/* { dg-final { scan-assembler-times "afor\t" 1 } } */
/* { dg-final { scan-assembler-times "afxor\t" 1 } } */