Branch data Line data Source code
1 : : /* gm2-lang.cc language-dependent hooks for GNU Modula-2.
2 : :
3 : : Copyright (C) 2002-2024 Free Software Foundation, Inc.
4 : : Contributed by Gaius Mulley <gaius@glam.ac.uk>.
5 : :
6 : : This file is part of GNU Modula-2.
7 : :
8 : : GNU Modula-2 is free software; you can redistribute it and/or modify
9 : : it under the terms of the GNU General Public License as published by
10 : : the Free Software Foundation; either version 3, or (at your option)
11 : : any later version.
12 : :
13 : : GNU Modula-2 is distributed in the hope that it will be useful, but
14 : : WITHOUT ANY WARRANTY; without even the implied warranty of
15 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 : : General Public License for more details.
17 : :
18 : : You should have received a copy of the GNU General Public License
19 : : along with GNU Modula-2; see the file COPYING. If not, write to the
20 : : Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
21 : : 02110-1301, USA. */
22 : :
23 : : #define INCLUDE_VECTOR
24 : : #include "gm2-gcc/gcc-consolidation.h"
25 : :
26 : : #include "langhooks-def.h" /* FIXME: for lhd_set_decl_assembler_name. */
27 : : #include "tree-pass.h" /* FIXME: only for PROP_gimple_any. */
28 : : #include "toplev.h"
29 : : #include "debug.h"
30 : :
31 : : #include "opts.h"
32 : :
33 : : #define GM2_LANG_C
34 : : #include "gm2-lang.h"
35 : : #include "m2block.h"
36 : : #include "dynamicstrings.h"
37 : : #include "m2options.h"
38 : : #include "m2convert.h"
39 : : #include "m2linemap.h"
40 : : #include "init.h"
41 : : #include "m2-tree.h"
42 : : #include "convert.h"
43 : : #include "rtegraph.h"
44 : :
45 : : #undef ENABLE_QUAD_DUMP_ALL
46 : :
47 : : static void write_globals (void);
48 : :
49 : : static int insideCppArgs = FALSE;
50 : :
51 : : /* We default to pim in the absence of fiso. */
52 : : static bool iso = false;
53 : :
54 : 549961 : typedef struct named_path_s {
55 : : std::vector<const char*>path;
56 : : const char *name;
57 : : } named_path;
58 : :
59 : :
60 : : /* The language include paths are based on the libraries in use. */
61 : : static bool allow_libraries = true;
62 : : static const char *flibs = nullptr;
63 : : static const char *iprefix = nullptr;
64 : : static const char *imultilib = nullptr;
65 : : static std::vector<named_path>Ipaths;
66 : : static std::vector<const char*>isystem;
67 : : static std::vector<const char*>iquote;
68 : :
69 : : #define EXPR_STMT_EXPR(NODE) TREE_OPERAND (EXPR_STMT_CHECK (NODE), 0)
70 : :
71 : : /* start of new stuff. */
72 : :
73 : : /* Language-dependent contents of a type. */
74 : :
75 : : struct GTY (()) lang_type
76 : : {
77 : : char dummy;
78 : : };
79 : :
80 : : /* Language-dependent contents of a decl. */
81 : :
82 : : struct GTY (()) lang_decl
83 : : {
84 : : char dummy;
85 : : };
86 : :
87 : : /* Language-dependent contents of an identifier. This must include a
88 : : tree_identifier. */
89 : :
90 : : struct GTY (()) lang_identifier
91 : : {
92 : : struct tree_identifier common;
93 : : };
94 : :
95 : : /* The resulting tree type. */
96 : :
97 : : union GTY ((desc ("TREE_CODE (&%h.generic) == IDENTIFIER_NODE"),
98 : : chain_next ("CODE_CONTAINS_STRUCT (TREE_CODE (&%h.generic), "
99 : : "TS_COMMON) ? ((union lang_tree_node *) TREE_CHAIN "
100 : : "(&%h.generic)) : NULL"))) lang_tree_node
101 : : {
102 : : union tree_node GTY ((tag ("0"),
103 : : desc ("tree_node_structure (&%h)"))) generic;
104 : : struct lang_identifier GTY ((tag ("1"))) identifier;
105 : : };
106 : :
107 : : struct GTY (()) language_function
108 : : {
109 : :
110 : : /* While we are parsing the function, this contains information about
111 : : the statement-tree that we are building. */
112 : : /* struct stmt_tree_s stmt_tree; */
113 : : tree stmt_tree;
114 : : };
115 : :
116 : : /* Language hooks. */
117 : :
118 : : static void gm2_langhook_parse_file (void);
119 : :
120 : : bool
121 : 16867 : gm2_langhook_init (void)
122 : : {
123 : 16867 : build_common_tree_nodes (false);
124 : 16867 : build_common_builtin_nodes ();
125 : :
126 : : /* The default precision for floating point numbers. This is used
127 : : for floating point constants with abstract type. This may eventually
128 : : be controllable by a command line option. */
129 : 16867 : mpfr_set_default_prec (256);
130 : :
131 : : /* GNU Modula-2 uses exceptions. */
132 : 16867 : using_eh_for_cleanups ();
133 : :
134 : 16867 : if (M2Options_GetPPOnly ())
135 : : {
136 : : /* Preprocess the file here. */
137 : 0 : gm2_langhook_parse_file ();
138 : 0 : return false; /* Finish now, no further compilation. */
139 : : }
140 : : return true;
141 : : }
142 : :
143 : : /* The option mask. */
144 : :
145 : : static unsigned int
146 : 36415 : gm2_langhook_option_lang_mask (void)
147 : : {
148 : 36415 : return CL_ModulaX2;
149 : : }
150 : :
151 : : /* Initialize the options structure. */
152 : :
153 : : static void
154 : 16867 : gm2_langhook_init_options_struct (struct gcc_options *opts)
155 : : {
156 : : /* Default to avoiding range issues for complex multiply and divide. */
157 : 16867 : opts->x_flag_complex_method = 2;
158 : :
159 : : /* The builtin math functions should not set errno. */
160 : 16867 : opts->x_flag_errno_math = 0;
161 : 16867 : opts->frontend_set_flag_errno_math = true;
162 : :
163 : : /* Exceptions are used. */
164 : 16867 : opts->x_flag_exceptions = 1;
165 : 16867 : init_FrontEndInit ();
166 : 16867 : }
167 : :
168 : : /* Infrastructure for a VEC of bool values. */
169 : :
170 : : /* This array determines whether the filename is associated with the
171 : : C preprocessor. */
172 : :
173 : : static vec<bool> filename_cpp;
174 : :
175 : : /* Build the C preprocessor command line here, since we need to include
176 : : options that are not passed to the handle_option function. */
177 : :
178 : : void
179 : 16867 : gm2_langhook_init_options (unsigned int decoded_options_count,
180 : : struct cl_decoded_option *decoded_options)
181 : : {
182 : 16867 : unsigned int i;
183 : 16867 : bool in_cpp_args = false;
184 : 16867 : bool building_cpp_command = false;
185 : :
186 : 803845 : for (i = 1; i < decoded_options_count; i++)
187 : : {
188 : 786978 : enum opt_code code = (enum opt_code)decoded_options[i].opt_index;
189 : 786978 : const struct cl_option *option = &cl_options[code];
190 : 786978 : const char *opt = (const char *)option->opt_text;
191 : 786978 : const char *arg = decoded_options[i].arg;
192 : 786978 : HOST_WIDE_INT value = decoded_options[i].value;
193 : 786978 : switch (code)
194 : : {
195 : 438 : case OPT_fcpp:
196 : 438 : gcc_checking_assert (building_cpp_command);
197 : : break;
198 : 438 : case OPT_fcpp_begin:
199 : 438 : in_cpp_args = true;
200 : 438 : building_cpp_command = true;
201 : 438 : break;
202 : 438 : case OPT_fcpp_end:
203 : 438 : in_cpp_args = false;
204 : 438 : break;
205 : 17305 : case OPT_SPECIAL_input_file:
206 : 17305 : filename_cpp.safe_push (in_cpp_args);
207 : 17305 : break;
208 : :
209 : : /* C and driver opts that are not passed to the preprocessor for
210 : : modula-2, but that we use internally for building preprocesor
211 : : command lines. */
212 : 16867 : case OPT_B:
213 : 16867 : M2Options_SetB (arg);
214 : 16867 : break;
215 : 14485 : case OPT_c:
216 : 14485 : M2Options_Setc (value);
217 : 14485 : break;
218 : 11012 : case OPT_dumpdir:
219 : 11012 : M2Options_SetDumpDir (arg);
220 : 11012 : break;
221 : 0 : case OPT_save_temps:
222 : 0 : if (building_cpp_command)
223 : 0 : M2Options_SetSaveTemps (value);
224 : : break;
225 : 0 : case OPT_save_temps_:
226 : 0 : if (building_cpp_command)
227 : : /* Also sets SaveTemps. */
228 : 0 : M2Options_SetSaveTempsDir (arg);
229 : : break;
230 : :
231 : 438 : case OPT_E:
232 : 438 : if (!in_cpp_args)
233 : : {
234 : 0 : M2Options_SetPPOnly (value);
235 : 0 : building_cpp_command = true;
236 : : }
237 : 438 : M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
238 : 438 : && !(option->flags & CL_SEPARATE));
239 : 438 : break;
240 : :
241 : 0 : case OPT_M:
242 : : /* Output a rule suitable for make describing the dependencies of the
243 : : main source file. */
244 : 0 : if (in_cpp_args)
245 : : {
246 : 0 : gcc_checking_assert (building_cpp_command);
247 : : /* This is a preprocessor command. */
248 : 0 : M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
249 : 0 : && !(option->flags & CL_SEPARATE));
250 : : }
251 : 0 : M2Options_SetPPOnly (value);
252 : 0 : M2Options_SetM (value);
253 : 0 : break;
254 : :
255 : 0 : case OPT_MM:
256 : 0 : if (in_cpp_args)
257 : : {
258 : 0 : gcc_checking_assert (building_cpp_command);
259 : : /* This is a preprocessor command. */
260 : 0 : M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
261 : 0 : && !(option->flags & CL_SEPARATE));
262 : : }
263 : 0 : M2Options_SetPPOnly (value);
264 : 0 : M2Options_SetMM (value);
265 : 0 : break;
266 : :
267 : 0 : case OPT_MF:
268 : 0 : if (!in_cpp_args)
269 : 0 : M2Options_SetMF (arg);
270 : : break;
271 : :
272 : 0 : case OPT_MP:
273 : 0 : M2Options_SetMP (value);
274 : 0 : break;
275 : :
276 : : /* We can only use MQ and MT when the command line is either PP-only, or
277 : : when there is a MD/MMD on it. */
278 : 0 : case OPT_MQ:
279 : 0 : M2Options_SetMQ (arg);
280 : 0 : break;
281 : :
282 : 0 : case OPT_MT:
283 : 0 : M2Options_SetMT (arg);
284 : 0 : break;
285 : :
286 : 16867 : case OPT_o:
287 : 16867 : M2Options_SetObj (arg);
288 : 16867 : break;
289 : :
290 : : /* C and driver options that we ignore for the preprocessor lines. */
291 : : case OPT_fpch_deps:
292 : : case OPT_fpch_preprocess:
293 : : break;
294 : :
295 : : case OPT_fplugin_:
296 : : /* FIXME: We might need to handle this specially, since the modula-2
297 : : plugin is not usable here, but others might be.
298 : : For now skip all plugins to avoid fails with the m2 one. */
299 : : break;
300 : :
301 : : /* Preprocessor arguments with a following filename. */
302 : 0 : case OPT_MD:
303 : 0 : M2Options_SetMD (value);
304 : 0 : if (value)
305 : : {
306 : 0 : M2Options_SetM (true);
307 : 0 : M2Options_SetMF (arg);
308 : : }
309 : : break;
310 : :
311 : 0 : case OPT_MMD:
312 : 0 : M2Options_SetMMD (value);
313 : 0 : if (value)
314 : : {
315 : 0 : M2Options_SetMM (true);
316 : 0 : M2Options_SetMF (arg);
317 : : }
318 : : break;
319 : :
320 : : /* Modula 2 claimed options we pass to the preprocessor. */
321 : 876 : case OPT_ansi:
322 : 876 : case OPT_traditional_cpp:
323 : 876 : if (building_cpp_command)
324 : 876 : M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
325 : 876 : && !(option->flags & CL_SEPARATE));
326 : : break;
327 : :
328 : : /* Options we act on and also pass to the preprocessor. */
329 : 6810 : case OPT_O:
330 : 6810 : M2Options_SetOptimizing (value);
331 : 6810 : if (building_cpp_command)
332 : 292 : M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
333 : 292 : && !(option->flags & CL_SEPARATE));
334 : : break;
335 : 17305 : case OPT_quiet:
336 : 17305 : M2Options_SetQuiet (value);
337 : 17305 : if (building_cpp_command)
338 : 876 : M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
339 : 876 : && !(option->flags & CL_SEPARATE));
340 : : break;
341 : 0 : case OPT_v:
342 : 0 : M2Options_SetVerbose (value);
343 : : /* FALLTHROUGH */
344 : 683593 : default:
345 : : /* We handled input files above. */
346 : 683593 : if (code >= N_OPTS)
347 : : break;
348 : : /* Do not pass Modula-2 args to the preprocessor, any that we care
349 : : about here should already have been handled above. */
350 : 683593 : if (option->flags & CL_ModulaX2)
351 : : break;
352 : : /* Otherwise, add this to the CPP command line. */
353 : 176370 : if (building_cpp_command)
354 : 4380 : M2Options_CppArg (opt, arg, (option->flags & CL_JOINED)
355 : 4380 : && !(option->flags & CL_SEPARATE));
356 : : break;
357 : : }
358 : : }
359 : 16867 : filename_cpp.safe_push (false);
360 : 16867 : }
361 : :
362 : : static bool
363 : 17305 : is_cpp_filename (unsigned int i)
364 : : {
365 : 17305 : gcc_assert (i < filename_cpp.length ());
366 : 17305 : return filename_cpp[i];
367 : : }
368 : :
369 : : static void
370 : 231198 : push_back_Ipath (const char *arg)
371 : : {
372 : 231198 : if (Ipaths.empty ())
373 : : {
374 : 16867 : named_path np;
375 : 16867 : np.path.push_back (arg);
376 : 16867 : np.name = xstrdup (M2Options_GetM2PathName ());
377 : 16867 : Ipaths.push_back (np);
378 : 16867 : }
379 : : else
380 : : {
381 : 214331 : if (strcmp (Ipaths.back ().name,
382 : 214331 : M2Options_GetM2PathName ()) == 0)
383 : 66546 : Ipaths.back ().path.push_back (arg);
384 : : else
385 : : {
386 : 147785 : named_path np;
387 : 147785 : np.path.push_back (arg);
388 : 147785 : np.name = xstrdup (M2Options_GetM2PathName ());
389 : 147785 : Ipaths.push_back (np);
390 : 147785 : }
391 : : }
392 : 231198 : }
393 : :
394 : : /* Handle gm2 specific options. Return 0 if we didn't do anything. */
395 : :
396 : : bool
397 : 541222 : gm2_langhook_handle_option (
398 : : size_t scode, const char *arg, HOST_WIDE_INT value, int kind ATTRIBUTE_UNUSED,
399 : : location_t loc ATTRIBUTE_UNUSED,
400 : : const struct cl_option_handlers *handlers ATTRIBUTE_UNUSED)
401 : : {
402 : 541222 : enum opt_code code = (enum opt_code)scode;
403 : :
404 : 541222 : const struct cl_option *option = &cl_options[scode];
405 : : /* ignore file names. */
406 : 541222 : if (code == N_OPTS)
407 : : return 1;
408 : :
409 : 541222 : switch (code)
410 : : {
411 : 0 : case OPT_dumpdir:
412 : 0 : M2Options_SetDumpDir (arg);
413 : 0 : return 1;
414 : 0 : case OPT_I:
415 : 0 : push_back_Ipath (arg);
416 : 0 : return 1;
417 : 3168 : case OPT_fiso:
418 : 3168 : M2Options_SetISO (value);
419 : 3168 : iso = value;
420 : 3168 : return 1;
421 : 13247 : case OPT_fpim:
422 : 13247 : M2Options_SetPIM (value);
423 : 13247 : iso = value ? false : iso;
424 : 13247 : return 1;
425 : 86 : case OPT_fpim2:
426 : 86 : M2Options_SetPIM2 (value);
427 : 86 : iso = value ? false : iso;
428 : 86 : return 1;
429 : 12 : case OPT_fpim3:
430 : 12 : M2Options_SetPIM3 (value);
431 : 12 : iso = value ? false : iso;
432 : 12 : return 1;
433 : 66 : case OPT_fpim4:
434 : 66 : M2Options_SetPIM4 (value);
435 : 66 : iso = value ? false : iso;
436 : 66 : return 1;
437 : 0 : case OPT_fpositive_mod_floor_div:
438 : 0 : M2Options_SetPositiveModFloor (value);
439 : 0 : return 1;
440 : 16867 : case OPT_flibs_:
441 : 16867 : allow_libraries = value;
442 : 16867 : flibs = arg;
443 : 16867 : return 1;
444 : 2372 : case OPT_fgen_module_list_:
445 : 2372 : M2Options_SetGenModuleList (value, arg);
446 : 2372 : return 1;
447 : 0 : case OPT_fnil:
448 : 0 : M2Options_SetNilCheck (value);
449 : 0 : return 1;
450 : 0 : case OPT_fwholediv:
451 : 0 : M2Options_SetWholeDiv (value);
452 : 0 : return 1;
453 : 0 : case OPT_findex:
454 : 0 : M2Options_SetIndex (value);
455 : 0 : return 1;
456 : 6 : case OPT_frange:
457 : 6 : M2Options_SetRange (value);
458 : 6 : return 1;
459 : 0 : case OPT_ffloatvalue:
460 : 0 : M2Options_SetFloatValueCheck (value);
461 : 0 : return 1;
462 : 0 : case OPT_fwholevalue:
463 : 0 : M2Options_SetWholeValueCheck (value);
464 : 0 : return 1;
465 : 0 : case OPT_freturn:
466 : 0 : M2Options_SetReturnCheck (value);
467 : 0 : return 1;
468 : 580 : case OPT_fcase:
469 : 580 : M2Options_SetCaseCheck (value);
470 : 580 : return 1;
471 : 0 : case OPT_fd:
472 : 0 : M2Options_SetCompilerDebugging (value);
473 : 0 : return 1;
474 : 0 : case OPT_fdebug_builtins:
475 : 0 : M2Options_SetDebugBuiltins (value);
476 : 0 : return 1;
477 : 0 : case OPT_fdebug_trace_quad:
478 : 0 : M2Options_SetDebugTraceQuad (value);
479 : 0 : return 1;
480 : 0 : case OPT_fdebug_trace_api:
481 : 0 : M2Options_SetDebugTraceAPI (value);
482 : 0 : return 1;
483 : 0 : case OPT_fdebug_function_line_numbers:
484 : 0 : M2Options_SetDebugFunctionLineNumbers (value);
485 : 0 : return 1;
486 : : #ifdef ENABLE_QUAD_DUMP_ALL
487 : : case OPT_fdump_lang_all:
488 : : M2Options_SetDumpLangDeclFilename (value, NULL);
489 : : M2Options_SetDumpLangGimpleFilename (value, NULL);
490 : : M2Options_SetDumpLangQuadFilename (value, NULL);
491 : : return 1;
492 : : case OPT_fdump_lang_decl:
493 : : M2Options_SetDumpLangDeclFilename (value, NULL);
494 : : return 1;
495 : : case OPT_fdump_lang_decl_:
496 : : M2Options_SetDumpLangDeclFilename (value, arg);
497 : : return 1;
498 : : case OPT_fdump_lang_gimple:
499 : : M2Options_SetDumpLangGimpleFilename (value, NULL);
500 : : return 1;
501 : : case OPT_fdump_lang_gimple_:
502 : : M2Options_SetDumpLangGimpleFilename (value, arg);
503 : : return 1;
504 : : case OPT_fdump_lang_quad:
505 : : M2Options_SetDumpLangQuadFilename (value, NULL);
506 : : return 1;
507 : : case OPT_fdump_lang_quad_:
508 : : M2Options_SetDumpLangQuadFilename (value, arg);
509 : : return 1;
510 : : #endif
511 : 12 : case OPT_fauto_init:
512 : 12 : M2Options_SetAutoInit (value);
513 : 12 : return 1;
514 : 1732 : case OPT_fsoft_check_all:
515 : 1732 : M2Options_SetCheckAll (value);
516 : 1732 : return 1;
517 : 18 : case OPT_fexceptions:
518 : 18 : M2Options_SetExceptions (value);
519 : 18 : return 1;
520 : 0 : case OPT_Wstyle:
521 : 0 : M2Options_SetStyle (value);
522 : 0 : return 1;
523 : 12 : case OPT_Wpedantic:
524 : 12 : M2Options_SetPedantic (value);
525 : 12 : return 1;
526 : 6 : case OPT_Wpedantic_param_names:
527 : 6 : M2Options_SetPedanticParamNames (value);
528 : 6 : return 1;
529 : 0 : case OPT_Wpedantic_cast:
530 : 0 : M2Options_SetPedanticCast (value);
531 : 0 : return 1;
532 : 324 : case OPT_fextended_opaque:
533 : 324 : M2Options_SetExtendedOpaque (value);
534 : 324 : return 1;
535 : 0 : case OPT_Wverbose_unbounded:
536 : 0 : M2Options_SetVerboseUnbounded (value);
537 : 0 : return 1;
538 : 0 : case OPT_Wunused_variable:
539 : 0 : M2Options_SetUnusedVariableChecking (value);
540 : 0 : return 1;
541 : 0 : case OPT_Wunused_parameter:
542 : 0 : M2Options_SetUnusedParameterChecking (value);
543 : 0 : return 1;
544 : 198 : case OPT_Wuninit_variable_checking:
545 : 198 : return M2Options_SetUninitVariableChecking (value, "known");
546 : 73 : case OPT_Wuninit_variable_checking_:
547 : 73 : return M2Options_SetUninitVariableChecking (value, arg);
548 : 0 : case OPT_fm2_strict_type:
549 : 0 : M2Options_SetStrictTypeChecking (value);
550 : 0 : return 1;
551 : : #ifdef ENABLE_QUAD_DUMP_ALL
552 : : case OPT_fm2_dump_filter_:
553 : : M2Options_SetM2DumpFilter (value, arg);
554 : : return 1;
555 : : #endif
556 : 0 : case OPT_Wall:
557 : 0 : M2Options_SetWall (value);
558 : 0 : return 1;
559 : 664 : case OPT_Wcase_enum:
560 : 664 : M2Options_SetCaseEnumChecking (value);
561 : 664 : return 1;
562 : : #if 0
563 : : /* Not yet implemented. */
564 : : case OPT_fxcode:
565 : : M2Options_SetXCode (value);
566 : : return 1;
567 : : #endif
568 : 0 : case OPT_fm2_lower_case:
569 : 0 : M2Options_SetLowerCaseKeywords (value);
570 : 0 : return 1;
571 : 0 : case OPT_fuse_list_:
572 : 0 : M2Options_SetUselist (value, arg);
573 : 0 : return 1;
574 : 0 : case OPT_fruntime_modules_:
575 : 0 : M2Options_SetRuntimeModuleOverride (arg);
576 : 0 : return 1;
577 : : case OPT_fpthread:
578 : : /* Handled in the driver. */
579 : : return 1;
580 : : case OPT_fm2_plugin:
581 : : /* Handled in the driver. */
582 : : return 1;
583 : 16867 : case OPT_fscaffold_dynamic:
584 : 16867 : M2Options_SetScaffoldDynamic (value);
585 : 16867 : return 1;
586 : 22 : case OPT_fscaffold_static:
587 : 22 : M2Options_SetScaffoldStatic (value);
588 : 22 : return 1;
589 : 2402 : case OPT_fscaffold_main:
590 : 2402 : M2Options_SetScaffoldMain (value);
591 : 2402 : return 1;
592 : 438 : case OPT_fcpp:
593 : 438 : M2Options_SetCpp (value);
594 : 438 : return 1;
595 : : case OPT_fpreprocessed:
596 : : /* Provided for compatibility; ignore for now. */
597 : : return 1;
598 : 438 : case OPT_fcpp_begin:
599 : 438 : insideCppArgs = TRUE;
600 : 438 : return 1;
601 : 438 : case OPT_fcpp_end:
602 : 438 : insideCppArgs = FALSE;
603 : 438 : return 1;
604 : 0 : case OPT_fq:
605 : 0 : M2Options_SetQuadDebugging (value);
606 : 0 : return 1;
607 : 0 : case OPT_fsources:
608 : 0 : M2Options_SetSources (value);
609 : 0 : return 1;
610 : 0 : case OPT_funbounded_by_reference:
611 : 0 : M2Options_SetUnboundedByReference (value);
612 : 0 : return 1;
613 : 6 : case OPT_fdef_:
614 : 6 : M2Options_setdefextension (arg);
615 : 6 : return 1;
616 : 6 : case OPT_fmod_:
617 : 6 : M2Options_setmodextension (arg);
618 : 6 : return 1;
619 : 22 : case OPT_fdump_system_exports:
620 : 22 : M2Options_SetDumpSystemExports (value);
621 : 22 : return 1;
622 : 0 : case OPT_fswig:
623 : 0 : M2Options_SetSwig (value);
624 : 0 : return 1;
625 : 0 : case OPT_fshared:
626 : 0 : M2Options_SetShared (value);
627 : 0 : return 1;
628 : 0 : case OPT_fm2_statistics:
629 : 0 : M2Options_SetStatistics (value);
630 : 0 : return 1;
631 : 484 : case OPT_fm2_g:
632 : 484 : M2Options_SetM2g (value);
633 : 484 : return 1;
634 : 164680 : break;
635 : 164680 : case OPT_fm2_pathname_:
636 : 164680 : if (strcmp (arg, "-") == 0)
637 : 31608 : M2Options_SetM2PathName ("");
638 : : else
639 : 133072 : M2Options_SetM2PathName (arg);
640 : : return 1;
641 : 231198 : break;
642 : 231198 : case OPT_fm2_pathnameI:
643 : 231198 : push_back_Ipath (arg);
644 : 231198 : return 1;
645 : 588 : break;
646 : 588 : case OPT_fm2_prefix_:
647 : 588 : if (strcmp (arg, "-") == 0)
648 : 0 : M2Options_SetM2Prefix ("");
649 : : else
650 : 588 : M2Options_SetM2Prefix (arg);
651 : : return 1;
652 : 16867 : break;
653 : 16867 : case OPT_iprefix:
654 : 16867 : iprefix = arg;
655 : 16867 : return 1;
656 : 294 : break;
657 : 294 : case OPT_imultilib:
658 : 294 : imultilib = arg;
659 : 294 : return 1;
660 : 33728 : break;
661 : 33728 : case OPT_isystem:
662 : 33728 : isystem.push_back (arg);
663 : 33728 : return 1;
664 : 0 : break;
665 : 0 : case OPT_iquote:
666 : 0 : iquote.push_back (arg);
667 : 0 : return 1;
668 : : break;
669 : : case OPT_isysroot:
670 : : /* Otherwise, ignored, at least for now. */
671 : : return 1;
672 : 24 : break;
673 : 24 : case OPT_fm2_whole_program:
674 : 24 : M2Options_SetWholeProgram (value);
675 : 24 : return 1;
676 : : #ifdef OPT_mabi_ibmlongdouble
677 : : case OPT_mabi_ibmlongdouble:
678 : : M2Options_SetIBMLongDouble (value);
679 : : return 1;
680 : : #endif
681 : : #ifdef OPT_mabi_ieeelongdouble
682 : : case OPT_mabi_ieeelongdouble:
683 : : M2Options_SetIEEELongDouble (value);
684 : : return 1;
685 : : #endif
686 : 0 : case OPT_flocation_:
687 : 0 : if (strcmp (arg, "builtins") == 0)
688 : : {
689 : 0 : M2Options_SetForcedLocation (BUILTINS_LOCATION);
690 : 0 : return 1;
691 : : }
692 : 0 : else if (strcmp (arg, "unknown") == 0)
693 : : {
694 : 0 : M2Options_SetForcedLocation (UNKNOWN_LOCATION);
695 : 0 : return 1;
696 : : }
697 : 0 : else if ((arg != NULL) && (ISDIGIT (arg[0])))
698 : : {
699 : 0 : M2Options_SetForcedLocation (atoi (arg));
700 : 0 : return 1;
701 : : }
702 : : else
703 : : return 0;
704 : 33277 : default:
705 : 33277 : if (insideCppArgs)
706 : : /* Handled in gm2_langhook_init_options (). */
707 : : return 1;
708 : 31951 : else if (option->flags & CL_DRIVER)
709 : : /* Driver options (unless specifically claimed above) should be handled
710 : : in gm2_langhook_init_options (). */
711 : : return 1;
712 : 599 : else if (option->flags & CL_C)
713 : : /* C options (unless specifically claimed above) should be handled
714 : : in gm2_langhook_init_options (). */
715 : : return 1;
716 : : break;
717 : : }
718 : : return 0;
719 : 0 : }
720 : :
721 : : /* This prefixes LIBNAME with the current compiler prefix (if it has been
722 : : relocated) or the LIBSUBDIR, if not. */
723 : : static void
724 : 2440 : add_one_import_path (const char *libname)
725 : : {
726 : 2440 : const char *libpath = iprefix ? iprefix : LIBSUBDIR;
727 : 2440 : const char dir_sep[] = {DIR_SEPARATOR, (char)0};
728 : 2440 : size_t dir_sep_size = strlen (dir_sep);
729 : 2440 : unsigned int mlib_len = 0;
730 : :
731 : 2440 : if (imultilib)
732 : : {
733 : 1176 : mlib_len = strlen (imultilib);
734 : 1176 : mlib_len += strlen (dir_sep);
735 : : }
736 : :
737 : 2440 : char *lib = (char *)alloca (strlen (libpath) + dir_sep_size
738 : : + strlen ("m2") + dir_sep_size
739 : : + strlen (libname) + 1
740 : : + mlib_len + 1);
741 : 2440 : strcpy (lib, libpath);
742 : : /* iprefix has a trailing dir separator, LIBSUBDIR does not. */
743 : 2440 : if (!iprefix)
744 : 0 : strcat (lib, dir_sep);
745 : :
746 : 2440 : if (imultilib)
747 : : {
748 : 1176 : strcat (lib, imultilib);
749 : 1176 : strcat (lib, dir_sep);
750 : : }
751 : 2440 : strcat (lib, "m2");
752 : 2440 : strcat (lib, dir_sep);
753 : 2440 : strcat (lib, libname);
754 : 2440 : M2Options_SetM2PathName (libname);
755 : 2440 : M2Options_SetSearchPath (lib);
756 : 2440 : }
757 : :
758 : : /* For each comma-separated standard library name in LIBLIST, add the
759 : : corresponding include path. */
760 : : static void
761 : 610 : add_m2_import_paths (const char *liblist)
762 : : {
763 : 3050 : while (*liblist != 0 && *liblist != '-')
764 : : {
765 : 2440 : const char *comma = strstr (liblist, ",");
766 : 2440 : size_t len;
767 : 2440 : if (comma)
768 : 1830 : len = comma - liblist;
769 : : else
770 : 610 : len = strlen (liblist);
771 : 2440 : char *libname = (char *) alloca (len+1);
772 : 2440 : strncpy (libname, liblist, len);
773 : 2440 : libname[len] = 0;
774 : 2440 : add_one_import_path (libname);
775 : 2440 : liblist += len;
776 : 2440 : if (*liblist == ',')
777 : 1830 : liblist++;
778 : : }
779 : 610 : }
780 : :
781 : : /* Run after parsing options. */
782 : :
783 : : static bool
784 : 16867 : gm2_langhook_post_options (const char **pfilename)
785 : : {
786 : 16867 : const char *filename = *pfilename;
787 : 16867 : flag_excess_precision = EXCESS_PRECISION_FAST;
788 : 16867 : M2Options_SetCC1Quiet (quiet_flag);
789 : 16867 : M2Options_FinaliseOptions ();
790 : 16867 : main_input_filename = filename;
791 : :
792 : : /* Add the include paths as per the libraries specified.
793 : : NOTE: This assumes that the driver has validated the input and makes
794 : : no attempt to be defensive of nonsense input in flibs=. */
795 : 16867 : if (allow_libraries)
796 : : {
797 : 610 : if (!flibs)
798 : : {
799 : 0 : if (iso)
800 : 0 : flibs = "m2iso,m2cor,m2pim,m2log";
801 : : else
802 : 0 : flibs = "m2pim,m2iso,m2cor,m2log";
803 : : }
804 : : }
805 : :
806 : : /* Add search paths.
807 : : We are not handling all of the cases yet (e.g idirafter).
808 : : This (barring the missing cases) is intended to follow the directory
809 : : search rules used for c-family. It would be less confusing if the
810 : : presence of absence of these search paths was not dependent on the
811 : : flibs= option. */
812 : :
813 : 16867 : for (auto *s : iquote)
814 : 0 : M2Options_SetSearchPath (s);
815 : 16867 : iquote.clear();
816 : 181519 : for (auto np : Ipaths)
817 : : {
818 : 164652 : M2Options_SetM2PathName (np.name);
819 : 395850 : for (auto *s : np.path)
820 : 231198 : M2Options_SetSearchPath (s);
821 : 164652 : }
822 : 16867 : Ipaths.clear();
823 : 50595 : for (auto *s : isystem)
824 : 33728 : M2Options_SetSearchPath (s);
825 : 16867 : isystem.clear();
826 : : /* FIXME: this is not a good way to suppress the addition of the import
827 : : paths. */
828 : 16867 : if (allow_libraries)
829 : 610 : add_m2_import_paths (flibs);
830 : :
831 : : /* Returning false means that the backend should be used. */
832 : 16867 : return M2Options_GetPPOnly ();
833 : : }
834 : :
835 : : /* Call the compiler for every source filename on the command line. */
836 : :
837 : : static void
838 : 16867 : gm2_parse_input_files (const char **filenames, unsigned int filename_count)
839 : : {
840 : 16867 : unsigned int i;
841 : 16867 : gcc_assert (filename_count > 0);
842 : :
843 : 33445 : for (i = 0; i < filename_count; i++)
844 : 17305 : if (!is_cpp_filename (i))
845 : : {
846 : 16867 : main_input_filename = filenames[i];
847 : 16867 : init_PerCompilationInit (filenames[i]);
848 : : }
849 : 16140 : }
850 : :
851 : : static void
852 : 16867 : gm2_langhook_parse_file (void)
853 : : {
854 : 16867 : gm2_parse_input_files (in_fnames, num_in_fnames);
855 : 16140 : if (!M2Options_GetPPOnly ())
856 : 16140 : write_globals ();
857 : 16140 : }
858 : :
859 : : static tree
860 : 243387 : gm2_langhook_type_for_size (unsigned int bits, int unsignedp)
861 : : {
862 : 138418 : return gm2_type_for_size (bits, unsignedp);
863 : : }
864 : :
865 : : static tree
866 : 258062 : gm2_langhook_type_for_mode (machine_mode mode, int unsignedp)
867 : : {
868 : 258062 : tree type;
869 : :
870 : 774136 : for (int i = 0; i < NUM_INT_N_ENTS; i ++)
871 : 258062 : if (int_n_enabled_p[i]
872 : 258062 : && mode == int_n_data[i].m)
873 : 50 : return (unsignedp ? int_n_trees[i].unsigned_type
874 : 50 : : int_n_trees[i].signed_type);
875 : :
876 : 258012 : if (VECTOR_MODE_P (mode))
877 : : {
878 : 4 : tree inner;
879 : :
880 : 8 : inner = gm2_langhook_type_for_mode (GET_MODE_INNER (mode), unsignedp);
881 : 4 : if (inner != NULL_TREE)
882 : 4 : return build_vector_type_for_mode (inner, mode);
883 : : return NULL_TREE;
884 : : }
885 : :
886 : 258008 : scalar_int_mode imode;
887 : 258008 : if (is_int_mode (mode, &imode))
888 : 209938 : return gm2_langhook_type_for_size (GET_MODE_BITSIZE (imode), unsignedp);
889 : :
890 : 153039 : if (mode == TYPE_MODE (float_type_node))
891 : 341 : return float_type_node;
892 : :
893 : 152698 : if (mode == TYPE_MODE (double_type_node))
894 : 508 : return double_type_node;
895 : :
896 : 152190 : if (mode == TYPE_MODE (long_double_type_node))
897 : 201 : return long_double_type_node;
898 : :
899 : 151989 : if ((float128_type_node != NULL) && (mode == TYPE_MODE (float128_type_node)))
900 : 16867 : return float128_type_node;
901 : :
902 : 135122 : if (COMPLEX_MODE_P (mode))
903 : : {
904 : 101388 : machine_mode inner_mode;
905 : 101388 : tree inner_type;
906 : :
907 : 101388 : if (mode == TYPE_MODE (complex_float_type_node))
908 : 16993 : return complex_float_type_node;
909 : 84395 : if (mode == TYPE_MODE (complex_double_type_node))
910 : 16871 : return complex_double_type_node;
911 : 67524 : if (mode == TYPE_MODE (complex_long_double_type_node))
912 : 16923 : return complex_long_double_type_node;
913 : :
914 : 50601 : inner_mode = GET_MODE_INNER (mode);
915 : 50601 : inner_type = gm2_langhook_type_for_mode (inner_mode, unsignedp);
916 : 50601 : if (inner_type != NULL_TREE)
917 : 16867 : return build_complex_type (inner_type);
918 : : }
919 : :
920 : : #if HOST_BITS_PER_WIDE_INT >= 64
921 : : /* The middle-end and some backends rely on TImode being supported
922 : : for 64-bit HWI. */
923 : 67468 : if (mode == TImode)
924 : : {
925 : 0 : type = build_nonstandard_integer_type (GET_MODE_BITSIZE (TImode),
926 : : unsignedp);
927 : 0 : if (type && TYPE_MODE (type) == TImode)
928 : : return type;
929 : : }
930 : : #endif
931 : : return NULL_TREE;
932 : : }
933 : :
934 : : /* Record a builtin function. We just ignore builtin functions. */
935 : :
936 : : static tree
937 : 2631252 : gm2_langhook_builtin_function (tree decl)
938 : : {
939 : 2631252 : return decl;
940 : : }
941 : :
942 : : /* Return true if we are in the global binding level. */
943 : :
944 : : static bool
945 : 31228 : gm2_langhook_global_bindings_p (void)
946 : : {
947 : 31228 : return current_function_decl == NULL_TREE;
948 : : }
949 : :
950 : : /* Unused langhook. */
951 : :
952 : : static tree
953 : 0 : gm2_langhook_pushdecl (tree decl ATTRIBUTE_UNUSED)
954 : : {
955 : 0 : gcc_unreachable ();
956 : : }
957 : :
958 : : /* This hook is used to get the current list of declarations as trees.
959 : : We don't support that; instead we use write_globals. This can't
960 : : simply crash because it is called by -gstabs. */
961 : :
962 : : static tree
963 : 0 : gm2_langhook_getdecls (void)
964 : : {
965 : 0 : return NULL;
966 : : }
967 : :
968 : : /* m2_write_global_declarations writes out globals creating an array
969 : : of the declarations and calling wrapup_global_declarations. */
970 : :
971 : : static void
972 : 16140 : m2_write_global_declarations (tree globals)
973 : : {
974 : 16140 : auto_vec<tree> global_decls;
975 : 16140 : tree decl = globals;
976 : 16140 : int n = 0;
977 : :
978 : 5597008 : while (decl != NULL)
979 : : {
980 : 5580868 : global_decls.safe_push (decl);
981 : 5580868 : decl = TREE_CHAIN (decl);
982 : 5580868 : n++;
983 : : }
984 : 32280 : wrapup_global_declarations (global_decls.address (), n);
985 : 16140 : }
986 : :
987 : : /* Write out globals. */
988 : :
989 : : static void
990 : 16140 : write_globals (void)
991 : : {
992 : 16140 : tree t;
993 : 16140 : unsigned i;
994 : :
995 : 16140 : m2block_finishGlobals ();
996 : :
997 : : /* Process all file scopes in this compilation, and the
998 : : external_scope, through wrapup_global_declarations and
999 : : check_global_declarations. */
1000 : 48420 : FOR_EACH_VEC_ELT (*all_translation_units, i, t)
1001 : 16140 : m2_write_global_declarations (BLOCK_VARS (DECL_INITIAL (t)));
1002 : 16140 : }
1003 : :
1004 : :
1005 : : /* Gimplify an EXPR_STMT node. */
1006 : :
1007 : : static void
1008 : 2528 : gimplify_expr_stmt (tree *stmt_p)
1009 : : {
1010 : 2528 : gcc_assert (EXPR_STMT_EXPR (*stmt_p) != NULL_TREE);
1011 : 2528 : *stmt_p = EXPR_STMT_EXPR (*stmt_p);
1012 : 2528 : }
1013 : :
1014 : : /* Genericize a TRY_BLOCK. */
1015 : :
1016 : : static void
1017 : 2528 : genericize_try_block (tree *stmt_p)
1018 : : {
1019 : 2528 : tree body = TRY_STMTS (*stmt_p);
1020 : 2528 : tree cleanup = TRY_HANDLERS (*stmt_p);
1021 : :
1022 : 2528 : *stmt_p = build2 (TRY_CATCH_EXPR, void_type_node, body, cleanup);
1023 : 2528 : }
1024 : :
1025 : : /* Genericize a HANDLER by converting to a CATCH_EXPR. */
1026 : :
1027 : : static void
1028 : 2528 : genericize_catch_block (tree *stmt_p)
1029 : : {
1030 : 2528 : tree type = HANDLER_TYPE (*stmt_p);
1031 : 2528 : tree body = HANDLER_BODY (*stmt_p);
1032 : :
1033 : : /* FIXME should the caught type go in TREE_TYPE? */
1034 : 2528 : *stmt_p = build2 (CATCH_EXPR, void_type_node, type, body);
1035 : 2528 : }
1036 : :
1037 : : /* Convert the tree representation of FNDECL from m2 frontend trees
1038 : : to GENERIC. */
1039 : :
1040 : : extern void pf (tree);
1041 : :
1042 : : void
1043 : 113162 : gm2_genericize (tree fndecl)
1044 : : {
1045 : 113162 : tree t;
1046 : 113162 : struct cgraph_node *cgn;
1047 : :
1048 : : #if 0
1049 : : pf (fndecl);
1050 : : #endif
1051 : : /* Fix up the types of parms passed by invisible reference. */
1052 : 298931 : for (t = DECL_ARGUMENTS (fndecl); t; t = DECL_CHAIN (t))
1053 : 185769 : if (TREE_ADDRESSABLE (TREE_TYPE (t)))
1054 : : {
1055 : :
1056 : : /* If a function's arguments are copied to create a thunk, then
1057 : : DECL_BY_REFERENCE will be set -- but the type of the argument will be
1058 : : a pointer type, so we will never get here. */
1059 : 0 : gcc_assert (!DECL_BY_REFERENCE (t));
1060 : 0 : gcc_assert (DECL_ARG_TYPE (t) != TREE_TYPE (t));
1061 : 0 : TREE_TYPE (t) = DECL_ARG_TYPE (t);
1062 : 0 : DECL_BY_REFERENCE (t) = 1;
1063 : 0 : TREE_ADDRESSABLE (t) = 0;
1064 : 0 : relayout_decl (t);
1065 : : }
1066 : :
1067 : : /* Dump all nested functions now. */
1068 : 113162 : cgn = cgraph_node::get_create (fndecl);
1069 : 114080 : for (cgn = first_nested_function (cgn);
1070 : 114080 : cgn != NULL; cgn = next_nested_function (cgn))
1071 : 918 : gm2_genericize (cgn->decl);
1072 : 113162 : }
1073 : :
1074 : : /* gm2 gimplify expression, currently just change THROW in the same
1075 : : way as C++ */
1076 : :
1077 : : static int
1078 : 9591635 : gm2_langhook_gimplify_expr (tree *expr_p, gimple_seq *pre_p ATTRIBUTE_UNUSED,
1079 : : gimple_seq *post_p ATTRIBUTE_UNUSED)
1080 : : {
1081 : 9591635 : enum tree_code code = TREE_CODE (*expr_p);
1082 : :
1083 : 9591635 : switch (code)
1084 : : {
1085 : 298 : case THROW_EXPR:
1086 : :
1087 : : /* FIXME communicate throw type to back end, probably by moving
1088 : : THROW_EXPR into ../tree.def. */
1089 : 298 : *expr_p = TREE_OPERAND (*expr_p, 0);
1090 : 298 : return GS_OK;
1091 : :
1092 : 2528 : case EXPR_STMT:
1093 : 2528 : gimplify_expr_stmt (expr_p);
1094 : 2528 : return GS_OK;
1095 : :
1096 : 2528 : case TRY_BLOCK:
1097 : 2528 : genericize_try_block (expr_p);
1098 : 2528 : return GS_OK;
1099 : :
1100 : 2528 : case HANDLER:
1101 : 2528 : genericize_catch_block (expr_p);
1102 : 2528 : return GS_OK;
1103 : :
1104 : : default:
1105 : : return GS_UNHANDLED;
1106 : : }
1107 : : }
1108 : :
1109 : : static GTY(()) tree gm2_eh_personality_decl;
1110 : :
1111 : : static tree
1112 : 2566 : gm2_langhook_eh_personality (void)
1113 : : {
1114 : 2566 : if (!gm2_eh_personality_decl)
1115 : 2432 : gm2_eh_personality_decl = build_personality_function ("gxx");
1116 : :
1117 : 2566 : return gm2_eh_personality_decl;
1118 : : }
1119 : :
1120 : : /* Functions called directly by the generic backend. */
1121 : :
1122 : : tree
1123 : 7381900 : convert_loc (location_t location, tree type, tree expr)
1124 : : {
1125 : 7381900 : if (type == error_mark_node || expr == error_mark_node
1126 : 14763794 : || TREE_TYPE (expr) == error_mark_node)
1127 : : return error_mark_node;
1128 : :
1129 : 7381894 : if (type == TREE_TYPE (expr))
1130 : : return expr;
1131 : :
1132 : 3485831 : gcc_assert (TYPE_MAIN_VARIANT (type) != NULL);
1133 : 3485831 : if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (expr)))
1134 : 0 : return fold_convert (type, expr);
1135 : :
1136 : 3485831 : expr = m2convert_GenericToType (location, type, expr);
1137 : 3485831 : switch (TREE_CODE (type))
1138 : : {
1139 : 102698 : case VOID_TYPE:
1140 : 102698 : case BOOLEAN_TYPE:
1141 : 102698 : return fold (convert_to_integer (type, expr));
1142 : 2797056 : case INTEGER_TYPE:
1143 : 2797056 : return fold (convert_to_integer (type, expr));
1144 : 534253 : case POINTER_TYPE:
1145 : 534253 : return fold (convert_to_pointer (type, expr));
1146 : 3756 : case REAL_TYPE:
1147 : 3756 : return fold (convert_to_real (type, expr));
1148 : 216 : case COMPLEX_TYPE:
1149 : 216 : return fold (convert_to_complex (type, expr));
1150 : 47846 : case ENUMERAL_TYPE:
1151 : 47846 : return fold (convert_to_integer (type, expr));
1152 : 6 : default:
1153 : 6 : error_at (location, "cannot convert expression, only base types can be converted");
1154 : 6 : break;
1155 : : }
1156 : 6 : return error_mark_node;
1157 : : }
1158 : :
1159 : : /* Functions called directly by the generic backend. */
1160 : :
1161 : : tree
1162 : 613434 : convert (tree type, tree expr)
1163 : : {
1164 : 613434 : return convert_loc (m2linemap_UnknownLocation (), type, expr);
1165 : : }
1166 : :
1167 : : /* Mark EXP saying that we need to be able to take the address of it;
1168 : : it should not be allocated in a register. Returns true if
1169 : : successful. */
1170 : :
1171 : : bool
1172 : 2647059 : gm2_mark_addressable (tree exp)
1173 : : {
1174 : 2647059 : tree x = exp;
1175 : :
1176 : 2700635 : while (TRUE)
1177 : 2700635 : switch (TREE_CODE (x))
1178 : : {
1179 : 8798 : case COMPONENT_REF:
1180 : 8798 : if (DECL_PACKED (TREE_OPERAND (x, 1)))
1181 : : return false;
1182 : 8798 : x = TREE_OPERAND (x, 0);
1183 : 8798 : break;
1184 : :
1185 : 44778 : case ADDR_EXPR:
1186 : 44778 : case ARRAY_REF:
1187 : 44778 : case REALPART_EXPR:
1188 : 44778 : case IMAGPART_EXPR:
1189 : 44778 : x = TREE_OPERAND (x, 0);
1190 : 44778 : break;
1191 : :
1192 : 2638471 : case COMPOUND_LITERAL_EXPR:
1193 : 2638471 : case CONSTRUCTOR:
1194 : 2638471 : case STRING_CST:
1195 : 2638471 : case VAR_DECL:
1196 : 2638471 : case CONST_DECL:
1197 : 2638471 : case PARM_DECL:
1198 : 2638471 : case RESULT_DECL:
1199 : 2638471 : case FUNCTION_DECL:
1200 : 2638471 : TREE_ADDRESSABLE (x) = 1;
1201 : 2638471 : return true;
1202 : : default:
1203 : : return true;
1204 : : }
1205 : : /* Never reach here. */
1206 : : gcc_unreachable ();
1207 : : }
1208 : :
1209 : : /* Return an integer type with BITS bits of precision, that is
1210 : : unsigned if UNSIGNEDP is nonzero, otherwise signed. */
1211 : :
1212 : : tree
1213 : 260254 : gm2_type_for_size (unsigned int bits, int unsignedp)
1214 : : {
1215 : 260254 : if (unsignedp)
1216 : : {
1217 : 92000 : if (bits == INT_TYPE_SIZE)
1218 : 30157 : return unsigned_type_node;
1219 : 61843 : else if (bits == CHAR_TYPE_SIZE)
1220 : 24409 : return unsigned_char_type_node;
1221 : 37434 : else if (bits == SHORT_TYPE_SIZE)
1222 : 42 : return short_unsigned_type_node;
1223 : 37804 : else if (bits == LONG_TYPE_SIZE)
1224 : 36974 : return long_unsigned_type_node;
1225 : 418 : else if (bits == LONG_LONG_TYPE_SIZE)
1226 : 412 : return long_long_unsigned_type_node;
1227 : : else
1228 : 6 : return build_nonstandard_integer_type (bits,
1229 : 6 : unsignedp);
1230 : : }
1231 : : else
1232 : : {
1233 : 168254 : if (bits == INT_TYPE_SIZE)
1234 : 3055 : return integer_type_node;
1235 : 165199 : else if (bits == CHAR_TYPE_SIZE)
1236 : 24 : return signed_char_type_node;
1237 : 165175 : else if (bits == SHORT_TYPE_SIZE)
1238 : 138 : return short_integer_type_node;
1239 : 165425 : else if (bits == LONG_TYPE_SIZE)
1240 : 148076 : return long_integer_type_node;
1241 : 16961 : else if (bits == LONG_LONG_TYPE_SIZE)
1242 : 388 : return long_long_integer_type_node;
1243 : : else
1244 : 16573 : return build_nonstandard_integer_type (bits,
1245 : 16573 : unsignedp);
1246 : : }
1247 : : /* Never reach here. */
1248 : : gcc_unreachable ();
1249 : : }
1250 : :
1251 : : /* Allow the analyzer to understand Storage ALLOCATE/DEALLOCATE. */
1252 : :
1253 : : bool
1254 : 0 : gm2_langhook_new_dispose_storage_substitution (void)
1255 : : {
1256 : 0 : return true;
1257 : : }
1258 : :
1259 : : #undef LANG_HOOKS_NAME
1260 : : #undef LANG_HOOKS_INIT
1261 : : #undef LANG_HOOKS_INIT_OPTIONS
1262 : : #undef LANG_HOOKS_OPTION_LANG_MASK
1263 : : #undef LANG_HOOKS_INIT_OPTIONS_STRUCT
1264 : : #undef LANG_HOOKS_HANDLE_OPTION
1265 : : #undef LANG_HOOKS_POST_OPTIONS
1266 : : #undef LANG_HOOKS_PARSE_FILE
1267 : : #undef LANG_HOOKS_TYPE_FOR_MODE
1268 : : #undef LANG_HOOKS_TYPE_FOR_SIZE
1269 : : #undef LANG_HOOKS_BUILTIN_FUNCTION
1270 : : #undef LANG_HOOKS_GLOBAL_BINDINGS_P
1271 : : #undef LANG_HOOKS_PUSHDECL
1272 : : #undef LANG_HOOKS_GETDECLS
1273 : : #undef LANG_HOOKS_GIMPLIFY_EXPR
1274 : : #undef LANG_HOOKS_EH_PERSONALITY
1275 : : #undef LANG_HOOKS_NEW_DISPOSE_STORAGE_SUBSTITUTION
1276 : :
1277 : : #define LANG_HOOKS_NAME "GNU Modula-2"
1278 : : #define LANG_HOOKS_INIT gm2_langhook_init
1279 : : #define LANG_HOOKS_INIT_OPTIONS gm2_langhook_init_options
1280 : : #define LANG_HOOKS_OPTION_LANG_MASK gm2_langhook_option_lang_mask
1281 : : #define LANG_HOOKS_INIT_OPTIONS_STRUCT gm2_langhook_init_options_struct
1282 : : #define LANG_HOOKS_HANDLE_OPTION gm2_langhook_handle_option
1283 : : #define LANG_HOOKS_POST_OPTIONS gm2_langhook_post_options
1284 : : #define LANG_HOOKS_PARSE_FILE gm2_langhook_parse_file
1285 : : #define LANG_HOOKS_TYPE_FOR_MODE gm2_langhook_type_for_mode
1286 : : #define LANG_HOOKS_TYPE_FOR_SIZE gm2_langhook_type_for_size
1287 : : #define LANG_HOOKS_BUILTIN_FUNCTION gm2_langhook_builtin_function
1288 : : #define LANG_HOOKS_GLOBAL_BINDINGS_P gm2_langhook_global_bindings_p
1289 : : #define LANG_HOOKS_PUSHDECL gm2_langhook_pushdecl
1290 : : #define LANG_HOOKS_GETDECLS gm2_langhook_getdecls
1291 : : #define LANG_HOOKS_GIMPLIFY_EXPR gm2_langhook_gimplify_expr
1292 : : #define LANG_HOOKS_EH_PERSONALITY gm2_langhook_eh_personality
1293 : : #define LANG_HOOKS_NEW_DISPOSE_STORAGE_SUBSTITUTION \
1294 : : gm2_langhook_new_dispose_storage_substitution
1295 : :
1296 : : struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
1297 : :
1298 : : #include "gt-m2-gm2-lang.h"
1299 : : #include "gtype-m2.h"
|