OSDN Git Service

* 41intnam.ads, 42intnam.ads, 4aintnam.ads, 4cintnam.ads,
[pf3gnuchains/gcc-fork.git] / gcc / ada / ttypes.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT COMPILER COMPONENTS                         --
4 --                                                                          --
5 --                               T T Y P E S                                --
6 --                                                                          --
7 --                                 S p e c                                  --
8 --                                                                          --
9 --                             $Revision$
10 --                                                                          --
11 --          Copyright (C) 1992-2002 Free Software Foundation, Inc.          --
12 --                                                                          --
13 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNAT;  see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- GNAT was originally developed  by the GNAT team at  New York University. --
25 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
26 --                                                                          --
27 ------------------------------------------------------------------------------
28
29 --  This package contains constants describing target properties
30
31 with Types;    use Types;
32 with Get_Targ; use Get_Targ;
33
34 package Ttypes is
35
36    ------------------------------
37    -- Host/Target Dependencies --
38    ------------------------------
39
40    --  It is vital to maintain a clear distinction between properties of
41    --  types on the host and types on the target, since in the general
42    --  case of a cross-compiler these will be different.
43
44    --  This package and its companion Ttypef provide definitions of values
45    --  that describe the properties of the target types. All instances of
46    --  target dependencies, including the definitions of such packages as
47    --  Standard and System depend directly or indirectly on the definitions
48    --  in the Ttypes and Ttypef packages.
49
50    --  In the source of the compiler, references to attributes such as
51    --  Integer'Size will give information regarding the host types (i.e.
52    --  the types within the compiler itself). Such references are therefore
53    --  almost always suspicious (it is hard for example to see that the
54    --  code in the compiler should even be using type Integer very much,
55    --  and certainly this code should not depend on the size of Integer).
56
57    --  On the other hand, it is perfectly reasonable for the compiler to
58    --  require access to the size of type Integer for the target machine,
59    --  e.g. in constructing the internal representation of package Standard.
60    --  For this purpose, instead of referencing the attribute Integer'Size,
61    --  a reference to Ttypes.Standard_Integer_Size will provide the needed
62    --  value for the target type.
63
64    --  Two approaches are used for handling target dependent values in the
65    --  standard library packages. Package Standard is handled specially,
66    --  being constructed internally (by package Stand). Target dependent
67    --  values needed in Stand are obtained by direct reference to Ttypes
68    --  and Ttypef.
69
70    --  For package System, the required constant values are obtained by
71    --  referencing appropriate attributes. Ada 95 already defines most of
72    --  the required attributes, and GNAT specific attributes have been
73    --  defined to cover the remaining cases (such as Storage_Unit). The
74    --  evaluation of these attributes obtains the required target dependent
75    --  values from Ttypes and Ttypef. The additional attributes that have
76    --  been added to GNAT (Address_Size, Storage_Unit, Word_Size, Max_Priority,
77    --  and Max_Interrupt_Priority) are for almost all purposes redundant with
78    --  respect to the corresponding references to System constants. For example
79    --  in a program, System.Address_Size and Standard'Address_Size yield the
80    --  same value. The critical use of the attribute is in writing the System
81    --  declaration of Address_Size which of course cannot refer to itself. By
82    --  this means we achieve complete target independence in the source code
83    --  of package System, i.e. there is only one copy of the source of System
84    --  for all targets.
85
86    --  Note that during compilation there are two versions of package System
87    --  around. The version that is directly WITH'ed by compiler packages
88    --  contains host-dependent definitions, which is what is needed in that
89    --  case (for example, System.Storage_Unit referenced in the source of the
90    --  compiler refers to the storage unit of the host, not the target. This
91    --  means that, like attribute references, any references to constants in
92    --  package System in the compiler code are suspicious, since it is strange
93    --  for the compiler to have such host dependencies. If the compiler needs
94    --  to access the target dependent values of such quantities as Storage_Unit
95    --  then it should reference the constants in this package (Ttypes), rather
96    --  than referencing System.Storage_Unit, or Standard'Storage_Unit, both of
97    --  which would yield the host value.
98
99    ---------------------------------------------------
100    -- Target-Dependent Values for Types in Standard --
101    ---------------------------------------------------
102
103    --  Note: GNAT always supplies all the following integer and float types,
104    --  but depending on the machine, some of the types may be identical. For
105    --  example, on some machines, Short_Float may be the same as Float, and
106    --  Long_Long_Float may be the same as Long_Float.
107
108    Standard_Short_Short_Integer_Size   : constant Pos := Get_Char_Size;
109    Standard_Short_Short_Integer_Width  : constant Pos :=
110                            Width_From_Size (Standard_Short_Short_Integer_Size);
111
112    Standard_Short_Integer_Size         : constant Pos := Get_Short_Size;
113    Standard_Short_Integer_Width        : constant Pos :=
114                            Width_From_Size (Standard_Short_Integer_Size);
115
116    Standard_Integer_Size               : constant Pos := Get_Int_Size;
117    Standard_Integer_Width              : constant Pos :=
118                            Width_From_Size (Standard_Integer_Size);
119
120    Standard_Long_Integer_Size          : constant Pos := Get_Long_Size;
121    Standard_Long_Integer_Width         : constant Pos :=
122                            Width_From_Size (Standard_Long_Integer_Size);
123
124    Standard_Long_Long_Integer_Size     : constant Pos := Get_Long_Long_Size;
125    Standard_Long_Long_Integer_Width    : constant Pos :=
126                            Width_From_Size (Standard_Long_Long_Integer_Size);
127
128    Standard_Short_Float_Size           : constant Pos := Get_Float_Size;
129    Standard_Short_Float_Digits         : constant Pos :=
130                            Digits_From_Size (Standard_Short_Float_Size);
131
132    Standard_Float_Size                 : constant Pos := Get_Float_Size;
133    Standard_Float_Digits               : constant Pos :=
134                            Digits_From_Size (Standard_Float_Size);
135
136    Standard_Long_Float_Size            : constant Pos := Get_Double_Size;
137    Standard_Long_Float_Digits          : constant Pos :=
138                            Digits_From_Size (Standard_Long_Float_Size);
139
140    Standard_Long_Long_Float_Size       : constant Pos := Get_Long_Double_Size;
141    Standard_Long_Long_Float_Digits     : constant Pos :=
142                            Digits_From_Size (Standard_Long_Long_Float_Size);
143
144    Standard_Character_Size             : constant Pos := Get_Char_Size;
145
146    Standard_Wide_Character_Size        : constant Pos := 16;
147    --  The Standard.Wide_Character type is special in the sense that
148    --  it is not defined in terms of its corresponding C type (wchar_t).
149    --  Unfortunately this makes the representation of Wide_Character
150    --  incompatible with the C wchar_t type.
151    --  ??? This is required by the RM or backward compatibility
152
153    --  Note: there is no specific control over the representation of
154    --  enumeration types. The convention used is that if an enumeration
155    --  type has fewer than 2**(Character'Size) elements, then the size
156    --  used is Character'Size, otherwise Integer'Size is used.
157
158    --  Similarly, the size of fixed-point types depends on the size of the
159    --  corresponding integer type, which is the smallest predefined integer
160    --  type capable of representing the required range of values.
161
162    -------------------------------------------------
163    -- Target-Dependent Values for Types in System --
164    -------------------------------------------------
165
166    System_Address_Size : constant Pos := Get_Pointer_Size;
167    --  System.Address'Size (also size of all thin pointers)
168
169    System_Max_Binary_Modulus_Power    : constant Pos :=
170                                           Standard_Long_Long_Integer_Size;
171
172    System_Max_Nonbinary_Modulus_Power : constant Pos :=
173                                           Standard_Integer_Size - 1;
174
175    System_Storage_Unit : constant Pos := Get_Bits_Per_Unit;
176    System_Word_Size    : constant Pos := Get_Bits_Per_Word;
177
178    System_Tick_Nanoseconds : constant Pos := 1_000_000_000;
179    --  Value of System.Tick in nanoseconds. At the moment, this is a fixed
180    --  constant (with value of 1.0 seconds), but later we should add this
181    --  value to the GCC configuration file so that its value can be made
182    --  configuration dependent.
183
184    -----------------------------------------------------
185    -- Target-Dependent Values for Types in Interfaces --
186    -----------------------------------------------------
187
188    Interfaces_Wchar_T_Size : constant Pos := Get_Wchar_T_Size;
189
190    ----------------------------------------
191    -- Other Target-Dependent Definitions --
192    ----------------------------------------
193
194    Maximum_Alignment : constant Pos := Get_Maximum_Alignment;
195    --  The maximum alignment, in storage units, that an object or
196    --  type may require on the target machine.
197
198    Bytes_Big_Endian : Boolean := Get_Bytes_BE /= 0;
199    --  Important note: for Ada purposes, the important setting is the bytes
200    --  endianness (Bytes_Big_Endian), not the bits value (Bits_Big_Endian).
201    --  This is because Ada bit addressing must be compatible with the byte
202    --  ordering (otherwise we would end up with non-contiguous fields). It
203    --  is rare for the two to be different, but if they are, Bits_Big_Endian
204    --  is relevant only for the generation of instructions with bit numbers,
205    --  and thus relevant only to the back end. Note that this is a variable
206    --  rather than a constant, since it can be modified (flipped) by -gnatd8.
207
208    Target_Strict_Alignment : Boolean := Get_Strict_Alignment /= 0;
209    --  True if instructions will fail if data is misaligned
210
211 end Ttypes;