1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
10 -- Copyright (C) 1992-2001 Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- GNAT was originally developed by the GNAT team at New York University. --
24 -- Extensive contributions were provided by Ada Core Technologies Inc. --
26 ------------------------------------------------------------------------------
28 -- This package provides for compile-time evaluation of static calls to the
29 -- floating-point attribute functions. It is the compile-time equivalent of
30 -- the System.Fat_Gen runtime package. The coding is quite similar, as are
31 -- the subprogram specs, except that the type is passed as an explicit
32 -- first parameter (and used via ttypes, to obtain the necessary information
33 -- about the characteristics of the type for computing the results.
35 with Types
; use Types
;
36 with Uintp
; use Uintp
;
37 with Urealp
; use Urealp
;
42 -- The compile time representation of universal integer
45 -- The compile time representation of floating-point values
47 subtype R
is Entity_Id
;
48 -- The compile time representation of the floating-point root type
50 type Rounding_Mode
is (Floor
, Ceiling
, Round
, Round_Even
);
51 for Rounding_Mode
use (0, 1, 2, 3);
52 -- Used to indicate rounding mode for Machine attribute
53 -- Note that C code in gigi knows that Round_Even is 3
55 Rounding_Was_Biased
: Boolean;
56 -- Set if last use of Machine rounded a halfway case away from zero
58 function Adjacent
(RT
: R
; X
, Towards
: T
) return T
;
60 function Ceiling
(RT
: R
; X
: T
) return T
;
62 function Compose
(RT
: R
; Fraction
: T
; Exponent
: UI
) return T
;
64 function Copy_Sign
(RT
: R
; Value
, Sign
: T
) return T
;
66 function Exponent
(RT
: R
; X
: T
) return UI
;
68 function Floor
(RT
: R
; X
: T
) return T
;
70 function Fraction
(RT
: R
; X
: T
) return T
;
72 function Leading_Part
(RT
: R
; X
: T
; Radix_Digits
: UI
) return T
;
74 function Machine
(RT
: R
; X
: T
; Mode
: Rounding_Mode
) return T
;
76 function Model
(RT
: R
; X
: T
) return T
;
78 function Pred
(RT
: R
; X
: T
) return T
;
80 function Remainder
(RT
: R
; X
, Y
: T
) return T
;
82 function Rounding
(RT
: R
; X
: T
) return T
;
84 function Scaling
(RT
: R
; X
: T
; Adjustment
: UI
) return T
;
86 function Succ
(RT
: R
; X
: T
) return T
;
88 function Truncation
(RT
: R
; X
: T
) return T
;
90 function Unbiased_Rounding
(RT
: R
; X
: T
) return T
;