gem5  v22.1.0.0
fplib.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013, 2017-2018 ARM Limited
3  * Copyright (c) 2020 Metempsy Technology Consulting
4  * All rights reserved
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions are
17  * met: redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer;
19  * redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution;
22  * neither the name of the copyright holders nor the names of its
23  * contributors may be used to endorse or promote products derived from
24  * this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
47 #ifndef __ARCH_ARM_INSTS_FPLIB_HH__
48 #define __ARCH_ARM_INSTS_FPLIB_HH__
49 
50 #include <stdint.h>
51 
52 #include "arch/arm/regs/misc.hh"
53 
54 namespace gem5
55 {
56 
57 namespace ArmISA
58 {
59 
61 {
67  FPRounding_ODD = 5
68 };
69 
70 static inline FPRounding
71 FPCRRounding(FPSCR &fpscr)
72 {
73  return (FPRounding)((uint32_t)fpscr >> 22 & 3);
74 }
75 
77 template <class T>
78 T fplibAbs(T op);
80 template <class T>
81 T fplibAdd(T op1, T op2, FPSCR &fpscr);
83 template <class T>
84 int fplibCompare(T op1, T op2, bool signal_nans, FPSCR &fpscr);
86 template <class T>
87 bool fplibCompareEQ(T op1, T op2, FPSCR &fpscr);
89 template <class T>
90 bool fplibCompareGE(T op1, T op2, FPSCR &fpscr);
92 template <class T>
93 bool fplibCompareGT(T op1, T op2, FPSCR &fpscr);
95 template <class T>
96 bool fplibCompareUN(T op1, T op2, FPSCR &fpscr);
98 template <class T1, class T2>
99 T2 fplibConvert(T1 op, FPRounding rounding, FPSCR &fpscr);
101 template <class T>
102 T fplibDiv(T op1, T op2, FPSCR &fpscr);
104 template <class T>
107 template <class T>
108 T fplibMax(T op1, T op2, FPSCR &fpscr);
110 template <class T>
111 T fplibMaxNum(T op1, T op2, FPSCR &fpscr);
113 template <class T>
114 T fplibMin(T op1, T op2, FPSCR &fpscr);
116 template <class T>
117 T fplibMinNum(T op1, T op2, FPSCR &fpscr);
119 template <class T>
120 T fplibMul(T op1, T op2, FPSCR &fpscr);
122 template <class T>
123 T fplibMulAdd(T addend, T op1, T op2, FPSCR &fpscr);
125 template <class T>
126 T fplibMulX(T op1, T op2, FPSCR &fpscr);
128 template <class T>
131 template <class T>
132 T fplibRSqrtEstimate(T op, FPSCR &fpscr);
134 template <class T>
135 T fplibRSqrtStepFused(T op1, T op2, FPSCR &fpscr);
137 template <class T>
138 T fplibRecipEstimate(T op, FPSCR &fpscr);
140 template <class T>
141 T fplibRecipStepFused(T op1, T op2, FPSCR &fpscr);
143 template <class T>
144 T fplibRecpX(T op, FPSCR &fpscr);
146 template <class T>
147 T fplibRoundInt(T op, FPRounding rounding, bool exact, FPSCR &fpscr);
149 template <class T>
150 T fplibScale(T op1, T op2, FPSCR &fpscr);
152 template <class T>
153 T fplibSqrt(T op, FPSCR &fpscr);
155 template <class T>
156 T fplibSub(T op1, T op2, FPSCR &fpscr);
158 template <class T>
159 T fplibTrigMulAdd(uint8_t coeff_index, T op1, T op2, FPSCR &fpscr);
161 template <class T>
162 T fplibTrigSMul(T op1, T op2, FPSCR &fpscr);
164 template <class T>
165 T fplibTrigSSel(T op1, T op2, FPSCR &fpscr);
167 template <class T1, class T2>
168 T2 fplibFPToFixed(T1 op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr);
170 template <class T>
171 T fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
172  FPSCR &fpscr);
174 template <class T>
175 T fplibInfinity(int sgn);
177 template <class T>
178 T fplibDefaultNaN();
180 uint32_t fplibFPToFixedJS(uint64_t op, FPSCR &fpscr, bool Is64, uint8_t &nz);
181 
182 /* Function specializations... */
183 template <>
184 uint16_t fplibAbs(uint16_t op);
185 template <>
186 uint32_t fplibAbs(uint32_t op);
187 template <>
188 uint64_t fplibAbs(uint64_t op);
189 template <>
190 uint16_t fplibAdd(uint16_t op1, uint16_t op2, FPSCR &fpscr);
191 template <>
192 uint32_t fplibAdd(uint32_t op1, uint32_t op2, FPSCR &fpscr);
193 template <>
194 uint64_t fplibAdd(uint64_t op1, uint64_t op2, FPSCR &fpscr);
195 template <>
196 int fplibCompare(uint16_t op1, uint16_t op2, bool signal_nans, FPSCR &fpscr);
197 template <>
198 int fplibCompare(uint32_t op1, uint32_t op2, bool signal_nans, FPSCR &fpscr);
199 template <>
200 int fplibCompare(uint64_t op1, uint64_t op2, bool signal_nans, FPSCR &fpscr);
201 template <>
202 bool fplibCompareEQ(uint16_t op1, uint16_t op2, FPSCR &fpscr);
203 template <>
204 bool fplibCompareEQ(uint32_t op1, uint32_t op2, FPSCR &fpscr);
205 template <>
206 bool fplibCompareEQ(uint64_t op1, uint64_t op2, FPSCR &fpscr);
207 template <>
208 bool fplibCompareGE(uint16_t op1, uint16_t op2, FPSCR &fpscr);
209 template <>
210 bool fplibCompareGE(uint32_t op1, uint32_t op2, FPSCR &fpscr);
211 template <>
212 bool fplibCompareGE(uint64_t op1, uint64_t op2, FPSCR &fpscr);
213 template <>
214 bool fplibCompareGT(uint16_t op1, uint16_t op2, FPSCR &fpscr);
215 template <>
216 bool fplibCompareGT(uint32_t op1, uint32_t op2, FPSCR &fpscr);
217 template <>
218 bool fplibCompareGT(uint64_t op1, uint64_t op2, FPSCR &fpscr);
219 template <>
220 bool fplibCompareUN(uint16_t op1, uint16_t op2, FPSCR &fpscr);
221 template <>
222 bool fplibCompareUN(uint32_t op1, uint32_t op2, FPSCR &fpscr);
223 template <>
224 bool fplibCompareUN(uint64_t op1, uint64_t op2, FPSCR &fpscr);
225 template <>
226 uint16_t fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr);
227 template <>
228 uint16_t fplibConvert(uint64_t op, FPRounding rounding, FPSCR &fpscr);
229 template <>
230 uint32_t fplibConvert(uint16_t op, FPRounding rounding, FPSCR &fpscr);
231 template <>
232 uint32_t fplibConvert(uint64_t op, FPRounding rounding, FPSCR &fpscr);
233 template <>
234 uint64_t fplibConvert(uint16_t op, FPRounding rounding, FPSCR &fpscr);
235 template <>
236 uint64_t fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr);
237 template <>
238 uint16_t fplibDiv(uint16_t op1, uint16_t op2, FPSCR &fpscr);
239 template <>
240 uint32_t fplibDiv(uint32_t op1, uint32_t op2, FPSCR &fpscr);
241 template <>
242 uint64_t fplibDiv(uint64_t op1, uint64_t op2, FPSCR &fpscr);
243 template <>
244 uint16_t fplibExpA(uint16_t op);
245 template <>
246 uint32_t fplibExpA(uint32_t op);
247 template <>
248 uint64_t fplibExpA(uint64_t op);
249 template <>
250 uint16_t fplibMax(uint16_t op1, uint16_t op2, FPSCR &fpscr);
251 template <>
252 uint32_t fplibMax(uint32_t op1, uint32_t op2, FPSCR &fpscr);
253 template <>
254 uint64_t fplibMax(uint64_t op1, uint64_t op2, FPSCR &fpscr);
255 template <>
256 uint16_t fplibMaxNum(uint16_t op1, uint16_t op2, FPSCR &fpscr);
257 template <>
258 uint32_t fplibMaxNum(uint32_t op1, uint32_t op2, FPSCR &fpscr);
259 template <>
260 uint64_t fplibMaxNum(uint64_t op1, uint64_t op2, FPSCR &fpscr);
261 template <>
262 uint16_t fplibMin(uint16_t op1, uint16_t op2, FPSCR &fpscr);
263 template <>
264 uint32_t fplibMin(uint32_t op1, uint32_t op2, FPSCR &fpscr);
265 template <>
266 uint64_t fplibMin(uint64_t op1, uint64_t op2, FPSCR &fpscr);
267 template <>
268 uint16_t fplibMinNum(uint16_t op1, uint16_t op2, FPSCR &fpscr);
269 template <>
270 uint32_t fplibMinNum(uint32_t op1, uint32_t op2, FPSCR &fpscr);
271 template <>
272 uint64_t fplibMinNum(uint64_t op1, uint64_t op2, FPSCR &fpscr);
273 template <>
274 uint16_t fplibMul(uint16_t op1, uint16_t op2, FPSCR &fpscr);
275 template <>
276 uint32_t fplibMul(uint32_t op1, uint32_t op2, FPSCR &fpscr);
277 template <>
278 uint64_t fplibMul(uint64_t op1, uint64_t op2, FPSCR &fpscr);
279 template <>
280 uint16_t fplibMulAdd(uint16_t addend, uint16_t op1, uint16_t op2,
281  FPSCR &fpscr);
282 template <>
283 uint32_t fplibMulAdd(uint32_t addend, uint32_t op1, uint32_t op2,
284  FPSCR &fpscr);
285 template <>
286 uint64_t fplibMulAdd(uint64_t addend, uint64_t op1, uint64_t op2,
287  FPSCR &fpscr);
288 template <>
289 uint16_t fplibMulX(uint16_t op1, uint16_t op2, FPSCR &fpscr);
290 template <>
291 uint32_t fplibMulX(uint32_t op1, uint32_t op2, FPSCR &fpscr);
292 template <>
293 uint64_t fplibMulX(uint64_t op1, uint64_t op2, FPSCR &fpscr);
294 template <>
295 uint16_t fplibNeg(uint16_t op);
296 template <>
297 uint32_t fplibNeg(uint32_t op);
298 template <>
299 uint64_t fplibNeg(uint64_t op);
300 template <>
301 uint16_t fplibRSqrtEstimate(uint16_t op, FPSCR &fpscr);
302 template <>
303 uint32_t fplibRSqrtEstimate(uint32_t op, FPSCR &fpscr);
304 template<>
305 uint64_t fplibRSqrtEstimate(uint64_t op, FPSCR &fpscr);
306 template <>
307 uint16_t fplibRSqrtStepFused(uint16_t op1, uint16_t op2, FPSCR &fpscr);
308 template <>
309 uint32_t fplibRSqrtStepFused(uint32_t op1, uint32_t op2, FPSCR &fpscr);
310 template <>
311 uint64_t fplibRSqrtStepFused(uint64_t op1, uint64_t op2, FPSCR &fpscr);
312 template <>
313 uint16_t fplibRecipEstimate(uint16_t op, FPSCR &fpscr);
314 template <>
315 uint32_t fplibRecipEstimate(uint32_t op, FPSCR &fpscr);
316 template <>
317 uint64_t fplibRecipEstimate(uint64_t op, FPSCR &fpscr);
318 template <>
319 uint16_t fplibRecipStepFused(uint16_t op1, uint16_t op2, FPSCR &fpscr);
320 template <>
321 uint32_t fplibRecipStepFused(uint32_t op1, uint32_t op2, FPSCR &fpscr);
322 template <>
323 uint64_t fplibRecipStepFused(uint64_t op1, uint64_t op2, FPSCR &fpscr);
324 template <>
325 uint16_t fplibRecpX(uint16_t op, FPSCR &fpscr);
326 template <>
327 uint32_t fplibRecpX(uint32_t op, FPSCR &fpscr);
328 template <>
329 uint64_t fplibRecpX(uint64_t op, FPSCR &fpscr);
330 template <>
331 uint16_t fplibRoundInt(uint16_t op, FPRounding rounding, bool exact,
332  FPSCR &fpscr);
333 template <>
334 uint32_t fplibRoundInt(uint32_t op, FPRounding rounding, bool exact,
335  FPSCR &fpscr);
336 template <>
337 uint64_t fplibRoundInt(uint64_t op, FPRounding rounding, bool exact,
338  FPSCR &fpscr);
339 template <>
340 uint16_t fplibScale(uint16_t op1, uint16_t op2, FPSCR &fpscr);
341 template <>
342 uint32_t fplibScale(uint32_t op1, uint32_t op2, FPSCR &fpscr);
343 template <>
344 uint64_t fplibScale(uint64_t op1, uint64_t op2, FPSCR &fpscr);
345 template <>
346 uint16_t fplibSqrt(uint16_t op, FPSCR &fpscr);
347 template <>
348 uint32_t fplibSqrt(uint32_t op, FPSCR &fpscr);
349 template <>
350 uint64_t fplibSqrt(uint64_t op, FPSCR &fpscr);
351 template <>
352 uint16_t fplibSub(uint16_t op1, uint16_t op2, FPSCR &fpscr);
353 template <>
354 uint32_t fplibSub(uint32_t op1, uint32_t op2, FPSCR &fpscr);
355 template <>
356 uint64_t fplibSub(uint64_t op1, uint64_t op2, FPSCR &fpscr);
357 template <>
358 uint16_t fplibTrigMulAdd(uint8_t coeff_index, uint16_t op1, uint16_t op2,
359  FPSCR &fpscr);
360 template <>
361 uint32_t fplibTrigMulAdd(uint8_t coeff_index, uint32_t op1, uint32_t op2,
362  FPSCR &fpscr);
363 template <>
364 uint64_t fplibTrigMulAdd(uint8_t coeff_index, uint64_t op1, uint64_t op2,
365  FPSCR &fpscr);
366 template <>
367 uint16_t fplibTrigSMul(uint16_t op1, uint16_t op2, FPSCR &fpscr);
368 template <>
369 uint32_t fplibTrigSMul(uint32_t op1, uint32_t op2, FPSCR &fpscr);
370 template <>
371 uint64_t fplibTrigSMul(uint64_t op1, uint64_t op2, FPSCR &fpscr);
372 template <>
373 uint16_t fplibTrigSSel(uint16_t op1, uint16_t op2, FPSCR &fpscr);
374 template <>
375 uint32_t fplibTrigSSel(uint32_t op1, uint32_t op2, FPSCR &fpscr);
376 template <>
377 uint64_t fplibTrigSSel(uint64_t op1, uint64_t op2, FPSCR &fpscr);
378 template <>
379 uint16_t fplibFPToFixed(uint16_t op, int fbits, bool u, FPRounding rounding,
380  FPSCR &fpscr);
381 template <>
382 uint32_t fplibFPToFixed(uint16_t op, int fbits, bool u, FPRounding rounding,
383  FPSCR &fpscr);
384 template <>
385 uint32_t fplibFPToFixed(uint32_t op, int fbits, bool u, FPRounding rounding,
386  FPSCR &fpscr);
387 template <>
388 uint32_t fplibFPToFixed(uint64_t op, int fbits, bool u, FPRounding rounding,
389  FPSCR &fpscr);
390 template <>
391 uint64_t fplibFPToFixed(uint16_t op, int fbits, bool u, FPRounding rounding,
392  FPSCR &fpscr);
393 template <>
394 uint64_t fplibFPToFixed(uint32_t op, int fbits, bool u, FPRounding rounding,
395  FPSCR &fpscr);
396 template <>
397 uint64_t fplibFPToFixed(uint64_t op, int fbits, bool u, FPRounding rounding,
398  FPSCR &fpscr);
399 template <>
400 uint16_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
401  FPSCR &fpscr);
402 template <>
403 uint32_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
404  FPSCR &fpscr);
405 template <>
406 uint64_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
407  FPSCR &fpscr);
408 template <>
409 uint16_t fplibInfinity(int sgn);
410 template <>
411 uint32_t fplibInfinity(int sgn);
412 template <>
413 uint64_t fplibInfinity(int sgn);
414 template <>
415 uint16_t fplibDefaultNaN();
416 template <>
417 uint32_t fplibDefaultNaN();
418 template <>
419 uint64_t fplibDefaultNaN();
420 
421 } // namespace ArmISA
422 } // namespace gem5
423 
424 #endif
uint16_t fplibMax(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:3182
uint32_t fplibFPToFixedJS(uint64_t op, FPSCR &fpscr, bool is64, uint8_t &nz)
Floating-point JS convert to a signed integer, with rounding to zero.
Definition: fplib.cc:4755
static FPRounding FPCRRounding(FPSCR &fpscr)
Definition: fplib.hh:71
uint16_t fplibMinNum(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:3344
uint16_t fplibMaxNum(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:3251
uint16_t fplibDiv(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:2908
uint16_t fplibRSqrtEstimate(uint16_t op, FPSCR &fpscr)
Definition: fplib.cc:3531
uint16_t fplibNeg(uint16_t op)
Definition: fplib.cc:3491
bool fplibCompareGT(uint16_t a, uint16_t b, FPSCR &fpscr)
Definition: fplib.cc:2272
uint16_t fplibRecipEstimate(uint16_t op, FPSCR &fpscr)
Definition: fplib.cc:3726
uint16_t fplibExpA(uint16_t op)
Definition: fplib.cc:2938
uint16_t fplibTrigSSel(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:4528
uint16_t fplibSqrt(uint16_t op, FPSCR &fpscr)
Definition: fplib.cc:4308
bool fplibCompareEQ(uint16_t a, uint16_t b, FPSCR &fpscr)
Definition: fplib.cc:2252
uint16_t fplibAdd(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:2393
uint16_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr)
Floating-point convert from fixed-point.
Definition: fplib.cc:4966
uint16_t fplibMulX(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:3398
uint16_t fplibAbs(uint16_t op)
Definition: fplib.cc:2372
uint16_t fplibFPToFixed(uint16_t op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr)
Definition: fplib.cc:4638
bool fplibCompareGE(uint16_t a, uint16_t b, FPSCR &fpscr)
Definition: fplib.cc:2262
uint16_t fplibMul(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:3368
uint16_t fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr)
Definition: fplib.cc:2627
uint16_t fplibScale(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:4278
Bitfield< 22 > u
Definition: misc_types.hh:359
uint16_t fplibRecpX(uint16_t op, FPSCR &fpscr)
Definition: fplib.cc:4002
uint16_t fplibRecipStepFused(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:3912
uint16_t fplibTrigSMul(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:4470
uint16_t fplibInfinity(int sgn)
Floating-point value for +/- infinity.
Definition: fplib.cc:5003
uint16_t fplibTrigMulAdd(uint8_t coeff_index, uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:4368
uint16_t fplibRSqrtStepFused(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:3636
int fplibCompare(uint16_t op1, uint16_t op2, bool signal_nans, FPSCR &fpscr)
Definition: fplib.cc:2423
uint16_t fplibSub(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:4338
uint16_t fplibMulAdd(uint16_t addend, uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:2878
uint16_t fplibDefaultNaN()
Foating-point value for default NaN.
Definition: fplib.cc:5024
uint16_t fplibRoundInt(uint16_t op, FPRounding rounding, bool exact, FPSCR &fpscr)
Definition: fplib.cc:4083
@ FPRounding_POSINF
Definition: fplib.hh:63
@ FPRounding_ZERO
Definition: fplib.hh:65
@ FPRounding_TIEEVEN
Definition: fplib.hh:62
@ FPRounding_TIEAWAY
Definition: fplib.hh:66
@ FPRounding_ODD
Definition: fplib.hh:67
@ FPRounding_NEGINF
Definition: fplib.hh:64
uint16_t fplibMin(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition: fplib.cc:3275
bool fplibCompareUN(uint16_t a, uint16_t b, FPSCR &fpscr)
Definition: fplib.cc:2282
constexpr RegId T1
Definition: int.hh:147
constexpr RegId T2
Definition: int.hh:148
Bitfield< 4 > op
Definition: types.hh:83
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....

Generated on Wed Dec 21 2022 10:22:25 for gem5 by doxygen 1.9.1