stats: update stats for mmap() change.
[gem5.git] / src / arch / arm / insts / fplib.hh
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
41 /**
42 * @file
43 * Floating-point library code, which will gradually replace vfp.hh. For
44 * portability, this library does not use floating-point data types. Currently,
45 * C's standard integer types are used in the API, though this could be changed
46 * to something like class Fp32 { uint32_t x; }, etc.
47 */
48
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 {
60 FPRounding_TIEEVEN = 0,
61 FPRounding_POSINF = 1,
62 FPRounding_NEGINF = 2,
63 FPRounding_ZERO = 3,
64 FPRounding_TIEAWAY = 4,
65 FPRounding_ODD = 5
66 };
67
68 static inline FPRounding
69 FPCRRounding(FPSCR &fpscr)
70 {
71 return (FPRounding)((uint32_t)fpscr >> 22 & 3);
72 }
73
74 /** Floating-point absolute value. */
75 template <class T>
76 T fplibAbs(T op);
77 /** Floating-point add. */
78 template <class T>
79 T fplibAdd(T op1, T op2, FPSCR &fpscr);
80 /** Floating-point compare (quiet and signaling). */
81 template <class T>
82 int fplibCompare(T op1, T op2, bool signal_nans, FPSCR &fpscr);
83 /** Floating-point compare equal. */
84 template <class T>
85 bool fplibCompareEQ(T op1, T op2, FPSCR &fpscr);
86 /** Floating-point compare greater than or equal. */
87 template <class T>
88 bool fplibCompareGE(T op1, T op2, FPSCR &fpscr);
89 /** Floating-point compare greater than. */
90 template <class T>
91 bool fplibCompareGT(T op1, T op2, FPSCR &fpscr);
92 /** Floating-point convert precision. */
93 template <class T1, class T2>
94 T2 fplibConvert(T1 op, FPRounding rounding, FPSCR &fpscr);
95 /** Floating-point division. */
96 template <class T>
97 T fplibDiv(T op1, T op2, FPSCR &fpscr);
98 /** Floating-point maximum. */
99 template <class T>
100 T fplibMax(T op1, T op2, FPSCR &fpscr);
101 /** Floating-point maximum number. */
102 template <class T>
103 T fplibMaxNum(T op1, T op2, FPSCR &fpscr);
104 /** Floating-point minimum. */
105 template <class T>
106 T fplibMin(T op1, T op2, FPSCR &fpscr);
107 /** Floating-point minimum number. */
108 template <class T>
109 T fplibMinNum(T op1, T op2, FPSCR &fpscr);
110 /** Floating-point multiply. */
111 template <class T>
112 T fplibMul(T op1, T op2, FPSCR &fpscr);
113 /** Floating-point multiply-add. */
114 template <class T>
115 T fplibMulAdd(T addend, T op1, T op2, FPSCR &fpscr);
116 /** Floating-point multiply extended. */
117 template <class T>
118 T fplibMulX(T op1, T op2, FPSCR &fpscr);
119 /** Floating-point negate. */
120 template <class T>
121 T fplibNeg(T op);
122 /** Floating-point reciprocal square root estimate. */
123 template <class T>
124 T fplibRSqrtEstimate(T op, FPSCR &fpscr);
125 /** Floating-point reciprocal square root step. */
126 template <class T>
127 T fplibRSqrtStepFused(T op1, T op2, FPSCR &fpscr);
128 /** Floating-point reciprocal estimate. */
129 template <class T>
130 T fplibRecipEstimate(T op, FPSCR &fpscr);
131 /** Floating-point reciprocal step. */
132 template <class T>
133 T fplibRecipStepFused(T op1, T op2, FPSCR &fpscr);
134 /** Floating-point reciprocal exponent. */
135 template <class T>
136 T fplibRecpX(T op, FPSCR &fpscr);
137 /** Floating-point convert to integer. */
138 template <class T>
139 T fplibRoundInt(T op, FPRounding rounding, bool exact, FPSCR &fpscr);
140 /** Floating-point square root. */
141 template <class T>
142 T fplibSqrt(T op, FPSCR &fpscr);
143 /** Floating-point subtract. */
144 template <class T>
145 T fplibSub(T op1, T op2, FPSCR &fpscr);
146 /** Floating-point convert to fixed-point. */
147 template <class T1, class T2>
148 T2 fplibFPToFixed(T1 op, int fbits, bool u, FPRounding rounding, FPSCR &fpscr);
149 /** Floating-point convert from fixed-point. */
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