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-1998 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,  59 Temple Place - Suite 330,  Boston, --
20-- MA 02111-1307, 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
37package 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   ----------------------
143   -- Debug Procedures --
144   ----------------------
145
146   procedure Debug_Output_D (Arg : D);
147   procedure Debug_Output_F (Arg : F);
148   procedure Debug_Output_G (Arg : G);
149   pragma Export (Ada, Debug_Output_D);
150   pragma Export (Ada, Debug_Output_F);
151   pragma Export (Ada, Debug_Output_G);
152   --  These routines output their argument in decimal string form, with
153   --  no terminating line return. They are provided for implicit use by
154   --  the pre gnat-3.12w GDB, and are retained for backwards compatibility.
155
156   function Debug_String_D (Arg : D) return System.Address;
157   function Debug_String_F (Arg : F) return System.Address;
158   function Debug_String_G (Arg : G) return System.Address;
159   pragma Export (Ada, Debug_String_D);
160   pragma Export (Ada, Debug_String_F);
161   pragma Export (Ada, Debug_String_G);
162   --  These routines return a decimal C string image of their argument.
163   --  They are provided for implicit use by the debugger, in response to
164   --  the special encoding used for Vax floating-point types (see Exp_Dbug
165   --  for details). They supercede the above Debug_Output_D/F/G routines
166   --  which didn't work properly with GDBTK.
167
168   procedure pd (Arg : D);
169   procedure pf (Arg : F);
170   procedure pg (Arg : G);
171   pragma Export (Ada, pd);
172   pragma Export (Ada, pf);
173   pragma Export (Ada, pg);
174   --  These are like the Debug_Output_D/F/G procedures except that they
175   --  output a line return after the output. They were originally present
176   --  for direct use in GDB before GDB recognized Vax floating-point
177   --  types, and are retained for backwards compatibility.
178
179private
180   pragma Inline (D_To_G);
181   pragma Inline (F_To_G);
182   pragma Inline (F_To_Q);
183   pragma Inline (F_To_S);
184   pragma Inline (G_To_D);
185   pragma Inline (G_To_F);
186   pragma Inline (G_To_Q);
187   pragma Inline (G_To_T);
188   pragma Inline (Q_To_F);
189   pragma Inline (Q_To_G);
190   pragma Inline (S_To_F);
191   pragma Inline (T_To_G);
192
193   pragma Inline (Abs_F);
194   pragma Inline (Abs_G);
195   pragma Inline (Add_F);
196   pragma Inline (Add_G);
197   pragma Inline (Div_G);
198   pragma Inline (Div_F);
199   pragma Inline (Mul_F);
200   pragma Inline (Mul_G);
201   pragma Inline (Neg_G);
202   pragma Inline (Neg_F);
203   pragma Inline (Sub_F);
204   pragma Inline (Sub_G);
205
206   pragma Inline (Eq_F);
207   pragma Inline (Eq_G);
208   pragma Inline (Le_F);
209   pragma Inline (Le_G);
210   pragma Inline (Lt_F);
211   pragma Inline (Lt_G);
212
213end System.Vax_Float_Operations;
214