gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
fplib.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  * Authors: Edmund Grimley Evans
38  * Thomas Grocutt
39  */
40 
49 #ifndef __ARCH_ARM_INSTS_FPLIB_HH__
50 #define __ARCH_ARM_INSTS_FPLIB_HH__
51 
52 #include <stdint.h>
53 
54 #include "arch/arm/miscregs.hh"
55 
56 namespace ArmISA
57 {
58 
59 enum FPRounding {
66 };
67 
68 static inline FPRounding
69 FPCRRounding(FPSCR &fpscr)
70 {
71  return (FPRounding)((uint32_t)fpscr >> 22 & 3);
72 }
73 
75 template <class T>
76 T fplibAbs(T op);
78 template <class T>
79 T fplibAdd(T op1, T op2, FPSCR &fpscr);
81 template <class T>
82 int fplibCompare(T op1, T op2, bool signal_nans, FPSCR &fpscr);
84 template <class T>
85 bool fplibCompareEQ(T op1, T op2, FPSCR &fpscr);
87 template <class T>
88 bool fplibCompareGE(T op1, T op2, FPSCR &fpscr);
90 template <class T>
91 bool fplibCompareGT(T op1, T op2, FPSCR &fpscr);
93 template <class T1, class T2>
94 T2 fplibConvert(T1 op, FPRounding rounding, FPSCR &fpscr);
96 template <class T>
97 T fplibDiv(T op1, T op2, FPSCR &fpscr);
99 template <class T>
100 T fplibMax(T op1, T op2, FPSCR &fpscr);
102 template <class T>
103 T fplibMaxNum(T op1, T op2, FPSCR &fpscr);
105 template <class T>
106 T fplibMin(T op1, T op2, FPSCR &fpscr);
108 template <class T>
109 T fplibMinNum(T op1, T op2, FPSCR &fpscr);
111 template <class T>
112 T fplibMul(T op1, T op2, FPSCR &fpscr);
114 template <class T>
115 T fplibMulAdd(T addend, T op1, T op2, FPSCR &fpscr);
117 template <class T>
118 T fplibMulX(T op1, T op2, FPSCR &fpscr);
120 template <class T>
121 T fplibNeg(T op);
123 template <class T>
124 T fplibRSqrtEstimate(T op, FPSCR &fpscr);
126 template <class T>
127 T fplibRSqrtStepFused(T op1, T op2, FPSCR &fpscr);
129 template <class T>
130 T fplibRecipEstimate(T op, FPSCR &fpscr);
132 template <class T>
133 T fplibRecipStepFused(T op1, T op2, FPSCR &fpscr);
135 template <class T>
136 T fplibRecpX(T op, FPSCR &fpscr);
138 template <class T>
139 T fplibRoundInt(T op, FPRounding rounding, bool exact, FPSCR &fpscr);
141 template <class T>
142 T fplibSqrt(T op, FPSCR &fpscr);
144 template <class T>
145 T fplibSub(T op1, T op2, FPSCR &fpscr);
147 template <class T1, class T2>
148 T2 fplibFPToFixed(T1 op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr);
150 template <class T>
151 T fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
152  FPSCR &fpscr);
153 
154 /* Function specializations... */
155 template <>
156 uint32_t fplibAbs(uint32_t op);
157 template <>
158 uint64_t fplibAbs(uint64_t op);
159 template <>
160 uint32_t fplibAdd(uint32_t op1, uint32_t op2, FPSCR &fpscr);
161 template <>
162 uint64_t fplibAdd(uint64_t op1, uint64_t op2, FPSCR &fpscr);
163 template <>
164 int fplibCompare(uint32_t op1, uint32_t op2, bool signal_nans, FPSCR &fpscr);
165 template <>
166 int fplibCompare(uint64_t op1, uint64_t op2, bool signal_nans, FPSCR &fpscr);
167 template <>
168 bool fplibCompareEQ(uint32_t op1, uint32_t op2, FPSCR &fpscr);
169 template <>
170 bool fplibCompareEQ(uint64_t op1, uint64_t op2, FPSCR &fpscr);
171 template <>
172 bool fplibCompareGE(uint32_t op1, uint32_t op2, FPSCR &fpscr);
173 template <>
174 bool fplibCompareGE(uint64_t op1, uint64_t op2, FPSCR &fpscr);
175 template <>
176 bool fplibCompareGT(uint32_t op1, uint32_t op2, FPSCR &fpscr);
177 template <>
178 bool fplibCompareGT(uint64_t op1, uint64_t op2, FPSCR &fpscr);
179 template <>
180 uint16_t fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr);
181 template <>
182 uint16_t fplibConvert(uint64_t op, FPRounding rounding, FPSCR &fpscr);
183 template <>
184 uint32_t fplibConvert(uint16_t op, FPRounding rounding, FPSCR &fpscr);
185 template <>
186 uint32_t fplibConvert(uint64_t op, FPRounding rounding, FPSCR &fpscr);
187 template <>
188 uint64_t fplibConvert(uint16_t op, FPRounding rounding, FPSCR &fpscr);
189 template <>
190 uint64_t fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr);
191 template <>
192 uint32_t fplibDiv(uint32_t op1, uint32_t op2, FPSCR &fpscr);
193 template <>
194 uint64_t fplibDiv(uint64_t op1, uint64_t op2, FPSCR &fpscr);
195 template <>
196 uint32_t fplibMax(uint32_t op1, uint32_t op2, FPSCR &fpscr);
197 template <>
198 uint64_t fplibMax(uint64_t op1, uint64_t op2, FPSCR &fpscr);
199 template <>
200 uint32_t fplibMaxNum(uint32_t op1, uint32_t op2, FPSCR &fpscr);
201 template <>
202 uint64_t fplibMaxNum(uint64_t op1, uint64_t op2, FPSCR &fpscr);
203 template <>
204 uint32_t fplibMin(uint32_t op1, uint32_t op2, FPSCR &fpscr);
205 template <>
206 uint64_t fplibMin(uint64_t op1, uint64_t op2, FPSCR &fpscr);
207 template <>
208 uint32_t fplibMinNum(uint32_t op1, uint32_t op2, FPSCR &fpscr);
209 template <>
210 uint64_t fplibMinNum(uint64_t op1, uint64_t op2, FPSCR &fpscr);
211 template <>
212 uint32_t fplibMul(uint32_t op1, uint32_t op2, FPSCR &fpscr);
213 template <>
214 uint64_t fplibMul(uint64_t op1, uint64_t op2, FPSCR &fpscr);
215 template <>
216 uint32_t fplibMulAdd(uint32_t addend, uint32_t op1, uint32_t op2,
217  FPSCR &fpscr);
218 template <>
219 uint64_t fplibMulAdd(uint64_t addend, uint64_t op1, uint64_t op2,
220  FPSCR &fpscr);
221 template <>
222 uint32_t fplibMulX(uint32_t op1, uint32_t op2, FPSCR &fpscr);
223 template <>
224 uint64_t fplibMulX(uint64_t op1, uint64_t op2, FPSCR &fpscr);
225 template <>
226 uint32_t fplibNeg(uint32_t op);
227 template <>
228 uint64_t fplibNeg(uint64_t op);
229 template <>
230 uint32_t fplibRSqrtEstimate(uint32_t op, FPSCR &fpscr);
231 template<>
232 uint64_t fplibRSqrtEstimate(uint64_t op, FPSCR &fpscr);
233 template <>
234 uint32_t fplibRSqrtStepFused(uint32_t op1, uint32_t op2, FPSCR &fpscr);
235 template <>
236 uint64_t fplibRSqrtStepFused(uint64_t op1, uint64_t op2, FPSCR &fpscr);
237 template <>
238 uint32_t fplibRecipEstimate(uint32_t op, FPSCR &fpscr);
239 template <>
240 uint64_t fplibRecipEstimate(uint64_t op, FPSCR &fpscr);
241 template <>
242 uint32_t fplibRecipStepFused(uint32_t op1, uint32_t op2, FPSCR &fpscr);
243 template <>
244 uint64_t fplibRecipStepFused(uint64_t op1, uint64_t op2, FPSCR &fpscr);
245 template <>
246 uint32_t fplibRecpX(uint32_t op, FPSCR &fpscr);
247 template <>
248 uint64_t fplibRecpX(uint64_t op, FPSCR &fpscr);
249 template <>
250 uint32_t fplibRoundInt(uint32_t op, FPRounding rounding, bool exact,
251  FPSCR &fpscr);
252 template <>
253 uint64_t fplibRoundInt(uint64_t op, FPRounding rounding, bool exact,
254  FPSCR &fpscr);
255 template <>
256 uint32_t fplibSqrt(uint32_t op, FPSCR &fpscr);
257 template <>
258 uint64_t fplibSqrt(uint64_t op, FPSCR &fpscr);
259 template <>
260 uint32_t fplibSub(uint32_t op1, uint32_t op2, FPSCR &fpscr);
261 template <>
262 uint64_t fplibSub(uint64_t op1, uint64_t op2, FPSCR &fpscr);
263 template <>
264 uint32_t fplibFPToFixed(uint32_t op, int fbits, bool u, FPRounding rounding,
265  FPSCR &fpscr);
266 template <>
267 uint32_t fplibFPToFixed(uint64_t op, int fbits, bool u, FPRounding rounding,
268  FPSCR &fpscr);
269 template <>
270 uint64_t fplibFPToFixed(uint32_t op, int fbits, bool u, FPRounding rounding,
271  FPSCR &fpscr);
272 template <>
273 uint64_t fplibFPToFixed(uint64_t op, int fbits, bool u, FPRounding rounding,
274  FPSCR &fpscr);
275 template <>
276 uint32_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
277  FPSCR &fpscr);
278 template <>
279 uint64_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding,
280  FPSCR &fpscr);
281 }
282 
283 #endif
uint32_t fplibFPToFixed(uint32_t op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr)
Definition: fplib.cc:2917
uint32_t fplibMax(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2094
uint32_t fplibRecpX(uint32_t op, FPSCR &fpscr)
Definition: fplib.cc:2635
uint32_t fplibRoundInt(uint32_t op, FPRounding rounding, bool exact, FPSCR &fpscr)
Definition: fplib.cc:2689
uint32_t fplibSub(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2835
FPRounding
Definition: fplib.hh:59
uint32_t fplibMaxNum(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2140
int fplibCompare(uint32_t op1, uint32_t op2, bool signal_nans, FPSCR &fpscr)
Definition: fplib.cc:1641
uint16_t fplibConvert(uint32_t op, FPRounding rounding, FPSCR &fpscr)
Definition: fplib.cc:1785
static FPRounding FPCRRounding(FPSCR &fpscr)
Definition: fplib.hh:69
uint32_t fplibRecipEstimate(uint32_t op, FPSCR &fpscr)
Definition: fplib.cc:2484
Bitfield< 22 > u
Definition: miscregs.hh:1537
uint32_t fplibDiv(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2042
bool fplibCompareGE(uint32_t a, uint32_t b, FPSCR &fpscr)
Definition: fplib.cc:1557
uint32_t fplibNeg(uint32_t op)
Definition: fplib.cc:2298
uint32_t fplibSqrt(uint32_t op, FPSCR &fpscr)
Definition: fplib.cc:2815
uint32_t fplibMulAdd(uint32_t addend, uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2022
uint32_t fplibAbs(uint32_t op)
Definition: fplib.cc:1607
uint32_t fplibRecipStepFused(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2455
uint32_t fplibAdd(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:1621
uint32_t fplibRSqrtStepFused(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2397
uint32_t fplibRSqrtEstimate(uint32_t op, FPSCR &fpscr)
Definition: fplib.cc:2331
uint32_t fplibMin(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2156
uint32_t fplibMinNum(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2202
bool fplibCompareGT(uint32_t a, uint32_t b, FPSCR &fpscr)
Definition: fplib.cc:1567
uint32_t fplibMulX(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2238
uint32_t fplibMul(uint32_t op1, uint32_t op2, FPSCR &fpscr)
Definition: fplib.cc:2218
Bitfield< 4 > op
Definition: types.hh:80
bool fplibCompareEQ(uint32_t a, uint32_t b, FPSCR &fpscr)
Definition: fplib.cc:1547
uint32_t fplibFixedToFP(uint64_t op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr)
Floating-point convert from fixed-point.
Definition: fplib.cc:3053

Generated on Fri Jun 9 2017 13:03:38 for gem5 by doxygen 1.8.6