1; RUN: llc -mtriple=amdgcn-amd- -mcpu=gfx600 -verify-machineinstrs < %s | FileCheck -check-prefixes=FUNC,GCN,GFX6,GFX68 %s
2; RUN: llc -mtriple=amdgcn-amd- -mcpu=gfx803 -verify-machineinstrs < %s | FileCheck -check-prefixes=FUNC,GCN,GFX8,GFX68 %s
3; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx803 -verify-machineinstrs < %s | FileCheck -check-prefixes=FUNC,GCN,GFX8,GFX68 %s
4
5; FUNC-LABEL: {{^}}system_acquire:
6; GCN:        %bb.0
7; GCN-NOT:    ATOMIC_FENCE
8; GFX6:       s_waitcnt vmcnt(0){{$}}
9; GFX6-NEXT:  buffer_wbinvl1{{$}}
10; GFX8:       s_waitcnt vmcnt(0){{$}}
11; GFX8-NEXT:  buffer_wbinvl1_vol{{$}}
12; GCN:        s_endpgm
13define amdgpu_kernel void @system_acquire() {
14entry:
15  fence acquire
16  ret void
17}
18
19; FUNC-LABEL: {{^}}system_release:
20; GCN:        %bb.0
21; GCN-NOT:    ATOMIC_FENCE
22; GCN:        s_waitcnt vmcnt(0){{$}}
23; GCN:        s_endpgm
24define amdgpu_kernel void @system_release() {
25entry:
26  fence release
27  ret void
28}
29
30; FUNC-LABEL: {{^}}system_acq_rel:
31; GCN:        %bb.0
32; GCN-NOT:    ATOMIC_FENCE
33; GCN:        s_waitcnt vmcnt(0){{$}}
34; GFX6:       buffer_wbinvl1{{$}}
35; GFX8:       buffer_wbinvl1_vol{{$}}
36; GCN:        s_endpgm
37define amdgpu_kernel void @system_acq_rel() {
38entry:
39  fence acq_rel
40  ret void
41}
42
43; FUNC-LABEL: {{^}}system_seq_cst:
44; GCN:        %bb.0
45; GCN-NOT:    ATOMIC_FENCE
46; GCN:        s_waitcnt vmcnt(0){{$}}
47; GFX6:       buffer_wbinvl1{{$}}
48; GFX8:       buffer_wbinvl1_vol{{$}}
49; GCN:        s_endpgm
50define amdgpu_kernel void @system_seq_cst() {
51entry:
52  fence seq_cst
53  ret void
54}
55
56; FUNC-LABEL: {{^}}singlethread_acquire:
57; GCN:        %bb.0
58; GCN-NOT:    ATOMIC_FENCE
59; GCN:        s_endpgm
60define amdgpu_kernel void @singlethread_acquire() {
61entry:
62  fence syncscope("singlethread") acquire
63  ret void
64}
65
66; FUNC-LABEL: {{^}}singlethread_release:
67; GCN:        %bb.0
68; GCN-NOT:    ATOMIC_FENCE
69; GCN:        s_endpgm
70define amdgpu_kernel void @singlethread_release() {
71entry:
72  fence syncscope("singlethread") release
73  ret void
74}
75
76; FUNC-LABEL: {{^}}singlethread_acq_rel:
77; GCN:        %bb.0
78; GCN-NOT:    ATOMIC_FENCE
79; GCN:        s_endpgm
80define amdgpu_kernel void @singlethread_acq_rel() {
81entry:
82  fence syncscope("singlethread") acq_rel
83  ret void
84}
85
86; FUNC-LABEL: {{^}}singlethread_seq_cst:
87; GCN:        %bb.0
88; GCN-NOT:    ATOMIC_FENCE
89; GCN:        s_endpgm
90define amdgpu_kernel void @singlethread_seq_cst() {
91entry:
92  fence syncscope("singlethread") seq_cst
93  ret void
94}
95
96; FUNC-LABEL: {{^}}agent_acquire:
97; GCN:        %bb.0
98; GCN-NOT:    ATOMIC_FENCE
99; GFX6:       s_waitcnt vmcnt(0){{$}}
100; GFX6-NEXT:  buffer_wbinvl1{{$}}
101; GFX8:       s_waitcnt vmcnt(0){{$}}
102; GFX8-NEXT:  buffer_wbinvl1_vol{{$}}
103; GCN:        s_endpgm
104define amdgpu_kernel void @agent_acquire() {
105entry:
106  fence syncscope("agent") acquire
107  ret void
108}
109
110; FUNC-LABEL: {{^}}agent_release:
111; GCN:        %bb.0
112; GCN-NOT:    ATOMIC_FENCE
113; GCN:        s_waitcnt vmcnt(0){{$}}
114; GCN:        s_endpgm
115define amdgpu_kernel void @agent_release() {
116entry:
117  fence syncscope("agent") release
118  ret void
119}
120
121; FUNC-LABEL: {{^}}agent_acq_rel:
122; GCN:        %bb.0
123; GCN-NOT:    ATOMIC_FENCE
124; GCN:        s_waitcnt vmcnt(0){{$}}
125; GFX6:       buffer_wbinvl1{{$}}
126; GFX8:       buffer_wbinvl1_vol{{$}}
127; GCN:        s_endpgm
128define amdgpu_kernel void @agent_acq_rel() {
129entry:
130  fence syncscope("agent") acq_rel
131  ret void
132}
133
134; FUNC-LABEL: {{^}}agent_seq_cst:
135; GCN:        %bb.0
136; GCN-NOT:    ATOMIC_FENCE
137; GCN:        s_waitcnt vmcnt(0){{$}}
138; GFX6:       buffer_wbinvl1{{$}}
139; GFX8:       buffer_wbinvl1_vol{{$}}
140; GCN:        s_endpgm
141define amdgpu_kernel void @agent_seq_cst() {
142entry:
143  fence syncscope("agent") seq_cst
144  ret void
145}
146
147; FUNC-LABEL: {{^}}workgroup_acquire:
148; GCN:        %bb.0
149; GFX68-NOT:  s_waitcnt vmcnt(0){{$}}
150; GCN-NOT:    ATOMIC_FENCE
151; GCN:        s_endpgm
152define amdgpu_kernel void @workgroup_acquire() {
153entry:
154  fence syncscope("workgroup") acquire
155  ret void
156}
157
158; FUNC-LABEL: {{^}}workgroup_release:
159; GCN:        %bb.0
160; GFX68-NOT:  s_waitcnt vmcnt(0){{$}}
161; GCN-NOT:    ATOMIC_FENCE
162; GCN:        s_endpgm
163define amdgpu_kernel void @workgroup_release() {
164entry:
165  fence syncscope("workgroup") release
166  ret void
167}
168
169; FUNC-LABEL: {{^}}workgroup_acq_rel:
170; GCN:        %bb.0
171; GFX68-NOT:  s_waitcnt vmcnt(0){{$}}
172; GCN-NOT:    ATOMIC_FENCE
173; GCN:        s_endpgm
174define amdgpu_kernel void @workgroup_acq_rel() {
175entry:
176  fence syncscope("workgroup") acq_rel
177  ret void
178}
179
180; FUNC-LABEL: {{^}}workgroup_seq_cst:
181; GCN:        %bb.0
182; GFX68-NOT:  s_waitcnt vmcnt(0){{$}}
183; GCN-NOT:    ATOMIC_FENCE
184; GCN:        s_endpgm
185define amdgpu_kernel void @workgroup_seq_cst() {
186entry:
187  fence syncscope("workgroup") seq_cst
188  ret void
189}
190
191; FUNC-LABEL: {{^}}wavefront_acquire:
192; GCN:        %bb.0
193; GCN-NOT:    ATOMIC_FENCE
194; GCN:        s_endpgm
195define amdgpu_kernel void @wavefront_acquire() {
196entry:
197  fence syncscope("wavefront") acquire
198  ret void
199}
200
201; FUNC-LABEL: {{^}}wavefront_release:
202; GCN:        %bb.0
203; GCN-NOT:    ATOMIC_FENCE
204; GCN:        s_endpgm
205define amdgpu_kernel void @wavefront_release() {
206entry:
207  fence syncscope("wavefront") release
208  ret void
209}
210
211; FUNC-LABEL: {{^}}wavefront_acq_rel:
212; GCN:        %bb.0
213; GCN-NOT:    ATOMIC_FENCE
214; GCN:        s_endpgm
215define amdgpu_kernel void @wavefront_acq_rel() {
216entry:
217  fence syncscope("wavefront") acq_rel
218  ret void
219}
220
221; FUNC-LABEL: {{^}}wavefront_seq_cst:
222; GCN:        %bb.0
223; GCN-NOT:    ATOMIC_FENCE
224; GCN:        s_endpgm
225define amdgpu_kernel void @wavefront_seq_cst() {
226entry:
227  fence syncscope("wavefront") seq_cst
228  ret void
229}
230