1 |
38 |
julius |
/* Top level of GCC compilers (cc1, cc1plus, etc.)
|
2 |
|
|
Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
|
3 |
|
|
1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
|
4 |
|
|
Free Software Foundation, Inc.
|
5 |
|
|
|
6 |
|
|
This file is part of GCC.
|
7 |
|
|
|
8 |
|
|
GCC is free software; you can redistribute it and/or modify it under
|
9 |
|
|
the terms of the GNU General Public License as published by the Free
|
10 |
|
|
Software Foundation; either version 3, or (at your option) any later
|
11 |
|
|
version.
|
12 |
|
|
|
13 |
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
14 |
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
15 |
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
16 |
|
|
for more details.
|
17 |
|
|
|
18 |
|
|
You should have received a copy of the GNU General Public License
|
19 |
|
|
along with GCC; see the file COPYING3. If not see
|
20 |
|
|
<http://www.gnu.org/licenses/>. */
|
21 |
|
|
|
22 |
|
|
/* This is the top level of cc1/c++.
|
23 |
|
|
It parses command args, opens files, invokes the various passes
|
24 |
|
|
in the proper order, and counts the time used by each.
|
25 |
|
|
Error messages and low-level interface to malloc also handled here. */
|
26 |
|
|
|
27 |
|
|
#include "config.h"
|
28 |
|
|
#undef FLOAT /* This is for hpux. They should change hpux. */
|
29 |
|
|
#undef FFS /* Some systems define this in param.h. */
|
30 |
|
|
#include "system.h"
|
31 |
|
|
#include "coretypes.h"
|
32 |
|
|
#include "tm.h"
|
33 |
|
|
#include <signal.h>
|
34 |
|
|
|
35 |
|
|
#ifdef HAVE_SYS_RESOURCE_H
|
36 |
|
|
# include <sys/resource.h>
|
37 |
|
|
#endif
|
38 |
|
|
|
39 |
|
|
#ifdef HAVE_SYS_TIMES_H
|
40 |
|
|
# include <sys/times.h>
|
41 |
|
|
#endif
|
42 |
|
|
|
43 |
|
|
#include "line-map.h"
|
44 |
|
|
#include "input.h"
|
45 |
|
|
#include "tree.h"
|
46 |
|
|
#include "version.h"
|
47 |
|
|
#include "rtl.h"
|
48 |
|
|
#include "tm_p.h"
|
49 |
|
|
#include "flags.h"
|
50 |
|
|
#include "insn-attr.h"
|
51 |
|
|
#include "insn-config.h"
|
52 |
|
|
#include "insn-flags.h"
|
53 |
|
|
#include "hard-reg-set.h"
|
54 |
|
|
#include "recog.h"
|
55 |
|
|
#include "output.h"
|
56 |
|
|
#include "except.h"
|
57 |
|
|
#include "function.h"
|
58 |
|
|
#include "toplev.h"
|
59 |
|
|
#include "expr.h"
|
60 |
|
|
#include "basic-block.h"
|
61 |
|
|
#include "intl.h"
|
62 |
|
|
#include "ggc.h"
|
63 |
|
|
#include "graph.h"
|
64 |
|
|
#include "regs.h"
|
65 |
|
|
#include "timevar.h"
|
66 |
|
|
#include "diagnostic.h"
|
67 |
|
|
#include "params.h"
|
68 |
|
|
#include "reload.h"
|
69 |
|
|
#include "dwarf2asm.h"
|
70 |
|
|
#include "integrate.h"
|
71 |
|
|
#include "real.h"
|
72 |
|
|
#include "debug.h"
|
73 |
|
|
#include "target.h"
|
74 |
|
|
#include "langhooks.h"
|
75 |
|
|
#include "cfglayout.h"
|
76 |
|
|
#include "cfgloop.h"
|
77 |
|
|
#include "hosthooks.h"
|
78 |
|
|
#include "cgraph.h"
|
79 |
|
|
#include "opts.h"
|
80 |
|
|
#include "coverage.h"
|
81 |
|
|
#include "value-prof.h"
|
82 |
|
|
#include "alloc-pool.h"
|
83 |
|
|
#include "tree-mudflap.h"
|
84 |
|
|
|
85 |
|
|
#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
|
86 |
|
|
#include "dwarf2out.h"
|
87 |
|
|
#endif
|
88 |
|
|
|
89 |
|
|
#if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
|
90 |
|
|
#include "dbxout.h"
|
91 |
|
|
#endif
|
92 |
|
|
|
93 |
|
|
#ifdef SDB_DEBUGGING_INFO
|
94 |
|
|
#include "sdbout.h"
|
95 |
|
|
#endif
|
96 |
|
|
|
97 |
|
|
#ifdef XCOFF_DEBUGGING_INFO
|
98 |
|
|
#include "xcoffout.h" /* Needed for external data
|
99 |
|
|
declarations for e.g. AIX 4.x. */
|
100 |
|
|
#endif
|
101 |
|
|
|
102 |
|
|
static void general_init (const char *);
|
103 |
|
|
static void do_compile (void);
|
104 |
|
|
static void process_options (void);
|
105 |
|
|
static void backend_init (void);
|
106 |
|
|
static int lang_dependent_init (const char *);
|
107 |
|
|
static void init_asm_output (const char *);
|
108 |
|
|
static void finalize (void);
|
109 |
|
|
|
110 |
|
|
static void crash_signal (int) ATTRIBUTE_NORETURN;
|
111 |
|
|
static void setup_core_dumping (void);
|
112 |
|
|
static void compile_file (void);
|
113 |
|
|
|
114 |
|
|
static int print_single_switch (FILE *, int, int, const char *,
|
115 |
|
|
const char *, const char *,
|
116 |
|
|
const char *, const char *);
|
117 |
|
|
static void print_switch_values (FILE *, int, int, const char *,
|
118 |
|
|
const char *, const char *);
|
119 |
|
|
|
120 |
|
|
/* Nonzero to dump debug info whilst parsing (-dy option). */
|
121 |
|
|
static int set_yydebug;
|
122 |
|
|
|
123 |
|
|
/* True if we don't need a backend (e.g. preprocessing only). */
|
124 |
|
|
static bool no_backend;
|
125 |
|
|
|
126 |
|
|
/* Length of line when printing switch values. */
|
127 |
|
|
#define MAX_LINE 75
|
128 |
|
|
|
129 |
|
|
/* Name of program invoked, sans directories. */
|
130 |
|
|
|
131 |
|
|
const char *progname;
|
132 |
|
|
|
133 |
|
|
/* Copy of argument vector to toplev_main. */
|
134 |
|
|
static const char **save_argv;
|
135 |
|
|
|
136 |
|
|
/* Name of top-level original source file (what was input to cpp).
|
137 |
|
|
This comes from the #-command at the beginning of the actual input.
|
138 |
|
|
If there isn't any there, then this is the cc1 input file name. */
|
139 |
|
|
|
140 |
|
|
const char *main_input_filename;
|
141 |
|
|
|
142 |
|
|
#ifndef USE_MAPPED_LOCATION
|
143 |
|
|
location_t unknown_location = { NULL, 0 };
|
144 |
|
|
#endif
|
145 |
|
|
|
146 |
|
|
/* Used to enable -fvar-tracking, -fweb and -frename-registers according
|
147 |
|
|
to optimize and default_debug_hooks in process_options (). */
|
148 |
|
|
#define AUTODETECT_VALUE 2
|
149 |
|
|
|
150 |
|
|
/* Current position in real source file. */
|
151 |
|
|
|
152 |
|
|
location_t input_location;
|
153 |
|
|
|
154 |
|
|
struct line_maps line_table;
|
155 |
|
|
|
156 |
|
|
/* Nonzero if it is unsafe to create any new pseudo registers. */
|
157 |
|
|
int no_new_pseudos;
|
158 |
|
|
|
159 |
|
|
/* Stack of currently pending input files. */
|
160 |
|
|
|
161 |
|
|
struct file_stack *input_file_stack;
|
162 |
|
|
|
163 |
|
|
/* Incremented on each change to input_file_stack. */
|
164 |
|
|
int input_file_stack_tick;
|
165 |
|
|
|
166 |
|
|
/* Record of input_file_stack at each tick. */
|
167 |
|
|
typedef struct file_stack *fs_p;
|
168 |
|
|
DEF_VEC_P(fs_p);
|
169 |
|
|
DEF_VEC_ALLOC_P(fs_p,heap);
|
170 |
|
|
static VEC(fs_p,heap) *input_file_stack_history;
|
171 |
|
|
|
172 |
|
|
/* Whether input_file_stack has been restored to a previous state (in
|
173 |
|
|
which case there should be no more pushing). */
|
174 |
|
|
static bool input_file_stack_restored;
|
175 |
|
|
|
176 |
|
|
/* Name to use as base of names for dump output files. */
|
177 |
|
|
|
178 |
|
|
const char *dump_base_name;
|
179 |
|
|
|
180 |
|
|
/* Name to use as a base for auxiliary output files. */
|
181 |
|
|
|
182 |
|
|
const char *aux_base_name;
|
183 |
|
|
|
184 |
|
|
/* Bit flags that specify the machine subtype we are compiling for.
|
185 |
|
|
Bits are tested using macros TARGET_... defined in the tm.h file
|
186 |
|
|
and set by `-m...' switches. Must be defined in rtlanal.c. */
|
187 |
|
|
|
188 |
|
|
extern int target_flags;
|
189 |
|
|
|
190 |
|
|
/* A mask of target_flags that includes bit X if X was set or cleared
|
191 |
|
|
on the command line. */
|
192 |
|
|
|
193 |
|
|
int target_flags_explicit;
|
194 |
|
|
|
195 |
|
|
/* Debug hooks - dependent upon command line options. */
|
196 |
|
|
|
197 |
|
|
const struct gcc_debug_hooks *debug_hooks;
|
198 |
|
|
|
199 |
|
|
/* Debug hooks - target default. */
|
200 |
|
|
|
201 |
|
|
static const struct gcc_debug_hooks *default_debug_hooks;
|
202 |
|
|
|
203 |
|
|
/* Other flags saying which kinds of debugging dump have been requested. */
|
204 |
|
|
|
205 |
|
|
int rtl_dump_and_exit;
|
206 |
|
|
int flag_print_asm_name;
|
207 |
|
|
enum graph_dump_types graph_dump_format;
|
208 |
|
|
|
209 |
|
|
/* Name for output file of assembly code, specified with -o. */
|
210 |
|
|
|
211 |
|
|
const char *asm_file_name;
|
212 |
|
|
|
213 |
|
|
/* Nonzero means do optimizations. -O.
|
214 |
|
|
Particular numeric values stand for particular amounts of optimization;
|
215 |
|
|
thus, -O2 stores 2 here. However, the optimizations beyond the basic
|
216 |
|
|
ones are not controlled directly by this variable. Instead, they are
|
217 |
|
|
controlled by individual `flag_...' variables that are defaulted
|
218 |
|
|
based on this variable. */
|
219 |
|
|
|
220 |
|
|
int optimize = 0;
|
221 |
|
|
|
222 |
|
|
/* Nonzero means optimize for size. -Os.
|
223 |
|
|
The only valid values are zero and nonzero. When optimize_size is
|
224 |
|
|
nonzero, optimize defaults to 2, but certain individual code
|
225 |
|
|
bloating optimizations are disabled. */
|
226 |
|
|
|
227 |
|
|
int optimize_size = 0;
|
228 |
|
|
|
229 |
|
|
/* The FUNCTION_DECL for the function currently being compiled,
|
230 |
|
|
or 0 if between functions. */
|
231 |
|
|
tree current_function_decl;
|
232 |
|
|
|
233 |
|
|
/* Set to the FUNC_BEGIN label of the current function, or NULL
|
234 |
|
|
if none. */
|
235 |
|
|
const char * current_function_func_begin_label;
|
236 |
|
|
|
237 |
|
|
/* Temporarily suppress certain warnings.
|
238 |
|
|
This is set while reading code from a system header file. */
|
239 |
|
|
|
240 |
|
|
int in_system_header = 0;
|
241 |
|
|
|
242 |
|
|
/* Nonzero means to collect statistics which might be expensive
|
243 |
|
|
and to print them when we are done. */
|
244 |
|
|
int flag_detailed_statistics = 0;
|
245 |
|
|
|
246 |
|
|
/* A random sequence of characters, unless overridden by user. */
|
247 |
|
|
const char *flag_random_seed;
|
248 |
|
|
|
249 |
|
|
/* A local time stamp derived from the time of compilation. It will be
|
250 |
|
|
zero if the system cannot provide a time. It will be -1u, if the
|
251 |
|
|
user has specified a particular random seed. */
|
252 |
|
|
unsigned local_tick;
|
253 |
|
|
|
254 |
|
|
/* -f flags. */
|
255 |
|
|
|
256 |
|
|
/* Nonzero means `char' should be signed. */
|
257 |
|
|
|
258 |
|
|
int flag_signed_char;
|
259 |
|
|
|
260 |
|
|
/* Nonzero means give an enum type only as many bytes as it needs. A value
|
261 |
|
|
of 2 means it has not yet been initialized. */
|
262 |
|
|
|
263 |
|
|
int flag_short_enums;
|
264 |
|
|
|
265 |
|
|
/* Nonzero if structures and unions should be returned in memory.
|
266 |
|
|
|
267 |
|
|
This should only be defined if compatibility with another compiler or
|
268 |
|
|
with an ABI is needed, because it results in slower code. */
|
269 |
|
|
|
270 |
|
|
#ifndef DEFAULT_PCC_STRUCT_RETURN
|
271 |
|
|
#define DEFAULT_PCC_STRUCT_RETURN 1
|
272 |
|
|
#endif
|
273 |
|
|
|
274 |
|
|
/* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
|
275 |
|
|
|
276 |
|
|
int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN;
|
277 |
|
|
|
278 |
|
|
/* 0 means straightforward implementation of complex divide acceptable.
|
279 |
|
|
1 means wide ranges of inputs must work for complex divide.
|
280 |
|
|
2 means C99-like requirements for complex multiply and divide. */
|
281 |
|
|
|
282 |
|
|
int flag_complex_method = 1;
|
283 |
|
|
|
284 |
|
|
/* Nonzero means that we don't want inlining by virtue of -fno-inline,
|
285 |
|
|
not just because the tree inliner turned us off. */
|
286 |
|
|
|
287 |
|
|
int flag_really_no_inline = 2;
|
288 |
|
|
|
289 |
|
|
/* Nonzero means we should be saving declaration info into a .X file. */
|
290 |
|
|
|
291 |
|
|
int flag_gen_aux_info = 0;
|
292 |
|
|
|
293 |
|
|
/* Specified name of aux-info file. */
|
294 |
|
|
|
295 |
|
|
const char *aux_info_file_name;
|
296 |
|
|
|
297 |
|
|
/* Nonzero if we are compiling code for a shared library, zero for
|
298 |
|
|
executable. */
|
299 |
|
|
|
300 |
|
|
int flag_shlib;
|
301 |
|
|
|
302 |
|
|
/* Generate code for GNU or NeXT Objective-C runtime environment. */
|
303 |
|
|
|
304 |
|
|
#ifdef NEXT_OBJC_RUNTIME
|
305 |
|
|
int flag_next_runtime = 1;
|
306 |
|
|
#else
|
307 |
|
|
int flag_next_runtime = 0;
|
308 |
|
|
#endif
|
309 |
|
|
|
310 |
|
|
/* Set to the default thread-local storage (tls) model to use. */
|
311 |
|
|
|
312 |
|
|
enum tls_model flag_tls_default = TLS_MODEL_GLOBAL_DYNAMIC;
|
313 |
|
|
|
314 |
|
|
/* Nonzero means change certain warnings into errors.
|
315 |
|
|
Usually these are warnings about failure to conform to some standard. */
|
316 |
|
|
|
317 |
|
|
int flag_pedantic_errors = 0;
|
318 |
|
|
|
319 |
|
|
/* -dA causes debug commentary information to be produced in
|
320 |
|
|
the generated assembly code (to make it more readable). This option
|
321 |
|
|
is generally only of use to those who actually need to read the
|
322 |
|
|
generated assembly code (perhaps while debugging the compiler itself).
|
323 |
|
|
Currently, this switch is only used by dwarfout.c; however, it is intended
|
324 |
|
|
to be a catchall for printing debug information in the assembler file. */
|
325 |
|
|
|
326 |
|
|
int flag_debug_asm = 0;
|
327 |
|
|
|
328 |
|
|
/* -dP causes the rtl to be emitted as a comment in assembly. */
|
329 |
|
|
|
330 |
|
|
int flag_dump_rtl_in_asm = 0;
|
331 |
|
|
|
332 |
|
|
/* When non-NULL, indicates that whenever space is allocated on the
|
333 |
|
|
stack, the resulting stack pointer must not pass this
|
334 |
|
|
address---that is, for stacks that grow downward, the stack pointer
|
335 |
|
|
must always be greater than or equal to this address; for stacks
|
336 |
|
|
that grow upward, the stack pointer must be less than this address.
|
337 |
|
|
At present, the rtx may be either a REG or a SYMBOL_REF, although
|
338 |
|
|
the support provided depends on the backend. */
|
339 |
|
|
rtx stack_limit_rtx;
|
340 |
|
|
|
341 |
|
|
/* If one, renumber instruction UIDs to reduce the number of
|
342 |
|
|
unused UIDs if there are a lot of instructions. If greater than
|
343 |
|
|
one, unconditionally renumber instruction UIDs. */
|
344 |
|
|
int flag_renumber_insns = 1;
|
345 |
|
|
|
346 |
|
|
/* Nonzero if we should track variables. When
|
347 |
|
|
flag_var_tracking == AUTODETECT_VALUE it will be set according
|
348 |
|
|
to optimize, debug_info_level and debug_hooks in process_options (). */
|
349 |
|
|
int flag_var_tracking = AUTODETECT_VALUE;
|
350 |
|
|
|
351 |
|
|
/* True if the user has tagged the function with the 'section'
|
352 |
|
|
attribute. */
|
353 |
|
|
|
354 |
|
|
bool user_defined_section_attribute = false;
|
355 |
|
|
|
356 |
|
|
/* Values of the -falign-* flags: how much to align labels in code.
|
357 |
|
|
|
358 |
|
|
For each variable, there is an _log variant which is the power
|
359 |
|
|
of two not less than the variable, for .align output. */
|
360 |
|
|
|
361 |
|
|
int align_loops_log;
|
362 |
|
|
int align_loops_max_skip;
|
363 |
|
|
int align_jumps_log;
|
364 |
|
|
int align_jumps_max_skip;
|
365 |
|
|
int align_labels_log;
|
366 |
|
|
int align_labels_max_skip;
|
367 |
|
|
int align_functions_log;
|
368 |
|
|
|
369 |
|
|
/* Like align_functions_log above, but used by front-ends to force the
|
370 |
|
|
minimum function alignment. Zero means no alignment is forced. */
|
371 |
|
|
int force_align_functions_log;
|
372 |
|
|
|
373 |
|
|
typedef struct
|
374 |
|
|
{
|
375 |
|
|
const char *const string;
|
376 |
|
|
int *const variable;
|
377 |
|
|
const int on_value;
|
378 |
|
|
}
|
379 |
|
|
lang_independent_options;
|
380 |
|
|
|
381 |
|
|
/* Nonzero if subexpressions must be evaluated from left-to-right. */
|
382 |
|
|
int flag_evaluation_order = 0;
|
383 |
|
|
|
384 |
|
|
/* The user symbol prefix after having resolved same. */
|
385 |
|
|
const char *user_label_prefix;
|
386 |
|
|
|
387 |
|
|
static const param_info lang_independent_params[] = {
|
388 |
|
|
#define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
|
389 |
|
|
{ OPTION, DEFAULT, MIN, MAX, HELP },
|
390 |
|
|
#include "params.def"
|
391 |
|
|
#undef DEFPARAM
|
392 |
|
|
{ NULL, 0, 0, 0, NULL }
|
393 |
|
|
};
|
394 |
|
|
|
395 |
|
|
/* Output files for assembler code (real compiler output)
|
396 |
|
|
and debugging dumps. */
|
397 |
|
|
|
398 |
|
|
FILE *asm_out_file;
|
399 |
|
|
FILE *aux_info_file;
|
400 |
|
|
FILE *dump_file = NULL;
|
401 |
|
|
const char *dump_file_name;
|
402 |
|
|
|
403 |
|
|
/* The current working directory of a translation. It's generally the
|
404 |
|
|
directory from which compilation was initiated, but a preprocessed
|
405 |
|
|
file may specify the original directory in which it was
|
406 |
|
|
created. */
|
407 |
|
|
|
408 |
|
|
static const char *src_pwd;
|
409 |
|
|
|
410 |
|
|
/* Initialize src_pwd with the given string, and return true. If it
|
411 |
|
|
was already initialized, return false. As a special case, it may
|
412 |
|
|
be called with a NULL argument to test whether src_pwd has NOT been
|
413 |
|
|
initialized yet. */
|
414 |
|
|
|
415 |
|
|
bool
|
416 |
|
|
set_src_pwd (const char *pwd)
|
417 |
|
|
{
|
418 |
|
|
if (src_pwd)
|
419 |
|
|
{
|
420 |
|
|
if (strcmp (src_pwd, pwd) == 0)
|
421 |
|
|
return true;
|
422 |
|
|
else
|
423 |
|
|
return false;
|
424 |
|
|
}
|
425 |
|
|
|
426 |
|
|
src_pwd = xstrdup (pwd);
|
427 |
|
|
return true;
|
428 |
|
|
}
|
429 |
|
|
|
430 |
|
|
/* Return the directory from which the translation unit was initiated,
|
431 |
|
|
in case set_src_pwd() was not called before to assign it a
|
432 |
|
|
different value. */
|
433 |
|
|
|
434 |
|
|
const char *
|
435 |
|
|
get_src_pwd (void)
|
436 |
|
|
{
|
437 |
|
|
if (! src_pwd)
|
438 |
|
|
{
|
439 |
|
|
src_pwd = getpwd ();
|
440 |
|
|
if (!src_pwd)
|
441 |
|
|
src_pwd = ".";
|
442 |
|
|
}
|
443 |
|
|
|
444 |
|
|
return src_pwd;
|
445 |
|
|
}
|
446 |
|
|
|
447 |
|
|
/* Called when the start of a function definition is parsed,
|
448 |
|
|
this function prints on stderr the name of the function. */
|
449 |
|
|
void
|
450 |
|
|
announce_function (tree decl)
|
451 |
|
|
{
|
452 |
|
|
if (!quiet_flag)
|
453 |
|
|
{
|
454 |
|
|
if (rtl_dump_and_exit)
|
455 |
|
|
fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl)));
|
456 |
|
|
else
|
457 |
|
|
fprintf (stderr, " %s", lang_hooks.decl_printable_name (decl, 2));
|
458 |
|
|
fflush (stderr);
|
459 |
|
|
pp_needs_newline (global_dc->printer) = true;
|
460 |
|
|
diagnostic_set_last_function (global_dc);
|
461 |
|
|
}
|
462 |
|
|
}
|
463 |
|
|
|
464 |
|
|
/* Set up a default flag_random_seed and local_tick, unless the user
|
465 |
|
|
already specified one. */
|
466 |
|
|
|
467 |
|
|
static void
|
468 |
|
|
randomize (void)
|
469 |
|
|
{
|
470 |
|
|
if (!flag_random_seed)
|
471 |
|
|
{
|
472 |
|
|
unsigned HOST_WIDE_INT value;
|
473 |
|
|
static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
|
474 |
|
|
|
475 |
|
|
/* Get some more or less random data. */
|
476 |
|
|
#ifdef HAVE_GETTIMEOFDAY
|
477 |
|
|
{
|
478 |
|
|
struct timeval tv;
|
479 |
|
|
|
480 |
|
|
gettimeofday (&tv, NULL);
|
481 |
|
|
local_tick = tv.tv_sec * 1000 + tv.tv_usec / 1000;
|
482 |
|
|
}
|
483 |
|
|
#else
|
484 |
|
|
{
|
485 |
|
|
time_t now = time (NULL);
|
486 |
|
|
|
487 |
|
|
if (now != (time_t)-1)
|
488 |
|
|
local_tick = (unsigned) now;
|
489 |
|
|
}
|
490 |
|
|
#endif
|
491 |
|
|
value = local_tick ^ getpid ();
|
492 |
|
|
|
493 |
|
|
sprintf (random_seed, HOST_WIDE_INT_PRINT_HEX, value);
|
494 |
|
|
flag_random_seed = random_seed;
|
495 |
|
|
}
|
496 |
|
|
else if (!local_tick)
|
497 |
|
|
local_tick = -1;
|
498 |
|
|
}
|
499 |
|
|
|
500 |
|
|
|
501 |
|
|
/* Decode the string P as an integral parameter.
|
502 |
|
|
If the string is indeed an integer return its numeric value else
|
503 |
|
|
issue an Invalid Option error for the option PNAME and return DEFVAL.
|
504 |
|
|
If PNAME is zero just return DEFVAL, do not call error. */
|
505 |
|
|
|
506 |
|
|
int
|
507 |
|
|
read_integral_parameter (const char *p, const char *pname, const int defval)
|
508 |
|
|
{
|
509 |
|
|
const char *endp = p;
|
510 |
|
|
|
511 |
|
|
while (*endp)
|
512 |
|
|
{
|
513 |
|
|
if (ISDIGIT (*endp))
|
514 |
|
|
endp++;
|
515 |
|
|
else
|
516 |
|
|
break;
|
517 |
|
|
}
|
518 |
|
|
|
519 |
|
|
if (*endp != 0)
|
520 |
|
|
{
|
521 |
|
|
if (pname != 0)
|
522 |
|
|
error ("invalid option argument %qs", pname);
|
523 |
|
|
return defval;
|
524 |
|
|
}
|
525 |
|
|
|
526 |
|
|
return atoi (p);
|
527 |
|
|
}
|
528 |
|
|
|
529 |
|
|
/* When compiling with a recent enough GCC, we use the GNU C "extern inline"
|
530 |
|
|
for floor_log2 and exact_log2; see toplev.h. That construct, however,
|
531 |
|
|
conflicts with the ISO C++ One Definition Rule. */
|
532 |
|
|
|
533 |
|
|
#if GCC_VERSION < 3004 || !defined (__cplusplus)
|
534 |
|
|
|
535 |
|
|
/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
|
536 |
|
|
If X is 0, return -1. */
|
537 |
|
|
|
538 |
|
|
int
|
539 |
|
|
floor_log2 (unsigned HOST_WIDE_INT x)
|
540 |
|
|
{
|
541 |
|
|
int t = 0;
|
542 |
|
|
|
543 |
|
|
if (x == 0)
|
544 |
|
|
return -1;
|
545 |
|
|
|
546 |
|
|
#ifdef CLZ_HWI
|
547 |
|
|
t = HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x);
|
548 |
|
|
#else
|
549 |
|
|
if (HOST_BITS_PER_WIDE_INT > 64)
|
550 |
|
|
if (x >= (unsigned HOST_WIDE_INT) 1 << (t + 64))
|
551 |
|
|
t += 64;
|
552 |
|
|
if (HOST_BITS_PER_WIDE_INT > 32)
|
553 |
|
|
if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 32))
|
554 |
|
|
t += 32;
|
555 |
|
|
if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 16))
|
556 |
|
|
t += 16;
|
557 |
|
|
if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 8))
|
558 |
|
|
t += 8;
|
559 |
|
|
if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 4))
|
560 |
|
|
t += 4;
|
561 |
|
|
if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 2))
|
562 |
|
|
t += 2;
|
563 |
|
|
if (x >= ((unsigned HOST_WIDE_INT) 1) << (t + 1))
|
564 |
|
|
t += 1;
|
565 |
|
|
#endif
|
566 |
|
|
|
567 |
|
|
return t;
|
568 |
|
|
}
|
569 |
|
|
|
570 |
|
|
/* Return the logarithm of X, base 2, considering X unsigned,
|
571 |
|
|
if X is a power of 2. Otherwise, returns -1. */
|
572 |
|
|
|
573 |
|
|
int
|
574 |
|
|
exact_log2 (unsigned HOST_WIDE_INT x)
|
575 |
|
|
{
|
576 |
|
|
if (x != (x & -x))
|
577 |
|
|
return -1;
|
578 |
|
|
#ifdef CTZ_HWI
|
579 |
|
|
return x ? CTZ_HWI (x) : -1;
|
580 |
|
|
#else
|
581 |
|
|
return floor_log2 (x);
|
582 |
|
|
#endif
|
583 |
|
|
}
|
584 |
|
|
|
585 |
|
|
#endif /* GCC_VERSION < 3004 || !defined (__cplusplus) */
|
586 |
|
|
|
587 |
|
|
/* Handler for fatal signals, such as SIGSEGV. These are transformed
|
588 |
|
|
into ICE messages, which is much more user friendly. In case the
|
589 |
|
|
error printer crashes, reset the signal to prevent infinite recursion. */
|
590 |
|
|
|
591 |
|
|
static void
|
592 |
|
|
crash_signal (int signo)
|
593 |
|
|
{
|
594 |
|
|
signal (signo, SIG_DFL);
|
595 |
|
|
|
596 |
|
|
/* If we crashed while processing an ASM statement, then be a little more
|
597 |
|
|
graceful. It's most likely the user's fault. */
|
598 |
|
|
if (this_is_asm_operands)
|
599 |
|
|
{
|
600 |
|
|
output_operand_lossage ("unrecoverable error");
|
601 |
|
|
exit (FATAL_EXIT_CODE);
|
602 |
|
|
}
|
603 |
|
|
|
604 |
|
|
internal_error ("%s", strsignal (signo));
|
605 |
|
|
}
|
606 |
|
|
|
607 |
|
|
/* Arrange to dump core on error. (The regular error message is still
|
608 |
|
|
printed first, except in the case of abort().) */
|
609 |
|
|
|
610 |
|
|
static void
|
611 |
|
|
setup_core_dumping (void)
|
612 |
|
|
{
|
613 |
|
|
#ifdef SIGABRT
|
614 |
|
|
signal (SIGABRT, SIG_DFL);
|
615 |
|
|
#endif
|
616 |
|
|
#if defined(HAVE_SETRLIMIT)
|
617 |
|
|
{
|
618 |
|
|
struct rlimit rlim;
|
619 |
|
|
if (getrlimit (RLIMIT_CORE, &rlim) != 0)
|
620 |
|
|
fatal_error ("getting core file size maximum limit: %m");
|
621 |
|
|
rlim.rlim_cur = rlim.rlim_max;
|
622 |
|
|
if (setrlimit (RLIMIT_CORE, &rlim) != 0)
|
623 |
|
|
fatal_error ("setting core file size limit to maximum: %m");
|
624 |
|
|
}
|
625 |
|
|
#endif
|
626 |
|
|
diagnostic_abort_on_error (global_dc);
|
627 |
|
|
}
|
628 |
|
|
|
629 |
|
|
|
630 |
|
|
/* Strip off a legitimate source ending from the input string NAME of
|
631 |
|
|
length LEN. Rather than having to know the names used by all of
|
632 |
|
|
our front ends, we strip off an ending of a period followed by
|
633 |
|
|
up to five characters. (Java uses ".class".) */
|
634 |
|
|
|
635 |
|
|
void
|
636 |
|
|
strip_off_ending (char *name, int len)
|
637 |
|
|
{
|
638 |
|
|
int i;
|
639 |
|
|
for (i = 2; i < 6 && len > i; i++)
|
640 |
|
|
{
|
641 |
|
|
if (name[len - i] == '.')
|
642 |
|
|
{
|
643 |
|
|
name[len - i] = '\0';
|
644 |
|
|
break;
|
645 |
|
|
}
|
646 |
|
|
}
|
647 |
|
|
}
|
648 |
|
|
|
649 |
|
|
/* Output a quoted string. */
|
650 |
|
|
|
651 |
|
|
void
|
652 |
|
|
output_quoted_string (FILE *asm_file, const char *string)
|
653 |
|
|
{
|
654 |
|
|
#ifdef OUTPUT_QUOTED_STRING
|
655 |
|
|
OUTPUT_QUOTED_STRING (asm_file, string);
|
656 |
|
|
#else
|
657 |
|
|
char c;
|
658 |
|
|
|
659 |
|
|
putc ('\"', asm_file);
|
660 |
|
|
while ((c = *string++) != 0)
|
661 |
|
|
{
|
662 |
|
|
if (ISPRINT (c))
|
663 |
|
|
{
|
664 |
|
|
if (c == '\"' || c == '\\')
|
665 |
|
|
putc ('\\', asm_file);
|
666 |
|
|
putc (c, asm_file);
|
667 |
|
|
}
|
668 |
|
|
else
|
669 |
|
|
fprintf (asm_file, "\\%03o", (unsigned char) c);
|
670 |
|
|
}
|
671 |
|
|
putc ('\"', asm_file);
|
672 |
|
|
#endif
|
673 |
|
|
}
|
674 |
|
|
|
675 |
|
|
/* Output a file name in the form wanted by System V. */
|
676 |
|
|
|
677 |
|
|
void
|
678 |
|
|
output_file_directive (FILE *asm_file, const char *input_name)
|
679 |
|
|
{
|
680 |
|
|
int len;
|
681 |
|
|
const char *na;
|
682 |
|
|
|
683 |
|
|
if (input_name == NULL)
|
684 |
|
|
input_name = "<stdin>";
|
685 |
|
|
|
686 |
|
|
len = strlen (input_name);
|
687 |
|
|
na = input_name + len;
|
688 |
|
|
|
689 |
|
|
/* NA gets INPUT_NAME sans directory names. */
|
690 |
|
|
while (na > input_name)
|
691 |
|
|
{
|
692 |
|
|
if (IS_DIR_SEPARATOR (na[-1]))
|
693 |
|
|
break;
|
694 |
|
|
na--;
|
695 |
|
|
}
|
696 |
|
|
|
697 |
|
|
#ifdef ASM_OUTPUT_SOURCE_FILENAME
|
698 |
|
|
ASM_OUTPUT_SOURCE_FILENAME (asm_file, na);
|
699 |
|
|
#else
|
700 |
|
|
fprintf (asm_file, "\t.file\t");
|
701 |
|
|
output_quoted_string (asm_file, na);
|
702 |
|
|
fputc ('\n', asm_file);
|
703 |
|
|
#endif
|
704 |
|
|
}
|
705 |
|
|
|
706 |
|
|
/* A subroutine of wrapup_global_declarations. We've come to the end of
|
707 |
|
|
the compilation unit. All deferred variables should be undeferred,
|
708 |
|
|
and all incomplete decls should be finalized. */
|
709 |
|
|
|
710 |
|
|
void
|
711 |
|
|
wrapup_global_declaration_1 (tree decl)
|
712 |
|
|
{
|
713 |
|
|
/* We're not deferring this any longer. Assignment is conditional to
|
714 |
|
|
avoid needlessly dirtying PCH pages. */
|
715 |
|
|
if (CODE_CONTAINS_STRUCT (TREE_CODE (decl), TS_DECL_WITH_VIS)
|
716 |
|
|
&& DECL_DEFER_OUTPUT (decl) != 0)
|
717 |
|
|
DECL_DEFER_OUTPUT (decl) = 0;
|
718 |
|
|
|
719 |
|
|
if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0)
|
720 |
|
|
lang_hooks.finish_incomplete_decl (decl);
|
721 |
|
|
}
|
722 |
|
|
|
723 |
|
|
/* A subroutine of wrapup_global_declarations. Decide whether or not DECL
|
724 |
|
|
needs to be output. Return true if it is output. */
|
725 |
|
|
|
726 |
|
|
bool
|
727 |
|
|
wrapup_global_declaration_2 (tree decl)
|
728 |
|
|
{
|
729 |
|
|
if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl))
|
730 |
|
|
return false;
|
731 |
|
|
|
732 |
|
|
/* Don't write out static consts, unless we still need them.
|
733 |
|
|
|
734 |
|
|
We also keep static consts if not optimizing (for debugging),
|
735 |
|
|
unless the user specified -fno-keep-static-consts.
|
736 |
|
|
??? They might be better written into the debug information.
|
737 |
|
|
This is possible when using DWARF.
|
738 |
|
|
|
739 |
|
|
A language processor that wants static constants to be always
|
740 |
|
|
written out (even if it is not used) is responsible for
|
741 |
|
|
calling rest_of_decl_compilation itself. E.g. the C front-end
|
742 |
|
|
calls rest_of_decl_compilation from finish_decl.
|
743 |
|
|
One motivation for this is that is conventional in some
|
744 |
|
|
environments to write things like:
|
745 |
|
|
static const char rcsid[] = "... version string ...";
|
746 |
|
|
intending to force the string to be in the executable.
|
747 |
|
|
|
748 |
|
|
A language processor that would prefer to have unneeded
|
749 |
|
|
static constants "optimized away" would just defer writing
|
750 |
|
|
them out until here. E.g. C++ does this, because static
|
751 |
|
|
constants are often defined in header files.
|
752 |
|
|
|
753 |
|
|
??? A tempting alternative (for both C and C++) would be
|
754 |
|
|
to force a constant to be written if and only if it is
|
755 |
|
|
defined in a main file, as opposed to an include file. */
|
756 |
|
|
|
757 |
|
|
if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
|
758 |
|
|
{
|
759 |
|
|
struct cgraph_varpool_node *node;
|
760 |
|
|
bool needed = true;
|
761 |
|
|
node = cgraph_varpool_node (decl);
|
762 |
|
|
|
763 |
|
|
if (node->finalized)
|
764 |
|
|
needed = false;
|
765 |
|
|
else if (node->alias)
|
766 |
|
|
needed = false;
|
767 |
|
|
else if (!cgraph_global_info_ready
|
768 |
|
|
&& (TREE_USED (decl)
|
769 |
|
|
|| TREE_USED (DECL_ASSEMBLER_NAME (decl))))
|
770 |
|
|
/* needed */;
|
771 |
|
|
else if (node->needed)
|
772 |
|
|
/* needed */;
|
773 |
|
|
else if (DECL_COMDAT (decl))
|
774 |
|
|
needed = false;
|
775 |
|
|
else if (TREE_READONLY (decl) && !TREE_PUBLIC (decl)
|
776 |
|
|
&& (optimize || !flag_keep_static_consts
|
777 |
|
|
|| DECL_ARTIFICIAL (decl)))
|
778 |
|
|
needed = false;
|
779 |
|
|
|
780 |
|
|
if (needed)
|
781 |
|
|
{
|
782 |
|
|
rest_of_decl_compilation (decl, 1, 1);
|
783 |
|
|
return true;
|
784 |
|
|
}
|
785 |
|
|
}
|
786 |
|
|
|
787 |
|
|
return false;
|
788 |
|
|
}
|
789 |
|
|
|
790 |
|
|
/* Do any final processing required for the declarations in VEC, of
|
791 |
|
|
which there are LEN. We write out inline functions and variables
|
792 |
|
|
that have been deferred until this point, but which are required.
|
793 |
|
|
Returns nonzero if anything was put out. */
|
794 |
|
|
|
795 |
|
|
bool
|
796 |
|
|
wrapup_global_declarations (tree *vec, int len)
|
797 |
|
|
{
|
798 |
|
|
bool reconsider, output_something = false;
|
799 |
|
|
int i;
|
800 |
|
|
|
801 |
|
|
for (i = 0; i < len; i++)
|
802 |
|
|
wrapup_global_declaration_1 (vec[i]);
|
803 |
|
|
|
804 |
|
|
/* Now emit any global variables or functions that we have been
|
805 |
|
|
putting off. We need to loop in case one of the things emitted
|
806 |
|
|
here references another one which comes earlier in the list. */
|
807 |
|
|
do
|
808 |
|
|
{
|
809 |
|
|
reconsider = false;
|
810 |
|
|
for (i = 0; i < len; i++)
|
811 |
|
|
reconsider |= wrapup_global_declaration_2 (vec[i]);
|
812 |
|
|
if (reconsider)
|
813 |
|
|
output_something = true;
|
814 |
|
|
}
|
815 |
|
|
while (reconsider);
|
816 |
|
|
|
817 |
|
|
return output_something;
|
818 |
|
|
}
|
819 |
|
|
|
820 |
|
|
/* A subroutine of check_global_declarations. Issue appropriate warnings
|
821 |
|
|
for the global declaration DECL. */
|
822 |
|
|
|
823 |
|
|
void
|
824 |
|
|
check_global_declaration_1 (tree decl)
|
825 |
|
|
{
|
826 |
|
|
/* Warn about any function declared static but not defined. We don't
|
827 |
|
|
warn about variables, because many programs have static variables
|
828 |
|
|
that exist only to get some text into the object file. */
|
829 |
|
|
if (TREE_CODE (decl) == FUNCTION_DECL
|
830 |
|
|
&& DECL_INITIAL (decl) == 0
|
831 |
|
|
&& DECL_EXTERNAL (decl)
|
832 |
|
|
&& ! DECL_ARTIFICIAL (decl)
|
833 |
|
|
&& ! TREE_NO_WARNING (decl)
|
834 |
|
|
&& ! TREE_PUBLIC (decl)
|
835 |
|
|
&& (warn_unused_function
|
836 |
|
|
|| TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))))
|
837 |
|
|
{
|
838 |
|
|
if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))
|
839 |
|
|
pedwarn ("%q+F used but never defined", decl);
|
840 |
|
|
else
|
841 |
|
|
warning (0, "%q+F declared %<static%> but never defined", decl);
|
842 |
|
|
/* This symbol is effectively an "extern" declaration now. */
|
843 |
|
|
TREE_PUBLIC (decl) = 1;
|
844 |
|
|
assemble_external (decl);
|
845 |
|
|
}
|
846 |
|
|
|
847 |
|
|
/* Warn about static fns or vars defined but not used. */
|
848 |
|
|
if (((warn_unused_function && TREE_CODE (decl) == FUNCTION_DECL)
|
849 |
|
|
/* We don't warn about "static const" variables because the
|
850 |
|
|
"rcs_id" idiom uses that construction. */
|
851 |
|
|
|| (warn_unused_variable
|
852 |
|
|
&& TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl)))
|
853 |
|
|
&& ! DECL_IN_SYSTEM_HEADER (decl)
|
854 |
|
|
&& ! TREE_USED (decl)
|
855 |
|
|
/* The TREE_USED bit for file-scope decls is kept in the identifier,
|
856 |
|
|
to handle multiple external decls in different scopes. */
|
857 |
|
|
&& ! (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))
|
858 |
|
|
&& ! DECL_EXTERNAL (decl)
|
859 |
|
|
&& ! TREE_PUBLIC (decl)
|
860 |
|
|
/* A volatile variable might be used in some non-obvious way. */
|
861 |
|
|
&& ! TREE_THIS_VOLATILE (decl)
|
862 |
|
|
/* Global register variables must be declared to reserve them. */
|
863 |
|
|
&& ! (TREE_CODE (decl) == VAR_DECL && DECL_REGISTER (decl))
|
864 |
|
|
/* Otherwise, ask the language. */
|
865 |
|
|
&& lang_hooks.decls.warn_unused_global (decl))
|
866 |
|
|
warning (0, "%q+D defined but not used", decl);
|
867 |
|
|
}
|
868 |
|
|
|
869 |
|
|
/* Issue appropriate warnings for the global declarations in VEC (of
|
870 |
|
|
which there are LEN). */
|
871 |
|
|
|
872 |
|
|
void
|
873 |
|
|
check_global_declarations (tree *vec, int len)
|
874 |
|
|
{
|
875 |
|
|
int i;
|
876 |
|
|
|
877 |
|
|
for (i = 0; i < len; i++)
|
878 |
|
|
check_global_declaration_1 (vec[i]);
|
879 |
|
|
}
|
880 |
|
|
|
881 |
|
|
/* Emit debugging information for all global declarations in VEC. */
|
882 |
|
|
|
883 |
|
|
void
|
884 |
|
|
emit_debug_global_declarations (tree *vec, int len)
|
885 |
|
|
{
|
886 |
|
|
int i;
|
887 |
|
|
|
888 |
|
|
/* Avoid confusing the debug information machinery when there are errors. */
|
889 |
|
|
if (errorcount != 0 || sorrycount != 0)
|
890 |
|
|
return;
|
891 |
|
|
|
892 |
|
|
timevar_push (TV_SYMOUT);
|
893 |
|
|
for (i = 0; i < len; i++)
|
894 |
|
|
debug_hooks->global_decl (vec[i]);
|
895 |
|
|
timevar_pop (TV_SYMOUT);
|
896 |
|
|
}
|
897 |
|
|
|
898 |
|
|
/* Warn about a use of an identifier which was marked deprecated. */
|
899 |
|
|
void
|
900 |
|
|
warn_deprecated_use (tree node)
|
901 |
|
|
{
|
902 |
|
|
if (node == 0 || !warn_deprecated_decl)
|
903 |
|
|
return;
|
904 |
|
|
|
905 |
|
|
if (DECL_P (node))
|
906 |
|
|
{
|
907 |
|
|
expanded_location xloc = expand_location (DECL_SOURCE_LOCATION (node));
|
908 |
|
|
warning (OPT_Wdeprecated_declarations,
|
909 |
|
|
"%qs is deprecated (declared at %s:%d)",
|
910 |
|
|
IDENTIFIER_POINTER (DECL_NAME (node)),
|
911 |
|
|
xloc.file, xloc.line);
|
912 |
|
|
}
|
913 |
|
|
else if (TYPE_P (node))
|
914 |
|
|
{
|
915 |
|
|
const char *what = NULL;
|
916 |
|
|
tree decl = TYPE_STUB_DECL (node);
|
917 |
|
|
|
918 |
|
|
if (TYPE_NAME (node))
|
919 |
|
|
{
|
920 |
|
|
if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
|
921 |
|
|
what = IDENTIFIER_POINTER (TYPE_NAME (node));
|
922 |
|
|
else if (TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
|
923 |
|
|
&& DECL_NAME (TYPE_NAME (node)))
|
924 |
|
|
what = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node)));
|
925 |
|
|
}
|
926 |
|
|
|
927 |
|
|
if (decl)
|
928 |
|
|
{
|
929 |
|
|
expanded_location xloc
|
930 |
|
|
= expand_location (DECL_SOURCE_LOCATION (decl));
|
931 |
|
|
if (what)
|
932 |
|
|
warning (OPT_Wdeprecated_declarations,
|
933 |
|
|
"%qs is deprecated (declared at %s:%d)", what,
|
934 |
|
|
xloc.file, xloc.line);
|
935 |
|
|
else
|
936 |
|
|
warning (OPT_Wdeprecated_declarations,
|
937 |
|
|
"type is deprecated (declared at %s:%d)",
|
938 |
|
|
xloc.file, xloc.line);
|
939 |
|
|
}
|
940 |
|
|
else
|
941 |
|
|
{
|
942 |
|
|
if (what)
|
943 |
|
|
warning (OPT_Wdeprecated_declarations, "%qs is deprecated", what);
|
944 |
|
|
else
|
945 |
|
|
warning (OPT_Wdeprecated_declarations, "type is deprecated");
|
946 |
|
|
}
|
947 |
|
|
}
|
948 |
|
|
}
|
949 |
|
|
|
950 |
|
|
/* Save the current INPUT_LOCATION on the top entry in the
|
951 |
|
|
INPUT_FILE_STACK. Push a new entry for FILE and LINE, and set the
|
952 |
|
|
INPUT_LOCATION accordingly. */
|
953 |
|
|
|
954 |
|
|
void
|
955 |
|
|
#ifdef USE_MAPPED_LOCATION
|
956 |
|
|
push_srcloc (location_t fline)
|
957 |
|
|
#else
|
958 |
|
|
push_srcloc (const char *file, int line)
|
959 |
|
|
#endif
|
960 |
|
|
{
|
961 |
|
|
struct file_stack *fs;
|
962 |
|
|
|
963 |
|
|
gcc_assert (!input_file_stack_restored);
|
964 |
|
|
if (input_file_stack_tick == (int) ((1U << INPUT_FILE_STACK_BITS) - 1))
|
965 |
|
|
sorry ("GCC supports only %d input file changes", input_file_stack_tick);
|
966 |
|
|
|
967 |
|
|
fs = XNEW (struct file_stack);
|
968 |
|
|
fs->location = input_location;
|
969 |
|
|
fs->next = input_file_stack;
|
970 |
|
|
#ifdef USE_MAPPED_LOCATION
|
971 |
|
|
input_location = fline;
|
972 |
|
|
#else
|
973 |
|
|
input_filename = file;
|
974 |
|
|
input_line = line;
|
975 |
|
|
#endif
|
976 |
|
|
input_file_stack = fs;
|
977 |
|
|
input_file_stack_tick++;
|
978 |
|
|
VEC_safe_push (fs_p, heap, input_file_stack_history, input_file_stack);
|
979 |
|
|
}
|
980 |
|
|
|
981 |
|
|
/* Pop the top entry off the stack of presently open source files.
|
982 |
|
|
Restore the INPUT_LOCATION from the new topmost entry on the
|
983 |
|
|
stack. */
|
984 |
|
|
|
985 |
|
|
void
|
986 |
|
|
pop_srcloc (void)
|
987 |
|
|
{
|
988 |
|
|
struct file_stack *fs;
|
989 |
|
|
|
990 |
|
|
gcc_assert (!input_file_stack_restored);
|
991 |
|
|
if (input_file_stack_tick == (int) ((1U << INPUT_FILE_STACK_BITS) - 1))
|
992 |
|
|
sorry ("GCC supports only %d input file changes", input_file_stack_tick);
|
993 |
|
|
|
994 |
|
|
fs = input_file_stack;
|
995 |
|
|
input_location = fs->location;
|
996 |
|
|
input_file_stack = fs->next;
|
997 |
|
|
input_file_stack_tick++;
|
998 |
|
|
VEC_safe_push (fs_p, heap, input_file_stack_history, input_file_stack);
|
999 |
|
|
}
|
1000 |
|
|
|
1001 |
|
|
/* Restore the input file stack to its state as of TICK, for the sake
|
1002 |
|
|
of diagnostics after processing the whole input. Once this has
|
1003 |
|
|
been called, push_srcloc and pop_srcloc may no longer be
|
1004 |
|
|
called. */
|
1005 |
|
|
void
|
1006 |
|
|
restore_input_file_stack (int tick)
|
1007 |
|
|
{
|
1008 |
|
|
if (tick == 0)
|
1009 |
|
|
input_file_stack = NULL;
|
1010 |
|
|
else
|
1011 |
|
|
input_file_stack = VEC_index (fs_p, input_file_stack_history, tick - 1);
|
1012 |
|
|
input_file_stack_tick = tick;
|
1013 |
|
|
input_file_stack_restored = true;
|
1014 |
|
|
}
|
1015 |
|
|
|
1016 |
|
|
/* Compile an entire translation unit. Write a file of assembly
|
1017 |
|
|
output and various debugging dumps. */
|
1018 |
|
|
|
1019 |
|
|
static void
|
1020 |
|
|
compile_file (void)
|
1021 |
|
|
{
|
1022 |
|
|
/* Initialize yet another pass. */
|
1023 |
|
|
|
1024 |
|
|
init_cgraph ();
|
1025 |
|
|
init_final (main_input_filename);
|
1026 |
|
|
coverage_init (aux_base_name);
|
1027 |
|
|
|
1028 |
|
|
timevar_push (TV_PARSE);
|
1029 |
|
|
|
1030 |
|
|
/* Call the parser, which parses the entire file (calling
|
1031 |
|
|
rest_of_compilation for each function). */
|
1032 |
|
|
lang_hooks.parse_file (set_yydebug);
|
1033 |
|
|
|
1034 |
|
|
/* In case there were missing block closers,
|
1035 |
|
|
get us back to the global binding level. */
|
1036 |
|
|
lang_hooks.clear_binding_stack ();
|
1037 |
|
|
|
1038 |
|
|
/* Compilation is now finished except for writing
|
1039 |
|
|
what's left of the symbol table output. */
|
1040 |
|
|
timevar_pop (TV_PARSE);
|
1041 |
|
|
|
1042 |
|
|
if (flag_syntax_only || errorcount || sorrycount)
|
1043 |
|
|
return;
|
1044 |
|
|
|
1045 |
|
|
lang_hooks.decls.final_write_globals ();
|
1046 |
|
|
cgraph_varpool_assemble_pending_decls ();
|
1047 |
|
|
finish_aliases_2 ();
|
1048 |
|
|
|
1049 |
|
|
/* This must occur after the loop to output deferred functions.
|
1050 |
|
|
Else the coverage initializer would not be emitted if all the
|
1051 |
|
|
functions in this compilation unit were deferred. */
|
1052 |
|
|
coverage_finish ();
|
1053 |
|
|
|
1054 |
|
|
/* Likewise for mudflap static object registrations. */
|
1055 |
|
|
if (flag_mudflap)
|
1056 |
|
|
mudflap_finish_file ();
|
1057 |
|
|
|
1058 |
|
|
output_shared_constant_pool ();
|
1059 |
|
|
output_object_blocks ();
|
1060 |
|
|
|
1061 |
|
|
/* Write out any pending weak symbol declarations. */
|
1062 |
|
|
|
1063 |
|
|
weak_finish ();
|
1064 |
|
|
|
1065 |
|
|
/* Do dbx symbols. */
|
1066 |
|
|
timevar_push (TV_SYMOUT);
|
1067 |
|
|
|
1068 |
|
|
#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
|
1069 |
|
|
if (dwarf2out_do_frame ())
|
1070 |
|
|
dwarf2out_frame_finish ();
|
1071 |
|
|
#endif
|
1072 |
|
|
|
1073 |
|
|
(*debug_hooks->finish) (main_input_filename);
|
1074 |
|
|
timevar_pop (TV_SYMOUT);
|
1075 |
|
|
|
1076 |
|
|
/* Output some stuff at end of file if nec. */
|
1077 |
|
|
|
1078 |
|
|
dw2_output_indirect_constants ();
|
1079 |
|
|
|
1080 |
|
|
/* Flush any pending external directives. cgraph did this for
|
1081 |
|
|
assemble_external calls from the front end, but the RTL
|
1082 |
|
|
expander can also generate them. */
|
1083 |
|
|
process_pending_assemble_externals ();
|
1084 |
|
|
|
1085 |
|
|
/* Attach a special .ident directive to the end of the file to identify
|
1086 |
|
|
the version of GCC which compiled this code. The format of the .ident
|
1087 |
|
|
string is patterned after the ones produced by native SVR4 compilers. */
|
1088 |
|
|
#ifdef IDENT_ASM_OP
|
1089 |
|
|
if (!flag_no_ident)
|
1090 |
|
|
fprintf (asm_out_file, "%s\"GCC: (GNU) %s\"\n",
|
1091 |
|
|
IDENT_ASM_OP, version_string);
|
1092 |
|
|
#endif
|
1093 |
|
|
|
1094 |
|
|
/* This must be at the end. Some target ports emit end of file directives
|
1095 |
|
|
into the assembly file here, and hence we can not output anything to the
|
1096 |
|
|
assembly file after this point. */
|
1097 |
|
|
targetm.asm_out.file_end ();
|
1098 |
|
|
}
|
1099 |
|
|
|
1100 |
|
|
/* Parse a -d... command line switch. */
|
1101 |
|
|
|
1102 |
|
|
void
|
1103 |
|
|
decode_d_option (const char *arg)
|
1104 |
|
|
{
|
1105 |
|
|
int c;
|
1106 |
|
|
|
1107 |
|
|
while (*arg)
|
1108 |
|
|
switch (c = *arg++)
|
1109 |
|
|
{
|
1110 |
|
|
case 'A':
|
1111 |
|
|
flag_debug_asm = 1;
|
1112 |
|
|
break;
|
1113 |
|
|
case 'p':
|
1114 |
|
|
flag_print_asm_name = 1;
|
1115 |
|
|
break;
|
1116 |
|
|
case 'P':
|
1117 |
|
|
flag_dump_rtl_in_asm = 1;
|
1118 |
|
|
flag_print_asm_name = 1;
|
1119 |
|
|
break;
|
1120 |
|
|
case 'v':
|
1121 |
|
|
graph_dump_format = vcg;
|
1122 |
|
|
break;
|
1123 |
|
|
case 'x':
|
1124 |
|
|
rtl_dump_and_exit = 1;
|
1125 |
|
|
break;
|
1126 |
|
|
case 'y':
|
1127 |
|
|
set_yydebug = 1;
|
1128 |
|
|
break;
|
1129 |
|
|
case 'D': /* These are handled by the preprocessor. */
|
1130 |
|
|
case 'I':
|
1131 |
|
|
break;
|
1132 |
|
|
case 'H':
|
1133 |
|
|
setup_core_dumping();
|
1134 |
|
|
break;
|
1135 |
|
|
|
1136 |
|
|
case 'a':
|
1137 |
|
|
default:
|
1138 |
|
|
if (!enable_rtl_dump_file (c))
|
1139 |
|
|
warning (0, "unrecognized gcc debugging option: %c", c);
|
1140 |
|
|
break;
|
1141 |
|
|
}
|
1142 |
|
|
}
|
1143 |
|
|
|
1144 |
|
|
/* Indexed by enum debug_info_type. */
|
1145 |
|
|
const char *const debug_type_names[] =
|
1146 |
|
|
{
|
1147 |
|
|
"none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
|
1148 |
|
|
};
|
1149 |
|
|
|
1150 |
|
|
/* Print version information to FILE.
|
1151 |
|
|
Each line begins with INDENT (for the case where FILE is the
|
1152 |
|
|
assembler output file). */
|
1153 |
|
|
|
1154 |
|
|
void
|
1155 |
|
|
print_version (FILE *file, const char *indent)
|
1156 |
|
|
{
|
1157 |
|
|
static const char fmt1[] =
|
1158 |
|
|
#ifdef __GNUC__
|
1159 |
|
|
N_("%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n")
|
1160 |
|
|
#else
|
1161 |
|
|
N_("%s%s%s version %s (%s) compiled by CC.\n")
|
1162 |
|
|
#endif
|
1163 |
|
|
;
|
1164 |
|
|
static const char fmt2[] =
|
1165 |
|
|
N_("%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n");
|
1166 |
|
|
#ifndef __VERSION__
|
1167 |
|
|
#define __VERSION__ "[?]"
|
1168 |
|
|
#endif
|
1169 |
|
|
fprintf (file,
|
1170 |
|
|
file == stderr ? _(fmt1) : fmt1,
|
1171 |
|
|
indent, *indent != 0 ? " " : "",
|
1172 |
|
|
lang_hooks.name, version_string, TARGET_NAME,
|
1173 |
|
|
indent, __VERSION__);
|
1174 |
|
|
fprintf (file,
|
1175 |
|
|
file == stderr ? _(fmt2) : fmt2,
|
1176 |
|
|
indent, *indent != 0 ? " " : "",
|
1177 |
|
|
PARAM_VALUE (GGC_MIN_EXPAND), PARAM_VALUE (GGC_MIN_HEAPSIZE));
|
1178 |
|
|
}
|
1179 |
|
|
|
1180 |
|
|
/* Print an option value and return the adjusted position in the line.
|
1181 |
|
|
??? We don't handle error returns from fprintf (disk full); presumably
|
1182 |
|
|
other code will catch a disk full though. */
|
1183 |
|
|
|
1184 |
|
|
static int
|
1185 |
|
|
print_single_switch (FILE *file, int pos, int max,
|
1186 |
|
|
const char *indent, const char *sep, const char *term,
|
1187 |
|
|
const char *type, const char *name)
|
1188 |
|
|
{
|
1189 |
|
|
/* The ultrix fprintf returns 0 on success, so compute the result we want
|
1190 |
|
|
here since we need it for the following test. */
|
1191 |
|
|
int len = strlen (sep) + strlen (type) + strlen (name);
|
1192 |
|
|
|
1193 |
|
|
if (pos != 0
|
1194 |
|
|
&& pos + len > max)
|
1195 |
|
|
{
|
1196 |
|
|
fprintf (file, "%s", term);
|
1197 |
|
|
pos = 0;
|
1198 |
|
|
}
|
1199 |
|
|
if (pos == 0)
|
1200 |
|
|
{
|
1201 |
|
|
fprintf (file, "%s", indent);
|
1202 |
|
|
pos = strlen (indent);
|
1203 |
|
|
}
|
1204 |
|
|
fprintf (file, "%s%s%s", sep, type, name);
|
1205 |
|
|
pos += len;
|
1206 |
|
|
return pos;
|
1207 |
|
|
}
|
1208 |
|
|
|
1209 |
|
|
/* Print active target switches to FILE.
|
1210 |
|
|
POS is the current cursor position and MAX is the size of a "line".
|
1211 |
|
|
Each line begins with INDENT and ends with TERM.
|
1212 |
|
|
Each switch is separated from the next by SEP. */
|
1213 |
|
|
|
1214 |
|
|
static void
|
1215 |
|
|
print_switch_values (FILE *file, int pos, int max,
|
1216 |
|
|
const char *indent, const char *sep, const char *term)
|
1217 |
|
|
{
|
1218 |
|
|
size_t j;
|
1219 |
|
|
const char **p;
|
1220 |
|
|
|
1221 |
|
|
/* Fill in the -frandom-seed option, if the user didn't pass it, so
|
1222 |
|
|
that it can be printed below. This helps reproducibility. */
|
1223 |
|
|
randomize ();
|
1224 |
|
|
|
1225 |
|
|
/* Print the options as passed. */
|
1226 |
|
|
pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
|
1227 |
|
|
_("options passed: "), "");
|
1228 |
|
|
|
1229 |
|
|
for (p = &save_argv[1]; *p != NULL; p++)
|
1230 |
|
|
if (**p == '-')
|
1231 |
|
|
{
|
1232 |
|
|
/* Ignore these. */
|
1233 |
|
|
if (strcmp (*p, "-o") == 0)
|
1234 |
|
|
{
|
1235 |
|
|
if (p[1] != NULL)
|
1236 |
|
|
p++;
|
1237 |
|
|
continue;
|
1238 |
|
|
}
|
1239 |
|
|
if (strcmp (*p, "-quiet") == 0)
|
1240 |
|
|
continue;
|
1241 |
|
|
if (strcmp (*p, "-version") == 0)
|
1242 |
|
|
continue;
|
1243 |
|
|
if ((*p)[1] == 'd')
|
1244 |
|
|
continue;
|
1245 |
|
|
|
1246 |
|
|
pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
|
1247 |
|
|
}
|
1248 |
|
|
if (pos > 0)
|
1249 |
|
|
fprintf (file, "%s", term);
|
1250 |
|
|
|
1251 |
|
|
/* Print the -f and -m options that have been enabled.
|
1252 |
|
|
We don't handle language specific options but printing argv
|
1253 |
|
|
should suffice. */
|
1254 |
|
|
|
1255 |
|
|
pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
|
1256 |
|
|
_("options enabled: "), "");
|
1257 |
|
|
|
1258 |
|
|
for (j = 0; j < cl_options_count; j++)
|
1259 |
|
|
if ((cl_options[j].flags & CL_REPORT)
|
1260 |
|
|
&& option_enabled (j) > 0)
|
1261 |
|
|
pos = print_single_switch (file, pos, max, indent, sep, term,
|
1262 |
|
|
"", cl_options[j].opt_text);
|
1263 |
|
|
|
1264 |
|
|
fprintf (file, "%s", term);
|
1265 |
|
|
}
|
1266 |
|
|
|
1267 |
|
|
/* Open assembly code output file. Do this even if -fsyntax-only is
|
1268 |
|
|
on, because then the driver will have provided the name of a
|
1269 |
|
|
temporary file or bit bucket for us. NAME is the file specified on
|
1270 |
|
|
the command line, possibly NULL. */
|
1271 |
|
|
static void
|
1272 |
|
|
init_asm_output (const char *name)
|
1273 |
|
|
{
|
1274 |
|
|
if (name == NULL && asm_file_name == 0)
|
1275 |
|
|
asm_out_file = stdout;
|
1276 |
|
|
else
|
1277 |
|
|
{
|
1278 |
|
|
if (asm_file_name == 0)
|
1279 |
|
|
{
|
1280 |
|
|
int len = strlen (dump_base_name);
|
1281 |
|
|
char *dumpname = XNEWVEC (char, len + 6);
|
1282 |
|
|
memcpy (dumpname, dump_base_name, len + 1);
|
1283 |
|
|
strip_off_ending (dumpname, len);
|
1284 |
|
|
strcat (dumpname, ".s");
|
1285 |
|
|
asm_file_name = dumpname;
|
1286 |
|
|
}
|
1287 |
|
|
if (!strcmp (asm_file_name, "-"))
|
1288 |
|
|
asm_out_file = stdout;
|
1289 |
|
|
else
|
1290 |
|
|
asm_out_file = fopen (asm_file_name, "w+b");
|
1291 |
|
|
if (asm_out_file == 0)
|
1292 |
|
|
fatal_error ("can%'t open %s for writing: %m", asm_file_name);
|
1293 |
|
|
}
|
1294 |
|
|
|
1295 |
|
|
if (!flag_syntax_only)
|
1296 |
|
|
{
|
1297 |
|
|
targetm.asm_out.file_start ();
|
1298 |
|
|
|
1299 |
|
|
#ifdef ASM_COMMENT_START
|
1300 |
|
|
if (flag_verbose_asm)
|
1301 |
|
|
{
|
1302 |
|
|
/* Print the list of options in effect. */
|
1303 |
|
|
print_version (asm_out_file, ASM_COMMENT_START);
|
1304 |
|
|
print_switch_values (asm_out_file, 0, MAX_LINE,
|
1305 |
|
|
ASM_COMMENT_START, " ", "\n");
|
1306 |
|
|
/* Add a blank line here so it appears in assembler output but not
|
1307 |
|
|
screen output. */
|
1308 |
|
|
fprintf (asm_out_file, "\n");
|
1309 |
|
|
}
|
1310 |
|
|
#endif
|
1311 |
|
|
}
|
1312 |
|
|
}
|
1313 |
|
|
|
1314 |
|
|
/* Return true if the state of option OPTION should be stored in PCH files
|
1315 |
|
|
and checked by default_pch_valid_p. Store the option's current state
|
1316 |
|
|
in STATE if so. */
|
1317 |
|
|
|
1318 |
|
|
static inline bool
|
1319 |
|
|
option_affects_pch_p (int option, struct cl_option_state *state)
|
1320 |
|
|
{
|
1321 |
|
|
if ((cl_options[option].flags & CL_TARGET) == 0)
|
1322 |
|
|
return false;
|
1323 |
|
|
if (cl_options[option].flag_var == &target_flags)
|
1324 |
|
|
if (targetm.check_pch_target_flags)
|
1325 |
|
|
return false;
|
1326 |
|
|
return get_option_state (option, state);
|
1327 |
|
|
}
|
1328 |
|
|
|
1329 |
|
|
/* Default version of get_pch_validity.
|
1330 |
|
|
By default, every flag difference is fatal; that will be mostly right for
|
1331 |
|
|
most targets, but completely right for very few. */
|
1332 |
|
|
|
1333 |
|
|
void *
|
1334 |
|
|
default_get_pch_validity (size_t *len)
|
1335 |
|
|
{
|
1336 |
|
|
struct cl_option_state state;
|
1337 |
|
|
size_t i;
|
1338 |
|
|
char *result, *r;
|
1339 |
|
|
|
1340 |
|
|
*len = 2;
|
1341 |
|
|
if (targetm.check_pch_target_flags)
|
1342 |
|
|
*len += sizeof (target_flags);
|
1343 |
|
|
for (i = 0; i < cl_options_count; i++)
|
1344 |
|
|
if (option_affects_pch_p (i, &state))
|
1345 |
|
|
*len += state.size;
|
1346 |
|
|
|
1347 |
|
|
result = r = XNEWVEC (char, *len);
|
1348 |
|
|
r[0] = flag_pic;
|
1349 |
|
|
r[1] = flag_pie;
|
1350 |
|
|
r += 2;
|
1351 |
|
|
if (targetm.check_pch_target_flags)
|
1352 |
|
|
{
|
1353 |
|
|
memcpy (r, &target_flags, sizeof (target_flags));
|
1354 |
|
|
r += sizeof (target_flags);
|
1355 |
|
|
}
|
1356 |
|
|
|
1357 |
|
|
for (i = 0; i < cl_options_count; i++)
|
1358 |
|
|
if (option_affects_pch_p (i, &state))
|
1359 |
|
|
{
|
1360 |
|
|
memcpy (r, state.data, state.size);
|
1361 |
|
|
r += state.size;
|
1362 |
|
|
}
|
1363 |
|
|
|
1364 |
|
|
return result;
|
1365 |
|
|
}
|
1366 |
|
|
|
1367 |
|
|
/* Return a message which says that a PCH file was created with a different
|
1368 |
|
|
setting of OPTION. */
|
1369 |
|
|
|
1370 |
|
|
static const char *
|
1371 |
|
|
pch_option_mismatch (const char *option)
|
1372 |
|
|
{
|
1373 |
|
|
char *r;
|
1374 |
|
|
|
1375 |
|
|
asprintf (&r, _("created and used with differing settings of '%s'"), option);
|
1376 |
|
|
if (r == NULL)
|
1377 |
|
|
return _("out of memory");
|
1378 |
|
|
return r;
|
1379 |
|
|
}
|
1380 |
|
|
|
1381 |
|
|
/* Default version of pch_valid_p. */
|
1382 |
|
|
|
1383 |
|
|
const char *
|
1384 |
|
|
default_pch_valid_p (const void *data_p, size_t len)
|
1385 |
|
|
{
|
1386 |
|
|
struct cl_option_state state;
|
1387 |
|
|
const char *data = (const char *)data_p;
|
1388 |
|
|
size_t i;
|
1389 |
|
|
|
1390 |
|
|
/* -fpic and -fpie also usually make a PCH invalid. */
|
1391 |
|
|
if (data[0] != flag_pic)
|
1392 |
|
|
return _("created and used with different settings of -fpic");
|
1393 |
|
|
if (data[1] != flag_pie)
|
1394 |
|
|
return _("created and used with different settings of -fpie");
|
1395 |
|
|
data += 2;
|
1396 |
|
|
|
1397 |
|
|
/* Check target_flags. */
|
1398 |
|
|
if (targetm.check_pch_target_flags)
|
1399 |
|
|
{
|
1400 |
|
|
int tf;
|
1401 |
|
|
const char *r;
|
1402 |
|
|
|
1403 |
|
|
memcpy (&tf, data, sizeof (target_flags));
|
1404 |
|
|
data += sizeof (target_flags);
|
1405 |
|
|
len -= sizeof (target_flags);
|
1406 |
|
|
r = targetm.check_pch_target_flags (tf);
|
1407 |
|
|
if (r != NULL)
|
1408 |
|
|
return r;
|
1409 |
|
|
}
|
1410 |
|
|
|
1411 |
|
|
for (i = 0; i < cl_options_count; i++)
|
1412 |
|
|
if (option_affects_pch_p (i, &state))
|
1413 |
|
|
{
|
1414 |
|
|
if (memcmp (data, state.data, state.size) != 0)
|
1415 |
|
|
return pch_option_mismatch (cl_options[i].opt_text);
|
1416 |
|
|
data += state.size;
|
1417 |
|
|
len -= state.size;
|
1418 |
|
|
}
|
1419 |
|
|
|
1420 |
|
|
return NULL;
|
1421 |
|
|
}
|
1422 |
|
|
|
1423 |
|
|
/* Default tree printer. Handles declarations only. */
|
1424 |
|
|
static bool
|
1425 |
|
|
default_tree_printer (pretty_printer * pp, text_info *text, const char *spec,
|
1426 |
|
|
int precision, bool wide, bool set_locus, bool hash)
|
1427 |
|
|
{
|
1428 |
|
|
tree t;
|
1429 |
|
|
|
1430 |
|
|
/* FUTURE: %+x should set the locus. */
|
1431 |
|
|
if (precision != 0 || wide || hash)
|
1432 |
|
|
return false;
|
1433 |
|
|
|
1434 |
|
|
switch (*spec)
|
1435 |
|
|
{
|
1436 |
|
|
case 'D':
|
1437 |
|
|
t = va_arg (*text->args_ptr, tree);
|
1438 |
|
|
if (DECL_DEBUG_EXPR_IS_FROM (t) && DECL_DEBUG_EXPR (t))
|
1439 |
|
|
t = DECL_DEBUG_EXPR (t);
|
1440 |
|
|
break;
|
1441 |
|
|
|
1442 |
|
|
case 'F':
|
1443 |
|
|
case 'T':
|
1444 |
|
|
t = va_arg (*text->args_ptr, tree);
|
1445 |
|
|
break;
|
1446 |
|
|
|
1447 |
|
|
default:
|
1448 |
|
|
return false;
|
1449 |
|
|
}
|
1450 |
|
|
|
1451 |
|
|
if (set_locus && text->locus)
|
1452 |
|
|
*text->locus = DECL_SOURCE_LOCATION (t);
|
1453 |
|
|
|
1454 |
|
|
if (DECL_P (t))
|
1455 |
|
|
{
|
1456 |
|
|
const char *n = DECL_NAME (t)
|
1457 |
|
|
? lang_hooks.decl_printable_name (t, 2)
|
1458 |
|
|
: "<anonymous>";
|
1459 |
|
|
pp_string (pp, n);
|
1460 |
|
|
}
|
1461 |
|
|
else
|
1462 |
|
|
dump_generic_node (pp, t, 0, 0, 0);
|
1463 |
|
|
|
1464 |
|
|
return true;
|
1465 |
|
|
}
|
1466 |
|
|
|
1467 |
|
|
/* Initialization of the front end environment, before command line
|
1468 |
|
|
options are parsed. Signal handlers, internationalization etc.
|
1469 |
|
|
ARGV0 is main's argv[0]. */
|
1470 |
|
|
static void
|
1471 |
|
|
general_init (const char *argv0)
|
1472 |
|
|
{
|
1473 |
|
|
const char *p;
|
1474 |
|
|
|
1475 |
|
|
p = argv0 + strlen (argv0);
|
1476 |
|
|
while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
|
1477 |
|
|
--p;
|
1478 |
|
|
progname = p;
|
1479 |
|
|
|
1480 |
|
|
xmalloc_set_program_name (progname);
|
1481 |
|
|
|
1482 |
|
|
hex_init ();
|
1483 |
|
|
|
1484 |
|
|
/* Unlock the stdio streams. */
|
1485 |
|
|
unlock_std_streams ();
|
1486 |
|
|
|
1487 |
|
|
gcc_init_libintl ();
|
1488 |
|
|
|
1489 |
|
|
/* Initialize the diagnostics reporting machinery, so option parsing
|
1490 |
|
|
can give warnings and errors. */
|
1491 |
|
|
diagnostic_initialize (global_dc);
|
1492 |
|
|
/* Set a default printer. Language specific initializations will
|
1493 |
|
|
override it later. */
|
1494 |
|
|
pp_format_decoder (global_dc->printer) = &default_tree_printer;
|
1495 |
|
|
|
1496 |
|
|
/* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
|
1497 |
|
|
#ifdef SIGSEGV
|
1498 |
|
|
signal (SIGSEGV, crash_signal);
|
1499 |
|
|
#endif
|
1500 |
|
|
#ifdef SIGILL
|
1501 |
|
|
signal (SIGILL, crash_signal);
|
1502 |
|
|
#endif
|
1503 |
|
|
#ifdef SIGBUS
|
1504 |
|
|
signal (SIGBUS, crash_signal);
|
1505 |
|
|
#endif
|
1506 |
|
|
#ifdef SIGABRT
|
1507 |
|
|
signal (SIGABRT, crash_signal);
|
1508 |
|
|
#endif
|
1509 |
|
|
#if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
|
1510 |
|
|
signal (SIGIOT, crash_signal);
|
1511 |
|
|
#endif
|
1512 |
|
|
#ifdef SIGFPE
|
1513 |
|
|
signal (SIGFPE, crash_signal);
|
1514 |
|
|
#endif
|
1515 |
|
|
|
1516 |
|
|
/* Other host-specific signal setup. */
|
1517 |
|
|
(*host_hooks.extra_signals)();
|
1518 |
|
|
|
1519 |
|
|
/* Initialize the garbage-collector, string pools and tree type hash
|
1520 |
|
|
table. */
|
1521 |
|
|
init_ggc ();
|
1522 |
|
|
init_stringpool ();
|
1523 |
|
|
linemap_init (&line_table);
|
1524 |
|
|
init_ttree ();
|
1525 |
|
|
|
1526 |
|
|
/* Initialize register usage now so switches may override. */
|
1527 |
|
|
init_reg_sets ();
|
1528 |
|
|
|
1529 |
|
|
/* Register the language-independent parameters. */
|
1530 |
|
|
add_params (lang_independent_params, LAST_PARAM);
|
1531 |
|
|
|
1532 |
|
|
/* This must be done after add_params but before argument processing. */
|
1533 |
|
|
init_ggc_heuristics();
|
1534 |
|
|
init_optimization_passes ();
|
1535 |
|
|
}
|
1536 |
|
|
|
1537 |
|
|
/* Return true if the current target supports -fsection-anchors. */
|
1538 |
|
|
|
1539 |
|
|
static bool
|
1540 |
|
|
target_supports_section_anchors_p (void)
|
1541 |
|
|
{
|
1542 |
|
|
if (targetm.min_anchor_offset == 0 && targetm.max_anchor_offset == 0)
|
1543 |
|
|
return false;
|
1544 |
|
|
|
1545 |
|
|
if (targetm.asm_out.output_anchor == NULL)
|
1546 |
|
|
return false;
|
1547 |
|
|
|
1548 |
|
|
return true;
|
1549 |
|
|
}
|
1550 |
|
|
|
1551 |
|
|
/* Process the options that have been parsed. */
|
1552 |
|
|
static void
|
1553 |
|
|
process_options (void)
|
1554 |
|
|
{
|
1555 |
|
|
/* Just in case lang_hooks.post_options ends up calling a debug_hook.
|
1556 |
|
|
This can happen with incorrect pre-processed input. */
|
1557 |
|
|
debug_hooks = &do_nothing_debug_hooks;
|
1558 |
|
|
|
1559 |
|
|
/* Allow the front end to perform consistency checks and do further
|
1560 |
|
|
initialization based on the command line options. This hook also
|
1561 |
|
|
sets the original filename if appropriate (e.g. foo.i -> foo.c)
|
1562 |
|
|
so we can correctly initialize debug output. */
|
1563 |
|
|
no_backend = lang_hooks.post_options (&main_input_filename);
|
1564 |
|
|
#ifndef USE_MAPPED_LOCATION
|
1565 |
|
|
input_filename = main_input_filename;
|
1566 |
|
|
#endif
|
1567 |
|
|
|
1568 |
|
|
#ifdef OVERRIDE_OPTIONS
|
1569 |
|
|
/* Some machines may reject certain combinations of options. */
|
1570 |
|
|
OVERRIDE_OPTIONS;
|
1571 |
|
|
#endif
|
1572 |
|
|
|
1573 |
|
|
if (flag_section_anchors && !target_supports_section_anchors_p ())
|
1574 |
|
|
{
|
1575 |
|
|
warning (OPT_fsection_anchors,
|
1576 |
|
|
"this target does not support %qs", "-fsection-anchors");
|
1577 |
|
|
flag_section_anchors = 0;
|
1578 |
|
|
}
|
1579 |
|
|
|
1580 |
|
|
if (flag_short_enums == 2)
|
1581 |
|
|
flag_short_enums = targetm.default_short_enums ();
|
1582 |
|
|
|
1583 |
|
|
/* Set aux_base_name if not already set. */
|
1584 |
|
|
if (aux_base_name)
|
1585 |
|
|
;
|
1586 |
|
|
else if (main_input_filename)
|
1587 |
|
|
{
|
1588 |
|
|
char *name = xstrdup (lbasename (main_input_filename));
|
1589 |
|
|
|
1590 |
|
|
strip_off_ending (name, strlen (name));
|
1591 |
|
|
aux_base_name = name;
|
1592 |
|
|
}
|
1593 |
|
|
else
|
1594 |
|
|
aux_base_name = "gccaux";
|
1595 |
|
|
|
1596 |
|
|
/* Set up the align_*_log variables, defaulting them to 1 if they
|
1597 |
|
|
were still unset. */
|
1598 |
|
|
if (align_loops <= 0) align_loops = 1;
|
1599 |
|
|
if (align_loops_max_skip > align_loops || !align_loops)
|
1600 |
|
|
align_loops_max_skip = align_loops - 1;
|
1601 |
|
|
align_loops_log = floor_log2 (align_loops * 2 - 1);
|
1602 |
|
|
if (align_jumps <= 0) align_jumps = 1;
|
1603 |
|
|
if (align_jumps_max_skip > align_jumps || !align_jumps)
|
1604 |
|
|
align_jumps_max_skip = align_jumps - 1;
|
1605 |
|
|
align_jumps_log = floor_log2 (align_jumps * 2 - 1);
|
1606 |
|
|
if (align_labels <= 0) align_labels = 1;
|
1607 |
|
|
align_labels_log = floor_log2 (align_labels * 2 - 1);
|
1608 |
|
|
if (align_labels_max_skip > align_labels || !align_labels)
|
1609 |
|
|
align_labels_max_skip = align_labels - 1;
|
1610 |
|
|
if (align_functions <= 0) align_functions = 1;
|
1611 |
|
|
align_functions_log = floor_log2 (align_functions * 2 - 1);
|
1612 |
|
|
|
1613 |
|
|
/* Unrolling all loops implies that standard loop unrolling must also
|
1614 |
|
|
be done. */
|
1615 |
|
|
if (flag_unroll_all_loops)
|
1616 |
|
|
flag_unroll_loops = 1;
|
1617 |
|
|
|
1618 |
|
|
/* The loop unrolling code assumes that cse will be run after loop.
|
1619 |
|
|
web and rename-registers also help when run after loop unrolling. */
|
1620 |
|
|
|
1621 |
|
|
if (flag_rerun_cse_after_loop == AUTODETECT_VALUE)
|
1622 |
|
|
flag_rerun_cse_after_loop = flag_unroll_loops || flag_peel_loops;
|
1623 |
|
|
if (flag_web == AUTODETECT_VALUE)
|
1624 |
|
|
flag_web = flag_unroll_loops || flag_peel_loops;
|
1625 |
|
|
if (flag_rename_registers == AUTODETECT_VALUE)
|
1626 |
|
|
flag_rename_registers = flag_unroll_loops || flag_peel_loops;
|
1627 |
|
|
|
1628 |
|
|
if (flag_non_call_exceptions)
|
1629 |
|
|
flag_asynchronous_unwind_tables = 1;
|
1630 |
|
|
if (flag_asynchronous_unwind_tables)
|
1631 |
|
|
flag_unwind_tables = 1;
|
1632 |
|
|
|
1633 |
|
|
/* Disable unit-at-a-time mode for frontends not supporting callgraph
|
1634 |
|
|
interface. */
|
1635 |
|
|
if (flag_unit_at_a_time && ! lang_hooks.callgraph.expand_function)
|
1636 |
|
|
flag_unit_at_a_time = 0;
|
1637 |
|
|
|
1638 |
|
|
if (!flag_unit_at_a_time)
|
1639 |
|
|
flag_section_anchors = 0;
|
1640 |
|
|
|
1641 |
|
|
if (flag_value_profile_transformations)
|
1642 |
|
|
flag_profile_values = 1;
|
1643 |
|
|
|
1644 |
|
|
/* Warn about options that are not supported on this machine. */
|
1645 |
|
|
#ifndef INSN_SCHEDULING
|
1646 |
|
|
if (flag_schedule_insns || flag_schedule_insns_after_reload)
|
1647 |
|
|
warning (0, "instruction scheduling not supported on this target machine");
|
1648 |
|
|
#endif
|
1649 |
|
|
#ifndef DELAY_SLOTS
|
1650 |
|
|
if (flag_delayed_branch)
|
1651 |
|
|
warning (0, "this target machine does not have delayed branches");
|
1652 |
|
|
#endif
|
1653 |
|
|
|
1654 |
|
|
user_label_prefix = USER_LABEL_PREFIX;
|
1655 |
|
|
if (flag_leading_underscore != -1)
|
1656 |
|
|
{
|
1657 |
|
|
/* If the default prefix is more complicated than "" or "_",
|
1658 |
|
|
issue a warning and ignore this option. */
|
1659 |
|
|
if (user_label_prefix[0] == 0 ||
|
1660 |
|
|
(user_label_prefix[0] == '_' && user_label_prefix[1] == 0))
|
1661 |
|
|
{
|
1662 |
|
|
user_label_prefix = flag_leading_underscore ? "_" : "";
|
1663 |
|
|
}
|
1664 |
|
|
else
|
1665 |
|
|
warning (0, "-f%sleading-underscore not supported on this target machine",
|
1666 |
|
|
flag_leading_underscore ? "" : "no-");
|
1667 |
|
|
}
|
1668 |
|
|
|
1669 |
|
|
/* If we are in verbose mode, write out the version and maybe all the
|
1670 |
|
|
option flags in use. */
|
1671 |
|
|
if (version_flag)
|
1672 |
|
|
{
|
1673 |
|
|
print_version (stderr, "");
|
1674 |
|
|
if (! quiet_flag)
|
1675 |
|
|
print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
|
1676 |
|
|
}
|
1677 |
|
|
|
1678 |
|
|
if (flag_syntax_only)
|
1679 |
|
|
{
|
1680 |
|
|
write_symbols = NO_DEBUG;
|
1681 |
|
|
profile_flag = 0;
|
1682 |
|
|
}
|
1683 |
|
|
|
1684 |
|
|
/* A lot of code assumes write_symbols == NO_DEBUG if the debugging
|
1685 |
|
|
level is 0. */
|
1686 |
|
|
if (debug_info_level == DINFO_LEVEL_NONE)
|
1687 |
|
|
write_symbols = NO_DEBUG;
|
1688 |
|
|
|
1689 |
|
|
/* Now we know write_symbols, set up the debug hooks based on it.
|
1690 |
|
|
By default we do nothing for debug output. */
|
1691 |
|
|
if (PREFERRED_DEBUGGING_TYPE == NO_DEBUG)
|
1692 |
|
|
default_debug_hooks = &do_nothing_debug_hooks;
|
1693 |
|
|
#if defined(DBX_DEBUGGING_INFO)
|
1694 |
|
|
else if (PREFERRED_DEBUGGING_TYPE == DBX_DEBUG)
|
1695 |
|
|
default_debug_hooks = &dbx_debug_hooks;
|
1696 |
|
|
#endif
|
1697 |
|
|
#if defined(XCOFF_DEBUGGING_INFO)
|
1698 |
|
|
else if (PREFERRED_DEBUGGING_TYPE == XCOFF_DEBUG)
|
1699 |
|
|
default_debug_hooks = &xcoff_debug_hooks;
|
1700 |
|
|
#endif
|
1701 |
|
|
#ifdef SDB_DEBUGGING_INFO
|
1702 |
|
|
else if (PREFERRED_DEBUGGING_TYPE == SDB_DEBUG)
|
1703 |
|
|
default_debug_hooks = &sdb_debug_hooks;
|
1704 |
|
|
#endif
|
1705 |
|
|
#ifdef DWARF2_DEBUGGING_INFO
|
1706 |
|
|
else if (PREFERRED_DEBUGGING_TYPE == DWARF2_DEBUG)
|
1707 |
|
|
default_debug_hooks = &dwarf2_debug_hooks;
|
1708 |
|
|
#endif
|
1709 |
|
|
#ifdef VMS_DEBUGGING_INFO
|
1710 |
|
|
else if (PREFERRED_DEBUGGING_TYPE == VMS_DEBUG
|
1711 |
|
|
|| PREFERRED_DEBUGGING_TYPE == VMS_AND_DWARF2_DEBUG)
|
1712 |
|
|
default_debug_hooks = &vmsdbg_debug_hooks;
|
1713 |
|
|
#endif
|
1714 |
|
|
|
1715 |
|
|
if (write_symbols == NO_DEBUG)
|
1716 |
|
|
;
|
1717 |
|
|
#if defined(DBX_DEBUGGING_INFO)
|
1718 |
|
|
else if (write_symbols == DBX_DEBUG)
|
1719 |
|
|
debug_hooks = &dbx_debug_hooks;
|
1720 |
|
|
#endif
|
1721 |
|
|
#if defined(XCOFF_DEBUGGING_INFO)
|
1722 |
|
|
else if (write_symbols == XCOFF_DEBUG)
|
1723 |
|
|
debug_hooks = &xcoff_debug_hooks;
|
1724 |
|
|
#endif
|
1725 |
|
|
#ifdef SDB_DEBUGGING_INFO
|
1726 |
|
|
else if (write_symbols == SDB_DEBUG)
|
1727 |
|
|
debug_hooks = &sdb_debug_hooks;
|
1728 |
|
|
#endif
|
1729 |
|
|
#ifdef DWARF2_DEBUGGING_INFO
|
1730 |
|
|
else if (write_symbols == DWARF2_DEBUG)
|
1731 |
|
|
debug_hooks = &dwarf2_debug_hooks;
|
1732 |
|
|
#endif
|
1733 |
|
|
#ifdef VMS_DEBUGGING_INFO
|
1734 |
|
|
else if (write_symbols == VMS_DEBUG || write_symbols == VMS_AND_DWARF2_DEBUG)
|
1735 |
|
|
debug_hooks = &vmsdbg_debug_hooks;
|
1736 |
|
|
#endif
|
1737 |
|
|
else
|
1738 |
|
|
error ("target system does not support the \"%s\" debug format",
|
1739 |
|
|
debug_type_names[write_symbols]);
|
1740 |
|
|
|
1741 |
|
|
/* Now we know which debug output will be used so we can set
|
1742 |
|
|
flag_var_tracking, flag_rename_registers if the user has
|
1743 |
|
|
not specified them. */
|
1744 |
|
|
if (debug_info_level < DINFO_LEVEL_NORMAL
|
1745 |
|
|
|| debug_hooks->var_location == do_nothing_debug_hooks.var_location)
|
1746 |
|
|
{
|
1747 |
|
|
if (flag_var_tracking == 1)
|
1748 |
|
|
{
|
1749 |
|
|
if (debug_info_level < DINFO_LEVEL_NORMAL)
|
1750 |
|
|
warning (0, "variable tracking requested, but useless unless "
|
1751 |
|
|
"producing debug info");
|
1752 |
|
|
else
|
1753 |
|
|
warning (0, "variable tracking requested, but not supported "
|
1754 |
|
|
"by this debug format");
|
1755 |
|
|
}
|
1756 |
|
|
flag_var_tracking = 0;
|
1757 |
|
|
}
|
1758 |
|
|
|
1759 |
|
|
if (flag_rename_registers == AUTODETECT_VALUE)
|
1760 |
|
|
flag_rename_registers = default_debug_hooks->var_location
|
1761 |
|
|
!= do_nothing_debug_hooks.var_location;
|
1762 |
|
|
|
1763 |
|
|
if (flag_var_tracking == AUTODETECT_VALUE)
|
1764 |
|
|
flag_var_tracking = optimize >= 1;
|
1765 |
|
|
|
1766 |
|
|
/* If auxiliary info generation is desired, open the output file.
|
1767 |
|
|
This goes in the same directory as the source file--unlike
|
1768 |
|
|
all the other output files. */
|
1769 |
|
|
if (flag_gen_aux_info)
|
1770 |
|
|
{
|
1771 |
|
|
aux_info_file = fopen (aux_info_file_name, "w");
|
1772 |
|
|
if (aux_info_file == 0)
|
1773 |
|
|
fatal_error ("can%'t open %s: %m", aux_info_file_name);
|
1774 |
|
|
}
|
1775 |
|
|
|
1776 |
|
|
if (! targetm.have_named_sections)
|
1777 |
|
|
{
|
1778 |
|
|
if (flag_function_sections)
|
1779 |
|
|
{
|
1780 |
|
|
warning (0, "-ffunction-sections not supported for this target");
|
1781 |
|
|
flag_function_sections = 0;
|
1782 |
|
|
}
|
1783 |
|
|
if (flag_data_sections)
|
1784 |
|
|
{
|
1785 |
|
|
warning (0, "-fdata-sections not supported for this target");
|
1786 |
|
|
flag_data_sections = 0;
|
1787 |
|
|
}
|
1788 |
|
|
}
|
1789 |
|
|
|
1790 |
|
|
if (flag_function_sections && profile_flag)
|
1791 |
|
|
{
|
1792 |
|
|
warning (0, "-ffunction-sections disabled; it makes profiling impossible");
|
1793 |
|
|
flag_function_sections = 0;
|
1794 |
|
|
}
|
1795 |
|
|
|
1796 |
|
|
#ifndef HAVE_prefetch
|
1797 |
|
|
if (flag_prefetch_loop_arrays)
|
1798 |
|
|
{
|
1799 |
|
|
warning (0, "-fprefetch-loop-arrays not supported for this target");
|
1800 |
|
|
flag_prefetch_loop_arrays = 0;
|
1801 |
|
|
}
|
1802 |
|
|
#else
|
1803 |
|
|
if (flag_prefetch_loop_arrays && !HAVE_prefetch)
|
1804 |
|
|
{
|
1805 |
|
|
warning (0, "-fprefetch-loop-arrays not supported for this target (try -march switches)");
|
1806 |
|
|
flag_prefetch_loop_arrays = 0;
|
1807 |
|
|
}
|
1808 |
|
|
#endif
|
1809 |
|
|
|
1810 |
|
|
/* This combination of options isn't handled for i386 targets and doesn't
|
1811 |
|
|
make much sense anyway, so don't allow it. */
|
1812 |
|
|
if (flag_prefetch_loop_arrays && optimize_size)
|
1813 |
|
|
{
|
1814 |
|
|
warning (0, "-fprefetch-loop-arrays is not supported with -Os");
|
1815 |
|
|
flag_prefetch_loop_arrays = 0;
|
1816 |
|
|
}
|
1817 |
|
|
|
1818 |
|
|
#ifndef OBJECT_FORMAT_ELF
|
1819 |
|
|
#ifndef OBJECT_FORMAT_MACHO
|
1820 |
|
|
if (flag_function_sections && write_symbols != NO_DEBUG)
|
1821 |
|
|
warning (0, "-ffunction-sections may affect debugging on some targets");
|
1822 |
|
|
#endif
|
1823 |
|
|
#endif
|
1824 |
|
|
|
1825 |
|
|
/* The presence of IEEE signaling NaNs, implies all math can trap. */
|
1826 |
|
|
if (flag_signaling_nans)
|
1827 |
|
|
flag_trapping_math = 1;
|
1828 |
|
|
|
1829 |
|
|
/* With -fcx-limited-range, we do cheap and quick complex arithmetic. */
|
1830 |
|
|
if (flag_cx_limited_range)
|
1831 |
|
|
flag_complex_method = 0;
|
1832 |
|
|
|
1833 |
|
|
/* Targets must be able to place spill slots at lower addresses. If the
|
1834 |
|
|
target already uses a soft frame pointer, the transition is trivial. */
|
1835 |
|
|
if (!FRAME_GROWS_DOWNWARD && flag_stack_protect)
|
1836 |
|
|
{
|
1837 |
|
|
warning (0, "-fstack-protector not supported for this target");
|
1838 |
|
|
flag_stack_protect = 0;
|
1839 |
|
|
}
|
1840 |
|
|
if (!flag_stack_protect)
|
1841 |
|
|
warn_stack_protect = 0;
|
1842 |
|
|
|
1843 |
|
|
/* ??? Unwind info is not correct around the CFG unless either a frame
|
1844 |
|
|
pointer is present or A_O_A is set. Fixing this requires rewriting
|
1845 |
|
|
unwind info generation to be aware of the CFG and propagating states
|
1846 |
|
|
around edges. */
|
1847 |
|
|
if (flag_unwind_tables && !ACCUMULATE_OUTGOING_ARGS
|
1848 |
|
|
&& flag_omit_frame_pointer)
|
1849 |
|
|
{
|
1850 |
|
|
warning (0, "unwind tables currently requires a frame pointer "
|
1851 |
|
|
"for correctness");
|
1852 |
|
|
flag_omit_frame_pointer = 0;
|
1853 |
|
|
}
|
1854 |
|
|
}
|
1855 |
|
|
|
1856 |
|
|
/* Initialize the compiler back end. */
|
1857 |
|
|
static void
|
1858 |
|
|
backend_init (void)
|
1859 |
|
|
{
|
1860 |
|
|
init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
|
1861 |
|
|
|| debug_info_level == DINFO_LEVEL_VERBOSE
|
1862 |
|
|
#ifdef VMS_DEBUGGING_INFO
|
1863 |
|
|
/* Enable line number info for traceback. */
|
1864 |
|
|
|| debug_info_level > DINFO_LEVEL_NONE
|
1865 |
|
|
#endif
|
1866 |
|
|
|| flag_test_coverage);
|
1867 |
|
|
|
1868 |
|
|
init_rtlanal ();
|
1869 |
|
|
init_regs ();
|
1870 |
|
|
init_fake_stack_mems ();
|
1871 |
|
|
init_alias_once ();
|
1872 |
|
|
init_reload ();
|
1873 |
|
|
init_varasm_once ();
|
1874 |
|
|
|
1875 |
|
|
/* The following initialization functions need to generate rtl, so
|
1876 |
|
|
provide a dummy function context for them. */
|
1877 |
|
|
init_dummy_function_start ();
|
1878 |
|
|
init_expmed ();
|
1879 |
|
|
if (flag_caller_saves)
|
1880 |
|
|
init_caller_save ();
|
1881 |
|
|
expand_dummy_function_end ();
|
1882 |
|
|
}
|
1883 |
|
|
|
1884 |
|
|
/* Language-dependent initialization. Returns nonzero on success. */
|
1885 |
|
|
static int
|
1886 |
|
|
lang_dependent_init (const char *name)
|
1887 |
|
|
{
|
1888 |
|
|
location_t save_loc = input_location;
|
1889 |
|
|
if (dump_base_name == 0)
|
1890 |
|
|
dump_base_name = name && name[0] ? name : "gccdump";
|
1891 |
|
|
|
1892 |
|
|
/* Other front-end initialization. */
|
1893 |
|
|
#ifdef USE_MAPPED_LOCATION
|
1894 |
|
|
input_location = BUILTINS_LOCATION;
|
1895 |
|
|
#else
|
1896 |
|
|
input_filename = "<built-in>";
|
1897 |
|
|
input_line = 0;
|
1898 |
|
|
#endif
|
1899 |
|
|
if (lang_hooks.init () == 0)
|
1900 |
|
|
return 0;
|
1901 |
|
|
input_location = save_loc;
|
1902 |
|
|
|
1903 |
|
|
init_asm_output (name);
|
1904 |
|
|
|
1905 |
|
|
/* These create various _DECL nodes, so need to be called after the
|
1906 |
|
|
front end is initialized. */
|
1907 |
|
|
init_eh ();
|
1908 |
|
|
init_optabs ();
|
1909 |
|
|
|
1910 |
|
|
/* The following initialization functions need to generate rtl, so
|
1911 |
|
|
provide a dummy function context for them. */
|
1912 |
|
|
init_dummy_function_start ();
|
1913 |
|
|
init_expr_once ();
|
1914 |
|
|
expand_dummy_function_end ();
|
1915 |
|
|
|
1916 |
|
|
/* If dbx symbol table desired, initialize writing it and output the
|
1917 |
|
|
predefined types. */
|
1918 |
|
|
timevar_push (TV_SYMOUT);
|
1919 |
|
|
|
1920 |
|
|
#if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
|
1921 |
|
|
if (dwarf2out_do_frame ())
|
1922 |
|
|
dwarf2out_frame_init ();
|
1923 |
|
|
#endif
|
1924 |
|
|
|
1925 |
|
|
/* Now we have the correct original filename, we can initialize
|
1926 |
|
|
debug output. */
|
1927 |
|
|
(*debug_hooks->init) (name);
|
1928 |
|
|
|
1929 |
|
|
timevar_pop (TV_SYMOUT);
|
1930 |
|
|
|
1931 |
|
|
return 1;
|
1932 |
|
|
}
|
1933 |
|
|
|
1934 |
|
|
/* Clean up: close opened files, etc. */
|
1935 |
|
|
|
1936 |
|
|
static void
|
1937 |
|
|
finalize (void)
|
1938 |
|
|
{
|
1939 |
|
|
/* Close the dump files. */
|
1940 |
|
|
if (flag_gen_aux_info)
|
1941 |
|
|
{
|
1942 |
|
|
fclose (aux_info_file);
|
1943 |
|
|
if (errorcount)
|
1944 |
|
|
unlink (aux_info_file_name);
|
1945 |
|
|
}
|
1946 |
|
|
|
1947 |
|
|
/* Close non-debugging input and output files. Take special care to note
|
1948 |
|
|
whether fclose returns an error, since the pages might still be on the
|
1949 |
|
|
buffer chain while the file is open. */
|
1950 |
|
|
|
1951 |
|
|
if (asm_out_file)
|
1952 |
|
|
{
|
1953 |
|
|
if (ferror (asm_out_file) != 0)
|
1954 |
|
|
fatal_error ("error writing to %s: %m", asm_file_name);
|
1955 |
|
|
if (fclose (asm_out_file) != 0)
|
1956 |
|
|
fatal_error ("error closing %s: %m", asm_file_name);
|
1957 |
|
|
}
|
1958 |
|
|
|
1959 |
|
|
finish_optimization_passes ();
|
1960 |
|
|
|
1961 |
|
|
if (mem_report)
|
1962 |
|
|
{
|
1963 |
|
|
ggc_print_statistics ();
|
1964 |
|
|
stringpool_statistics ();
|
1965 |
|
|
dump_tree_statistics ();
|
1966 |
|
|
dump_rtx_statistics ();
|
1967 |
|
|
dump_varray_statistics ();
|
1968 |
|
|
dump_alloc_pool_statistics ();
|
1969 |
|
|
dump_ggc_loc_statistics ();
|
1970 |
|
|
}
|
1971 |
|
|
|
1972 |
|
|
/* Free up memory for the benefit of leak detectors. */
|
1973 |
|
|
free_reg_info ();
|
1974 |
|
|
|
1975 |
|
|
/* Language-specific end of compilation actions. */
|
1976 |
|
|
lang_hooks.finish ();
|
1977 |
|
|
}
|
1978 |
|
|
|
1979 |
|
|
/* Initialize the compiler, and compile the input file. */
|
1980 |
|
|
static void
|
1981 |
|
|
do_compile (void)
|
1982 |
|
|
{
|
1983 |
|
|
/* Initialize timing first. The C front ends read the main file in
|
1984 |
|
|
the post_options hook, and C++ does file timings. */
|
1985 |
|
|
if (time_report || !quiet_flag || flag_detailed_statistics)
|
1986 |
|
|
timevar_init ();
|
1987 |
|
|
timevar_start (TV_TOTAL);
|
1988 |
|
|
|
1989 |
|
|
process_options ();
|
1990 |
|
|
|
1991 |
|
|
/* Don't do any more if an error has already occurred. */
|
1992 |
|
|
if (!errorcount)
|
1993 |
|
|
{
|
1994 |
|
|
/* This must be run always, because it is needed to compute the FP
|
1995 |
|
|
predefined macros, such as __LDBL_MAX__, for targets using non
|
1996 |
|
|
default FP formats. */
|
1997 |
|
|
init_adjust_machine_modes ();
|
1998 |
|
|
|
1999 |
|
|
/* Set up the back-end if requested. */
|
2000 |
|
|
if (!no_backend)
|
2001 |
|
|
backend_init ();
|
2002 |
|
|
|
2003 |
|
|
/* Language-dependent initialization. Returns true on success. */
|
2004 |
|
|
if (lang_dependent_init (main_input_filename))
|
2005 |
|
|
compile_file ();
|
2006 |
|
|
|
2007 |
|
|
finalize ();
|
2008 |
|
|
}
|
2009 |
|
|
|
2010 |
|
|
/* Stop timing and print the times. */
|
2011 |
|
|
timevar_stop (TV_TOTAL);
|
2012 |
|
|
timevar_print (stderr);
|
2013 |
|
|
}
|
2014 |
|
|
|
2015 |
|
|
/* Entry point of cc1, cc1plus, jc1, f771, etc.
|
2016 |
|
|
Exit code is FATAL_EXIT_CODE if can't open files or if there were
|
2017 |
|
|
any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
|
2018 |
|
|
|
2019 |
|
|
It is not safe to call this function more than once. */
|
2020 |
|
|
|
2021 |
|
|
int
|
2022 |
|
|
toplev_main (unsigned int argc, const char **argv)
|
2023 |
|
|
{
|
2024 |
|
|
save_argv = argv;
|
2025 |
|
|
|
2026 |
|
|
/* Initialization of GCC's environment, and diagnostics. */
|
2027 |
|
|
general_init (argv[0]);
|
2028 |
|
|
|
2029 |
|
|
/* Parse the options and do minimal processing; basically just
|
2030 |
|
|
enough to default flags appropriately. */
|
2031 |
|
|
decode_options (argc, argv);
|
2032 |
|
|
|
2033 |
|
|
randomize ();
|
2034 |
|
|
|
2035 |
|
|
/* Exit early if we can (e.g. -help). */
|
2036 |
|
|
if (!exit_after_options)
|
2037 |
|
|
do_compile ();
|
2038 |
|
|
|
2039 |
|
|
if (errorcount || sorrycount)
|
2040 |
|
|
return (FATAL_EXIT_CODE);
|
2041 |
|
|
|
2042 |
|
|
return (SUCCESS_EXIT_CODE);
|
2043 |
|
|
}
|