Intel vISA Spec: vISA Assembly Syntax
intel_gpu_visa)Intel Gen9–Gen12 / Xe-LP / Xe-HPG / Xe-HPC / Xe2
master
Summary
Intel IGC Virtual ISA specification chapter: vISA Assembly Syntax.
Syntax / Encoding
vISA Assembly Syntax
Reference Notes
# vISA Assembly Syntax
Notation
--------
- Left associated rules are used
- \| : indicates "or"
- <abc> : means abc is none-terminal token
- [xyz] : 0 or 1 occurrence of xyz
- [xyz]?: 1 occurrence of x, or y, or z
- [xyz]\* : 0 or more occurrences of x, y and z.
- [xyz]+ : 1 or more occurrences of x, y and z.
- ^ : start position of a line
Lexemes
-------
### Operators:
<operators>::=+\|-\|\*\|/
<assign_operator>::='='
<colon>::=':'
<other_operators>::=, \| ; \| '<' \| '>' \| '(' \| ')' \| '{' \| '}'
### Types:
<variable_type> ::= G\|A\|P\|S\|T
<data_type> ::= <FLOAT> \| <INT> \| <BOOLEAN> \| <VECTOR>
<FLOAT>::=f \| df \| F \| DF
<INT>::= ud \| d \| uw \| w \| ub \| b \| UD \| D \| UW \| W \| UB \| B
<BOOLEAN>::=bool \| BOOL
<VECTOR>::= v \| vf \| V \| VF
<src_modifier>::=[(-) \| (abs) \| (-abs)]
### Tokens:
<directives>::=.kernel_attr \| .decl \| .input \| .kernel \| .function \|
.version
<pred_ctrl>::= all \| any
<pred_state>::= !
<vme_op_type>::=inter \| intra \| all
<align>::= byte\|word\|dword\|qword\|oword\|GRF\|2GRF
<rel_op>::= eq\|ne\|gt\|ge\|lt\|le\|EQ\|NE\|GT\|GE\|LT\|LE
<start_offset>::=M0\|M1\|M2\|M3\|M4\|M5\|M6\|M7\|NM
<kernel_attribute>::= Extern \| NoBarrier \| Target \| SLMSize \| SpillMemOffset \| ArgSize \| RetValSize \| SimdSize \| PerThreadInputSize \| OutputAsmPath
<var_attribute>::= Input \| Output \| Input_Output
<other_tokens>::= num_elts \| align \| alias \| type \| v_type \|
size \| attrs \| offset \| .sat
<OP>::=
and\|or\|xor\|shl\|shr\|asr\|not\|inv\|log\|exp\|sqrt\|rsqrt\|sin\|cos\|div\|mod\|pow\|frc\|lzd\|rndd\|rndu
\|rnde\|rndz\|add\|avg\|dp2\|dp3\|dp4\|dhp\|line\|mul\|pow\|mulh\|sad2\|mad\|asin\|acos\|atan\|addr_add\|sel\|mov\|movs\|setp\|cmp\|oword_ld\|oword_st\|oword_ld_unaligned\|media_ld\|media_st\|gather\|scatter\|dword_atomic\|sample\|load\|sample_unorm\|vme\|jmp\|call\|ret\|if\|while\|else\|do\|endif\|break\|cont\|vme_fbr\|vme_sic\|vme_ime
<atomic_op>::=add\|sub\|inc\|dec\|min\|max\|xchg\|cmpxchg\|and\|or\|xor\|imin\|imax
### Numbers:
<number>::=<int_number>\|<hex_number>\|<float_point_number>
<int_number>::=<oct_number>\|<hex_number>
<oct_number>::= [0-9]+
<hex_number>::=0x[0-9a-fA-F]+
<float_point_number>::=<float_number_basic>
\|<float_number_science>
< float_number_basic >::=[0-9]+"."[0-9]+
< float_number_science >::= ([0-9]+"."[0-9]+)"e"("+"\|"-")[0-9]+
<exp>::=<INT_NUMBER>\|Exp'+'Exp\|Exp'-'Exp\|Exp'\*'Exp\|Exp'/'Exp\|'-'
Exp\|'('Exp')'
<offset>::=<exp>
### Strings:
<label>::= ^[a-zA-Z_$@?]?[a-zA-Z0-9_\\-$@?]\*
<asmFileName>::=[a-zA-Z_]?[a-zA-Z0-9_\\-$]\*"."asm
<func_name>::=[a-zA-Z_$@\\?]?[a-zA-Z0-9_\\-$@\\?]\*
<bracket_pairs>::= '<'[a-zA-Z_]?[a-zA-Z0-9_\\-, \\t]\*'>' \| '('
[a-zA-Z][a-zA-Z0-9_\\-, \\t]\*')'
<kernel_name>::= [a-zA-Z_]?[a-zA-Z0-9_\\-]\*[<bracket_pairs>]
<var_name>::= [a-zA-Z_]?[a-zA-Z0-9_\\-]\*
<comment>::= /\* <string_with_no_end_comment> \*/
<end_of_line>::='\\n'
vISA Assembly File
------------------
<vISA_Assembly_File>::=<directives_declares> [<kernel_function>]+
<directives_declares>::= <directive_kernel><end_line>
<directive_version><end_line> <directives_declares ><end_line>[
<directives_input ><end_line>]+ [<directives_attr >><end_line>]+
<kernel_function>::=<directive_function>[[<vISA_instructions><end_line>]\|[<decl_label><end_line>]]+
Directives and Declarations Syntax
----------------------------------
### Directives
| Directive | Mnemonic / Syntax | Example |
| --- | --- | --- |
| <directive_attr> | .kernel_attr <attr_name>[=<attr_value>] | .kernel_attr OutputAsmPath=IS_genx_1.asm |
| <directive_decl> | See following Declarations table | See following Declarations table |
| <directive_input> | .input <input_var> offset=<offset> size=<size> | .input T5 offset=36 size=4 |
| <directive_version> | .version <major_version>.<minor_version> | .version 1.0 |
| <directive_kernel> | .kernel <kernel_name> | .kernel BlockMotionSearch |
| <directive_function> | .function <func_name> | .function foo |
<directive_decl>::=[<decl_gen_var>\|<decl_add_var>\|<decl_pred_var>\|<decl_samp_var>\|<decl_surf_var>]+
### Declarations
| Variable | Declaration Mnemonic / Syntax | Type | Max Count | R\\W | Input | Address-able | Example |
| --- | --- | --- | --- | --- | --- | --- | --- |
| <decl_gen_var> | .decl <gen_var_name> v_type=G type= <data_type> num_elts =<num_elements> [align=<align>] [alias (<alias_variable_name>, <offset>)] | UD, D, UW, W, UB, B, DF, F | 65536 | R\\W | Y | Y | .decl V8 v_type=G type=UD num_elts=1 align=dword |
| <decl_add_var> | .decl <addr_var_name> v_type=A type=<data_type> num_elts=<num_elements> | UW | 4096 | R\\W | N | N | .decl A14 v_type=A type=UW num_elts=1 |
| <decl_pred_var> | .decl <pred_var_name> v_type=P num_elts=<num_elements> [ attrs={Input}] | BOOL | 4096 | R\\W | N | N | .decl P182 v_type=P num_elts=8 |
| <decl_samp_var> | .decl <samp_var_name> v_type = S | | 16 | R | Y | N | .decl S0 v_type=S |
| <decl_surf_var> | .decl <surf_var_name> v_type=T | | 128 | R | Y | N | .decl T5 v_type=T |
| <decl_label> | <label >: | | 4096 | R | N | N | BB_11224: |
| | | | | | | | ??$d_transpose@M$07$0IA@@@YAXVSurfaceIndex@@0HH@Z: |
<gen_var_name>::=<var_name>
<addr_var_name>::=<var_name>
<pred_var_name>::=<var_name>
<samp_var_name>::=<var_name>
<surf_var_name>::=<var_name>
<input_var>::=<gen_var_name>\|<samp_var_name>\|<surf_var_name>\|<samp_var_name
vISA instruction syntax
-----------------------
### Operands
| Operand position | Operand group | Operand type | Operand type ID | Mnemonic / Syntax | Example |
| --- | --- | --- | --- | --- | --- |
| Execution size | | | <exec_size> | ( <start_offset>, <exp>) | (M1, 4) |
| Predicate | | Predicate | P | [!] <pred_var_name>[.<pred_ctrl>] | !P64.all |
| Source | V_OPND | General | G | [<src_modifier>] <gen_var_name> (<row_offset>, < col_offset>) '<'<vertical_stride>; <width>, <horizontal_stride>'>' | V58(0,0)<8;8,1> |
| Address | A | <addr_var_name> (<offset>)'<'<width>'>' | A3(0)<1> | | |
| Indirect | I | [<src_modifier>]r'[' <addr_var_name>(<addr_offset>), < indirect_offset> ']' '<' <vertical_stride>; <width>, <horizontal_stride>'>': <data_type> | r[A3(0),448]<8;8,1>:ud | | |
| Predicate | P | [<src_modifier>] <pred_var_name> | P17 | | |
| Immediate | IM | <value>:<data_type> | 0x100:uw | | |
| Address Of | AO | &<gen_var_name> [+\|-] <addr_offset> | &V21+0 | | |
| R_OPND | Raw | G | <gen_var_name>.<offset> | V16.0 | |
| OTHERS | Sampler | S | <samp_var_name> | S9 | |
| Surface | T | <surf_var_name>