aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.2.1/gcc/ada/ttypes.ads
blob: 4eb8c82ba6f574c2ca4d5abd34976a4071b6b931 (plain)
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
------------------------------------------------------------------------------
--                                                                          --
--                         GNAT COMPILER COMPONENTS                         --
--                                                                          --
--                               T T Y P E S                                --
--                                                                          --
--                                 S p e c                                  --
--                                                                          --
--          Copyright (C) 1992-2005, 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 2,  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 COPYING.  If not, write --
-- to  the  Free Software Foundation,  51  Franklin  Street,  Fifth  Floor, --
-- Boston, MA 02110-1301, USA.                                              --
--                                                                          --
-- 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 Get_Targ; use Get_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 and its companion Ttypef provide 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 and Ttypef 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, the required constant values are obtained by
   --  referencing appropriate attributes. Ada 95 already defines most of
   --  the required attributes, and GNAT specific attributes have been
   --  defined to cover the remaining cases (such as Storage_Unit). The
   --  evaluation of these attributes obtains the required target dependent
   --  values from Ttypes and Ttypef. The additional attributes that have
   --  been added to GNAT (Address_Size, Storage_Unit, Word_Size, Max_Priority,
   --  and Max_Interrupt_Priority) are for almost all purposes 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. The critical use of the attribute is in writing the System
   --  declaration of Address_Size which of course cannot refer to itself. By
   --  this means we achieve complete target independence in the source code
   --  of package System, i.e. there is only one copy of the source of System
   --  for all targets.

   --  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 := Get_Char_Size;
   Standard_Short_Short_Integer_Width  : constant Pos :=
                           Width_From_Size (Standard_Short_Short_Integer_Size);

   Standard_Short_Integer_Size         : constant Pos := Get_Short_Size;
   Standard_Short_Integer_Width        : constant Pos :=
                           Width_From_Size (Standard_Short_Integer_Size);

   Standard_Integer_Size               : constant Pos := Get_Int_Size;
   Standard_Integer_Width              : constant Pos :=
                           Width_From_Size (Standard_Integer_Size);

   Standard_Long_Integer_Size          : constant Pos := Get_Long_Size;
   Standard_Long_Integer_Width         : constant Pos :=
                           Width_From_Size (Standard_Long_Integer_Size);

   Standard_Long_Long_Integer_Size     : constant Pos := Get_Long_Long_Size;
   Standard_Long_Long_Integer_Width    : constant Pos :=
                           Width_From_Size (Standard_Long_Long_Integer_Size);

   Standard_Short_Float_Size           : constant Pos := Get_Float_Size;
   Standard_Short_Float_Digits         : constant Pos :=
                           Digits_From_Size (Standard_Short_Float_Size);

   Standard_Float_Size                 : constant Pos := Get_Float_Size;
   Standard_Float_Digits               : constant Pos :=
                           Digits_From_Size (Standard_Float_Size);

   Standard_Long_Float_Size            : constant Pos := Get_Double_Size;
   Standard_Long_Float_Digits          : constant Pos :=
                           Digits_From_Size (Standard_Long_Float_Size);

   Standard_Long_Long_Float_Size       : constant Pos := Get_Long_Double_Size;
   Standard_Long_Long_Float_Digits     : constant Pos :=
                           Digits_From_Size (Standard_Long_Long_Float_Size);

   Standard_Character_Size             : constant Pos := Get_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 := Get_Pointer_Size;
   --  System.Address'Size (also size of all thin pointers)

   System_Max_Binary_Modulus_Power    : constant Pos :=
                                          Standard_Long_Long_Integer_Size;

   System_Max_Nonbinary_Modulus_Power : constant Pos :=
                                          Standard_Integer_Size - 1;

   System_Storage_Unit : constant Pos := Get_Bits_Per_Unit;
   System_Word_Size    : constant Pos := Get_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 := Get_Wchar_T_Size;

   ----------------------------------------
   -- Other Target-Dependent Definitions --
   ----------------------------------------

   Maximum_Alignment : constant Pos := Get_Maximum_Alignment;
   --  The maximum alignment, in storage units, that an object or
   --  type may require on the target machine.

   Max_Unaligned_Field : constant Pos := Get_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 := Get_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_Strict_Alignment : Boolean := Get_Strict_Alignment /= 0;
   --  True if instructions will fail if data is misaligned

end Ttypes;