Add flakey floating-point support to the TI c80 simulator.
[deliverable/binutils-gdb.git] / sim / common / sim-fpu.c
CommitLineData
3971886a
AC
1/* Simulator Floating-point support.
2 Copyright (C) 1997 Free Software Foundation, Inc.
3 Contributed by Cygnus Support.
4
5This file is part of GDB, the GNU debugger.
6
7This program is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License along
18with this program; if not, write to the Free Software Foundation, Inc.,
1959 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21
22
23#ifndef _SIM_FPU_C_
24#define _SIM_FPU_C_
25
26#include "sim-main.h"
27#include "sim-fpu.h"
28
29#include <math.h>
30
31
32INLINE_SIM_FPU (sim_fpu)
33sim_fpu_add (sim_fpu l,
34 sim_fpu r)
35{
36 sim_fpu ans;
37 ans.val = l.val + r.val;
38 return ans;
39}
40
41
42INLINE_SIM_FPU (sim_fpu)
43sim_fpu_sub (sim_fpu l,
44 sim_fpu r)
45{
46 sim_fpu ans;
47 ans.val = l.val - r.val;
48 return ans;
49}
50
51
52INLINE_SIM_FPU (sim_fpu)
53sim_fpu_mul (sim_fpu l,
54 sim_fpu r)
55{
56 sim_fpu ans;
57 ans.val = l.val * r.val;
58 return ans;
59}
60
61
62INLINE_SIM_FPU (sim_fpu)
63sim_fpu_div (sim_fpu l,
64 sim_fpu r)
65{
66 sim_fpu ans;
67 ans.val = l.val / r.val;
68 return ans;
69}
70
71
72INLINE_SIM_FPU (sim_fpu)
73sim_fpu_inv (sim_fpu r)
74{
75 sim_fpu ans;
76 ans.val = 1 / r.val;
77 return ans;
78}
79
80
81INLINE_SIM_FPU (sim_fpu)
82sim_fpu_sqrt (sim_fpu r)
83{
84 sim_fpu ans;
85 ans.val = sqrt (r.val);
86 return ans;
87}
88
89
90INLINE_SIM_FPU (sim_fpu)
91sim_fpu_32to (unsigned32 s)
92{
93 sim_fpu ans;
94 ans.val = *(float*) &s;
95 return ans;
96}
97
98
99INLINE_SIM_FPU (sim_fpu)
100sim_fpu_64to (unsigned64 s)
101{
102 sim_fpu ans;
103 ans.val = *(double*) &s;
104 return ans;
105}
106
107
108INLINE_SIM_FPU (unsigned32)
109sim_fpu_to32 (sim_fpu l)
110{
111 float s = l.val;
112 return *(unsigned32*) &s;
113}
114
115
116INLINE_SIM_FPU (unsigned64)
117sim_fpu_to64 (sim_fpu s)
118{
119 return *(unsigned64*) &s.val;
120}
121
122
123INLINE_SIM_FPU (float)
124sim_fpu_2f (sim_fpu f)
125{
126 return f.val;
127}
128
129
130INLINE_SIM_FPU (double)
131sim_fpu_2d (sim_fpu s)
132{
133 return s.val;
134}
135
136
137INLINE_SIM_FPU (sim_fpu)
138sim_fpu_f2 (float f)
139{
140 sim_fpu ans;
141 ans.val = f;
142 return ans;
143}
144
145
146INLINE_SIM_FPU (sim_fpu)
147sim_fpu_d2 (double d)
148{
149 sim_fpu ans;
150 ans.val = d;
151 return ans;
152}
153
154
155INLINE_SIM_FPU (int)
156sim_fpu_is_nan (sim_fpu d)
157{
158 return 0; /* FIXME - detect NaN */
159}
160
161
162INLINE_SIM_FPU (int)
163sim_fpu_cmp (sim_fpu l,
164 sim_fpu r)
165{
166 return l.val - r.val;
167}
168
169#endif
This page took 0.028553 seconds and 4 git commands to generate.