add empty brownfield funct5
[libreriscv.git] / rv_major_opcode_1010011.mdwn
1 # Summary FP Opcodes
2
3 This page aids and assists in the development of FP proposals,
4 by identifying and listing in full both publicly-known proposals
5 and the full brownfield encoding space available in the 0b010011
6 major opcode.
7
8 Publicly-known FP proposals:
9
10 * Zfrsqrt - Reciprocal SQRT <http://bugs.libre-riscv.org/show_bug.cgi?id=110>
11 * Zftrans - Transcendentals (FSIN, FCOS, FATAN, FPOW, FEXP, FLOG, FRCP)
12 * HI-half FP MV - <https://github.com/riscv/riscv-isa-manual/pull/301>
13 <https://groups.google.com/a/groups.riscv.org/forum/m/#!topic/isa-dev/kXgfFqgBv-c>
14 * (Add new entries here: Zextname - Description and URL)
15
16 [[!toc levels=2]]
17
18 # Main FP opcode 1010011 table
19
20 Notes:
21
22 * Proposed new encodings in **bold**.
23 * *Use funct5 sparingly!* - 2-operand functions only.
24 * Single-argument FP operations should go under one of the funct5 tables
25 * Both dual and single argument FP operations that do not require
26 "rounding mode" should go in one of the funct5 tables that already use
27 "funct3".
28 * Be careful not to use encoding space for which FP16 has already been
29 reserved.
30
31 [[!table data="""
32 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
33 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
34 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
35 00000 | xx | rs2 | rs1 | rm | rd | 1010011 | FADD.xx |
36 00001 | xx | rs2 | rs1 | rm | rd | 1010011 | FSUB.xx |
37 00010 | xx | rs2 | rs1 | rm | rd | 1010011 | FMUL.xx |
38 00011 | xx | rs2 | rs1 | rm | rd | 1010011 | FDIV.xx |
39 00100 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
40 00101 | xx | rs2 | rs1 | yyy | rd | 1010011 | tb=00101 |
41 00110 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
42 00111 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
43 01000 | xx | rs2 | rs1 | yyy | rd | 1010011 | tb=01000 |
44 01001 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
45 01010 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
46 01011 | xx | xxxxx | rs1 | yyy | rd | 1010011 | tb=01011 |
47 01100 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
48 01101 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
49 01110 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
50 01111 | xx | rs2 | rs1 | yyy | rd | 1010011 | **FPOW.xx** |
51 10000 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
52 10001 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
53 10010 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
54 10011 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
55 10100 | xx | rs2 | rs1 | yyy | rd | 1010011 | tb=10100 |
56 10101 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
57 10110 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
58 10111 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
59 11000 | xx | xxxxx | rs1 | yyy | rd | 1010011 | tb=11000 |
60 11001 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
61 11010 | xx | xxxxx | rs1 | yyy | rd | 1010011 | tb=11010 |
62 11100 | xx | xxxxx | rs1 | 000 | rd | 1010011 | tb=11100 |
63 11101 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
64 11110 | xx | xxxxx | rs1 | 000 | rd | 1010011 | tb=11110 |
65 11111 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
66 """]]
67
68 ## funct5 = 00100
69
70 This table uses funct3 for encoding 2-operand FP operations
71
72 [[!table data="""
73 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
74 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
75 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
76 00100 | xx | rs2 | rs1 | 000 | rd | 1010011 | FSGNJ.xx |
77 00100 | xx | rs2 | rs1 | 001 | rd | 1010011 | FSGNJN.xx |
78 00100 | xx | rs2 | rs1 | 010 | rd | 1010011 | FSGNJX.xx |
79 00100 | xx | rs2 | rs1 | 011 | rd | 1010011 | ?f3=011 |
80 00100 | xx | rs2 | rs1 | 100 | rd | 1010011 | ?f3=100 |
81 00100 | xx | rs2 | rs1 | 101 | rd | 1010011 | ?f3=101 |
82 00100 | xx | rs2 | rs1 | 110 | rd | 1010011 | ?f3=110 |
83 00100 | xx | rs2 | rs1 | 111 | rd | 1010011 | ?f3=111 |
84 """]]
85
86 ## funct5 = 00000 - FADD
87
88 No brownfield encodings available.
89
90 ## funct5 = 00001 - FSUB
91
92 No brownfield encodings available.
93
94 ## funct5 = 00010 - FMUL
95
96 No brownfield encodings available.
97
98 ## funct5 = 00011 - FDIV
99
100 No brownfield encodings available.
101
102 ## funct5 = 00100 - unused
103
104 Brownfield encodings available.
105
106 ## funct5 = 00101
107
108 This table uses funct3 for encoding 2-operand FP operations where the result
109 register is a **floating-point** value.
110
111 [[!table data="""
112 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
113 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
114 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
115 00101 | xx | rs2 | rs1 | 000 | rd | 1010011 | FMIN.S |
116 00101 | xx | rs2 | rs1 | 001 | rd | 1010011 | FMAX.S |
117 00101 | xx | rs2 | rs1 | 010 | rd | 1010011 | ?f3=010 |
118 00101 | xx | rs2 | rs1 | 011 | rd | 1010011 | ?f3=011 |
119 00101 | xx | rs2 | rs1 | 100 | rd | 1010011 | ?f3=100 |
120 00101 | xx | rs2 | rs1 | 101 | rd | 1010011 | ?f3=101 |
121 00101 | xx | rs2 | rs1 | 110 | rd | 1010011 | ?f3=110 |
122 00101 | xx | rs2 | rs1 | 111 | rd | 1010011 | ?f3=111 |
123 """]]
124
125 ## funct5 = 00110 - unused
126
127 Brownfield encodings available.
128
129 ## funct5 = 00111 - unused
130
131 Brownfield encodings available.
132
133 ## funct5 = 01000
134
135 This table uses rs2 for encoding 1-operand FP operations that require "rounding"
136
137 Notes:
138
139 * TODO FP16 (trivial)
140
141
142 [[!table data="""
143 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
144 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
145 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
146 01000 | 00 | 00001 | rs1 | rm | rd | 1010011 | FCVT.S.D |
147 01000 | 00 | 00011 | rs1 | rm | rd | 1010011 | FCVT.S.Q |
148 01000 | 00 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
149 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
150 01000 | 01 | 00000 | rs1 | rm | rd | 1010011 | FCVT.D.S |
151 01000 | 01 | 00011 | rs1 | rm | rd | 1010011 | FCVT.D.Q |
152 01000 | 01 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
153 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
154 01000 | 11 | 00000 | rs1 | rm | rd | 1010011 | FCVT.Q.S |
155 01000 | 11 | 00001 | rs1 | rm | rd | 1010011 | FCVT.Q.D |
156 01000 | 11 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
157 """]]
158
159 ## funct5 = 01001 - unused
160
161 Brownfield encodings available.
162
163 ## funct5 = 01010 - unused
164
165 Brownfield encodings available.
166
167 ## funct5 = 01011
168
169 This table uses rs2 for encoding 1-operand FP operations that require "rounding"
170
171 [[!table data="""
172 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
173 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
174 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
175 01011 | xx | 00000 | rs1 | rm | rd | 1010011 | FSQRT.xx |
176 01011 | xx | 00001 | rs1 | rm | rd | 1010011 | **FRSQRT.xx** |
177 01011 | xx | 00010 | rs1 | rm | rd | 1010011 | **FSIN.xx** |
178 01011 | xx | 00011 | rs1 | rm | rd | 1010011 | **FCOS.xx** |
179 01011 | xx | 00100 | rs1 | rm | rd | 1010011 | **FATAN.xx** |
180 01011 | xx | 00101 | rs1 | rm | rd | 1010011 | **FEXP.xx** |
181 01011 | xx | 00110 | rs1 | rm | rd | 1010011 | **FLOG.xx** |
182 01011 | xx | 00111 | rs1 | rm | rd | 1010011 | **FRCP.xx** |
183 01011 | xx | 01000 | rs1 | rm | rd | 1010011 | ? |
184 01011 | xx | 01001 | rs1 | rm | rd | 1010011 | ? |
185 01011 | xx | 01010 | rs1 | rm | rd | 1010011 | ? |
186 01011 | xx | 01011 | rs1 | rm | rd | 1010011 | ? |
187 01011 | xx | 01100 | rs1 | rm | rd | 1010011 | ? |
188 01011 | xx | 01101 | rs1 | rm | rd | 1010011 | ? |
189 01011 | xx | 01110 | rs1 | rm | rd | 1010011 | ? |
190 01011 | xx | 01111 | rs1 | rm | rd | 1010011 | ? |
191 01011 | xx | 10000 | rs1 | rm | rd | 1010011 | ? |
192 01011 | xx | 10001 | rs1 | rm | rd | 1010011 | ? |
193 01011 | xx | 10010 | rs1 | rm | rd | 1010011 | ? |
194 01011 | xx | 10011 | rs1 | rm | rd | 1010011 | ? |
195 01011 | xx | 10100 | rs1 | rm | rd | 1010011 | ? |
196 01011 | xx | 10101 | rs1 | rm | rd | 1010011 | ? |
197 01011 | xx | 10110 | rs1 | rm | rd | 1010011 | ? |
198 01011 | xx | 10111 | rs1 | rm | rd | 1010011 | ? |
199 01011 | xx | 11000 | rs1 | rm | rd | 1010011 | ? |
200 01011 | xx | 11001 | rs1 | rm | rd | 1010011 | ? |
201 01011 | xx | 11010 | rs1 | rm | rd | 1010011 | ? |
202 01011 | xx | 11011 | rs1 | rm | rd | 1010011 | ? |
203 01011 | xx | 11100 | rs1 | rm | rd | 1010011 | ? |
204 01011 | xx | 11101 | rs1 | rm | rd | 1010011 | ? |
205 01011 | xx | 11110 | rs1 | rm | rd | 1010011 | ? |
206 01011 | xx | 11111 | rs1 | rm | rd | 1010011 | ? |
207 """]]
208
209 ## funct5 = 01100 - unused
210
211 Brownfield encodings available.
212
213 ## funct5 = 01101 - unused
214
215 Brownfield encodings available.
216
217 ## funct5 = 01110 - unused
218
219 Brownfield encodings available.
220
221 ## funct5 = 01111 - **FPOW**
222
223 Proposed for Zftrans - FPOW: "FP rs2 to the power of rs1"
224
225 ## funct5 = 10000 - unused
226
227 Brownfield encodings available.
228
229 ## funct5 = 10001 - unused
230
231 Brownfield encodings available.
232
233 ## funct5 = 10010 - unused
234
235 Brownfield encodings available.
236
237 ## funct5 = 10011 - unused
238
239 Brownfield encodings available.
240
241 ## funct5 = 10100
242
243 This table uses funct3 for encoding 2-operand FP "comparison" operations
244 where the result register is an **integer**
245
246 Notes:
247
248 * FNE missing?
249
250 [[!table data="""
251 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
252 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
253 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
254 10100 | xx | rs2 | rs1 | 000 | rd | 1010011 | FLE.xx |
255 10100 | xx | rs2 | rs1 | 001 | rd | 1010011 | FLT.xx |
256 10100 | xx | rs2 | rs1 | 010 | rd | 1010011 | FEQ.xx |
257 10100 | xx | rs2 | rs1 | 011 | rd | 1010011 | ?f3=011 |
258 10100 | xx | rs2 | rs1 | 100 | rd | 1010011 | ?f3=100 |
259 10100 | xx | rs2 | rs1 | 101 | rd | 1010011 | ?f3=101 |
260 10100 | xx | rs2 | rs1 | 110 | rd | 1010011 | ?f3=110 |
261 10100 | xx | rs2 | rs1 | 111 | rd | 1010011 | ?f3=111 |
262 """]]
263
264 ## funct5 = 10101 - unused
265
266 Brownfield encodings available.
267
268 ## funct5 = 10110 - unused
269
270 Brownfield encodings available.
271
272 ## funct5 = 10111 - unused
273
274 Brownfield encodings available.
275
276 ## funct5 = 11000
277
278 This table uses rs2 for encoding 1-operand FP operations that require "rounding"
279
280 Notes:
281
282 * TODO FP16 (trivial)
283
284 [[!table data="""
285 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
286 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
287 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
288 11000 | 00 | 00000 | rs1 | rm | rd | 1010011 | FCVT.W.S |
289 11000 | 00 | 00001 | rs1 | rm | rd | 1010011 | FCVT.WU.S |
290 11000 | 00 | 00010 | rs1 | rm | rd | 1010011 | FCVT.L.S |
291 11000 | 00 | 00011 | rs1 | rm | rd | 1010011 | FCVT.LU.S |
292 11000 | 00 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
293 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
294 11000 | 01 | 00000 | rs1 | rm | rd | 1010011 | FCVT.W.D |
295 11000 | 01 | 00001 | rs1 | rm | rd | 1010011 | FCVT.WU.D |
296 11000 | 01 | 00010 | rs1 | rm | rd | 1010011 | FCVT.L.D |
297 11000 | 01 | 00011 | rs1 | rm | rd | 1010011 | FCVT.LU.D |
298 11000 | 01 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
299 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
300 11000 | 11 | 00000 | rs1 | rm | rd | 1010011 | FCVT.W.Q |
301 11000 | 11 | 00001 | rs1 | rm | rd | 1010011 | FCVT.WU.Q |
302 11000 | 11 | 00010 | rs1 | rm | rd | 1010011 | FCVT.L.Q |
303 11000 | 11 | 00011 | rs1 | rm | rd | 1010011 | FCVT.LU.Q |
304 11000 | 11 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
305 """]]
306
307 ## funct5 = 11001 - unused
308
309 Brownfield encodings available.
310
311 ## funct5 = 11010
312
313 This table uses rs2 for encoding 1-operand FP operations that require "rounding"
314
315 [[!table data="""
316 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
317 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
318 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
319 11010 | 00 | 00000 | rs1 | rm | rd | 1010011 | FCVT.S.W |
320 11010 | 00 | 00001 | rs1 | rm | rd | 1010011 | FCVT.S.WU |
321 11010 | 00 | 00010 | rs1 | rm | rd | 1010011 | FCVT.S.L |
322 11010 | 00 | 00011 | rs1 | rm | rd | 1010011 | FCVT.S.LU |
323 11010 | 00 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
324 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
325 11010 | 01 | 00000 | rs1 | rm | rd | 1010011 | FCVT.D.W |
326 11010 | 01 | 00001 | rs1 | rm | rd | 1010011 | FCVT.D.WU |
327 11010 | 01 | 00010 | rs1 | rm | rd | 1010011 | FCVT.D.L |
328 11010 | 01 | 00011 | rs1 | rm | rd | 1010011 | FCVT.D.LU |
329 11010 | 01 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
330 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
331 11010 | 11 | 00000 | rs1 | rm | rd | 1010011 | FCVT.Q.W |
332 11010 | 11 | 00001 | rs1 | rm | rd | 1010011 | FCVT.Q.WU |
333 11010 | 11 | 00010 | rs1 | rm | rd | 1010011 | FCVT.Q.L |
334 11010 | 11 | 00011 | rs1 | rm | rd | 1010011 | FCVT.Q.LU |
335 11010 | 11 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
336 """]]
337
338 ## funct5 = 11100
339
340 This table uses *both* rs2 *and* funct3 for encoding 1-operand FP operations.
341
342 Notes:
343
344 * FMV.X.Q is missing (alias of FMVH.X.D if it existed)
345 * TODO FP16 (trivial)
346 * FMVH.X.HW (half-word) missing?
347
348 [[!table data="""
349 31..27| 26..25| 24..20 |19..15|14...12| 11..7 | 6....0 | function |
350 funct5| SDHQ | rs2 | rs1 |funct3 | rd | opcode | name |
351 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
352 11100 | 00 | 00000 | rs1 | 000 | rd | 1010011 | FMV.X.W |
353 11100 | 00 | 00000 | rs1 | 001 | rd | 1010011 | FCLASS.S |
354 11100 | 00 | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
355 ------| ----- | ----- | -----| ----- | ----- | ------- | -------- |
356 11100 | 01 | 00000 | rs1 | 000 | rd | 1010011 | FMV.X.D **FMVH.X.W** |
357 11100 | 01 | 00000 | rs1 | 001 | rd | 1010011 | FCLASS.D |
358 11100 | xx | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
359 ------| ----- | ----- | -----| ----- | ----- | ------- | -------- |
360 11100 | 11 | 00000 | rs1 | 000 | rd | 1010011 | **FMVH.X.D** |
361 11100 | 11 | 00000 | rs1 | 001 | rd | 1010011 | FCLASS.Q |
362 11100 | xx | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
363 """]]
364
365 ## funct5 = 11101 - unused
366
367 Brownfield encodings available.
368
369 ## funct5 = 11110
370
371 This table uses *both* rs2 *and* funct3 for encoding 1-operand FP operations.
372
373 Notes:
374
375 * FMV.Q.X is missing (as is FMVH.D.X)
376 * FMVH.W.X is missing (alias of FMV.D.X)
377 * TODO FP16 (trivial)
378 * FMVH.HW.X (half-word) missing?
379
380 [[!table data="""
381 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
382 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
383 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
384 11110 | 00 | 00000 | rs1 | 000 | rd | 1010011 | FMV.W.X |
385 11110 | 00 | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
386 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
387 11110 | 01 | 00000 | rs1 | 000 | rd | 1010011 | FMV.D.X |
388 11110 | 01 | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
389 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
390 11110 | 11 | 00000 | rs1 | 000 | rd | 1010011 | ? |
391 11110 | 11 | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
392 """]]
393
394 ## funct5 = 11111 - unused
395
396 Brownfield encodings available.
397
398 ## funct5 = ?????
399
400 [[!table data="""
401 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
402 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
403 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
404 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
405 """]]
406