annotate gcc/ada/ttypes.ads @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 1830386684a0
children
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 -- T T Y P E S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 1992-2019, 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. 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 contains constants describing target properties
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 with Types; use Types;
kono
parents:
diff changeset
29 with Get_Targ;
kono
parents:
diff changeset
30 with Set_Targ;
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 package Ttypes is
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 ------------------------------
kono
parents:
diff changeset
35 -- Host/Target Dependencies --
kono
parents:
diff changeset
36 ------------------------------
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 -- It is vital to maintain a clear distinction between properties of
kono
parents:
diff changeset
39 -- types on the host and types on the target, since in the general
kono
parents:
diff changeset
40 -- case of a cross-compiler these will be different.
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 -- This package provides definitions of values that describe the properties
kono
parents:
diff changeset
43 -- of the target types. All instances of target dependencies, including the
kono
parents:
diff changeset
44 -- definitions of such packages as Standard and System depend directly or
kono
parents:
diff changeset
45 -- indirectly on the definitions in the Ttypes packages.
kono
parents:
diff changeset
46
kono
parents:
diff changeset
47 -- In the source of the compiler, references to attributes such as
kono
parents:
diff changeset
48 -- Integer'Size will give information regarding the host types (i.e.
kono
parents:
diff changeset
49 -- the types within the compiler itself). Such references are therefore
kono
parents:
diff changeset
50 -- almost always suspicious (it is hard for example to see that the
kono
parents:
diff changeset
51 -- code in the compiler should even be using type Integer very much,
kono
parents:
diff changeset
52 -- and certainly this code should not depend on the size of Integer).
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 -- On the other hand, it is perfectly reasonable for the compiler to
kono
parents:
diff changeset
55 -- require access to the size of type Integer for the target machine,
kono
parents:
diff changeset
56 -- e.g. in constructing the internal representation of package Standard.
kono
parents:
diff changeset
57 -- For this purpose, instead of referencing the attribute Integer'Size,
kono
parents:
diff changeset
58 -- a reference to Ttypes.Standard_Integer_Size will provide the needed
kono
parents:
diff changeset
59 -- value for the target type.
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 -- Two approaches are used for handling target dependent values in the
kono
parents:
diff changeset
62 -- standard library packages. Package Standard is handled specially,
kono
parents:
diff changeset
63 -- being constructed internally (by package Stand). Target dependent
kono
parents:
diff changeset
64 -- values needed in Stand are obtained by direct reference to Ttypes
kono
parents:
diff changeset
65 -- and Ttypef.
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 -- For package System, there is a separate version for each target, with
kono
parents:
diff changeset
68 -- explicit declarations of the required, constants.
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 -- Historical note: Originally we had in mind dealing with target dependent
kono
parents:
diff changeset
71 -- differences by referencing appropriate attributes. Ada 95 already
kono
parents:
diff changeset
72 -- defines most of the required attributes, and GNAT specific attributes
kono
parents:
diff changeset
73 -- were defined to cover the remaining cases (such as Storage_Unit).
kono
parents:
diff changeset
74 -- The additional attributes that have been added to GNAT (Address_Size,
kono
parents:
diff changeset
75 -- Storage_Unit, and Word_Size) are redundant with respect to the
kono
parents:
diff changeset
76 -- corresponding references to System constants. For example in a program,
kono
parents:
diff changeset
77 -- System.Address_Size and Standard'Address_Size yield the same value.
kono
parents:
diff changeset
78 -- These attributes have been retained for compatibility purposes, but
kono
parents:
diff changeset
79 -- serve no purpose at this stage.
kono
parents:
diff changeset
80
kono
parents:
diff changeset
81 -- Note that during compilation there are two versions of package System
kono
parents:
diff changeset
82 -- around. The version that is directly with'ed by compiler packages
kono
parents:
diff changeset
83 -- contains host-dependent definitions, which is what is needed in that
kono
parents:
diff changeset
84 -- case (for example, System.Storage_Unit referenced in the source of the
kono
parents:
diff changeset
85 -- compiler refers to the storage unit of the host, not the target). This
kono
parents:
diff changeset
86 -- means that, like attribute references, any references to constants in
kono
parents:
diff changeset
87 -- package System in the compiler code are suspicious, since it is strange
kono
parents:
diff changeset
88 -- for the compiler to have such host dependencies. If the compiler needs
kono
parents:
diff changeset
89 -- to access the target dependent values of such quantities as Storage_Unit
kono
parents:
diff changeset
90 -- then it should reference the constants in this package (Ttypes), rather
kono
parents:
diff changeset
91 -- than referencing System.Storage_Unit, or Standard'Storage_Unit, both of
kono
parents:
diff changeset
92 -- which would yield the host value.
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 ---------------------------------------------------
kono
parents:
diff changeset
95 -- Target-Dependent Values for Types in Standard --
kono
parents:
diff changeset
96 ---------------------------------------------------
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 -- Note: GNAT always supplies all the following integer and float types,
kono
parents:
diff changeset
99 -- but depending on the machine, some of the types may be identical. For
kono
parents:
diff changeset
100 -- example, on some machines, Short_Float may be the same as Float, and
kono
parents:
diff changeset
101 -- Long_Long_Float may be the same as Long_Float.
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 Standard_Short_Short_Integer_Size : constant Pos :=
kono
parents:
diff changeset
104 Set_Targ.Char_Size;
kono
parents:
diff changeset
105 Standard_Short_Short_Integer_Width : constant Pos :=
kono
parents:
diff changeset
106 Get_Targ.Width_From_Size
kono
parents:
diff changeset
107 (Standard_Short_Short_Integer_Size);
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109 Standard_Short_Integer_Size : constant Pos :=
kono
parents:
diff changeset
110 Set_Targ.Short_Size;
kono
parents:
diff changeset
111 Standard_Short_Integer_Width : constant Pos :=
kono
parents:
diff changeset
112 Get_Targ.Width_From_Size
kono
parents:
diff changeset
113 (Standard_Short_Integer_Size);
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 Standard_Integer_Size : constant Pos :=
kono
parents:
diff changeset
116 Set_Targ.Int_Size;
kono
parents:
diff changeset
117 Standard_Integer_Width : constant Pos :=
kono
parents:
diff changeset
118 Get_Targ.Width_From_Size
kono
parents:
diff changeset
119 (Standard_Integer_Size);
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 Standard_Long_Integer_Size : constant Pos :=
kono
parents:
diff changeset
122 Set_Targ.Long_Size;
kono
parents:
diff changeset
123 Standard_Long_Integer_Width : constant Pos :=
kono
parents:
diff changeset
124 Get_Targ.Width_From_Size
kono
parents:
diff changeset
125 (Standard_Long_Integer_Size);
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 Standard_Long_Long_Integer_Size : constant Pos :=
kono
parents:
diff changeset
128 Set_Targ.Long_Long_Size;
kono
parents:
diff changeset
129 Standard_Long_Long_Integer_Width : constant Pos :=
kono
parents:
diff changeset
130 Get_Targ.Width_From_Size
kono
parents:
diff changeset
131 (Standard_Long_Long_Integer_Size);
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 Standard_Short_Float_Size : constant Pos :=
kono
parents:
diff changeset
134 Set_Targ.Float_Size;
kono
parents:
diff changeset
135 Standard_Short_Float_Digits : constant Pos :=
kono
parents:
diff changeset
136 Get_Targ.Digits_From_Size
kono
parents:
diff changeset
137 (Standard_Short_Float_Size);
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 Standard_Float_Size : constant Pos :=
kono
parents:
diff changeset
140 Set_Targ.Float_Size;
kono
parents:
diff changeset
141 Standard_Float_Digits : constant Pos :=
kono
parents:
diff changeset
142 Get_Targ.Digits_From_Size
kono
parents:
diff changeset
143 (Standard_Float_Size);
kono
parents:
diff changeset
144
kono
parents:
diff changeset
145 Standard_Long_Float_Size : constant Pos :=
kono
parents:
diff changeset
146 Set_Targ.Double_Size;
kono
parents:
diff changeset
147 Standard_Long_Float_Digits : constant Pos :=
kono
parents:
diff changeset
148 Get_Targ.Digits_From_Size
kono
parents:
diff changeset
149 (Standard_Long_Float_Size);
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 Standard_Long_Long_Float_Size : constant Pos :=
kono
parents:
diff changeset
152 Set_Targ.Long_Double_Size;
kono
parents:
diff changeset
153 Standard_Long_Long_Float_Digits : constant Pos :=
kono
parents:
diff changeset
154 Get_Targ.Digits_From_Size
kono
parents:
diff changeset
155 (Standard_Long_Long_Float_Size);
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 Standard_Character_Size : constant Pos := Set_Targ.Char_Size;
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 Standard_Wide_Character_Size : constant Pos := 16;
kono
parents:
diff changeset
160 Standard_Wide_Wide_Character_Size : constant Pos := 32;
kono
parents:
diff changeset
161 -- Standard wide character sizes
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 -- Note: there is no specific control over the representation of
kono
parents:
diff changeset
164 -- enumeration types. The convention used is that if an enumeration
kono
parents:
diff changeset
165 -- type has fewer than 2**(Character'Size) elements, then the size
kono
parents:
diff changeset
166 -- used is Character'Size, otherwise Integer'Size is used.
kono
parents:
diff changeset
167
kono
parents:
diff changeset
168 -- Similarly, the size of fixed-point types depends on the size of the
kono
parents:
diff changeset
169 -- corresponding integer type, which is the smallest predefined integer
kono
parents:
diff changeset
170 -- type capable of representing the required range of values.
kono
parents:
diff changeset
171
kono
parents:
diff changeset
172 -------------------------------------------------
kono
parents:
diff changeset
173 -- Target-Dependent Values for Types in System --
kono
parents:
diff changeset
174 -------------------------------------------------
kono
parents:
diff changeset
175
kono
parents:
diff changeset
176 System_Address_Size : constant Pos := Set_Targ.Pointer_Size;
kono
parents:
diff changeset
177 -- System.Address'Size (also size of all thin pointers)
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 System_Max_Binary_Modulus_Power : constant Pos :=
kono
parents:
diff changeset
180 Standard_Long_Long_Integer_Size;
kono
parents:
diff changeset
181
kono
parents:
diff changeset
182 System_Max_Nonbinary_Modulus_Power : constant Pos := Standard_Integer_Size;
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 System_Storage_Unit : constant Pos := Set_Targ.Bits_Per_Unit;
kono
parents:
diff changeset
185 System_Word_Size : constant Pos := Set_Targ.Bits_Per_Word;
kono
parents:
diff changeset
186
kono
parents:
diff changeset
187 System_Tick_Nanoseconds : constant Pos := 1_000_000_000;
kono
parents:
diff changeset
188 -- Value of System.Tick in nanoseconds. At the moment, this is a fixed
kono
parents:
diff changeset
189 -- constant (with value of 1.0 seconds), but later we should add this
kono
parents:
diff changeset
190 -- value to the GCC configuration file so that its value can be made
kono
parents:
diff changeset
191 -- configuration dependent.
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 -----------------------------------------------------
kono
parents:
diff changeset
194 -- Target-Dependent Values for Types in Interfaces --
kono
parents:
diff changeset
195 -----------------------------------------------------
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 Interfaces_Wchar_T_Size : constant Pos := Set_Targ.Wchar_T_Size;
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 ----------------------------------------
kono
parents:
diff changeset
200 -- Other Target-Dependent Definitions --
kono
parents:
diff changeset
201 ----------------------------------------
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 Maximum_Alignment : constant Pos := Set_Targ.Maximum_Alignment;
kono
parents:
diff changeset
204 -- The maximum alignment, in storage units, that an object or type may
kono
parents:
diff changeset
205 -- require on the target machine.
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 System_Allocator_Alignment : constant Pos :=
kono
parents:
diff changeset
208 Set_Targ.System_Allocator_Alignment;
kono
parents:
diff changeset
209 -- The alignment in storage units of addresses returned by malloc
kono
parents:
diff changeset
210
kono
parents:
diff changeset
211 Max_Unaligned_Field : constant Pos := Set_Targ.Max_Unaligned_Field;
kono
parents:
diff changeset
212 -- The maximum supported size in bits for a field that is not aligned
kono
parents:
diff changeset
213 -- on a storage unit boundary.
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 Bytes_Big_Endian : Boolean := Set_Targ.Bytes_BE /= 0;
kono
parents:
diff changeset
216 -- Important note: for Ada purposes, the important setting is the bytes
kono
parents:
diff changeset
217 -- endianness (Bytes_Big_Endian), not the bits value (Bits_Big_Endian).
kono
parents:
diff changeset
218 -- This is because Ada bit addressing must be compatible with the byte
kono
parents:
diff changeset
219 -- ordering (otherwise we would end up with non-contiguous fields). It
kono
parents:
diff changeset
220 -- is rare for the two to be different, but if they are, Bits_Big_Endian
kono
parents:
diff changeset
221 -- is relevant only for the generation of instructions with bit numbers,
kono
parents:
diff changeset
222 -- and thus relevant only to the back end. Note that this is a variable
kono
parents:
diff changeset
223 -- rather than a constant, since it can be modified (flipped) by -gnatd8.
kono
parents:
diff changeset
224
kono
parents:
diff changeset
225 Target_Short_Enums : constant Boolean := Set_Targ.Short_Enums /= 0;
kono
parents:
diff changeset
226 -- True if we are in short enums mode, where foreign convention
kono
parents:
diff changeset
227 -- (in particular C and C++) enumeration types will be sized as in Ada,
kono
parents:
diff changeset
228 -- using the shortest possibility from 8,16,32 bits, signed or unsigned.
kono
parents:
diff changeset
229 -- A zero value means Short_Enums are not in use, and in this case all
kono
parents:
diff changeset
230 -- foreign convention enumeration types are given the same size as c int.
kono
parents:
diff changeset
231
kono
parents:
diff changeset
232 Target_Strict_Alignment : Boolean :=
kono
parents:
diff changeset
233 Set_Targ.Strict_Alignment /= 0;
kono
parents:
diff changeset
234 -- True if instructions will fail if data is misaligned. Note that this
kono
parents:
diff changeset
235 -- is a variable rather than a constant since it can be modified (set to
kono
parents:
diff changeset
236 -- True) if the debug flag -gnatd.A is used.
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 Target_Double_Float_Alignment : constant Nat :=
kono
parents:
diff changeset
239 Set_Targ.Double_Float_Alignment;
kono
parents:
diff changeset
240 -- The default alignment of "double" floating-point types, i.e. floating
kono
parents:
diff changeset
241 -- point types whose size is equal to 64 bits, or 0 if this alignment is
kono
parents:
diff changeset
242 -- not lower than the largest power of 2 multiple of System.Storage_Unit
kono
parents:
diff changeset
243 -- that does not exceed either the object size of the type or the maximum
kono
parents:
diff changeset
244 -- allowed alignment.
kono
parents:
diff changeset
245
kono
parents:
diff changeset
246 Target_Double_Scalar_Alignment : constant Nat :=
kono
parents:
diff changeset
247 Set_Targ.Double_Scalar_Alignment;
kono
parents:
diff changeset
248 -- The default alignment of "double" or larger scalar types, i.e. scalar
kono
parents:
diff changeset
249 -- types whose size is greater or equal to 64 bits, or 0 if this alignment
kono
parents:
diff changeset
250 -- is not lower than the largest power of 2 multiple of System.Storage_Unit
kono
parents:
diff changeset
251 -- that does not exceed either the object size of the type or the maximum
kono
parents:
diff changeset
252 -- allowed alignment.
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 end Ttypes;