1 /* 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, 2008
4 Free Software Foundation, Inc.
6 This file is part of GCC.
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
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
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/>. */
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. */
28 #undef FLOAT /* This is for hpux. They should change hpux. */
29 #undef FFS /* Some systems define this in param.h. */
31 #include "coretypes.h"
35 #ifdef HAVE_SYS_RESOURCE_H
36 # include <sys/resource.h>
39 #ifdef HAVE_SYS_TIMES_H
40 # include <sys/times.h>
50 #include "insn-attr.h"
51 #include "insn-config.h"
52 #include "insn-flags.h"
53 #include "hard-reg-set.h"
60 #include "basic-block.h"
66 #include "diagnostic.h"
70 #include "dwarf2asm.h"
71 #include "integrate.h"
75 #include "langhooks.h"
76 #include "cfglayout.h"
78 #include "hosthooks.h"
82 #include "value-prof.h"
83 #include "alloc-pool.h"
84 #include "tree-mudflap.h"
85 #include "tree-pass.h"
87 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
88 #include "dwarf2out.h"
91 #if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO)
95 #ifdef SDB_DEBUGGING_INFO
99 #ifdef XCOFF_DEBUGGING_INFO
100 #include "xcoffout.h" /* Needed for external data
101 declarations for e.g. AIX 4.x. */
104 static void general_init (const char *);
105 static void do_compile (void);
106 static void process_options (void);
107 static void backend_init (void);
108 static int lang_dependent_init (const char *);
109 static void init_asm_output (const char *);
110 static void finalize (void);
112 static void crash_signal (int) ATTRIBUTE_NORETURN
;
113 static void setup_core_dumping (void);
114 static void compile_file (void);
116 /* Nonzero to dump debug info whilst parsing (-dy option). */
117 static int set_yydebug
;
119 /* True if we don't need a backend (e.g. preprocessing only). */
120 static bool no_backend
;
122 /* Length of line when printing switch values. */
125 /* Name of program invoked, sans directories. */
127 const char *progname
;
129 /* Copy of argument vector to toplev_main. */
130 static const char **save_argv
;
132 /* Name of top-level original source file (what was input to cpp).
133 This comes from the #-command at the beginning of the actual input.
134 If there isn't any there, then this is the cc1 input file name. */
136 const char *main_input_filename
;
138 /* Used to enable -fvar-tracking, -fweb and -frename-registers according
139 to optimize and default_debug_hooks in process_options (). */
140 #define AUTODETECT_VALUE 2
142 /* Current position in real source file. */
144 location_t input_location
;
146 struct line_maps
*line_table
;
148 /* Name to use as base of names for dump output files. */
150 const char *dump_base_name
;
152 /* Name to use as a base for auxiliary output files. */
154 const char *aux_base_name
;
156 /* Prefix for profile data files */
157 const char *profile_data_prefix
;
159 /* A mask of target_flags that includes bit X if X was set or cleared
160 on the command line. */
162 int target_flags_explicit
;
164 /* Debug hooks - dependent upon command line options. */
166 const struct gcc_debug_hooks
*debug_hooks
;
168 /* Debug hooks - target default. */
170 static const struct gcc_debug_hooks
*default_debug_hooks
;
172 /* Other flags saying which kinds of debugging dump have been requested. */
174 int rtl_dump_and_exit
;
175 int flag_print_asm_name
;
176 enum graph_dump_types graph_dump_format
;
178 /* Name for output file of assembly code, specified with -o. */
180 const char *asm_file_name
;
182 /* Nonzero means do optimizations. -O.
183 Particular numeric values stand for particular amounts of optimization;
184 thus, -O2 stores 2 here. However, the optimizations beyond the basic
185 ones are not controlled directly by this variable. Instead, they are
186 controlled by individual `flag_...' variables that are defaulted
187 based on this variable. */
191 /* Nonzero means optimize for size. -Os.
192 The only valid values are zero and nonzero. When optimize_size is
193 nonzero, optimize defaults to 2, but certain individual code
194 bloating optimizations are disabled. */
196 int optimize_size
= 0;
198 /* The FUNCTION_DECL for the function currently being compiled,
199 or 0 if between functions. */
200 tree current_function_decl
;
202 /* Set to the FUNC_BEGIN label of the current function, or NULL
204 const char * current_function_func_begin_label
;
206 /* Temporarily suppress certain warnings.
207 This is set while reading code from a system header file. */
209 int in_system_header
= 0;
211 /* Nonzero means to collect statistics which might be expensive
212 and to print them when we are done. */
213 int flag_detailed_statistics
= 0;
215 /* A random sequence of characters, unless overridden by user. */
216 static const char *flag_random_seed
;
218 /* A local time stamp derived from the time of compilation. It will be
219 zero if the system cannot provide a time. It will be -1u, if the
220 user has specified a particular random seed. */
225 /* Nonzero means `char' should be signed. */
227 int flag_signed_char
;
229 /* Nonzero means give an enum type only as many bytes as it needs. A value
230 of 2 means it has not yet been initialized. */
232 int flag_short_enums
;
234 /* Nonzero if structures and unions should be returned in memory.
236 This should only be defined if compatibility with another compiler or
237 with an ABI is needed, because it results in slower code. */
239 #ifndef DEFAULT_PCC_STRUCT_RETURN
240 #define DEFAULT_PCC_STRUCT_RETURN 1
243 /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */
245 int flag_pcc_struct_return
= DEFAULT_PCC_STRUCT_RETURN
;
247 /* 0 means straightforward implementation of complex divide acceptable.
248 1 means wide ranges of inputs must work for complex divide.
249 2 means C99-like requirements for complex multiply and divide. */
251 int flag_complex_method
= 1;
253 /* Nonzero means that we don't want inlining by virtue of -fno-inline,
254 not just because the tree inliner turned us off. */
256 int flag_really_no_inline
= 2;
258 /* Nonzero means we should be saving declaration info into a .X file. */
260 int flag_gen_aux_info
= 0;
262 /* Specified name of aux-info file. */
264 const char *aux_info_file_name
;
266 /* Nonzero if we are compiling code for a shared library, zero for
271 /* Generate code for GNU or NeXT Objective-C runtime environment. */
273 #ifdef NEXT_OBJC_RUNTIME
274 int flag_next_runtime
= 1;
276 int flag_next_runtime
= 0;
279 /* Set to the default thread-local storage (tls) model to use. */
281 enum tls_model flag_tls_default
= TLS_MODEL_GLOBAL_DYNAMIC
;
283 /* Set the default algorithm for the integrated register allocator. */
285 enum ira_algorithm flag_ira_algorithm
= IRA_ALGORITHM_MIXED
;
287 /* Set the default value for -fira-verbose. */
289 unsigned int flag_ira_verbose
= 5;
291 /* Nonzero means change certain warnings into errors.
292 Usually these are warnings about failure to conform to some standard. */
294 int flag_pedantic_errors
= 0;
296 /* Nonzero means make permerror produce warnings instead of errors. */
298 int flag_permissive
= 0;
300 /* -dA causes debug commentary information to be produced in
301 the generated assembly code (to make it more readable). This option
302 is generally only of use to those who actually need to read the
303 generated assembly code (perhaps while debugging the compiler itself).
304 Currently, this switch is only used by dwarfout.c; however, it is intended
305 to be a catchall for printing debug information in the assembler file. */
307 int flag_debug_asm
= 0;
309 /* -dP causes the rtl to be emitted as a comment in assembly. */
311 int flag_dump_rtl_in_asm
= 0;
313 /* When non-NULL, indicates that whenever space is allocated on the
314 stack, the resulting stack pointer must not pass this
315 address---that is, for stacks that grow downward, the stack pointer
316 must always be greater than or equal to this address; for stacks
317 that grow upward, the stack pointer must be less than this address.
318 At present, the rtx may be either a REG or a SYMBOL_REF, although
319 the support provided depends on the backend. */
322 /* Nonzero if we should track variables. When
323 flag_var_tracking == AUTODETECT_VALUE it will be set according
324 to optimize, debug_info_level and debug_hooks in process_options (). */
325 int flag_var_tracking
= AUTODETECT_VALUE
;
327 /* True if the user has tagged the function with the 'section'
330 bool user_defined_section_attribute
= false;
332 /* Values of the -falign-* flags: how much to align labels in code.
333 0 means `use default', 1 means `don't align'.
334 For each variable, there is an _log variant which is the power
335 of two not less than the variable, for .align output. */
338 int align_loops_max_skip
;
340 int align_jumps_max_skip
;
341 int align_labels_log
;
342 int align_labels_max_skip
;
343 int align_functions_log
;
347 const char *const string
;
351 lang_independent_options
;
353 /* Nonzero if subexpressions must be evaluated from left-to-right. */
354 int flag_evaluation_order
= 0;
356 /* The user symbol prefix after having resolved same. */
357 const char *user_label_prefix
;
359 static const param_info lang_independent_params
[] = {
360 #define DEFPARAM(ENUM, OPTION, HELP, DEFAULT, MIN, MAX) \
361 { OPTION, DEFAULT, false, MIN, MAX, HELP },
362 #include "params.def"
364 { NULL
, 0, false, 0, 0, NULL
}
367 /* Output files for assembler code (real compiler output)
368 and debugging dumps. */
372 FILE *dump_file
= NULL
;
373 const char *dump_file_name
;
375 /* The current working directory of a translation. It's generally the
376 directory from which compilation was initiated, but a preprocessed
377 file may specify the original directory in which it was
380 static const char *src_pwd
;
382 /* Initialize src_pwd with the given string, and return true. If it
383 was already initialized, return false. As a special case, it may
384 be called with a NULL argument to test whether src_pwd has NOT been
388 set_src_pwd (const char *pwd
)
392 if (strcmp (src_pwd
, pwd
) == 0)
398 src_pwd
= xstrdup (pwd
);
402 /* Return the directory from which the translation unit was initiated,
403 in case set_src_pwd() was not called before to assign it a
419 /* Called when the start of a function definition is parsed,
420 this function prints on stderr the name of the function. */
422 announce_function (tree decl
)
426 if (rtl_dump_and_exit
)
427 fprintf (stderr
, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl
)));
429 fprintf (stderr
, " %s", lang_hooks
.decl_printable_name (decl
, 2));
431 pp_needs_newline (global_dc
->printer
) = true;
432 diagnostic_set_last_function (global_dc
, (diagnostic_info
*) NULL
);
436 /* Initialize local_tick with the time of day, or -1 if
437 flag_random_seed is set. */
440 init_local_tick (void)
442 if (!flag_random_seed
)
444 /* Get some more or less random data. */
445 #ifdef HAVE_GETTIMEOFDAY
449 gettimeofday (&tv
, NULL
);
450 local_tick
= tv
.tv_sec
* 1000 + tv
.tv_usec
/ 1000;
454 time_t now
= time (NULL
);
456 if (now
!= (time_t)-1)
457 local_tick
= (unsigned) now
;
465 /* Set up a default flag_random_seed and local_tick, unless the user
466 already specified one. Must be called after init_local_tick. */
469 init_random_seed (void)
471 unsigned HOST_WIDE_INT value
;
472 static char random_seed
[HOST_BITS_PER_WIDE_INT
/ 4 + 3];
474 value
= local_tick
^ getpid ();
476 sprintf (random_seed
, HOST_WIDE_INT_PRINT_HEX
, value
);
477 flag_random_seed
= random_seed
;
480 /* Obtain the random_seed string. Unless NOINIT, initialize it if
481 it's not provided in the command line. */
484 get_random_seed (bool noinit
)
486 if (!flag_random_seed
&& !noinit
)
488 return flag_random_seed
;
491 /* Modify the random_seed string to VAL. Return its previous
495 set_random_seed (const char *val
)
497 const char *old
= flag_random_seed
;
498 flag_random_seed
= val
;
502 /* Decode the string P as an integral parameter.
503 If the string is indeed an integer return its numeric value else
504 issue an Invalid Option error for the option PNAME and return DEFVAL.
505 If PNAME is zero just return DEFVAL, do not call error. */
508 read_integral_parameter (const char *p
, const char *pname
, const int defval
)
510 const char *endp
= p
;
523 error ("invalid option argument %qs", pname
);
530 /* When compiling with a recent enough GCC, we use the GNU C "extern inline"
531 for floor_log2 and exact_log2; see toplev.h. That construct, however,
532 conflicts with the ISO C++ One Definition Rule. */
534 #if GCC_VERSION < 3004 || !defined (__cplusplus)
536 /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
537 If X is 0, return -1. */
540 floor_log2 (unsigned HOST_WIDE_INT x
)
548 t
= HOST_BITS_PER_WIDE_INT
- 1 - (int) CLZ_HWI (x
);
550 if (HOST_BITS_PER_WIDE_INT
> 64)
551 if (x
>= (unsigned HOST_WIDE_INT
) 1 << (t
+ 64))
553 if (HOST_BITS_PER_WIDE_INT
> 32)
554 if (x
>= ((unsigned HOST_WIDE_INT
) 1) << (t
+ 32))
556 if (x
>= ((unsigned HOST_WIDE_INT
) 1) << (t
+ 16))
558 if (x
>= ((unsigned HOST_WIDE_INT
) 1) << (t
+ 8))
560 if (x
>= ((unsigned HOST_WIDE_INT
) 1) << (t
+ 4))
562 if (x
>= ((unsigned HOST_WIDE_INT
) 1) << (t
+ 2))
564 if (x
>= ((unsigned HOST_WIDE_INT
) 1) << (t
+ 1))
571 /* Return the logarithm of X, base 2, considering X unsigned,
572 if X is a power of 2. Otherwise, returns -1. */
575 exact_log2 (unsigned HOST_WIDE_INT x
)
580 return x
? CTZ_HWI (x
) : -1;
582 return floor_log2 (x
);
586 #endif /* GCC_VERSION < 3004 || !defined (__cplusplus) */
588 /* Handler for fatal signals, such as SIGSEGV. These are transformed
589 into ICE messages, which is much more user friendly. In case the
590 error printer crashes, reset the signal to prevent infinite recursion. */
593 crash_signal (int signo
)
595 signal (signo
, SIG_DFL
);
597 /* If we crashed while processing an ASM statement, then be a little more
598 graceful. It's most likely the user's fault. */
599 if (this_is_asm_operands
)
601 output_operand_lossage ("unrecoverable error");
602 exit (FATAL_EXIT_CODE
);
605 internal_error ("%s", strsignal (signo
));
608 /* Arrange to dump core on error. (The regular error message is still
609 printed first, except in the case of abort().) */
612 setup_core_dumping (void)
615 signal (SIGABRT
, SIG_DFL
);
617 #if defined(HAVE_SETRLIMIT)
620 if (getrlimit (RLIMIT_CORE
, &rlim
) != 0)
621 fatal_error ("getting core file size maximum limit: %m");
622 rlim
.rlim_cur
= rlim
.rlim_max
;
623 if (setrlimit (RLIMIT_CORE
, &rlim
) != 0)
624 fatal_error ("setting core file size limit to maximum: %m");
627 diagnostic_abort_on_error (global_dc
);
631 /* Strip off a legitimate source ending from the input string NAME of
632 length LEN. Rather than having to know the names used by all of
633 our front ends, we strip off an ending of a period followed by
634 up to five characters. (Java uses ".class".) */
637 strip_off_ending (char *name
, int len
)
640 for (i
= 2; i
< 6 && len
> i
; i
++)
642 if (name
[len
- i
] == '.')
644 name
[len
- i
] = '\0';
650 /* Output a quoted string. */
653 output_quoted_string (FILE *asm_file
, const char *string
)
655 #ifdef OUTPUT_QUOTED_STRING
656 OUTPUT_QUOTED_STRING (asm_file
, string
);
660 putc ('\"', asm_file
);
661 while ((c
= *string
++) != 0)
665 if (c
== '\"' || c
== '\\')
666 putc ('\\', asm_file
);
670 fprintf (asm_file
, "\\%03o", (unsigned char) c
);
672 putc ('\"', asm_file
);
676 /* Output a file name in the form wanted by System V. */
679 output_file_directive (FILE *asm_file
, const char *input_name
)
684 if (input_name
== NULL
)
685 input_name
= "<stdin>";
687 input_name
= remap_debug_filename (input_name
);
689 len
= strlen (input_name
);
690 na
= input_name
+ len
;
692 /* NA gets INPUT_NAME sans directory names. */
693 while (na
> input_name
)
695 if (IS_DIR_SEPARATOR (na
[-1]))
700 #ifdef ASM_OUTPUT_SOURCE_FILENAME
701 ASM_OUTPUT_SOURCE_FILENAME (asm_file
, na
);
703 fprintf (asm_file
, "\t.file\t");
704 output_quoted_string (asm_file
, na
);
705 fputc ('\n', asm_file
);
709 /* A subroutine of wrapup_global_declarations. We've come to the end of
710 the compilation unit. All deferred variables should be undeferred,
711 and all incomplete decls should be finalized. */
714 wrapup_global_declaration_1 (tree decl
)
716 /* We're not deferring this any longer. Assignment is conditional to
717 avoid needlessly dirtying PCH pages. */
718 if (CODE_CONTAINS_STRUCT (TREE_CODE (decl
), TS_DECL_WITH_VIS
)
719 && DECL_DEFER_OUTPUT (decl
) != 0)
720 DECL_DEFER_OUTPUT (decl
) = 0;
722 if (TREE_CODE (decl
) == VAR_DECL
&& DECL_SIZE (decl
) == 0)
723 lang_hooks
.finish_incomplete_decl (decl
);
726 /* A subroutine of wrapup_global_declarations. Decide whether or not DECL
727 needs to be output. Return true if it is output. */
730 wrapup_global_declaration_2 (tree decl
)
732 if (TREE_ASM_WRITTEN (decl
) || DECL_EXTERNAL (decl
))
735 /* Don't write out static consts, unless we still need them.
737 We also keep static consts if not optimizing (for debugging),
738 unless the user specified -fno-keep-static-consts.
739 ??? They might be better written into the debug information.
740 This is possible when using DWARF.
742 A language processor that wants static constants to be always
743 written out (even if it is not used) is responsible for
744 calling rest_of_decl_compilation itself. E.g. the C front-end
745 calls rest_of_decl_compilation from finish_decl.
746 One motivation for this is that is conventional in some
747 environments to write things like:
748 static const char rcsid[] = "... version string ...";
749 intending to force the string to be in the executable.
751 A language processor that would prefer to have unneeded
752 static constants "optimized away" would just defer writing
753 them out until here. E.g. C++ does this, because static
754 constants are often defined in header files.
756 ??? A tempting alternative (for both C and C++) would be
757 to force a constant to be written if and only if it is
758 defined in a main file, as opposed to an include file. */
760 if (TREE_CODE (decl
) == VAR_DECL
&& TREE_STATIC (decl
))
762 struct varpool_node
*node
;
764 node
= varpool_node (decl
);
768 else if (node
->alias
)
770 else if (!cgraph_global_info_ready
772 || TREE_USED (DECL_ASSEMBLER_NAME (decl
))))
774 else if (node
->needed
)
776 else if (DECL_COMDAT (decl
))
778 else if (TREE_READONLY (decl
) && !TREE_PUBLIC (decl
)
779 && (optimize
|| !flag_keep_static_consts
780 || DECL_ARTIFICIAL (decl
)))
785 rest_of_decl_compilation (decl
, 1, 1);
793 /* Do any final processing required for the declarations in VEC, of
794 which there are LEN. We write out inline functions and variables
795 that have been deferred until this point, but which are required.
796 Returns nonzero if anything was put out. */
799 wrapup_global_declarations (tree
*vec
, int len
)
801 bool reconsider
, output_something
= false;
804 for (i
= 0; i
< len
; i
++)
805 wrapup_global_declaration_1 (vec
[i
]);
807 /* Now emit any global variables or functions that we have been
808 putting off. We need to loop in case one of the things emitted
809 here references another one which comes earlier in the list. */
813 for (i
= 0; i
< len
; i
++)
814 reconsider
|= wrapup_global_declaration_2 (vec
[i
]);
816 output_something
= true;
820 return output_something
;
823 /* A subroutine of check_global_declarations. Issue appropriate warnings
824 for the global declaration DECL. */
827 check_global_declaration_1 (tree decl
)
829 /* Warn about any function declared static but not defined. We don't
830 warn about variables, because many programs have static variables
831 that exist only to get some text into the object file. */
832 if (TREE_CODE (decl
) == FUNCTION_DECL
833 && DECL_INITIAL (decl
) == 0
834 && DECL_EXTERNAL (decl
)
835 && ! DECL_ARTIFICIAL (decl
)
836 && ! TREE_NO_WARNING (decl
)
837 && ! TREE_PUBLIC (decl
)
838 && (warn_unused_function
839 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
))))
841 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl
)))
842 pedwarn ("%q+F used but never defined", decl
);
844 warning (OPT_Wunused_function
, "%q+F declared %<static%> but never defined", decl
);
845 /* This symbol is effectively an "extern" declaration now. */
846 TREE_PUBLIC (decl
) = 1;
847 assemble_external (decl
);
850 /* Warn about static fns or vars defined but not used. */
851 if (((warn_unused_function
&& TREE_CODE (decl
) == FUNCTION_DECL
)
852 /* We don't warn about "static const" variables because the
853 "rcs_id" idiom uses that construction. */
854 || (warn_unused_variable
855 && TREE_CODE (decl
) == VAR_DECL
&& ! TREE_READONLY (decl
)))
856 && ! DECL_IN_SYSTEM_HEADER (decl
)
857 && ! TREE_USED (decl
)
858 /* The TREE_USED bit for file-scope decls is kept in the identifier,
859 to handle multiple external decls in different scopes. */
860 && ! (DECL_NAME (decl
) && TREE_USED (DECL_NAME (decl
)))
861 && ! DECL_EXTERNAL (decl
)
862 && ! TREE_PUBLIC (decl
)
863 /* A volatile variable might be used in some non-obvious way. */
864 && ! TREE_THIS_VOLATILE (decl
)
865 /* Global register variables must be declared to reserve them. */
866 && ! (TREE_CODE (decl
) == VAR_DECL
&& DECL_REGISTER (decl
))
867 /* Otherwise, ask the language. */
868 && lang_hooks
.decls
.warn_unused_global (decl
))
869 warning ((TREE_CODE (decl
) == FUNCTION_DECL
)
870 ? OPT_Wunused_function
871 : OPT_Wunused_variable
,
872 "%q+D defined but not used", decl
);
875 /* Issue appropriate warnings for the global declarations in VEC (of
876 which there are LEN). */
879 check_global_declarations (tree
*vec
, int len
)
883 for (i
= 0; i
< len
; i
++)
884 check_global_declaration_1 (vec
[i
]);
887 /* Emit debugging information for all global declarations in VEC. */
890 emit_debug_global_declarations (tree
*vec
, int len
)
894 /* Avoid confusing the debug information machinery when there are errors. */
895 if (errorcount
!= 0 || sorrycount
!= 0)
898 timevar_push (TV_SYMOUT
);
899 for (i
= 0; i
< len
; i
++)
900 debug_hooks
->global_decl (vec
[i
]);
901 timevar_pop (TV_SYMOUT
);
904 /* Warn about a use of an identifier which was marked deprecated. */
906 warn_deprecated_use (tree node
)
908 if (node
== 0 || !warn_deprecated_decl
)
913 expanded_location xloc
= expand_location (DECL_SOURCE_LOCATION (node
));
914 warning (OPT_Wdeprecated_declarations
,
915 "%qD is deprecated (declared at %s:%d)",
916 node
, xloc
.file
, xloc
.line
);
918 else if (TYPE_P (node
))
920 const char *what
= NULL
;
921 tree decl
= TYPE_STUB_DECL (node
);
923 if (TYPE_NAME (node
))
925 if (TREE_CODE (TYPE_NAME (node
)) == IDENTIFIER_NODE
)
926 what
= IDENTIFIER_POINTER (TYPE_NAME (node
));
927 else if (TREE_CODE (TYPE_NAME (node
)) == TYPE_DECL
928 && DECL_NAME (TYPE_NAME (node
)))
929 what
= IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node
)));
934 expanded_location xloc
935 = expand_location (DECL_SOURCE_LOCATION (decl
));
937 warning (OPT_Wdeprecated_declarations
,
938 "%qs is deprecated (declared at %s:%d)", what
,
939 xloc
.file
, xloc
.line
);
941 warning (OPT_Wdeprecated_declarations
,
942 "type is deprecated (declared at %s:%d)",
943 xloc
.file
, xloc
.line
);
948 warning (OPT_Wdeprecated_declarations
, "%qs is deprecated", what
);
950 warning (OPT_Wdeprecated_declarations
, "type is deprecated");
955 /* Compile an entire translation unit. Write a file of assembly
956 output and various debugging dumps. */
961 /* Initialize yet another pass. */
963 ggc_protect_identifiers
= true;
966 init_final (main_input_filename
);
967 coverage_init (aux_base_name
);
970 timevar_push (TV_PARSE
);
972 /* Call the parser, which parses the entire file (calling
973 rest_of_compilation for each function). */
974 lang_hooks
.parse_file (set_yydebug
);
976 /* Compilation is now finished except for writing
977 what's left of the symbol table output. */
978 timevar_pop (TV_PARSE
);
980 if (flag_syntax_only
)
983 ggc_protect_identifiers
= false;
985 lang_hooks
.decls
.final_write_globals ();
987 if (errorcount
|| sorrycount
)
990 varpool_assemble_pending_decls ();
993 /* This must occur after the loop to output deferred functions.
994 Else the coverage initializer would not be emitted if all the
995 functions in this compilation unit were deferred. */
998 /* Likewise for mudflap static object registrations. */
1000 mudflap_finish_file ();
1002 /* Likewise for emulated thread-local storage. */
1003 if (!targetm
.have_tls
)
1006 output_shared_constant_pool ();
1007 output_object_blocks ();
1009 /* Write out any pending weak symbol declarations. */
1012 /* Do dbx symbols. */
1013 timevar_push (TV_SYMOUT
);
1015 #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
1016 if (dwarf2out_do_frame ())
1017 dwarf2out_frame_finish ();
1020 (*debug_hooks
->finish
) (main_input_filename
);
1021 timevar_pop (TV_SYMOUT
);
1023 /* Output some stuff at end of file if nec. */
1025 dw2_output_indirect_constants ();
1027 /* Flush any pending external directives. */
1028 process_pending_assemble_externals ();
1030 /* Attach a special .ident directive to the end of the file to identify
1031 the version of GCC which compiled this code. The format of the .ident
1032 string is patterned after the ones produced by native SVR4 compilers. */
1036 const char *pkg_version
= "(GNU) ";
1038 if (strcmp ("(GCC) ", pkgversion_string
))
1039 pkg_version
= pkgversion_string
;
1040 fprintf (asm_out_file
, "%s\"GCC: %s%s\"\n",
1041 IDENT_ASM_OP
, pkg_version
, version_string
);
1045 /* This must be at the end. Some target ports emit end of file directives
1046 into the assembly file here, and hence we can not output anything to the
1047 assembly file after this point. */
1048 targetm
.asm_out
.file_end ();
1051 /* Parse a -d... command line switch. */
1054 decode_d_option (const char *arg
)
1065 flag_print_asm_name
= 1;
1068 flag_dump_rtl_in_asm
= 1;
1069 flag_print_asm_name
= 1;
1072 graph_dump_format
= vcg
;
1075 rtl_dump_and_exit
= 1;
1080 case 'D': /* These are handled by the preprocessor. */
1087 setup_core_dumping();
1090 enable_rtl_dump_file ();
1094 warning (0, "unrecognized gcc debugging option: %c", c
);
1099 /* Indexed by enum debug_info_type. */
1100 const char *const debug_type_names
[] =
1102 "none", "stabs", "coff", "dwarf-2", "xcoff", "vms"
1105 /* Print version information to FILE.
1106 Each line begins with INDENT (for the case where FILE is the
1107 assembler output file). */
1110 print_version (FILE *file
, const char *indent
)
1112 static const char fmt1
[] =
1114 N_("%s%s%s %sversion %s (%s)\n%s\tcompiled by GNU C version %s, ")
1116 N_("%s%s%s %sversion %s (%s) compiled by CC, ")
1119 static const char fmt2
[] =
1120 N_("GMP version %s, MPFR version %s.\n");
1121 static const char fmt3
[] =
1122 N_("%s%swarning: %s header version %s differs from library version %s.\n");
1123 static const char fmt4
[] =
1124 N_("%s%sGGC heuristics: --param ggc-min-expand=%d --param ggc-min-heapsize=%d\n");
1126 #define __VERSION__ "[?]"
1129 file
== stderr
? _(fmt1
) : fmt1
,
1130 indent
, *indent
!= 0 ? " " : "",
1131 lang_hooks
.name
, pkgversion_string
, version_string
, TARGET_NAME
,
1132 indent
, __VERSION__
);
1134 /* We need to stringify the GMP macro values. Ugh, gmp_version has
1135 two string formats, "i.j.k" and "i.j" when k is zero. */
1136 #define GCC_GMP_STRINGIFY_VERSION3(X) #X
1137 #define GCC_GMP_STRINGIFY_VERSION2(X) GCC_GMP_STRINGIFY_VERSION3(X)
1138 #if __GNU_MP_VERSION_PATCHLEVEL == 0
1139 #define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
1140 GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR)
1142 #define GCC_GMP_STRINGIFY_VERSION GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION) "." \
1143 GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_MINOR) "." \
1144 GCC_GMP_STRINGIFY_VERSION2(__GNU_MP_VERSION_PATCHLEVEL)
1147 file
== stderr
? _(fmt2
) : fmt2
,
1148 GCC_GMP_STRINGIFY_VERSION
, MPFR_VERSION_STRING
);
1149 if (strcmp (GCC_GMP_STRINGIFY_VERSION
, gmp_version
))
1151 file
== stderr
? _(fmt3
) : fmt3
,
1152 indent
, *indent
!= 0 ? " " : "",
1153 "GMP", GCC_GMP_STRINGIFY_VERSION
, gmp_version
);
1154 if (strcmp (MPFR_VERSION_STRING
, mpfr_get_version ()))
1156 file
== stderr
? _(fmt3
) : fmt3
,
1157 indent
, *indent
!= 0 ? " " : "",
1158 "MPFR", MPFR_VERSION_STRING
, mpfr_get_version ());
1160 file
== stderr
? _(fmt4
) : fmt4
,
1161 indent
, *indent
!= 0 ? " " : "",
1162 PARAM_VALUE (GGC_MIN_EXPAND
), PARAM_VALUE (GGC_MIN_HEAPSIZE
));
1165 #ifdef ASM_COMMENT_START
1167 print_to_asm_out_file (print_switch_type type
, const char * text
)
1169 bool prepend_sep
= true;
1173 case SWITCH_TYPE_LINE_END
:
1174 putc ('\n', asm_out_file
);
1177 case SWITCH_TYPE_LINE_START
:
1178 fputs (ASM_COMMENT_START
, asm_out_file
);
1179 return strlen (ASM_COMMENT_START
);
1181 case SWITCH_TYPE_DESCRIPTIVE
:
1182 if (ASM_COMMENT_START
[0] == 0)
1183 prepend_sep
= false;
1185 case SWITCH_TYPE_PASSED
:
1186 case SWITCH_TYPE_ENABLED
:
1188 fputc (' ', asm_out_file
);
1189 fprintf (asm_out_file
, text
);
1190 /* No need to return the length here as
1191 print_single_switch has already done it. */
1201 print_to_stderr (print_switch_type type
, const char * text
)
1205 case SWITCH_TYPE_LINE_END
:
1206 putc ('\n', stderr
);
1209 case SWITCH_TYPE_LINE_START
:
1212 case SWITCH_TYPE_PASSED
:
1213 case SWITCH_TYPE_ENABLED
:
1214 fputc (' ', stderr
);
1217 case SWITCH_TYPE_DESCRIPTIVE
:
1218 fprintf (stderr
, text
);
1219 /* No need to return the length here as
1220 print_single_switch has already done it. */
1228 /* Print an option value and return the adjusted position in the line.
1229 ??? print_fn doesn't handle errors, eg disk full; presumably other
1230 code will catch a disk full though. */
1233 print_single_switch (print_switch_fn_type print_fn
,
1235 print_switch_type type
,
1238 /* The ultrix fprintf returns 0 on success, so compute the result
1239 we want here since we need it for the following test. The +1
1240 is for the separator character that will probably be emitted. */
1241 int len
= strlen (text
) + 1;
1244 && pos
+ len
> MAX_LINE
)
1246 print_fn (SWITCH_TYPE_LINE_END
, NULL
);
1251 pos
+= print_fn (SWITCH_TYPE_LINE_START
, NULL
);
1253 print_fn (type
, text
);
1257 /* Print active target switches using PRINT_FN.
1258 POS is the current cursor position and MAX is the size of a "line".
1259 Each line begins with INDENT and ends with TERM.
1260 Each switch is separated from the next by SEP. */
1263 print_switch_values (print_switch_fn_type print_fn
)
1269 /* Fill in the -frandom-seed option, if the user didn't pass it, so
1270 that it can be printed below. This helps reproducibility. */
1271 if (!flag_random_seed
)
1272 init_random_seed ();
1274 /* Print the options as passed. */
1275 pos
= print_single_switch (print_fn
, pos
,
1276 SWITCH_TYPE_DESCRIPTIVE
, _("options passed: "));
1278 for (p
= &save_argv
[1]; *p
!= NULL
; p
++)
1283 if (strcmp (*p
, "-o") == 0
1284 || strcmp (*p
, "-dumpbase") == 0
1285 || strcmp (*p
, "-auxbase") == 0)
1292 if (strcmp (*p
, "-quiet") == 0
1293 || strcmp (*p
, "-version") == 0)
1300 pos
= print_single_switch (print_fn
, pos
, SWITCH_TYPE_PASSED
, *p
);
1304 print_fn (SWITCH_TYPE_LINE_END
, NULL
);
1306 /* Print the -f and -m options that have been enabled.
1307 We don't handle language specific options but printing argv
1309 pos
= print_single_switch (print_fn
, 0,
1310 SWITCH_TYPE_DESCRIPTIVE
, _("options enabled: "));
1312 for (j
= 0; j
< cl_options_count
; j
++)
1313 if ((cl_options
[j
].flags
& CL_REPORT
)
1314 && option_enabled (j
) > 0)
1315 pos
= print_single_switch (print_fn
, pos
,
1316 SWITCH_TYPE_ENABLED
, cl_options
[j
].opt_text
);
1318 print_fn (SWITCH_TYPE_LINE_END
, NULL
);
1321 /* Open assembly code output file. Do this even if -fsyntax-only is
1322 on, because then the driver will have provided the name of a
1323 temporary file or bit bucket for us. NAME is the file specified on
1324 the command line, possibly NULL. */
1326 init_asm_output (const char *name
)
1328 if (name
== NULL
&& asm_file_name
== 0)
1329 asm_out_file
= stdout
;
1332 if (asm_file_name
== 0)
1334 int len
= strlen (dump_base_name
);
1335 char *dumpname
= XNEWVEC (char, len
+ 6);
1337 memcpy (dumpname
, dump_base_name
, len
+ 1);
1338 strip_off_ending (dumpname
, len
);
1339 strcat (dumpname
, ".s");
1340 asm_file_name
= dumpname
;
1342 if (!strcmp (asm_file_name
, "-"))
1343 asm_out_file
= stdout
;
1345 asm_out_file
= fopen (asm_file_name
, "w+b");
1346 if (asm_out_file
== 0)
1347 fatal_error ("can%'t open %s for writing: %m", asm_file_name
);
1350 if (!flag_syntax_only
)
1352 targetm
.asm_out
.file_start ();
1354 if (flag_record_gcc_switches
)
1356 if (targetm
.asm_out
.record_gcc_switches
)
1358 /* Let the target know that we are about to start recording. */
1359 targetm
.asm_out
.record_gcc_switches (SWITCH_TYPE_DESCRIPTIVE
,
1361 /* Now record the switches. */
1362 print_switch_values (targetm
.asm_out
.record_gcc_switches
);
1363 /* Let the target know that the recording is over. */
1364 targetm
.asm_out
.record_gcc_switches (SWITCH_TYPE_DESCRIPTIVE
,
1368 inform ("-frecord-gcc-switches is not supported by the current target");
1371 #ifdef ASM_COMMENT_START
1372 if (flag_verbose_asm
)
1374 /* Print the list of switches in effect
1375 into the assembler file as comments. */
1376 print_version (asm_out_file
, ASM_COMMENT_START
);
1377 print_switch_values (print_to_asm_out_file
);
1378 fprintf (asm_out_file
, "\n");
1384 /* Return true if the state of option OPTION should be stored in PCH files
1385 and checked by default_pch_valid_p. Store the option's current state
1389 option_affects_pch_p (int option
, struct cl_option_state
*state
)
1391 if ((cl_options
[option
].flags
& CL_TARGET
) == 0)
1393 if (cl_options
[option
].flag_var
== &target_flags
)
1394 if (targetm
.check_pch_target_flags
)
1396 return get_option_state (option
, state
);
1399 /* Default version of get_pch_validity.
1400 By default, every flag difference is fatal; that will be mostly right for
1401 most targets, but completely right for very few. */
1404 default_get_pch_validity (size_t *len
)
1406 struct cl_option_state state
;
1411 if (targetm
.check_pch_target_flags
)
1412 *len
+= sizeof (target_flags
);
1413 for (i
= 0; i
< cl_options_count
; i
++)
1414 if (option_affects_pch_p (i
, &state
))
1417 result
= r
= XNEWVEC (char, *len
);
1421 if (targetm
.check_pch_target_flags
)
1423 memcpy (r
, &target_flags
, sizeof (target_flags
));
1424 r
+= sizeof (target_flags
);
1427 for (i
= 0; i
< cl_options_count
; i
++)
1428 if (option_affects_pch_p (i
, &state
))
1430 memcpy (r
, state
.data
, state
.size
);
1437 /* Return a message which says that a PCH file was created with a different
1438 setting of OPTION. */
1441 pch_option_mismatch (const char *option
)
1445 asprintf (&r
, _("created and used with differing settings of '%s'"), option
);
1447 return _("out of memory");
1451 /* Default version of pch_valid_p. */
1454 default_pch_valid_p (const void *data_p
, size_t len
)
1456 struct cl_option_state state
;
1457 const char *data
= (const char *)data_p
;
1460 /* -fpic and -fpie also usually make a PCH invalid. */
1461 if (data
[0] != flag_pic
)
1462 return _("created and used with different settings of -fpic");
1463 if (data
[1] != flag_pie
)
1464 return _("created and used with different settings of -fpie");
1467 /* Check target_flags. */
1468 if (targetm
.check_pch_target_flags
)
1473 memcpy (&tf
, data
, sizeof (target_flags
));
1474 data
+= sizeof (target_flags
);
1475 len
-= sizeof (target_flags
);
1476 r
= targetm
.check_pch_target_flags (tf
);
1481 for (i
= 0; i
< cl_options_count
; i
++)
1482 if (option_affects_pch_p (i
, &state
))
1484 if (memcmp (data
, state
.data
, state
.size
) != 0)
1485 return pch_option_mismatch (cl_options
[i
].opt_text
);
1493 /* Default tree printer. Handles declarations only. */
1495 default_tree_printer (pretty_printer
* pp
, text_info
*text
, const char *spec
,
1496 int precision
, bool wide
, bool set_locus
, bool hash
)
1500 /* FUTURE: %+x should set the locus. */
1501 if (precision
!= 0 || wide
|| hash
)
1507 t
= va_arg (*text
->args_ptr
, tree
);
1508 if (DECL_DEBUG_EXPR_IS_FROM (t
) && DECL_DEBUG_EXPR (t
))
1509 t
= DECL_DEBUG_EXPR (t
);
1514 t
= va_arg (*text
->args_ptr
, tree
);
1521 if (set_locus
&& text
->locus
)
1522 *text
->locus
= DECL_SOURCE_LOCATION (t
);
1526 const char *n
= DECL_NAME (t
)
1527 ? lang_hooks
.decl_printable_name (t
, 2)
1532 dump_generic_node (pp
, t
, 0, TDF_DIAGNOSTIC
, 0);
1537 /* A helper function; used as the reallocator function for cpp's line
1540 realloc_for_line_map (void *ptr
, size_t len
)
1542 return ggc_realloc (ptr
, len
);
1545 /* Initialization of the front end environment, before command line
1546 options are parsed. Signal handlers, internationalization etc.
1547 ARGV0 is main's argv[0]. */
1549 general_init (const char *argv0
)
1553 p
= argv0
+ strlen (argv0
);
1554 while (p
!= argv0
&& !IS_DIR_SEPARATOR (p
[-1]))
1558 xmalloc_set_program_name (progname
);
1562 /* Unlock the stdio streams. */
1563 unlock_std_streams ();
1565 gcc_init_libintl ();
1567 /* Initialize the diagnostics reporting machinery, so option parsing
1568 can give warnings and errors. */
1569 diagnostic_initialize (global_dc
);
1570 /* Set a default printer. Language specific initializations will
1571 override it later. */
1572 pp_format_decoder (global_dc
->printer
) = &default_tree_printer
;
1574 /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
1576 signal (SIGSEGV
, crash_signal
);
1579 signal (SIGILL
, crash_signal
);
1582 signal (SIGBUS
, crash_signal
);
1585 signal (SIGABRT
, crash_signal
);
1587 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
1588 signal (SIGIOT
, crash_signal
);
1591 signal (SIGFPE
, crash_signal
);
1594 /* Other host-specific signal setup. */
1595 (*host_hooks
.extra_signals
)();
1597 /* Initialize the garbage-collector, string pools and tree type hash
1601 line_table
= GGC_NEW (struct line_maps
);
1602 linemap_init (line_table
);
1603 line_table
->reallocator
= realloc_for_line_map
;
1606 /* Initialize register usage now so switches may override. */
1609 /* Register the language-independent parameters. */
1610 add_params (lang_independent_params
, LAST_PARAM
);
1612 /* This must be done after add_params but before argument processing. */
1613 init_ggc_heuristics();
1614 init_optimization_passes ();
1615 statistics_early_init ();
1618 /* Return true if the current target supports -fsection-anchors. */
1621 target_supports_section_anchors_p (void)
1623 if (targetm
.min_anchor_offset
== 0 && targetm
.max_anchor_offset
== 0)
1626 if (targetm
.asm_out
.output_anchor
== NULL
)
1632 /* Default the align_* variables to 1 if they're still unset, and
1633 set up the align_*_log variables. */
1635 init_alignments (void)
1637 if (align_loops
<= 0)
1639 if (align_loops_max_skip
> align_loops
)
1640 align_loops_max_skip
= align_loops
- 1;
1641 align_loops_log
= floor_log2 (align_loops
* 2 - 1);
1642 if (align_jumps
<= 0)
1644 if (align_jumps_max_skip
> align_jumps
)
1645 align_jumps_max_skip
= align_jumps
- 1;
1646 align_jumps_log
= floor_log2 (align_jumps
* 2 - 1);
1647 if (align_labels
<= 0)
1649 align_labels_log
= floor_log2 (align_labels
* 2 - 1);
1650 if (align_labels_max_skip
> align_labels
)
1651 align_labels_max_skip
= align_labels
- 1;
1652 if (align_functions
<= 0)
1653 align_functions
= 1;
1654 align_functions_log
= floor_log2 (align_functions
* 2 - 1);
1657 /* Process the options that have been parsed. */
1659 process_options (void)
1661 /* Just in case lang_hooks.post_options ends up calling a debug_hook.
1662 This can happen with incorrect pre-processed input. */
1663 debug_hooks
= &do_nothing_debug_hooks
;
1665 /* Allow the front end to perform consistency checks and do further
1666 initialization based on the command line options. This hook also
1667 sets the original filename if appropriate (e.g. foo.i -> foo.c)
1668 so we can correctly initialize debug output. */
1669 no_backend
= lang_hooks
.post_options (&main_input_filename
);
1671 #ifdef OVERRIDE_OPTIONS
1672 /* Some machines may reject certain combinations of options. */
1676 if (flag_section_anchors
&& !target_supports_section_anchors_p ())
1678 warning (OPT_fsection_anchors
,
1679 "this target does not support %qs", "-fsection-anchors");
1680 flag_section_anchors
= 0;
1683 if (flag_short_enums
== 2)
1684 flag_short_enums
= targetm
.default_short_enums ();
1686 /* Set aux_base_name if not already set. */
1689 else if (main_input_filename
)
1691 char *name
= xstrdup (lbasename (main_input_filename
));
1693 strip_off_ending (name
, strlen (name
));
1694 aux_base_name
= name
;
1697 aux_base_name
= "gccaux";
1699 /* Unrolling all loops implies that standard loop unrolling must also
1701 if (flag_unroll_all_loops
)
1702 flag_unroll_loops
= 1;
1704 /* The loop unrolling code assumes that cse will be run after loop.
1705 web and rename-registers also help when run after loop unrolling. */
1707 if (flag_rerun_cse_after_loop
== AUTODETECT_VALUE
)
1708 flag_rerun_cse_after_loop
= flag_unroll_loops
|| flag_peel_loops
;
1709 if (flag_web
== AUTODETECT_VALUE
)
1710 flag_web
= flag_unroll_loops
|| flag_peel_loops
;
1711 if (flag_rename_registers
== AUTODETECT_VALUE
)
1712 flag_rename_registers
= flag_unroll_loops
|| flag_peel_loops
;
1714 if (flag_non_call_exceptions
)
1715 flag_asynchronous_unwind_tables
= 1;
1716 if (flag_asynchronous_unwind_tables
)
1717 flag_unwind_tables
= 1;
1719 if (!flag_unit_at_a_time
)
1720 flag_section_anchors
= 0;
1722 if (flag_value_profile_transformations
)
1723 flag_profile_values
= 1;
1725 /* Warn about options that are not supported on this machine. */
1726 #ifndef INSN_SCHEDULING
1727 if (flag_schedule_insns
|| flag_schedule_insns_after_reload
)
1728 warning (0, "instruction scheduling not supported on this target machine");
1731 if (flag_delayed_branch
)
1732 warning (0, "this target machine does not have delayed branches");
1735 user_label_prefix
= USER_LABEL_PREFIX
;
1736 if (flag_leading_underscore
!= -1)
1738 /* If the default prefix is more complicated than "" or "_",
1739 issue a warning and ignore this option. */
1740 if (user_label_prefix
[0] == 0 ||
1741 (user_label_prefix
[0] == '_' && user_label_prefix
[1] == 0))
1743 user_label_prefix
= flag_leading_underscore
? "_" : "";
1746 warning (0, "-f%sleading-underscore not supported on this target machine",
1747 flag_leading_underscore
? "" : "no-");
1750 /* If we are in verbose mode, write out the version and maybe all the
1751 option flags in use. */
1754 print_version (stderr
, "");
1756 print_switch_values (print_to_stderr
);
1759 if (flag_syntax_only
)
1761 write_symbols
= NO_DEBUG
;
1765 /* A lot of code assumes write_symbols == NO_DEBUG if the debugging
1767 if (debug_info_level
== DINFO_LEVEL_NONE
)
1768 write_symbols
= NO_DEBUG
;
1770 /* Now we know write_symbols, set up the debug hooks based on it.
1771 By default we do nothing for debug output. */
1772 if (PREFERRED_DEBUGGING_TYPE
== NO_DEBUG
)
1773 default_debug_hooks
= &do_nothing_debug_hooks
;
1774 #if defined(DBX_DEBUGGING_INFO)
1775 else if (PREFERRED_DEBUGGING_TYPE
== DBX_DEBUG
)
1776 default_debug_hooks
= &dbx_debug_hooks
;
1778 #if defined(XCOFF_DEBUGGING_INFO)
1779 else if (PREFERRED_DEBUGGING_TYPE
== XCOFF_DEBUG
)
1780 default_debug_hooks
= &xcoff_debug_hooks
;
1782 #ifdef SDB_DEBUGGING_INFO
1783 else if (PREFERRED_DEBUGGING_TYPE
== SDB_DEBUG
)
1784 default_debug_hooks
= &sdb_debug_hooks
;
1786 #ifdef DWARF2_DEBUGGING_INFO
1787 else if (PREFERRED_DEBUGGING_TYPE
== DWARF2_DEBUG
)
1788 default_debug_hooks
= &dwarf2_debug_hooks
;
1790 #ifdef VMS_DEBUGGING_INFO
1791 else if (PREFERRED_DEBUGGING_TYPE
== VMS_DEBUG
1792 || PREFERRED_DEBUGGING_TYPE
== VMS_AND_DWARF2_DEBUG
)
1793 default_debug_hooks
= &vmsdbg_debug_hooks
;
1796 if (write_symbols
== NO_DEBUG
)
1798 #if defined(DBX_DEBUGGING_INFO)
1799 else if (write_symbols
== DBX_DEBUG
)
1800 debug_hooks
= &dbx_debug_hooks
;
1802 #if defined(XCOFF_DEBUGGING_INFO)
1803 else if (write_symbols
== XCOFF_DEBUG
)
1804 debug_hooks
= &xcoff_debug_hooks
;
1806 #ifdef SDB_DEBUGGING_INFO
1807 else if (write_symbols
== SDB_DEBUG
)
1808 debug_hooks
= &sdb_debug_hooks
;
1810 #ifdef DWARF2_DEBUGGING_INFO
1811 else if (write_symbols
== DWARF2_DEBUG
)
1812 debug_hooks
= &dwarf2_debug_hooks
;
1814 #ifdef VMS_DEBUGGING_INFO
1815 else if (write_symbols
== VMS_DEBUG
|| write_symbols
== VMS_AND_DWARF2_DEBUG
)
1816 debug_hooks
= &vmsdbg_debug_hooks
;
1819 error ("target system does not support the \"%s\" debug format",
1820 debug_type_names
[write_symbols
]);
1822 /* Now we know which debug output will be used so we can set
1823 flag_var_tracking, flag_rename_registers if the user has
1824 not specified them. */
1825 if (debug_info_level
< DINFO_LEVEL_NORMAL
1826 || debug_hooks
->var_location
== do_nothing_debug_hooks
.var_location
)
1828 if (flag_var_tracking
== 1
1829 || flag_var_tracking_uninit
== 1)
1831 if (debug_info_level
< DINFO_LEVEL_NORMAL
)
1832 warning (0, "variable tracking requested, but useless unless "
1833 "producing debug info");
1835 warning (0, "variable tracking requested, but not supported "
1836 "by this debug format");
1838 flag_var_tracking
= 0;
1839 flag_var_tracking_uninit
= 0;
1842 if (flag_rename_registers
== AUTODETECT_VALUE
)
1843 flag_rename_registers
= default_debug_hooks
->var_location
1844 != do_nothing_debug_hooks
.var_location
;
1846 if (flag_var_tracking
== AUTODETECT_VALUE
)
1847 flag_var_tracking
= optimize
>= 1;
1849 if (flag_tree_cselim
== AUTODETECT_VALUE
)
1850 #ifdef HAVE_conditional_move
1851 flag_tree_cselim
= 1;
1853 flag_tree_cselim
= 0;
1856 /* If the user specifically requested variable tracking with tagging
1857 uninitialized variables, we need to turn on variable tracking.
1858 (We already determined above that variable tracking is feasible.) */
1859 if (flag_var_tracking_uninit
)
1860 flag_var_tracking
= 1;
1862 /* If auxiliary info generation is desired, open the output file.
1863 This goes in the same directory as the source file--unlike
1864 all the other output files. */
1865 if (flag_gen_aux_info
)
1867 aux_info_file
= fopen (aux_info_file_name
, "w");
1868 if (aux_info_file
== 0)
1869 fatal_error ("can%'t open %s: %m", aux_info_file_name
);
1872 if (! targetm
.have_named_sections
)
1874 if (flag_function_sections
)
1876 warning (0, "-ffunction-sections not supported for this target");
1877 flag_function_sections
= 0;
1879 if (flag_data_sections
)
1881 warning (0, "-fdata-sections not supported for this target");
1882 flag_data_sections
= 0;
1886 if (flag_function_sections
&& profile_flag
)
1888 warning (0, "-ffunction-sections disabled; it makes profiling impossible");
1889 flag_function_sections
= 0;
1892 #ifndef HAVE_prefetch
1893 if (flag_prefetch_loop_arrays
)
1895 warning (0, "-fprefetch-loop-arrays not supported for this target");
1896 flag_prefetch_loop_arrays
= 0;
1899 if (flag_prefetch_loop_arrays
&& !HAVE_prefetch
)
1901 warning (0, "-fprefetch-loop-arrays not supported for this target (try -march switches)");
1902 flag_prefetch_loop_arrays
= 0;
1906 /* This combination of options isn't handled for i386 targets and doesn't
1907 make much sense anyway, so don't allow it. */
1908 if (flag_prefetch_loop_arrays
&& optimize_size
)
1910 warning (0, "-fprefetch-loop-arrays is not supported with -Os");
1911 flag_prefetch_loop_arrays
= 0;
1914 /* The presence of IEEE signaling NaNs, implies all math can trap. */
1915 if (flag_signaling_nans
)
1916 flag_trapping_math
= 1;
1918 /* We cannot reassociate if we want traps or signed zeros. Â */
1919 if (flag_associative_math
&& (flag_trapping_math
|| flag_signed_zeros
))
1921 warning (0, "-fassociative-math disabled; other options take precedence");
1922 flag_associative_math
= 0;
1925 /* With -fcx-limited-range, we do cheap and quick complex arithmetic. */
1926 if (flag_cx_limited_range
)
1927 flag_complex_method
= 0;
1929 /* With -fcx-fortran-rules, we do something in-between cheap and C99. */
1930 if (flag_cx_fortran_rules
)
1931 flag_complex_method
= 1;
1933 /* Targets must be able to place spill slots at lower addresses. If the
1934 target already uses a soft frame pointer, the transition is trivial. */
1935 if (!FRAME_GROWS_DOWNWARD
&& flag_stack_protect
)
1937 warning (0, "-fstack-protector not supported for this target");
1938 flag_stack_protect
= 0;
1940 if (!flag_stack_protect
)
1941 warn_stack_protect
= 0;
1943 /* ??? Unwind info is not correct around the CFG unless either a frame
1944 pointer is present or A_O_A is set. Fixing this requires rewriting
1945 unwind info generation to be aware of the CFG and propagating states
1947 if (flag_unwind_tables
&& !ACCUMULATE_OUTGOING_ARGS
1948 && flag_omit_frame_pointer
)
1950 warning (0, "unwind tables currently require a frame pointer "
1952 flag_omit_frame_pointer
= 0;
1956 /* This function can be called multiple times to reinitialize the compiler
1957 back end when register classes or instruction sets have changed,
1958 before each function. */
1960 backend_init_target (void)
1962 /* Initialize alignment variables. */
1965 /* This reinitializes hard_frame_pointer, and calls init_reg_modes_target()
1966 to initialize reg_raw_mode[]. */
1969 /* This invokes target hooks to set fixed_reg[] etc, which is
1973 /* This depends on stack_pointer_rtx. */
1974 init_fake_stack_mems ();
1976 /* Sets static_base_value[HARD_FRAME_POINTER_REGNUM], which is
1978 init_alias_target ();
1980 /* Depends on HARD_FRAME_POINTER_REGNUM. */
1983 /* The following initialization functions need to generate rtl, so
1984 provide a dummy function context for them. */
1985 init_dummy_function_start ();
1987 /* rtx_cost is mode-dependent, so cached values need to be recomputed
1988 on a mode change. */
1991 /* We may need to recompute regno_save_code[] and regno_restore_code[]
1992 after a mode change as well. */
1993 if (flag_caller_saves
)
1994 init_caller_save ();
1995 expand_dummy_function_end ();
1998 /* Initialize the compiler back end. This function is called only once,
1999 when starting the compiler. */
2003 init_emit_once (debug_info_level
== DINFO_LEVEL_NORMAL
2004 || debug_info_level
== DINFO_LEVEL_VERBOSE
2005 #ifdef VMS_DEBUGGING_INFO
2006 /* Enable line number info for traceback. */
2007 || debug_info_level
> DINFO_LEVEL_NONE
2009 || flag_test_coverage
);
2012 init_inline_once ();
2013 init_varasm_once ();
2014 save_register_info ();
2016 /* Initialize the target-specific back end pieces. */
2018 backend_init_target ();
2021 /* Initialize things that are both lang-dependent and target-dependent.
2022 This function can be called more than once if target parameters change. */
2024 lang_dependent_init_target (void)
2026 /* This creates various _DECL nodes, so needs to be called after the
2027 front end is initialized. It also depends on the HAVE_xxx macros
2028 generated from the target machine description. */
2031 /* The following initialization functions need to generate rtl, so
2032 provide a dummy function context for them. */
2033 init_dummy_function_start ();
2035 /* Do the target-specific parts of expr initialization. */
2036 init_expr_target ();
2038 /* Although the actions of these functions are language-independent,
2039 they use optabs, so we cannot call them from backend_init. */
2043 expand_dummy_function_end ();
2046 /* Language-dependent initialization. Returns nonzero on success. */
2048 lang_dependent_init (const char *name
)
2050 location_t save_loc
= input_location
;
2051 if (dump_base_name
== 0)
2052 dump_base_name
= name
&& name
[0] ? name
: "gccdump";
2054 /* Other front-end initialization. */
2055 input_location
= BUILTINS_LOCATION
;
2056 if (lang_hooks
.init () == 0)
2058 input_location
= save_loc
;
2060 init_asm_output (name
);
2062 /* This creates various _DECL nodes, so needs to be called after the
2063 front end is initialized. */
2066 /* Do the target-specific parts of the initialization. */
2067 lang_dependent_init_target ();
2069 /* If dbx symbol table desired, initialize writing it and output the
2070 predefined types. */
2071 timevar_push (TV_SYMOUT
);
2073 #if defined DWARF2_DEBUGGING_INFO || defined DWARF2_UNWIND_INFO
2074 if (dwarf2out_do_frame ())
2075 dwarf2out_frame_init ();
2078 /* Now we have the correct original filename, we can initialize
2080 (*debug_hooks
->init
) (name
);
2082 timevar_pop (TV_SYMOUT
);
2088 /* Reinitialize everything when target parameters, such as register usage,
2091 target_reinit (void)
2093 /* Reinitialize RTL backend. */
2094 backend_init_target ();
2096 /* Reinitialize lang-dependent parts. */
2097 lang_dependent_init_target ();
2101 dump_memory_report (bool final
)
2103 ggc_print_statistics ();
2104 stringpool_statistics ();
2105 dump_tree_statistics ();
2106 dump_rtx_statistics ();
2107 dump_varray_statistics ();
2108 dump_alloc_pool_statistics ();
2109 dump_bitmap_statistics ();
2110 dump_ggc_loc_statistics (final
);
2113 /* Clean up: close opened files, etc. */
2118 /* Close the dump files. */
2119 if (flag_gen_aux_info
)
2121 fclose (aux_info_file
);
2123 unlink (aux_info_file_name
);
2126 /* Close non-debugging input and output files. Take special care to note
2127 whether fclose returns an error, since the pages might still be on the
2128 buffer chain while the file is open. */
2132 if (ferror (asm_out_file
) != 0)
2133 fatal_error ("error writing to %s: %m", asm_file_name
);
2134 if (fclose (asm_out_file
) != 0)
2135 fatal_error ("error closing %s: %m", asm_file_name
);
2139 finish_optimization_passes ();
2144 dump_memory_report (true);
2146 /* Language-specific end of compilation actions. */
2147 lang_hooks
.finish ();
2150 /* Initialize the compiler, and compile the input file. */
2154 /* Initialize timing first. The C front ends read the main file in
2155 the post_options hook, and C++ does file timings. */
2156 if (time_report
|| !quiet_flag
|| flag_detailed_statistics
)
2158 timevar_start (TV_TOTAL
);
2162 /* Don't do any more if an error has already occurred. */
2165 /* This must be run always, because it is needed to compute the FP
2166 predefined macros, such as __LDBL_MAX__, for targets using non
2167 default FP formats. */
2168 init_adjust_machine_modes ();
2170 /* Set up the back-end if requested. */
2174 /* Language-dependent initialization. Returns true on success. */
2175 if (lang_dependent_init (main_input_filename
))
2181 /* Stop timing and print the times. */
2182 timevar_stop (TV_TOTAL
);
2183 timevar_print (stderr
);
2186 /* Entry point of cc1, cc1plus, jc1, f771, etc.
2187 Exit code is FATAL_EXIT_CODE if can't open files or if there were
2188 any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
2190 It is not safe to call this function more than once. */
2193 toplev_main (unsigned int argc
, const char **argv
)
2197 /* Initialization of GCC's environment, and diagnostics. */
2198 general_init (argv
[0]);
2200 /* Parse the options and do minimal processing; basically just
2201 enough to default flags appropriately. */
2202 decode_options (argc
, argv
);
2206 /* Exit early if we can (e.g. -help). */
2207 if (!exit_after_options
)
2210 if (warningcount
|| errorcount
)
2211 print_ignored_options ();
2213 if (errorcount
|| sorrycount
)
2214 return (FATAL_EXIT_CODE
);
2216 return (SUCCESS_EXIT_CODE
);