aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.2.1/gcc/ada/s-vaflop.ads
blob: 9f205d4833856f37341a53051d31cb7d7b60e74c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
------------------------------------------------------------------------------
--                                                                          --
--                         GNAT COMPILER COMPONENTS                         --
--                                                                          --
--           S Y S T E M . V A X _ F L O A T _ O P E R A T I O N S          --
--                                                                          --
--                                 S p e c                                  --
--                                                                          --
--          Copyright (C) 1997-2005, Free Software Foundation, Inc.         --
--                                                                          --
-- GNAT is free software;  you can  redistribute it  and/or modify it under --
-- terms of the  GNU General Public License as published  by the Free Soft- --
-- ware  Foundation;  either version 2,  or (at your option) any later ver- --
-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
-- for  more details.  You should have  received  a copy of the GNU General --
-- Public License  distributed with GNAT;  see file COPYING.  If not, write --
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
-- Boston, MA 02110-1301, USA.                                              --
--                                                                          --
-- As a special exception,  if other files  instantiate  generics from this --
-- unit, or you link  this unit with other files  to produce an executable, --
-- this  unit  does not  by itself cause  the resulting  executable  to  be --
-- covered  by the  GNU  General  Public  License.  This exception does not --
-- however invalidate  any other reasons why  the executable file  might be --
-- covered by the  GNU Public License.                                      --
--                                                                          --
-- GNAT was originally developed  by the GNAT team at  New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
--                                                                          --
------------------------------------------------------------------------------

--  This package contains runtime routines for handling the non-IEEE
--  floating-point formats used on the Vax and the Alpha.

