]>
Commit | Line | Data |
---|---|---|
70482933 RK |
1 | ------------------------------------------------------------------------------ |
2 | -- -- | |
3 | -- GNAT COMPILER COMPONENTS -- | |
4 | -- -- | |
5 | -- E V A L _ F A T -- | |
6 | -- -- | |
7 | -- S p e c -- | |
8 | -- -- | |
fbf5a39b | 9 | -- Copyright (C) 1992-2003 Free Software Foundation, Inc. -- |
70482933 RK |
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 | -- GNAT was originally developed by the GNAT team at New York University. -- | |
71ff80dc | 23 | -- Extensive contributions were provided by Ada Core Technologies Inc. -- |
70482933 RK |
24 | -- -- |
25 | ------------------------------------------------------------------------------ | |
26 | ||
27 | -- This package provides for compile-time evaluation of static calls to the | |
28 | -- floating-point attribute functions. It is the compile-time equivalent of | |
29 | -- the System.Fat_Gen runtime package. The coding is quite similar, as are | |
30 | -- the subprogram specs, except that the type is passed as an explicit | |
31 | -- first parameter (and used via ttypes, to obtain the necessary information | |
32 | -- about the characteristics of the type for computing the results. | |
33 | ||
34 | with Types; use Types; | |
35 | with Uintp; use Uintp; | |
36 | with Urealp; use Urealp; | |
37 | ||
38 | package Eval_Fat is | |
39 | ||
40 | subtype UI is Uint; | |
41 | -- The compile time representation of universal integer | |
42 | ||
43 | subtype T is Ureal; | |
44 | -- The compile time representation of floating-point values | |
45 | ||
46 | subtype R is Entity_Id; | |
47 | -- The compile time representation of the floating-point root type | |
48 | ||
fbf5a39b AC |
49 | -- The following functions perform the operation implied by their name |
50 | -- which corresponds to the name of the attribute which they compute. | |
51 | -- The arguments correspond to the attribute function arguments. | |
70482933 RK |
52 | |
53 | function Adjacent (RT : R; X, Towards : T) return T; | |
54 | ||
55 | function Ceiling (RT : R; X : T) return T; | |
56 | ||
57 | function Compose (RT : R; Fraction : T; Exponent : UI) return T; | |
58 | ||
59 | function Copy_Sign (RT : R; Value, Sign : T) return T; | |
60 | ||
61 | function Exponent (RT : R; X : T) return UI; | |
62 | ||
63 | function Floor (RT : R; X : T) return T; | |
64 | ||
65 | function Fraction (RT : R; X : T) return T; | |
66 | ||
67 | function Leading_Part (RT : R; X : T; Radix_Digits : UI) return T; | |
68 | ||
70482933 RK |
69 | function Model (RT : R; X : T) return T; |
70 | ||
71 | function Pred (RT : R; X : T) return T; | |
72 | ||
73 | function Remainder (RT : R; X, Y : T) return T; | |
74 | ||
75 | function Rounding (RT : R; X : T) return T; | |
76 | ||
77 | function Scaling (RT : R; X : T; Adjustment : UI) return T; | |
78 | ||
79 | function Succ (RT : R; X : T) return T; | |
80 | ||
81 | function Truncation (RT : R; X : T) return T; | |
82 | ||
83 | function Unbiased_Rounding (RT : R; X : T) return T; | |
84 | ||
fbf5a39b AC |
85 | -- The following global declarations are used by the Machine attribute |
86 | ||
87 | type Rounding_Mode is (Floor, Ceiling, Round, Round_Even); | |
88 | for Rounding_Mode use (0, 1, 2, 3); | |
89 | -- Used to indicate rounding mode for Machine attribute | |
90 | -- Note that C code in gigi knows that Round_Even is 3 | |
91 | ||
92 | -- The Machine attribute is special, in that it takes an extra argument | |
93 | -- indicating the rounding mode, and also an argument Enode that is a | |
94 | -- node used to post warnings (e.g. if asked to convert a negative zero | |
95 | -- on a machine for which Signed_Zeros is False). | |
96 | ||
97 | function Machine | |
98 | (RT : R; | |
99 | X : T; | |
100 | Mode : Rounding_Mode; | |
101 | Enode : Node_Id) | |
102 | return T; | |
103 | ||
70482933 | 104 | end Eval_Fat; |