annotate gcc/ada/eval_fat.ads @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT COMPILER COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- E V A L _ F A T --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
kono
parents:
diff changeset
9 -- Copyright (C) 1992-2012, Free Software Foundation, Inc. --
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
kono
parents:
diff changeset
17 -- for more details. You should have received a copy of the GNU General --
kono
parents:
diff changeset
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
kono
parents:
diff changeset
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
kono
parents:
diff changeset
20 -- --
kono
parents:
diff changeset
21 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
23 -- --
kono
parents:
diff changeset
24 ------------------------------------------------------------------------------
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 -- This package provides for compile-time evaluation of static calls to the
kono
parents:
diff changeset
27 -- floating-point attribute functions. It is the compile-time equivalent of
kono
parents:
diff changeset
28 -- the System.Fat_Gen runtime package. The coding is quite similar, as are
kono
parents:
diff changeset
29 -- the subprogram specs, except that the type is passed as an explicit
kono
parents:
diff changeset
30 -- first parameter (and used via ttypes, to obtain the necessary information
kono
parents:
diff changeset
31 -- about the characteristics of the type for computing the results.
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 with Types; use Types;
kono
parents:
diff changeset
34 with Uintp; use Uintp;
kono
parents:
diff changeset
35 with Urealp; use Urealp;
kono
parents:
diff changeset
36
kono
parents:
diff changeset
37 package Eval_Fat is
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 subtype UI is Uint;
kono
parents:
diff changeset
40 -- The compile time representation of universal integer
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 subtype T is Ureal;
kono
parents:
diff changeset
43 -- The compile time representation of floating-point values
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 subtype R is Entity_Id;
kono
parents:
diff changeset
46 -- The compile time representation of the floating-point root type
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 -- The following functions perform the operation implied by their name
kono
parents:
diff changeset
49 -- which corresponds to the name of the attribute which they compute.
kono
parents:
diff changeset
50 -- The arguments correspond to the attribute function arguments.
kono
parents:
diff changeset
51
kono
parents:
diff changeset
52 function Adjacent (RT : R; X, Towards : T) return T;
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 function Ceiling (RT : R; X : T) return T;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 function Compose (RT : R; Fraction : T; Exponent : UI) return T;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 function Copy_Sign (RT : R; Value, Sign : T) return T;
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 function Exponent (RT : R; X : T) return UI;
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 function Floor (RT : R; X : T) return T;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 function Fraction (RT : R; X : T) return T;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 function Leading_Part (RT : R; X : T; Radix_Digits : UI) return T;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 function Model (RT : R; X : T) return T;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 function Pred (RT : R; X : T) return T;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 function Remainder (RT : R; X, Y : T) return T;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 function Rounding (RT : R; X : T) return T;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 function Scaling (RT : R; X : T; Adjustment : UI) return T;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 function Succ (RT : R; X : T) return T;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 function Truncation (RT : R; X : T) return T;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 function Unbiased_Rounding (RT : R; X : T) return T;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 -- The following global declarations are used by the Machine attribute
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 type Rounding_Mode is (Floor, Ceiling, Round, Round_Even);
kono
parents:
diff changeset
87 for Rounding_Mode use (0, 1, 2, 3);
kono
parents:
diff changeset
88 -- Used to indicate rounding mode for Machine attribute
kono
parents:
diff changeset
89 -- Note that C code in gigi knows that Round_Even is 3
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 -- The Machine attribute is special, in that it takes an extra argument
kono
parents:
diff changeset
92 -- indicating the rounding mode, and also an argument Enode that is a
kono
parents:
diff changeset
93 -- node used to post warnings (e.g. if asked to convert a negative zero
kono
parents:
diff changeset
94 -- on a machine for which Signed_Zeros is False).
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 function Machine
kono
parents:
diff changeset
97 (RT : R;
kono
parents:
diff changeset
98 X : T;
kono
parents:
diff changeset
99 Mode : Rounding_Mode;
kono
parents:
diff changeset
100 Enode : Node_Id) return T;
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 procedure Decompose_Int
kono
parents:
diff changeset
103 (RT : R;
kono
parents:
diff changeset
104 X : T;
kono
parents:
diff changeset
105 Fraction : out UI;
kono
parents:
diff changeset
106 Exponent : out UI;
kono
parents:
diff changeset
107 Mode : Rounding_Mode);
kono
parents:
diff changeset
108 -- Decomposes a floating-point number into fraction and exponent parts.
kono
parents:
diff changeset
109 -- The Fraction value returned is an integer representing the value
kono
parents:
diff changeset
110 -- Fraction * Scale, where Scale is the value (Machine_Radix_Value (RT) **
kono
parents:
diff changeset
111 -- Machine_Mantissa_Value (RT)). The value is obtained by using biased
kono
parents:
diff changeset
112 -- rounding (halfway cases round away from zero), round to even, a floor
kono
parents:
diff changeset
113 -- operation or a ceiling operation depending on the setting of Mode (see
kono
parents:
diff changeset
114 -- corresponding descriptions in Urealp).
kono
parents:
diff changeset
115
kono
parents:
diff changeset
116 end Eval_Fat;