[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / AMDGPU / sopp.s
bloba8e2c451a72f3fdc91287f9c518f8620a79fb839
1 // RUN: not llvm-mc -arch=amdgcn -show-encoding %s | FileCheck --check-prefixes=GCN,SI %s
2 // RUN: not llvm-mc -arch=amdgcn %s 2>&1 | FileCheck %s --check-prefix=NOSICI --implicit-check-not=error:
3 // RUN: llvm-mc -arch=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_branch 2
26 // GCN: s_branch 2 ; encoding: [0x02,0x00,0x82,0xbf]
28 s_cbranch_scc0 3
29 // GCN: s_cbranch_scc0 3 ; encoding: [0x03,0x00,0x84,0xbf]
31 s_cbranch_scc1 4
32 // GCN: s_cbranch_scc1 4 ; encoding: [0x04,0x00,0x85,0xbf]
34 s_cbranch_vccz 5
35 // GCN: s_cbranch_vccz 5 ; encoding: [0x05,0x00,0x86,0xbf]
37 s_cbranch_vccnz 6
38 // GCN: s_cbranch_vccnz 6 ; encoding: [0x06,0x00,0x87,0xbf]
40 s_cbranch_execz 7
41 // GCN: s_cbranch_execz 7 ; encoding: [0x07,0x00,0x88,0xbf]
43 s_cbranch_execnz 8
44 // GCN: s_cbranch_execnz 8 ; encoding: [0x08,0x00,0x89,0xbf]
46 s_cbranch_cdbgsys 9
47 // GCN: s_cbranch_cdbgsys 9 ; encoding: [0x09,0x00,0x97,0xbf]
49 s_cbranch_cdbgsys_and_user 10
50 // GCN: s_cbranch_cdbgsys_and_user 10 ; encoding: [0x0a,0x00,0x9a,0xbf]
52 s_cbranch_cdbgsys_or_user 11
53 // GCN: s_cbranch_cdbgsys_or_user 11 ; encoding: [0x0b,0x00,0x99,0xbf]
55 s_cbranch_cdbguser 12
56 // GCN: s_cbranch_cdbguser 12 ; encoding: [0x0c,0x00,0x98,0xbf]
58 s_barrier
59 // GCN: s_barrier ; encoding: [0x00,0x00,0x8a,0xbf]
61 //===----------------------------------------------------------------------===//
62 // s_waitcnt
63 //===----------------------------------------------------------------------===//
65 s_waitcnt 0
66 // GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
68 s_waitcnt vmcnt(0) & expcnt(0) & lgkmcnt(0)
69 // GCN: s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(0) ; encoding: [0x00,0x00,0x8c,0xbf]
71 s_waitcnt vmcnt(0) expcnt(0) lgkmcnt(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(1)
78 // GCN: s_waitcnt vmcnt(1) ; encoding: [0x71,0x0f,0x8c,0xbf]
80 s_waitcnt vmcnt(9)
81 // GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf]
83 s_waitcnt vmcnt(15)
84 // GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
86 s_waitcnt vmcnt_sat(9)
87 // GCN: s_waitcnt vmcnt(9) ; encoding: [0x79,0x0f,0x8c,0xbf]
89 s_waitcnt vmcnt_sat(15)
90 // GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
92 s_waitcnt vmcnt_sat(16)
93 // GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
95 s_waitcnt expcnt(2)
96 // GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf]
98 s_waitcnt expcnt(7)
99 // GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
101 s_waitcnt expcnt_sat(2)
102 // GCN: s_waitcnt expcnt(2) ; encoding: [0x2f,0x0f,0x8c,0xbf]
104 s_waitcnt expcnt_sat(7)
105 // GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
107 s_waitcnt expcnt_sat(0xFFFF0000)
108 // GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
110 s_waitcnt lgkmcnt(3)
111 // GCN: s_waitcnt lgkmcnt(3) ; encoding: [0x7f,0x03,0x8c,0xbf]
113 s_waitcnt lgkmcnt(9)
114 // GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf]
116 s_waitcnt lgkmcnt(15)
117 // GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
119 s_waitcnt vmcnt(0), expcnt(0)
120 // GCN: s_waitcnt vmcnt(0) expcnt(0) ; encoding: [0x00,0x0f,0x8c,0xbf]
122 s_waitcnt lgkmcnt_sat(3)
123 // GCN: s_waitcnt lgkmcnt(3) ; encoding: [0x7f,0x03,0x8c,0xbf]
125 s_waitcnt lgkmcnt_sat(9)
126 // GCN: s_waitcnt lgkmcnt(9) ; encoding: [0x7f,0x09,0x8c,0xbf]
128 s_waitcnt lgkmcnt_sat(15)
129 // GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
131 s_waitcnt lgkmcnt_sat(16)
132 // GCN: s_waitcnt ; encoding: [0x7f,0x0f,0x8c,0xbf]
135 s_waitcnt lgkmcnt_sat(x+1)
136 // GCN: s_waitcnt lgkmcnt(2) ; encoding: [0x7f,0x02,0x8c,0xbf]
138 s_waitcnt lgkmcnt_sat(1+x)
139 // GCN: s_waitcnt lgkmcnt(2) ; encoding: [0x7f,0x02,0x8c,0xbf]
141 s_waitcnt x+1
142 // GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf]
144 s_waitcnt 1+x
145 // GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf]
147 lgkmcnt_sat=1
148 s_waitcnt lgkmcnt_sat
149 // GCN: s_waitcnt vmcnt(1) expcnt(0) lgkmcnt(0) ; encoding: [0x01,0x00,0x8c,0xbf]
151 s_waitcnt lgkmcnt_sat+1
152 // GCN: s_waitcnt vmcnt(2) expcnt(0) lgkmcnt(0) ; encoding: [0x02,0x00,0x8c,0xbf]
154 //===----------------------------------------------------------------------===//
155 // misc sopp instructions
156 //===----------------------------------------------------------------------===//
158 s_sethalt 9
159 // GCN: s_sethalt 9 ; encoding: [0x09,0x00,0x8d,0xbf]
161 s_setkill 7
162 // GCN: s_setkill 7 ; encoding: [0x07,0x00,0x8b,0xbf]
164 s_sleep 10
165 // GCN: s_sleep 10 ; encoding: [0x0a,0x00,0x8e,0xbf]
167 s_setprio 1
168 // GCN: s_setprio 1 ; encoding: [0x01,0x00,0x8f,0xbf]
170 //===----------------------------------------------------------------------===//
171 // s_sendmsg
172 //===----------------------------------------------------------------------===//
174 s_sendmsg 0x1
175 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
177 s_sendmsg sendmsg(1)
178 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
180 s_sendmsg sendmsg(MSG_INTERRUPT)
181 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
183 s_sendmsg 0x12
184 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
186 s_sendmsg sendmsg(2, 1)
187 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
189 s_sendmsg sendmsg(2, GS_OP_CUT)
190 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
192 s_sendmsg sendmsg(MSG_GS, GS_OP_CUT)
193 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
195 s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0)
196 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
198 s_sendmsg sendmsg(MSG_GS, 1)
199 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
201 s_sendmsg sendmsg(MSG_GS, 1, 1)
202 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 1) ; encoding: [0x12,0x01,0x90,0xbf]
204 s_sendmsg 0x122
205 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf]
207 s_sendmsg sendmsg(2, 2, 1)
208 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf]
210 s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1)
211 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x90,0xbf]
213 s_sendmsg 0x232
214 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
216 s_sendmsg sendmsg(2, 3, 2)
217 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
219 s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2)
220 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
222 s_sendmsg 0x3
223 // GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf]
225 s_sendmsg sendmsg(3, 0)
226 // GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf]
228 s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP)
229 // GCN: s_sendmsg sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x90,0xbf]
231 s_sendmsg 0x4
232 // SI: s_sendmsg sendmsg(4, 0, 0) ; encoding: [0x04,0x00,0x90,0xbf]
233 // VI: s_sendmsg sendmsg(MSG_SAVEWAVE) ; encoding: [0x04,0x00,0x90,0xbf]
235 s_sendmsg sendmsg(4)
236 // SI: s_sendmsg sendmsg(4, 0, 0) ; encoding: [0x04,0x00,0x90,0xbf]
237 // VI: s_sendmsg sendmsg(MSG_SAVEWAVE) ; encoding: [0x04,0x00,0x90,0xbf]
239 s_sendmsg sendmsg(MSG_SAVEWAVE)
240 // NOSICI: error: invalid message id
241 // VI: s_sendmsg sendmsg(MSG_SAVEWAVE) ; encoding: [0x04,0x00,0x90,0xbf]
243 s_sendmsg 0x1f
244 // GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf]
246 s_sendmsg sendmsg(15, 1)
247 // GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf]
249 s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT)
250 // GCN: s_sendmsg sendmsg(MSG_SYSMSG, SYSMSG_OP_ECC_ERR_INTERRUPT) ; encoding: [0x1f,0x00,0x90,0xbf]
252 s_sendmsghalt 3
253 // GCN: s_sendmsghalt sendmsg(MSG_GS_DONE, GS_OP_NOP) ; encoding: [0x03,0x00,0x91,0xbf]
255 s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1)
256 // GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x91,0xbf]
258 //===----------------------------------------------------------------------===//
259 // s_sendmsg with a numeric message id (no validation)
260 //===----------------------------------------------------------------------===//
262 s_sendmsg 2
263 // GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
265 s_sendmsg 9
266 // GCN: s_sendmsg sendmsg(9, 0, 0) ; encoding: [0x09,0x00,0x90,0xbf]
268 s_sendmsg 11
269 // GCN: s_sendmsg sendmsg(11, 0, 0) ; encoding: [0x0b,0x00,0x90,0xbf]
271 s_sendmsg 0x6f
272 // GCN: s_sendmsg sendmsg(15, 6, 0) ; encoding: [0x6f,0x00,0x90,0xbf]
274 s_sendmsg sendmsg(1, 3)
275 // GCN: s_sendmsg sendmsg(1, 3, 0) ; encoding: [0x31,0x00,0x90,0xbf]
277 s_sendmsg sendmsg(1, 3, 2)
278 // GCN: s_sendmsg sendmsg(1, 3, 2) ; encoding: [0x31,0x02,0x90,0xbf]
280 s_sendmsg sendmsg(2, 0, 1)
281 // GCN: s_sendmsg sendmsg(2, 0, 1) ; encoding: [0x02,0x01,0x90,0xbf]
283 s_sendmsg sendmsg(15, 7, 3)
284 // GCN: s_sendmsg sendmsg(15, 7, 3) ; encoding: [0x7f,0x03,0x90,0xbf]
286 s_sendmsg 4567
287 // GCN: s_sendmsg 4567 ; encoding: [0xd7,0x11,0x90,0xbf]
289 //===----------------------------------------------------------------------===//
290 // s_sendmsg with expressions
291 //===----------------------------------------------------------------------===//
293 sendmsg=2
294 s_sendmsg sendmsg
295 // GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
297 sendmsg=1
298 s_sendmsg sendmsg+1
299 // GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
301 s_sendmsg 1+sendmsg
302 // GCN: s_sendmsg sendmsg(2, 0, 0) ; encoding: [0x02,0x00,0x90,0xbf]
304 msg=1
305 s_sendmsg sendmsg(msg)
306 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
308 msg=0
309 s_sendmsg sendmsg(msg+1)
310 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
312 msg=0
313 s_sendmsg sendmsg(1+msg)
314 // GCN: s_sendmsg sendmsg(MSG_INTERRUPT) ; encoding: [0x01,0x00,0x90,0xbf]
316 msg=2
317 op=1
318 s_sendmsg sendmsg(msg, op)
319 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
321 msg=1
322 op=0
323 s_sendmsg sendmsg(msg+1, op+1)
324 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
326 msg=1
327 op=0
328 s_sendmsg sendmsg(1+msg, 1+op)
329 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_CUT, 0) ; encoding: [0x12,0x00,0x90,0xbf]
331 msg=1
332 op=2
333 stream=1
334 s_sendmsg sendmsg(msg+1, op+1, stream+1)
335 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
337 msg=1
338 op=2
339 stream=1
340 s_sendmsg sendmsg(1+msg, 1+op, 1+stream)
341 // GCN: s_sendmsg sendmsg(MSG_GS, GS_OP_EMIT_CUT, 2) ; encoding: [0x32,0x02,0x90,0xbf]
343 MSG_GS=-1
344 GS_OP_EMIT=-1
345 s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1)
346 // GCN: s_sendmsghalt sendmsg(MSG_GS, GS_OP_EMIT, 1) ; encoding: [0x22,0x01,0x91,0xbf]
348 //===----------------------------------------------------------------------===//
349 // misc sopp instructions
350 //===----------------------------------------------------------------------===//
352 s_trap 4
353 // GCN: s_trap 4 ; encoding: [0x04,0x00,0x92,0xbf]
355 s_icache_inv
356 // GCN: s_icache_inv ; encoding: [0x00,0x00,0x93,0xbf]
358 s_incperflevel 5
359 // GCN: s_incperflevel 5 ; encoding: [0x05,0x00,0x94,0xbf]
361 s_decperflevel 6
362 // GCN: s_decperflevel 6 ; encoding: [0x06,0x00,0x95,0xbf]
364 s_ttracedata
365 // GCN: s_ttracedata ; encoding: [0x00,0x00,0x96,0xbf]
367 s_set_gpr_idx_off
368 // VI: s_set_gpr_idx_off ; encoding: [0x00,0x00,0x9c,0xbf]
369 // NOSICI: error: instruction not supported on this GPU
371 s_set_gpr_idx_mode 0
372 // VI: s_set_gpr_idx_mode gpr_idx() ; encoding: [0x00,0x00,0x9d,0xbf]
373 // NOSICI: error: instruction not supported on this GPU
375 s_set_gpr_idx_mode gpr_idx()
376 // VI: s_set_gpr_idx_mode gpr_idx() ; encoding: [0x00,0x00,0x9d,0xbf]
377 // NOSICI: error: instruction not supported on this GPU
379 s_set_gpr_idx_mode 15
380 // VI: s_set_gpr_idx_mode gpr_idx(SRC0,SRC1,SRC2,DST) ; encoding: [0x0f,0x00,0x9d,0xbf]
381 // NOSICI: error: instruction not supported on this GPU
383 s_set_gpr_idx_mode gpr_idx(SRC2,SRC1,SRC0,DST)
384 // VI: s_set_gpr_idx_mode gpr_idx(SRC0,SRC1,SRC2,DST) ; encoding: [0x0f,0x00,0x9d,0xbf]
385 // NOSICI: error: instruction not supported on this GPU
387 s_endpgm_saved
388 // VI: s_endpgm_saved ; encoding: [0x00,0x00,0x9b,0xbf]
389 // NOSICI: error: instruction not supported on this GPU
391 s_wakeup
392 // VI: s_wakeup ; encoding: [0x00,0x00,0x83,0xbf]
393 // NOSICI: error: instruction not supported on this GPU
395 //===----------------------------------------------------------------------===//
396 // absolute expressions as branch offsets
397 //===----------------------------------------------------------------------===//
399 offset = 3
400 s_branch 1+offset
401 // GCN: s_branch 4 ; encoding: [0x04,0x00,0x82,0xbf]
403 offset = 3
404 s_branch offset+1
405 // GCN: s_branch 4 ; encoding: [0x04,0x00,0x82,0xbf]