add descriptions on each table
[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 # Main FP opcode 1010011 table
17
18 Notes:
19
20 * Proposed new encodings in **bold**.
21 * *Use funct5 sparingly!* - 2-operand functions only.
22 * Single-argument FP operations should go under one of the funct5 tables
23 * Both dual and single argument FP operations that do not require
24 "rounding mode" should go in one of the funct5 tables that already use
25 "funct3".
26 * Be careful not to use encoding space for which FP16 has already been
27 reserved.
28
29 [[!table data="""
30 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
31 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
32 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
33 00000 | xx | rs2 | rs1 | rm | rd | 1010011 | FADD.xx |
34 00001 | xx | rs2 | rs1 | rm | rd | 1010011 | FSUB.xx |
35 00010 | xx | rs2 | rs1 | rm | rd | 1010011 | FMUL.xx |
36 00011 | xx | rs2 | rs1 | rm | rd | 1010011 | FDIV.xx |
37 00100 | xx | rs2 | rs1 | yyy | rd | 1010011 | tb=00100 |
38 00101 | xx | rs2 | rs1 | yyy | rd | 1010011 | tb=00101 |
39 00110 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
40 00111 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
41 01000 | xx | rs2 | rs1 | yyy | rd | 1010011 | tb=01000 |
42 01001 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
43 01010 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
44 01011 | xx | xxxxx | rs1 | yyy | rd | 1010011 | tb=01011 |
45 01100 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
46 01101 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
47 01110 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
48 01111 | xx | rs2 | rs1 | yyy | rd | 1010011 | **FPOW.xx** |
49 10000 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
50 10001 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
51 10010 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
52 10011 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
53 10100 | xx | rs2 | rs1 | yyy | rd | 1010011 | tb=10100 |
54 10101 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
55 10110 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
56 10111 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
57 11000 | xx | xxxxx | rs1 | yyy | rd | 1010011 | tb=11000 |
58 11001 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
59 11010 | xx | xxxxx | rs1 | yyy | rd | 1010011 | tb=11010 |
60 11100 | xx | xxxxx | rs1 | 000 | rd | 1010011 | tb=11100 |
61 11101 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
62 11110 | xx | xxxxx | rs1 | 000 | rd | 1010011 | tb=11110 |
63 11111 | xx | rs2 | rs1 | yyy | rd | 1010011 | ? |
64 """]]
65
66 ## funct5 = 00100
67
68 This table uses funct3 for encoding 2-operand FP operations
69
70 [[!table data="""
71 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
72 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
73 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
74 00100 | xx | rs2 | rs1 | 000 | rd | 1010011 | FSGNJ.xx |
75 00100 | xx | rs2 | rs1 | 001 | rd | 1010011 | FSGNJN.xx |
76 00100 | xx | rs2 | rs1 | 010 | rd | 1010011 | FSGNJX.xx |
77 00100 | xx | rs2 | rs1 | 011 | rd | 1010011 | ?f3=011 |
78 00100 | xx | rs2 | rs1 | 100 | rd | 1010011 | ?f3=100 |
79 00100 | xx | rs2 | rs1 | 101 | rd | 1010011 | ?f3=101 |
80 00100 | xx | rs2 | rs1 | 110 | rd | 1010011 | ?f3=110 |
81 00100 | xx | rs2 | rs1 | 111 | rd | 1010011 | ?f3=111 |
82 """]]
83
84 # funct5 = 00101
85
86 This table uses funct3 for encoding 2-operand FP operations where the result
87 register is a **floating-point** value.
88
89 [[!table data="""
90 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
91 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
92 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
93 00101 | xx | rs2 | rs1 | 000 | rd | 1010011 | FMIN.S |
94 00101 | xx | rs2 | rs1 | 001 | rd | 1010011 | FMAX.S |
95 00101 | xx | rs2 | rs1 | 010 | rd | 1010011 | ?f3=010 |
96 00101 | xx | rs2 | rs1 | 011 | rd | 1010011 | ?f3=011 |
97 00101 | xx | rs2 | rs1 | 100 | rd | 1010011 | ?f3=100 |
98 00101 | xx | rs2 | rs1 | 101 | rd | 1010011 | ?f3=101 |
99 00101 | xx | rs2 | rs1 | 110 | rd | 1010011 | ?f3=110 |
100 00101 | xx | rs2 | rs1 | 111 | rd | 1010011 | ?f3=111 |
101 """]]
102
103 # funct5 = 01000
104
105 This table uses rs2 for encoding 1-operand FP operations that require "rounding"
106
107 Notes:
108
109 * TODO FP16 (trivial)
110
111
112 [[!table data="""
113 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
114 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
115 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
116 01000 | 00 | 00001 | rs1 | rm | rd | 1010011 | FCVT.S.D |
117 01000 | 00 | 00011 | rs1 | rm | rd | 1010011 | FCVT.S.Q |
118 01000 | 00 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
119 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
120 01000 | 01 | 00000 | rs1 | rm | rd | 1010011 | FCVT.D.S |
121 01000 | 01 | 00011 | rs1 | rm | rd | 1010011 | FCVT.D.Q |
122 01000 | 01 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
123 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
124 01000 | 11 | 00000 | rs1 | rm | rd | 1010011 | FCVT.Q.S |
125 01000 | 11 | 00001 | rs1 | rm | rd | 1010011 | FCVT.Q.D |
126 01000 | 11 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
127 """]]
128
129 # funct5 = 01011
130
131 This table uses rs2 for encoding 1-operand FP operations that require "rounding"
132
133 [[!table data="""
134 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
135 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
136 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
137 01011 | xx | 00000 | rs1 | rm | rd | 1010011 | FSQRT.xx |
138 01011 | xx | 00001 | rs1 | rm | rd | 1010011 | **FRSQRT.xx** |
139 01011 | xx | 00010 | rs1 | rm | rd | 1010011 | **FSIN.xx** |
140 01011 | xx | 00011 | rs1 | rm | rd | 1010011 | **FCOS.xx** |
141 01011 | xx | 00100 | rs1 | rm | rd | 1010011 | **FATAN.xx** |
142 01011 | xx | 00101 | rs1 | rm | rd | 1010011 | **FEXP.xx** |
143 01011 | xx | 00110 | rs1 | rm | rd | 1010011 | **FLOG.xx** |
144 01011 | xx | 00111 | rs1 | rm | rd | 1010011 | **FRCP.xx** |
145 01011 | xx | 01000 | rs1 | rm | rd | 1010011 | ? |
146 01011 | xx | 01001 | rs1 | rm | rd | 1010011 | ? |
147 01011 | xx | 01010 | rs1 | rm | rd | 1010011 | ? |
148 01011 | xx | 01011 | rs1 | rm | rd | 1010011 | ? |
149 01011 | xx | 01100 | rs1 | rm | rd | 1010011 | ? |
150 01011 | xx | 01101 | rs1 | rm | rd | 1010011 | ? |
151 01011 | xx | 01110 | rs1 | rm | rd | 1010011 | ? |
152 01011 | xx | 01111 | rs1 | rm | rd | 1010011 | ? |
153 01011 | xx | 10000 | rs1 | rm | rd | 1010011 | ? |
154 01011 | xx | 10001 | rs1 | rm | rd | 1010011 | ? |
155 01011 | xx | 10010 | rs1 | rm | rd | 1010011 | ? |
156 01011 | xx | 10011 | rs1 | rm | rd | 1010011 | ? |
157 01011 | xx | 10100 | rs1 | rm | rd | 1010011 | ? |
158 01011 | xx | 10101 | rs1 | rm | rd | 1010011 | ? |
159 01011 | xx | 10110 | rs1 | rm | rd | 1010011 | ? |
160 01011 | xx | 10111 | rs1 | rm | rd | 1010011 | ? |
161 01011 | xx | 11000 | rs1 | rm | rd | 1010011 | ? |
162 01011 | xx | 11001 | rs1 | rm | rd | 1010011 | ? |
163 01011 | xx | 11010 | rs1 | rm | rd | 1010011 | ? |
164 01011 | xx | 11011 | rs1 | rm | rd | 1010011 | ? |
165 01011 | xx | 11100 | rs1 | rm | rd | 1010011 | ? |
166 01011 | xx | 11101 | rs1 | rm | rd | 1010011 | ? |
167 01011 | xx | 11110 | rs1 | rm | rd | 1010011 | ? |
168 01011 | xx | 11111 | rs1 | rm | rd | 1010011 | ? |
169 """]]
170
171 # funct5 = 10100
172
173 This table uses funct3 for encoding 2-operand FP "comparison" operations
174 where the result register is an **integer**
175
176 Notes:
177
178 * FNE missing?
179
180 [[!table data="""
181 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
182 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
183 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
184 10100 | xx | rs2 | rs1 | 000 | rd | 1010011 | FLE.xx |
185 10100 | xx | rs2 | rs1 | 001 | rd | 1010011 | FLT.xx |
186 10100 | xx | rs2 | rs1 | 010 | rd | 1010011 | FEQ.xx |
187 10100 | xx | rs2 | rs1 | 011 | rd | 1010011 | ?f3=011 |
188 10100 | xx | rs2 | rs1 | 100 | rd | 1010011 | ?f3=100 |
189 10100 | xx | rs2 | rs1 | 101 | rd | 1010011 | ?f3=101 |
190 10100 | xx | rs2 | rs1 | 110 | rd | 1010011 | ?f3=110 |
191 10100 | xx | rs2 | rs1 | 111 | rd | 1010011 | ?f3=111 |
192 """]]
193
194 # funct5 = 11000
195
196 This table uses rs2 for encoding 1-operand FP operations that require "rounding"
197
198 Notes:
199
200 * TODO FP16 (trivial)
201
202 [[!table data="""
203 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
204 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
205 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
206 11000 | 00 | 00000 | rs1 | rm | rd | 1010011 | FCVT.W.S |
207 11000 | 00 | 00001 | rs1 | rm | rd | 1010011 | FCVT.WU.S |
208 11000 | 00 | 00010 | rs1 | rm | rd | 1010011 | FCVT.L.S |
209 11000 | 00 | 00011 | rs1 | rm | rd | 1010011 | FCVT.LU.S |
210 11000 | 00 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
211 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
212 11000 | 01 | 00000 | rs1 | rm | rd | 1010011 | FCVT.W.D |
213 11000 | 01 | 00001 | rs1 | rm | rd | 1010011 | FCVT.WU.D |
214 11000 | 01 | 00010 | rs1 | rm | rd | 1010011 | FCVT.L.D |
215 11000 | 01 | 00011 | rs1 | rm | rd | 1010011 | FCVT.LU.D |
216 11000 | 01 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
217 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
218 11000 | 11 | 00000 | rs1 | rm | rd | 1010011 | FCVT.W.Q |
219 11000 | 11 | 00001 | rs1 | rm | rd | 1010011 | FCVT.WU.Q |
220 11000 | 11 | 00010 | rs1 | rm | rd | 1010011 | FCVT.L.Q |
221 11000 | 11 | 00011 | rs1 | rm | rd | 1010011 | FCVT.LU.Q |
222 11000 | 11 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
223 """]]
224
225 # funct5 = 11010
226
227 This table uses rs2 for encoding 1-operand FP operations that require "rounding"
228
229 [[!table data="""
230 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
231 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
232 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
233 11010 | 00 | 00000 | rs1 | rm | rd | 1010011 | FCVT.S.W |
234 11010 | 00 | 00001 | rs1 | rm | rd | 1010011 | FCVT.S.WU |
235 11010 | 00 | 00010 | rs1 | rm | rd | 1010011 | FCVT.S.L |
236 11010 | 00 | 00011 | rs1 | rm | rd | 1010011 | FCVT.S.LU |
237 11010 | 00 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
238 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
239 11010 | 01 | 00000 | rs1 | rm | rd | 1010011 | FCVT.D.W |
240 11010 | 01 | 00001 | rs1 | rm | rd | 1010011 | FCVT.D.WU |
241 11010 | 01 | 00010 | rs1 | rm | rd | 1010011 | FCVT.D.L |
242 11010 | 01 | 00011 | rs1 | rm | rd | 1010011 | FCVT.D.LU |
243 11010 | 01 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
244 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
245 11010 | 11 | 00000 | rs1 | rm | rd | 1010011 | FCVT.Q.W |
246 11010 | 11 | 00001 | rs1 | rm | rd | 1010011 | FCVT.Q.WU |
247 11010 | 11 | 00010 | rs1 | rm | rd | 1010011 | FCVT.Q.L |
248 11010 | 11 | 00011 | rs1 | rm | rd | 1010011 | FCVT.Q.LU |
249 11010 | 11 | xxxxx | rs1 | rm | rd | 1010011 | rs2? |
250 """]]
251
252 # funct5 = 11100
253
254 This table uses *both* rs2 *and* funct3 for encoding 1-operand FP operations.
255
256 Notes:
257
258 * FMV.X.Q is missing (alias of FMVH.X.D if it existed)
259 * TODO FP16 (trivial)
260 * FMVH.X.HW (half-word) missing?
261
262 [[!table data="""
263 31..27| 26..25| 24..20 |19..15|14...12| 11..7 | 6....0 | function |
264 funct5| SDHQ | rs2 | rs1 |funct3 | rd | opcode | name |
265 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
266 11100 | 00 | 00000 | rs1 | 000 | rd | 1010011 | FMV.X.W |
267 11100 | 00 | 00000 | rs1 | 001 | rd | 1010011 | FCLASS.S |
268 11100 | 00 | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
269 ------| ----- | ----- | -----| ----- | ----- | ------- | -------- |
270 11100 | 01 | 00000 | rs1 | 000 | rd | 1010011 | FMV.X.D **FMVH.X.W** |
271 11100 | 01 | 00000 | rs1 | 001 | rd | 1010011 | FCLASS.D |
272 11100 | xx | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
273 ------| ----- | ----- | -----| ----- | ----- | ------- | -------- |
274 11100 | 11 | 00000 | rs1 | 000 | rd | 1010011 | **FMVH.X.D** |
275 11100 | 11 | 00000 | rs1 | 001 | rd | 1010011 | FCLASS.Q |
276 11100 | xx | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
277 """]]
278
279 # funct5 = 11110
280
281 This table uses *both* rs2 *and* funct3 for encoding 1-operand FP operations.
282
283 Notes:
284
285 * FMV.Q.X is missing (as is FMVH.D.X)
286 * FMVH.W.X is missing (alias of FMV.D.X)
287 * TODO FP16 (trivial)
288 * FMVH.HW.X (half-word) missing?
289
290 [[!table data="""
291 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
292 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
293 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
294 11110 | 00 | 00000 | rs1 | 000 | rd | 1010011 | FMV.W.X |
295 11110 | 00 | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
296 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
297 11110 | 01 | 00000 | rs1 | 000 | rd | 1010011 | FMV.D.X |
298 11110 | 01 | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
299 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
300 11110 | 11 | 00000 | rs1 | 000 | rd | 1010011 | ? |
301 11110 | 11 | xxxxx | rs1 | yyy | rd | 1010011 | rs2? f3? |
302 """]]
303
304 # funct5 = ?????
305
306 [[!table data="""
307 31..27 | 26..25 | 24..20 |19..15| 14...12| 11..7 | 6....0 | function |
308 funct5 | SDHQ | rs2 | rs1 | funct3 | rd | opcode | name |
309 5 | 2 | 5 | 5 | 3 | 5 | 7 | |
310 ------ | ----- | ----- | -----| ----- | ----- | ------- | -------- |
311 """]]
312