1 /* Simulator Floating-point support.
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
5 This file is part of GDB, the GNU debugger.
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, or (at your option)
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 along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
32 /* register <-> sim_fpu */
34 INLINE_SIM_FPU (sim_fpu)
35 sim_fpu_32to (unsigned32 s)
38 ans.val = *(float*) &s;
43 INLINE_SIM_FPU (sim_fpu)
44 sim_fpu_64to (unsigned64 s)
47 ans.val = *(double*) &s;
52 INLINE_SIM_FPU (unsigned32)
53 sim_fpu_to32 (sim_fpu l)
56 return *(unsigned32*) &s;
60 INLINE_SIM_FPU (unsigned64)
61 sim_fpu_to64 (sim_fpu s)
63 return *(unsigned64*) &s.val;
69 INLINE_SIM_FPU (sim_fpu)
70 sim_fpu_add (sim_fpu l,
74 ans.val = l.val + r.val;
79 INLINE_SIM_FPU (sim_fpu)
80 sim_fpu_sub (sim_fpu l,
84 ans.val = l.val - r.val;
89 INLINE_SIM_FPU (sim_fpu)
90 sim_fpu_mul (sim_fpu l,
94 ans.val = l.val * r.val;
99 INLINE_SIM_FPU (sim_fpu)
100 sim_fpu_div (sim_fpu l,
104 ans.val = l.val / r.val;
109 INLINE_SIM_FPU (sim_fpu)
110 sim_fpu_inv (sim_fpu r)
118 INLINE_SIM_FPU (sim_fpu)
119 sim_fpu_sqrt (sim_fpu r)
122 ans.val = sqrt (r.val);
127 /* int/long -> sim_fpu */
129 INLINE_SIM_FPU (sim_fpu)
130 sim_fpu_i32to (signed32 s)
138 INLINE_SIM_FPU (sim_fpu)
139 sim_fpu_u32to (unsigned32 s)
147 INLINE_SIM_FPU (sim_fpu)
148 sim_fpu_i64to (signed64 s)
156 INLINE_SIM_FPU (sim_fpu)
157 sim_fpu_u64to (unsigned64 s)
165 /* sim_fpu -> host format */
167 INLINE_SIM_FPU (float)
168 sim_fpu_2f (sim_fpu f)
174 INLINE_SIM_FPU (double)
175 sim_fpu_2d (sim_fpu s)
182 INLINE_SIM_FPU (sim_fpu)
193 INLINE_SIM_FPU (sim_fpu)
194 sim_fpu_d2 (double d)
207 sim_fpu_is_nan (sim_fpu d)
209 return 0; /* FIXME - detect NaN */
213 /* Compare operators */
216 sim_fpu_is_lt (sim_fpu l,
219 return (l.val < r.val);
223 sim_fpu_is_le (sim_fpu l,
226 return (l.val <= r.val);
230 sim_fpu_is_eq (sim_fpu l,
233 return (l.val == r.val);
237 sim_fpu_is_ne (sim_fpu l,
240 return (l.val != r.val);
244 sim_fpu_is_ge (sim_fpu l,
247 return (l.val >= r.val);
251 sim_fpu_is_gt (sim_fpu l,
254 return (l.val > r.val);