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