2018-12-06 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / ada / set_targ.ads
bloba395388cc9259cd9aa7b033e401a9ebe556d2cbb
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S E T _ T A R G --
6 -- --
7 -- S p e c --
8 -- --
9 -- Copyright (C) 2013-2018, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING3. If not, go to --
19 -- http://www.gnu.org/licenses for a complete copy of the license. --
20 -- --
21 -- GNAT was originally developed by the GNAT team at New York University. --
22 -- Extensive contributions were provided by Ada Core Technologies Inc. --
23 -- --
24 ------------------------------------------------------------------------------
26 -- This package handles setting target dependent parameters. If the -gnatet
27 -- switch is not set, then these values are taken from the back end (via the
28 -- routines in Get_Targ, and the enumerate_modes routine in misc.c). If the
29 -- switch is set, then the values are read from the target.atp file in the
30 -- current directory (usually written with the Write_Target_Dependent_Values
31 -- procedure defined in this package).
33 -- Note that all these values return sizes of C types with corresponding
34 -- names. This allows GNAT to define the corresponding Ada types to have
35 -- the same representation. There is one exception: the representation
36 -- of Wide_Character_Type uses twice the size of a C char, instead of the
37 -- size of wchar_t, since this corresponds to expected Ada usage.
39 with Einfo; use Einfo;
40 with Stand; use Stand;
41 with Types; use Types;
43 package Set_Targ is
45 -----------------------------
46 -- Target-Dependent Values --
47 -----------------------------
49 -- The following is a table of target dependent values. In normal operation
50 -- these values are set by calling the appropriate C backend routines that
51 -- interface to back end routines that determine target characteristics.
53 -- If the -gnateT switch is used, then any values that are read from the
54 -- file target.atp in the current directory overwrite values set from the
55 -- back end. This is used by tools other than the compiler, e.g. to do
56 -- semantic analysis of programs that will run on some other target than
57 -- the machine on which the tool is run.
59 -- Note: fields marked with a question mark are boolean fields, where a
60 -- value of 0 is False, and a value of 1 is True.
62 Bits_BE : Nat; -- Bits stored big-endian?
63 Bits_Per_Unit : Pos; -- Bits in a storage unit
64 Bits_Per_Word : Pos; -- Bits in a word
65 Bytes_BE : Nat; -- Bytes stored big-endian?
66 Char_Size : Pos; -- Standard.Character'Size
67 Double_Float_Alignment : Nat; -- Alignment of double float
68 Double_Scalar_Alignment : Nat; -- Alignment of double length scalar
69 Double_Size : Pos; -- Standard.Long_Float'Size
70 Float_Size : Pos; -- Standard.Float'Size
71 Float_Words_BE : Nat; -- Float words stored big-endian?
72 Int_Size : Pos; -- Standard.Integer'Size
73 Long_Double_Size : Pos; -- Standard.Long_Long_Float'Size
74 Long_Long_Size : Pos; -- Standard.Long_Long_Integer'Size
75 Long_Size : Pos; -- Standard.Long_Integer'Size
76 Maximum_Alignment : Pos; -- Maximum permitted alignment
77 Max_Unaligned_Field : Pos; -- Maximum size for unaligned bit field
78 Pointer_Size : Pos; -- System.Address'Size
79 Short_Enums : Nat; -- Foreign enums use short size?
80 Short_Size : Pos; -- Standard.Short_Integer'Size
81 Strict_Alignment : Nat; -- Strict alignment?
82 System_Allocator_Alignment : Nat; -- Alignment for malloc calls
83 Wchar_T_Size : Pos; -- Interfaces.C.wchar_t'Size
84 Words_BE : Nat; -- Words stored big-endian?
86 -------------------------------------
87 -- Registered Floating-Point Types --
88 -------------------------------------
90 -- This table contains the list of modes supported by the back-end as
91 -- provided by the back end routine enumerate_modes in misc.c. Note that
92 -- we only store floating-point modes (see Register_Float_Type).
94 type FPT_Mode_Entry is record
95 NAME : String_Ptr; -- Name of mode (no null character at end)
96 DIGS : Natural; -- Digits for floating-point type
97 FLOAT_REP : Float_Rep_Kind; -- Float representation
98 PRECISION : Natural; -- Precision in bits
99 SIZE : Natural; -- Size in bits
100 ALIGNMENT : Natural; -- Alignment in bits
101 end record;
103 FPT_Mode_Table : array (1 .. 1000) of FPT_Mode_Entry;
104 Num_FPT_Modes : Natural := 0;
105 -- Table containing the supported modes and number of entries
107 -----------------
108 -- Subprograms --
109 -----------------
111 subtype S_Float_Types is
112 Standard_Entity_Type range S_Short_Float .. S_Long_Long_Float;
114 function C_Type_For (T : S_Float_Types) return String;
115 -- Return the name of a C type supported by the back-end and suitable as
116 -- a basis to construct the standard Ada floating point type identified by
117 -- T. This is used as a common ground to feed both ttypes values and the
118 -- GNAT tree nodes for the standard floating point types.
120 procedure Write_Target_Dependent_Values;
121 -- This routine writes the file target.atp in the current directory with
122 -- the values of the global target parameters as listed above, and as set
123 -- by prior calls to Initialize/Read_Target_Dependent_Values. The format
124 -- of the target.atp file is as follows
126 -- First come the values of the variables defined in this spec:
128 -- One line per value
130 -- name value
132 -- where name is the name of the parameter, spelled out in full,
133 -- and cased as in the above list, and value is an unsigned decimal
134 -- integer. Two or more blanks separates the name from the value.
136 -- All the variables must be present, in alphabetical order (i.e. the
137 -- same order as the declarations in this spec).
139 -- Then there is a blank line to separate the two parts of the file. Then
140 -- come the lines showing the floating-point types to be registered.
142 -- One line per registered mode
144 -- name digs float_rep precision alignment
146 -- where name is the string name of the type (which can have single
147 -- spaces embedded in the name (e.g. long double). The name is followed
148 -- by at least two blanks. The following fields are as described above
149 -- for a Mode_Entry (where float_rep is I/V/A for IEEE-754-Binary,
150 -- Vax_Native, AAMP), fields are separated by at least one blank, and
151 -- a LF character immediately follows the alignment field.
153 -- ??? We do not write the size for backward compatibility reasons,
154 -- which means that target.atp will not be a complete description for
155 -- the very peculiar cases where the size cannot be computed from the
156 -- precision and the alignment by the formula:
158 -- size := (precision + alignment - 1) / alignment * alignment
160 end Set_Targ;