xref: /llvm-project/llvm/test/MC/AMDGPU/sopp.s (revision 252c42354eca54274ed7b10c32c73c6937478e8b)
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
4
5//===----------------------------------------------------------------------===//
6// Edge Cases
7//===----------------------------------------------------------------------===//
8
9s_nop 0
10// GCN: s_nop 0 ; encoding: [0x00,0x00,0x80,0xbf]
11
12s_nop 0xffff
13// GCN: s_nop 0xffff ; encoding: [0xff,0xff,0x80,0xbf]
14
15//===----------------------------------------------------------------------===//
16// Instructions
17//===----------------------------------------------------------------------===//
18
19s_nop 1
20// GCN: s_nop 1 ; encoding: [0x01,0x00,0x80,0xbf]
21
22s_endpgm
23// GCN: s_endpgm ; encoding: [0x00,0x00,0x81,0xbf]
24
25s_endpgm 1
26// GCN: s_endpgm 1 ; encoding: [0x01,0x00,0x81,0xbf]
27
28s_endpgm 65535
29// GCN: s_endpgm 65535 ; encoding: [0xff,0xff,0x81,0xbf]
30
31s_branch 2
32// GCN: s_branch 2 ; encoding: [0x02,0x00,0x82,0xbf]
33
34s_cbranch_scc0 3
35// GCN: s_cbranch_scc0 3 ; encoding: [0x03,0x00,0x84,0xbf]
36
37s_cbranch_scc1 4
38// GCN: s_cbranch_scc1 4 ; encoding: [0x04,0x00,0x85,0xbf]
39
40s_cbranch_vccz 5
41// GCN: s_cbranch_vccz 5 ; encoding: [0x05,0x00,0x86,0xbf]
42
43s_cbranch_vccnz 6
44// GCN: s_cbranch_vccnz 6 ; encoding: [0x06,0x00,0x87,0xbf]
45
46s_cbranch_execz 7
47// GCN: s_cbranch_execz 7 ; encoding: [0x07,0x00,0x88,0xbf]
48
49s_cbranch_execnz 8
50// GCN: s_cbranch_execnz 8 ; encoding: [0x08,0x00,0x89,0xbf]
51
52s_cbranch_cdbgsys 9
53// GCN: s_cbranch_cdbgsys 9 ; encoding: [0x09,0x00,0x97,0xbf]
54
55s_cbranch_cdbgsys_and_user 10
56// GCN: s_cbranch_cdbgsys_and_user 10 ; encoding: [0x0a,0x00,0x9a,0xbf]
57
58s_cbranch_cdbgsys_or_user 11
59// GCN: s_cbranch_cdbgsys_or_user 11 ; encoding: [0x0b,0x00,0x99,0xbf]
60
61s_cbranch_cdbguser 12
62// GCN: s_cbranch_cdbguser 12 ; encoding: [0x0c,0x00,0x98,0xbf]
63
64s_barrier
65// GCN: s_barrier ; encoding: [0x00,0x00,0x8a,0xbf]
66
67//===----------------------------------------------------------------------===//
68// s_waitcnt
69//===----------------------------------------------------------------------===//
70
71s_waitcnt 0
72// GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
73
74s_waitcnt vmcnt(0) & expcnt(0) & lgkmcnt(0)
75// GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
76
77s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0)
78// GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
79
80s_waitcnt vmcnt(0), expcnt(0), lgkmcnt(0)
81// GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
82
83s_waitcnt vmcnt(1)
84// GCN: s_waitcnt vmcnt(1) ; encoding: [0x71,0x0f,0x8c,0xbf]
85
86s_waitcnt vmcnt(9)
87// GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf]
88
89s_waitcnt vmcnt(15)
90// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
91
92s_waitcnt vmcnt_sat(9)
93// GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf]
94
95s_waitcnt vmcnt_sat(15)
96// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
97
98s_waitcnt vmcnt_sat(16)
99// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
100
101s_waitcnt expcnt(2)
102// GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf]
103
104s_waitcnt expcnt(7)
105// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
106
107s_waitcnt expcnt_sat(2)
108// GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf]
109
110s_waitcnt expcnt_sat(7)
111// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
112
113s_waitcnt expcnt_sat(0xFFFF0000)
114// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
115
116s_waitcnt lgkmcnt(3)
117// GCN: s_waitcnt lgkmcnt(3) ; encoding: [0x7f,0x03,0x8c,0xbf]
118
119s_waitcnt lgkmcnt(9)
120// GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf]
121
122s_waitcnt lgkmcnt(15)
123// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
124
125s_waitcnt vmcnt(0), expcnt(0)
126// GCN: s_waitcnt vmcnt(0) expcnt(0) ; encoding: [0x00,0x0f,0x8c,0xbf]
127
128s_waitcnt lgkmcnt_sat(3)
129// GCN: s_waitcnt lgkmcnt(3) ; encoding: [0x7f,0x03,0x8c,0xbf]
130
131s_waitcnt lgkmcnt_sat(9)
132// GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf]
133
134s_waitcnt lgkmcnt_sat(15)
135// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
136
137s_waitcnt lgkmcnt_sat(16)
138// GCN: s_waitcnt vmcnt(15) expcnt(7) lgkmcnt(15) ; encoding: [0x7f,0x0f,0x8c,0xbf]
139
140x=1
141s_waitcnt lgkmcnt_sat(x+1)
142// GCN: s_waitcnt lgkmcnt(2)            ; encoding: [0x7f,0x02,0x8c,0xbf]
143
144s_waitcnt lgkmcnt_sat(1+x)
145// GCN: s_waitcnt lgkmcnt(2)            ; encoding: [0x7f,0x02,0x8c,0xbf]
146
147s_waitcnt x+1
148// GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf]
149
150s_waitcnt 1+x
151// GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf]
152
153lgkmcnt_sat=1
154s_waitcnt lgkmcnt_sat
155// GCN: s_waitcnt vmcnt(1) expcnt(0) lgkmcnt(0) ; encoding: [0x01,0x00,0x8c,0xbf]
156
157s_waitcnt lgkmcnt_sat+1
158// GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf]
159
160//===----------------------------------------------------------------------===//
161// misc sopp instructions
162//===----------------------------------------------------------------------===//
163
164s_sethalt 9
165// GCN: s_sethalt 9 ; encoding: [0x09,0x00,0x8d,0xbf]
166
167s_setkill 7
168// GCN: s_setkill 7 ; encoding: [0x07,0x00,0x8b,0xbf]
169
170s_sleep 10
171// GCN: s_sleep 10 ; encoding: [0x0a,0x00,0x8e,0xbf]
172
173s_setprio 1
174// GCN: s_setprio 1 ; encoding: [0x01,0x00,0x8f,0xbf]
175
176//===----------------------------------------------------------------------===//
177// s_sendmsg
178//===----------------------------------------------------------------------===//
179
180s_sendmsg 0x1
181// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
182
183s_sendmsg sendmsg(1)
184// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
185
186s_sendmsg sendmsg(MSG_INTERRUPT)
187// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
188
189s_sendmsg 0x12
190// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
191
192s_sendmsg sendmsg(2, 1)
193// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
194
195s_sendmsg sendmsg(2, GS_OP_CUT)
196// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
197
198s_sendmsg sendmsg(MSG_GS, GS_OP_CUT)
199// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
200
201s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0)
202// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
203
204s_sendmsg sendmsg(MSG_GS, 1)
205// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
206
207s_sendmsg sendmsg(MSG_GS, 1, 1)
208// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 1) ; encoding: [0x12,0x01,0x90,0xbf]
209
210s_sendmsg 0x122
211// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf]
212
213s_sendmsg sendmsg(2, 2, 1)
214// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf]
215
216s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1)
217// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf]
218
219s_sendmsg 0x232
220// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
221
222s_sendmsg sendmsg(2, 3, 2)
223// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
224
225s_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]
227
228s_sendmsg 0x3
229// GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf]
230
231s_sendmsg sendmsg(3, 0)
232// GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf]
233
234s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP)
235// GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf]
236
237s_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]
240
241s_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]
244
245s_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]
248
249s_sendmsg 0x1f
250// GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf]
251
252s_sendmsg sendmsg(15, 1)
253// GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf]
254
255s_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]
257
258s_sendmsghalt 3
259// GCN: s_sendmsghalt sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x91,0xbf]
260
261s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1)
262// GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x91,0xbf]
263
264//===----------------------------------------------------------------------===//
265// s_sendmsg with a numeric message id (no validation)
266//===----------------------------------------------------------------------===//
267
268s_sendmsg 2
269// GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
270
271s_sendmsg 9
272// GCN: s_sendmsg sendmsg(9, 0, 0) ; encoding: [0x09,0x00,0x90,0xbf]
273
274s_sendmsg 11
275// GCN: s_sendmsg sendmsg(11, 0, 0) ; encoding: [0x0b,0x00,0x90,0xbf]
276
277s_sendmsg 0x6f
278// GCN: s_sendmsg sendmsg(15, 6, 0) ; encoding: [0x6f,0x00,0x90,0xbf]
279
280s_sendmsg sendmsg(1, 3)
281// GCN: s_sendmsg sendmsg(1, 3, 0)      ; encoding: [0x31,0x00,0x90,0xbf]
282
283s_sendmsg sendmsg(1, 3, 2)
284// GCN: s_sendmsg sendmsg(1, 3, 2)      ; encoding: [0x31,0x02,0x90,0xbf]
285
286s_sendmsg sendmsg(2, 0, 1)
287// GCN: s_sendmsg sendmsg(2, 0, 1)      ; encoding: [0x02,0x01,0x90,0xbf]
288
289s_sendmsg sendmsg(15, 7, 3)
290// GCN: s_sendmsg sendmsg(15, 7, 3)     ; encoding: [0x7f,0x03,0x90,0xbf]
291
292s_sendmsg 4567
293// GCN: s_sendmsg 4567                  ; encoding: [0xd7,0x11,0x90,0xbf]
294
295//===----------------------------------------------------------------------===//
296// s_sendmsg with expressions
297//===----------------------------------------------------------------------===//
298
299sendmsg=2
300s_sendmsg sendmsg
301// GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
302
303sendmsg=1
304s_sendmsg sendmsg+1
305// GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
306
307s_sendmsg 1+sendmsg
308// GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
309
310msg=1
311s_sendmsg sendmsg(msg)
312// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
313
314msg=0
315s_sendmsg sendmsg(msg+1)
316// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
317
318msg=0
319s_sendmsg sendmsg(1+msg)
320// GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
321
322msg=2
323op=1
324s_sendmsg sendmsg(msg, op)
325// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
326
327msg=1
328op=0
329s_sendmsg sendmsg(msg+1, op+1)
330// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
331
332msg=1
333op=0
334s_sendmsg sendmsg(1+msg, 1+op)
335// GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
336
337msg=1
338op=2
339stream=1
340s_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]
342
343msg=1
344op=2
345stream=1
346s_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]
348
349MSG_GS=-1
350GS_OP_EMIT=-1
351s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1)
352// GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x91,0xbf]
353
354//===----------------------------------------------------------------------===//
355// misc sopp instructions
356//===----------------------------------------------------------------------===//
357
358s_trap 4
359// GCN: s_trap 4 ; encoding: [0x04,0x00,0x92,0xbf]
360
361s_icache_inv
362// GCN: s_icache_inv ; encoding: [0x00,0x00,0x93,0xbf]
363
364s_incperflevel 5
365// GCN: s_incperflevel 5 ; encoding: [0x05,0x00,0x94,0xbf]
366
367s_decperflevel 6
368// GCN: s_decperflevel 6 ; encoding: [0x06,0x00,0x95,0xbf]
369
370s_ttracedata
371// GCN: s_ttracedata ; encoding: [0x00,0x00,0x96,0xbf]
372
373s_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
376
377s_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
380
381s_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
384
385s_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
388
389s_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
392
393s_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
396
397s_wakeup
398// VI: s_wakeup ; encoding: [0x00,0x00,0x83,0xbf]
399// NOSICI: :[[@LINE-2]]:{{[0-9]+}}: error: instruction not supported on this GPU
400
401//===----------------------------------------------------------------------===//
402// absolute expressions as branch offsets
403//===----------------------------------------------------------------------===//
404
405offset = 3
406s_branch 1+offset
407// GCN: s_branch 4 ; encoding: [0x04,0x00,0x82,0xbf]
408
409offset = 3
410s_branch offset+1
411// GCN: s_branch 4 ; encoding: [0x04,0x00,0x82,0xbf]
412