OSDN Git Service

9f205d4833856f37341a53051d31cb7d7b60e74c
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-vaflop.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --           S Y S T E M . V A X _ F L O A T _ O P E R A T I O N S          --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --          Copyright (C) 1997-2005, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
19 -- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
20 -- Boston, MA 02110-1301, USA.                                              --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This package contains runtime routines for handling the non-IEEE
35 --  floating-point formats used on the Vax and the Alpha.
36
37 package System.Vax_Float_Operations is
38
39    pragma Warnings (Off);
40    --  Suppress warnings if not on Alpha/VAX
41
42    type D is digits 9;
43    pragma Float_Representation (VAX_Float, D);
44    --  D Float type on Vax
45
46    type G is digits 15;
47    pragma Float_Representation (VAX_Float, G);
48    --  G Float type on Vax
49
50    type F is digits 6;
51    pragma Float_Representation (VAX_Float, F);
52    --  F Float type on Vax
53
54    type S is digits 6;
55    pragma Float_Representation (IEEE_Float, S);
56    --  IEEE short
57
58    type T is digits 15;
59    pragma Float_Representation (IEEE_Float, T);
60    --  IEEE long
61
62    pragma Warnings (On);
63
64    type Q is range -2 ** 63 .. +(2 ** 63 - 1);
65    --  64-bit signed integer
66
67    --------------------------
68    -- Conversion Functions --
69    --------------------------
70
71    function D_To_G (X : D) return G;
72    function G_To_D (X : G) return D;
73    --  Conversions between D float and G float
74
75    function G_To_F (X : G) return F;
76    function F_To_G (X : F) return G;
77    --  Conversions between F float and G float
78
79    function F_To_S (X : F) return S;
80    function S_To_F (X : S) return F;
81    --  Conversions between F float and IEEE short
82
83    function G_To_T (X : G) return T;
84    function T_To_G (X : T) return G;
85    --  Conversions between G float and IEEE long
86
87    function F_To_Q (X : F) return Q;
88    function Q_To_F (X : Q) return F;
89    --  Conversions between F float and 64-bit integer
90
91    function G_To_Q (X : G) return Q;
92    function Q_To_G (X : Q) return G;
93    --  Conversions between G float and 64-bit integer
94
95    function T_To_D (X : T) return D;
96    --  Conversion from IEEE long to D_Float (used for literals)
97
98    --------------------------
99    -- Arithmetic Functions --
100    --------------------------
101
102    function Abs_F (X : F) return F;
103    function Abs_G (X : G) return G;
104    --  Absolute value of F/G float
105
106    function Add_F (X, Y : F) return F;
107    function Add_G (X, Y : G) return G;
108    --  Addition of F/G float
109
110    function Div_F (X, Y : F) return F;
111    function Div_G (X, Y : G) return G;
112    --  Division of F/G float
113
114    function Mul_F (X, Y : F) return F;
115    function Mul_G (X, Y : G) return G;
116    --  Multiplication of F/G float
117
118    function Neg_F (X : F) return F;
119    function Neg_G (X : G) return G;
120    --  Negation of F/G float
121
122    function Sub_F (X, Y : F) return F;
123    function Sub_G (X, Y : G) return G;
124    --  Subtraction of F/G float
125
126    --------------------------
127    -- Comparison Functions --
128    --------------------------
129
130    function Eq_F (X, Y : F) return Boolean;
131    function Eq_G (X, Y : G) return Boolean;
132    --  Compares for X = Y
133
134    function Le_F (X, Y : F) return Boolean;
135    function Le_G (X, Y : G) return Boolean;
136    --  Compares for X <= Y
137
138    function Lt_F (X, Y : F) return Boolean;
139    function Lt_G (X, Y : G) return Boolean;
140    --  Compares for X < Y
141
142    function Ne_F (X, Y : F) return Boolean;
143    function Ne_G (X, Y : G) return Boolean;
144    --  Compares for X /= Y
145
146    ----------------------------------
147    -- Routines for Valid Attribute --
148    ----------------------------------
149
150    function Valid_D (Arg : D) return Boolean;
151    function Valid_F (Arg : F) return Boolean;
152    function Valid_G (Arg : G) return Boolean;
153    --  Test whether Arg has a valid representation
154
155    ----------------------
156    -- Debug Procedures --
157    ----------------------
158
159    procedure Debug_Output_D (Arg : D);
160    procedure Debug_Output_F (Arg : F);
161    procedure Debug_Output_G (Arg : G);
162    pragma Export (Ada, Debug_Output_D);
163    pragma Export (Ada, Debug_Output_F);
164    pragma Export (Ada, Debug_Output_G);
165    --  These routines output their argument in decimal string form, with
166    --  no terminating line return. They are provided for implicit use by
167    --  the pre gnat-3.12w GDB, and are retained for backwards compatibility.
168
169    function Debug_String_D (Arg : D) return System.Address;
170    function Debug_String_F (Arg : F) return System.Address;
171    function Debug_String_G (Arg : G) return System.Address;
172    pragma Export (Ada, Debug_String_D);
173    pragma Export (Ada, Debug_String_F);
174    pragma Export (Ada, Debug_String_G);
175    --  These routines return a decimal C string image of their argument.
176    --  They are provided for implicit use by the debugger, in response to
177    --  the special encoding used for Vax floating-point types (see Exp_Dbug
178    --  for details). They supercede the above Debug_Output_D/F/G routines
179    --  which didn't work properly with GDBTK.
180
181    procedure pd (Arg : D);
182    procedure pf (Arg : F);
183    procedure pg (Arg : G);
184    pragma Export (Ada, pd);
185    pragma Export (Ada, pf);
186    pragma Export (Ada, pg);
187    --  These are like the Debug_Output_D/F/G procedures except that they
188    --  output a line return after the output. They were originally present
189    --  for direct use in GDB before GDB recognized Vax floating-point
190    --  types, and are retained for backwards compatibility.
191
192 private
193    pragma Inline (D_To_G);
194    pragma Inline (F_To_G);
195    pragma Inline (F_To_Q);
196    pragma Inline (F_To_S);
197    pragma Inline (G_To_D);
198    pragma Inline (G_To_F);
199    pragma Inline (G_To_Q);
200    pragma Inline (G_To_T);
201    pragma Inline (Q_To_F);
202    pragma Inline (Q_To_G);
203    pragma Inline (S_To_F);
204    pragma Inline (T_To_G);
205
206    pragma Inline (Abs_F);
207    pragma Inline (Abs_G);
208    pragma Inline (Add_F);
209    pragma Inline (Add_G);
210    pragma Inline (Div_G);
211    pragma Inline (Div_F);
212    pragma Inline (Mul_F);
213    pragma Inline (Mul_G);
214    pragma Inline (Neg_G);
215    pragma Inline (Neg_F);
216    pragma Inline (Sub_F);
217    pragma Inline (Sub_G);
218
219    pragma Inline (Eq_F);
220    pragma Inline (Eq_G);
221    pragma Inline (Le_F);
222    pragma Inline (Le_G);
223    pragma Inline (Lt_F);
224    pragma Inline (Lt_G);
225    pragma Inline (Ne_F);
226    pragma Inline (Ne_G);
227
228    pragma Inline (Valid_D);
229    pragma Inline (Valid_F);
230    pragma Inline (Valid_G);
231
232 end System.Vax_Float_Operations;