Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / AMDGPU / sopp.s
blob7771573df1ecbfa4624e6821227c241b65f8ee1c
1 // RUN: not llvm-mc -triple=amdgcn -show-encoding %s | FileCheck --check-prefixes=GCN,SI %s
2 // RUN: not llvm-mc -triple=amdgcn %s 2>&1 | FileCheck %s --check-prefix=NOSICI --implicit-check-not=error:
3 // RUN: llvm-mc -triple=amdgcn -mcpu=fiji -show-encoding %s | FileCheck --check-prefixes=GCN,VI %s
5 //===----------------------------------------------------------------------===//
6 // Edge Cases
7 //===----------------------------------------------------------------------===//
9 s_nop 0
10 // GCN: s_nop 0 ; encoding: [0x00,0x00,0x80,0xbf]
12 s_nop 0xffff
13 // GCN: s_nop 0xffff ; encoding: [0xff,0xff,0x80,0xbf]
15 //===----------------------------------------------------------------------===//
16 // Instructions
17 //===----------------------------------------------------------------------===//
19 s_nop 1
20 // GCN: s_nop 1 ; encoding: [0x01,0x00,0x80,0xbf]
22 s_endpgm
23 // GCN: s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
25 s_endpgm 1
26 // GCN: s_endpgm 1 ; encoding: [0x01,0x00,0x81,0xbf]
28 s_endpgm 65535
29 // GCN: s_endpgm 65535 ; encoding: [0xff,0xff,0x81,0xbf]
31 s_branch 2
32 // GCN: s_branch 2 ; encoding: [0x02,0x00,0x82,0xbf]
34 s_cbranch_scc0 3
35 // GCN: s_cbranch_scc0 3 ; encoding: [0x03,0x00,0x84,0xbf]
37 s_cbranch_scc1 4
38 // GCN: s_cbranch_scc1 4 ; encoding: [0x04,0x00,0x85,0xbf]
40 s_cbranch_vccz 5
41 // GCN: s_cbranch_vccz 5 ; encoding: [0x05,0x00,0x86,0xbf]
43 s_cbranch_vccnz 6
44 // GCN: s_cbranch_vccnz 6 ; encoding: [0x06,0x00,0x87,0xbf]
46 s_cbranch_execz 7
47 // GCN: s_cbranch_execz 7 ; encoding: [0x07,0x00,0x88,0xbf]
49 s_cbranch_execnz 8
50 // GCN: s_cbranch_execnz 8 ; encoding: [0x08,0x00,0x89,0xbf]
52 s_cbranch_cdbgsys 9
53 // GCN: s_cbranch_cdbgsys 9 ; encoding: [0x09,0x00,0x97,0xbf]
55 s_cbranch_cdbgsys_and_user 10
56 // GCN: s_cbranch_cdbgsys_and_user 10 ; encoding: [0x0a,0x00,0x9a,0xbf]
58 s_cbranch_cdbgsys_or_user 11
59 // GCN: s_cbranch_cdbgsys_or_user 11 ; encoding: [0x0b,0x00,0x99,0xbf]
61 s_cbranch_cdbguser 12
62 // GCN: s_cbranch_cdbguser 12 ; encoding: [0x0c,0x00,0x98,0xbf]
64 s_barrier
65 // GCN: s_barrier ; encoding: [0x00,0x00,0x8a,0xbf]
67 //===----------------------------------------------------------------------===//
68 // s_waitcnt
69 //===----------------------------------------------------------------------===//
71 s_waitcnt 0
72 // GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
74 s_waitcnt vmcnt(0) & expcnt(0) & lgkmcnt(0)
75 // GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
77 s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
78 // GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
80 s_waitcnt vmcnt(0), expcnt(0), lgkmcnt(0)
81 // GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
83 s_waitcnt vmcnt(1)
84 // GCN: s_waitcnt vmcnt(1) ; encoding: [0x71,0x0f,0x8c,0xbf]
86 s_waitcnt vmcnt(9)
87 // GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf]
89 s_waitcnt vmcnt(15)
90 // GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
92 s_waitcnt vmcnt_sat(9)
93 // GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf]
95 s_waitcnt vmcnt_sat(15)
96 // GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
98 s_waitcnt vmcnt_sat(16)
99 // GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
101 s_waitcnt expcnt(2)
102 // GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf]
104 s_waitcnt expcnt(7)
105 // GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
107 s_waitcnt expcnt_sat(2)
108 // GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf]
110 s_waitcnt expcnt_sat(7)
111 // GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
113 s_waitcnt expcnt_sat(0xFFFF0000)
114 // GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
116 s_waitcnt lgkmcnt(3)
117 // GCN: s_waitcnt lgkmcnt(3) ; encoding: [0x7f,0x03,0x8c,0xbf]
119 s_waitcnt lgkmcnt(9)
120 // GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf]
122 s_waitcnt lgkmcnt(15)
123 // GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
125 s_waitcnt vmcnt(0), expcnt(0)
126 // GCN: s_waitcnt vmcnt(0) expcnt(0) ; encoding: [0x00,0x0f,0x8c,0xbf]
128 s_waitcnt lgkmcnt_sat(3)
129 // GCN: s_waitcnt lgkmcnt(3) ; encoding: [0x7f,0x03,0x8c,0xbf]
131 s_waitcnt lgkmcnt_sat(9)
132 // GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf]
134 s_waitcnt lgkmcnt_sat(15)
135 // GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
137 s_waitcnt lgkmcnt_sat(16)
138 // GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
141 s_waitcnt lgkmcnt_sat(x+1)
142 // GCN: s_waitcnt lgkmcnt(2) ; encoding: [0x7f,0x02,0x8c,0xbf]
144 s_waitcnt lgkmcnt_sat(1+x)
145 // GCN: s_waitcnt lgkmcnt(2) ; encoding: [0x7f,0x02,0x8c,0xbf]
147 s_waitcnt x+1
148 // GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf]
150 s_waitcnt 1+x
151 // GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf]
153 lgkmcnt_sat=1
154 s_waitcnt lgkmcnt_sat
155 // GCN: s_waitcnt vmcnt(1) expcnt(0) lgkmcnt(0) ; encoding: [0x01,0x00,0x8c,0xbf]
157 s_waitcnt lgkmcnt_sat+1
158 // GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf]
160 //===----------------------------------------------------------------------===//
161 // misc sopp instructions
162 //===----------------------------------------------------------------------===//
164 s_sethalt 9
165 // GCN: s_sethalt 9 ; encoding: [0x09,0x00,0x8d,0xbf]
167 s_setkill 7
168 // GCN: s_setkill 7 ; encoding: [0x07,0x00,0x8b,0xbf]
170 s_sleep 10
171 // GCN: s_sleep 10 ; encoding: [0x0a,0x00,0x8e,0xbf]
173 s_setprio 1
174 // GCN: s_setprio 1 ; encoding: [0x01,0x00,0x8f,0xbf]
176 //===----------------------------------------------------------------------===//
177 // s_sendmsg
178 //===----------------------------------------------------------------------===//
180 s_sendmsg 0x1
181 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
183 s_sendmsg sendmsg(1)
184 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
186 s_sendmsg sendmsg(MSG_INTERRUPT)
187 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
189 s_sendmsg 0x12
190 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
192 s_sendmsg sendmsg(2, 1)
193 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
195 s_sendmsg sendmsg(2, GS_OP_CUT)
196 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
198 s_sendmsg sendmsg(MSG_GS, GS_OP_CUT)
199 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
201 s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0)
202 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
204 s_sendmsg sendmsg(MSG_GS, 1)
205 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
207 s_sendmsg sendmsg(MSG_GS, 1, 1)
208 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 1) ; encoding: [0x12,0x01,0x90,0xbf]
210 s_sendmsg 0x122
211 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf]
213 s_sendmsg sendmsg(2, 2, 1)
214 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf]
216 s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1)
217 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf]
219 s_sendmsg 0x232
220 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
222 s_sendmsg sendmsg(2, 3, 2)
223 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
225 s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2)
226 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
228 s_sendmsg 0x3
229 // GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf]
231 s_sendmsg sendmsg(3, 0)
232 // GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf]
234 s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP)
235 // GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf]
237 s_sendmsg 0x4
238 // SI: s_sendmsg sendmsg(4, 0, 0) ; encoding: [0x04,0x00,0x90,0xbf]
239 // VI: s_sendmsg sendmsg(MSG_SAVEWAVE) ; encoding: [0x04,0x00,0x90,0xbf]
241 s_sendmsg sendmsg(4)
242 // SI: s_sendmsg sendmsg(4, 0, 0) ; encoding: [0x04,0x00,0x90,0xbf]
243 // VI: s_sendmsg sendmsg(MSG_SAVEWAVE) ; encoding: [0x04,0x00,0x90,0xbf]
245 s_sendmsg sendmsg(MSG_SAVEWAVE)
246 // NOSICI: :[[@LINE-1]]:{{[0-9]+}}: error: specified message id is not supported on this GPU
247 // VI: s_sendmsg sendmsg(MSG_SAVEWAVE) ; encoding: [0x04,0x00,0x90,0xbf]
249 s_sendmsg 0x1f
250 // GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf]
252 s_sendmsg sendmsg(15, 1)
253 // GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf]
255 s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT)
256 // GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf]
258 s_sendmsghalt 3
259 // GCN: s_sendmsghalt sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x91,0xbf]
261 s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1)
262 // GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x91,0xbf]
264 //===----------------------------------------------------------------------===//
265 // s_sendmsg with a numeric message id (no validation)
266 //===----------------------------------------------------------------------===//
268 s_sendmsg 2
269 // GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
271 s_sendmsg 9
272 // GCN: s_sendmsg sendmsg(9, 0, 0) ; encoding: [0x09,0x00,0x90,0xbf]
274 s_sendmsg 11
275 // GCN: s_sendmsg sendmsg(11, 0, 0) ; encoding: [0x0b,0x00,0x90,0xbf]
277 s_sendmsg 0x6f
278 // GCN: s_sendmsg sendmsg(15, 6, 0) ; encoding: [0x6f,0x00,0x90,0xbf]
280 s_sendmsg sendmsg(1, 3)
281 // GCN: s_sendmsg sendmsg(1, 3, 0) ; encoding: [0x31,0x00,0x90,0xbf]
283 s_sendmsg sendmsg(1, 3, 2)
284 // GCN: s_sendmsg sendmsg(1, 3, 2) ; encoding: [0x31,0x02,0x90,0xbf]
286 s_sendmsg sendmsg(2, 0, 1)
287 // GCN: s_sendmsg sendmsg(2, 0, 1) ; encoding: [0x02,0x01,0x90,0xbf]
289 s_sendmsg sendmsg(15, 7, 3)
290 // GCN: s_sendmsg sendmsg(15, 7, 3) ; encoding: [0x7f,0x03,0x90,0xbf]
292 s_sendmsg 4567
293 // GCN: s_sendmsg 4567 ; encoding: [0xd7,0x11,0x90,0xbf]
295 //===----------------------------------------------------------------------===//
296 // s_sendmsg with expressions
297 //===----------------------------------------------------------------------===//
299 sendmsg=2
300 s_sendmsg sendmsg
301 // GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
303 sendmsg=1
304 s_sendmsg sendmsg+1
305 // GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
307 s_sendmsg 1+sendmsg
308 // GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
310 msg=1
311 s_sendmsg sendmsg(msg)
312 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
314 msg=0
315 s_sendmsg sendmsg(msg+1)
316 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
318 msg=0
319 s_sendmsg sendmsg(1+msg)
320 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
322 msg=2
323 op=1
324 s_sendmsg sendmsg(msg, op)
325 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
327 msg=1
328 op=0
329 s_sendmsg sendmsg(msg+1, op+1)
330 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
332 msg=1
333 op=0
334 s_sendmsg sendmsg(1+msg, 1+op)
335 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
337 msg=1
338 op=2
339 stream=1
340 s_sendmsg sendmsg(msg+1, op+1, stream+1)
341 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
343 msg=1
344 op=2
345 stream=1
346 s_sendmsg sendmsg(1+msg, 1+op, 1+stream)
347 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
349 MSG_GS=-1
350 GS_OP_EMIT=-1
351 s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1)
352 // GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x91,0xbf]
354 //===----------------------------------------------------------------------===//
355 // misc sopp instructions
356 //===----------------------------------------------------------------------===//
358 s_trap 4
359 // GCN: s_trap 4 ; encoding: [0x04,0x00,0x92,0xbf]
361 s_icache_inv
362 // GCN: s_icache_inv ; encoding: [0x00,0x00,0x93,0xbf]
364 s_incperflevel 5
365 // GCN: s_incperflevel 5 ; encoding: [0x05,0x00,0x94,0xbf]
367 s_decperflevel 6
368 // GCN: s_decperflevel 6 ; encoding: [0x06,0x00,0x95,0xbf]
370 s_ttracedata
371 // GCN: s_ttracedata ; encoding: [0x00,0x00,0x96,0xbf]
373 s_set_gpr_idx_off
374 // VI: s_set_gpr_idx_off ; encoding: [0x00,0x00,0x9c,0xbf]
375 // NOSICI: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
377 s_set_gpr_idx_mode 0
378 // VI: s_set_gpr_idx_mode gpr_idx() ; encoding: [0x00,0x00,0x9d,0xbf]
379 // NOSICI: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
381 s_set_gpr_idx_mode gpr_idx()
382 // VI: s_set_gpr_idx_mode gpr_idx() ; encoding: [0x00,0x00,0x9d,0xbf]
383 // NOSICI: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
385 s_set_gpr_idx_mode 15
386 // VI: s_set_gpr_idx_mode gpr_idx(SRC0,SRC1,SRC2,DST) ; encoding: [0x0f,0x00,0x9d,0xbf]
387 // NOSICI: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
389 s_set_gpr_idx_mode gpr_idx(SRC2,SRC1,SRC0,DST)
390 // VI: s_set_gpr_idx_mode gpr_idx(SRC0,SRC1,SRC2,DST) ; encoding: [0x0f,0x00,0x9d,0xbf]
391 // NOSICI: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
393 s_endpgm_saved
394 // VI: s_endpgm_saved ; encoding: [0x00,0x00,0x9b,0xbf]
395 // NOSICI: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
397 s_wakeup
398 // VI: s_wakeup ; encoding: [0x00,0x00,0x83,0xbf]
399 // NOSICI: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
401 //===----------------------------------------------------------------------===//
402 // absolute expressions as branch offsets
403 //===----------------------------------------------------------------------===//
405 offset = 3
406 s_branch 1+offset
407 // GCN: s_branch 4 ; encoding: [0x04,0x00,0x82,0xbf]
409 offset = 3
410 s_branch offset+1
411 // GCN: s_branch 4 ; encoding: [0x04,0x00,0x82,0xbf]