diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/arm/nwfpe/fpa11_cpdo.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/arm/nwfpe/fpa11_cpdo.c')
-rw-r--r-- | arch/arm/nwfpe/fpa11_cpdo.c | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/arch/arm/nwfpe/fpa11_cpdo.c b/arch/arm/nwfpe/fpa11_cpdo.c new file mode 100644 index 000000000000..1bea67437b6f --- /dev/null +++ b/arch/arm/nwfpe/fpa11_cpdo.c | |||
@@ -0,0 +1,132 @@ | |||
1 | /* | ||
2 | NetWinder Floating Point Emulator | ||
3 | (c) Rebel.COM, 1998,1999 | ||
4 | (c) Philip Blundell, 2001 | ||
5 | |||
6 | Direct questions, comments to Scott Bambrough <scottb@netwinder.org> | ||
7 | |||
8 | This program is free software; you can redistribute it and/or modify | ||
9 | it under the terms of the GNU General Public License as published by | ||
10 | the Free Software Foundation; either version 2 of the License, or | ||
11 | (at your option) any later version. | ||
12 | |||
13 | This program is distributed in the hope that it will be useful, | ||
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | GNU General Public License for more details. | ||
17 | |||
18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program; if not, write to the Free Software | ||
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
21 | */ | ||
22 | |||
23 | #include <linux/config.h> | ||
24 | #include "fpa11.h" | ||
25 | #include "fpopcode.h" | ||
26 | |||
27 | unsigned int SingleCPDO(const unsigned int opcode, FPREG * rFd); | ||
28 | unsigned int DoubleCPDO(const unsigned int opcode, FPREG * rFd); | ||
29 | unsigned int ExtendedCPDO(const unsigned int opcode, FPREG * rFd); | ||
30 | |||
31 | unsigned int EmulateCPDO(const unsigned int opcode) | ||
32 | { | ||
33 | FPA11 *fpa11 = GET_FPA11(); | ||
34 | FPREG *rFd; | ||
35 | unsigned int nType, nDest, nRc; | ||
36 | |||
37 | /* Get the destination size. If not valid let Linux perform | ||
38 | an invalid instruction trap. */ | ||
39 | nDest = getDestinationSize(opcode); | ||
40 | if (typeNone == nDest) | ||
41 | return 0; | ||
42 | |||
43 | SetRoundingMode(opcode); | ||
44 | |||
45 | /* Compare the size of the operands in Fn and Fm. | ||
46 | Choose the largest size and perform operations in that size, | ||
47 | in order to make use of all the precision of the operands. | ||
48 | If Fm is a constant, we just grab a constant of a size | ||
49 | matching the size of the operand in Fn. */ | ||
50 | if (MONADIC_INSTRUCTION(opcode)) | ||
51 | nType = nDest; | ||
52 | else | ||
53 | nType = fpa11->fType[getFn(opcode)]; | ||
54 | |||
55 | if (!CONSTANT_FM(opcode)) { | ||
56 | register unsigned int Fm = getFm(opcode); | ||
57 | if (nType < fpa11->fType[Fm]) { | ||
58 | nType = fpa11->fType[Fm]; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | rFd = &fpa11->fpreg[getFd(opcode)]; | ||
63 | |||
64 | switch (nType) { | ||
65 | case typeSingle: | ||
66 | nRc = SingleCPDO(opcode, rFd); | ||
67 | break; | ||
68 | case typeDouble: | ||
69 | nRc = DoubleCPDO(opcode, rFd); | ||
70 | break; | ||
71 | #ifdef CONFIG_FPE_NWFPE_XP | ||
72 | case typeExtended: | ||
73 | nRc = ExtendedCPDO(opcode, rFd); | ||
74 | break; | ||
75 | #endif | ||
76 | default: | ||
77 | nRc = 0; | ||
78 | } | ||
79 | |||
80 | /* The CPDO functions used to always set the destination type | ||
81 | to be the same as their working size. */ | ||
82 | |||
83 | if (nRc != 0) { | ||
84 | /* If the operation succeeded, check to see if the result in the | ||
85 | destination register is the correct size. If not force it | ||
86 | to be. */ | ||
87 | |||
88 | fpa11->fType[getFd(opcode)] = nDest; | ||
89 | |||
90 | #ifdef CONFIG_FPE_NWFPE_XP | ||
91 | if (nDest != nType) { | ||
92 | switch (nDest) { | ||
93 | case typeSingle: | ||
94 | { | ||
95 | if (typeDouble == nType) | ||
96 | rFd->fSingle = float64_to_float32(rFd->fDouble); | ||
97 | else | ||
98 | rFd->fSingle = floatx80_to_float32(rFd->fExtended); | ||
99 | } | ||
100 | break; | ||
101 | |||
102 | case typeDouble: | ||
103 | { | ||
104 | if (typeSingle == nType) | ||
105 | rFd->fDouble = float32_to_float64(rFd->fSingle); | ||
106 | else | ||
107 | rFd->fDouble = floatx80_to_float64(rFd->fExtended); | ||
108 | } | ||
109 | break; | ||
110 | |||
111 | case typeExtended: | ||
112 | { | ||
113 | if (typeSingle == nType) | ||
114 | rFd->fExtended = float32_to_floatx80(rFd->fSingle); | ||
115 | else | ||
116 | rFd->fExtended = float64_to_floatx80(rFd->fDouble); | ||
117 | } | ||
118 | break; | ||
119 | } | ||
120 | } | ||
121 | #else | ||
122 | if (nDest != nType) { | ||
123 | if (nDest == typeSingle) | ||
124 | rFd->fSingle = float64_to_float32(rFd->fDouble); | ||
125 | else | ||
126 | rFd->fDouble = float32_to_float64(rFd->fSingle); | ||
127 | } | ||
128 | #endif | ||
129 | } | ||
130 | |||
131 | return nRc; | ||
132 | } | ||