]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/ada/gcc-interface/targtyps.c
tree-core.h: Include symtab.h.
[thirdparty/gcc.git] / gcc / ada / gcc-interface / targtyps.c
1 /****************************************************************************
2 * *
3 * GNAT COMPILER COMPONENTS *
4 * *
5 * T A R G T Y P S *
6 * *
7 * Body *
8 * *
9 * Copyright (C) 1992-2015, 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 see *
19 * <http://www.gnu.org/licenses/>. *
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 ****************************************************************************/
25
26 /* Functions for retrieving target types. See Ada package Get_Targ. */
27
28 #include "config.h"
29 #include "system.h"
30 #include "coretypes.h"
31 #include "vec.h"
32 #include "alias.h"
33 #include "tree.h"
34 #include "inchash.h"
35 #include "options.h"
36 #include "tm.h"
37 #include "tm_p.h"
38
39 #include "ada.h"
40 #include "types.h"
41 #include "atree.h"
42 #include "elists.h"
43 #include "namet.h"
44 #include "nlists.h"
45 #include "snames.h"
46 #include "stringt.h"
47 #include "uintp.h"
48 #include "urealp.h"
49 #include "fe.h"
50 #include "sinfo.h"
51 #include "einfo.h"
52 #include "ada-tree.h"
53 #include "gigi.h"
54
55 /* If we don't have a specific size for Ada's equivalent of `long', use that
56 of C. */
57 #ifndef ADA_LONG_TYPE_SIZE
58 #define ADA_LONG_TYPE_SIZE LONG_TYPE_SIZE
59 #endif
60
61 /* The following provide a functional interface for the front end Ada code
62 to determine the sizes that are used for various C types. */
63
64 Pos
65 get_target_bits_per_unit (void)
66 {
67 return BITS_PER_UNIT;
68 }
69
70 Pos
71 get_target_bits_per_word (void)
72 {
73 return BITS_PER_WORD;
74 }
75
76 Pos
77 get_target_char_size (void)
78 {
79 return CHAR_TYPE_SIZE;
80 }
81
82 Pos
83 get_target_wchar_t_size (void)
84 {
85 /* We never want wide characters less than "short" in Ada. */
86 return MAX (SHORT_TYPE_SIZE, WCHAR_TYPE_SIZE);
87 }
88
89 Pos
90 get_target_short_size (void)
91 {
92 return SHORT_TYPE_SIZE;
93 }
94
95 Pos
96 get_target_int_size (void)
97 {
98 return INT_TYPE_SIZE;
99 }
100
101 Pos
102 get_target_long_size (void)
103 {
104 return ADA_LONG_TYPE_SIZE;
105 }
106
107 Pos
108 get_target_long_long_size (void)
109 {
110 return LONG_LONG_TYPE_SIZE;
111 }
112
113 Pos
114 get_target_pointer_size (void)
115 {
116 return POINTER_SIZE;
117 }
118
119 /* Alignment related values, mapped to attributes for functional and
120 documentation purposes. */
121
122 /* Standard'Maximum_Default_Alignment. Maximum alignment that the compiler
123 might choose by default for a type or object.
124
125 Stricter alignment requests trigger gigi's aligning_type circuitry for
126 stack objects or objects allocated by the default allocator. */
127
128 Pos
129 get_target_maximum_default_alignment (void)
130 {
131 return BIGGEST_ALIGNMENT / BITS_PER_UNIT;
132 }
133
134 /* Standard'System_Allocator_Alignment. Alignment guaranteed to be honored
135 by the default allocator (System.Memory.Alloc or malloc if we have no
136 run-time library at hand).
137
138 Stricter alignment requests trigger gigi's aligning_type circuitry for
139 objects allocated by the default allocator. */
140
141 /* ??? Need a way to get info about __gnat_malloc from here (whether it is
142 handy and what alignment it honors). In the meantime, resort to malloc
143 considerations only. */
144
145 /* Account for MALLOC_OBSERVABLE_ALIGNMENTs here. Use this or the ABI
146 guaranteed alignment if greater. */
147
148 #ifdef MALLOC_OBSERVABLE_ALIGNMENT
149 #define MALLOC_ALIGNMENT MALLOC_OBSERVABLE_ALIGNMENT
150 #else
151 #define MALLOC_OBSERVABLE_ALIGNMENT (2 * LONG_TYPE_SIZE)
152 #define MALLOC_ALIGNMENT \
153 MAX (MALLOC_ABI_ALIGNMENT, MALLOC_OBSERVABLE_ALIGNMENT)
154 #endif
155
156 Pos
157 get_target_system_allocator_alignment (void)
158 {
159 return MALLOC_ALIGNMENT / BITS_PER_UNIT;
160 }
161
162 /* Standard'Maximum_Allowed_Alignment. Maximum alignment that we may
163 accept for any type or object. */
164
165 #ifndef MAX_OFILE_ALIGNMENT
166 #define MAX_OFILE_ALIGNMENT BIGGEST_ALIGNMENT
167 #endif
168
169 Pos
170 get_target_maximum_allowed_alignment (void)
171 {
172 return MAX_OFILE_ALIGNMENT / BITS_PER_UNIT;
173 }
174
175 /* Standard'Maximum_Alignment. The single attribute initially made
176 available, now a synonym of Standard'Maximum_Default_Alignment. */
177
178 Pos
179 get_target_maximum_alignment (void)
180 {
181 return get_target_maximum_default_alignment ();
182 }
183
184 #ifndef FLOAT_WORDS_BIG_ENDIAN
185 #define FLOAT_WORDS_BIG_ENDIAN WORDS_BIG_ENDIAN
186 #endif
187
188 Nat
189 get_target_float_words_be (void)
190 {
191 return FLOAT_WORDS_BIG_ENDIAN;
192 }
193
194 Nat
195 get_target_words_be (void)
196 {
197 return WORDS_BIG_ENDIAN;
198 }
199
200 Nat
201 get_target_bytes_be (void)
202 {
203 return BYTES_BIG_ENDIAN;
204 }
205
206 Nat
207 get_target_bits_be (void)
208 {
209 return BITS_BIG_ENDIAN;
210 }
211
212 Nat
213 get_target_strict_alignment (void)
214 {
215 return STRICT_ALIGNMENT;
216 }
217
218 Nat
219 get_target_double_float_alignment (void)
220 {
221 #ifdef TARGET_ALIGN_NATURAL
222 /* This macro is only defined by the rs6000 port. */
223 if (!TARGET_ALIGN_NATURAL
224 && (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_DARWIN))
225 return 32 / BITS_PER_UNIT;
226 #endif
227 return 0;
228 }
229
230 Nat
231 get_target_double_scalar_alignment (void)
232 {
233 #ifdef TARGET_ALIGN_DOUBLE
234 /* This macro is only defined by the i386 and sh ports. */
235 if (!TARGET_ALIGN_DOUBLE
236 #ifdef TARGET_64BIT
237 && !TARGET_64BIT
238 #endif
239 )
240 return 32 / BITS_PER_UNIT;
241 #endif
242 return 0;
243 }