gem5 v24.0.0.0
Loading...
Searching...
No Matches
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
54namespace gem5
55{
56
57namespace ArmISA
58{
59
69
70static inline FPRounding
71FPCRRounding(FPSCR &fpscr)
72{
73 return (FPRounding)((uint32_t)fpscr >> 22 & 3);
74}
75
77template <class T>
80template <class T>
81T fplibAdd(T op1, T op2, FPSCR &fpscr);
83template <class T>
84int fplibCompare(T op1, T op2, bool signal_nans, FPSCR &fpscr);
86template <class T>
87bool fplibCompareEQ(T op1, T op2, FPSCR &fpscr);
89template <class T>
90bool fplibCompareGE(T op1, T op2, FPSCR &fpscr);
92template <class T>
93bool fplibCompareGT(T op1, T op2, FPSCR &fpscr);
95template <class T>
96bool fplibCompareUN(T op1, T op2, FPSCR &fpscr);
98template <class T1, class T2>
99T2 fplibConvert(T1 op, FPRounding rounding, FPSCR &fpscr);
101template <class T>
102T fplibDiv(T op1, T op2, FPSCR &fpscr);
104template <class T>
107template <class T>
108T fplibMax(T op1, T op2, FPSCR &fpscr);
110template <class T>
111T fplibMaxNum(T op1, T op2, FPSCR &fpscr);
113template <class T>
114T fplibMin(T op1, T op2, FPSCR &fpscr);
116template <class T>
117T fplibMinNum(T op1, T op2, FPSCR &fpscr);
119template <class T>
120T fplibMul(T op1, T op2, FPSCR &fpscr);
122template <class T>
123T fplibMulAdd(T addend, T op1, T op2, FPSCR &fpscr);
125template <class T>
126T fplibMulX(T op1, T op2, FPSCR &fpscr);
128template <class T>
131template <class T>
132T fplibRSqrtEstimate(T op, FPSCR &fpscr);
134template <class T>
135T fplibRSqrtStepFused(T op1, T op2, FPSCR &fpscr);
137template <class T>
138T fplibRecipEstimate(T op, FPSCR &fpscr);
140template <class T>
141T fplibRecipStepFused(T op1, T op2, FPSCR &fpscr);
143template <class T>
144T fplibRecpX(T op, FPSCR &fpscr);
146template <class T>
147T fplibRoundInt(T op, FPRounding rounding, bool exact, FPSCR &fpscr);
149template <class T>
150T fplibScale(T op1, T op2, FPSCR &fpscr);
152template <class T>
153T fplibSqrt(T op, FPSCR &fpscr);
155template <class T>
156T fplibSub(T op1, T op2, FPSCR &fpscr);
158template <class T>
159T fplibTrigMulAdd(uint8_t coeff_index, T op1, T op2, FPSCR &fpscr);
161template <class T>
162T fplibTrigSMul(T op1, T op2, FPSCR &fpscr);
164template <class T>
165T fplibTrigSSel(T op1, T op2, FPSCR &fpscr);
167template <class T1, class T2>
168T2 fplibFPToFixed(T1 op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr);
170template <class T>
171T fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
172 FPSCR &fpscr);
174template <class T>
175T fplibInfinity(int sgn);
177template <class T>
180uint32_t fplibFPToFixedJS(uint64_t op, FPSCR &fpscr, bool Is64, uint8_t &nz);
181
182/* Function specializations... */
183template <>
184uint16_t fplibAbs(uint16_t op);
185template <>
186uint32_t fplibAbs(uint32_t op);
187template <>
188uint64_t fplibAbs(uint64_t op);
189template <>
190uint16_t fplibAdd(uint16_t op1, uint16_t op2, FPSCR &fpscr);
191template <>
192uint32_t fplibAdd(uint32_t op1, uint32_t op2, FPSCR &fpscr);
193template <>
194uint64_t fplibAdd(uint64_t op1, uint64_t op2, FPSCR &fpscr);
195template <>
196int fplibCompare(uint16_t op1, uint16_t op2, bool signal_nans, FPSCR &fpscr);
197template <>
198int fplibCompare(uint32_t op1, uint32_t op2, bool signal_nans, FPSCR &fpscr);
199template <>
200int fplibCompare(uint64_t op1, uint64_t op2, bool signal_nans, FPSCR &fpscr);
201template <>
202bool fplibCompareEQ(uint16_t op1, uint16_t op2, FPSCR &fpscr);
203template <>
204bool fplibCompareEQ(uint32_t op1, uint32_t op2, FPSCR &fpscr);
205template <>
206bool fplibCompareEQ(uint64_t op1, uint64_t op2, FPSCR &fpscr);
207template <>
208bool fplibCompareGE(uint16_t op1, uint16_t op2, FPSCR &fpscr);
209template <>
210bool fplibCompareGE(uint32_t op1, uint32_t op2, FPSCR &fpscr);
211template <>
212bool fplibCompareGE(uint64_t op1, uint64_t op2, FPSCR &fpscr);
213template <>
214bool fplibCompareGT(uint16_t op1, uint16_t op2, FPSCR &fpscr);
215template <>
216bool fplibCompareGT(uint32_t op1, uint32_t op2, FPSCR &fpscr);
217template <>
218bool fplibCompareGT(uint64_t op1, uint64_t op2, FPSCR &fpscr);
219template <>
220bool fplibCompareUN(uint16_t op1, uint16_t op2, FPSCR &fpscr);
221template <>
222bool fplibCompareUN(uint32_t op1, uint32_t op2, FPSCR &fpscr);
223template <>
224bool fplibCompareUN(uint64_t op1, uint64_t op2, FPSCR &fpscr);
225template <>
226uint16_t fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr);
227template <>
228uint16_t fplibConvert(uint64_t op, FPRounding rounding, FPSCR &fpscr);
229template <>
230uint32_t fplibConvert(uint16_t op, FPRounding rounding, FPSCR &fpscr);
231template <>
232uint32_t fplibConvert(uint64_t op, FPRounding rounding, FPSCR &fpscr);
233template <>
234uint64_t fplibConvert(uint16_t op, FPRounding rounding, FPSCR &fpscr);
235template <>
236uint64_t fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr);
237template <>
238uint16_t fplibDiv(uint16_t op1, uint16_t op2, FPSCR &fpscr);
239template <>
240uint32_t fplibDiv(uint32_t op1, uint32_t op2, FPSCR &fpscr);
241template <>
242uint64_t fplibDiv(uint64_t op1, uint64_t op2, FPSCR &fpscr);
243template <>
244uint16_t fplibExpA(uint16_t op);
245template <>
246uint32_t fplibExpA(uint32_t op);
247template <>
248uint64_t fplibExpA(uint64_t op);
249template <>
250uint16_t fplibMax(uint16_t op1, uint16_t op2, FPSCR &fpscr);
251template <>
252uint32_t fplibMax(uint32_t op1, uint32_t op2, FPSCR &fpscr);
253template <>
254uint64_t fplibMax(uint64_t op1, uint64_t op2, FPSCR &fpscr);
255template <>
256uint16_t fplibMaxNum(uint16_t op1, uint16_t op2, FPSCR &fpscr);
257template <>
258uint32_t fplibMaxNum(uint32_t op1, uint32_t op2, FPSCR &fpscr);
259template <>
260uint64_t fplibMaxNum(uint64_t op1, uint64_t op2, FPSCR &fpscr);
261template <>
262uint16_t fplibMin(uint16_t op1, uint16_t op2, FPSCR &fpscr);
263template <>
264uint32_t fplibMin(uint32_t op1, uint32_t op2, FPSCR &fpscr);
265template <>
266uint64_t fplibMin(uint64_t op1, uint64_t op2, FPSCR &fpscr);
267template <>
268uint16_t fplibMinNum(uint16_t op1, uint16_t op2, FPSCR &fpscr);
269template <>
270uint32_t fplibMinNum(uint32_t op1, uint32_t op2, FPSCR &fpscr);
271template <>
272uint64_t fplibMinNum(uint64_t op1, uint64_t op2, FPSCR &fpscr);
273template <>
274uint16_t fplibMul(uint16_t op1, uint16_t op2, FPSCR &fpscr);
275template <>
276uint32_t fplibMul(uint32_t op1, uint32_t op2, FPSCR &fpscr);
277template <>
278uint64_t fplibMul(uint64_t op1, uint64_t op2, FPSCR &fpscr);
279template <>
280uint16_t fplibMulAdd(uint16_t addend, uint16_t op1, uint16_t op2,
281 FPSCR &fpscr);
282template <>
283uint32_t fplibMulAdd(uint32_t addend, uint32_t op1, uint32_t op2,
284 FPSCR &fpscr);
285template <>
286uint64_t fplibMulAdd(uint64_t addend, uint64_t op1, uint64_t op2,
287 FPSCR &fpscr);
288template <>
289uint16_t fplibMulX(uint16_t op1, uint16_t op2, FPSCR &fpscr);
290template <>
291uint32_t fplibMulX(uint32_t op1, uint32_t op2, FPSCR &fpscr);
292template <>
293uint64_t fplibMulX(uint64_t op1, uint64_t op2, FPSCR &fpscr);
294template <>
295uint16_t fplibNeg(uint16_t op);
296template <>
297uint32_t fplibNeg(uint32_t op);
298template <>
299uint64_t fplibNeg(uint64_t op);
300template <>
301uint16_t fplibRSqrtEstimate(uint16_t op, FPSCR &fpscr);
302template <>
303uint32_t fplibRSqrtEstimate(uint32_t op, FPSCR &fpscr);
304template<>
305uint64_t fplibRSqrtEstimate(uint64_t op, FPSCR &fpscr);
306template <>
307uint16_t fplibRSqrtStepFused(uint16_t op1, uint16_t op2, FPSCR &fpscr);
308template <>
309uint32_t fplibRSqrtStepFused(uint32_t op1, uint32_t op2, FPSCR &fpscr);
310template <>
311uint64_t fplibRSqrtStepFused(uint64_t op1, uint64_t op2, FPSCR &fpscr);
312template <>
313uint16_t fplibRecipEstimate(uint16_t op, FPSCR &fpscr);
314template <>
315uint32_t fplibRecipEstimate(uint32_t op, FPSCR &fpscr);
316template <>
317uint64_t fplibRecipEstimate(uint64_t op, FPSCR &fpscr);
318template <>
319uint16_t fplibRecipStepFused(uint16_t op1, uint16_t op2, FPSCR &fpscr);
320template <>
321uint32_t fplibRecipStepFused(uint32_t op1, uint32_t op2, FPSCR &fpscr);
322template <>
323uint64_t fplibRecipStepFused(uint64_t op1, uint64_t op2, FPSCR &fpscr);
324template <>
325uint16_t fplibRecpX(uint16_t op, FPSCR &fpscr);
326template <>
327uint32_t fplibRecpX(uint32_t op, FPSCR &fpscr);
328template <>
329uint64_t fplibRecpX(uint64_t op, FPSCR &fpscr);
330template <>
331uint16_t fplibRoundInt(uint16_t op, FPRounding rounding, bool exact,
332 FPSCR &fpscr);
333template <>
334uint32_t fplibRoundInt(uint32_t op, FPRounding rounding, bool exact,
335 FPSCR &fpscr);
336template <>
337uint64_t fplibRoundInt(uint64_t op, FPRounding rounding, bool exact,
338 FPSCR &fpscr);
339template <>
340uint16_t fplibScale(uint16_t op1, uint16_t op2, FPSCR &fpscr);
341template <>
342uint32_t fplibScale(uint32_t op1, uint32_t op2, FPSCR &fpscr);
343template <>
344uint64_t fplibScale(uint64_t op1, uint64_t op2, FPSCR &fpscr);
345template <>
346uint16_t fplibSqrt(uint16_t op, FPSCR &fpscr);
347template <>
348uint32_t fplibSqrt(uint32_t op, FPSCR &fpscr);
349template <>
350uint64_t fplibSqrt(uint64_t op, FPSCR &fpscr);
351template <>
352uint16_t fplibSub(uint16_t op1, uint16_t op2, FPSCR &fpscr);
353template <>
354uint32_t fplibSub(uint32_t op1, uint32_t op2, FPSCR &fpscr);
355template <>
356uint64_t fplibSub(uint64_t op1, uint64_t op2, FPSCR &fpscr);
357template <>
358uint16_t fplibTrigMulAdd(uint8_t coeff_index, uint16_t op1, uint16_t op2,
359 FPSCR &fpscr);
360template <>
361uint32_t fplibTrigMulAdd(uint8_t coeff_index, uint32_t op1, uint32_t op2,
362 FPSCR &fpscr);
363template <>
364uint64_t fplibTrigMulAdd(uint8_t coeff_index, uint64_t op1, uint64_t op2,
365 FPSCR &fpscr);
366template <>
367uint16_t fplibTrigSMul(uint16_t op1, uint16_t op2, FPSCR &fpscr);
368template <>
369uint32_t fplibTrigSMul(uint32_t op1, uint32_t op2, FPSCR &fpscr);
370template <>
371uint64_t fplibTrigSMul(uint64_t op1, uint64_t op2, FPSCR &fpscr);
372template <>
373uint16_t fplibTrigSSel(uint16_t op1, uint16_t op2, FPSCR &fpscr);
374template <>
375uint32_t fplibTrigSSel(uint32_t op1, uint32_t op2, FPSCR &fpscr);
376template <>
377uint64_t fplibTrigSSel(uint64_t op1, uint64_t op2, FPSCR &fpscr);
378template <>
379uint16_t fplibFPToFixed(uint16_t op, int fbits, bool u, FPRounding rounding,
380 FPSCR &fpscr);
381template <>
382uint32_t fplibFPToFixed(uint16_t op, int fbits, bool u, FPRounding rounding,
383 FPSCR &fpscr);
384template <>
385uint32_t fplibFPToFixed(uint32_t op, int fbits, bool u, FPRounding rounding,
386 FPSCR &fpscr);
387template <>
388uint32_t fplibFPToFixed(uint64_t op, int fbits, bool u, FPRounding rounding,
389 FPSCR &fpscr);
390template <>
391uint64_t fplibFPToFixed(uint16_t op, int fbits, bool u, FPRounding rounding,
392 FPSCR &fpscr);
393template <>
394uint64_t fplibFPToFixed(uint32_t op, int fbits, bool u, FPRounding rounding,
395 FPSCR &fpscr);
396template <>
397uint64_t fplibFPToFixed(uint64_t op, int fbits, bool u, FPRounding rounding,
398 FPSCR &fpscr);
399template <>
400uint16_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
401 FPSCR &fpscr);
402template <>
403uint32_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
404 FPSCR &fpscr);
405template <>
406uint64_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
407 FPSCR &fpscr);
408template <>
409uint16_t fplibInfinity(int sgn);
410template <>
411uint32_t fplibInfinity(int sgn);
412template <>
413uint64_t fplibInfinity(int sgn);
414template <>
415uint16_t fplibDefaultNaN();
416template <>
417uint32_t fplibDefaultNaN();
418template <>
419uint64_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 fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr)
Definition fplib.cc:2627
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 fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr)
Definition fplib.cc:4966
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 fplibMulX(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition fplib.cc:3398
uint16_t fplibAbs(uint16_t op)
Definition fplib.cc:2372
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 fplibScale(uint16_t op1, uint16_t op2, FPSCR &fpscr)
Definition fplib.cc:4278
Bitfield< 22 > u
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 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 fplibDefaultNaN()
Definition fplib.cc:5024
uint16_t fplibFPToFixed(uint16_t op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr)
Definition fplib.cc:4638
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 fplibInfinity(int sgn)
Definition fplib.cc:5003
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
Bitfield< 4 > op
Definition types.hh:83
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
Definition binary32.hh:36

Generated on Tue Jun 18 2024 16:23:56 for gem5 by doxygen 1.11.0