annotate gcc/ada/set_targ.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
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 -- S E T _ T A R G --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2013-2018, 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 handles setting target dependent parameters. If the -gnatet
kono
parents:
diff changeset
27 -- switch is not set, then these values are taken from the back end (via the
kono
parents:
diff changeset
28 -- routines in Get_Targ, and the enumerate_modes routine in misc.c). If the
kono
parents:
diff changeset
29 -- switch is set, then the values are read from the target.atp file in the
kono
parents:
diff changeset
30 -- current directory (usually written with the Write_Target_Dependent_Values
kono
parents:
diff changeset
31 -- procedure defined in this package).
kono
parents:
diff changeset
32
kono
parents:
diff changeset
33 -- Note that all these values return sizes of C types with corresponding
kono
parents:
diff changeset
34 -- names. This allows GNAT to define the corresponding Ada types to have
kono
parents:
diff changeset
35 -- the same representation. There is one exception: the representation
kono
parents:
diff changeset
36 -- of Wide_Character_Type uses twice the size of a C char, instead of the
kono
parents:
diff changeset
37 -- size of wchar_t, since this corresponds to expected Ada usage.
kono
parents:
diff changeset
38
kono
parents:
diff changeset
39 with Einfo; use Einfo;
kono
parents:
diff changeset
40 with Stand; use Stand;
kono
parents:
diff changeset
41 with Types; use Types;
kono
parents:
diff changeset
42
kono
parents:
diff changeset
43 package Set_Targ is
kono
parents:
diff changeset
44
kono
parents:
diff changeset
45 -----------------------------
kono
parents:
diff changeset
46 -- Target-Dependent Values --
kono
parents:
diff changeset
47 -----------------------------
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 -- The following is a table of target dependent values. In normal operation
kono
parents:
diff changeset
50 -- these values are set by calling the appropriate C backend routines that
kono
parents:
diff changeset
51 -- interface to back end routines that determine target characteristics.
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 -- If the -gnateT switch is used, then any values that are read from the
kono
parents:
diff changeset
54 -- file target.atp in the current directory overwrite values set from the
kono
parents:
diff changeset
55 -- back end. This is used by tools other than the compiler, e.g. to do
kono
parents:
diff changeset
56 -- semantic analysis of programs that will run on some other target than
kono
parents:
diff changeset
57 -- the machine on which the tool is run.
kono
parents:
diff changeset
58
kono
parents:
diff changeset
59 -- Note: fields marked with a question mark are boolean fields, where a
kono
parents:
diff changeset
60 -- value of 0 is False, and a value of 1 is True.
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 Bits_BE : Nat; -- Bits stored big-endian?
kono
parents:
diff changeset
63 Bits_Per_Unit : Pos; -- Bits in a storage unit
kono
parents:
diff changeset
64 Bits_Per_Word : Pos; -- Bits in a word
kono
parents:
diff changeset
65 Bytes_BE : Nat; -- Bytes stored big-endian?
kono
parents:
diff changeset
66 Char_Size : Pos; -- Standard.Character'Size
kono
parents:
diff changeset
67 Double_Float_Alignment : Nat; -- Alignment of double float
kono
parents:
diff changeset
68 Double_Scalar_Alignment : Nat; -- Alignment of double length scalar
kono
parents:
diff changeset
69 Double_Size : Pos; -- Standard.Long_Float'Size
kono
parents:
diff changeset
70 Float_Size : Pos; -- Standard.Float'Size
kono
parents:
diff changeset
71 Float_Words_BE : Nat; -- Float words stored big-endian?
kono
parents:
diff changeset
72 Int_Size : Pos; -- Standard.Integer'Size
kono
parents:
diff changeset
73 Long_Double_Size : Pos; -- Standard.Long_Long_Float'Size
kono
parents:
diff changeset
74 Long_Long_Size : Pos; -- Standard.Long_Long_Integer'Size
kono
parents:
diff changeset
75 Long_Size : Pos; -- Standard.Long_Integer'Size
kono
parents:
diff changeset
76 Maximum_Alignment : Pos; -- Maximum permitted alignment
kono
parents:
diff changeset
77 Max_Unaligned_Field : Pos; -- Maximum size for unaligned bit field
kono
parents:
diff changeset
78 Pointer_Size : Pos; -- System.Address'Size
kono
parents:
diff changeset
79 Short_Enums : Nat; -- Foreign enums use short size?
kono
parents:
diff changeset
80 Short_Size : Pos; -- Standard.Short_Integer'Size
kono
parents:
diff changeset
81 Strict_Alignment : Nat; -- Strict alignment?
kono
parents:
diff changeset
82 System_Allocator_Alignment : Nat; -- Alignment for malloc calls
kono
parents:
diff changeset
83 Wchar_T_Size : Pos; -- Interfaces.C.wchar_t'Size
kono
parents:
diff changeset
84 Words_BE : Nat; -- Words stored big-endian?
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 -------------------------------------
kono
parents:
diff changeset
87 -- Registered Floating-Point Types --
kono
parents:
diff changeset
88 -------------------------------------
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 -- This table contains the list of modes supported by the back-end as
kono
parents:
diff changeset
91 -- provided by the back end routine enumerate_modes in misc.c. Note that
kono
parents:
diff changeset
92 -- we only store floating-point modes (see Register_Float_Type).
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 type FPT_Mode_Entry is record
kono
parents:
diff changeset
95 NAME : String_Ptr; -- Name of mode (no null character at end)
kono
parents:
diff changeset
96 DIGS : Natural; -- Digits for floating-point type
kono
parents:
diff changeset
97 FLOAT_REP : Float_Rep_Kind; -- Float representation
kono
parents:
diff changeset
98 PRECISION : Natural; -- Precision in bits
kono
parents:
diff changeset
99 SIZE : Natural; -- Size in bits
kono
parents:
diff changeset
100 ALIGNMENT : Natural; -- Alignment in bits
kono
parents:
diff changeset
101 end record;
kono
parents:
diff changeset
102
kono
parents:
diff changeset
103 FPT_Mode_Table : array (1 .. 1000) of FPT_Mode_Entry;
kono
parents:
diff changeset
104 Num_FPT_Modes : Natural := 0;
kono
parents:
diff changeset
105 -- Table containing the supported modes and number of entries
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 -----------------
kono
parents:
diff changeset
108 -- Subprograms --
kono
parents:
diff changeset
109 -----------------
kono
parents:
diff changeset
110
kono
parents:
diff changeset
111 subtype S_Float_Types is
kono
parents:
diff changeset
112 Standard_Entity_Type range S_Short_Float .. S_Long_Long_Float;
kono
parents:
diff changeset
113
kono
parents:
diff changeset
114 function C_Type_For (T : S_Float_Types) return String;
kono
parents:
diff changeset
115 -- Return the name of a C type supported by the back-end and suitable as
kono
parents:
diff changeset
116 -- a basis to construct the standard Ada floating point type identified by
kono
parents:
diff changeset
117 -- T. This is used as a common ground to feed both ttypes values and the
kono
parents:
diff changeset
118 -- GNAT tree nodes for the standard floating point types.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 procedure Write_Target_Dependent_Values;
kono
parents:
diff changeset
121 -- This routine writes the file target.atp in the current directory with
kono
parents:
diff changeset
122 -- the values of the global target parameters as listed above, and as set
kono
parents:
diff changeset
123 -- by prior calls to Initialize/Read_Target_Dependent_Values. The format
kono
parents:
diff changeset
124 -- of the target.atp file is as follows
kono
parents:
diff changeset
125 --
kono
parents:
diff changeset
126 -- First come the values of the variables defined in this spec:
kono
parents:
diff changeset
127 --
kono
parents:
diff changeset
128 -- One line per value
kono
parents:
diff changeset
129 --
kono
parents:
diff changeset
130 -- name value
kono
parents:
diff changeset
131 --
kono
parents:
diff changeset
132 -- where name is the name of the parameter, spelled out in full,
kono
parents:
diff changeset
133 -- and cased as in the above list, and value is an unsigned decimal
kono
parents:
diff changeset
134 -- integer. Two or more blanks separates the name from the value.
kono
parents:
diff changeset
135 --
kono
parents:
diff changeset
136 -- All the variables must be present, in alphabetical order (i.e. the
kono
parents:
diff changeset
137 -- same order as the declarations in this spec).
kono
parents:
diff changeset
138 --
kono
parents:
diff changeset
139 -- Then there is a blank line to separate the two parts of the file. Then
kono
parents:
diff changeset
140 -- come the lines showing the floating-point types to be registered.
kono
parents:
diff changeset
141 --
kono
parents:
diff changeset
142 -- One line per registered mode
kono
parents:
diff changeset
143 --
kono
parents:
diff changeset
144 -- name digs float_rep precision alignment
kono
parents:
diff changeset
145 --
kono
parents:
diff changeset
146 -- where name is the string name of the type (which can have single
kono
parents:
diff changeset
147 -- spaces embedded in the name (e.g. long double). The name is followed
kono
parents:
diff changeset
148 -- by at least two blanks. The following fields are as described above
kono
parents:
diff changeset
149 -- for a Mode_Entry (where float_rep is I/V/A for IEEE-754-Binary,
kono
parents:
diff changeset
150 -- Vax_Native, AAMP), fields are separated by at least one blank, and
kono
parents:
diff changeset
151 -- a LF character immediately follows the alignment field.
kono
parents:
diff changeset
152 --
kono
parents:
diff changeset
153 -- ??? We do not write the size for backward compatibility reasons,
kono
parents:
diff changeset
154 -- which means that target.atp will not be a complete description for
kono
parents:
diff changeset
155 -- the very peculiar cases where the size cannot be computed from the
kono
parents:
diff changeset
156 -- precision and the alignment by the formula:
kono
parents:
diff changeset
157 --
kono
parents:
diff changeset
158 -- size := (precision + alignment - 1) / alignment * alignment
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 end Set_Targ;