(no commit message)
[libreriscv.git] / openpower / sv / po9_encoding / discussion.mdwn
1 [[!toc]]
2
3 # introduction
4
5 the purpose of this page is to create and evaluate alternative
6 encoding schemes that allow for a hybrid mixture of
7 (ultra-precious) 32-bit and 64-bit (actually `x86 REP`-like
8 prefixed) instructions.
9
10 a specific view to attaining high-speed massive-wide multi-issue decode
11 is a high priority. therefore especially length-detection must be kept
12 brutally simple.
13
14 # alternative 32-64 encoding (1) **superseded**
15
16 conflict to resolve: EXT90x and EXT232. they are indistinguishable.
17
18 ```
19 |0-5| 6-27 28 29|30-31|32|33-35|36-37| 38-59 | 60-63 | Description |
20 |---|-----|-----|-----|--|-----|-----|-------|-------|------------------|
21 |PO9| rm0 | 0 0 | 0 0 | 0 000 rm1 | xxxx | 0000 | SVP64:EXT900 |
22 |PO9| rm0 | 0 0 | 0 0 | 1 000 rm1 | xxxx | 0000 | SSingle:EXT900 |
23 |PO9| xxx | x 0 | 0 0 | x !zero0 | xxxx | !zero1| 55-bit RESERVED |
24 |PO9| xxx | 0 1 | 0 0 | 32-bit EXT900 (Vectorizable) |
25 |PO9| xxx | 1 1 | 0 0 | 32-bit EXT901 (Unvectorizable) |
26 |PO9| !ZERO | 0 0 | 1 | DWi | SSingle:EXT232-263 |
27 |PO9| 0000 | 0 0 | 1 | DWi | Scalar EXT232-263 |
28 |PO9| RM | 1 0 | 1 | DWi | SVP64:EXT232-263 |
29 |PO9| 0000 | 0 1 | Defined Word-instruction | 32-bit Unvec in 64b|
30 |PO9| !ZERO | 0 1 | Defined Word-instruction | SSingle:EXT000-063 |
31 |PO9| RM | 1 1 | Defined Word-instruction | SVP64:EXT000-063 |
32 ```
33
34 Fields:
35
36 * `RM`: 24-bit SVP64 prefix
37 * `RM <- rm0 || rm1` split field
38 * `!zero0 || !zero1` a split field that must not be zero
39
40 Length detection:
41
42 ```
43 if PO1 return 64
44 elif not PO9 return 32
45 elif Word[31] = 1 return 64
46 elif Word[29:30] = 0b10 return 32
47 elif Word[29:30] = 0b00 return 64
48 else return 32
49 ```
50
51 Instruction allocation restrictions:
52
53 * setvl is Unvectorizable but needs more space later: use 55-bit
54 * likewise svshape svindex and svshape2, all these need 32-bit
55 * svstep *is* Vectorizable but needs to be encoded 32-bit in order
56 to reduce loop-size
57 * space for 32-bit instructions is needed: some instructions
58 just make no sense if done as 64-bit because they **replace**
59 two 32-bit instructions.
60 * but those types of space-saving instructions
61 **also need to be Vectorizable*
62
63 # alternative 32-64 encoding (2) **superseded**
64
65 requires reducing SVP64Single to 23 bits. luckily there are 2 spare
66
67 the complexity of attempting to fit 32-bit instructions into
68 PO9 is very high. encoding (1) attempts to fit `setvl` etc. into
69 32-bit but it is very tight. the entire EXT900 area would be
70 taken up by the SVP64 Management instructions, below, defeating
71 the purpose of having it.
72
73 * `setvl` - Unvectorizable, EXT0xx, `RT RA CTR SVSTATE`, 6-bit XO (including Rc=1)
74 * `psetvl` - Unvectorizable, EXT1xx, ditto
75 * `svstep` - Vectorizable, either EXT900 (very precious) or EXT1xx (better), `RT, SVSTATE`, 6-bit XO (including Rc=1)
76 * `svindex` - Unvectorizable, EXT0xx, `SVSTATE,SVSHAPE0-3`, 5-bit XO
77 * `psvindex` - Unvectorizable, EXT1xx, ditto
78 * `svstep(2)` - Unvectorizable, EXT0xx, `SVSTATE,SVSHAPE0-3`, 5-bit XO
79 * `svstep(2)` - Unvectorizable, EXT1xx, ditto
80
81 ```
82 |0-5| 6-28|29 30 31|32|33-36|37 | 38-60 | 61-63 | Description |
83 |---|-----|--------|--|-----|---|-------|-------|------------------|
84 |PO9| rm0 | 1 0 0 | 0 0000 rm1| xxxx | 000 | SVP64:EXT900 |
85 |PO9|!ZERO| 1 0 0 | 0 1000 1 | xxxx | 000 | SSingle:EXT900 |
86 |PO9| xxx | 1 0 0 | 0 !zero0 | xxxx | !zero1| 55-bit RESERVED |
87 |PO9| xxx | 0 0 0 | 32-bit EXT900 |
88 |PO9|!ZERO| 1 0 0 | 1 | DWi | SSingle:EXT232-263 |
89 |PO9| 000 | 1 0 0 | 1 | DWi | Scalar EXT232-263 |
90 |PO9| nnnn | 1 0 | 1 | DWi | SVP64:EXT232-263 |
91 |PO9| 0000 | 0 1 | Defined Word-instruction | 32-bit Unvec in 64b|
92 |PO9|!ZERO | 0 1 | Defined Word-instruction | SSingle:EXT000-063 |
93 |PO9| nnnn | 1 1 | Defined Word-instruction | SVP64:EXT000-063 |
94 ```
95
96 Length detection:
97
98 ```
99 if PO1 return 64
100 elif not PO9 return 32
101 elif Word[29:31] = 0b000 return 32
102 else return 64
103 ```
104
105 # alternative 32-64 encoding (3) **current**
106
107 aim of this idea is to attempt simplification of area identification
108 and length. the 55-bit area is eliminated and may only be reintroduced
109 by sacrificing parts of EXT200-231, bear in mind that EXT209 is already
110 unavailable (used by EXT900).
111
112
113 ```
114 |0-5| 6-29 |30 31|32|33-36|37 | 38-61 | 62-63 | Description |
115 |---|--------|-----|--|-----|---|-------|-------|------------------|
116 |PO9| xxxx | 0 0 | (next new instruction) | 32-bit EXT900 |
117 |PO9| 0000 | 1 0 | 0 1000 1 | xxxx | 00 | RESERVED |
118 |PO9| !ZERO | 1 0 | 0 1000 1 | xxxx | 00 | SSingle:EXT900 |
119 |PO9| nnnn | 1 0 | 0 1000 1 | xxxx | 01 | SVP64:EXT900 |
120 |PO9| xxxx | 1 0 | 0 1000 1 | xxxx | 10 | RESERVED |
121 |PO9| xxxx | 1 0 | 0 1000 1 | xxxx | 11 | RESERVED |
122 |PO9| !ZERO | 1 0 | 0 | !PO9 | xxxx | SSingle:EXT200-231 |
123 |PO9| 0000 | 1 0 | 0 | !PO9 | xxxx | Scalar EXT200-231 |
124 |PO9| nnnn | 1 0 | 1 | !PO9 | xxxx | SVP64:EXT200-231 |
125 |PO9| 0000 | 0 1 | Defined Word-instruction | 32-bit Unvec in 64b|
126 |PO9| !ZERO | 0 1 | Defined Word-instruction | SSingle:EXT000-063 |
127 |PO9| nnnn | 1 1 | Defined Word-instruction | SVP64:EXT000-063 |
128 ```
129
130 The following identification-criteria may be easily verified by taking
131 a copy of the table above and striking out each line that fails each
132 test. Only EXT000-063 is not by a "process of elimination" (if ... return True)
133
134 **Length detection**: (critically-important to be short)
135
136 ```
137 if PO1 return 64
138 elif not PO9 return 32
139 elif Word[30:31] = 0b00 return 32
140 else return 64
141 ```
142
143 **EXT200-231:**
144
145 ```
146 if not PO9 return False
147 if Word[30:31] == 0b00 return False
148 if Word[33:37] != 0b10001 return False
149 # if Word[33:37] != XXXXX return False # 50-bit
150 return True
151 ```
152
153 **EXT900:**
154
155 ```
156 # easy first step
157 if not PO9 return False
158 # eliminate EXT0xx, 32-Unvec-in-64b
159 if Word[31] = 0b1 return False
160 # eliminate EXT2xx
161 if Word[30:31] = 0b10 and
162 Word[33:37] != 0b10001 return False
163 # eliminate currently-RESERVED areas
164 if Word[30:31] = 0b10 and
165 Word[62] = 0b1 return False
166 # eliminate final RESERVED area
167 if Word[30:31] = 0b10 and
168 Word[62:63] = 0b00 and
169 Word[6:29 ] = 0x000000 return False
170 # last-remaining is EXT900
171 return True
172 ```
173
174 **EXT000-063**: (includes Prefixed)
175
176 ```
177 if PO1 return False # or other reserved
178 if not PO9 return True # prefixed needs more
179 # eliminate EXT900
180 if Word[30:31] = 0b00 return False
181 # eliminate Prefixed-EXT900, RESERVED and EXT200
182 if Word[31] = 0b0 return False
183 # eliminate 32-bit Unvec in 64b area
184 if Word[30:31] = 0b01 and
185 Word[6:29 ] = 0x000000 return False
186 return True
187 ```
188
189 **SVP64**:
190
191 ```
192 # easy-elimination, first
193 if not PO9 return False
194 if Word[30] = 0b0 return False
195 # eliminate anything not SVP64:EXT900
196 if Word[30:31] = 0b10 and
197 Word[33:37] = 0b10001 and
198 Word[62:63] != 0b01 return False
199 # eliminate anything not SVP64:EXT200-231
200 if Word[31:32] = 0b00 return False
201 # all remaining combinations are SVP64:EXTnnn
202 return True
203 ```
204
205 **SVP64Single**:
206
207 ```
208 # easy-elimination, first
209 if not PO9 return False
210 # eliminate 32-bit EXT900
211 if Word[30:31] = 0b00 return False
212 # eliminate SVP64:EXT000-063
213 if Word[30:31] = 0b11 return False
214 # eliminate anything "Identity"
215 if Word[6:29 ] = 0x000000 return False
216 # eliminate SVP64:EXT200-231
217 if Word[30:32] = 0b101 return False
218 # eliminate anything not SSingle:EXT900
219 if Word[30:31] = 0b10 and
220 Word[33:37] = 0b10001 and
221 Word[62:63] != 0b00 return False
222 # everything left is SVP64Single
223 return True
224 ```
225
226 **RESERVED**: (no need to pass for further detailed decode)
227
228 ```
229 # easy-elimination, first
230 if not PO9 return False
231 # eliminate EXT900
232 if Word[30:31] = 0b00 return False
233 # eliminate SVP64:EXT000-031
234 if Word[30:31] = 0b11 return False
235 # eliminate SSingle:EXT000-063
236 if Word[6:29 ] != 0x000000 and
237 Word[30:31] = 0b01 return False
238 # eliminate EXT200-231
239 if Word[30:31] = 0b10 and
240 Word[33:37] = 0b10001 return False
241 # eliminate SSingle:EXT900
242 if Word[30:31] = 0b10 and
243 Word[6:29 ] != 0x000000 and
244 Word[33:37] = 0b10001 and
245 Word[62:63] = 0b00 return False
246 # eliminate SVP64:EXT900
247 if Word[30:31] = 0b10 and
248 Word[33:37] = 0b10001 and
249 Word[62:63] = 0b01 return False
250 # all else needs further detailed decode
251 return True
252 ```
253