annotate gcc/ada/gcc-interface/misc.c @ 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 * M I S C *
kono
parents:
diff changeset
6 * *
kono
parents:
diff changeset
7 * C Implementation File *
kono
parents:
diff changeset
8 * *
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 * Copyright (C) 1992-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 see *
kono
parents:
diff changeset
19 * <http://www.gnu.org/licenses/>. *
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 #include "config.h"
kono
parents:
diff changeset
27 #include "system.h"
kono
parents:
diff changeset
28 #include "coretypes.h"
kono
parents:
diff changeset
29 #include "target.h"
kono
parents:
diff changeset
30 #include "tree.h"
kono
parents:
diff changeset
31 #include "diagnostic.h"
kono
parents:
diff changeset
32 #include "opts.h"
kono
parents:
diff changeset
33 #include "alias.h"
kono
parents:
diff changeset
34 #include "fold-const.h"
kono
parents:
diff changeset
35 #include "stor-layout.h"
kono
parents:
diff changeset
36 #include "print-tree.h"
kono
parents:
diff changeset
37 #include "toplev.h"
kono
parents:
diff changeset
38 #include "langhooks.h"
kono
parents:
diff changeset
39 #include "langhooks-def.h"
kono
parents:
diff changeset
40 #include "plugin.h"
kono
parents:
diff changeset
41 #include "calls.h" /* For pass_by_reference. */
kono
parents:
diff changeset
42 #include "dwarf2out.h"
kono
parents:
diff changeset
43
kono
parents:
diff changeset
44 #include "ada.h"
kono
parents:
diff changeset
45 #include "adadecode.h"
kono
parents:
diff changeset
46 #include "types.h"
kono
parents:
diff changeset
47 #include "atree.h"
kono
parents:
diff changeset
48 #include "namet.h"
kono
parents:
diff changeset
49 #include "nlists.h"
kono
parents:
diff changeset
50 #include "uintp.h"
kono
parents:
diff changeset
51 #include "fe.h"
kono
parents:
diff changeset
52 #include "sinfo.h"
kono
parents:
diff changeset
53 #include "einfo.h"
kono
parents:
diff changeset
54 #include "ada-tree.h"
kono
parents:
diff changeset
55 #include "gigi.h"
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 /* This symbol needs to be defined for the front-end. */
kono
parents:
diff changeset
58 void *callgraph_info_file = NULL;
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 /* Command-line argc and argv. These variables are global since they are
kono
parents:
diff changeset
61 imported in back_end.adb. */
kono
parents:
diff changeset
62 unsigned int save_argc;
kono
parents:
diff changeset
63 const char **save_argv;
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 /* GNAT argc and argv generated by the binder for all Ada programs. */
kono
parents:
diff changeset
66 extern int gnat_argc;
kono
parents:
diff changeset
67 extern const char **gnat_argv;
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 /* Ada code requires variables for these settings rather than elements
kono
parents:
diff changeset
70 of the global_options structure because they are imported. */
kono
parents:
diff changeset
71 #undef gnat_encodings
kono
parents:
diff changeset
72 enum dwarf_gnat_encodings gnat_encodings = DWARF_GNAT_ENCODINGS_DEFAULT;
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 #undef optimize
kono
parents:
diff changeset
75 int optimize;
kono
parents:
diff changeset
76
kono
parents:
diff changeset
77 #undef optimize_size
kono
parents:
diff changeset
78 int optimize_size;
kono
parents:
diff changeset
79
kono
parents:
diff changeset
80 #undef flag_short_enums
kono
parents:
diff changeset
81 int flag_short_enums;
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 #undef flag_stack_check
kono
parents:
diff changeset
84 enum stack_check_type flag_stack_check = NO_STACK_CHECK;
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 #ifdef __cplusplus
kono
parents:
diff changeset
87 extern "C" {
kono
parents:
diff changeset
88 #endif
kono
parents:
diff changeset
89
kono
parents:
diff changeset
90 /* Declare functions we use as part of startup. */
kono
parents:
diff changeset
91 extern void __gnat_initialize (void *);
kono
parents:
diff changeset
92 extern void __gnat_install_SEH_handler (void *);
kono
parents:
diff changeset
93 extern void adainit (void);
kono
parents:
diff changeset
94 extern void _ada_gnat1drv (void);
kono
parents:
diff changeset
95
kono
parents:
diff changeset
96 #ifdef __cplusplus
kono
parents:
diff changeset
97 }
kono
parents:
diff changeset
98 #endif
kono
parents:
diff changeset
99
kono
parents:
diff changeset
100 /* The parser for the language. For us, we process the GNAT tree. */
kono
parents:
diff changeset
101
kono
parents:
diff changeset
102 static void
kono
parents:
diff changeset
103 gnat_parse_file (void)
kono
parents:
diff changeset
104 {
kono
parents:
diff changeset
105 int seh[2];
kono
parents:
diff changeset
106
kono
parents:
diff changeset
107 /* Call the target specific initializations. */
kono
parents:
diff changeset
108 __gnat_initialize (NULL);
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 /* ??? Call the SEH initialization routine. This is to workaround
kono
parents:
diff changeset
111 a bootstrap path problem. The call below should be removed at some
kono
parents:
diff changeset
112 point and the SEH pointer passed to __gnat_initialize above. */
kono
parents:
diff changeset
113 __gnat_install_SEH_handler ((void *)seh);
kono
parents:
diff changeset
114
kono
parents:
diff changeset
115 /* Call the front-end elaboration procedures. */
kono
parents:
diff changeset
116 adainit ();
kono
parents:
diff changeset
117
kono
parents:
diff changeset
118 /* Call the front end. */
kono
parents:
diff changeset
119 _ada_gnat1drv ();
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 /* Write the global declarations. */
kono
parents:
diff changeset
122 gnat_write_global_declarations ();
kono
parents:
diff changeset
123 }
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 /* Return language mask for option processing. */
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 static unsigned int
kono
parents:
diff changeset
128 gnat_option_lang_mask (void)
kono
parents:
diff changeset
129 {
kono
parents:
diff changeset
130 return CL_Ada;
kono
parents:
diff changeset
131 }
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 /* Decode all the language specific options that cannot be decoded by GCC.
kono
parents:
diff changeset
134 The option decoding phase of GCC calls this routine on the flags that
kono
parents:
diff changeset
135 are marked as Ada-specific. Return true on success or false on failure. */
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 static bool
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
138 gnat_handle_option (size_t scode, const char *arg, HOST_WIDE_INT value,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
139 int kind, location_t loc,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
140 const struct cl_option_handlers *handlers)
111
kono
parents:
diff changeset
141 {
kono
parents:
diff changeset
142 enum opt_code code = (enum opt_code) scode;
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 switch (code)
kono
parents:
diff changeset
145 {
kono
parents:
diff changeset
146 case OPT_Wall:
kono
parents:
diff changeset
147 handle_generated_option (&global_options, &global_options_set,
kono
parents:
diff changeset
148 OPT_Wunused, NULL, value,
kono
parents:
diff changeset
149 gnat_option_lang_mask (), kind, loc,
kono
parents:
diff changeset
150 handlers, true, global_dc);
kono
parents:
diff changeset
151 warn_uninitialized = value;
kono
parents:
diff changeset
152 warn_maybe_uninitialized = value;
kono
parents:
diff changeset
153 break;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 case OPT_gant:
kono
parents:
diff changeset
156 warning (0, "%<-gnat%> misspelled as %<-gant%>");
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 /* ... fall through ... */
kono
parents:
diff changeset
159
kono
parents:
diff changeset
160 case OPT_gnat:
kono
parents:
diff changeset
161 case OPT_gnatO:
kono
parents:
diff changeset
162 case OPT_fRTS_:
kono
parents:
diff changeset
163 case OPT_I:
kono
parents:
diff changeset
164 case OPT_nostdinc:
kono
parents:
diff changeset
165 case OPT_nostdlib:
kono
parents:
diff changeset
166 /* These are handled by the front-end. */
kono
parents:
diff changeset
167 break;
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 case OPT_fshort_enums:
kono
parents:
diff changeset
170 case OPT_fsigned_char:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
171 case OPT_funsigned_char:
111
kono
parents:
diff changeset
172 /* These are handled by the middle-end. */
kono
parents:
diff changeset
173 break;
kono
parents:
diff changeset
174
kono
parents:
diff changeset
175 case OPT_fbuiltin_printf:
kono
parents:
diff changeset
176 /* This is ignored in Ada but needs to be accepted so it can be
kono
parents:
diff changeset
177 defaulted. */
kono
parents:
diff changeset
178 break;
kono
parents:
diff changeset
179
kono
parents:
diff changeset
180 default:
kono
parents:
diff changeset
181 gcc_unreachable ();
kono
parents:
diff changeset
182 }
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 Ada_handle_option_auto (&global_options, &global_options_set,
kono
parents:
diff changeset
185 scode, arg, value,
kono
parents:
diff changeset
186 gnat_option_lang_mask (), kind, loc,
kono
parents:
diff changeset
187 handlers, global_dc);
kono
parents:
diff changeset
188 return true;
kono
parents:
diff changeset
189 }
kono
parents:
diff changeset
190
kono
parents:
diff changeset
191 /* Initialize options structure OPTS. */
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 static void
kono
parents:
diff changeset
194 gnat_init_options_struct (struct gcc_options *opts)
kono
parents:
diff changeset
195 {
kono
parents:
diff changeset
196 /* Uninitialized really means uninitialized in Ada. */
kono
parents:
diff changeset
197 opts->x_flag_zero_initialized_in_bss = 0;
kono
parents:
diff changeset
198
kono
parents:
diff changeset
199 /* We don't care about errno in Ada and it causes __builtin_sqrt to
kono
parents:
diff changeset
200 call the libm function rather than do it inline. */
kono
parents:
diff changeset
201 opts->x_flag_errno_math = 0;
kono
parents:
diff changeset
202 opts->frontend_set_flag_errno_math = true;
kono
parents:
diff changeset
203 }
kono
parents:
diff changeset
204
kono
parents:
diff changeset
205 /* Initialize for option processing. */
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 static void
kono
parents:
diff changeset
208 gnat_init_options (unsigned int decoded_options_count,
kono
parents:
diff changeset
209 struct cl_decoded_option *decoded_options)
kono
parents:
diff changeset
210 {
kono
parents:
diff changeset
211 /* Reconstruct an argv array for use of back_end.adb.
kono
parents:
diff changeset
212
kono
parents:
diff changeset
213 ??? back_end.adb should not rely on this; instead, it should work with
kono
parents:
diff changeset
214 decoded options without such reparsing, to ensure consistency in how
kono
parents:
diff changeset
215 options are decoded. */
kono
parents:
diff changeset
216 save_argv = XNEWVEC (const char *, 2 * decoded_options_count + 1);
kono
parents:
diff changeset
217 save_argc = 0;
kono
parents:
diff changeset
218 for (unsigned int i = 0; i < decoded_options_count; i++)
kono
parents:
diff changeset
219 {
kono
parents:
diff changeset
220 size_t num_elements = decoded_options[i].canonical_option_num_elements;
kono
parents:
diff changeset
221
kono
parents:
diff changeset
222 if (decoded_options[i].errors
kono
parents:
diff changeset
223 || decoded_options[i].opt_index == OPT_SPECIAL_unknown
kono
parents:
diff changeset
224 || num_elements == 0)
kono
parents:
diff changeset
225 continue;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 /* Deal with -I- specially since it must be a single switch. */
kono
parents:
diff changeset
228 if (decoded_options[i].opt_index == OPT_I
kono
parents:
diff changeset
229 && num_elements == 2
kono
parents:
diff changeset
230 && decoded_options[i].canonical_option[1][0] == '-'
kono
parents:
diff changeset
231 && decoded_options[i].canonical_option[1][1] == '\0')
kono
parents:
diff changeset
232 save_argv[save_argc++] = "-I-";
kono
parents:
diff changeset
233 else
kono
parents:
diff changeset
234 {
kono
parents:
diff changeset
235 gcc_assert (num_elements >= 1 && num_elements <= 2);
kono
parents:
diff changeset
236 save_argv[save_argc++] = decoded_options[i].canonical_option[0];
kono
parents:
diff changeset
237 if (num_elements >= 2)
kono
parents:
diff changeset
238 save_argv[save_argc++] = decoded_options[i].canonical_option[1];
kono
parents:
diff changeset
239 }
kono
parents:
diff changeset
240 }
kono
parents:
diff changeset
241 save_argv[save_argc] = NULL;
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 /* Pass just the name of the command through the regular channel. */
kono
parents:
diff changeset
244 gnat_argv = (const char **) xmalloc (sizeof (char *));
kono
parents:
diff changeset
245 gnat_argv[0] = xstrdup (save_argv[0]);
kono
parents:
diff changeset
246 gnat_argc = 1;
kono
parents:
diff changeset
247 }
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 /* Settings adjustments after switches processing by the back-end.
kono
parents:
diff changeset
250 Note that the front-end switches processing (Scan_Compiler_Arguments)
kono
parents:
diff changeset
251 has not been done yet at this point! */
kono
parents:
diff changeset
252
kono
parents:
diff changeset
253 static bool
kono
parents:
diff changeset
254 gnat_post_options (const char **pfilename ATTRIBUTE_UNUSED)
kono
parents:
diff changeset
255 {
kono
parents:
diff changeset
256 /* Excess precision other than "fast" requires front-end support. */
kono
parents:
diff changeset
257 if (flag_excess_precision_cmdline == EXCESS_PRECISION_STANDARD)
kono
parents:
diff changeset
258 sorry ("-fexcess-precision=standard for Ada");
kono
parents:
diff changeset
259 flag_excess_precision_cmdline = EXCESS_PRECISION_FAST;
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 /* No psABI change warnings for Ada. */
kono
parents:
diff changeset
262 warn_psabi = 0;
kono
parents:
diff changeset
263
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
264 /* No return type warnings for Ada. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
265 warn_return_type = 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
266
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
267 /* No string overflow warnings for Ada. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
268 warn_stringop_overflow = 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
269
111
kono
parents:
diff changeset
270 /* No caret by default for Ada. */
kono
parents:
diff changeset
271 if (!global_options_set.x_flag_diagnostics_show_caret)
kono
parents:
diff changeset
272 global_dc->show_caret = false;
kono
parents:
diff changeset
273
kono
parents:
diff changeset
274 /* Warn only if STABS is not the default: we don't want to emit a warning if
kono
parents:
diff changeset
275 the user did not use a -gstabs option. */
kono
parents:
diff changeset
276 if (PREFERRED_DEBUGGING_TYPE != DBX_DEBUG && write_symbols == DBX_DEBUG)
kono
parents:
diff changeset
277 warning (0, "STABS debugging information for Ada is obsolete and not "
kono
parents:
diff changeset
278 "supported anymore");
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 /* Copy global settings to local versions. */
kono
parents:
diff changeset
281 gnat_encodings = global_options.x_gnat_encodings;
kono
parents:
diff changeset
282 optimize = global_options.x_optimize;
kono
parents:
diff changeset
283 optimize_size = global_options.x_optimize_size;
kono
parents:
diff changeset
284 flag_stack_check = global_options.x_flag_stack_check;
kono
parents:
diff changeset
285 flag_short_enums = global_options.x_flag_short_enums;
kono
parents:
diff changeset
286
kono
parents:
diff changeset
287 /* Unfortunately the post_options hook is called before the value of
kono
parents:
diff changeset
288 flag_short_enums is autodetected, if need be. Mimic the process
kono
parents:
diff changeset
289 for our private flag_short_enums. */
kono
parents:
diff changeset
290 if (flag_short_enums == 2)
kono
parents:
diff changeset
291 flag_short_enums = targetm.default_short_enums ();
kono
parents:
diff changeset
292
kono
parents:
diff changeset
293 return false;
kono
parents:
diff changeset
294 }
kono
parents:
diff changeset
295
kono
parents:
diff changeset
296 /* Here is the function to handle the compiler error processing in GCC. */
kono
parents:
diff changeset
297
kono
parents:
diff changeset
298 static void
kono
parents:
diff changeset
299 internal_error_function (diagnostic_context *context, const char *msgid,
kono
parents:
diff changeset
300 va_list *ap)
kono
parents:
diff changeset
301 {
kono
parents:
diff changeset
302 text_info tinfo;
kono
parents:
diff changeset
303 char *buffer, *p, *loc;
kono
parents:
diff changeset
304 String_Template temp, temp_loc;
kono
parents:
diff changeset
305 String_Pointer sp, sp_loc;
kono
parents:
diff changeset
306 expanded_location xloc;
kono
parents:
diff changeset
307
kono
parents:
diff changeset
308 /* Warn if plugins present. */
kono
parents:
diff changeset
309 warn_if_plugins ();
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 /* Reset the pretty-printer. */
kono
parents:
diff changeset
312 pp_clear_output_area (context->printer);
kono
parents:
diff changeset
313
kono
parents:
diff changeset
314 /* Format the message into the pretty-printer. */
kono
parents:
diff changeset
315 tinfo.format_spec = msgid;
kono
parents:
diff changeset
316 tinfo.args_ptr = ap;
kono
parents:
diff changeset
317 tinfo.err_no = errno;
kono
parents:
diff changeset
318 pp_format_verbatim (context->printer, &tinfo);
kono
parents:
diff changeset
319
kono
parents:
diff changeset
320 /* Extract a (writable) pointer to the formatted text. */
kono
parents:
diff changeset
321 buffer = xstrdup (pp_formatted_text (context->printer));
kono
parents:
diff changeset
322
kono
parents:
diff changeset
323 /* Go up to the first newline. */
kono
parents:
diff changeset
324 for (p = buffer; *p; p++)
kono
parents:
diff changeset
325 if (*p == '\n')
kono
parents:
diff changeset
326 {
kono
parents:
diff changeset
327 *p = '\0';
kono
parents:
diff changeset
328 break;
kono
parents:
diff changeset
329 }
kono
parents:
diff changeset
330
kono
parents:
diff changeset
331 temp.Low_Bound = 1;
kono
parents:
diff changeset
332 temp.High_Bound = p - buffer;
kono
parents:
diff changeset
333 sp.Bounds = &temp;
kono
parents:
diff changeset
334 sp.Array = buffer;
kono
parents:
diff changeset
335
kono
parents:
diff changeset
336 xloc = expand_location (input_location);
kono
parents:
diff changeset
337 if (context->show_column && xloc.column != 0)
kono
parents:
diff changeset
338 loc = xasprintf ("%s:%d:%d", xloc.file, xloc.line, xloc.column);
kono
parents:
diff changeset
339 else
kono
parents:
diff changeset
340 loc = xasprintf ("%s:%d", xloc.file, xloc.line);
kono
parents:
diff changeset
341 temp_loc.Low_Bound = 1;
kono
parents:
diff changeset
342 temp_loc.High_Bound = strlen (loc);
kono
parents:
diff changeset
343 sp_loc.Bounds = &temp_loc;
kono
parents:
diff changeset
344 sp_loc.Array = loc;
kono
parents:
diff changeset
345
kono
parents:
diff changeset
346 Compiler_Abort (sp, sp_loc, true);
kono
parents:
diff changeset
347 }
kono
parents:
diff changeset
348
kono
parents:
diff changeset
349 /* Perform all the initialization steps that are language-specific. */
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 static bool
kono
parents:
diff changeset
352 gnat_init (void)
kono
parents:
diff changeset
353 {
kono
parents:
diff changeset
354 /* Do little here, most of the standard declarations are set up after the
kono
parents:
diff changeset
355 front-end has been run. Use the same `char' as C for Interfaces.C. */
kono
parents:
diff changeset
356 build_common_tree_nodes (flag_signed_char);
kono
parents:
diff changeset
357
kono
parents:
diff changeset
358 /* In Ada, we use an unsigned 8-bit type for the default boolean type. */
kono
parents:
diff changeset
359 boolean_type_node = make_unsigned_type (8);
kono
parents:
diff changeset
360 TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
kono
parents:
diff changeset
361 SET_TYPE_RM_MAX_VALUE (boolean_type_node,
kono
parents:
diff changeset
362 build_int_cst (boolean_type_node, 1));
kono
parents:
diff changeset
363 SET_TYPE_RM_SIZE (boolean_type_node, bitsize_int (1));
kono
parents:
diff changeset
364 boolean_true_node = TYPE_MAX_VALUE (boolean_type_node);
kono
parents:
diff changeset
365 boolean_false_node = TYPE_MIN_VALUE (boolean_type_node);
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 sbitsize_one_node = sbitsize_int (1);
kono
parents:
diff changeset
368 sbitsize_unit_node = sbitsize_int (BITS_PER_UNIT);
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 /* Register our internal error function. */
kono
parents:
diff changeset
371 global_dc->internal_error = &internal_error_function;
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 return true;
kono
parents:
diff changeset
374 }
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 /* Initialize the GCC support for exception handling. */
kono
parents:
diff changeset
377
kono
parents:
diff changeset
378 void
kono
parents:
diff changeset
379 gnat_init_gcc_eh (void)
kono
parents:
diff changeset
380 {
kono
parents:
diff changeset
381 /* We shouldn't do anything if the No_Exceptions_Handler pragma is set,
kono
parents:
diff changeset
382 though. This could for instance lead to the emission of tables with
kono
parents:
diff changeset
383 references to symbols (such as the Ada eh personality routine) within
kono
parents:
diff changeset
384 libraries we won't link against. */
kono
parents:
diff changeset
385 if (No_Exception_Handlers_Set ())
kono
parents:
diff changeset
386 return;
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 /* Tell GCC we are handling cleanup actions through exception propagation.
kono
parents:
diff changeset
389 This opens possibilities that we don't take advantage of yet, but is
kono
parents:
diff changeset
390 nonetheless necessary to ensure that fixup code gets assigned to the
kono
parents:
diff changeset
391 right exception regions. */
kono
parents:
diff changeset
392 using_eh_for_cleanups ();
kono
parents:
diff changeset
393
kono
parents:
diff changeset
394 /* Turn on -fexceptions, -fnon-call-exceptions and -fdelete-dead-exceptions.
kono
parents:
diff changeset
395 The first one triggers the generation of the necessary exception tables.
kono
parents:
diff changeset
396 The second one is useful for two reasons: 1/ we map some asynchronous
kono
parents:
diff changeset
397 signals like SEGV to exceptions, so we need to ensure that the insns
kono
parents:
diff changeset
398 which can lead to such signals are correctly attached to the exception
kono
parents:
diff changeset
399 region they pertain to, 2/ some calls to pure subprograms are handled as
kono
parents:
diff changeset
400 libcall blocks and then marked as "cannot trap" if the flag is not set
kono
parents:
diff changeset
401 (see emit_libcall_block). We should not let this be since it is possible
kono
parents:
diff changeset
402 for such calls to actually raise in Ada.
kono
parents:
diff changeset
403 The third one is an optimization that makes it possible to delete dead
kono
parents:
diff changeset
404 instructions that may throw exceptions, most notably loads and stores,
kono
parents:
diff changeset
405 as permitted in Ada. */
kono
parents:
diff changeset
406 flag_exceptions = 1;
kono
parents:
diff changeset
407 flag_non_call_exceptions = 1;
kono
parents:
diff changeset
408 flag_delete_dead_exceptions = 1;
kono
parents:
diff changeset
409
kono
parents:
diff changeset
410 init_eh ();
kono
parents:
diff changeset
411 }
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 /* Initialize the GCC support for floating-point operations. */
kono
parents:
diff changeset
414
kono
parents:
diff changeset
415 void
kono
parents:
diff changeset
416 gnat_init_gcc_fp (void)
kono
parents:
diff changeset
417 {
kono
parents:
diff changeset
418 /* Disable FP optimizations that ignore the signedness of zero if
kono
parents:
diff changeset
419 S'Signed_Zeros is true, but don't override the user if not. */
kono
parents:
diff changeset
420 if (Signed_Zeros_On_Target)
kono
parents:
diff changeset
421 flag_signed_zeros = 1;
kono
parents:
diff changeset
422 else if (!global_options_set.x_flag_signed_zeros)
kono
parents:
diff changeset
423 flag_signed_zeros = 0;
kono
parents:
diff changeset
424
kono
parents:
diff changeset
425 /* Assume that FP operations can trap if S'Machine_Overflow is true,
kono
parents:
diff changeset
426 but don't override the user if not. */
kono
parents:
diff changeset
427 if (Machine_Overflows_On_Target)
kono
parents:
diff changeset
428 flag_trapping_math = 1;
kono
parents:
diff changeset
429 else if (!global_options_set.x_flag_trapping_math)
kono
parents:
diff changeset
430 flag_trapping_math = 0;
kono
parents:
diff changeset
431 }
kono
parents:
diff changeset
432
kono
parents:
diff changeset
433 /* Print language-specific items in declaration NODE. */
kono
parents:
diff changeset
434
kono
parents:
diff changeset
435 static void
kono
parents:
diff changeset
436 gnat_print_decl (FILE *file, tree node, int indent)
kono
parents:
diff changeset
437 {
kono
parents:
diff changeset
438 switch (TREE_CODE (node))
kono
parents:
diff changeset
439 {
kono
parents:
diff changeset
440 case CONST_DECL:
kono
parents:
diff changeset
441 print_node (file, "corresponding var",
kono
parents:
diff changeset
442 DECL_CONST_CORRESPONDING_VAR (node), indent + 4);
kono
parents:
diff changeset
443 break;
kono
parents:
diff changeset
444
kono
parents:
diff changeset
445 case FIELD_DECL:
kono
parents:
diff changeset
446 print_node (file, "original field", DECL_ORIGINAL_FIELD (node),
kono
parents:
diff changeset
447 indent + 4);
kono
parents:
diff changeset
448 break;
kono
parents:
diff changeset
449
kono
parents:
diff changeset
450 case VAR_DECL:
kono
parents:
diff changeset
451 if (DECL_LOOP_PARM_P (node))
kono
parents:
diff changeset
452 print_node (file, "induction var", DECL_INDUCTION_VAR (node),
kono
parents:
diff changeset
453 indent + 4);
kono
parents:
diff changeset
454 else
kono
parents:
diff changeset
455 print_node (file, "renamed object", DECL_RENAMED_OBJECT (node),
kono
parents:
diff changeset
456 indent + 4);
kono
parents:
diff changeset
457 break;
kono
parents:
diff changeset
458
kono
parents:
diff changeset
459 default:
kono
parents:
diff changeset
460 break;
kono
parents:
diff changeset
461 }
kono
parents:
diff changeset
462 }
kono
parents:
diff changeset
463
kono
parents:
diff changeset
464 /* Print language-specific items in type NODE. */
kono
parents:
diff changeset
465
kono
parents:
diff changeset
466 static void
kono
parents:
diff changeset
467 gnat_print_type (FILE *file, tree node, int indent)
kono
parents:
diff changeset
468 {
kono
parents:
diff changeset
469 switch (TREE_CODE (node))
kono
parents:
diff changeset
470 {
kono
parents:
diff changeset
471 case FUNCTION_TYPE:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
472 case METHOD_TYPE:
111
kono
parents:
diff changeset
473 print_node (file, "ci/co list", TYPE_CI_CO_LIST (node), indent + 4);
kono
parents:
diff changeset
474 break;
kono
parents:
diff changeset
475
kono
parents:
diff changeset
476 case INTEGER_TYPE:
kono
parents:
diff changeset
477 if (TYPE_MODULAR_P (node))
kono
parents:
diff changeset
478 print_node_brief (file, "modulus", TYPE_MODULUS (node), indent + 4);
kono
parents:
diff changeset
479 else if (TYPE_FIXED_POINT_P (node))
kono
parents:
diff changeset
480 print_node (file, "scale factor", TYPE_SCALE_FACTOR (node),
kono
parents:
diff changeset
481 indent + 4);
kono
parents:
diff changeset
482 else if (TYPE_HAS_ACTUAL_BOUNDS_P (node))
kono
parents:
diff changeset
483 print_node (file, "actual bounds", TYPE_ACTUAL_BOUNDS (node),
kono
parents:
diff changeset
484 indent + 4);
kono
parents:
diff changeset
485 else
kono
parents:
diff changeset
486 print_node (file, "index type", TYPE_INDEX_TYPE (node), indent + 4);
kono
parents:
diff changeset
487
kono
parents:
diff changeset
488 /* ... fall through ... */
kono
parents:
diff changeset
489
kono
parents:
diff changeset
490 case ENUMERAL_TYPE:
kono
parents:
diff changeset
491 case BOOLEAN_TYPE:
kono
parents:
diff changeset
492 print_node_brief (file, "RM size", TYPE_RM_SIZE (node), indent + 4);
kono
parents:
diff changeset
493
kono
parents:
diff changeset
494 /* ... fall through ... */
kono
parents:
diff changeset
495
kono
parents:
diff changeset
496 case REAL_TYPE:
kono
parents:
diff changeset
497 print_node_brief (file, "RM min", TYPE_RM_MIN_VALUE (node), indent + 4);
kono
parents:
diff changeset
498 print_node_brief (file, "RM max", TYPE_RM_MAX_VALUE (node), indent + 4);
kono
parents:
diff changeset
499 break;
kono
parents:
diff changeset
500
kono
parents:
diff changeset
501 case ARRAY_TYPE:
kono
parents:
diff changeset
502 print_node (file,"actual bounds", TYPE_ACTUAL_BOUNDS (node), indent + 4);
kono
parents:
diff changeset
503 break;
kono
parents:
diff changeset
504
kono
parents:
diff changeset
505 case VECTOR_TYPE:
kono
parents:
diff changeset
506 print_node (file,"representative array",
kono
parents:
diff changeset
507 TYPE_REPRESENTATIVE_ARRAY (node), indent + 4);
kono
parents:
diff changeset
508 break;
kono
parents:
diff changeset
509
kono
parents:
diff changeset
510 case RECORD_TYPE:
kono
parents:
diff changeset
511 if (TYPE_FAT_POINTER_P (node) || TYPE_CONTAINS_TEMPLATE_P (node))
kono
parents:
diff changeset
512 print_node (file, "unconstrained array",
kono
parents:
diff changeset
513 TYPE_UNCONSTRAINED_ARRAY (node), indent + 4);
kono
parents:
diff changeset
514 else
kono
parents:
diff changeset
515 print_node (file, "Ada size", TYPE_ADA_SIZE (node), indent + 4);
kono
parents:
diff changeset
516 break;
kono
parents:
diff changeset
517
kono
parents:
diff changeset
518 case UNION_TYPE:
kono
parents:
diff changeset
519 case QUAL_UNION_TYPE:
kono
parents:
diff changeset
520 print_node (file, "Ada size", TYPE_ADA_SIZE (node), indent + 4);
kono
parents:
diff changeset
521 break;
kono
parents:
diff changeset
522
kono
parents:
diff changeset
523 default:
kono
parents:
diff changeset
524 break;
kono
parents:
diff changeset
525 }
kono
parents:
diff changeset
526
kono
parents:
diff changeset
527 if (TYPE_CAN_HAVE_DEBUG_TYPE_P (node) && TYPE_DEBUG_TYPE (node))
kono
parents:
diff changeset
528 print_node_brief (file, "debug type", TYPE_DEBUG_TYPE (node), indent + 4);
kono
parents:
diff changeset
529
kono
parents:
diff changeset
530 if (TYPE_IMPL_PACKED_ARRAY_P (node) && TYPE_ORIGINAL_PACKED_ARRAY (node))
kono
parents:
diff changeset
531 print_node_brief (file, "original packed array",
kono
parents:
diff changeset
532 TYPE_ORIGINAL_PACKED_ARRAY (node), indent + 4);
kono
parents:
diff changeset
533 }
kono
parents:
diff changeset
534
kono
parents:
diff changeset
535 /* Return the name to be printed for DECL. */
kono
parents:
diff changeset
536
kono
parents:
diff changeset
537 static const char *
kono
parents:
diff changeset
538 gnat_printable_name (tree decl, int verbosity)
kono
parents:
diff changeset
539 {
kono
parents:
diff changeset
540 const char *coded_name = IDENTIFIER_POINTER (DECL_NAME (decl));
kono
parents:
diff changeset
541 char *ada_name = (char *) ggc_alloc_atomic (strlen (coded_name) * 2 + 60);
kono
parents:
diff changeset
542
kono
parents:
diff changeset
543 __gnat_decode (coded_name, ada_name, 0);
kono
parents:
diff changeset
544
kono
parents:
diff changeset
545 if (verbosity == 2 && !DECL_IS_BUILTIN (decl))
kono
parents:
diff changeset
546 {
kono
parents:
diff changeset
547 Set_Identifier_Casing (ada_name, DECL_SOURCE_FILE (decl));
kono
parents:
diff changeset
548 return ggc_strdup (Name_Buffer);
kono
parents:
diff changeset
549 }
kono
parents:
diff changeset
550
kono
parents:
diff changeset
551 return ada_name;
kono
parents:
diff changeset
552 }
kono
parents:
diff changeset
553
kono
parents:
diff changeset
554 /* Return the name to be used in DWARF debug info for DECL. */
kono
parents:
diff changeset
555
kono
parents:
diff changeset
556 static const char *
kono
parents:
diff changeset
557 gnat_dwarf_name (tree decl, int verbosity ATTRIBUTE_UNUSED)
kono
parents:
diff changeset
558 {
kono
parents:
diff changeset
559 gcc_assert (DECL_P (decl));
kono
parents:
diff changeset
560 return (const char *) IDENTIFIER_POINTER (DECL_NAME (decl));
kono
parents:
diff changeset
561 }
kono
parents:
diff changeset
562
kono
parents:
diff changeset
563 /* Return the descriptive type associated with TYPE, if any. */
kono
parents:
diff changeset
564
kono
parents:
diff changeset
565 static tree
kono
parents:
diff changeset
566 gnat_descriptive_type (const_tree type)
kono
parents:
diff changeset
567 {
kono
parents:
diff changeset
568 if (TYPE_STUB_DECL (type))
kono
parents:
diff changeset
569 return DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type));
kono
parents:
diff changeset
570 else
kono
parents:
diff changeset
571 return NULL_TREE;
kono
parents:
diff changeset
572 }
kono
parents:
diff changeset
573
kono
parents:
diff changeset
574 /* Return the underlying base type of an enumeration type. */
kono
parents:
diff changeset
575
kono
parents:
diff changeset
576 static tree
kono
parents:
diff changeset
577 gnat_enum_underlying_base_type (const_tree)
kono
parents:
diff changeset
578 {
kono
parents:
diff changeset
579 /* Enumeration types are base types in Ada. */
kono
parents:
diff changeset
580 return void_type_node;
kono
parents:
diff changeset
581 }
kono
parents:
diff changeset
582
kono
parents:
diff changeset
583 /* Return the type to be used for debugging information instead of TYPE or
kono
parents:
diff changeset
584 NULL_TREE if TYPE is fine. */
kono
parents:
diff changeset
585
kono
parents:
diff changeset
586 static tree
kono
parents:
diff changeset
587 gnat_get_debug_type (const_tree type)
kono
parents:
diff changeset
588 {
kono
parents:
diff changeset
589 if (TYPE_CAN_HAVE_DEBUG_TYPE_P (type) && TYPE_DEBUG_TYPE (type))
kono
parents:
diff changeset
590 {
kono
parents:
diff changeset
591 type = TYPE_DEBUG_TYPE (type);
kono
parents:
diff changeset
592
kono
parents:
diff changeset
593 /* ??? The get_debug_type language hook is processed after the array
kono
parents:
diff changeset
594 descriptor language hook, so if there is an array behind this type,
kono
parents:
diff changeset
595 the latter is supposed to handle it. Still, we can get here with
kono
parents:
diff changeset
596 a type we are not supposed to handle (e.g. when the DWARF back-end
kono
parents:
diff changeset
597 processes the type of a variable), so keep this guard. */
kono
parents:
diff changeset
598 if (type && TYPE_CAN_HAVE_DEBUG_TYPE_P (type))
kono
parents:
diff changeset
599 return const_cast<tree> (type);
kono
parents:
diff changeset
600 }
kono
parents:
diff changeset
601
kono
parents:
diff changeset
602 return NULL_TREE;
kono
parents:
diff changeset
603 }
kono
parents:
diff changeset
604
kono
parents:
diff changeset
605 /* Provide information in INFO for debugging output about the TYPE fixed-point
kono
parents:
diff changeset
606 type. Return whether TYPE is handled. */
kono
parents:
diff changeset
607
kono
parents:
diff changeset
608 static bool
kono
parents:
diff changeset
609 gnat_get_fixed_point_type_info (const_tree type,
kono
parents:
diff changeset
610 struct fixed_point_type_info *info)
kono
parents:
diff changeset
611 {
kono
parents:
diff changeset
612 tree scale_factor;
kono
parents:
diff changeset
613
kono
parents:
diff changeset
614 /* GDB cannot handle fixed-point types yet, so rely on GNAT encodings
kono
parents:
diff changeset
615 instead for it. */
kono
parents:
diff changeset
616 if (!TYPE_IS_FIXED_POINT_P (type)
kono
parents:
diff changeset
617 || gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
kono
parents:
diff changeset
618 return false;
kono
parents:
diff changeset
619
kono
parents:
diff changeset
620 scale_factor = TYPE_SCALE_FACTOR (type);
kono
parents:
diff changeset
621
kono
parents:
diff changeset
622 /* We expect here only a finite set of pattern. See fixed-point types
kono
parents:
diff changeset
623 handling in gnat_to_gnu_entity. */
kono
parents:
diff changeset
624
kono
parents:
diff changeset
625 /* Put invalid values when compiler internals cannot represent the scale
kono
parents:
diff changeset
626 factor. */
kono
parents:
diff changeset
627 if (scale_factor == integer_zero_node)
kono
parents:
diff changeset
628 {
kono
parents:
diff changeset
629 info->scale_factor_kind = fixed_point_scale_factor_arbitrary;
kono
parents:
diff changeset
630 info->scale_factor.arbitrary.numerator = 0;
kono
parents:
diff changeset
631 info->scale_factor.arbitrary.denominator = 0;
kono
parents:
diff changeset
632 return true;
kono
parents:
diff changeset
633 }
kono
parents:
diff changeset
634
kono
parents:
diff changeset
635 if (TREE_CODE (scale_factor) == RDIV_EXPR)
kono
parents:
diff changeset
636 {
kono
parents:
diff changeset
637 const tree num = TREE_OPERAND (scale_factor, 0);
kono
parents:
diff changeset
638 const tree den = TREE_OPERAND (scale_factor, 1);
kono
parents:
diff changeset
639
kono
parents:
diff changeset
640 /* See if we have a binary or decimal scale. */
kono
parents:
diff changeset
641 if (TREE_CODE (den) == POWER_EXPR)
kono
parents:
diff changeset
642 {
kono
parents:
diff changeset
643 const tree base = TREE_OPERAND (den, 0);
kono
parents:
diff changeset
644 const tree exponent = TREE_OPERAND (den, 1);
kono
parents:
diff changeset
645
kono
parents:
diff changeset
646 /* We expect the scale factor to be 1 / 2 ** N or 1 / 10 ** N. */
kono
parents:
diff changeset
647 gcc_assert (num == integer_one_node
kono
parents:
diff changeset
648 && TREE_CODE (base) == INTEGER_CST
kono
parents:
diff changeset
649 && TREE_CODE (exponent) == INTEGER_CST);
kono
parents:
diff changeset
650
kono
parents:
diff changeset
651 switch (tree_to_shwi (base))
kono
parents:
diff changeset
652 {
kono
parents:
diff changeset
653 case 2:
kono
parents:
diff changeset
654 info->scale_factor_kind = fixed_point_scale_factor_binary;
kono
parents:
diff changeset
655 info->scale_factor.binary = -tree_to_shwi (exponent);
kono
parents:
diff changeset
656 return true;
kono
parents:
diff changeset
657
kono
parents:
diff changeset
658 case 10:
kono
parents:
diff changeset
659 info->scale_factor_kind = fixed_point_scale_factor_decimal;
kono
parents:
diff changeset
660 info->scale_factor.decimal = -tree_to_shwi (exponent);
kono
parents:
diff changeset
661 return true;
kono
parents:
diff changeset
662
kono
parents:
diff changeset
663 default:
kono
parents:
diff changeset
664 gcc_unreachable ();
kono
parents:
diff changeset
665 }
kono
parents:
diff changeset
666 }
kono
parents:
diff changeset
667
kono
parents:
diff changeset
668 /* If we reach this point, we are handling an arbitrary scale factor. We
kono
parents:
diff changeset
669 expect N / D with constant operands. */
kono
parents:
diff changeset
670 gcc_assert (TREE_CODE (num) == INTEGER_CST
kono
parents:
diff changeset
671 && TREE_CODE (den) == INTEGER_CST);
kono
parents:
diff changeset
672
kono
parents:
diff changeset
673 info->scale_factor_kind = fixed_point_scale_factor_arbitrary;
kono
parents:
diff changeset
674 info->scale_factor.arbitrary.numerator = tree_to_uhwi (num);
kono
parents:
diff changeset
675 info->scale_factor.arbitrary.denominator = tree_to_shwi (den);
kono
parents:
diff changeset
676 return true;
kono
parents:
diff changeset
677 }
kono
parents:
diff changeset
678
kono
parents:
diff changeset
679 gcc_unreachable ();
kono
parents:
diff changeset
680 }
kono
parents:
diff changeset
681
kono
parents:
diff changeset
682 /* Return true if types T1 and T2 are identical for type hashing purposes.
kono
parents:
diff changeset
683 Called only after doing all language independent checks. At present,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
684 this is only called when both types are FUNCTION_TYPE or METHOD_TYPE. */
111
kono
parents:
diff changeset
685
kono
parents:
diff changeset
686 static bool
kono
parents:
diff changeset
687 gnat_type_hash_eq (const_tree t1, const_tree t2)
kono
parents:
diff changeset
688 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
689 gcc_assert (FUNC_OR_METHOD_TYPE_P (t1) && TREE_CODE (t1) == TREE_CODE (t2));
111
kono
parents:
diff changeset
690 return fntype_same_flags_p (t1, TYPE_CI_CO_LIST (t2),
kono
parents:
diff changeset
691 TYPE_RETURN_UNCONSTRAINED_P (t2),
kono
parents:
diff changeset
692 TYPE_RETURN_BY_DIRECT_REF_P (t2),
kono
parents:
diff changeset
693 TREE_ADDRESSABLE (t2));
kono
parents:
diff changeset
694 }
kono
parents:
diff changeset
695
kono
parents:
diff changeset
696 /* Do nothing (return the tree node passed). */
kono
parents:
diff changeset
697
kono
parents:
diff changeset
698 static tree
kono
parents:
diff changeset
699 gnat_return_tree (tree t)
kono
parents:
diff changeset
700 {
kono
parents:
diff changeset
701 return t;
kono
parents:
diff changeset
702 }
kono
parents:
diff changeset
703
kono
parents:
diff changeset
704 /* Get the alias set corresponding to a type or expression. */
kono
parents:
diff changeset
705
kono
parents:
diff changeset
706 static alias_set_type
kono
parents:
diff changeset
707 gnat_get_alias_set (tree type)
kono
parents:
diff changeset
708 {
kono
parents:
diff changeset
709 /* If this is a padding type, use the type of the first field. */
kono
parents:
diff changeset
710 if (TYPE_IS_PADDING_P (type))
kono
parents:
diff changeset
711 return get_alias_set (TREE_TYPE (TYPE_FIELDS (type)));
kono
parents:
diff changeset
712
kono
parents:
diff changeset
713 /* If the type is an unconstrained array, use the type of the
kono
parents:
diff changeset
714 self-referential array we make. */
kono
parents:
diff changeset
715 else if (TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE)
kono
parents:
diff changeset
716 return
kono
parents:
diff changeset
717 get_alias_set (TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (type)))));
kono
parents:
diff changeset
718
kono
parents:
diff changeset
719 /* If the type can alias any other types, return the alias set 0. */
kono
parents:
diff changeset
720 else if (TYPE_P (type)
kono
parents:
diff changeset
721 && !TYPE_IS_DUMMY_P (type)
kono
parents:
diff changeset
722 && TYPE_UNIVERSAL_ALIASING_P (type))
kono
parents:
diff changeset
723 return 0;
kono
parents:
diff changeset
724
kono
parents:
diff changeset
725 return -1;
kono
parents:
diff changeset
726 }
kono
parents:
diff changeset
727
kono
parents:
diff changeset
728 /* GNU_TYPE is a type. Return its maximum size in bytes, if known,
kono
parents:
diff changeset
729 as a constant when possible. */
kono
parents:
diff changeset
730
kono
parents:
diff changeset
731 static tree
kono
parents:
diff changeset
732 gnat_type_max_size (const_tree gnu_type)
kono
parents:
diff changeset
733 {
kono
parents:
diff changeset
734 /* First see what we can get from TYPE_SIZE_UNIT, which might not
kono
parents:
diff changeset
735 be constant even for simple expressions if it has already been
kono
parents:
diff changeset
736 elaborated and possibly replaced by a VAR_DECL. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
737 tree max_size_unit = max_size (TYPE_SIZE_UNIT (gnu_type), true);
111
kono
parents:
diff changeset
738
kono
parents:
diff changeset
739 /* If we don't have a constant, try to look at attributes which should have
kono
parents:
diff changeset
740 stayed untouched. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
741 if (!tree_fits_uhwi_p (max_size_unit))
111
kono
parents:
diff changeset
742 {
kono
parents:
diff changeset
743 /* For record types, see what we can get from TYPE_ADA_SIZE. */
kono
parents:
diff changeset
744 if (RECORD_OR_UNION_TYPE_P (gnu_type)
kono
parents:
diff changeset
745 && !TYPE_FAT_POINTER_P (gnu_type)
kono
parents:
diff changeset
746 && TYPE_ADA_SIZE (gnu_type))
kono
parents:
diff changeset
747 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
748 tree max_ada_size = max_size (TYPE_ADA_SIZE (gnu_type), true);
111
kono
parents:
diff changeset
749
kono
parents:
diff changeset
750 /* If we have succeeded in finding a constant, round it up to the
kono
parents:
diff changeset
751 type's alignment and return the result in units. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
752 if (tree_fits_uhwi_p (max_ada_size))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
753 max_size_unit
111
kono
parents:
diff changeset
754 = size_binop (CEIL_DIV_EXPR,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
755 round_up (max_ada_size, TYPE_ALIGN (gnu_type)),
111
kono
parents:
diff changeset
756 bitsize_unit_node);
kono
parents:
diff changeset
757 }
kono
parents:
diff changeset
758
kono
parents:
diff changeset
759 /* For array types, see what we can get from TYPE_INDEX_TYPE. */
kono
parents:
diff changeset
760 else if (TREE_CODE (gnu_type) == ARRAY_TYPE
kono
parents:
diff changeset
761 && TYPE_INDEX_TYPE (TYPE_DOMAIN (gnu_type))
kono
parents:
diff changeset
762 && tree_fits_uhwi_p (TYPE_SIZE_UNIT (TREE_TYPE (gnu_type))))
kono
parents:
diff changeset
763 {
kono
parents:
diff changeset
764 tree lb = TYPE_MIN_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (gnu_type)));
kono
parents:
diff changeset
765 tree hb = TYPE_MAX_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (gnu_type)));
kono
parents:
diff changeset
766 if (TREE_CODE (lb) != INTEGER_CST
kono
parents:
diff changeset
767 && TYPE_RM_SIZE (TREE_TYPE (lb))
kono
parents:
diff changeset
768 && compare_tree_int (TYPE_RM_SIZE (TREE_TYPE (lb)), 16) <= 0)
kono
parents:
diff changeset
769 lb = TYPE_MIN_VALUE (TREE_TYPE (lb));
kono
parents:
diff changeset
770 if (TREE_CODE (hb) != INTEGER_CST
kono
parents:
diff changeset
771 && TYPE_RM_SIZE (TREE_TYPE (hb))
kono
parents:
diff changeset
772 && compare_tree_int (TYPE_RM_SIZE (TREE_TYPE (hb)), 16) <= 0)
kono
parents:
diff changeset
773 hb = TYPE_MAX_VALUE (TREE_TYPE (hb));
kono
parents:
diff changeset
774 if (TREE_CODE (lb) == INTEGER_CST && TREE_CODE (hb) == INTEGER_CST)
kono
parents:
diff changeset
775 {
kono
parents:
diff changeset
776 tree ctype = get_base_type (TREE_TYPE (lb));
kono
parents:
diff changeset
777 lb = fold_convert (ctype, lb);
kono
parents:
diff changeset
778 hb = fold_convert (ctype, hb);
kono
parents:
diff changeset
779 if (tree_int_cst_le (lb, hb))
kono
parents:
diff changeset
780 {
kono
parents:
diff changeset
781 tree length
kono
parents:
diff changeset
782 = fold_build2 (PLUS_EXPR, ctype,
kono
parents:
diff changeset
783 fold_build2 (MINUS_EXPR, ctype, hb, lb),
kono
parents:
diff changeset
784 build_int_cst (ctype, 1));
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
785 max_size_unit
111
kono
parents:
diff changeset
786 = fold_build2 (MULT_EXPR, sizetype,
kono
parents:
diff changeset
787 fold_convert (sizetype, length),
kono
parents:
diff changeset
788 TYPE_SIZE_UNIT (TREE_TYPE (gnu_type)));
kono
parents:
diff changeset
789 }
kono
parents:
diff changeset
790 }
kono
parents:
diff changeset
791 }
kono
parents:
diff changeset
792 }
kono
parents:
diff changeset
793
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
794 return max_size_unit;
111
kono
parents:
diff changeset
795 }
kono
parents:
diff changeset
796
kono
parents:
diff changeset
797 static tree get_array_bit_stride (tree);
kono
parents:
diff changeset
798
kono
parents:
diff changeset
799 /* Provide information in INFO for debug output about the TYPE array type.
kono
parents:
diff changeset
800 Return whether TYPE is handled. */
kono
parents:
diff changeset
801
kono
parents:
diff changeset
802 static bool
kono
parents:
diff changeset
803 gnat_get_array_descr_info (const_tree const_type,
kono
parents:
diff changeset
804 struct array_descr_info *info)
kono
parents:
diff changeset
805 {
kono
parents:
diff changeset
806 bool convention_fortran_p;
kono
parents:
diff changeset
807 bool is_array = false;
kono
parents:
diff changeset
808 bool is_fat_ptr = false;
kono
parents:
diff changeset
809 bool is_packed_array = false;
kono
parents:
diff changeset
810 tree type = const_cast<tree> (const_type);
kono
parents:
diff changeset
811 const_tree first_dimen = NULL_TREE;
kono
parents:
diff changeset
812 const_tree last_dimen = NULL_TREE;
kono
parents:
diff changeset
813 const_tree dimen;
kono
parents:
diff changeset
814 int i;
kono
parents:
diff changeset
815
kono
parents:
diff changeset
816 /* Temporaries created in the first pass and used in the second one for thin
kono
parents:
diff changeset
817 pointers. The first one is an expression that yields the template record
kono
parents:
diff changeset
818 from the base address (i.e. the PLACEHOLDER_EXPR). The second one is just
kono
parents:
diff changeset
819 a cursor through this record's fields. */
kono
parents:
diff changeset
820 tree thinptr_template_expr = NULL_TREE;
kono
parents:
diff changeset
821 tree thinptr_bound_field = NULL_TREE;
kono
parents:
diff changeset
822
kono
parents:
diff changeset
823 /* ??? See gnat_get_debug_type. */
kono
parents:
diff changeset
824 type = maybe_debug_type (type);
kono
parents:
diff changeset
825
kono
parents:
diff changeset
826 /* If we have an implementation type for a packed array, get the orignial
kono
parents:
diff changeset
827 array type. */
kono
parents:
diff changeset
828 if (TYPE_IMPL_PACKED_ARRAY_P (type) && TYPE_ORIGINAL_PACKED_ARRAY (type))
kono
parents:
diff changeset
829 {
kono
parents:
diff changeset
830 type = TYPE_ORIGINAL_PACKED_ARRAY (type);
kono
parents:
diff changeset
831 is_packed_array = true;
kono
parents:
diff changeset
832 }
kono
parents:
diff changeset
833
kono
parents:
diff changeset
834 /* First pass: gather all information about this array except everything
kono
parents:
diff changeset
835 related to dimensions. */
kono
parents:
diff changeset
836
kono
parents:
diff changeset
837 /* Only handle ARRAY_TYPE nodes that come from GNAT. */
kono
parents:
diff changeset
838 if (TREE_CODE (type) == ARRAY_TYPE
kono
parents:
diff changeset
839 && TYPE_DOMAIN (type)
kono
parents:
diff changeset
840 && TYPE_INDEX_TYPE (TYPE_DOMAIN (type)))
kono
parents:
diff changeset
841 {
kono
parents:
diff changeset
842 is_array = true;
kono
parents:
diff changeset
843 first_dimen = type;
kono
parents:
diff changeset
844 info->data_location = NULL_TREE;
kono
parents:
diff changeset
845 }
kono
parents:
diff changeset
846
kono
parents:
diff changeset
847 else if (TYPE_IS_FAT_POINTER_P (type)
kono
parents:
diff changeset
848 && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
kono
parents:
diff changeset
849 {
kono
parents:
diff changeset
850 const tree ua_type = TYPE_UNCONSTRAINED_ARRAY (type);
kono
parents:
diff changeset
851
kono
parents:
diff changeset
852 /* This will be our base object address. */
kono
parents:
diff changeset
853 const tree placeholder_expr = build0 (PLACEHOLDER_EXPR, type);
kono
parents:
diff changeset
854
kono
parents:
diff changeset
855 /* We assume below that maybe_unconstrained_array returns an INDIRECT_REF
kono
parents:
diff changeset
856 node. */
kono
parents:
diff changeset
857 const tree ua_val
kono
parents:
diff changeset
858 = maybe_unconstrained_array (build_unary_op (INDIRECT_REF,
kono
parents:
diff changeset
859 ua_type,
kono
parents:
diff changeset
860 placeholder_expr));
kono
parents:
diff changeset
861
kono
parents:
diff changeset
862 is_fat_ptr = true;
kono
parents:
diff changeset
863 first_dimen = TREE_TYPE (ua_val);
kono
parents:
diff changeset
864
kono
parents:
diff changeset
865 /* Get the *address* of the array, not the array itself. */
kono
parents:
diff changeset
866 info->data_location = TREE_OPERAND (ua_val, 0);
kono
parents:
diff changeset
867 }
kono
parents:
diff changeset
868
kono
parents:
diff changeset
869 /* Unlike fat pointers (which appear for unconstrained arrays passed in
kono
parents:
diff changeset
870 argument), thin pointers are used only for array access types, so we want
kono
parents:
diff changeset
871 them to appear in the debug info as pointers to an array type. That's why
kono
parents:
diff changeset
872 we match only the RECORD_TYPE here instead of the POINTER_TYPE with the
kono
parents:
diff changeset
873 TYPE_IS_THIN_POINTER_P predicate. */
kono
parents:
diff changeset
874 else if (TREE_CODE (type) == RECORD_TYPE
kono
parents:
diff changeset
875 && TYPE_CONTAINS_TEMPLATE_P (type)
kono
parents:
diff changeset
876 && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
kono
parents:
diff changeset
877 {
kono
parents:
diff changeset
878 /* This will be our base object address. Note that we assume that
kono
parents:
diff changeset
879 pointers to these will actually point to the array field (thin
kono
parents:
diff changeset
880 pointers are shifted). */
kono
parents:
diff changeset
881 const tree placeholder_expr = build0 (PLACEHOLDER_EXPR, type);
kono
parents:
diff changeset
882 const tree placeholder_addr
kono
parents:
diff changeset
883 = build_unary_op (ADDR_EXPR, NULL_TREE, placeholder_expr);
kono
parents:
diff changeset
884
kono
parents:
diff changeset
885 const tree bounds_field = TYPE_FIELDS (type);
kono
parents:
diff changeset
886 const tree bounds_type = TREE_TYPE (bounds_field);
kono
parents:
diff changeset
887 const tree array_field = DECL_CHAIN (bounds_field);
kono
parents:
diff changeset
888 const tree array_type = TREE_TYPE (array_field);
kono
parents:
diff changeset
889
kono
parents:
diff changeset
890 /* Shift the thin pointer address to get the address of the template. */
kono
parents:
diff changeset
891 const tree shift_amount
kono
parents:
diff changeset
892 = fold_build1 (NEGATE_EXPR, sizetype, byte_position (array_field));
kono
parents:
diff changeset
893 tree template_addr
kono
parents:
diff changeset
894 = build_binary_op (POINTER_PLUS_EXPR, TREE_TYPE (placeholder_addr),
kono
parents:
diff changeset
895 placeholder_addr, shift_amount);
kono
parents:
diff changeset
896 template_addr
kono
parents:
diff changeset
897 = fold_convert (TYPE_POINTER_TO (bounds_type), template_addr);
kono
parents:
diff changeset
898
kono
parents:
diff changeset
899 first_dimen = array_type;
kono
parents:
diff changeset
900
kono
parents:
diff changeset
901 /* The thin pointer is already the pointer to the array data, so there's
kono
parents:
diff changeset
902 no need for a specific "data location" expression. */
kono
parents:
diff changeset
903 info->data_location = NULL_TREE;
kono
parents:
diff changeset
904
kono
parents:
diff changeset
905 thinptr_template_expr = build_unary_op (INDIRECT_REF,
kono
parents:
diff changeset
906 bounds_type,
kono
parents:
diff changeset
907 template_addr);
kono
parents:
diff changeset
908 thinptr_bound_field = TYPE_FIELDS (bounds_type);
kono
parents:
diff changeset
909 }
kono
parents:
diff changeset
910 else
kono
parents:
diff changeset
911 return false;
kono
parents:
diff changeset
912
kono
parents:
diff changeset
913 /* Second pass: compute the remaining information: dimensions and
kono
parents:
diff changeset
914 corresponding bounds. */
kono
parents:
diff changeset
915
kono
parents:
diff changeset
916 if (TYPE_PACKED (first_dimen))
kono
parents:
diff changeset
917 is_packed_array = true;
kono
parents:
diff changeset
918 /* If this array has fortran convention, it's arranged in column-major
kono
parents:
diff changeset
919 order, so our view here has reversed dimensions. */
kono
parents:
diff changeset
920 convention_fortran_p = TYPE_CONVENTION_FORTRAN_P (first_dimen);
kono
parents:
diff changeset
921 /* ??? For row major ordering, we probably want to emit nothing and
kono
parents:
diff changeset
922 instead specify it as the default in Dw_TAG_compile_unit. */
kono
parents:
diff changeset
923 info->ordering = (convention_fortran_p
kono
parents:
diff changeset
924 ? array_descr_ordering_column_major
kono
parents:
diff changeset
925 : array_descr_ordering_row_major);
kono
parents:
diff changeset
926
kono
parents:
diff changeset
927 /* Count how many dimensions this array has. */
kono
parents:
diff changeset
928 for (i = 0, dimen = first_dimen; ; ++i, dimen = TREE_TYPE (dimen))
kono
parents:
diff changeset
929 {
kono
parents:
diff changeset
930 if (i > 0
kono
parents:
diff changeset
931 && (TREE_CODE (dimen) != ARRAY_TYPE
kono
parents:
diff changeset
932 || !TYPE_MULTI_ARRAY_P (dimen)))
kono
parents:
diff changeset
933 break;
kono
parents:
diff changeset
934 last_dimen = dimen;
kono
parents:
diff changeset
935 }
kono
parents:
diff changeset
936
kono
parents:
diff changeset
937 info->ndimensions = i;
kono
parents:
diff changeset
938 info->rank = NULL_TREE;
kono
parents:
diff changeset
939
kono
parents:
diff changeset
940 /* Too many dimensions? Give up generating proper description: yield instead
kono
parents:
diff changeset
941 nested arrays. Note that in this case, this hook is invoked once on each
kono
parents:
diff changeset
942 intermediate array type: be consistent and output nested arrays for all
kono
parents:
diff changeset
943 dimensions. */
kono
parents:
diff changeset
944 if (info->ndimensions > DWARF2OUT_ARRAY_DESCR_INFO_MAX_DIMEN
kono
parents:
diff changeset
945 || TYPE_MULTI_ARRAY_P (first_dimen))
kono
parents:
diff changeset
946 {
kono
parents:
diff changeset
947 info->ndimensions = 1;
kono
parents:
diff changeset
948 last_dimen = first_dimen;
kono
parents:
diff changeset
949 }
kono
parents:
diff changeset
950
kono
parents:
diff changeset
951 info->element_type = TREE_TYPE (last_dimen);
kono
parents:
diff changeset
952
kono
parents:
diff changeset
953 /* Now iterate over all dimensions in source-order and fill the info
kono
parents:
diff changeset
954 structure. */
kono
parents:
diff changeset
955 for (i = (convention_fortran_p ? info->ndimensions - 1 : 0),
kono
parents:
diff changeset
956 dimen = first_dimen;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
957 IN_RANGE (i, 0, info->ndimensions - 1);
111
kono
parents:
diff changeset
958 i += (convention_fortran_p ? -1 : 1),
kono
parents:
diff changeset
959 dimen = TREE_TYPE (dimen))
kono
parents:
diff changeset
960 {
kono
parents:
diff changeset
961 /* We are interested in the stored bounds for the debug info. */
kono
parents:
diff changeset
962 tree index_type = TYPE_INDEX_TYPE (TYPE_DOMAIN (dimen));
kono
parents:
diff changeset
963
kono
parents:
diff changeset
964 if (is_array || is_fat_ptr)
kono
parents:
diff changeset
965 {
kono
parents:
diff changeset
966 /* GDB does not handle very well the self-referencial bound
kono
parents:
diff changeset
967 expressions we are able to generate here for XUA types (they are
kono
parents:
diff changeset
968 used only by XUP encodings) so avoid them in this case. Note that
kono
parents:
diff changeset
969 there are two cases where we generate self-referencial bound
kono
parents:
diff changeset
970 expressions: arrays that are constrained by record discriminants
kono
parents:
diff changeset
971 and XUA types. */
kono
parents:
diff changeset
972 if (TYPE_CONTEXT (first_dimen)
kono
parents:
diff changeset
973 && TREE_CODE (TYPE_CONTEXT (first_dimen)) != RECORD_TYPE
kono
parents:
diff changeset
974 && CONTAINS_PLACEHOLDER_P (TYPE_MIN_VALUE (index_type))
kono
parents:
diff changeset
975 && gnat_encodings != DWARF_GNAT_ENCODINGS_MINIMAL)
kono
parents:
diff changeset
976 {
kono
parents:
diff changeset
977 info->dimen[i].lower_bound = NULL_TREE;
kono
parents:
diff changeset
978 info->dimen[i].upper_bound = NULL_TREE;
kono
parents:
diff changeset
979 }
kono
parents:
diff changeset
980 else
kono
parents:
diff changeset
981 {
kono
parents:
diff changeset
982 info->dimen[i].lower_bound
kono
parents:
diff changeset
983 = maybe_character_value (TYPE_MIN_VALUE (index_type));
kono
parents:
diff changeset
984 info->dimen[i].upper_bound
kono
parents:
diff changeset
985 = maybe_character_value (TYPE_MAX_VALUE (index_type));
kono
parents:
diff changeset
986 }
kono
parents:
diff changeset
987 }
kono
parents:
diff changeset
988
kono
parents:
diff changeset
989 /* This is a thin pointer. */
kono
parents:
diff changeset
990 else
kono
parents:
diff changeset
991 {
kono
parents:
diff changeset
992 info->dimen[i].lower_bound
kono
parents:
diff changeset
993 = build_component_ref (thinptr_template_expr, thinptr_bound_field,
kono
parents:
diff changeset
994 false);
kono
parents:
diff changeset
995 thinptr_bound_field = DECL_CHAIN (thinptr_bound_field);
kono
parents:
diff changeset
996
kono
parents:
diff changeset
997 info->dimen[i].upper_bound
kono
parents:
diff changeset
998 = build_component_ref (thinptr_template_expr, thinptr_bound_field,
kono
parents:
diff changeset
999 false);
kono
parents:
diff changeset
1000 thinptr_bound_field = DECL_CHAIN (thinptr_bound_field);
kono
parents:
diff changeset
1001 }
kono
parents:
diff changeset
1002
kono
parents:
diff changeset
1003 /* The DWARF back-end will output BOUNDS_TYPE as the base type of
kono
parents:
diff changeset
1004 the array index, so get to the base type of INDEX_TYPE. */
kono
parents:
diff changeset
1005 while (TREE_TYPE (index_type))
kono
parents:
diff changeset
1006 index_type = TREE_TYPE (index_type);
kono
parents:
diff changeset
1007
kono
parents:
diff changeset
1008 info->dimen[i].bounds_type = maybe_debug_type (index_type);
kono
parents:
diff changeset
1009 info->dimen[i].stride = NULL_TREE;
kono
parents:
diff changeset
1010 }
kono
parents:
diff changeset
1011
kono
parents:
diff changeset
1012 /* These are Fortran-specific fields. They make no sense here. */
kono
parents:
diff changeset
1013 info->allocated = NULL_TREE;
kono
parents:
diff changeset
1014 info->associated = NULL_TREE;
kono
parents:
diff changeset
1015
kono
parents:
diff changeset
1016 if (gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
kono
parents:
diff changeset
1017 {
kono
parents:
diff changeset
1018 /* When arrays contain dynamically-sized elements, we usually wrap them
kono
parents:
diff changeset
1019 in padding types, or we create constrained types for them. Then, if
kono
parents:
diff changeset
1020 such types are stripped in the debugging information output, the
kono
parents:
diff changeset
1021 debugger needs a way to know the size that is reserved for each
kono
parents:
diff changeset
1022 element. This is why we emit a stride in such situations. */
kono
parents:
diff changeset
1023 tree source_element_type = info->element_type;
kono
parents:
diff changeset
1024
kono
parents:
diff changeset
1025 while (true)
kono
parents:
diff changeset
1026 {
kono
parents:
diff changeset
1027 if (TYPE_DEBUG_TYPE (source_element_type))
kono
parents:
diff changeset
1028 source_element_type = TYPE_DEBUG_TYPE (source_element_type);
kono
parents:
diff changeset
1029 else if (TYPE_IS_PADDING_P (source_element_type))
kono
parents:
diff changeset
1030 source_element_type
kono
parents:
diff changeset
1031 = TREE_TYPE (TYPE_FIELDS (source_element_type));
kono
parents:
diff changeset
1032 else
kono
parents:
diff changeset
1033 break;
kono
parents:
diff changeset
1034 }
kono
parents:
diff changeset
1035
kono
parents:
diff changeset
1036 if (TREE_CODE (TYPE_SIZE_UNIT (source_element_type)) != INTEGER_CST)
kono
parents:
diff changeset
1037 {
kono
parents:
diff changeset
1038 info->stride = TYPE_SIZE_UNIT (info->element_type);
kono
parents:
diff changeset
1039 info->stride_in_bits = false;
kono
parents:
diff changeset
1040 }
kono
parents:
diff changeset
1041
kono
parents:
diff changeset
1042 /* We need to specify a bit stride when it does not correspond to the
kono
parents:
diff changeset
1043 natural size of the contained elements. ??? Note that we do not
kono
parents:
diff changeset
1044 support packed records and nested packed arrays. */
kono
parents:
diff changeset
1045 else if (is_packed_array)
kono
parents:
diff changeset
1046 {
kono
parents:
diff changeset
1047 info->stride = get_array_bit_stride (info->element_type);
kono
parents:
diff changeset
1048 info->stride_in_bits = true;
kono
parents:
diff changeset
1049 }
kono
parents:
diff changeset
1050 }
kono
parents:
diff changeset
1051
kono
parents:
diff changeset
1052 return true;
kono
parents:
diff changeset
1053 }
kono
parents:
diff changeset
1054
kono
parents:
diff changeset
1055 /* Given the component type COMP_TYPE of a packed array, return an expression
kono
parents:
diff changeset
1056 that computes the bit stride of this packed array. Return NULL_TREE when
kono
parents:
diff changeset
1057 unsuccessful. */
kono
parents:
diff changeset
1058
kono
parents:
diff changeset
1059 static tree
kono
parents:
diff changeset
1060 get_array_bit_stride (tree comp_type)
kono
parents:
diff changeset
1061 {
kono
parents:
diff changeset
1062 struct array_descr_info info;
kono
parents:
diff changeset
1063 tree stride;
kono
parents:
diff changeset
1064
kono
parents:
diff changeset
1065 /* Simple case: the array contains an integral type: return its RM size. */
kono
parents:
diff changeset
1066 if (INTEGRAL_TYPE_P (comp_type))
kono
parents:
diff changeset
1067 return TYPE_RM_SIZE (comp_type);
kono
parents:
diff changeset
1068
kono
parents:
diff changeset
1069 /* Otherwise, see if this is an array we can analyze; if it's not, punt. */
kono
parents:
diff changeset
1070 memset (&info, 0, sizeof (info));
kono
parents:
diff changeset
1071 if (!gnat_get_array_descr_info (comp_type, &info) || !info.stride)
kono
parents:
diff changeset
1072 return NULL_TREE;
kono
parents:
diff changeset
1073
kono
parents:
diff changeset
1074 /* Otherwise, the array stride is the inner array's stride multiplied by the
kono
parents:
diff changeset
1075 number of elements it contains. Note that if the inner array is not
kono
parents:
diff changeset
1076 packed, then the stride is "natural" and thus does not deserve an
kono
parents:
diff changeset
1077 attribute. */
kono
parents:
diff changeset
1078 stride = info.stride;
kono
parents:
diff changeset
1079 if (!info.stride_in_bits)
kono
parents:
diff changeset
1080 {
kono
parents:
diff changeset
1081 stride = fold_convert (bitsizetype, stride);
kono
parents:
diff changeset
1082 stride = build_binary_op (MULT_EXPR, bitsizetype,
kono
parents:
diff changeset
1083 stride, build_int_cst (bitsizetype, 8));
kono
parents:
diff changeset
1084 }
kono
parents:
diff changeset
1085
kono
parents:
diff changeset
1086 for (int i = 0; i < info.ndimensions; ++i)
kono
parents:
diff changeset
1087 {
kono
parents:
diff changeset
1088 tree count;
kono
parents:
diff changeset
1089
kono
parents:
diff changeset
1090 if (!info.dimen[i].lower_bound || !info.dimen[i].upper_bound)
kono
parents:
diff changeset
1091 return NULL_TREE;
kono
parents:
diff changeset
1092
kono
parents:
diff changeset
1093 /* Put in count an expression that computes the length of this
kono
parents:
diff changeset
1094 dimension. */
kono
parents:
diff changeset
1095 count = build_binary_op (MINUS_EXPR, sbitsizetype,
kono
parents:
diff changeset
1096 fold_convert (sbitsizetype,
kono
parents:
diff changeset
1097 info.dimen[i].upper_bound),
kono
parents:
diff changeset
1098 fold_convert (sbitsizetype,
kono
parents:
diff changeset
1099 info.dimen[i].lower_bound)),
kono
parents:
diff changeset
1100 count = build_binary_op (PLUS_EXPR, sbitsizetype,
kono
parents:
diff changeset
1101 count, build_int_cst (sbitsizetype, 1));
kono
parents:
diff changeset
1102 count = build_binary_op (MAX_EXPR, sbitsizetype,
kono
parents:
diff changeset
1103 count,
kono
parents:
diff changeset
1104 build_int_cst (sbitsizetype, 0));
kono
parents:
diff changeset
1105 count = fold_convert (bitsizetype, count);
kono
parents:
diff changeset
1106 stride = build_binary_op (MULT_EXPR, bitsizetype, stride, count);
kono
parents:
diff changeset
1107 }
kono
parents:
diff changeset
1108
kono
parents:
diff changeset
1109 return stride;
kono
parents:
diff changeset
1110 }
kono
parents:
diff changeset
1111
kono
parents:
diff changeset
1112 /* GNU_TYPE is a subtype of an integral type. Set LOWVAL to the low bound
kono
parents:
diff changeset
1113 and HIGHVAL to the high bound, respectively. */
kono
parents:
diff changeset
1114
kono
parents:
diff changeset
1115 static void
kono
parents:
diff changeset
1116 gnat_get_subrange_bounds (const_tree gnu_type, tree *lowval, tree *highval)
kono
parents:
diff changeset
1117 {
kono
parents:
diff changeset
1118 *lowval = TYPE_MIN_VALUE (gnu_type);
kono
parents:
diff changeset
1119 *highval = TYPE_MAX_VALUE (gnu_type);
kono
parents:
diff changeset
1120 }
kono
parents:
diff changeset
1121
kono
parents:
diff changeset
1122 /* Return the bias of GNU_TYPE, if any. */
kono
parents:
diff changeset
1123
kono
parents:
diff changeset
1124 static tree
kono
parents:
diff changeset
1125 gnat_get_type_bias (const_tree gnu_type)
kono
parents:
diff changeset
1126 {
kono
parents:
diff changeset
1127 if (TREE_CODE (gnu_type) == INTEGER_TYPE
kono
parents:
diff changeset
1128 && TYPE_BIASED_REPRESENTATION_P (gnu_type)
kono
parents:
diff changeset
1129 && gnat_encodings == DWARF_GNAT_ENCODINGS_MINIMAL)
kono
parents:
diff changeset
1130 return TYPE_RM_MIN_VALUE (gnu_type);
kono
parents:
diff changeset
1131
kono
parents:
diff changeset
1132 return NULL_TREE;
kono
parents:
diff changeset
1133 }
kono
parents:
diff changeset
1134
kono
parents:
diff changeset
1135 /* GNU_TYPE is the type of a subprogram parameter. Determine if it should be
kono
parents:
diff changeset
1136 passed by reference by default. */
kono
parents:
diff changeset
1137
kono
parents:
diff changeset
1138 bool
kono
parents:
diff changeset
1139 default_pass_by_ref (tree gnu_type)
kono
parents:
diff changeset
1140 {
kono
parents:
diff changeset
1141 /* We pass aggregates by reference if they are sufficiently large for
kono
parents:
diff changeset
1142 their alignment. The ratio is somewhat arbitrary. We also pass by
kono
parents:
diff changeset
1143 reference if the target machine would either pass or return by
kono
parents:
diff changeset
1144 reference. Strictly speaking, we need only check the return if this
kono
parents:
diff changeset
1145 is an In Out parameter, but it's probably best to err on the side of
kono
parents:
diff changeset
1146 passing more things by reference. */
kono
parents:
diff changeset
1147
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1148 if (AGGREGATE_TYPE_P (gnu_type)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1149 && (!valid_constant_size_p (TYPE_SIZE_UNIT (gnu_type))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1150 || compare_tree_int (TYPE_SIZE_UNIT (gnu_type),
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1151 TYPE_ALIGN (gnu_type)) > 0))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1152 return true;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1153
111
kono
parents:
diff changeset
1154 if (pass_by_reference (NULL, TYPE_MODE (gnu_type), gnu_type, true))
kono
parents:
diff changeset
1155 return true;
kono
parents:
diff changeset
1156
kono
parents:
diff changeset
1157 if (targetm.calls.return_in_memory (gnu_type, NULL_TREE))
kono
parents:
diff changeset
1158 return true;
kono
parents:
diff changeset
1159
kono
parents:
diff changeset
1160 return false;
kono
parents:
diff changeset
1161 }
kono
parents:
diff changeset
1162
kono
parents:
diff changeset
1163 /* GNU_TYPE is the type of a subprogram parameter. Determine if it must be
kono
parents:
diff changeset
1164 passed by reference. */
kono
parents:
diff changeset
1165
kono
parents:
diff changeset
1166 bool
kono
parents:
diff changeset
1167 must_pass_by_ref (tree gnu_type)
kono
parents:
diff changeset
1168 {
kono
parents:
diff changeset
1169 /* We pass only unconstrained objects, those required by the language
kono
parents:
diff changeset
1170 to be passed by reference, and objects of variable size. The latter
kono
parents:
diff changeset
1171 is more efficient, avoids problems with variable size temporaries,
kono
parents:
diff changeset
1172 and does not produce compatibility problems with C, since C does
kono
parents:
diff changeset
1173 not have such objects. */
kono
parents:
diff changeset
1174 return (TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE
kono
parents:
diff changeset
1175 || TYPE_IS_BY_REFERENCE_P (gnu_type)
kono
parents:
diff changeset
1176 || (TYPE_SIZE_UNIT (gnu_type)
kono
parents:
diff changeset
1177 && TREE_CODE (TYPE_SIZE_UNIT (gnu_type)) != INTEGER_CST));
kono
parents:
diff changeset
1178 }
kono
parents:
diff changeset
1179
kono
parents:
diff changeset
1180 /* This function is called by the front-end to enumerate all the supported
kono
parents:
diff changeset
1181 modes for the machine, as well as some predefined C types. F is a function
kono
parents:
diff changeset
1182 which is called back with the parameters as listed below, first a string,
kono
parents:
diff changeset
1183 then seven ints. The name is any arbitrary null-terminated string and has
kono
parents:
diff changeset
1184 no particular significance, except for the case of predefined C types, where
kono
parents:
diff changeset
1185 it should be the name of the C type. For integer types, only signed types
kono
parents:
diff changeset
1186 should be listed, unsigned versions are assumed. The order of types should
kono
parents:
diff changeset
1187 be in order of preference, with the smallest/cheapest types first.
kono
parents:
diff changeset
1188
kono
parents:
diff changeset
1189 In particular, C predefined types should be listed before other types,
kono
parents:
diff changeset
1190 binary floating point types before decimal ones, and narrower/cheaper
kono
parents:
diff changeset
1191 type versions before more expensive ones. In type selection the first
kono
parents:
diff changeset
1192 matching variant will be used.
kono
parents:
diff changeset
1193
kono
parents:
diff changeset
1194 NAME pointer to first char of type name
kono
parents:
diff changeset
1195 DIGS number of decimal digits for floating-point modes, else 0
kono
parents:
diff changeset
1196 COMPLEX_P nonzero is this represents a complex mode
kono
parents:
diff changeset
1197 COUNT count of number of items, nonzero for vector mode
kono
parents:
diff changeset
1198 FLOAT_REP Float_Rep_Kind for FP, otherwise undefined
kono
parents:
diff changeset
1199 PRECISION number of bits used to store data
kono
parents:
diff changeset
1200 SIZE number of bits occupied by the mode
kono
parents:
diff changeset
1201 ALIGN number of bits to which mode is aligned. */
kono
parents:
diff changeset
1202
kono
parents:
diff changeset
1203 void
kono
parents:
diff changeset
1204 enumerate_modes (void (*f) (const char *, int, int, int, int, int, int, int))
kono
parents:
diff changeset
1205 {
kono
parents:
diff changeset
1206 const tree c_types[]
kono
parents:
diff changeset
1207 = { float_type_node, double_type_node, long_double_type_node };
kono
parents:
diff changeset
1208 const char *const c_names[]
kono
parents:
diff changeset
1209 = { "float", "double", "long double" };
kono
parents:
diff changeset
1210 int iloop;
kono
parents:
diff changeset
1211
kono
parents:
diff changeset
1212 /* We are going to compute it below. */
kono
parents:
diff changeset
1213 fp_arith_may_widen = false;
kono
parents:
diff changeset
1214
kono
parents:
diff changeset
1215 for (iloop = 0; iloop < NUM_MACHINE_MODES; iloop++)
kono
parents:
diff changeset
1216 {
kono
parents:
diff changeset
1217 machine_mode i = (machine_mode) iloop;
kono
parents:
diff changeset
1218 machine_mode inner_mode = i;
kono
parents:
diff changeset
1219 bool float_p = false;
kono
parents:
diff changeset
1220 bool complex_p = false;
kono
parents:
diff changeset
1221 bool vector_p = false;
kono
parents:
diff changeset
1222 bool skip_p = false;
kono
parents:
diff changeset
1223 int digs = 0;
kono
parents:
diff changeset
1224 unsigned int nameloop;
kono
parents:
diff changeset
1225 Float_Rep_Kind float_rep = IEEE_Binary; /* Until proven otherwise */
kono
parents:
diff changeset
1226
kono
parents:
diff changeset
1227 switch (GET_MODE_CLASS (i))
kono
parents:
diff changeset
1228 {
kono
parents:
diff changeset
1229 case MODE_INT:
kono
parents:
diff changeset
1230 break;
kono
parents:
diff changeset
1231 case MODE_FLOAT:
kono
parents:
diff changeset
1232 float_p = true;
kono
parents:
diff changeset
1233 break;
kono
parents:
diff changeset
1234 case MODE_COMPLEX_INT:
kono
parents:
diff changeset
1235 complex_p = true;
kono
parents:
diff changeset
1236 inner_mode = GET_MODE_INNER (i);
kono
parents:
diff changeset
1237 break;
kono
parents:
diff changeset
1238 case MODE_COMPLEX_FLOAT:
kono
parents:
diff changeset
1239 float_p = true;
kono
parents:
diff changeset
1240 complex_p = true;
kono
parents:
diff changeset
1241 inner_mode = GET_MODE_INNER (i);
kono
parents:
diff changeset
1242 break;
kono
parents:
diff changeset
1243 case MODE_VECTOR_INT:
kono
parents:
diff changeset
1244 vector_p = true;
kono
parents:
diff changeset
1245 inner_mode = GET_MODE_INNER (i);
kono
parents:
diff changeset
1246 break;
kono
parents:
diff changeset
1247 case MODE_VECTOR_FLOAT:
kono
parents:
diff changeset
1248 float_p = true;
kono
parents:
diff changeset
1249 vector_p = true;
kono
parents:
diff changeset
1250 inner_mode = GET_MODE_INNER (i);
kono
parents:
diff changeset
1251 break;
kono
parents:
diff changeset
1252 default:
kono
parents:
diff changeset
1253 skip_p = true;
kono
parents:
diff changeset
1254 }
kono
parents:
diff changeset
1255
kono
parents:
diff changeset
1256 if (float_p)
kono
parents:
diff changeset
1257 {
kono
parents:
diff changeset
1258 const struct real_format *fmt = REAL_MODE_FORMAT (inner_mode);
kono
parents:
diff changeset
1259
kono
parents:
diff changeset
1260 /* ??? Cope with the ghost XFmode of the ARM port. */
kono
parents:
diff changeset
1261 if (!fmt)
kono
parents:
diff changeset
1262 continue;
kono
parents:
diff changeset
1263
kono
parents:
diff changeset
1264 /* Be conservative and consider that floating-point arithmetics may
kono
parents:
diff changeset
1265 use wider intermediate results as soon as there is an extended
kono
parents:
diff changeset
1266 Motorola or Intel mode supported by the machine. */
kono
parents:
diff changeset
1267 if (fmt == &ieee_extended_motorola_format
kono
parents:
diff changeset
1268 || fmt == &ieee_extended_intel_96_format
kono
parents:
diff changeset
1269 || fmt == &ieee_extended_intel_96_round_53_format
kono
parents:
diff changeset
1270 || fmt == &ieee_extended_intel_128_format)
kono
parents:
diff changeset
1271 {
kono
parents:
diff changeset
1272 #ifdef TARGET_FPMATH_DEFAULT
kono
parents:
diff changeset
1273 if (TARGET_FPMATH_DEFAULT == FPMATH_387)
kono
parents:
diff changeset
1274 #endif
kono
parents:
diff changeset
1275 fp_arith_may_widen = true;
kono
parents:
diff changeset
1276 }
kono
parents:
diff changeset
1277
kono
parents:
diff changeset
1278 if (fmt->b == 2)
kono
parents:
diff changeset
1279 digs = (fmt->p - 1) * 1233 / 4096; /* scale by log (2) */
kono
parents:
diff changeset
1280
kono
parents:
diff changeset
1281 else if (fmt->b == 10)
kono
parents:
diff changeset
1282 digs = fmt->p;
kono
parents:
diff changeset
1283
kono
parents:
diff changeset
1284 else
kono
parents:
diff changeset
1285 gcc_unreachable ();
kono
parents:
diff changeset
1286 }
kono
parents:
diff changeset
1287
kono
parents:
diff changeset
1288 /* First register any C types for this mode that the front end
kono
parents:
diff changeset
1289 may need to know about, unless the mode should be skipped. */
kono
parents:
diff changeset
1290 if (!skip_p && !vector_p)
kono
parents:
diff changeset
1291 for (nameloop = 0; nameloop < ARRAY_SIZE (c_types); nameloop++)
kono
parents:
diff changeset
1292 {
kono
parents:
diff changeset
1293 tree type = c_types[nameloop];
kono
parents:
diff changeset
1294 const char *name = c_names[nameloop];
kono
parents:
diff changeset
1295
kono
parents:
diff changeset
1296 if (TYPE_MODE (type) == i)
kono
parents:
diff changeset
1297 {
kono
parents:
diff changeset
1298 f (name, digs, complex_p, 0, float_rep, TYPE_PRECISION (type),
kono
parents:
diff changeset
1299 TREE_INT_CST_LOW (TYPE_SIZE (type)), TYPE_ALIGN (type));
kono
parents:
diff changeset
1300 skip_p = true;
kono
parents:
diff changeset
1301 }
kono
parents:
diff changeset
1302 }
kono
parents:
diff changeset
1303
kono
parents:
diff changeset
1304 /* If no predefined C types were found, register the mode itself. */
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1305 int nunits, precision, bitsize;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1306 if (!skip_p
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1307 && GET_MODE_NUNITS (i).is_constant (&nunits)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1308 && GET_MODE_PRECISION (i).is_constant (&precision)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1309 && GET_MODE_BITSIZE (i).is_constant (&bitsize))
111
kono
parents:
diff changeset
1310 f (GET_MODE_NAME (i), digs, complex_p,
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1311 vector_p ? nunits : 0, float_rep,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1312 precision, bitsize, GET_MODE_ALIGNMENT (i));
111
kono
parents:
diff changeset
1313 }
kono
parents:
diff changeset
1314 }
kono
parents:
diff changeset
1315
kono
parents:
diff changeset
1316 /* Return the size of the FP mode with precision PREC. */
kono
parents:
diff changeset
1317
kono
parents:
diff changeset
1318 int
kono
parents:
diff changeset
1319 fp_prec_to_size (int prec)
kono
parents:
diff changeset
1320 {
kono
parents:
diff changeset
1321 opt_scalar_float_mode opt_mode;
kono
parents:
diff changeset
1322
kono
parents:
diff changeset
1323 FOR_EACH_MODE_IN_CLASS (opt_mode, MODE_FLOAT)
kono
parents:
diff changeset
1324 {
kono
parents:
diff changeset
1325 scalar_float_mode mode = opt_mode.require ();
kono
parents:
diff changeset
1326 if (GET_MODE_PRECISION (mode) == prec)
kono
parents:
diff changeset
1327 return GET_MODE_BITSIZE (mode);
kono
parents:
diff changeset
1328 }
kono
parents:
diff changeset
1329
kono
parents:
diff changeset
1330 gcc_unreachable ();
kono
parents:
diff changeset
1331 }
kono
parents:
diff changeset
1332
kono
parents:
diff changeset
1333 /* Return the precision of the FP mode with size SIZE. */
kono
parents:
diff changeset
1334
kono
parents:
diff changeset
1335 int
kono
parents:
diff changeset
1336 fp_size_to_prec (int size)
kono
parents:
diff changeset
1337 {
kono
parents:
diff changeset
1338 opt_scalar_float_mode opt_mode;
kono
parents:
diff changeset
1339
kono
parents:
diff changeset
1340 FOR_EACH_MODE_IN_CLASS (opt_mode, MODE_FLOAT)
kono
parents:
diff changeset
1341 {
kono
parents:
diff changeset
1342 scalar_mode mode = opt_mode.require ();
kono
parents:
diff changeset
1343 if (GET_MODE_BITSIZE (mode) == size)
kono
parents:
diff changeset
1344 return GET_MODE_PRECISION (mode);
kono
parents:
diff changeset
1345 }
kono
parents:
diff changeset
1346
kono
parents:
diff changeset
1347 gcc_unreachable ();
kono
parents:
diff changeset
1348 }
kono
parents:
diff changeset
1349
kono
parents:
diff changeset
1350 static GTY(()) tree gnat_eh_personality_decl;
kono
parents:
diff changeset
1351
kono
parents:
diff changeset
1352 /* Return the GNAT personality function decl. */
kono
parents:
diff changeset
1353
kono
parents:
diff changeset
1354 static tree
kono
parents:
diff changeset
1355 gnat_eh_personality (void)
kono
parents:
diff changeset
1356 {
kono
parents:
diff changeset
1357 if (!gnat_eh_personality_decl)
kono
parents:
diff changeset
1358 gnat_eh_personality_decl = build_personality_function ("gnat");
kono
parents:
diff changeset
1359 return gnat_eh_personality_decl;
kono
parents:
diff changeset
1360 }
kono
parents:
diff changeset
1361
kono
parents:
diff changeset
1362 /* Initialize language-specific bits of tree_contains_struct. */
kono
parents:
diff changeset
1363
kono
parents:
diff changeset
1364 static void
kono
parents:
diff changeset
1365 gnat_init_ts (void)
kono
parents:
diff changeset
1366 {
kono
parents:
diff changeset
1367 MARK_TS_COMMON (UNCONSTRAINED_ARRAY_TYPE);
kono
parents:
diff changeset
1368
kono
parents:
diff changeset
1369 MARK_TS_TYPED (UNCONSTRAINED_ARRAY_REF);
kono
parents:
diff changeset
1370 MARK_TS_TYPED (NULL_EXPR);
kono
parents:
diff changeset
1371 MARK_TS_TYPED (PLUS_NOMOD_EXPR);
kono
parents:
diff changeset
1372 MARK_TS_TYPED (MINUS_NOMOD_EXPR);
kono
parents:
diff changeset
1373 MARK_TS_TYPED (POWER_EXPR);
kono
parents:
diff changeset
1374 MARK_TS_TYPED (ATTR_ADDR_EXPR);
kono
parents:
diff changeset
1375 MARK_TS_TYPED (STMT_STMT);
kono
parents:
diff changeset
1376 MARK_TS_TYPED (LOOP_STMT);
kono
parents:
diff changeset
1377 MARK_TS_TYPED (EXIT_STMT);
kono
parents:
diff changeset
1378 }
kono
parents:
diff changeset
1379
kono
parents:
diff changeset
1380 /* Return the size of a tree with CODE, which is a language-specific tree code
kono
parents:
diff changeset
1381 in category tcc_constant, tcc_exceptional or tcc_type. The default expects
kono
parents:
diff changeset
1382 never to be called. */
kono
parents:
diff changeset
1383
kono
parents:
diff changeset
1384 static size_t
kono
parents:
diff changeset
1385 gnat_tree_size (enum tree_code code)
kono
parents:
diff changeset
1386 {
kono
parents:
diff changeset
1387 gcc_checking_assert (code >= NUM_TREE_CODES);
kono
parents:
diff changeset
1388 switch (code)
kono
parents:
diff changeset
1389 {
kono
parents:
diff changeset
1390 case UNCONSTRAINED_ARRAY_TYPE:
kono
parents:
diff changeset
1391 return sizeof (tree_type_non_common);
kono
parents:
diff changeset
1392 default:
kono
parents:
diff changeset
1393 gcc_unreachable ();
kono
parents:
diff changeset
1394 }
kono
parents:
diff changeset
1395 }
kono
parents:
diff changeset
1396
kono
parents:
diff changeset
1397 /* Return the lang specific structure attached to NODE. Allocate it (cleared)
kono
parents:
diff changeset
1398 if needed. */
kono
parents:
diff changeset
1399
kono
parents:
diff changeset
1400 struct lang_type *
kono
parents:
diff changeset
1401 get_lang_specific (tree node)
kono
parents:
diff changeset
1402 {
kono
parents:
diff changeset
1403 if (!TYPE_LANG_SPECIFIC (node))
kono
parents:
diff changeset
1404 TYPE_LANG_SPECIFIC (node) = ggc_cleared_alloc<struct lang_type> ();
kono
parents:
diff changeset
1405 return TYPE_LANG_SPECIFIC (node);
kono
parents:
diff changeset
1406 }
kono
parents:
diff changeset
1407
kono
parents:
diff changeset
1408 /* Definitions for our language-specific hooks. */
kono
parents:
diff changeset
1409
kono
parents:
diff changeset
1410 #undef LANG_HOOKS_NAME
kono
parents:
diff changeset
1411 #define LANG_HOOKS_NAME "GNU Ada"
kono
parents:
diff changeset
1412 #undef LANG_HOOKS_IDENTIFIER_SIZE
kono
parents:
diff changeset
1413 #define LANG_HOOKS_IDENTIFIER_SIZE sizeof (struct tree_identifier)
kono
parents:
diff changeset
1414 #undef LANG_HOOKS_TREE_SIZE
kono
parents:
diff changeset
1415 #define LANG_HOOKS_TREE_SIZE gnat_tree_size
kono
parents:
diff changeset
1416 #undef LANG_HOOKS_INIT
kono
parents:
diff changeset
1417 #define LANG_HOOKS_INIT gnat_init
kono
parents:
diff changeset
1418 #undef LANG_HOOKS_OPTION_LANG_MASK
kono
parents:
diff changeset
1419 #define LANG_HOOKS_OPTION_LANG_MASK gnat_option_lang_mask
kono
parents:
diff changeset
1420 #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
kono
parents:
diff changeset
1421 #define LANG_HOOKS_INIT_OPTIONS_STRUCT gnat_init_options_struct
kono
parents:
diff changeset
1422 #undef LANG_HOOKS_INIT_OPTIONS
kono
parents:
diff changeset
1423 #define LANG_HOOKS_INIT_OPTIONS gnat_init_options
kono
parents:
diff changeset
1424 #undef LANG_HOOKS_HANDLE_OPTION
kono
parents:
diff changeset
1425 #define LANG_HOOKS_HANDLE_OPTION gnat_handle_option
kono
parents:
diff changeset
1426 #undef LANG_HOOKS_POST_OPTIONS
kono
parents:
diff changeset
1427 #define LANG_HOOKS_POST_OPTIONS gnat_post_options
kono
parents:
diff changeset
1428 #undef LANG_HOOKS_PARSE_FILE
kono
parents:
diff changeset
1429 #define LANG_HOOKS_PARSE_FILE gnat_parse_file
kono
parents:
diff changeset
1430 #undef LANG_HOOKS_TYPE_HASH_EQ
kono
parents:
diff changeset
1431 #define LANG_HOOKS_TYPE_HASH_EQ gnat_type_hash_eq
kono
parents:
diff changeset
1432 #undef LANG_HOOKS_GETDECLS
kono
parents:
diff changeset
1433 #define LANG_HOOKS_GETDECLS hook_tree_void_null
kono
parents:
diff changeset
1434 #undef LANG_HOOKS_PUSHDECL
kono
parents:
diff changeset
1435 #define LANG_HOOKS_PUSHDECL gnat_return_tree
kono
parents:
diff changeset
1436 #undef LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL
kono
parents:
diff changeset
1437 #define LANG_HOOKS_WARN_UNUSED_GLOBAL_DECL hook_bool_const_tree_false
kono
parents:
diff changeset
1438 #undef LANG_HOOKS_GET_ALIAS_SET
kono
parents:
diff changeset
1439 #define LANG_HOOKS_GET_ALIAS_SET gnat_get_alias_set
kono
parents:
diff changeset
1440 #undef LANG_HOOKS_PRINT_DECL
kono
parents:
diff changeset
1441 #define LANG_HOOKS_PRINT_DECL gnat_print_decl
kono
parents:
diff changeset
1442 #undef LANG_HOOKS_PRINT_TYPE
kono
parents:
diff changeset
1443 #define LANG_HOOKS_PRINT_TYPE gnat_print_type
kono
parents:
diff changeset
1444 #undef LANG_HOOKS_TYPE_MAX_SIZE
kono
parents:
diff changeset
1445 #define LANG_HOOKS_TYPE_MAX_SIZE gnat_type_max_size
kono
parents:
diff changeset
1446 #undef LANG_HOOKS_DECL_PRINTABLE_NAME
kono
parents:
diff changeset
1447 #define LANG_HOOKS_DECL_PRINTABLE_NAME gnat_printable_name
kono
parents:
diff changeset
1448 #undef LANG_HOOKS_DWARF_NAME
kono
parents:
diff changeset
1449 #define LANG_HOOKS_DWARF_NAME gnat_dwarf_name
kono
parents:
diff changeset
1450 #undef LANG_HOOKS_GIMPLIFY_EXPR
kono
parents:
diff changeset
1451 #define LANG_HOOKS_GIMPLIFY_EXPR gnat_gimplify_expr
kono
parents:
diff changeset
1452 #undef LANG_HOOKS_TYPE_FOR_MODE
kono
parents:
diff changeset
1453 #define LANG_HOOKS_TYPE_FOR_MODE gnat_type_for_mode
kono
parents:
diff changeset
1454 #undef LANG_HOOKS_TYPE_FOR_SIZE
kono
parents:
diff changeset
1455 #define LANG_HOOKS_TYPE_FOR_SIZE gnat_type_for_size
kono
parents:
diff changeset
1456 #undef LANG_HOOKS_TYPES_COMPATIBLE_P
kono
parents:
diff changeset
1457 #define LANG_HOOKS_TYPES_COMPATIBLE_P gnat_types_compatible_p
kono
parents:
diff changeset
1458 #undef LANG_HOOKS_GET_ARRAY_DESCR_INFO
kono
parents:
diff changeset
1459 #define LANG_HOOKS_GET_ARRAY_DESCR_INFO gnat_get_array_descr_info
kono
parents:
diff changeset
1460 #undef LANG_HOOKS_GET_SUBRANGE_BOUNDS
kono
parents:
diff changeset
1461 #define LANG_HOOKS_GET_SUBRANGE_BOUNDS gnat_get_subrange_bounds
kono
parents:
diff changeset
1462 #undef LANG_HOOKS_GET_TYPE_BIAS
kono
parents:
diff changeset
1463 #define LANG_HOOKS_GET_TYPE_BIAS gnat_get_type_bias
kono
parents:
diff changeset
1464 #undef LANG_HOOKS_DESCRIPTIVE_TYPE
kono
parents:
diff changeset
1465 #define LANG_HOOKS_DESCRIPTIVE_TYPE gnat_descriptive_type
kono
parents:
diff changeset
1466 #undef LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE
kono
parents:
diff changeset
1467 #define LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE gnat_enum_underlying_base_type
kono
parents:
diff changeset
1468 #undef LANG_HOOKS_GET_DEBUG_TYPE
kono
parents:
diff changeset
1469 #define LANG_HOOKS_GET_DEBUG_TYPE gnat_get_debug_type
kono
parents:
diff changeset
1470 #undef LANG_HOOKS_GET_FIXED_POINT_TYPE_INFO
kono
parents:
diff changeset
1471 #define LANG_HOOKS_GET_FIXED_POINT_TYPE_INFO gnat_get_fixed_point_type_info
kono
parents:
diff changeset
1472 #undef LANG_HOOKS_ATTRIBUTE_TABLE
kono
parents:
diff changeset
1473 #define LANG_HOOKS_ATTRIBUTE_TABLE gnat_internal_attribute_table
kono
parents:
diff changeset
1474 #undef LANG_HOOKS_BUILTIN_FUNCTION
kono
parents:
diff changeset
1475 #define LANG_HOOKS_BUILTIN_FUNCTION gnat_builtin_function
kono
parents:
diff changeset
1476 #undef LANG_HOOKS_INIT_TS
kono
parents:
diff changeset
1477 #define LANG_HOOKS_INIT_TS gnat_init_ts
kono
parents:
diff changeset
1478 #undef LANG_HOOKS_EH_PERSONALITY
kono
parents:
diff changeset
1479 #define LANG_HOOKS_EH_PERSONALITY gnat_eh_personality
kono
parents:
diff changeset
1480 #undef LANG_HOOKS_DEEP_UNSHARING
kono
parents:
diff changeset
1481 #define LANG_HOOKS_DEEP_UNSHARING true
kono
parents:
diff changeset
1482 #undef LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS
kono
parents:
diff changeset
1483 #define LANG_HOOKS_CUSTOM_FUNCTION_DESCRIPTORS true
kono
parents:
diff changeset
1484
kono
parents:
diff changeset
1485 struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
kono
parents:
diff changeset
1486
kono
parents:
diff changeset
1487 #include "gt-ada-misc.h"