annotate gcc/ada/libgnat/s-fatgen.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
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 -- S Y S T E M . F A T _ G E N --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 1992-2018, Free Software Foundation, Inc. --
111
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. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This generic package provides a target independent implementation of the
kono
parents:
diff changeset
33 -- floating-point attributes that denote functions. The implementations here
kono
parents:
diff changeset
34 -- are portable, but very slow. The runtime contains a set of instantiations
kono
parents:
diff changeset
35 -- of this package for all predefined floating-point types, and these should
kono
parents:
diff changeset
36 -- be replaced by efficient assembly language code where possible.
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 generic
kono
parents:
diff changeset
39 type T is digits <>;
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 package System.Fat_Gen is
kono
parents:
diff changeset
42 pragma Pure;
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 subtype UI is Integer;
kono
parents:
diff changeset
45 -- The runtime representation of universal integer for the purposes of
kono
parents:
diff changeset
46 -- this package is integer. The expander generates conversions for the
kono
parents:
diff changeset
47 -- actual type used. For functions returning universal integer, there
kono
parents:
diff changeset
48 -- is no problem, since the result always is in range of integer. For
kono
parents:
diff changeset
49 -- input arguments, the expander has to do some special casing to deal
kono
parents:
diff changeset
50 -- with the (very annoying) cases of out of range values. If we used
kono
parents:
diff changeset
51 -- Long_Long_Integer to represent universal, then there would be no
kono
parents:
diff changeset
52 -- problem, but the resulting inefficiency would be annoying.
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 function Adjacent (X, Towards : T) return T;
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 function Ceiling (X : T) return T;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 function Compose (Fraction : T; Exponent : UI) return T;
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 function Copy_Sign (Value, Sign : T) return T;
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 function Exponent (X : T) return UI;
kono
parents:
diff changeset
63
kono
parents:
diff changeset
64 function Floor (X : T) return T;
kono
parents:
diff changeset
65
kono
parents:
diff changeset
66 function Fraction (X : T) return T;
kono
parents:
diff changeset
67
kono
parents:
diff changeset
68 function Leading_Part (X : T; Radix_Digits : UI) return T;
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 function Machine (X : T) return T;
kono
parents:
diff changeset
71
kono
parents:
diff changeset
72 function Machine_Rounding (X : T) return T;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 function Model (X : T) return T;
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 function Pred (X : T) return T;
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 function Remainder (X, Y : T) return T;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 function Rounding (X : T) return T;
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 function Scaling (X : T; Adjustment : UI) return T;
kono
parents:
diff changeset
83
kono
parents:
diff changeset
84 function Succ (X : T) return T;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 function Truncation (X : T) return T;
kono
parents:
diff changeset
87
kono
parents:
diff changeset
88 function Unbiased_Rounding (X : T) return T;
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 function Valid (X : not null access T) return Boolean;
kono
parents:
diff changeset
91 -- This function checks if the object of type T referenced by X is valid,
kono
parents:
diff changeset
92 -- and returns True/False accordingly. The parameter is passed by reference
kono
parents:
diff changeset
93 -- (access) here, as the object of type T may be an abnormal value that
kono
parents:
diff changeset
94 -- cannot be passed in a floating-point register, and the whole point of
kono
parents:
diff changeset
95 -- 'Valid is to prevent exceptions. Note that the object of type T must
kono
parents:
diff changeset
96 -- have the natural alignment for type T.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 type S is new String (1 .. T'Size / Character'Size);
kono
parents:
diff changeset
99 type P is access all S with Storage_Size => 0;
kono
parents:
diff changeset
100 -- Buffer and access types used to initialize temporaries for validity
kono
parents:
diff changeset
101 -- checks, if the value to be checked has reverse scalar storage order, or
kono
parents:
diff changeset
102 -- is not known to be properly aligned (for example it appears in a packed
kono
parents:
diff changeset
103 -- record). In this case, we cannot call Valid since Valid assumes proper
kono
parents:
diff changeset
104 -- full alignment. Instead, we copy the value to a temporary location using
kono
parents:
diff changeset
105 -- type S (we cannot simply do a copy of a T value, because the value might
kono
parents:
diff changeset
106 -- be invalid, in which case it might not be possible to copy it through a
kono
parents:
diff changeset
107 -- floating point register).
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 private
kono
parents:
diff changeset
110 pragma Inline (Machine);
kono
parents:
diff changeset
111 pragma Inline (Model);
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 -- Note: previously the validity checking subprograms (Unaligned_Valid and
kono
parents:
diff changeset
114 -- Valid) were also inlined, but this was changed since there were some
kono
parents:
diff changeset
115 -- problems with this inlining in optimized mode, and in any case it seems
kono
parents:
diff changeset
116 -- better to avoid this inlining (space and robustness considerations).
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 end System.Fat_Gen;