More floating point operations.
[external/binutils.git] / sim / common / sim-fpu.h
1 /* Simulator Floating-point support.
2    Copyright (C) 1997 Free Software Foundation, Inc.
3    Contributed by Cygnus Support.
4
5 This file is part of GDB, the GNU debugger.
6
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)
10 any later version.
11
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.
16
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.  */
20
21
22
23 #ifndef _SIM_FPU_H_
24 #define _SIM_FPU_H_
25
26 /* the FPU intermediate type */
27
28 typedef struct _sim_fpu {
29   double val;
30 } sim_fpu;
31
32
33 /* Directly map a 32/64bit register quantity into the sim_fpu internal
34    type ready for various arithmetic and conversion operations. */
35
36 INLINE_SIM_FPU (sim_fpu) sim_fpu_32to (unsigned32 s);
37 INLINE_SIM_FPU (sim_fpu) sim_fpu_64to (unsigned64 s);
38
39 INLINE_SIM_FPU (unsigned32) sim_fpu_to32 (sim_fpu s);
40 INLINE_SIM_FPU (unsigned64) sim_fpu_to64 (sim_fpu s);
41
42
43 /* Arrithmetic operators */
44
45 INLINE_SIM_FPU (sim_fpu) sim_fpu_add (sim_fpu l, sim_fpu r);
46 INLINE_SIM_FPU (sim_fpu) sim_fpu_sub (sim_fpu l, sim_fpu r);
47 INLINE_SIM_FPU (sim_fpu) sim_fpu_mul (sim_fpu l, sim_fpu r);
48 INLINE_SIM_FPU (sim_fpu) sim_fpu_div (sim_fpu l, sim_fpu r);
49 INLINE_SIM_FPU (sim_fpu) sim_fpu_inv (sim_fpu l);
50 INLINE_SIM_FPU (sim_fpu) sim_fpu_sqrt (sim_fpu sqr);
51
52
53 /* Conversion of integer value into floating point types */
54
55 INLINE_SIM_FPU (sim_fpu) sim_fpu_i32to (signed32 s);
56 INLINE_SIM_FPU (sim_fpu) sim_fpu_u32to (unsigned32 s);
57 INLINE_SIM_FPU (sim_fpu) sim_fpu_i64to (signed64 s);
58 INLINE_SIM_FPU (sim_fpu) sim_fpu_u64to (unsigned64 s);
59
60
61 /* Conversion of internal sim_fpu type to host float and double
62    formats - for debuging/tracing */
63
64 INLINE_SIM_FPU (float) sim_fpu_2f (sim_fpu f);
65 INLINE_SIM_FPU (double) sim_fpu_2d (sim_fpu d);
66
67 #if 0
68 INLINE_SIM_FPU (sim_fpu) sim_fpu_f2 (float f);
69 INLINE_SIM_FPU (sim_fpu) sim_fpu_d2 (double d);
70 #endif
71
72
73 /* Signalling or NonSignalling NaN */
74
75 INLINE_SIM_FPU (int) sim_fpu_is_nan (sim_fpu s);
76
77
78 /* compare l with r; return <0, ==0, >0 accordingly */
79
80 INLINE_SIM_FPU (int) sim_fpu_is_lt (sim_fpu l, sim_fpu r);
81 INLINE_SIM_FPU (int) sim_fpu_is_le (sim_fpu l, sim_fpu r);
82 INLINE_SIM_FPU (int) sim_fpu_is_eq (sim_fpu l, sim_fpu r);
83 INLINE_SIM_FPU (int) sim_fpu_is_ne (sim_fpu l, sim_fpu r);
84 INLINE_SIM_FPU (int) sim_fpu_is_ge (sim_fpu l, sim_fpu r);
85 INLINE_SIM_FPU (int) sim_fpu_is_gt (sim_fpu l, sim_fpu r);
86
87 #endif