package System.Vax_Float_Operations is

   pragma Warnings (Off);
   --  Suppress warnings if not on Alpha/VAX

   type D is digits 9;
   pragma Float_Representation (VAX_Float, D);
   --  D Float type on Vax

   type G is digits 15;
   pragma Float_Representation (VAX_Float, G);
   --  G Float type on Vax

   type F is digits 6;
   pragma Float_Representation (VAX_Float, F);
   --  F Float type on Vax

   type S is digits 6;
   pragma Float_Representation (IEEE_Float, S);
   --  IEEE short

   type T is digits 15;
   pragma Float_Representation (IEEE_Float, T);
   --  IEEE long

   pragma Warnings (On);

   type Q is range -2 ** 63 .. +(2 ** 63 - 1);
   --  64-bit signed integer

   --------------------------
   -- Conversion Functions --
   --------------------------

   function D_To_G (X : D) return G;
   function G_To_D (X : G) return D;
   --  Conversions between D float and G float

   function G_To_F (X : G) return F;
   function F_To_G (X : F) return G;
   --  Conversions between F float and G float

   function F_To_S (X : F) return S;
   function S_To_F (X : S) return F;
   --  Conversions between F float and IEEE short

   function G_To_T (X : G) return T;
   function T_To_G (X : T) return G;
   --  Conversions between G float and IEEE long

   function F_To_Q (X : F) return Q;
   function Q_To_F (X : Q) return F;
   --  Conversions between F float and 64-bit integer

   function G_To_Q (X : G) return Q;
   function Q_To_G (X : Q) return G;
   --  Conversions between G float and 64-bit integer

   function T_To_D (X : T) return D;
   --  Conversion from IEEE long to D_Float (used for literals)

   --------------------------
   -- Arithmetic Functions --
   --------------------------

   function Abs_F (X : F) return F;
   function Abs_G (X : G) return G;
   --  Absolute value of F/G float

   function Add_F (X, Y : F) return F;
   function Add_G (X, Y : G) return G;
   --  Addition of F/G float

   function Div_F (X, Y : F) return F;
   function Div_G (X, Y : G) return G;
   --  Division of F/G float

   function Mul_F (X, Y : F) return F;
   function Mul_G (X, Y : G) return G;
   --  Multiplication of F/G float

   function Neg_F (X : F) return F;
   function Neg_G (X : G) return G;
   --  Negation of F/G float

   function Sub_F (X, Y : F) return F;
   function Sub_G (X, Y : G) return G;
   --  Subtraction of F/G float

   --------------------------
   -- Comparison Functions --
   --------------------------

   function Eq_F (X, Y : F) return Boolean;
   function Eq_G (X, Y : G) return Boolean;
   --  Compares for X = Y

   function Le_F (X, Y : F) return Boolean;
   function Le_G (X, Y : G) return Boolean;
   --  Compares for X <= Y

   function Lt_F (X, Y : F) return Boolean;
   function Lt_G (X, Y : G) return Boolean;
   --  Compares for X < Y

   function Ne_F (X, Y : F) return Boolean;
   function Ne_G (X, Y : G) return Boolean;
   --  Compares for X /= Y

   ----------------------------------
   -- Routines for Valid Attribute --
   ----------------------------------

   function Valid_D (Arg : D) return Boolean;
   function Valid_F (Arg : F) return Boolean;
   function Valid_G (Arg : G) return Boolean;
   --  Test whether Arg has a valid representation

   ----------------------
   -- Debug Procedures --
   ----------------------

   procedure Debug_Output_D (Arg : D);
   procedure Debug_Output_F (Arg : F);
   procedure Debug_Output_G (Arg : G);
   pragma Export (Ada, Debug_Output_D);
   pragma Export (Ada, Debug_Output_F);
   pragma Export (Ada, Debug_Output_G);
   --  These routines output their argument in decimal string form, with
   --  no terminating line return. They are provided for implicit use by
   --  the pre gnat-3.12w GDB, and are retained for backwards compatibility.

   function Debug_String_D (Arg : D) return System.Address;
   function Debug_String_F (Arg : F) return System.Address;
   function Debug_String_G (Arg : G) return System.Address;
   pragma Export (Ada, Debug_String_D);
   pragma Export (Ada, Debug_String_F);
   pragma Export (Ada, Debug_String_G);
   --  These routines return a decimal C string image of their argument.
   --  They are provided for implicit use by the debugger, in response to
   --  the special encoding used for Vax floating-point types (see Exp_Dbug
   --  for details). They supercede the above Debug_Output_D/F/G routines
   --  which didn't work properly with GDBTK.

   procedure pd (Arg : D);
   procedure pf (Arg : F);
   procedure pg (Arg : G);
   pragma Export (Ada, pd);
   pragma Export (Ada, pf);
   pragma Export (Ada, pg);
   --  These are like the Debug_Output_D/F/G procedures except that they
   --  output a line return after the output. They were originally present
   --  for direct use in GDB before GDB recognized Vax floating-point
   --  types, and are retained for backwards compatibility.

private
   pragma Inline (D_To_G);
   pragma Inline (F_To_G);
   pragma Inline (F_To_Q);
   pragma Inline (F_To_S);
   pragma Inline (G_To_D);
   pragma Inline (G_To_F);
   pragma Inline (G_To_Q);
   pragma Inline (G_To_T);
   pragma Inline (Q_To_F);
   pragma Inline (Q_To_G);
   pragma Inline (S_To_F);
   pragma Inline (T_To_G);

   pragma Inline (Abs_F);
   pragma Inline (Abs_G);
   pragma Inline (Add_F);
   pragma Inline (Add_G);
   pragma Inline (Div_G);
   pragma Inline (Div_F);
   pragma Inline (Mul_F);
   pragma Inline (Mul_G);
   pragma Inline (Neg_G);
   pragma Inline (Neg_F);
   pragma Inline (Sub_F);
   pragma Inline (Sub_G);

   pragma Inline (Eq_F);
   pragma Inline (Eq_G);
   pragma Inline (Le_F);
   pragma Inline (Le_G);
   pragma Inline (Lt_F);
   pragma Inline (Lt_G);
   pragma Inline (Ne_F);
   pragma Inline (Ne_G);

   pragma Inline (Valid_D);
   pragma Inline (Valid_F);
   pragma Inline (Valid_G);

end System.Vax_Float_Operations;