xref: /aosp_15_r20/external/llvm/test/CodeGen/Hexagon/Atomics.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -march=hexagon
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker@si = common global i32 0, align 4
4*9880d681SAndroid Build Coastguard Worker@sll = common global i64 0, align 8
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workerdefine void @test_op_ignore() nounwind {
7*9880d681SAndroid Build Coastguard Workerentry:
8*9880d681SAndroid Build Coastguard Worker  %t00 = atomicrmw add i32* @si, i32 1 monotonic
9*9880d681SAndroid Build Coastguard Worker  %t01 = atomicrmw add i64* @sll, i64 1 monotonic
10*9880d681SAndroid Build Coastguard Worker  %t10 = atomicrmw sub i32* @si, i32 1 monotonic
11*9880d681SAndroid Build Coastguard Worker  %t11 = atomicrmw sub i64* @sll, i64 1 monotonic
12*9880d681SAndroid Build Coastguard Worker  %t20 = atomicrmw or i32* @si, i32 1 monotonic
13*9880d681SAndroid Build Coastguard Worker  %t21 = atomicrmw or i64* @sll, i64 1 monotonic
14*9880d681SAndroid Build Coastguard Worker  %t30 = atomicrmw xor i32* @si, i32 1 monotonic
15*9880d681SAndroid Build Coastguard Worker  %t31 = atomicrmw xor i64* @sll, i64 1 monotonic
16*9880d681SAndroid Build Coastguard Worker  %t40 = atomicrmw and i32* @si, i32 1 monotonic
17*9880d681SAndroid Build Coastguard Worker  %t41 = atomicrmw and i64* @sll, i64 1 monotonic
18*9880d681SAndroid Build Coastguard Worker  %t50 = atomicrmw nand i32* @si, i32 1 monotonic
19*9880d681SAndroid Build Coastguard Worker  %t51 = atomicrmw nand i64* @sll, i64 1 monotonic
20*9880d681SAndroid Build Coastguard Worker  br label %return
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Workerreturn:                                           ; preds = %entry
23*9880d681SAndroid Build Coastguard Worker  ret void
24*9880d681SAndroid Build Coastguard Worker}
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workerdefine void @test_fetch_and_op() nounwind {
27*9880d681SAndroid Build Coastguard Workerentry:
28*9880d681SAndroid Build Coastguard Worker  %t00 = atomicrmw add i32* @si, i32 11 monotonic
29*9880d681SAndroid Build Coastguard Worker  store i32 %t00, i32* @si, align 4
30*9880d681SAndroid Build Coastguard Worker  %t01 = atomicrmw add i64* @sll, i64 11 monotonic
31*9880d681SAndroid Build Coastguard Worker  store i64 %t01, i64* @sll, align 8
32*9880d681SAndroid Build Coastguard Worker  %t10 = atomicrmw sub i32* @si, i32 11 monotonic
33*9880d681SAndroid Build Coastguard Worker  store i32 %t10, i32* @si, align 4
34*9880d681SAndroid Build Coastguard Worker  %t11 = atomicrmw sub i64* @sll, i64 11 monotonic
35*9880d681SAndroid Build Coastguard Worker  store i64 %t11, i64* @sll, align 8
36*9880d681SAndroid Build Coastguard Worker  %t20 = atomicrmw or i32* @si, i32 11 monotonic
37*9880d681SAndroid Build Coastguard Worker  store i32 %t20, i32* @si, align 4
38*9880d681SAndroid Build Coastguard Worker  %t21 = atomicrmw or i64* @sll, i64 11 monotonic
39*9880d681SAndroid Build Coastguard Worker  store i64 %t21, i64* @sll, align 8
40*9880d681SAndroid Build Coastguard Worker  %t30 = atomicrmw xor i32* @si, i32 11 monotonic
41*9880d681SAndroid Build Coastguard Worker  store i32 %t30, i32* @si, align 4
42*9880d681SAndroid Build Coastguard Worker  %t31 = atomicrmw xor i64* @sll, i64 11 monotonic
43*9880d681SAndroid Build Coastguard Worker  store i64 %t31, i64* @sll, align 8
44*9880d681SAndroid Build Coastguard Worker  %t40 = atomicrmw and i32* @si, i32 11 monotonic
45*9880d681SAndroid Build Coastguard Worker  store i32 %t40, i32* @si, align 4
46*9880d681SAndroid Build Coastguard Worker  %t41 = atomicrmw and i64* @sll, i64 11 monotonic
47*9880d681SAndroid Build Coastguard Worker  store i64 %t41, i64* @sll, align 8
48*9880d681SAndroid Build Coastguard Worker  %t50 = atomicrmw nand i32* @si, i32 11 monotonic
49*9880d681SAndroid Build Coastguard Worker  store i32 %t50, i32* @si, align 4
50*9880d681SAndroid Build Coastguard Worker  %t51 = atomicrmw nand i64* @sll, i64 11 monotonic
51*9880d681SAndroid Build Coastguard Worker  store i64 %t51, i64* @sll, align 8
52*9880d681SAndroid Build Coastguard Worker  br label %return
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Workerreturn:                                           ; preds = %entry
55*9880d681SAndroid Build Coastguard Worker  ret void
56*9880d681SAndroid Build Coastguard Worker}
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Workerdefine void @test_lock() nounwind {
59*9880d681SAndroid Build Coastguard Workerentry:
60*9880d681SAndroid Build Coastguard Worker  %t00 = atomicrmw xchg i32* @si, i32 1 monotonic
61*9880d681SAndroid Build Coastguard Worker  store i32 %t00, i32* @si, align 4
62*9880d681SAndroid Build Coastguard Worker  %t01 = atomicrmw xchg i64* @sll, i64 1 monotonic
63*9880d681SAndroid Build Coastguard Worker  store i64 %t01, i64* @sll, align 8
64*9880d681SAndroid Build Coastguard Worker  fence seq_cst
65*9880d681SAndroid Build Coastguard Worker  store volatile i32 0, i32* @si, align 4
66*9880d681SAndroid Build Coastguard Worker  store volatile i64 0, i64* @sll, align 8
67*9880d681SAndroid Build Coastguard Worker  br label %return
68*9880d681SAndroid Build Coastguard Worker
69*9880d681SAndroid Build Coastguard Workerreturn:                                           ; preds = %entry
70*9880d681SAndroid Build Coastguard Worker  ret void
71*9880d681SAndroid Build Coastguard Worker}
72*9880d681SAndroid Build Coastguard Worker
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Workerdefine i64 @fred() nounwind {
75*9880d681SAndroid Build Coastguard Workerentry:
76*9880d681SAndroid Build Coastguard Worker  %s0 = cmpxchg i32* undef, i32 undef, i32 undef seq_cst seq_cst
77*9880d681SAndroid Build Coastguard Worker  %s1 = extractvalue { i32, i1 } %s0, 0
78*9880d681SAndroid Build Coastguard Worker  %t0 = cmpxchg i64* undef, i64 undef, i64 undef seq_cst seq_cst
79*9880d681SAndroid Build Coastguard Worker  %t1 = extractvalue { i64, i1 } %t0, 0
80*9880d681SAndroid Build Coastguard Worker  %u0 = zext i32 %s1 to i64
81*9880d681SAndroid Build Coastguard Worker  %u1 = add i64 %u0, %t1
82*9880d681SAndroid Build Coastguard Worker  ret i64 %u1
83*9880d681SAndroid Build Coastguard Worker}
84*9880d681SAndroid Build Coastguard Worker
85