0a8c5a626184b12ba7423bd2dcdcfca93cb5cdea
[libreriscv.git] / openpower / sv / svstep.mdwn
1 # svstep
2
3 Links
4
5 * pseudocode in [[isa/simplev]] page
6
7 `svstep` performs explicit stepping of the Vector for-loop,
8 and it can also be used to enquire about the current state
9 of the REMAP indices and SVSTATE.
10
11 # Format
12
13 *(Allocation of opcode TBD pending OPF ISA WG approval)*,
14 using EXT22 temporarily and fitting into the
15 [[sv/bitmanip]] space
16
17 Form: SVL-Form (see [[isatables/fields.text]])
18
19 | 0.5|6.10|11.15|16..22| 23...25 | 26.30 |31| name |
20 | -- | -- | --- | ---- |----------- | ----- |--| ------- |
21 |OPCD| RT | / | SVi | / / vf | 11011 |Rc| svstep |
22
23 Instruction format:
24
25 svstep RT,SVi,vf (Rc=0)
26 svstep. RT,SVi,vf (Rc=1)
27
28 # Description
29
30 svstep may be used
31 to enquire about the REMAP Schedule. When `vf=1` then stepping occurs. When `vf=0` the enquiry is performed
32 without altering internal
33 state. If `SVi=0, Rc=0, vf=0` this instruction is a `nop`.
34 The following modes are identical to those in [[sv/setvl]], returning
35 identical results:
36
37 * When `SVi` is 1-4 the REMAP Schedule for a given SVSHAPE may be
38 returned in `RT`. SVi=1 selects SVSHAPE0 current state,
39 through to SVi=4 selects SVSHAPE3.
40 * When `SVi` is 5, `SVSTATE.srcstep` is returned.
41 * When `SVi` is 6, `SVSTATE.dststep` is returned.
42 * When `SVi` is 0b1100 pack/unpack in SVSTATE is cleared
43 * When `SVi` is 0b1101 pack in SVSTATE is set, unpack is cleared
44 * When `SVi` is 0b1110 unpack in SVSTATE is set, pack is cleared
45 * When `SVi` is 0b1111 pack/unpack in SVSTATE are set
46
47 As this is a Single-Predicated (1P) instruction, predication may be applied
48 to skip (or zero) elements.
49
50 * Vertical-First Mode will return the requested index
51 (and move to the next state if `vf=1`)
52 * Horizontal-First Mode can be used to return all indices,
53 i.e. walks through all possible states.
54
55 To obtain the full set of possible computed element
56 indices use `svstep RT.v,SVI,1` which will store all computed element
57 indices, starting from RT. If Rc=1 then a co-result Vector of CR Fields
58 will also be returned, comprising the "loop end-points" of each of the inner
59 loops when either Matrix Mode or DCT/FFT is set. In other words,
60 for example, when the `xdim` inner loop reaches the end and on the next
61 iteration it will begin again at zero, the CR Field `EQ` will be set.
62 With a maximum of three loops within both Matrix and DCT/FFT Modes,
63 the CR Field's EQ bit will be set at the end of the first inner loop,
64 the LE bit for the second, the GT bit for the outermost loop and the
65 SO bit set on the very last element, when all loops reach their maximum
66 extent.
67
68 *Programmer's note (1): VL in some situations, particularly larger Matrices,
69 may exceed 64,
70 meaning that `sv.svshape` returning a considerable number of values. Under
71 such circumstances `sv.svshape/ew=8` is recommended.*
72
73 *Programmer's note (2): having conveniently obtained a pre-computed
74 Schedule with `sv.svstep`,
75 it may then be used as the input to Indexed REMAP Mode
76 to achieve the exact same Schedule. It is evident however that
77 before use some of the Indices may be arbitrarily altered as desired.
78 `sv.svstep` helps the programmer avoid having to manually recreate
79 Indices for certain
80 types of common Loop patterns, and in its simplest form, without REMAP
81 (SVi=5 or SVi=6),
82 is equivalent to the `iota` instruction found in other Vector ISAs*