Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: fpsim.h | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | #ifndef _INCLUDED_FPSIM_H | |
24 | #define _INCLUDED_FPSIM_H | |
25 | ||
26 | /*============================================================= | |
27 | Floating-Point Simulation Library Interfaces | |
28 | ||
29 | Author: Robert Rethemeyer, Sun Microsystems, Inc. | |
30 | ||
31 | $Id: fpsim.h,v 1.3 2006/12/07 21:55:14 bobsmail Exp $ | |
32 | ||
33 | COPYRIGHT 2005-2006 Sun Microsystems, Inc. | |
34 | Sun Confidential: Sun SSG Only | |
35 | *============================================================*/ | |
36 | ||
37 | /********************************************************************* | |
38 | * ATTENTION: This code is part of a library shared by multiple | |
39 | * projects. DO NOT MAKE CHANGES TO THIS CODE WITHIN YOUR PROJECT. | |
40 | * Instead, contact the owner/maintainer of the library, currently: | |
41 | * Robert.Rethemeyer@Sun.COM +1-408-616-5717 (x45717) | |
42 | * Systems Group: TVT: FrontEnd Technologies | |
43 | * The CVS source code repository for the library is at: | |
44 | * /import/ftap-blimp1/cvs/fpsim | |
45 | * DO NOT COMMIT CHANGES TO THAT REPOSITORY: contact the maintainer. | |
46 | ********************************************************************/ | |
47 | ||
48 | /* Exception bits returned by most functions */ | |
49 | #define FPX_NV 0x10 /* not-valid */ | |
50 | #define FPX_OF 0x08 /* overflow */ | |
51 | #define FPX_UF 0x04 /* underflow */ | |
52 | #define FPX_DZ 0x02 /* div-by-zero */ | |
53 | #define FPX_NX 0x01 /* not-exact */ | |
54 | #define FPX_AXCX 0x400 /* extension: both aexc (9:5) & cexc (4:0) (FMAu) */ | |
55 | #define FPX_TRAP 0x800 /* extension: force trap (7:0) */ | |
56 | #define FPX_ILL 0x810 /* extension: illegal_instr trap */ | |
57 | #define FPX_UN 0x802 /* extension: FPother-unfinished trap */ | |
58 | #define FPX_UIMP 0x803 /* extension: FPother-unimplemented trap */ | |
59 | ||
60 | /* Multiply-add instruction subtype codes */ | |
61 | typedef enum fpsim_fma_subtype { | |
62 | FMA_ADD_POS = 0, // fmadd,fumadd | |
63 | FMA_SUB_POS = 1, // fmsub,fumsub | |
64 | FMA_ADD_NEG = 2, // fnmadd,fnumadd | |
65 | FMA_SUB_NEG = 3 // fnmsub,fnumsub | |
66 | } fpsim_fma_subtype; | |
67 | ||
68 | /* Half-add instruction subtype codes */ | |
69 | typedef enum fpsim_fha_subtype { | |
70 | FHA_ADD = 0, // fhadd | |
71 | FHA_SUB = 1, // fhsub | |
72 | FHA_ADD_NEG = 2 // fnhadd | |
73 | } fpsim_fha_subtype; | |
74 | ||
75 | ||
76 | #ifdef __cplusplus | |
77 | extern "C" { | |
78 | #endif | |
79 | ||
80 | /*------------------ Library function prototypes ----------------------*/ | |
81 | ||
82 | /* utility functions */ | |
83 | extern int fpsim_update_fsr( int exc, unsigned long long* fsr ); | |
84 | ||
85 | extern unsigned long long fpsim_gsr_mask(void); | |
86 | ||
87 | /* double arithmetic */ | |
88 | extern int fpsim_faddd( const double* op1, const double* op2, double* res, | |
89 | unsigned long long fsr, unsigned long long gsr); | |
90 | extern int fpsim_fsubd( const double* op1, const double* op2, double* res, | |
91 | unsigned long long fsr, unsigned long long gsr); | |
92 | extern int fpsim_fmuld( const double* op1, const double* op2, double* res, | |
93 | unsigned long long fsr, unsigned long long gsr); | |
94 | extern int fpsim_fdivd( const double* op1, const double* op2, double* res, | |
95 | unsigned long long fsr, unsigned long long gsr); | |
96 | extern int fpsim_fsqrtd(const double* op2, double* res, | |
97 | unsigned long long fsr, unsigned long long gsr); | |
98 | ||
99 | /* single arithmetic */ | |
100 | extern int fpsim_fadds( const float* op1, const float* op2, float* res, | |
101 | unsigned long long fsr, unsigned long long gsr); | |
102 | extern int fpsim_fsubs( const float* op1, const float* op2, float* res, | |
103 | unsigned long long fsr, unsigned long long gsr); | |
104 | extern int fpsim_fmuls( const float* op1, const float* op2, float* res, | |
105 | unsigned long long fsr, unsigned long long gsr); | |
106 | extern int fpsim_fsmuld(const float* op1, const float* op2, double* res, | |
107 | unsigned long long fsr, unsigned long long gsr); | |
108 | extern int fpsim_fdivs( const float* op1, const float* op2, float* res, | |
109 | unsigned long long fsr, unsigned long long gsr); | |
110 | extern int fpsim_fsqrts(const float* op2, float* res, | |
111 | unsigned long long fsr, unsigned long long gsr); | |
112 | ||
113 | /* conversions */ | |
114 | extern int fpsim_fstod( const float* op2, double* res, | |
115 | unsigned long long fsr, unsigned long long gsr); | |
116 | extern int fpsim_fdtos( const double* op2, float* res, | |
117 | unsigned long long fsr, unsigned long long gsr); | |
118 | extern int fpsim_fstox( const float* op2, unsigned long long* res, | |
119 | unsigned long long fsr, unsigned long long gsr); | |
120 | extern int fpsim_fdtox( const double* op2, unsigned long long* res, | |
121 | unsigned long long fsr, unsigned long long gsr); | |
122 | extern int fpsim_fstoi( const float* op2, unsigned int* res, | |
123 | unsigned long long fsr, unsigned long long gsr); | |
124 | extern int fpsim_fdtoi( const double* op2, unsigned int* res, | |
125 | unsigned long long fsr, unsigned long long gsr); | |
126 | extern int fpsim_fxtos( const unsigned long long* op2, float* res, | |
127 | unsigned long long fsr, unsigned long long gsr); | |
128 | extern int fpsim_fxtod( const unsigned long long* op2, double* res, | |
129 | unsigned long long fsr, unsigned long long gsr); | |
130 | extern int fpsim_fitos( const unsigned int* op2, float* res, | |
131 | unsigned long long fsr, unsigned long long gsr); | |
132 | extern int fpsim_fitod( const unsigned int* op2,double* res); | |
133 | ||
134 | ||
135 | /* negated-add,multiply (Rock only) */ | |
136 | extern int fpsim_fnaddd( const double* op1, const double* op2, double* res, | |
137 | unsigned long long fsr, unsigned long long gsr); | |
138 | extern int fpsim_fnadds( const float* op1, const float* op2, float* res, | |
139 | unsigned long long fsr, unsigned long long gsr); | |
140 | extern int fpsim_fnmuld( const double* op1, const double* op2, double* res, | |
141 | unsigned long long fsr, unsigned long long gsr); | |
142 | extern int fpsim_fnmuls( const float* op1, const float* op2, float* res, | |
143 | unsigned long long fsr, unsigned long long gsr); | |
144 | extern int fpsim_fnsmuld(const float* op1, const float* op2, double* res, | |
145 | unsigned long long fsr, unsigned long long gsr); | |
146 | ||
147 | /* half-add,subtract 3 subtypes each (Rock only) */ | |
148 | extern int fpsim_fhaddd( const double* op1, const double* op2, double* res, | |
149 | unsigned long long fsr, unsigned long long gsr, | |
150 | fpsim_fha_subtype subtype); | |
151 | extern int fpsim_fhadds( const float* op1, const float* op2, float* res, | |
152 | unsigned long long fsr, unsigned long long gsr, | |
153 | fpsim_fha_subtype subtype); | |
154 | ||
155 | /* fused multiply-add 4 subtypes each (Rock only) */ | |
156 | extern int fpsim_fmaddd(const double* op1, const double* op2, const double* op3, | |
157 | double* res, unsigned long long fsr, | |
158 | unsigned long long gsr, fpsim_fma_subtype subtype); | |
159 | extern int fpsim_fmadds(const float* op1, const float* op2, const float* op3, | |
160 | float* res, unsigned long long fsr, | |
161 | unsigned long long gsr, fpsim_fma_subtype subtype); | |
162 | ||
163 | /* unfused multiply-add 4 subtypes each (Rock only) */ | |
164 | extern int fpsim_fumaddd(const double* op1, const double* op2, const double* op3, | |
165 | double* res, unsigned long long fsr, | |
166 | unsigned long long gsr, fpsim_fma_subtype subtype); | |
167 | extern int fpsim_fumadds(const float* op1, const float* op2, const float* op3, | |
168 | float* res, unsigned long long fsr, | |
169 | unsigned long long gsr, fpsim_fma_subtype subtype); | |
170 | ||
171 | ||
172 | ||
173 | /*------------------ Library function pointers ----------------------*/ | |
174 | ||
175 | struct fpsim_functions | |
176 | { | |
177 | int (*update_fsr)( int exc, unsigned long long* fsr ); | |
178 | unsigned long long (*gsr_mask)(void); | |
179 | ||
180 | int (*faddd)( const double* op1,const double* op2,double* res, | |
181 | unsigned long long fsr,unsigned long long gsr); | |
182 | int (*fsubd)( const double* op1,const double* op2,double* res, | |
183 | unsigned long long fsr,unsigned long long gsr); | |
184 | int (*fmuld)( const double* op1,const double* op2,double* res, | |
185 | unsigned long long fsr,unsigned long long gsr); | |
186 | int (*fdivd)( const double* op1,const double* op2,double* res, | |
187 | unsigned long long fsr,unsigned long long gsr); | |
188 | int (*fsqrtd)(const double* op2,double* res, | |
189 | unsigned long long fsr,unsigned long long gsr); | |
190 | int (*fadds)( const float* op1,const float* op2,float* res, | |
191 | unsigned long long fsr,unsigned long long gsr); | |
192 | int (*fsubs)( const float* op1,const float* op2,float* res, | |
193 | unsigned long long fsr,unsigned long long gsr); | |
194 | int (*fmuls)( const float* op1,const float* op2,float* res, | |
195 | unsigned long long fsr,unsigned long long gsr); | |
196 | int (*fdivs)( const float* op1,const float* op2,float* res, | |
197 | unsigned long long fsr,unsigned long long gsr); | |
198 | int (*fsqrts)(const float* op2,float* res, | |
199 | unsigned long long fsr,unsigned long long gsr); | |
200 | int (*fsmuld)(const float* op1,const float* op2,double* res, | |
201 | unsigned long long fsr,unsigned long long gsr); | |
202 | int (*fstod)( const float* op2,double* res, | |
203 | unsigned long long fsr,unsigned long long gsr); | |
204 | int (*fdtos)( const double* op2,float* res, | |
205 | unsigned long long fsr,unsigned long long gsr); | |
206 | int (*fstox)( const float* op2,unsigned long long* res, | |
207 | unsigned long long fsr,unsigned long long gsr); | |
208 | int (*fdtox)( const double* op2,unsigned long long* res, | |
209 | unsigned long long fsr,unsigned long long gsr); | |
210 | int (*fstoi)( const float* op2,unsigned int* res, | |
211 | unsigned long long fsr,unsigned long long gsr); | |
212 | int (*fdtoi)( const double* op2,unsigned int* res, | |
213 | unsigned long long fsr,unsigned long long gsr); | |
214 | int (*fxtos)( const unsigned long long* op2,float* res, | |
215 | unsigned long long fsr,unsigned long long gsr); | |
216 | int (*fxtod)( const unsigned long long* op2,double* res, | |
217 | unsigned long long fsr,unsigned long long gsr); | |
218 | int (*fitos)( const unsigned int* op2,float* res, | |
219 | unsigned long long fsr,unsigned long long gsr); | |
220 | int (*fitod)( const unsigned int* op2,double* res); | |
221 | ||
222 | int (*fnaddd)( const double* op1,const double* op2,double* res, | |
223 | unsigned long long fsr,unsigned long long gsr); | |
224 | int (*fnadds)( const float* op1,const float* op2,float* res, | |
225 | unsigned long long fsr,unsigned long long gsr); | |
226 | int (*fnmuld)( const double* op1,const double* op2,double* res, | |
227 | unsigned long long fsr,unsigned long long gsr); | |
228 | int (*fnmuls)( const float* op1,const float* op2,float* res, | |
229 | unsigned long long fsr,unsigned long long gsr); | |
230 | int (*fnsmuld)(const float* op1,const float* op2,double* res, | |
231 | unsigned long long fsr,unsigned long long gsr); | |
232 | ||
233 | int (*fhaddd)( const double* op1, const double* op2, double* res, | |
234 | unsigned long long fsr, unsigned long long gsr, | |
235 | fpsim_fha_subtype subtype); | |
236 | int (*fhadds)( const float* op1, const float* op2, float* res, | |
237 | unsigned long long fsr, unsigned long long gsr, | |
238 | fpsim_fha_subtype subtype); | |
239 | ||
240 | int (*fmaddd)(const double* op1,const double* op2,const double* op3, | |
241 | double* res, unsigned long long fsr, | |
242 | unsigned long long gsr, fpsim_fma_subtype subtype); | |
243 | int (*fmadds)(const float* op1,const float* op2,const float* op3, | |
244 | float* res, unsigned long long fsr, | |
245 | unsigned long long gsr, fpsim_fma_subtype subtype); | |
246 | ||
247 | int (*fumaddd)(const double* op1, const double* op2, const double* op3, | |
248 | double* res, unsigned long long fsr, | |
249 | unsigned long long gsr, fpsim_fma_subtype subtype); | |
250 | int (*fumadds)(const float* op1, const float* op2, const float* op3, | |
251 | float* res, unsigned long long fsr, | |
252 | unsigned long long gsr, fpsim_fma_subtype subtype); | |
253 | }; | |
254 | ||
255 | #ifdef __cplusplus | |
256 | } | |
257 | #endif | |
258 | ||
259 | #endif /*_INCLUDED_FPSIM_H*/ |