Avoid a warning from OpenBSD linker
[qemu/cris-port.git] / linux-user / arm / nwfpe / extended_cpdo.c
blob880ce030a54e7968bdd1da4599bb6c37136da6c1
1 /*
2 NetWinder Floating Point Emulator
3 (c) Rebel.COM, 1998,1999
5 Direct questions, comments to Scott Bambrough <scottb@netwinder.org>
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "fpa11.h"
22 #include "softfloat.h"
23 #include "fpopcode.h"
25 floatx80 floatx80_exp(floatx80 Fm);
26 floatx80 floatx80_ln(floatx80 Fm);
27 floatx80 floatx80_sin(floatx80 rFm);
28 floatx80 floatx80_cos(floatx80 rFm);
29 floatx80 floatx80_arcsin(floatx80 rFm);
30 floatx80 floatx80_arctan(floatx80 rFm);
31 floatx80 floatx80_log(floatx80 rFm);
32 floatx80 floatx80_tan(floatx80 rFm);
33 floatx80 floatx80_arccos(floatx80 rFm);
34 floatx80 floatx80_pow(floatx80 rFn,floatx80 rFm);
35 floatx80 floatx80_pol(floatx80 rFn,floatx80 rFm);
37 unsigned int ExtendedCPDO(const unsigned int opcode)
39 FPA11 *fpa11 = GET_FPA11();
40 floatx80 rFm, rFn;
41 unsigned int Fd, Fm, Fn, nRc = 1;
43 //printk("ExtendedCPDO(0x%08x)\n",opcode);
45 Fm = getFm(opcode);
46 if (CONSTANT_FM(opcode))
48 rFm = getExtendedConstant(Fm);
50 else
52 switch (fpa11->fType[Fm])
54 case typeSingle:
55 rFm = float32_to_floatx80(fpa11->fpreg[Fm].fSingle, &fpa11->fp_status);
56 break;
58 case typeDouble:
59 rFm = float64_to_floatx80(fpa11->fpreg[Fm].fDouble, &fpa11->fp_status);
60 break;
62 case typeExtended:
63 rFm = fpa11->fpreg[Fm].fExtended;
64 break;
66 default: return 0;
70 if (!MONADIC_INSTRUCTION(opcode))
72 Fn = getFn(opcode);
73 switch (fpa11->fType[Fn])
75 case typeSingle:
76 rFn = float32_to_floatx80(fpa11->fpreg[Fn].fSingle, &fpa11->fp_status);
77 break;
79 case typeDouble:
80 rFn = float64_to_floatx80(fpa11->fpreg[Fn].fDouble, &fpa11->fp_status);
81 break;
83 case typeExtended:
84 rFn = fpa11->fpreg[Fn].fExtended;
85 break;
87 default: return 0;
91 Fd = getFd(opcode);
92 switch (opcode & MASK_ARITHMETIC_OPCODE)
94 /* dyadic opcodes */
95 case ADF_CODE:
96 fpa11->fpreg[Fd].fExtended = floatx80_add(rFn,rFm, &fpa11->fp_status);
97 break;
99 case MUF_CODE:
100 case FML_CODE:
101 fpa11->fpreg[Fd].fExtended = floatx80_mul(rFn,rFm, &fpa11->fp_status);
102 break;
104 case SUF_CODE:
105 fpa11->fpreg[Fd].fExtended = floatx80_sub(rFn,rFm, &fpa11->fp_status);
106 break;
108 case RSF_CODE:
109 fpa11->fpreg[Fd].fExtended = floatx80_sub(rFm,rFn, &fpa11->fp_status);
110 break;
112 case DVF_CODE:
113 case FDV_CODE:
114 fpa11->fpreg[Fd].fExtended = floatx80_div(rFn,rFm, &fpa11->fp_status);
115 break;
117 case RDF_CODE:
118 case FRD_CODE:
119 fpa11->fpreg[Fd].fExtended = floatx80_div(rFm,rFn, &fpa11->fp_status);
120 break;
122 #if 0
123 case POW_CODE:
124 fpa11->fpreg[Fd].fExtended = floatx80_pow(rFn,rFm);
125 break;
127 case RPW_CODE:
128 fpa11->fpreg[Fd].fExtended = floatx80_pow(rFm,rFn);
129 break;
130 #endif
132 case RMF_CODE:
133 fpa11->fpreg[Fd].fExtended = floatx80_rem(rFn,rFm, &fpa11->fp_status);
134 break;
136 #if 0
137 case POL_CODE:
138 fpa11->fpreg[Fd].fExtended = floatx80_pol(rFn,rFm);
139 break;
140 #endif
142 /* monadic opcodes */
143 case MVF_CODE:
144 fpa11->fpreg[Fd].fExtended = rFm;
145 break;
147 case MNF_CODE:
148 rFm.high ^= 0x8000;
149 fpa11->fpreg[Fd].fExtended = rFm;
150 break;
152 case ABS_CODE:
153 rFm.high &= 0x7fff;
154 fpa11->fpreg[Fd].fExtended = rFm;
155 break;
157 case RND_CODE:
158 case URD_CODE:
159 fpa11->fpreg[Fd].fExtended = floatx80_round_to_int(rFm, &fpa11->fp_status);
160 break;
162 case SQT_CODE:
163 fpa11->fpreg[Fd].fExtended = floatx80_sqrt(rFm, &fpa11->fp_status);
164 break;
166 #if 0
167 case LOG_CODE:
168 fpa11->fpreg[Fd].fExtended = floatx80_log(rFm);
169 break;
171 case LGN_CODE:
172 fpa11->fpreg[Fd].fExtended = floatx80_ln(rFm);
173 break;
175 case EXP_CODE:
176 fpa11->fpreg[Fd].fExtended = floatx80_exp(rFm);
177 break;
179 case SIN_CODE:
180 fpa11->fpreg[Fd].fExtended = floatx80_sin(rFm);
181 break;
183 case COS_CODE:
184 fpa11->fpreg[Fd].fExtended = floatx80_cos(rFm);
185 break;
187 case TAN_CODE:
188 fpa11->fpreg[Fd].fExtended = floatx80_tan(rFm);
189 break;
191 case ASN_CODE:
192 fpa11->fpreg[Fd].fExtended = floatx80_arcsin(rFm);
193 break;
195 case ACS_CODE:
196 fpa11->fpreg[Fd].fExtended = floatx80_arccos(rFm);
197 break;
199 case ATN_CODE:
200 fpa11->fpreg[Fd].fExtended = floatx80_arctan(rFm);
201 break;
202 #endif
204 case NRM_CODE:
205 break;
207 default:
209 nRc = 0;
213 if (0 != nRc) fpa11->fType[Fd] = typeExtended;
214 return nRc;
217 #if 0
218 floatx80 floatx80_exp(floatx80 Fm)
220 //series
223 floatx80 floatx80_ln(floatx80 Fm)
225 //series
228 floatx80 floatx80_sin(floatx80 rFm)
230 //series
233 floatx80 floatx80_cos(floatx80 rFm)
235 //series
238 floatx80 floatx80_arcsin(floatx80 rFm)
240 //series
243 floatx80 floatx80_arctan(floatx80 rFm)
245 //series
248 floatx80 floatx80_log(floatx80 rFm)
250 return floatx80_div(floatx80_ln(rFm),getExtendedConstant(7));
253 floatx80 floatx80_tan(floatx80 rFm)
255 return floatx80_div(floatx80_sin(rFm),floatx80_cos(rFm));
258 floatx80 floatx80_arccos(floatx80 rFm)
260 //return floatx80_sub(halfPi,floatx80_arcsin(rFm));
263 floatx80 floatx80_pow(floatx80 rFn,floatx80 rFm)
265 return floatx80_exp(floatx80_mul(rFm,floatx80_ln(rFn)));
268 floatx80 floatx80_pol(floatx80 rFn,floatx80 rFm)
270 return floatx80_arctan(floatx80_div(rFn,rFm));
272 #endif