main-loop: drop spin_counter
[qemu/ar7.git] / linux-user / arm / nwfpe / fpa11_cpdo.c
blob94ac98aef5e54ee04e9cd6db578b04aadc186942
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 "qemu/osdep.h"
22 #include "fpa11.h"
23 #include "fpopcode.h"
25 unsigned int EmulateCPDO(const unsigned int opcode)
27 FPA11 *fpa11 = GET_FPA11();
28 unsigned int Fd, nType, nDest, nRc = 1;
30 //printk("EmulateCPDO(0x%08x)\n",opcode);
32 /* Get the destination size. If not valid let Linux perform
33 an invalid instruction trap. */
34 nDest = getDestinationSize(opcode);
35 if (typeNone == nDest) return 0;
37 SetRoundingMode(opcode);
39 /* Compare the size of the operands in Fn and Fm.
40 Choose the largest size and perform operations in that size,
41 in order to make use of all the precision of the operands.
42 If Fm is a constant, we just grab a constant of a size
43 matching the size of the operand in Fn. */
44 if (MONADIC_INSTRUCTION(opcode))
45 nType = nDest;
46 else
47 nType = fpa11->fType[getFn(opcode)];
49 if (!CONSTANT_FM(opcode))
51 register unsigned int Fm = getFm(opcode);
52 if (nType < fpa11->fType[Fm])
54 nType = fpa11->fType[Fm];
58 switch (nType)
60 case typeSingle : nRc = SingleCPDO(opcode); break;
61 case typeDouble : nRc = DoubleCPDO(opcode); break;
62 case typeExtended : nRc = ExtendedCPDO(opcode); break;
63 default : nRc = 0;
66 /* If the operation succeeded, check to see if the result in the
67 destination register is the correct size. If not force it
68 to be. */
69 Fd = getFd(opcode);
70 nType = fpa11->fType[Fd];
71 if ((0 != nRc) && (nDest != nType))
73 switch (nDest)
75 case typeSingle:
77 if (typeDouble == nType)
78 fpa11->fpreg[Fd].fSingle =
79 float64_to_float32(fpa11->fpreg[Fd].fDouble, &fpa11->fp_status);
80 else
81 fpa11->fpreg[Fd].fSingle =
82 floatx80_to_float32(fpa11->fpreg[Fd].fExtended, &fpa11->fp_status);
84 break;
86 case typeDouble:
88 if (typeSingle == nType)
89 fpa11->fpreg[Fd].fDouble =
90 float32_to_float64(fpa11->fpreg[Fd].fSingle, &fpa11->fp_status);
91 else
92 fpa11->fpreg[Fd].fDouble =
93 floatx80_to_float64(fpa11->fpreg[Fd].fExtended, &fpa11->fp_status);
95 break;
97 case typeExtended:
99 if (typeSingle == nType)
100 fpa11->fpreg[Fd].fExtended =
101 float32_to_floatx80(fpa11->fpreg[Fd].fSingle, &fpa11->fp_status);
102 else
103 fpa11->fpreg[Fd].fExtended =
104 float64_to_floatx80(fpa11->fpreg[Fd].fDouble, &fpa11->fp_status);
106 break;
109 fpa11->fType[Fd] = nDest;
112 return nRc;