blob: 523c5ac7179ccf17bedd0ad5925cb60dc904ac7f [file] [log] [blame]
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001=====================================
2Syntax of AMDGPU Instruction Operands
3=====================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +00004
5.. contents::
6 :local:
7
8Conventions
9===========
10
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +000011The following notation is used throughout this document:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +000012
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +000013 =================== =============================================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +000014 Notation Description
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +000015 =================== =============================================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +000016 {0..N} Any integer value in the range from 0 to N (inclusive).
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +000017 <x> Syntax and meaning of *x* is explained elsewhere.
18 =================== =============================================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +000019
20.. _amdgpu_syn_operands:
21
22Operands
23========
24
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +000025.. _amdgpu_synid_v:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +000026
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +000027v
28-
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +000029
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +000030Vector registers. There are 256 32-bit vector registers.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +000031
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +000032A sequence of *vector* registers may be used to operate with more than 32 bits of data.
33
34Assembler currently supports sequences of 1, 2, 3, 4, 8 and 16 *vector* registers.
35
36 =================================================== ====================================================================
37 Syntax Description
38 =================================================== ====================================================================
39 **v**\<N> A single 32-bit *vector* register.
40
41 *N* must be a decimal integer number.
42 **v[**\ <N>\ **]** A single 32-bit *vector* register.
43
44 *N* may be specified as an
45 :ref:`integer number<amdgpu_synid_integer_number>`
46 or an :ref:`absolute expression<amdgpu_synid_absolute_expression>`.
47 **v[**\ <N>:<K>\ **]** A sequence of (\ *K-N+1*\ ) *vector* registers.
48
49 *N* and *K* may be specified as
50 :ref:`integer numbers<amdgpu_synid_integer_number>`
51 or :ref:`absolute expressions<amdgpu_synid_absolute_expression>`.
52 **[v**\ <N>, \ **v**\ <N+1>, ... **v**\ <K>\ **]** A sequence of (\ *K-N+1*\ ) *vector* registers.
53
54 Register indices must be specified as decimal integer numbers.
55 =================================================== ====================================================================
56
57Note. *N* and *K* must satisfy the following conditions:
58
59* *N* <= *K*.
60* 0 <= *N* <= 255.
61* 0 <= *K* <= 255.
62* *K-N+1* must be equal to 1, 2, 3, 4, 8 or 16.
63
64Examples:
65
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +000066.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +000067
68 v255
69 v[0]
70 v[0:1]
71 v[1:1]
72 v[0:3]
73 v[2*2]
74 v[1-1:2-1]
75 [v252]
76 [v252,v253,v254,v255]
77
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +000078.. _amdgpu_synid_nsa:
79
80*Image* instructions may use special *NSA* (Non-Sequential Address) syntax for *image addresses*:
81
82 =================================================== ====================================================================
83 Syntax Description
84 =================================================== ====================================================================
85 **[v**\ <A>, \ **v**\ <B>, ... **v**\ <X>\ **]** A sequence of *vector* registers. At least one register
86 must be specified.
87
88 In contrast with standard syntax described above, registers in
89 this sequence are not required to have consecutive indices.
90 Moreover, the same register may appear in the list more than once.
91 =================================================== ====================================================================
92
93Note. Reqister indices must be in the range 0..255. They must be specified as decimal integer numbers.
94
95Examples:
96
97.. parsed-literal::
98
99 [v32,v1,v2]
100 [v4,v4,v4,v4]
101
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000102.. _amdgpu_synid_s:
103
104s
105-
106
107Scalar 32-bit registers. The number of available *scalar* registers depends on GPU:
108
109 ======= ============================
110 GPU Number of *scalar* registers
111 ======= ============================
112 GFX7 104
113 GFX8 102
114 GFX9 102
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000115 GFX10 106
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000116 ======= ============================
117
118A sequence of *scalar* registers may be used to operate with more than 32 bits of data.
119Assembler currently supports sequences of 1, 2, 4, 8 and 16 *scalar* registers.
120
121Pairs of *scalar* registers must be even-aligned (the first register must be even).
122Sequences of 4 and more *scalar* registers must be quad-aligned.
123
124 ======================================================== ====================================================================
125 Syntax Description
126 ======================================================== ====================================================================
127 **s**\ <N> A single 32-bit *scalar* register.
128
129 *N* must be a decimal integer number.
130 **s[**\ <N>\ **]** A single 32-bit *scalar* register.
131
132 *N* may be specified as an
133 :ref:`integer number<amdgpu_synid_integer_number>`
134 or an :ref:`absolute expression<amdgpu_synid_absolute_expression>`.
135 **s[**\ <N>:<K>\ **]** A sequence of (\ *K-N+1*\ ) *scalar* registers.
136
137 *N* and *K* may be specified as
138 :ref:`integer numbers<amdgpu_synid_integer_number>`
139 or :ref:`absolute expressions<amdgpu_synid_absolute_expression>`.
140 **[s**\ <N>, \ **s**\ <N+1>, ... **s**\ <K>\ **]** A sequence of (\ *K-N+1*\ ) *scalar* registers.
141
142 Register indices must be specified as decimal integer numbers.
143 ======================================================== ====================================================================
144
145Note. *N* and *K* must satisfy the following conditions:
146
147* *N* must be properly aligned based on sequence size.
148* *N* <= *K*.
149* 0 <= *N* < *SMAX*\ , where *SMAX* is the number of available *scalar* registers.
150* 0 <= *K* < *SMAX*\ , where *SMAX* is the number of available *scalar* registers.
151* *K-N+1* must be equal to 1, 2, 4, 8 or 16.
152
153Examples:
154
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000155.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000156
157 s0
158 s[0]
159 s[0:1]
160 s[1:1]
161 s[0:3]
162 s[2*2]
163 s[1-1:2-1]
164 [s4]
165 [s4,s5,s6,s7]
166
167Examples of *scalar* registers with an invalid alignment:
168
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000169.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000170
171 s[1:2]
172 s[2:5]
173
174.. _amdgpu_synid_trap:
175
176trap
177----
178
179A set of trap handler registers:
180
181* :ref:`ttmp<amdgpu_synid_ttmp>`
182* :ref:`tba<amdgpu_synid_tba>`
183* :ref:`tma<amdgpu_synid_tma>`
184
185.. _amdgpu_synid_ttmp:
186
187ttmp
188----
189
190Trap handler temporary scalar registers, 32-bits wide.
191The number of available *ttmp* registers depends on GPU:
192
193 ======= ===========================
194 GPU Number of *ttmp* registers
195 ======= ===========================
196 GFX7 12
197 GFX8 12
198 GFX9 16
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000199 GFX10 16
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000200 ======= ===========================
201
202A sequence of *ttmp* registers may be used to operate with more than 32 bits of data.
203Assembler currently supports sequences of 1, 2, 4, 8 and 16 *ttmp* registers.
204
205Pairs of *ttmp* registers must be even-aligned (the first register must be even).
206Sequences of 4 and more *ttmp* registers must be quad-aligned.
207
208 ============================================================= ====================================================================
209 Syntax Description
210 ============================================================= ====================================================================
211 **ttmp**\ <N> A single 32-bit *ttmp* register.
212
213 *N* must be a decimal integer number.
214 **ttmp[**\ <N>\ **]** A single 32-bit *ttmp* register.
215
216 *N* may be specified as an
217 :ref:`integer number<amdgpu_synid_integer_number>`
218 or an :ref:`absolute expression<amdgpu_synid_absolute_expression>`.
219 **ttmp[**\ <N>:<K>\ **]** A sequence of (\ *K-N+1*\ ) *ttmp* registers.
220
221 *N* and *K* may be specified as
222 :ref:`integer numbers<amdgpu_synid_integer_number>`
223 or :ref:`absolute expressions<amdgpu_synid_absolute_expression>`.
224 **[ttmp**\ <N>, \ **ttmp**\ <N+1>, ... **ttmp**\ <K>\ **]** A sequence of (\ *K-N+1*\ ) *ttmp* registers.
225
226 Register indices must be specified as decimal integer numbers.
227 ============================================================= ====================================================================
228
229Note. *N* and *K* must satisfy the following conditions:
230
231* *N* must be properly aligned based on sequence size.
232* *N* <= *K*.
233* 0 <= *N* < *TMAX*, where *TMAX* is the number of available *ttmp* registers.
234* 0 <= *K* < *TMAX*, where *TMAX* is the number of available *ttmp* registers.
235* *K-N+1* must be equal to 1, 2, 4, 8 or 16.
236
237Examples:
238
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000239.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000240
241 ttmp0
242 ttmp[0]
243 ttmp[0:1]
244 ttmp[1:1]
245 ttmp[0:3]
246 ttmp[2*2]
247 ttmp[1-1:2-1]
248 [ttmp4]
249 [ttmp4,ttmp5,ttmp6,ttmp7]
250
251Examples of *ttmp* registers with an invalid alignment:
252
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000253.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000254
255 ttmp[1:2]
256 ttmp[2:5]
257
258.. _amdgpu_synid_tba:
259
260tba
261---
262
263Trap base address, 64-bits wide. Holds the pointer to the current trap handler program.
264
265 ================== ======================================================================= =============
266 Syntax Description Availability
267 ================== ======================================================================= =============
268 tba 64-bit *trap base address* register. GFX7, GFX8
269 [tba] 64-bit *trap base address* register (an alternative syntax). GFX7, GFX8
270 [tba_lo,tba_hi] 64-bit *trap base address* register (an alternative syntax). GFX7, GFX8
271 ================== ======================================================================= =============
272
273High and low 32 bits of *trap base address* may be accessed as separate registers:
274
275 ================== ======================================================================= =============
276 Syntax Description Availability
277 ================== ======================================================================= =============
278 tba_lo Low 32 bits of *trap base address* register. GFX7, GFX8
279 tba_hi High 32 bits of *trap base address* register. GFX7, GFX8
280 [tba_lo] Low 32 bits of *trap base address* register (an alternative syntax). GFX7, GFX8
281 [tba_hi] High 32 bits of *trap base address* register (an alternative syntax). GFX7, GFX8
282 ================== ======================================================================= =============
283
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000284Note that *tba*, *tba_lo* and *tba_hi* are not accessible as assembler registers in GFX9 and GFX10,
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000285but *tba* is readable/writable with the help of *s_get_reg* and *s_set_reg* instructions.
286
287.. _amdgpu_synid_tma:
288
289tma
290---
291
292Trap memory address, 64-bits wide.
293
294 ================= ======================================================================= ==================
295 Syntax Description Availability
296 ================= ======================================================================= ==================
297 tma 64-bit *trap memory address* register. GFX7, GFX8
298 [tma] 64-bit *trap memory address* register (an alternative syntax). GFX7, GFX8
299 [tma_lo,tma_hi] 64-bit *trap memory address* register (an alternative syntax). GFX7, GFX8
300 ================= ======================================================================= ==================
301
302High and low 32 bits of *trap memory address* may be accessed as separate registers:
303
304 ================= ======================================================================= ==================
305 Syntax Description Availability
306 ================= ======================================================================= ==================
307 tma_lo Low 32 bits of *trap memory address* register. GFX7, GFX8
308 tma_hi High 32 bits of *trap memory address* register. GFX7, GFX8
309 [tma_lo] Low 32 bits of *trap memory address* register (an alternative syntax). GFX7, GFX8
310 [tma_hi] High 32 bits of *trap memory address* register (an alternative syntax). GFX7, GFX8
311 ================= ======================================================================= ==================
312
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000313Note that *tma*, *tma_lo* and *tma_hi* are not accessible as assembler registers in GFX9 and GFX10,
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000314but *tma* is readable/writable with the help of *s_get_reg* and *s_set_reg* instructions.
315
316.. _amdgpu_synid_flat_scratch:
317
318flat_scratch
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000319------------
320
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000321Flat scratch address, 64-bits wide. Holds the base address of scratch memory.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000322
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000323 ================================== ================================================================
324 Syntax Description
325 ================================== ================================================================
326 flat_scratch 64-bit *flat scratch* address register.
327 [flat_scratch] 64-bit *flat scratch* address register (an alternative syntax).
328 [flat_scratch_lo,flat_scratch_hi] 64-bit *flat scratch* address register (an alternative syntax).
329 ================================== ================================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000330
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000331High and low 32 bits of *flat scratch* address may be accessed as separate registers:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000332
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000333 ========================= =========================================================================
334 Syntax Description
335 ========================= =========================================================================
336 flat_scratch_lo Low 32 bits of *flat scratch* address register.
337 flat_scratch_hi High 32 bits of *flat scratch* address register.
338 [flat_scratch_lo] Low 32 bits of *flat scratch* address register (an alternative syntax).
339 [flat_scratch_hi] High 32 bits of *flat scratch* address register (an alternative syntax).
340 ========================= =========================================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000341
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000342.. _amdgpu_synid_xnack:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000343
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000344xnack
345-----
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000346
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000347Xnack mask, 64-bits wide. Holds a 64-bit mask of which threads
348received an *XNACK* due to a vector memory operation.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000349
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000350.. WARNING:: GFX7 does not support *xnack* feature. For availability of this feature in other GPUs, refer :ref:`this table<amdgpu-processors>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000351
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000352\
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000353
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000354 ============================== =====================================================
355 Syntax Description
356 ============================== =====================================================
357 xnack_mask 64-bit *xnack mask* register.
358 [xnack_mask] 64-bit *xnack mask* register (an alternative syntax).
359 [xnack_mask_lo,xnack_mask_hi] 64-bit *xnack mask* register (an alternative syntax).
360 ============================== =====================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000361
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000362High and low 32 bits of *xnack mask* may be accessed as separate registers:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000363
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000364 ===================== ==============================================================
365 Syntax Description
366 ===================== ==============================================================
367 xnack_mask_lo Low 32 bits of *xnack mask* register.
368 xnack_mask_hi High 32 bits of *xnack mask* register.
369 [xnack_mask_lo] Low 32 bits of *xnack mask* register (an alternative syntax).
370 [xnack_mask_hi] High 32 bits of *xnack mask* register (an alternative syntax).
371 ===================== ==============================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000372
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000373.. _amdgpu_synid_vcc:
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000374.. _amdgpu_synid_vcc_lo:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000375
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000376vcc
377---
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000378
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000379Vector condition code, 64-bits wide. A bit mask with one bit per thread;
380it holds the result of a vector compare operation.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000381
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000382Note that GFX10 H/W does not use high 32 bits of *vcc* in *wave32* mode.
383
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000384 ================ =========================================================================
385 Syntax Description
386 ================ =========================================================================
387 vcc 64-bit *vector condition code* register.
388 [vcc] 64-bit *vector condition code* register (an alternative syntax).
389 [vcc_lo,vcc_hi] 64-bit *vector condition code* register (an alternative syntax).
390 ================ =========================================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000391
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000392High and low 32 bits of *vector condition code* may be accessed as separate registers:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000393
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000394 ================ =========================================================================
395 Syntax Description
396 ================ =========================================================================
397 vcc_lo Low 32 bits of *vector condition code* register.
398 vcc_hi High 32 bits of *vector condition code* register.
399 [vcc_lo] Low 32 bits of *vector condition code* register (an alternative syntax).
400 [vcc_hi] High 32 bits of *vector condition code* register (an alternative syntax).
401 ================ =========================================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000402
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000403.. _amdgpu_synid_m0:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000404
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000405m0
406--
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000407
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000408A 32-bit memory register. It has various uses,
409including register indexing and bounds checking.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000410
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000411 =========== ===================================================
412 Syntax Description
413 =========== ===================================================
414 m0 A 32-bit *memory* register.
415 [m0] A 32-bit *memory* register (an alternative syntax).
416 =========== ===================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000417
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000418.. _amdgpu_synid_exec:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000419
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000420exec
421----
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000422
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000423Execute mask, 64-bits wide. A bit mask with one bit per thread,
424which is applied to vector instructions and controls which threads execute
425and which ignore the instruction.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000426
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000427Note that GFX10 H/W does not use high 32 bits of *exec* in *wave32* mode.
428
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000429 ===================== =================================================================
430 Syntax Description
431 ===================== =================================================================
432 exec 64-bit *execute mask* register.
433 [exec] 64-bit *execute mask* register (an alternative syntax).
434 [exec_lo,exec_hi] 64-bit *execute mask* register (an alternative syntax).
435 ===================== =================================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000436
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000437High and low 32 bits of *execute mask* may be accessed as separate registers:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000438
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000439 ===================== =================================================================
440 Syntax Description
441 ===================== =================================================================
442 exec_lo Low 32 bits of *execute mask* register.
443 exec_hi High 32 bits of *execute mask* register.
444 [exec_lo] Low 32 bits of *execute mask* register (an alternative syntax).
445 [exec_hi] High 32 bits of *execute mask* register (an alternative syntax).
446 ===================== =================================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000447
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000448.. _amdgpu_synid_vccz:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000449
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000450vccz
451----
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000452
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000453A single bit flag indicating that the :ref:`vcc<amdgpu_synid_vcc>` is all zeros.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000454
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000455Note. When GFX10 operates in *wave32* mode, this register reflects state of :ref:`vcc_lo<amdgpu_synid_vcc_lo>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000456
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000457.. _amdgpu_synid_execz:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000458
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000459execz
460-----
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000461
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000462A single bit flag indicating that the :ref:`exec<amdgpu_synid_exec>` is all zeros.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000463
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000464Note. When GFX10 operates in *wave32* mode, this register reflects state of :ref:`exec_lo<amdgpu_synid_exec>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000465
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000466.. _amdgpu_synid_scc:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000467
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000468scc
469---
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000470
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000471A single bit flag indicating the result of a scalar compare operation.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000472
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000473.. _amdgpu_synid_lds_direct:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000474
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000475lds_direct
476----------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000477
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000478A special operand which supplies a 32-bit value
479fetched from *LDS* memory using :ref:`m0<amdgpu_synid_m0>` as an address.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000480
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000481.. _amdgpu_synid_null:
482
483null
484----
485
486This is a special operand which may be used as a source or a destination.
487
488When used as a destination, the result of the operation is discarded.
489
490When used as a source, it supplies zero value.
491
492GFX10 only.
493
494.. WARNING:: Due to a H/W bug, this operand cannot be used with VALU instructions in first generation of GFX10.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000495
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000496.. _amdgpu_synid_constant:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000497
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000498constant
499--------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000500
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000501A set of integer and floating-point *inline* constants and values:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000502
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000503* :ref:`iconst<amdgpu_synid_iconst>`
504* :ref:`fconst<amdgpu_synid_fconst>`
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000505* :ref:`ival<amdgpu_synid_ival>`
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000506
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000507In contrast with :ref:`literals<amdgpu_synid_literal>`, these operands are encoded as a part of instruction.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000508
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000509If a number may be encoded as either
510a :ref:`literal<amdgpu_synid_literal>` or
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000511a :ref:`constant<amdgpu_synid_constant>`,
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000512assembler selects the latter encoding as more efficient.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000513
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000514.. _amdgpu_synid_iconst:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000515
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000516iconst
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000517~~~~~~
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000518
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000519An :ref:`integer number<amdgpu_synid_integer_number>`
520encoded as an *inline constant*.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000521
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000522Only a small fraction of integer numbers may be encoded as *inline constants*.
523They are enumerated in the table below.
524Other integer numbers have to be encoded as :ref:`literals<amdgpu_synid_literal>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000525
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000526Integer *inline constants* are converted to
527:ref:`expected operand type<amdgpu_syn_instruction_type>`
528as described :ref:`here<amdgpu_synid_int_const_conv>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000529
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000530 ================================== ====================================
531 Value Note
532 ================================== ====================================
533 {0..64} Positive integer inline constants.
534 {-16..-1} Negative integer inline constants.
535 ================================== ====================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000536
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000537.. WARNING:: GFX7 does not support inline constants for *f16* operands.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000538
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000539.. _amdgpu_synid_fconst:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000540
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000541fconst
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000542~~~~~~
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000543
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000544A :ref:`floating-point number<amdgpu_synid_floating-point_number>`
545encoded as an *inline constant*.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000546
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000547Only a small fraction of floating-point numbers may be encoded as *inline constants*.
548They are enumerated in the table below.
549Other floating-point numbers have to be encoded as :ref:`literals<amdgpu_synid_literal>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000550
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000551Floating-point *inline constants* are converted to
552:ref:`expected operand type<amdgpu_syn_instruction_type>`
553as described :ref:`here<amdgpu_synid_fp_const_conv>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000554
Dmitry Preobrazhensky6bc26aa2019-01-18 15:17:17 +0000555 ===================== ===================================================== ==================
556 Value Note Availability
557 ===================== ===================================================== ==================
558 0.0 The same as integer constant 0. All GPUs
559 0.5 Floating-point constant 0.5 All GPUs
560 1.0 Floating-point constant 1.0 All GPUs
561 2.0 Floating-point constant 2.0 All GPUs
562 4.0 Floating-point constant 4.0 All GPUs
563 -0.5 Floating-point constant -0.5 All GPUs
564 -1.0 Floating-point constant -1.0 All GPUs
565 -2.0 Floating-point constant -2.0 All GPUs
566 -4.0 Floating-point constant -4.0 All GPUs
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000567 0.1592 1.0/(2.0*pi). Use only for 16-bit operands. GFX8, GFX9, GFX10
568 0.15915494 1.0/(2.0*pi). Use only for 16- and 32-bit operands. GFX8, GFX9, GFX10
569 0.15915494309189532 1.0/(2.0*pi). GFX8, GFX9, GFX10
Dmitry Preobrazhensky6bc26aa2019-01-18 15:17:17 +0000570 ===================== ===================================================== ==================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000571
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000572.. WARNING:: GFX7 does not support inline constants for *f16* operands.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000573
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000574.. _amdgpu_synid_ival:
575
576ival
577~~~~
578
579A symbolic operand encoded as an *inline constant*.
580These operands provide read-only access to H/W registers.
581
582 ======================== ================================================ =============
583 Syntax Note Availability
584 ======================== ================================================ =============
585 shared_base Base address of shared memory region. GFX9, GFX10
586 shared_limit Address of the end of shared memory region. GFX9, GFX10
587 private_base Base address of private memory region. GFX9, GFX10
588 private_limit Address of the end of private memory region. GFX9, GFX10
589 pops_exiting_wave_id A dedicated counter for POPS. GFX9, GFX10
590 ======================== ================================================ =============
591
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000592.. _amdgpu_synid_literal:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000593
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000594literal
595-------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000596
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000597A literal is a 64-bit value which is encoded as a separate 32-bit dword in the instruction stream.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000598
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000599If a number may be encoded as either
600a :ref:`literal<amdgpu_synid_literal>` or
601an :ref:`inline constant<amdgpu_synid_constant>`,
602assembler selects the latter encoding as more efficient.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000603
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000604Literals may be specified as :ref:`integer numbers<amdgpu_synid_integer_number>`,
605:ref:`floating-point numbers<amdgpu_synid_floating-point_number>` or
606:ref:`expressions<amdgpu_synid_expression>`
607(expressions are currently supported for 32-bit operands only).
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000608
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000609A 64-bit literal value is converted by assembler
610to an :ref:`expected operand type<amdgpu_syn_instruction_type>`
611as described :ref:`here<amdgpu_synid_lit_conv>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000612
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000613An instruction may use only one literal but several operands may refer the same literal.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000614
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000615.. _amdgpu_synid_uimm8:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000616
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000617uimm8
618-----
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000619
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000620A 8-bit positive :ref:`integer number<amdgpu_synid_integer_number>`.
621The value is encoded as part of the opcode so it is free to use.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000622
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000623.. _amdgpu_synid_uimm32:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000624
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000625uimm32
626------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000627
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000628A 32-bit positive :ref:`integer number<amdgpu_synid_integer_number>`.
629The value is stored as a separate 32-bit dword in the instruction stream.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000630
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000631.. _amdgpu_synid_uimm20:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000632
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000633uimm20
634------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000635
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000636A 20-bit positive :ref:`integer number<amdgpu_synid_integer_number>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000637
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000638.. _amdgpu_synid_uimm21:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000639
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000640uimm21
641------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000642
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000643A 21-bit positive :ref:`integer number<amdgpu_synid_integer_number>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000644
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000645.. WARNING:: Assembler currently supports 20-bit offsets only. Use :ref:`uimm20<amdgpu_synid_uimm20>` as a replacement.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000646
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000647.. _amdgpu_synid_simm21:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000648
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000649simm21
650------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000651
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000652A 21-bit :ref:`integer number<amdgpu_synid_integer_number>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000653
Dmitry Preobrazhenskycef9d422019-07-08 16:50:11 +0000654.. WARNING:: Assembler currently supports 20-bit unsigned offsets only. Use :ref:`uimm20<amdgpu_synid_uimm20>` as a replacement.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000655
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000656.. _amdgpu_synid_off:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000657
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000658off
659---
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000660
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000661A special entity which indicates that the value of this operand is not used.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000662
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000663 ================================== ===================================================
664 Syntax Description
665 ================================== ===================================================
666 off Indicates an unused operand.
667 ================================== ===================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000668
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000669
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000670.. _amdgpu_synid_number:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000671
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000672Numbers
673=======
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000674
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000675.. _amdgpu_synid_integer_number:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000676
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000677Integer Numbers
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000678---------------
679
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000680Integer numbers are 64 bits wide.
681They may be specified in binary, octal, hexadecimal and decimal formats:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000682
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000683 ============== ====================================
684 Format Syntax
685 ============== ====================================
686 Decimal [-]?[1-9][0-9]*
687 Binary [-]?0b[01]+
688 Octal [-]?0[0-7]+
689 Hexadecimal [-]?0x[0-9a-fA-F]+
690 \ [-]?[0x]?[0-9][0-9a-fA-F]*[hH]
691 ============== ====================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000692
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000693Examples:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000694
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000695.. parsed-literal::
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000696
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000697 -1234
698 0b1010
699 010
700 0xff
701 0ffh
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000702
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000703.. _amdgpu_synid_floating-point_number:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000704
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000705Floating-Point Numbers
706----------------------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000707
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000708All floating-point numbers are handled as double (64 bits wide).
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000709
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000710Floating-point numbers may be specified in hexadecimal and decimal formats:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000711
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000712 ============== ======================================================== ========================================================
713 Format Syntax Note
714 ============== ======================================================== ========================================================
715 Decimal [-]?[0-9]*[.][0-9]*([eE][+-]?[0-9]*)? Must include either a decimal separator or an exponent.
716 Hexadecimal [-]0x[0-9a-fA-F]*(.[0-9a-fA-F]*)?[pP][+-]?[0-9a-fA-F]+
717 ============== ======================================================== ========================================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000718
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000719Examples:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000720
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000721.. parsed-literal::
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000722
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000723 -1.234
724 234e2
725 -0x1afp-10
726 0x.1afp10
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000727
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000728.. _amdgpu_synid_expression:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000729
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000730Expressions
731===========
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000732
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000733An expression specifies an address or a numeric value.
734There are two kinds of expressions:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000735
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000736* :ref:`Absolute<amdgpu_synid_absolute_expression>`.
737* :ref:`Relocatable<amdgpu_synid_relocatable_expression>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000738
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000739.. _amdgpu_synid_absolute_expression:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000740
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000741Absolute Expressions
742--------------------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000743
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000744The value of an absolute expression remains the same after program relocation.
745Absolute expressions must not include unassigned and relocatable values
746such as labels.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000747
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000748Examples:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000749
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000750.. parsed-literal::
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000751
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000752 x = -1
753 y = x + 10
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000754
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000755.. _amdgpu_synid_relocatable_expression:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000756
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000757Relocatable Expressions
758-----------------------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000759
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000760The value of a relocatable expression depends on program relocation.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000761
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000762Note that use of relocatable expressions is limited with branch targets
763and 32-bit :ref:`literals<amdgpu_synid_literal>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000764
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000765Addition information about relocation may be found :ref:`here<amdgpu-relocation-records>`.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000766
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000767Examples:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000768
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000769.. parsed-literal::
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000770
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000771 y = x + 10 // x is not yet defined. Undefined symbols are assumed to be PC-relative.
772 z = .
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000773
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000774Expression Data Type
775--------------------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000776
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000777Expressions and operands of expressions are interpreted as 64-bit integers.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000778
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000779Expressions may include 64-bit :ref:`floating-point numbers<amdgpu_synid_floating-point_number>` (double).
780However these operands are also handled as 64-bit integers
781using binary representation of specified floating-point numbers.
782No conversion from floating-point to integer is performed.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000783
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000784Examples:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000785
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000786.. parsed-literal::
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000787
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000788 x = 0.1 // x is assigned an integer 4591870180066957722 which is a binary representation of 0.1.
789 y = x + x // y is a sum of two integer values; it is not equal to 0.2!
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000790
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000791Syntax
792------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000793
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000794Expressions are composed of
795:ref:`symbols<amdgpu_synid_symbol>`,
796:ref:`integer numbers<amdgpu_synid_integer_number>`,
797:ref:`floating-point numbers<amdgpu_synid_floating-point_number>`,
798:ref:`binary operators<amdgpu_synid_expression_bin_op>`,
799:ref:`unary operators<amdgpu_synid_expression_un_op>` and subexpressions.
Dmitry Preobrazhenskyc80b1652018-07-27 14:17:15 +0000800
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000801Expressions may also use "." which is a reference to the current PC (program counter).
Dmitry Preobrazhenskyc80b1652018-07-27 14:17:15 +0000802
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000803The syntax of expressions is shown below::
Dmitry Preobrazhenskyc80b1652018-07-27 14:17:15 +0000804
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000805 expr ::= expr binop expr | primaryexpr ;
Dmitry Preobrazhenskyc80b1652018-07-27 14:17:15 +0000806
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000807 primaryexpr ::= '(' expr ')' | symbol | number | '.' | unop primaryexpr ;
Dmitry Preobrazhenskyc80b1652018-07-27 14:17:15 +0000808
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000809 binop ::= '&&'
810 | '||'
811 | '|'
812 | '^'
813 | '&'
814 | '!'
815 | '=='
816 | '!='
817 | '<>'
818 | '<'
819 | '<='
820 | '>'
821 | '>='
822 | '<<'
823 | '>>'
824 | '+'
825 | '-'
826 | '*'
827 | '/'
828 | '%' ;
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000829
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000830 unop ::= '~'
831 | '+'
832 | '-'
833 | '!' ;
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000834
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000835.. _amdgpu_synid_expression_bin_op:
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000836
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000837Binary Operators
838----------------
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000839
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000840Binary operators are described in the following table.
841They operate on and produce 64-bit integers.
842Operators with higher priority are performed first.
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000843
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000844 ========== ========= ===============================================
845 Operator Priority Meaning
846 ========== ========= ===============================================
847 \* 5 Integer multiplication.
848 / 5 Integer division.
849 % 5 Integer signed remainder.
850 \+ 4 Integer addition.
851 \- 4 Integer subtraction.
852 << 3 Integer shift left.
853 >> 3 Logical shift right.
854 == 2 Equality comparison.
855 != 2 Inequality comparison.
856 <> 2 Inequality comparison.
857 < 2 Signed less than comparison.
858 <= 2 Signed less than or equal comparison.
859 > 2 Signed greater than comparison.
860 >= 2 Signed greater than or equal comparison.
861 \| 1 Bitwise or.
862 ^ 1 Bitwise xor.
863 & 1 Bitwise and.
864 && 0 Logical and.
865 || 0 Logical or.
866 ========== ========= ===============================================
Dmitry Preobrazhenskyc6d31e62018-03-12 15:55:08 +0000867
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000868.. _amdgpu_synid_expression_un_op:
869
870Unary Operators
871---------------
872
873Unary operators are described in the following table.
874They operate on and produce 64-bit integers.
875
876 ========== ===============================================
877 Operator Meaning
878 ========== ===============================================
879 ! Logical negation.
880 ~ Bitwise negation.
881 \+ Integer unary plus.
882 \- Integer unary minus.
883 ========== ===============================================
884
885.. _amdgpu_synid_symbol:
886
887Symbols
888-------
889
890A symbol is a named 64-bit value, representing a relocatable
891address or an absolute (non-relocatable) number.
892
893Symbol names have the following syntax:
894 ``[a-zA-Z_.][a-zA-Z0-9_$.@]*``
895
896The table below provides several examples of syntax used for symbol definition.
897
898 ================ ==========================================================
899 Syntax Meaning
900 ================ ==========================================================
901 .globl <S> Declares a global symbol S without assigning it a value.
902 .set <S>, <E> Assigns the value of an expression E to a symbol S.
903 <S> = <E> Assigns the value of an expression E to a symbol S.
904 <S>: Declares a label S and assigns it the current PC value.
905 ================ ==========================================================
906
907A symbol may be used before it is declared or assigned;
908unassigned symbols are assumed to be PC-relative.
909
910Addition information about symbols may be found :ref:`here<amdgpu-symbols>`.
911
912.. _amdgpu_synid_conv:
913
914Conversions
915===========
916
917This section describes what happens when a 64-bit
918:ref:`integer number<amdgpu_synid_integer_number>`, a
919:ref:`floating-point numbers<amdgpu_synid_floating-point_number>` or a
920:ref:`symbol<amdgpu_synid_symbol>`
921is used for an operand which has a different type or size.
922
923Depending on operand kind, this conversion is performed by either assembler or AMDGPU H/W:
924
925* Values encoded as :ref:`inline constants<amdgpu_synid_constant>` are handled by H/W.
926* Values encoded as :ref:`literals<amdgpu_synid_literal>` are converted by assembler.
927
928.. _amdgpu_synid_const_conv:
929
930Inline Constants
931----------------
932
933.. _amdgpu_synid_int_const_conv:
934
935Integer Inline Constants
936~~~~~~~~~~~~~~~~~~~~~~~~
937
938Integer :ref:`inline constants<amdgpu_synid_constant>`
939may be thought of as 64-bit
940:ref:`integer numbers<amdgpu_synid_integer_number>`;
941when used as operands they are truncated to the size of
942:ref:`expected operand type<amdgpu_syn_instruction_type>`.
943No data type conversions are performed.
944
945Examples:
946
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000947.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000948
949 // GFX9
950
951 v_add_u16 v0, -1, 0 // v0 = 0xFFFF
952 v_add_f16 v0, -1, 0 // v0 = 0xFFFF (NaN)
953
954 v_add_u32 v0, -1, 0 // v0 = 0xFFFFFFFF
955 v_add_f32 v0, -1, 0 // v0 = 0xFFFFFFFF (NaN)
956
957.. _amdgpu_synid_fp_const_conv:
958
959Floating-Point Inline Constants
960~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
961
962Floating-point :ref:`inline constants<amdgpu_synid_constant>`
963may be thought of as 64-bit
964:ref:`floating-point numbers<amdgpu_synid_floating-point_number>`;
965when used as operands they are converted to a floating-point number of
966:ref:`expected operand size<amdgpu_syn_instruction_type>`.
967
968Examples:
969
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +0000970.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +0000971
972 // GFX9
973
974 v_add_f16 v0, 1.0, 0 // v0 = 0x3C00 (1.0)
975 v_add_u16 v0, 1.0, 0 // v0 = 0x3C00
976
977 v_add_f32 v0, 1.0, 0 // v0 = 0x3F800000 (1.0)
978 v_add_u32 v0, 1.0, 0 // v0 = 0x3F800000
979
980
981.. _amdgpu_synid_lit_conv:
982
983Literals
984--------
985
986.. _amdgpu_synid_int_lit_conv:
987
988Integer Literals
989~~~~~~~~~~~~~~~~
990
991Integer :ref:`literals<amdgpu_synid_literal>`
992are specified as 64-bit :ref:`integer numbers<amdgpu_synid_integer_number>`.
993
994When used as operands they are converted to
995:ref:`expected operand type<amdgpu_syn_instruction_type>` as described below.
996
997 ============== ============== =============== ====================================================================
998 Expected type Condition Result Note
999 ============== ============== =============== ====================================================================
Dmitry Preobrazhenskyddac5c92018-12-28 11:48:23 +00001000 i16, u16, b16 cond(num,16) num.u16 Truncate to 16 bits.
1001 i32, u32, b32 cond(num,32) num.u32 Truncate to 32 bits.
1002 i64 cond(num,32) {-1,num.i32} Truncate to 32 bits and then sign-extend the result to 64 bits.
1003 u64, b64 cond(num,32) { 0,num.u32} Truncate to 32 bits and then zero-extend the result to 64 bits.
1004 f16 cond(num,16) num.u16 Use low 16 bits as an f16 value.
1005 f32 cond(num,32) num.u32 Use low 32 bits as an f32 value.
1006 f64 cond(num,32) {num.u32,0} Use low 32 bits of the number as high 32 bits
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001007 of the result; low 32 bits of the result are zeroed.
1008 ============== ============== =============== ====================================================================
1009
1010The condition *cond(X,S)* indicates if a 64-bit number *X*
1011can be converted to a smaller size *S* by truncation of upper bits.
1012There are two cases when the conversion is possible:
1013
1014* The truncated bits are all 0.
1015* The truncated bits are all 1 and the value after truncation has its MSB bit set.
1016
1017Examples of valid literals:
1018
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +00001019.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001020
1021 // GFX9
Dmitry Preobrazhenskyddac5c92018-12-28 11:48:23 +00001022 // Literal value after conversion:
1023 v_add_u16 v0, 0xff00, v0 // 0xff00
1024 v_add_u16 v0, 0xffffffffffffff00, v0 // 0xff00
1025 v_add_u16 v0, -256, v0 // 0xff00
1026 // Literal value after conversion:
1027 s_bfe_i64 s[0:1], 0xffefffff, s3 // 0xffffffffffefffff
1028 s_bfe_u64 s[0:1], 0xffefffff, s3 // 0x00000000ffefffff
1029 v_ceil_f64_e32 v[0:1], 0xffefffff // 0xffefffff00000000 (-1.7976922776554302e308)
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001030
1031Examples of invalid literals:
1032
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +00001033.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001034
1035 // GFX9
1036
Dmitry Preobrazhenskyddac5c92018-12-28 11:48:23 +00001037 v_add_u16 v0, 0x1ff00, v0 // truncated bits are not all 0 or 1
1038 v_add_u16 v0, 0xffffffffffff00ff, v0 // truncated bits do not match MSB of the result
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001039
1040.. _amdgpu_synid_fp_lit_conv:
1041
1042Floating-Point Literals
1043~~~~~~~~~~~~~~~~~~~~~~~
1044
1045Floating-point :ref:`literals<amdgpu_synid_literal>` are specified as 64-bit
1046:ref:`floating-point numbers<amdgpu_synid_floating-point_number>`.
1047
1048When used as operands they are converted to
1049:ref:`expected operand type<amdgpu_syn_instruction_type>` as described below.
1050
1051 ============== ============== ================= =================================================================
1052 Expected type Condition Result Note
1053 ============== ============== ================= =================================================================
Dmitry Preobrazhenskyddac5c92018-12-28 11:48:23 +00001054 i16, u16, b16 cond(num,16) f16(num) Convert to f16 and use bits of the result as an integer value.
1055 i32, u32, b32 cond(num,32) f32(num) Convert to f32 and use bits of the result as an integer value.
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001056 i64, u64, b64 false \- Conversion disabled because of an unclear semantics.
Dmitry Preobrazhenskyddac5c92018-12-28 11:48:23 +00001057 f16 cond(num,16) f16(num) Convert to f16.
1058 f32 cond(num,32) f32(num) Convert to f32.
1059 f64 true {num.u32.hi,0} Use high 32 bits of the number as high 32 bits of the result;
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001060 zero-fill low 32 bits of the result.
1061
1062 Note that the result may differ from the original number.
1063 ============== ============== ================= =================================================================
1064
1065The condition *cond(X,S)* indicates if an f64 number *X* can be converted
1066to a smaller *S*-bit floating-point type without overflow or underflow.
1067Precision lost is allowed.
1068
1069Examples of valid literals:
1070
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +00001071.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001072
1073 // GFX9
1074
1075 v_add_f16 v1, 65500.0, v2
1076 v_add_f32 v1, 65600.0, v2
1077
Dmitry Preobrazhenskyddac5c92018-12-28 11:48:23 +00001078 // Literal value before conversion: 1.7976931348623157e308 (0x7fefffffffffffff)
1079 // Literal value after conversion: 1.7976922776554302e308 (0x7fefffff00000000)
1080 v_ceil_f64 v[0:1], 1.7976931348623157e308
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001081
1082Examples of invalid literals:
1083
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +00001084.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001085
1086 // GFX9
1087
Dmitry Preobrazhenskyddac5c92018-12-28 11:48:23 +00001088 v_add_f16 v1, 65600.0, v2 // overflow
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001089
1090.. _amdgpu_synid_exp_conv:
1091
1092Expressions
1093~~~~~~~~~~~
1094
1095Expressions operate with and result in 64-bit integers.
1096
1097When used as operands they are truncated to
1098:ref:`expected operand size<amdgpu_syn_instruction_type>`.
1099No data type conversions are performed.
1100
1101Examples:
1102
Dmitry Preobrazhensky1fa7aaf2018-12-17 18:53:10 +00001103.. parsed-literal::
Dmitry Preobrazhensky47eb6362018-12-17 17:38:11 +00001104
1105 // GFX9
1106
1107 x = 0.1
1108 v_sqrt_f32 v0, x // v0 = [low 32 bits of 0.1 (double)]
1109 v_sqrt_f32 v0, (0.1 + 0) // the same as above
1110 v_sqrt_f32 v0, 0.1 // v0 = [0.1 (double) converted to float]
1111