toplev.c revision 72566
1/* Top level of GNU C compiler 2 Copyright (C) 1987, 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 3 1999, 2000, 2001 Free Software Foundation, Inc. 4 5This file is part of GNU CC. 6 7GNU CC is free software; you can redistribute it and/or modify 8it under the terms of the GNU General Public License as published by 9the Free Software Foundation; either version 2, or (at your option) 10any later version. 11 12GNU CC is distributed in the hope that it will be useful, 13but WITHOUT ANY WARRANTY; without even the implied warranty of 14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15GNU General Public License for more details. 16 17You should have received a copy of the GNU General Public License 18along with GNU CC; see the file COPYING. If not, write to 19the Free Software Foundation, 59 Temple Place - Suite 330, 20Boston, MA 02111-1307, USA. */ 21 22/* $FreeBSD: head/contrib/gcc/toplev.c 72566 2001-02-17 09:06:31Z obrien $ */ 23 24/* This is the top level of cc1/c++. 25 It parses command args, opens files, invokes the various passes 26 in the proper order, and counts the time used by each. 27 Error messages and low-level interface to malloc also handled here. */ 28 29#include "config.h" 30#undef FLOAT /* This is for hpux. They should change hpux. */ 31#undef FFS /* Some systems define this in param.h. */ 32#include "system.h" 33#include <signal.h> 34#include <setjmp.h> 35 36#ifdef HAVE_SYS_RESOURCE_H 37# include <sys/resource.h> 38#endif 39 40#ifdef HAVE_SYS_TIMES_H 41# include <sys/times.h> 42#endif 43 44#include "input.h" 45#include "tree.h" 46#include "rtl.h" 47#include "flags.h" 48#include "insn-attr.h" 49#include "insn-codes.h" 50#include "insn-config.h" 51#include "recog.h" 52#include "defaults.h" 53#include "output.h" 54#include "except.h" 55#include "toplev.h" 56#include "expr.h" 57#include "basic-block.h" 58#include "intl.h" 59 60#ifdef DWARF_DEBUGGING_INFO 61#include "dwarfout.h" 62#endif 63 64#if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO) 65#include "dwarf2out.h" 66#endif 67 68#if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) 69#include "dbxout.h" 70#endif 71 72#ifdef SDB_DEBUGGING_INFO 73#include "sdbout.h" 74#endif 75 76#ifdef XCOFF_DEBUGGING_INFO 77#include "xcoffout.h" 78#endif 79 80#ifdef VMS 81/* The extra parameters substantially improve the I/O performance. */ 82static FILE * 83vms_fopen (fname, type) 84 char * fname; 85 char * type; 86{ 87 /* The <stdio.h> in the gcc-vms-1.42 distribution prototypes fopen with two 88 fixed arguments, which matches ANSI's specification but not VAXCRTL's 89 pre-ANSI implementation. This hack circumvents the mismatch problem. */ 90 FILE *(*vmslib_fopen)() = (FILE *(*)()) fopen; 91 92 if (*type == 'w') 93 return (*vmslib_fopen) (fname, type, "mbc=32", 94 "deq=64", "fop=tef", "shr=nil"); 95 else 96 return (*vmslib_fopen) (fname, type, "mbc=32"); 97} 98#define fopen vms_fopen 99#endif /* VMS */ 100 101#ifndef DEFAULT_GDB_EXTENSIONS 102#define DEFAULT_GDB_EXTENSIONS 1 103#endif 104 105/* If more than one debugging type is supported, you must define 106 PREFERRED_DEBUGGING_TYPE to choose a format in a system-dependent way. 107 108 This is one long line cause VAXC can't handle a \-newline. */ 109#if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (DWARF2_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO)) 110#ifndef PREFERRED_DEBUGGING_TYPE 111You Lose! You must define PREFERRED_DEBUGGING_TYPE! 112#endif /* no PREFERRED_DEBUGGING_TYPE */ 113#else /* Only one debugging format supported. Define PREFERRED_DEBUGGING_TYPE 114 so the following code needn't care. */ 115#ifdef DBX_DEBUGGING_INFO 116#define PREFERRED_DEBUGGING_TYPE DBX_DEBUG 117#endif 118#ifdef SDB_DEBUGGING_INFO 119#define PREFERRED_DEBUGGING_TYPE SDB_DEBUG 120#endif 121#ifdef DWARF_DEBUGGING_INFO 122#define PREFERRED_DEBUGGING_TYPE DWARF_DEBUG 123#endif 124#ifdef DWARF2_DEBUGGING_INFO 125#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG 126#endif 127#ifdef XCOFF_DEBUGGING_INFO 128#define PREFERRED_DEBUGGING_TYPE XCOFF_DEBUG 129#endif 130#endif /* More than one debugger format enabled. */ 131 132/* If still not defined, must have been because no debugging formats 133 are supported. */ 134#ifndef PREFERRED_DEBUGGING_TYPE 135#define PREFERRED_DEBUGGING_TYPE NO_DEBUG 136#endif 137 138#ifndef DIR_SEPARATOR 139#define DIR_SEPARATOR '/' 140#endif 141 142extern int rtx_equal_function_value_matters; 143 144#if ! (defined (VMS) || defined (OS2)) 145extern char **environ; 146#endif 147extern char *version_string, *language_string; 148 149/* Carry information from ASM_DECLARE_OBJECT_NAME 150 to ASM_FINISH_DECLARE_OBJECT. */ 151 152extern int size_directive_output; 153extern tree last_assemble_variable_decl; 154 155extern char *init_parse PVPROTO((char *)); 156extern void finish_parse (); 157extern void init_decl_processing (); 158extern void init_obstacks (); 159extern void init_tree_codes (); 160extern void init_rtl (); 161extern void init_regs (); 162extern void init_optabs (); 163extern void init_stmt (); 164extern void init_reg_sets (); 165extern void dump_flow_info (); 166extern void dump_sched_info (); 167extern void dump_local_alloc (); 168extern void regset_release_memory (); 169 170extern void print_rtl (); 171extern void print_rtl_with_bb (); 172 173void rest_of_decl_compilation (); 174void error_with_file_and_line PVPROTO((const char *file, 175 int line, const char *s, ...)); 176void error_with_decl PVPROTO((tree decl, const char *s, ...)); 177void error_for_asm PVPROTO((rtx insn, const char *s, ...)); 178void notice PVPROTO((const char *s, ...)); 179void error PVPROTO((const char *s, ...)); 180void fatal PVPROTO((const char *s, ...)); 181void warning_with_file_and_line PVPROTO((const char *file, 182 int line, const char *s, ...)); 183void warning_with_decl PVPROTO((tree decl, const char *s, ...)); 184void warning PVPROTO((const char *s, ...)); 185void pedwarn PVPROTO((const char *s, ...)); 186void pedwarn_with_decl PVPROTO((tree decl, const char *s, ...)); 187void pedwarn_with_file_and_line PVPROTO((const char *file, 188 int line, const char *s, ...)); 189void sorry PVPROTO((const char *s, ...)); 190static void set_target_switch PROTO((const char *)); 191static char *decl_name PROTO((tree, int)); 192static void vmessage PROTO((const char *, const char *, va_list)); 193static void v_message_with_file_and_line PROTO((const char *, int, int, 194 const char *, va_list)); 195static void v_message_with_decl PROTO((tree, int, const char *, va_list)); 196static void file_and_line_for_asm PROTO((rtx, char **, int *)); 197static void v_error_with_file_and_line PROTO((const char *, int, 198 const char *, va_list)); 199static void v_error_with_decl PROTO((tree, const char *, va_list)); 200static void v_error_for_asm PROTO((rtx, const char *, va_list)); 201static void verror PROTO((const char *, va_list)); 202static void vfatal PROTO((const char *, va_list)) ATTRIBUTE_NORETURN; 203static void v_warning_with_file_and_line PROTO ((const char *, int, 204 const char *, va_list)); 205static void v_warning_with_decl PROTO((tree, const char *, va_list)); 206static void v_warning_for_asm PROTO((rtx, const char *, va_list)); 207static void vwarning PROTO((const char *, va_list)); 208static void vpedwarn PROTO((const char *, va_list)); 209static void v_pedwarn_with_decl PROTO((tree, const char *, va_list)); 210static void v_pedwarn_with_file_and_line PROTO((const char *, int, 211 const char *, va_list)); 212static void vsorry PROTO((const char *, va_list)); 213static void float_signal PROTO((int)) ATTRIBUTE_NORETURN; 214static void pipe_closed PROTO((int)) ATTRIBUTE_NORETURN; 215#ifdef ASM_IDENTIFY_LANGUAGE 216/* This might or might not be used in ASM_IDENTIFY_LANGUAGE. */ 217static void output_lang_identify PROTO((FILE *)) ATTRIBUTE_UNUSED; 218#endif 219static void open_dump_file PROTO((const char *, const char *)); 220static void close_dump_file PROTO((void (*) (FILE *, rtx), rtx)); 221static void dump_rtl PROTO((const char *, tree, void (*) (FILE *, rtx), rtx)); 222static void clean_dump_file PROTO((const char *)); 223static void compile_file PROTO((char *)); 224static void display_help PROTO ((void)); 225 226static void print_version PROTO((FILE *, const char *)); 227static int print_single_switch PROTO((FILE *, int, int, const char *, 228 const char *, const char *, 229 const char *, const char *)); 230static void print_switch_values PROTO((FILE *, int, int, const char *, 231 const char *, const char *)); 232 233void print_rtl_graph_with_bb PROTO ((const char *, const char *, rtx)); 234void clean_graph_dump_file PROTO ((const char *, const char *)); 235void finish_graph_dump_file PROTO ((const char *, const char *)); 236/* Length of line when printing switch values. */ 237#define MAX_LINE 75 238 239/* Name of program invoked, sans directories. */ 240 241char *progname; 242 243/* Copy of arguments to main. */ 244int save_argc; 245char **save_argv; 246 247/* Name of current original source file (what was input to cpp). 248 This comes from each #-command in the actual input. */ 249 250char *input_filename; 251 252/* Name of top-level original source file (what was input to cpp). 253 This comes from the #-command at the beginning of the actual input. 254 If there isn't any there, then this is the cc1 input file name. */ 255 256char *main_input_filename; 257 258/* Current line number in real source file. */ 259 260int lineno; 261 262/* Nonzero if it is unsafe to create any new pseudo registers. */ 263int no_new_pseudos; 264 265/* Stack of currently pending input files. */ 266 267struct file_stack *input_file_stack; 268 269/* Incremented on each change to input_file_stack. */ 270int input_file_stack_tick; 271 272/* FUNCTION_DECL for function now being parsed or compiled. */ 273 274extern tree current_function_decl; 275 276/* Name to use as base of names for dump output files. */ 277 278const char *dump_base_name; 279 280/* Bit flags that specify the machine subtype we are compiling for. 281 Bits are tested using macros TARGET_... defined in the tm.h file 282 and set by `-m...' switches. Must be defined in rtlanal.c. */ 283 284extern int target_flags; 285 286/* Flags saying which kinds of debugging dump have been requested. */ 287 288int rtl_dump = 0; 289int rtl_dump_and_exit = 0; 290int jump_opt_dump = 0; 291int addressof_dump = 0; 292int cse_dump = 0; 293int gcse_dump = 0; 294int loop_dump = 0; 295int cse2_dump = 0; 296int branch_prob_dump = 0; 297int flow_dump = 0; 298int combine_dump = 0; 299int regmove_dump = 0; 300int sched_dump = 0; 301int local_reg_dump = 0; 302int global_reg_dump = 0; 303int flow2_dump = 0; 304int sched2_dump = 0; 305int jump2_opt_dump = 0; 306#ifdef DELAY_SLOTS 307int dbr_sched_dump = 0; 308#endif 309int flag_print_asm_name = 0; 310#ifdef STACK_REGS 311int stack_reg_dump = 0; 312#endif 313#ifdef MACHINE_DEPENDENT_REORG 314int mach_dep_reorg_dump = 0; 315#endif 316enum graph_dump_types graph_dump_format; 317 318/* Name for output file of assembly code, specified with -o. */ 319 320char *asm_file_name; 321 322/* Value of the -G xx switch, and whether it was passed or not. */ 323int g_switch_value; 324int g_switch_set; 325 326/* Type(s) of debugging information we are producing (if any). 327 See flags.h for the definitions of the different possible 328 types of debugging information. */ 329enum debug_info_type write_symbols = NO_DEBUG; 330 331/* Level of debugging information we are producing. See flags.h 332 for the definitions of the different possible levels. */ 333enum debug_info_level debug_info_level = DINFO_LEVEL_NONE; 334 335/* Nonzero means use GNU-only extensions in the generated symbolic 336 debugging information. */ 337/* Currently, this only has an effect when write_symbols is set to 338 DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */ 339int use_gnu_debug_info_extensions = 0; 340 341/* Nonzero means do optimizations. -O. 342 Particular numeric values stand for particular amounts of optimization; 343 thus, -O2 stores 2 here. However, the optimizations beyond the basic 344 ones are not controlled directly by this variable. Instead, they are 345 controlled by individual `flag_...' variables that are defaulted 346 based on this variable. */ 347 348int optimize = 0; 349 350/* Nonzero means optimize for size. -Os. 351 The only valid values are zero and non-zero. When optimize_size is 352 non-zero, optimize defaults to 2, but certain individual code 353 bloating optimizations are disabled. */ 354 355int optimize_size = 0; 356 357/* Number of error messages and warning messages so far. */ 358 359int errorcount = 0; 360int warningcount = 0; 361int sorrycount = 0; 362 363/* Pointer to function to compute the name to use to print a declaration. 364 DECL is the declaration in question. 365 VERBOSITY determines what information will be printed: 366 0: DECL_NAME, demangled as necessary. 367 1: and scope information. 368 2: and any other information that might be interesting, such as function 369 parameter types in C++. */ 370 371char *(*decl_printable_name) PROTO ((tree, int)); 372 373/* Pointer to function to compute rtl for a language-specific tree code. */ 374 375typedef rtx (*lang_expand_expr_t) 376 PROTO ((union tree_node *, rtx, enum machine_mode, 377 enum expand_modifier modifier)); 378 379lang_expand_expr_t lang_expand_expr = 0; 380 381tree (*lang_expand_constant) PROTO((tree)) = 0; 382 383/* Pointer to function to finish handling an incomplete decl at the 384 end of compilation. */ 385 386void (*incomplete_decl_finalize_hook) PROTO((tree)) = 0; 387 388/* Nonzero if generating code to do profiling. */ 389 390int profile_flag = 0; 391 392/* Nonzero if generating code to do profiling on a line-by-line basis. */ 393 394int profile_block_flag; 395 396/* Nonzero if generating code to profile program flow graph arcs. */ 397 398int profile_arc_flag = 0; 399 400/* Nonzero if generating info for gcov to calculate line test coverage. */ 401 402int flag_test_coverage = 0; 403 404/* Nonzero indicates that branch taken probabilities should be calculated. */ 405 406int flag_branch_probabilities = 0; 407 408/* Nonzero for -pedantic switch: warn about anything 409 that standard spec forbids. */ 410 411int pedantic = 0; 412 413/* Temporarily suppress certain warnings. 414 This is set while reading code from a system header file. */ 415 416int in_system_header = 0; 417 418/* Nonzero means do stupid register allocation. 419 Currently, this is 1 if `optimize' is 0. */ 420 421int obey_regdecls = 0; 422 423/* Don't print functions as they are compiled and don't print 424 times taken by the various passes. -quiet. */ 425 426int quiet_flag = 0; 427 428/* -f flags. */ 429 430/* Nonzero means `char' should be signed. */ 431 432int flag_signed_char; 433 434/* Nonzero means give an enum type only as many bytes as it needs. */ 435 436int flag_short_enums; 437 438/* Nonzero for -fcaller-saves: allocate values in regs that need to 439 be saved across function calls, if that produces overall better code. 440 Optional now, so people can test it. */ 441 442#ifdef DEFAULT_CALLER_SAVES 443int flag_caller_saves = 1; 444#else 445int flag_caller_saves = 0; 446#endif 447 448/* Nonzero if structures and unions should be returned in memory. 449 450 This should only be defined if compatibility with another compiler or 451 with an ABI is needed, because it results in slower code. */ 452 453#ifndef DEFAULT_PCC_STRUCT_RETURN 454#define DEFAULT_PCC_STRUCT_RETURN 1 455#endif 456 457/* Nonzero for -fpcc-struct-return: return values the same way PCC does. */ 458 459int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN; 460 461/* Nonzero for -fforce-mem: load memory value into a register 462 before arithmetic on it. This makes better cse but slower compilation. */ 463 464int flag_force_mem = 0; 465 466/* Nonzero for -fforce-addr: load memory address into a register before 467 reference to memory. This makes better cse but slower compilation. */ 468 469int flag_force_addr = 0; 470 471/* Nonzero for -fdefer-pop: don't pop args after each function call; 472 instead save them up to pop many calls' args with one insns. */ 473 474int flag_defer_pop = 0; 475 476/* Nonzero for -ffloat-store: don't allocate floats and doubles 477 in extended-precision registers. */ 478 479int flag_float_store = 0; 480 481/* Nonzero for -fcse-follow-jumps: 482 have cse follow jumps to do a more extensive job. */ 483 484int flag_cse_follow_jumps; 485 486/* Nonzero for -fcse-skip-blocks: 487 have cse follow a branch around a block. */ 488int flag_cse_skip_blocks; 489 490/* Nonzero for -fexpensive-optimizations: 491 perform miscellaneous relatively-expensive optimizations. */ 492int flag_expensive_optimizations; 493 494/* Nonzero for -fthread-jumps: 495 have jump optimize output of loop. */ 496 497int flag_thread_jumps; 498 499/* Nonzero enables strength-reduction in loop.c. */ 500 501int flag_strength_reduce = 0; 502 503/* Nonzero enables loop unrolling in unroll.c. Only loops for which the 504 number of iterations can be calculated at compile-time (UNROLL_COMPLETELY, 505 UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are 506 unrolled. */ 507 508int flag_unroll_loops; 509 510/* Nonzero enables loop unrolling in unroll.c. All loops are unrolled. 511 This is generally not a win. */ 512 513int flag_unroll_all_loops; 514 515/* Nonzero forces all invariant computations in loops to be moved 516 outside the loop. */ 517 518int flag_move_all_movables = 0; 519 520/* Nonzero forces all general induction variables in loops to be 521 strength reduced. */ 522 523int flag_reduce_all_givs = 0; 524 525/* Nonzero to perform full register move optimization passes. This is the 526 default for -O2. */ 527 528int flag_regmove = 0; 529 530/* Nonzero for -fwritable-strings: 531 store string constants in data segment and don't uniquize them. */ 532 533int flag_writable_strings = 0; 534 535/* Nonzero means don't put addresses of constant functions in registers. 536 Used for compiling the Unix kernel, where strange substitutions are 537 done on the assembly output. */ 538 539int flag_no_function_cse = 0; 540 541/* Nonzero for -fomit-frame-pointer: 542 don't make a frame pointer in simple functions that don't require one. */ 543 544int flag_omit_frame_pointer = 0; 545 546/* Nonzero means place each function into its own section on those platforms 547 which support arbitrary section names and unlimited numbers of sections. */ 548 549int flag_function_sections = 0; 550 551/* ... and similar for data. */ 552 553int flag_data_sections = 0; 554 555/* Nonzero to inhibit use of define_optimization peephole opts. */ 556 557int flag_no_peephole = 0; 558 559/* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math 560 operations in the interest of optimization. For example it allows 561 GCC to assume arguments to sqrt are nonnegative numbers, allowing 562 faster code for sqrt to be generated. */ 563 564int flag_fast_math = 0; 565 566/* Nonzero means the front end generally wants `errno' maintained by math 567 operations, like built-in SQRT, unless overridden by flag_fast_math. */ 568 569int flag_errno_math = 1; 570 571/* 0 means straightforward implementation of complex divide acceptable. 572 1 means wide ranges of inputs must work for complex divide. 573 2 means C9X-like requirements for complex divide (not yet implemented). */ 574 575int flag_complex_divide_method = 0; 576 577/* Nonzero means all references through pointers are volatile. */ 578 579int flag_volatile; 580 581/* Nonzero means treat all global and extern variables as volatile. */ 582 583int flag_volatile_global; 584 585/* Nonzero means treat all static variables as volatile. */ 586 587int flag_volatile_static; 588 589/* Nonzero means just do syntax checking; don't output anything. */ 590 591int flag_syntax_only = 0; 592 593/* Nonzero means perform global cse. */ 594 595static int flag_gcse; 596 597/* Nonzero means to rerun cse after loop optimization. This increases 598 compilation time about 20% and picks up a few more common expressions. */ 599 600static int flag_rerun_cse_after_loop; 601 602/* Nonzero means to run loop optimizations twice. */ 603 604int flag_rerun_loop_opt; 605 606/* Nonzero for -finline-functions: ok to inline functions that look like 607 good inline candidates. */ 608 609int flag_inline_functions; 610 611/* Nonzero for -fkeep-inline-functions: even if we make a function 612 go inline everywhere, keep its definition around for debugging 613 purposes. */ 614 615int flag_keep_inline_functions; 616 617/* Nonzero means that functions will not be inlined. */ 618 619int flag_no_inline; 620 621/* Nonzero means that we should emit static const variables 622 regardless of whether or not optimization is turned on. */ 623 624int flag_keep_static_consts = 1; 625 626/* Nonzero means we should be saving declaration info into a .X file. */ 627 628int flag_gen_aux_info = 0; 629 630/* Specified name of aux-info file. */ 631 632static char *aux_info_file_name; 633 634/* Nonzero means make the text shared if supported. */ 635 636int flag_shared_data; 637 638/* Nonzero means schedule into delayed branch slots if supported. */ 639 640int flag_delayed_branch; 641 642/* Nonzero if we are compiling pure (sharable) code. 643 Value is 1 if we are doing reasonable (i.e. simple 644 offset into offset table) pic. Value is 2 if we can 645 only perform register offsets. */ 646 647int flag_pic; 648 649/* Nonzero means generate extra code for exception handling and enable 650 exception handling. */ 651 652int flag_exceptions; 653 654/* Nonzero means use the new model for exception handling. Replaces 655 -DNEW_EH_MODEL as a compile option. */ 656 657int flag_new_exceptions = 0; 658 659/* Nonzero means don't place uninitialized global data in common storage 660 by default. */ 661 662int flag_no_common; 663 664/* Nonzero means pretend it is OK to examine bits of target floats, 665 even if that isn't true. The resulting code will have incorrect constants, 666 but the same series of instructions that the native compiler would make. */ 667 668int flag_pretend_float; 669 670/* Nonzero means change certain warnings into errors. 671 Usually these are warnings about failure to conform to some standard. */ 672 673int flag_pedantic_errors = 0; 674 675/* flag_schedule_insns means schedule insns within basic blocks (before 676 local_alloc). 677 flag_schedule_insns_after_reload means schedule insns after 678 global_alloc. */ 679 680int flag_schedule_insns = 0; 681int flag_schedule_insns_after_reload = 0; 682 683#ifdef HAIFA 684/* The following flags have effect only for scheduling before register 685 allocation: 686 687 flag_schedule_interblock means schedule insns accross basic blocks. 688 flag_schedule_speculative means allow speculative motion of non-load insns. 689 flag_schedule_speculative_load means allow speculative motion of some 690 load insns. 691 flag_schedule_speculative_load_dangerous allows speculative motion of more 692 load insns. */ 693 694int flag_schedule_interblock = 1; 695int flag_schedule_speculative = 1; 696int flag_schedule_speculative_load = 0; 697int flag_schedule_speculative_load_dangerous = 0; 698#endif /* HAIFA */ 699 700/* flag_on_branch_count_reg means try to replace add-1,compare,branch tupple 701 by a cheaper branch, on a count register. */ 702int flag_branch_on_count_reg; 703 704/* -finhibit-size-directive inhibits output of .size for ELF. 705 This is used only for compiling crtstuff.c, 706 and it may be extended to other effects 707 needed for crtstuff.c on other systems. */ 708int flag_inhibit_size_directive = 0; 709 710/* -fverbose-asm causes extra commentary information to be produced in 711 the generated assembly code (to make it more readable). This option 712 is generally only of use to those who actually need to read the 713 generated assembly code (perhaps while debugging the compiler itself). 714 -fno-verbose-asm, the default, causes the extra information 715 to be omitted and is useful when comparing two assembler files. */ 716 717int flag_verbose_asm = 0; 718 719/* -dA causes debug commentary information to be produced in 720 the generated assembly code (to make it more readable). This option 721 is generally only of use to those who actually need to read the 722 generated assembly code (perhaps while debugging the compiler itself). 723 Currently, this switch is only used by dwarfout.c; however, it is intended 724 to be a catchall for printing debug information in the assembler file. */ 725 726int flag_debug_asm = 0; 727 728/* -fgnu-linker specifies use of the GNU linker for initializations. 729 (Or, more generally, a linker that handles initializations.) 730 -fno-gnu-linker says that collect2 will be used. */ 731#ifdef USE_COLLECT2 732int flag_gnu_linker = 0; 733#else 734int flag_gnu_linker = 1; 735#endif 736 737/* Tag all structures with __attribute__(packed) */ 738int flag_pack_struct = 0; 739 740/* Nonzero means that -Wformat accepts certain system-dependent formats. */ 741int flag_format_extensions = 0; 742 743/* Emit code to check for stack overflow; also may cause large objects 744 to be allocated dynamically. */ 745int flag_stack_check; 746 747/* -fcheck-memory-usage causes extra code to be generated in order to check 748 memory accesses. This is used by a detector of bad memory accesses such 749 as Checker. */ 750int flag_check_memory_usage = 0; 751 752/* -fprefix-function-name causes function name to be prefixed. This 753 can be used with -fcheck-memory-usage to isolate code compiled with 754 -fcheck-memory-usage. */ 755int flag_prefix_function_name = 0; 756 757/* 0 if pointer arguments may alias each other. True in C. 758 1 if pointer arguments may not alias each other but may alias 759 global variables. 760 2 if pointer arguments may not alias each other and may not 761 alias global variables. True in Fortran. 762 This defaults to 0 for C. */ 763int flag_argument_noalias = 0; 764 765/* Nonzero if we should do (language-dependent) alias analysis. 766 Typically, this analysis will assume that expressions of certain 767 types do not alias expressions of certain other types. Only used 768 if alias analysis (in general) is enabled. */ 769int flag_strict_aliasing = 0; 770 771/* Instrument functions with calls at entry and exit, for profiling. */ 772int flag_instrument_function_entry_exit = 0; 773 774/* Nonzero means ignore `#ident' directives. 0 means handle them. 775 On SVR4 targets, it also controls whether or not to emit a 776 string identifying the compiler. */ 777 778int flag_no_ident = 0; 779 780/* Table of supported debugging formats. */ 781static struct 782{ 783 const char * arg; 784 /* Since PREFERRED_DEBUGGING_TYPE isn't necessarily a 785 constant expression, we use NO_DEBUG in its place. */ 786 enum debug_info_type debug_type; 787 int use_extensions_p; 788 const char * description; 789} *da, 790debug_args[] = 791{ 792 { "g", NO_DEBUG, DEFAULT_GDB_EXTENSIONS, 793 "Generate default debug format output" }, 794 { "ggdb", NO_DEBUG, 1, "Generate default extended debug format output" }, 795#ifdef DBX_DEBUGGING_INFO 796 { "gstabs", DBX_DEBUG, 0, "Generate STABS format debug output" }, 797 { "gstabs+", DBX_DEBUG, 1, "Generate extended STABS format debug output" }, 798#endif 799#ifdef DWARF_DEBUGGING_INFO 800 { "gdwarf", DWARF_DEBUG, 0, "Generate DWARF-1 format debug output"}, 801 { "gdwarf+", DWARF_DEBUG, 1, 802 "Generated extended DWARF-1 format debug output" }, 803#endif 804#ifdef DWARF2_DEBUGGING_INFO 805 { "gdwarf-2", DWARF2_DEBUG, 0, "Enable DWARF-2 debug output" }, 806#endif 807#ifdef XCOFF_DEBUGGING_INFO 808 { "gxcoff", XCOFF_DEBUG, 0, "Generate XCOFF format debug output" }, 809 { "gxcoff+", XCOFF_DEBUG, 1, "Generate extended XCOFF format debug output" }, 810#endif 811#ifdef SDB_DEBUGGING_INFO 812 { "gcoff", SDB_DEBUG, 0, "Generate COFF format debug output" }, 813#endif 814 { 0, 0, 0, 0 } 815}; 816 817typedef struct 818{ 819 const char * string; 820 int * variable; 821 int on_value; 822 const char * description; 823} 824lang_independent_options; 825 826/* Add or remove a leading underscore from user symbols. */ 827int flag_leading_underscore = -1; 828 829/* The user symbol prefix after having resolved same. */ 830const char *user_label_prefix; 831 832/* A default for same. */ 833#ifndef USER_LABEL_PREFIX 834#define USER_LABEL_PREFIX "" 835#endif 836 837/* Table of language-independent -f options. 838 STRING is the option name. VARIABLE is the address of the variable. 839 ON_VALUE is the value to store in VARIABLE 840 if `-fSTRING' is seen as an option. 841 (If `-fno-STRING' is seen as an option, the opposite value is stored.) */ 842 843lang_independent_options f_options[] = 844{ 845 {"float-store", &flag_float_store, 1, 846 "Do not store floats in registers" }, 847 {"volatile", &flag_volatile, 1, 848 "Consider all mem refs through pointers as volatile"}, 849 {"volatile-global", &flag_volatile_global, 1, 850 "Consider all mem refs to global data to be volatile" }, 851 {"volatile-static", &flag_volatile_static, 1, 852 "Consider all mem refs to static data to be volatile" }, 853 {"defer-pop", &flag_defer_pop, 1, 854 "Defer popping functions args from stack until later" }, 855 {"omit-frame-pointer", &flag_omit_frame_pointer, 1, 856 "When possible do not generate stack frames"}, 857 {"cse-follow-jumps", &flag_cse_follow_jumps, 1, 858 "When running CSE, follow jumps to their targets" }, 859 {"cse-skip-blocks", &flag_cse_skip_blocks, 1, 860 "When running CSE, follow conditional jumps" }, 861 {"expensive-optimizations", &flag_expensive_optimizations, 1, 862 "Perform a number of minor, expensive optimisations" }, 863 {"thread-jumps", &flag_thread_jumps, 1, 864 "Perform jump threading optimisations"}, 865 {"strength-reduce", &flag_strength_reduce, 1, 866 "Perform strength reduction optimisations" }, 867 {"unroll-loops", &flag_unroll_loops, 1, 868 "Perform loop unrolling when iteration count is known" }, 869 {"unroll-all-loops", &flag_unroll_all_loops, 1, 870 "Perform loop unrolling for all loops" }, 871 {"move-all-movables", &flag_move_all_movables, 1, 872 "Force all loop invariant computations out of loops" }, 873 {"reduce-all-givs", &flag_reduce_all_givs, 1, 874 "Strength reduce all loop general induction variables" }, 875 {"writable-strings", &flag_writable_strings, 1, 876 "Store strings in writable data section" }, 877 {"peephole", &flag_no_peephole, 0, 878 "Enable machine specific peephole optimisations" }, 879 {"force-mem", &flag_force_mem, 1, 880 "Copy memory operands into registers before using" }, 881 {"force-addr", &flag_force_addr, 1, 882 "Copy memory address constants into regs before using" }, 883 {"function-cse", &flag_no_function_cse, 0, 884 "Allow function addresses to be held in registers" }, 885 {"inline-functions", &flag_inline_functions, 1, 886 "Integrate simple functions into their callers" }, 887 {"keep-inline-functions", &flag_keep_inline_functions, 1, 888 "Generate code for funcs even if they are fully inlined" }, 889 {"inline", &flag_no_inline, 0, 890 "Pay attention to the 'inline' keyword"}, 891 {"keep-static-consts", &flag_keep_static_consts, 1, 892 "Emit static const variables even if they are not used" }, 893 {"syntax-only", &flag_syntax_only, 1, 894 "Check for syntax errors, then stop" }, 895 {"shared-data", &flag_shared_data, 1, 896 "Mark data as shared rather than private" }, 897 {"caller-saves", &flag_caller_saves, 1, 898 "Enable saving registers around function calls" }, 899 {"pcc-struct-return", &flag_pcc_struct_return, 1, 900 "Return 'short' aggregates in memory, not registers" }, 901 {"reg-struct-return", &flag_pcc_struct_return, 0, 902 "Return 'short' aggregates in registers" }, 903 {"delayed-branch", &flag_delayed_branch, 1, 904 "Attempt to fill delay slots of branch instructions" }, 905 {"gcse", &flag_gcse, 1, 906 "Perform the global common subexpression elimination" }, 907 {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1, 908 "Run CSE pass after loop optimisations"}, 909 {"rerun-loop-opt", &flag_rerun_loop_opt, 1, 910 "Run the loop optimiser twice"}, 911 {"pretend-float", &flag_pretend_float, 1, 912 "Pretend that host and target use the same FP format"}, 913 {"schedule-insns", &flag_schedule_insns, 1, 914 "Reschedule instructions to avoid pipeline stalls"}, 915 {"schedule-insns2", &flag_schedule_insns_after_reload, 1, 916 "Run two passes of the instruction scheduler"}, 917#ifdef HAIFA 918 {"sched-interblock",&flag_schedule_interblock, 1, 919 "Enable scheduling across basic blocks" }, 920 {"sched-spec",&flag_schedule_speculative, 1, 921 "Allow speculative motion of non-loads" }, 922 {"sched-spec-load",&flag_schedule_speculative_load, 1, 923 "Allow speculative motion of some loads" }, 924 {"sched-spec-load-dangerous",&flag_schedule_speculative_load_dangerous, 1, 925 "Allow speculative motion of more loads" }, 926#endif /* HAIFA */ 927 {"branch-count-reg",&flag_branch_on_count_reg, 1, 928 "Replace add,compare,branch with branch on count reg"}, 929 {"pic", &flag_pic, 1, 930 "Generate position independent code, if possible"}, 931 {"PIC", &flag_pic, 2, ""}, 932 {"exceptions", &flag_exceptions, 1, 933 "Enable exception handling" }, 934 {"new-exceptions", &flag_new_exceptions, 1, 935 "Use the new model for exception handling" }, 936 {"sjlj-exceptions", &exceptions_via_longjmp, 1, 937 "Use setjmp/longjmp to handle exceptions" }, 938 {"asynchronous-exceptions", &asynchronous_exceptions, 1, 939 "Support asynchronous exceptions" }, 940 {"profile-arcs", &profile_arc_flag, 1, 941 "Insert arc based program profiling code" }, 942 {"test-coverage", &flag_test_coverage, 1, 943 "Create data files needed by gcov" }, 944 {"branch-probabilities", &flag_branch_probabilities, 1, 945 "Use profiling information for branch probabilities" }, 946 {"fast-math", &flag_fast_math, 1, 947 "Improve FP speed by violating ANSI & IEEE rules" }, 948 {"common", &flag_no_common, 0, 949 "Do not put unitialised globals in the common section" }, 950 {"inhibit-size-directive", &flag_inhibit_size_directive, 1, 951 "Do not generate .size directives" }, 952 {"function-sections", &flag_function_sections, 1, 953 "place each function into its own section" }, 954 {"data-sections", &flag_data_sections, 1, 955 "place data items into their own section" }, 956 {"verbose-asm", &flag_verbose_asm, 1, 957 "Add extra commentry to assembler output"}, 958 {"gnu-linker", &flag_gnu_linker, 1, 959 "Output GNU ld formatted global initialisers"}, 960 {"regmove", &flag_regmove, 1, 961 "Enables a register move optimisation"}, 962 {"optimize-register-move", &flag_regmove, 1, 963 "Do the full regmove optimization pass"}, 964 {"pack-struct", &flag_pack_struct, 1, 965 "Pack structure members together without holes" }, 966 {"format-extensions", &flag_format_extensions, 1, 967 "-Wformat accepts certain FreeBSD system-dependent formats" }, 968 {"stack-check", &flag_stack_check, 1, 969 "Insert stack checking code into the program" }, 970 {"argument-alias", &flag_argument_noalias, 0, 971 "Specify that arguments may alias each other & globals"}, 972 {"argument-noalias", &flag_argument_noalias, 1, 973 "Assume arguments may alias globals but not each other"}, 974 {"argument-noalias-global", &flag_argument_noalias, 2, 975 "Assume arguments do not alias each other or globals" }, 976 {"strict-aliasing", &flag_strict_aliasing, 1, 977 "Assume strict aliasing rules apply" }, 978 {"check-memory-usage", &flag_check_memory_usage, 1, 979 "Generate code to check every memory access" }, 980 {"prefix-function-name", &flag_prefix_function_name, 1, 981 "Add a prefix to all function names" }, 982 {"dump-unnumbered", &flag_dump_unnumbered, 1, 983 "Suppress output of instruction numbers and line number notes in debugging dumps"}, 984 {"instrument-functions", &flag_instrument_function_entry_exit, 1, 985 "Instrument function entry/exit with profiling calls"}, 986 {"leading-underscore", &flag_leading_underscore, 1, 987 "External symbols have a leading underscore" }, 988 {"ident", &flag_no_ident, 0, 989 "Process #ident directives"} 990}; 991 992#define NUM_ELEM(a) (sizeof (a) / sizeof ((a)[0])) 993 994/* Table of language-specific options. */ 995 996static struct lang_opt 997{ 998 const char * option; 999 const char * description; 1000} 1001documented_lang_options[] = 1002{ 1003 /* In order not to overload the --help output, the convention 1004 used here is to only describe those options which are not 1005 enabled by default. */ 1006 1007 { "-ansi", "Compile just for ANSI C" }, 1008 { "-fallow-single-precision", 1009 "Do not promote floats to double if using -traditional" }, 1010 { "-std= ", "Determine language standard"}, 1011 1012 { "-fsigned-bitfields", "" }, 1013 { "-funsigned-bitfields","Make bitfields by unsigned by default" }, 1014 { "-fno-signed-bitfields", "" }, 1015 { "-fno-unsigned-bitfields","" }, 1016 { "-fsigned-char", "Make 'char' be signed by default"}, 1017 { "-funsigned-char", "Make 'char' be unsigned by default"}, 1018 { "-fno-signed-char", "" }, 1019 { "-fno-unsigned-char", "" }, 1020 1021 { "-ftraditional", "" }, 1022 { "-traditional", "Attempt to support traditional K&R style C"}, 1023 { "-fnotraditional", "" }, 1024 { "-fno-traditional", "" }, 1025 1026 { "-fasm", "" }, 1027 { "-fno-asm", "Do not recognise the 'asm' keyword" }, 1028 { "-fbuiltin", "" }, 1029 { "-fno-builtin", "Do not recognise any built in functions" }, 1030 { "-fhosted", "Assume normal C execution environment" }, 1031 { "-fno-hosted", "" }, 1032 { "-ffreestanding", 1033 "Assume that standard libraries & main might not exist" }, 1034 { "-fno-freestanding", "" }, 1035 { "-fcond-mismatch", "Allow different types as args of ? operator"}, 1036 { "-fno-cond-mismatch", "" }, 1037 { "-fdollars-in-identifiers", "Allow the use of $ inside identifiers" }, 1038 { "-fno-dollars-in-identifiers", "" }, 1039 { "-fshort-double", "Use the same size for double as for float" }, 1040 { "-fno-short-double", "" }, 1041 { "-fshort-enums", "Use the smallest fitting integer to hold enums"}, 1042 { "-fno-short-enums", "" }, 1043 1044 { "-Wall", "Enable most warning messages" }, 1045 { "-Wbad-function-cast", 1046 "Warn about casting functions to incompatible types" }, 1047 { "-Wno-bad-function-cast", "" }, 1048 { "-Wmissing-noreturn", 1049 "Warn about functions which might be candidates for attribute noreturn" }, 1050 { "-Wno-missing-noreturn", "" }, 1051 { "-Wcast-qual", "Warn about casts which discard qualifiers"}, 1052 { "-Wno-cast-qual", "" }, 1053 { "-Wchar-subscripts", "Warn about subscripts whose type is 'char'"}, 1054 { "-Wno-char-subscripts", "" }, 1055 { "-Wcomment", "Warn if nested comments are detected" }, 1056 { "-Wno-comment", "" }, 1057 { "-Wcomments", "Warn if nested comments are detected" }, 1058 { "-Wno-comments", "" }, 1059 { "-Wconversion", "Warn about possibly confusing type conversions" }, 1060 { "-Wno-conversion", "" }, 1061 { "-Wformat", "Warn about printf format anomalies" }, 1062 { "-Wno-format", "" }, 1063 { "-Wimplicit-function-declaration", 1064 "Warn about implicit function declarations" }, 1065 { "-Wno-implicit-function-declaration", "" }, 1066 { "-Werror-implicit-function-declaration", "" }, 1067 { "-Wimplicit-int", "Warn when a declaration does not specify a type" }, 1068 { "-Wno-implicit-int", "" }, 1069 { "-Wimplicit", "" }, 1070 { "-Wno-implicit", "" }, 1071 { "-Wimport", "Warn about the use of the #import directive" }, 1072 { "-Wno-import", "" }, 1073 { "-Wlong-long","" }, 1074 { "-Wno-long-long", "Do not warn about using 'long long' when -pedantic" }, 1075 { "-Wmain", "Warn about suspicious declarations of main" }, 1076 { "-Wno-main", "" }, 1077 { "-Wmissing-braces", 1078 "Warn about possibly missing braces around initialisers" }, 1079 { "-Wno-missing-braces", "" }, 1080 { "-Wmissing-declarations", 1081 "Warn about global funcs without previous declarations"}, 1082 { "-Wno-missing-declarations", "" }, 1083 { "-Wmissing-prototypes", "Warn about global funcs without prototypes" }, 1084 { "-Wno-missing-prototypes", "" }, 1085 { "-Wmultichar", "Warn about use of multicharacter literals"}, 1086 { "-Wno-multichar", "" }, 1087 { "-Wnested-externs", "Warn about externs not at file scope level" }, 1088 { "-Wno-nested-externs", "" }, 1089 { "-Wparentheses", "Warn about possible missing parentheses" }, 1090 { "-Wno-parentheses", "" }, 1091 { "-Wpointer-arith", "Warn about function pointer arithmetic" }, 1092 { "-Wno-pointer-arith", "" }, 1093 { "-Wredundant-decls", 1094 "Warn about multiple declarations of the same object" }, 1095 { "-Wno-redundant-decls", "" }, 1096 { "-Wsign-compare", "Warn about signed/unsigned comparisons" }, 1097 { "-Wno-sign-compare", "" }, 1098 { "-Wunknown-pragmas", "Warn about unrecognised pragmas" }, 1099 { "-Wno-unknown-pragmas", "" }, 1100 { "-Wstrict-prototypes", "Warn about non-prototyped function decls" }, 1101 { "-Wno-strict-prototypes", "" }, 1102 { "-Wtraditional", "Warn about constructs whose meaning change in ANSI C"}, 1103 { "-Wno-traditional", "" }, 1104 { "-Wtrigraphs", "Warn when trigraphs are encountered" }, 1105 { "-Wno-trigraphs", "" }, 1106 { "-Wundef", "" }, 1107 { "-Wno-undef", "" }, 1108 { "-Wwrite-strings", "Mark strings as 'const char *'"}, 1109 { "-Wno-write-strings", "" }, 1110 1111 /* These are for languages with USE_CPPLIB. */ 1112 /* These options are already documented in cpplib.c */ 1113 { "--help", "" }, 1114 { "-A", "" }, 1115 { "-D", "" }, 1116 { "-I", "" }, 1117#if USE_CPPLIB 1118 { "-MD", "Print dependencies to FILE.d" }, 1119 { "-MMD", "Print dependencies to FILE.d" }, 1120 { "-M", "Print dependencies to stdout" }, 1121 { "-MM", "Print dependencies to stdout" }, 1122#endif /* USE_CPPLIB */ 1123 { "-U", "" }, 1124 { "-H", "" }, 1125 { "-idirafter", "" }, 1126 { "-imacros", "" }, 1127 { "-include", "" }, 1128 { "-iprefix", "" }, 1129 { "-isystem", "" }, 1130 { "-iwithprefix", "" }, 1131 { "-iwithprefixbefore", "" }, 1132 { "-lang-c", "" }, 1133 { "-lang-c89", "" }, 1134 { "-lang-c++", "" }, 1135 { "-remap", "" }, 1136 { "-nostdinc", "" }, 1137 { "-nostdinc++", "" }, 1138 { "-trigraphs", "" }, 1139 { "-undef", "" }, 1140 1141#define DEFINE_LANG_NAME(NAME) { NULL, NAME }, 1142 1143 /* These are for obj c. */ 1144 DEFINE_LANG_NAME ("Objective C") 1145 1146 { "-lang-objc", "" }, 1147 { "-gen-decls", "Dump decls to a .decl file" }, 1148 { "-fgnu-runtime", "Generate code for GNU runtime environment" }, 1149 { "-fno-gnu-runtime", "" }, 1150 { "-fnext-runtime", "Generate code for NeXT runtime environment" }, 1151 { "-fno-next-runtime", "" }, 1152 { "-Wselector", "Warn if a selector has multiple methods" }, 1153 { "-Wno-selector", "" }, 1154 { "-Wprotocol", "" }, 1155 { "-Wno-protocol", "Do not warn if inherited methods are unimplemented"}, 1156 { "-print-objc-runtime-info", 1157 "Generate C header of platform specific features" }, 1158 1159#include "options.h" 1160 1161}; 1162 1163/* Here is a table, controlled by the tm.h file, listing each -m switch 1164 and which bits in `target_switches' it should set or clear. 1165 If VALUE is positive, it is bits to set. 1166 If VALUE is negative, -VALUE is bits to clear. 1167 (The sign bit is not used so there is no confusion.) */ 1168 1169struct 1170{ 1171 const char * name; 1172 int value; 1173 const char * description; 1174} 1175target_switches [] = TARGET_SWITCHES; 1176 1177/* This table is similar, but allows the switch to have a value. */ 1178 1179#ifdef TARGET_OPTIONS 1180struct 1181{ 1182 const char * prefix; 1183 const char ** variable; 1184 const char * description; 1185} 1186target_options [] = TARGET_OPTIONS; 1187#endif 1188 1189/* Options controlling warnings */ 1190 1191/* Don't print warning messages. -w. */ 1192 1193int inhibit_warnings = 0; 1194 1195/* Print various extra warnings. -W. */ 1196 1197int extra_warnings = 0; 1198 1199/* Treat warnings as errors. -Werror. */ 1200 1201int warnings_are_errors = 0; 1202 1203/* Nonzero to warn about unused local variables. */ 1204 1205int warn_unused; 1206 1207/* Nonzero to warn about variables used before they are initialized. */ 1208 1209int warn_uninitialized; 1210 1211/* Nonzero means warn about all declarations which shadow others. */ 1212 1213int warn_shadow; 1214 1215/* Warn if a switch on an enum fails to have a case for every enum value. */ 1216 1217int warn_switch; 1218 1219/* Nonzero means warn about function definitions that default the return type 1220 or that use a null return and have a return-type other than void. */ 1221 1222int warn_return_type; 1223 1224/* Nonzero means warn about pointer casts that increase the required 1225 alignment of the target type (and might therefore lead to a crash 1226 due to a misaligned access). */ 1227 1228int warn_cast_align; 1229 1230/* Nonzero means warn about any identifiers that match in the first N 1231 characters. The value N is in `id_clash_len'. */ 1232 1233int warn_id_clash; 1234unsigned id_clash_len; 1235 1236/* Nonzero means warn about any objects definitions whose size is larger 1237 than N bytes. Also want about function definitions whose returned 1238 values are larger than N bytes. The value N is in `larger_than_size'. */ 1239 1240int warn_larger_than; 1241unsigned larger_than_size; 1242 1243/* Nonzero means warn if inline function is too large. */ 1244 1245int warn_inline; 1246 1247/* Warn if a function returns an aggregate, 1248 since there are often incompatible calling conventions for doing this. */ 1249 1250int warn_aggregate_return; 1251 1252/* Likewise for -W. */ 1253 1254lang_independent_options W_options[] = 1255{ 1256 {"unused", &warn_unused, 1, "Warn when a variable is unused" }, 1257 {"error", &warnings_are_errors, 1, ""}, 1258 {"shadow", &warn_shadow, 1, "Warn when one local variable shadows another" }, 1259 {"switch", &warn_switch, 1, 1260 "Warn about enumerated switches missing a specific case" }, 1261 {"aggregate-return", &warn_aggregate_return, 1, 1262 "Warn about returning structures, unions or arrays" }, 1263 {"cast-align", &warn_cast_align, 1, 1264 "Warn about pointer casts which increase alignment" }, 1265 {"uninitialized", &warn_uninitialized, 1, 1266 "Warn about unitialized automatic variables"}, 1267 {"inline", &warn_inline, 1, 1268 "Warn when an inlined function cannot be inlined"} 1269}; 1270 1271/* Output files for assembler code (real compiler output) 1272 and debugging dumps. */ 1273 1274FILE *asm_out_file; 1275FILE *aux_info_file; 1276FILE *rtl_dump_file = NULL; 1277 1278/* Decode the string P as an integral parameter. 1279 If the string is indeed an integer return its numeric value else 1280 issue an Invalid Option error for the option PNAME and return DEFVAL. 1281 If PNAME is zero just return DEFVAL, do not call error. */ 1282 1283int 1284read_integral_parameter (p, pname, defval) 1285 const char *p; 1286 const char *pname; 1287 const int defval; 1288{ 1289 const char *endp = p; 1290 1291 while (*endp) 1292 { 1293 if (*endp >= '0' && *endp <= '9') 1294 endp++; 1295 else 1296 break; 1297 } 1298 1299 if (*endp != 0) 1300 { 1301 if (pname != 0) 1302 error ("Invalid option `%s'", pname); 1303 return defval; 1304 } 1305 1306 return atoi (p); 1307} 1308 1309 1310/* Time accumulators, to count the total time spent in various passes. */ 1311 1312int parse_time; 1313int varconst_time; 1314int integration_time; 1315int jump_time; 1316int cse_time; 1317int gcse_time; 1318int loop_time; 1319int cse2_time; 1320int branch_prob_time; 1321int flow_time; 1322int combine_time; 1323int regmove_time; 1324int sched_time; 1325int local_alloc_time; 1326int global_alloc_time; 1327int flow2_time; 1328int sched2_time; 1329#ifdef DELAY_SLOTS 1330int dbr_sched_time; 1331#endif 1332int shorten_branch_time; 1333int stack_reg_time; 1334int final_time; 1335int symout_time; 1336int dump_time; 1337 1338/* Return time used so far, in microseconds. */ 1339 1340long 1341get_run_time () 1342{ 1343 if (quiet_flag) 1344 return 0; 1345 1346#ifdef __BEOS__ 1347 return 0; 1348#else /* not BeOS */ 1349#if defined (_WIN32) && !defined (__CYGWIN__) 1350 if (clock() < 0) 1351 return 0; 1352 else 1353 return (clock() * 1000); 1354#else /* not _WIN32 */ 1355#ifdef _SC_CLK_TCK 1356 { 1357 static int tick; 1358 struct tms tms; 1359 if (tick == 0) 1360 tick = 1000000 / sysconf(_SC_CLK_TCK); 1361 times (&tms); 1362 return (tms.tms_utime + tms.tms_stime) * tick; 1363 } 1364#else 1365#ifdef USG 1366 { 1367 struct tms tms; 1368# if HAVE_SYSCONF && defined _SC_CLK_TCK 1369# define TICKS_PER_SECOND sysconf (_SC_CLK_TCK) /* POSIX 1003.1-1996 */ 1370# else 1371# ifdef CLK_TCK 1372# define TICKS_PER_SECOND CLK_TCK /* POSIX 1003.1-1988; obsolescent */ 1373# else 1374# define TICKS_PER_SECOND HZ /* traditional UNIX */ 1375# endif 1376# endif 1377 times (&tms); 1378 return (tms.tms_utime + tms.tms_stime) * (1000000 / TICKS_PER_SECOND); 1379 } 1380#else 1381#ifndef VMS 1382 { 1383 struct rusage rusage; 1384 getrusage (0, &rusage); 1385 return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec 1386 + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); 1387 } 1388#else /* VMS */ 1389 { 1390 struct 1391 { 1392 int proc_user_time; 1393 int proc_system_time; 1394 int child_user_time; 1395 int child_system_time; 1396 } vms_times; 1397 times ((void *) &vms_times); 1398 return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; 1399 } 1400#endif /* VMS */ 1401#endif /* USG */ 1402#endif /* _SC_CLK_TCK */ 1403#endif /* _WIN32 */ 1404#endif /* __BEOS__ */ 1405} 1406 1407#define TIMEVAR(VAR, BODY) \ 1408do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0) 1409 1410void 1411print_time (str, total) 1412 const char *str; 1413 int total; 1414{ 1415 fprintf (stderr, 1416 "time in %s: %d.%06d\n", 1417 str, total / 1000000, total % 1000000); 1418} 1419 1420/* Count an error or warning. Return 1 if the message should be printed. */ 1421 1422int 1423count_error (warningp) 1424 int warningp; 1425{ 1426 if (warningp && inhibit_warnings) 1427 return 0; 1428 1429 if (warningp && !warnings_are_errors) 1430 warningcount++; 1431 else 1432 { 1433 static int warning_message = 0; 1434 1435 if (warningp && !warning_message) 1436 { 1437 notice ("%s: warnings being treated as errors\n", progname); 1438 warning_message = 1; 1439 } 1440 errorcount++; 1441 } 1442 1443 return 1; 1444} 1445 1446/* Print a fatal error message. NAME is the text. 1447 Also include a system error message based on `errno'. */ 1448 1449void 1450pfatal_with_name (name) 1451 const char *name; 1452{ 1453 fprintf (stderr, "%s: ", progname); 1454 perror (name); 1455 exit (FATAL_EXIT_CODE); 1456} 1457 1458void 1459fatal_io_error (name) 1460 const char *name; 1461{ 1462 notice ("%s: %s: I/O error\n", progname, name); 1463 exit (FATAL_EXIT_CODE); 1464} 1465 1466/* Called to give a better error message for a bad insn rather than 1467 just calling abort(). */ 1468 1469void 1470fatal_insn VPROTO((const char *msgid, rtx insn, ...)) 1471{ 1472#ifndef ANSI_PROTOTYPES 1473 const char *msgid; 1474 rtx insn; 1475#endif 1476 va_list ap; 1477 1478 VA_START (ap, insn); 1479 1480#ifndef ANSI_PROTOTYPES 1481 msgid = va_arg (ap, const char *); 1482 insn = va_arg (ap, rtx); 1483#endif 1484 1485 verror (msgid, ap); 1486 debug_rtx (insn); 1487 exit (FATAL_EXIT_CODE); 1488} 1489 1490/* Called to give a better error message when we don't have an insn to match 1491 what we are looking for or if the insn's constraints aren't satisfied, 1492 rather than just calling abort(). */ 1493 1494void 1495fatal_insn_not_found (insn) 1496 rtx insn; 1497{ 1498 if (INSN_CODE (insn) < 0) 1499 fatal_insn ("internal error--unrecognizable insn:", insn); 1500 else 1501 fatal_insn ("internal error--insn does not satisfy its constraints:", insn); 1502} 1503 1504/* This is the default decl_printable_name function. */ 1505 1506static char * 1507decl_name (decl, verbosity) 1508 tree decl; 1509 int verbosity ATTRIBUTE_UNUSED; 1510{ 1511 return IDENTIFIER_POINTER (DECL_NAME (decl)); 1512} 1513 1514static int need_error_newline; 1515 1516/* Function of last error message; 1517 more generally, function such that if next error message is in it 1518 then we don't have to mention the function name. */ 1519static tree last_error_function = NULL; 1520 1521/* Used to detect when input_file_stack has changed since last described. */ 1522static int last_error_tick; 1523 1524/* Called when the start of a function definition is parsed, 1525 this function prints on stderr the name of the function. */ 1526 1527void 1528announce_function (decl) 1529 tree decl; 1530{ 1531 if (! quiet_flag) 1532 { 1533 if (rtl_dump_and_exit) 1534 fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); 1535 else 1536 fprintf (stderr, " %s", (*decl_printable_name) (decl, 2)); 1537 fflush (stderr); 1538 need_error_newline = 1; 1539 last_error_function = current_function_decl; 1540 } 1541} 1542 1543/* The default function to print out name of current function that caused 1544 an error. */ 1545 1546void 1547default_print_error_function (file) 1548 const char *file; 1549{ 1550 if (last_error_function != current_function_decl) 1551 { 1552 if (file) 1553 fprintf (stderr, "%s: ", file); 1554 1555 if (current_function_decl == NULL) 1556 notice ("At top level:\n"); 1557 else 1558 notice ((TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE 1559 ? "In method `%s':\n" 1560 : "In function `%s':\n"), 1561 (*decl_printable_name) (current_function_decl, 2)); 1562 1563 last_error_function = current_function_decl; 1564 } 1565} 1566 1567/* Called by report_error_function to print out function name. 1568 * Default may be overridden by language front-ends. */ 1569 1570void (*print_error_function) PROTO((const char *)) = 1571 default_print_error_function; 1572 1573/* Prints out, if necessary, the name of the current function 1574 that caused an error. Called from all error and warning functions. 1575 We ignore the FILE parameter, as it cannot be relied upon. */ 1576 1577void 1578report_error_function (file) 1579 const char *file ATTRIBUTE_UNUSED; 1580{ 1581 struct file_stack *p; 1582 1583 if (need_error_newline) 1584 { 1585 fprintf (stderr, "\n"); 1586 need_error_newline = 0; 1587 } 1588 1589 if (input_file_stack && input_file_stack->next != 0 1590 && input_file_stack_tick != last_error_tick) 1591 { 1592 for (p = input_file_stack->next; p; p = p->next) 1593 notice ((p == input_file_stack->next 1594 ? "In file included from %s:%d" 1595 : ",\n from %s:%d"), 1596 p->name, p->line); 1597 fprintf (stderr, ":\n"); 1598 last_error_tick = input_file_stack_tick; 1599 } 1600 1601 (*print_error_function) (input_filename); 1602} 1603 1604/* Print a message. */ 1605 1606static void 1607vnotice (file, msgid, ap) 1608 FILE *file; 1609 char *msgid; 1610 va_list ap; 1611{ 1612 vfprintf (file, _(msgid), ap); 1613} 1614 1615void 1616notice VPROTO((const char *msgid, ...)) 1617{ 1618#ifndef ANSI_PROTOTYPES 1619 char *msgid; 1620#endif 1621 va_list ap; 1622 1623 VA_START (ap, msgid); 1624 1625#ifndef ANSI_PROTOTYPES 1626 msgid = va_arg (ap, char *); 1627#endif 1628 1629 vnotice (stderr, msgid, ap); 1630 va_end (ap); 1631} 1632 1633void 1634fnotice VPROTO((FILE *file, const char *msgid, ...)) 1635{ 1636#ifndef ANSI_PROTOTYPES 1637 FILE *file; 1638 const char *msgid; 1639#endif 1640 va_list ap; 1641 1642 VA_START (ap, msgid); 1643 1644#ifndef ANSI_PROTOTYPES 1645 file = va_arg (ap, FILE *); 1646 msgid = va_arg (ap, const char *); 1647#endif 1648 1649 vnotice (file, msgid, ap); 1650 va_end (ap); 1651} 1652 1653/* Report FILE and LINE (or program name), and optionally just WARN. */ 1654 1655static void 1656report_file_and_line (file, line, warn) 1657 char *file; 1658 int line; 1659 int warn; 1660{ 1661 if (file) 1662 fprintf (stderr, "%s:%d: ", file, line); 1663 else 1664 fprintf (stderr, "%s: ", progname); 1665 1666 if (warn) 1667 notice ("warning: "); 1668} 1669 1670/* Print a message. */ 1671 1672static void 1673vmessage (prefix, msgid, ap) 1674 const char *prefix; 1675 const char *msgid; 1676 va_list ap; 1677{ 1678 if (prefix) 1679 fprintf (stderr, "%s: ", prefix); 1680 1681 vfprintf (stderr, msgid, ap); 1682} 1683 1684/* Print a message relevant to line LINE of file FILE. */ 1685 1686static void 1687v_message_with_file_and_line (file, line, warn, msgid, ap) 1688 const char *file; 1689 int line; 1690 int warn; 1691 const char *msgid; 1692 va_list ap; 1693{ 1694 report_file_and_line (file, line, warn); 1695 vnotice (stderr, msgid, ap); 1696 fputc ('\n', stderr); 1697} 1698 1699/* Print a message relevant to the given DECL. */ 1700 1701static void 1702v_message_with_decl (decl, warn, msgid, ap) 1703 tree decl; 1704 int warn; 1705 const char *msgid; 1706 va_list ap; 1707{ 1708 const char *p; 1709 1710 report_file_and_line (DECL_SOURCE_FILE (decl), 1711 DECL_SOURCE_LINE (decl), warn); 1712 1713 /* Do magic to get around lack of varargs support for insertion 1714 of arguments into existing list. We know that the decl is first; 1715 we ass_u_me that it will be printed with "%s". */ 1716 1717 for (p = _(msgid); *p; ++p) 1718 { 1719 if (*p == '%') 1720 { 1721 if (*(p + 1) == '%') 1722 ++p; 1723 else if (*(p + 1) != 's') 1724 abort (); 1725 else 1726 break; 1727 } 1728 } 1729 1730 if (p > _(msgid)) /* Print the left-hand substring. */ 1731 { 1732 char fmt[sizeof "%.255s"]; 1733 long width = p - _(msgid); 1734 1735 if (width > 255L) width = 255L; /* arbitrary */ 1736 sprintf (fmt, "%%.%lds", width); 1737 fprintf (stderr, fmt, _(msgid)); 1738 } 1739 1740 if (*p == '%') /* Print the name. */ 1741 { 1742 const char *n = (DECL_NAME (decl) 1743 ? (*decl_printable_name) (decl, 2) 1744 : "((anonymous))"); 1745 fputs (n, stderr); 1746 while (*p) 1747 { 1748 ++p; 1749 if (ISALPHA (*(p - 1) & 0xFF)) 1750 break; 1751 } 1752 } 1753 1754 if (*p) /* Print the rest of the message. */ 1755 vmessage ((char *)NULL, p, ap); 1756 1757 fputc ('\n', stderr); 1758} 1759 1760/* Figure file and line of the given INSN. */ 1761 1762static void 1763file_and_line_for_asm (insn, pfile, pline) 1764 rtx insn; 1765 char **pfile; 1766 int *pline; 1767{ 1768 rtx body = PATTERN (insn); 1769 rtx asmop; 1770 1771 /* Find the (or one of the) ASM_OPERANDS in the insn. */ 1772 if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) 1773 asmop = SET_SRC (body); 1774 else if (GET_CODE (body) == ASM_OPERANDS) 1775 asmop = body; 1776 else if (GET_CODE (body) == PARALLEL 1777 && GET_CODE (XVECEXP (body, 0, 0)) == SET) 1778 asmop = SET_SRC (XVECEXP (body, 0, 0)); 1779 else if (GET_CODE (body) == PARALLEL 1780 && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) 1781 asmop = XVECEXP (body, 0, 0); 1782 else 1783 asmop = NULL; 1784 1785 if (asmop) 1786 { 1787 *pfile = ASM_OPERANDS_SOURCE_FILE (asmop); 1788 *pline = ASM_OPERANDS_SOURCE_LINE (asmop); 1789 } 1790 else 1791 { 1792 *pfile = input_filename; 1793 *pline = lineno; 1794 } 1795} 1796 1797/* Report an error at line LINE of file FILE. */ 1798 1799static void 1800v_error_with_file_and_line (file, line, msgid, ap) 1801 const char *file; 1802 int line; 1803 const char *msgid; 1804 va_list ap; 1805{ 1806 count_error (0); 1807 report_error_function (file); 1808 v_message_with_file_and_line (file, line, 0, msgid, ap); 1809} 1810 1811void 1812error_with_file_and_line VPROTO((const char *file, int line, 1813 const char *msgid, ...)) 1814{ 1815#ifndef ANSI_PROTOTYPES 1816 const char *file; 1817 int line; 1818 const char *msgid; 1819#endif 1820 va_list ap; 1821 1822 VA_START (ap, msgid); 1823 1824#ifndef ANSI_PROTOTYPES 1825 file = va_arg (ap, const char *); 1826 line = va_arg (ap, int); 1827 msgid = va_arg (ap, const char *); 1828#endif 1829 1830 v_error_with_file_and_line (file, line, msgid, ap); 1831 va_end (ap); 1832} 1833 1834/* Report an error at the declaration DECL. 1835 MSGID is a format string which uses %s to substitute the declaration 1836 name; subsequent substitutions are a la printf. */ 1837 1838static void 1839v_error_with_decl (decl, msgid, ap) 1840 tree decl; 1841 const char *msgid; 1842 va_list ap; 1843{ 1844 count_error (0); 1845 report_error_function (DECL_SOURCE_FILE (decl)); 1846 v_message_with_decl (decl, 0, msgid, ap); 1847} 1848 1849void 1850error_with_decl VPROTO((tree decl, const char *msgid, ...)) 1851{ 1852#ifndef ANSI_PROTOTYPES 1853 tree decl; 1854 const char *msgid; 1855#endif 1856 va_list ap; 1857 1858 VA_START (ap, msgid); 1859 1860#ifndef ANSI_PROTOTYPES 1861 decl = va_arg (ap, tree); 1862 msgid = va_arg (ap, const char *); 1863#endif 1864 1865 v_error_with_decl (decl, msgid, ap); 1866 va_end (ap); 1867} 1868 1869/* Report an error at the line number of the insn INSN. 1870 This is used only when INSN is an `asm' with operands, 1871 and each ASM_OPERANDS records its own source file and line. */ 1872 1873static void 1874v_error_for_asm (insn, msgid, ap) 1875 rtx insn; 1876 const char *msgid; 1877 va_list ap; 1878{ 1879 char *file; 1880 int line; 1881 1882 count_error (0); 1883 file_and_line_for_asm (insn, &file, &line); 1884 report_error_function (file); 1885 v_message_with_file_and_line (file, line, 0, msgid, ap); 1886} 1887 1888void 1889error_for_asm VPROTO((rtx insn, const char *msgid, ...)) 1890{ 1891#ifndef ANSI_PROTOTYPES 1892 rtx insn; 1893 const char *msgid; 1894#endif 1895 va_list ap; 1896 1897 VA_START (ap, msgid); 1898 1899#ifndef ANSI_PROTOTYPES 1900 insn = va_arg (ap, rtx); 1901 msgid = va_arg (ap, const char *); 1902#endif 1903 1904 v_error_for_asm (insn, msgid, ap); 1905 va_end (ap); 1906} 1907 1908/* Report an error at the current line number. */ 1909 1910static void 1911verror (msgid, ap) 1912 const char *msgid; 1913 va_list ap; 1914{ 1915 v_error_with_file_and_line (input_filename, lineno, msgid, ap); 1916} 1917 1918void 1919error VPROTO((const char *msgid, ...)) 1920{ 1921#ifndef ANSI_PROTOTYPES 1922 const char *msgid; 1923#endif 1924 va_list ap; 1925 1926 VA_START (ap, msgid); 1927 1928#ifndef ANSI_PROTOTYPES 1929 msgid = va_arg (ap, const char *); 1930#endif 1931 1932 verror (msgid, ap); 1933 va_end (ap); 1934} 1935 1936/* Report a fatal error at the current line number. */ 1937 1938static void 1939vfatal (msgid, ap) 1940 const char *msgid; 1941 va_list ap; 1942{ 1943 verror (msgid, ap); 1944 exit (FATAL_EXIT_CODE); 1945} 1946 1947void 1948fatal VPROTO((const char *msgid, ...)) 1949{ 1950#ifndef ANSI_PROTOTYPES 1951 const char *msgid; 1952#endif 1953 va_list ap; 1954 1955 VA_START (ap, msgid); 1956 1957#ifndef ANSI_PROTOTYPES 1958 msgid = va_arg (ap, const char *); 1959#endif 1960 1961 vfatal (msgid, ap); 1962 va_end (ap); 1963} 1964 1965/* Report a warning at line LINE of file FILE. */ 1966 1967static void 1968v_warning_with_file_and_line (file, line, msgid, ap) 1969 const char *file; 1970 int line; 1971 const char *msgid; 1972 va_list ap; 1973{ 1974 if (count_error (1)) 1975 { 1976 report_error_function (file); 1977 v_message_with_file_and_line (file, line, 1, msgid, ap); 1978 } 1979} 1980 1981void 1982warning_with_file_and_line VPROTO((const char *file, int line, 1983 const char *msgid, ...)) 1984{ 1985#ifndef ANSI_PROTOTYPES 1986 const char *file; 1987 int line; 1988 const char *msgid; 1989#endif 1990 va_list ap; 1991 1992 VA_START (ap, msgid); 1993 1994#ifndef ANSI_PROTOTYPES 1995 file = va_arg (ap, const char *); 1996 line = va_arg (ap, int); 1997 msgid = va_arg (ap, const char *); 1998#endif 1999 2000 v_warning_with_file_and_line (file, line, msgid, ap); 2001 va_end (ap); 2002} 2003 2004/* Report a warning at the declaration DECL. 2005 MSGID is a format string which uses %s to substitute the declaration 2006 name; subsequent substitutions are a la printf. */ 2007 2008static void 2009v_warning_with_decl (decl, msgid, ap) 2010 tree decl; 2011 const char *msgid; 2012 va_list ap; 2013{ 2014 if (count_error (1)) 2015 { 2016 report_error_function (DECL_SOURCE_FILE (decl)); 2017 v_message_with_decl (decl, 1, msgid, ap); 2018 } 2019} 2020 2021void 2022warning_with_decl VPROTO((tree decl, const char *msgid, ...)) 2023{ 2024#ifndef ANSI_PROTOTYPES 2025 tree decl; 2026 const char *msgid; 2027#endif 2028 va_list ap; 2029 2030 VA_START (ap, msgid); 2031 2032#ifndef ANSI_PROTOTYPES 2033 decl = va_arg (ap, tree); 2034 msgid = va_arg (ap, const char *); 2035#endif 2036 2037 v_warning_with_decl (decl, msgid, ap); 2038 va_end (ap); 2039} 2040 2041/* Report a warning at the line number of the insn INSN. 2042 This is used only when INSN is an `asm' with operands, 2043 and each ASM_OPERANDS records its own source file and line. */ 2044 2045static void 2046v_warning_for_asm (insn, msgid, ap) 2047 rtx insn; 2048 const char *msgid; 2049 va_list ap; 2050{ 2051 if (count_error (1)) 2052 { 2053 char *file; 2054 int line; 2055 2056 file_and_line_for_asm (insn, &file, &line); 2057 report_error_function (file); 2058 v_message_with_file_and_line (file, line, 1, msgid, ap); 2059 } 2060} 2061 2062void 2063warning_for_asm VPROTO((rtx insn, const char *msgid, ...)) 2064{ 2065#ifndef ANSI_PROTOTYPES 2066 rtx insn; 2067 const char *msgid; 2068#endif 2069 va_list ap; 2070 2071 VA_START (ap, msgid); 2072 2073#ifndef ANSI_PROTOTYPES 2074 insn = va_arg (ap, rtx); 2075 msgid = va_arg (ap, const char *); 2076#endif 2077 2078 v_warning_for_asm (insn, msgid, ap); 2079 va_end (ap); 2080} 2081 2082/* Report a warning at the current line number. */ 2083 2084static void 2085vwarning (msgid, ap) 2086 const char *msgid; 2087 va_list ap; 2088{ 2089 v_warning_with_file_and_line (input_filename, lineno, msgid, ap); 2090} 2091 2092void 2093warning VPROTO((const char *msgid, ...)) 2094{ 2095#ifndef ANSI_PROTOTYPES 2096 const char *msgid; 2097#endif 2098 va_list ap; 2099 2100 VA_START (ap, msgid); 2101 2102#ifndef ANSI_PROTOTYPES 2103 msgid = va_arg (ap, const char *); 2104#endif 2105 2106 vwarning (msgid, ap); 2107 va_end (ap); 2108} 2109 2110/* These functions issue either warnings or errors depending on 2111 -pedantic-errors. */ 2112 2113static void 2114vpedwarn (msgid, ap) 2115 const char *msgid; 2116 va_list ap; 2117{ 2118 if (flag_pedantic_errors) 2119 verror (msgid, ap); 2120 else 2121 vwarning (msgid, ap); 2122} 2123 2124void 2125pedwarn VPROTO((const char *msgid, ...)) 2126{ 2127#ifndef ANSI_PROTOTYPES 2128 const char *msgid; 2129#endif 2130 va_list ap; 2131 2132 VA_START (ap, msgid); 2133 2134#ifndef ANSI_PROTOTYPES 2135 msgid = va_arg (ap, const char *); 2136#endif 2137 2138 vpedwarn (msgid, ap); 2139 va_end (ap); 2140} 2141 2142static void 2143v_pedwarn_with_decl (decl, msgid, ap) 2144 tree decl; 2145 const char *msgid; 2146 va_list ap; 2147{ 2148 /* We don't want -pedantic-errors to cause the compilation to fail from 2149 "errors" in system header files. Sometimes fixincludes can't fix what's 2150 broken (eg: unsigned char bitfields - fixing it may change the alignment 2151 which will cause programs to mysteriously fail because the C library 2152 or kernel uses the original layout). There's no point in issuing a 2153 warning either, it's just unnecessary noise. */ 2154 2155 if (! DECL_IN_SYSTEM_HEADER (decl)) 2156 { 2157 if (flag_pedantic_errors) 2158 v_error_with_decl (decl, msgid, ap); 2159 else 2160 v_warning_with_decl (decl, msgid, ap); 2161 } 2162} 2163 2164void 2165pedwarn_with_decl VPROTO((tree decl, const char *msgid, ...)) 2166{ 2167#ifndef ANSI_PROTOTYPES 2168 tree decl; 2169 const char *msgid; 2170#endif 2171 va_list ap; 2172 2173 VA_START (ap, msgid); 2174 2175#ifndef ANSI_PROTOTYPES 2176 decl = va_arg (ap, tree); 2177 msgid = va_arg (ap, const char *); 2178#endif 2179 2180 v_pedwarn_with_decl (decl, msgid, ap); 2181 va_end (ap); 2182} 2183 2184static void 2185v_pedwarn_with_file_and_line (file, line, msgid, ap) 2186 const char *file; 2187 int line; 2188 const char *msgid; 2189 va_list ap; 2190{ 2191 if (flag_pedantic_errors) 2192 v_error_with_file_and_line (file, line, msgid, ap); 2193 else 2194 v_warning_with_file_and_line (file, line, msgid, ap); 2195} 2196 2197void 2198pedwarn_with_file_and_line VPROTO((const char *file, int line, 2199 const char *msgid, ...)) 2200{ 2201#ifndef ANSI_PROTOTYPES 2202 const char *file; 2203 int line; 2204 const char *msgid; 2205#endif 2206 va_list ap; 2207 2208 VA_START (ap, msgid); 2209 2210#ifndef ANSI_PROTOTYPES 2211 file = va_arg (ap, const char *); 2212 line = va_arg (ap, int); 2213 msgid = va_arg (ap, const char *); 2214#endif 2215 2216 v_pedwarn_with_file_and_line (file, line, msgid, ap); 2217 va_end (ap); 2218} 2219 2220/* Apologize for not implementing some feature. */ 2221 2222static void 2223vsorry (msgid, ap) 2224 const char *msgid; 2225 va_list ap; 2226{ 2227 sorrycount++; 2228 if (input_filename) 2229 fprintf (stderr, "%s:%d: ", input_filename, lineno); 2230 else 2231 fprintf (stderr, "%s: ", progname); 2232 notice ("sorry, not implemented: "); 2233 vnotice (stderr, msgid, ap); 2234 fputc ('\n', stderr); 2235} 2236 2237void 2238sorry VPROTO((const char *msgid, ...)) 2239{ 2240#ifndef ANSI_PROTOTYPES 2241 const char *msgid; 2242#endif 2243 va_list ap; 2244 2245 VA_START (ap, msgid); 2246 2247#ifndef ANSI_PROTOTYPES 2248 msgid = va_arg (ap, const char *); 2249#endif 2250 2251 vsorry (msgid, ap); 2252 va_end (ap); 2253} 2254 2255/* Given a partial pathname as input, return another pathname that shares 2256 no elements with the pathname of __FILE__. This is used by abort() to 2257 print `Internal compiler error in expr.c' instead of `Internal compiler 2258 error in ../../egcs/gcc/expr.c'. */ 2259const char * 2260trim_filename (name) 2261 const char *name; 2262{ 2263 static const char *this_file = __FILE__; 2264 const char *p = name, *q = this_file; 2265 2266 while (*p == *q && *p != 0 && *q != 0) p++, q++; 2267 while (p > name && p[-1] != DIR_SEPARATOR 2268#ifdef DIR_SEPARATOR_2 2269 && p[-1] != DIR_SEPARATOR_2 2270#endif 2271 ) 2272 p--; 2273 2274 return p; 2275} 2276 2277/* More 'friendly' abort that prints the line and file. 2278 config.h can #define abort fancy_abort if you like that sort of thing. 2279 2280 I don't think this is actually a good idea. 2281 Other sorts of crashes will look a certain way. 2282 It is a good thing if crashes from calling abort look the same way. 2283 -- RMS */ 2284 2285void 2286fancy_abort () 2287{ 2288 fatal ("internal gcc abort"); 2289} 2290 2291/* This calls abort and is used to avoid problems when abort if a macro. 2292 It is used when we need to pass the address of abort. */ 2293 2294void 2295do_abort () 2296{ 2297 abort (); 2298} 2299 2300/* When `malloc.c' is compiled with `rcheck' defined, 2301 it calls this function to report clobberage. */ 2302 2303void 2304botch (s) 2305 const char * s ATTRIBUTE_UNUSED; 2306{ 2307 abort (); 2308} 2309 2310/* Same as `malloc' but report error if no memory available. */ 2311 2312PTR 2313xmalloc (size) 2314 size_t size; 2315{ 2316 register PTR value; 2317 2318 if (size == 0) 2319 size = 1; 2320 2321 value = (PTR) malloc (size); 2322 if (value == 0) 2323 fatal ("virtual memory exhausted"); 2324 return value; 2325} 2326 2327/* Same as `calloc' but report error if no memory available. */ 2328 2329PTR 2330xcalloc (size1, size2) 2331 size_t size1, size2; 2332{ 2333 register PTR value; 2334 2335 if (size1 == 0 || size2 == 0) 2336 size1 = size2 = 1; 2337 2338 value = (PTR) calloc (size1, size2); 2339 if (value == 0) 2340 fatal ("virtual memory exhausted"); 2341 return value; 2342} 2343 2344 2345/* Same as `realloc' but report error if no memory available. 2346 Also handle null PTR even if the vendor realloc gets it wrong. */ 2347 2348PTR 2349xrealloc (ptr, size) 2350 PTR ptr; 2351 size_t size; 2352{ 2353 register PTR result; 2354 2355 if (size == 0) 2356 size = 1; 2357 2358 result = (ptr ? (PTR) realloc (ptr, size) : (PTR) malloc (size)); 2359 2360 if (!result) 2361 fatal ("virtual memory exhausted"); 2362 2363 return result; 2364} 2365 2366/* Same as `strdup' but report error if no memory available. */ 2367 2368char * 2369xstrdup (s) 2370 register const char *s; 2371{ 2372 register char *result = (char *) malloc (strlen (s) + 1); 2373 2374 if (! result) 2375 fatal ("virtual memory exhausted"); 2376 strcpy (result, s); 2377 return result; 2378} 2379 2380/* Return the logarithm of X, base 2, considering X unsigned, 2381 if X is a power of 2. Otherwise, returns -1. 2382 2383 This should be used via the `exact_log2' macro. */ 2384 2385int 2386exact_log2_wide (x) 2387 register unsigned HOST_WIDE_INT x; 2388{ 2389 register int log = 0; 2390 /* Test for 0 or a power of 2. */ 2391 if (x == 0 || x != (x & -x)) 2392 return -1; 2393 while ((x >>= 1) != 0) 2394 log++; 2395 return log; 2396} 2397 2398/* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. 2399 If X is 0, return -1. 2400 2401 This should be used via the floor_log2 macro. */ 2402 2403int 2404floor_log2_wide (x) 2405 register unsigned HOST_WIDE_INT x; 2406{ 2407 register int log = -1; 2408 while (x != 0) 2409 log++, 2410 x >>= 1; 2411 return log; 2412} 2413 2414static int float_handler_set; 2415int float_handled; 2416jmp_buf float_handler; 2417 2418/* Signals actually come here. */ 2419 2420static void 2421float_signal (signo) 2422 /* If this is missing, some compilers complain. */ 2423 int signo ATTRIBUTE_UNUSED; 2424{ 2425 if (float_handled == 0) 2426 abort (); 2427#if defined (USG) || defined (hpux) 2428 signal (SIGFPE, float_signal); /* re-enable the signal catcher */ 2429#endif 2430 float_handled = 0; 2431 signal (SIGFPE, float_signal); 2432 longjmp (float_handler, 1); 2433} 2434 2435/* Specify where to longjmp to when a floating arithmetic error happens. 2436 If HANDLER is 0, it means don't handle the errors any more. */ 2437 2438void 2439set_float_handler (handler) 2440 jmp_buf handler; 2441{ 2442 float_handled = (handler != 0); 2443 if (handler) 2444 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); 2445 2446 if (float_handled && ! float_handler_set) 2447 { 2448 signal (SIGFPE, float_signal); 2449 float_handler_set = 1; 2450 } 2451} 2452 2453/* This is a wrapper function for code which might elicit an 2454 arithmetic exception. That code should be passed in as a function 2455 pointer FN, and one argument DATA. DATA is usually a struct which 2456 contains the real input and output for function FN. This function 2457 returns 0 (failure) if longjmp was called (i.e. an exception 2458 occured.) It returns 1 (success) otherwise. */ 2459 2460int 2461do_float_handler (fn, data) 2462 void (*fn) PROTO ((PTR)); 2463 PTR data; 2464{ 2465 jmp_buf buf; 2466 2467 if (setjmp (buf)) 2468 { 2469 /* We got here via longjmp() caused by an exception in function fn() */ 2470 set_float_handler (NULL); 2471 return 0; 2472 } 2473 2474 set_float_handler (buf); 2475 (*fn)(data); 2476 set_float_handler (NULL); 2477 return 1; 2478} 2479 2480/* Specify, in HANDLER, where to longjmp to when a floating arithmetic 2481 error happens, pushing the previous specification into OLD_HANDLER. 2482 Return an indication of whether there was a previous handler in effect. */ 2483 2484int 2485push_float_handler (handler, old_handler) 2486 jmp_buf handler, old_handler; 2487{ 2488 int was_handled = float_handled; 2489 2490 float_handled = 1; 2491 if (was_handled) 2492 memcpy ((char *) old_handler, (char *) float_handler, 2493 sizeof (float_handler)); 2494 2495 memcpy ((char *) float_handler, (char *) handler, sizeof (float_handler)); 2496 return was_handled; 2497} 2498 2499/* Restore the previous specification of whether and where to longjmp to 2500 when a floating arithmetic error happens. */ 2501 2502void 2503pop_float_handler (handled, handler) 2504 int handled; 2505 jmp_buf handler; 2506{ 2507 float_handled = handled; 2508 if (handled) 2509 bcopy ((char *) handler, (char *) float_handler, sizeof (float_handler)); 2510} 2511 2512/* Handler for SIGPIPE. */ 2513 2514static void 2515pipe_closed (signo) 2516 /* If this is missing, some compilers complain. */ 2517 int signo ATTRIBUTE_UNUSED; 2518{ 2519 fatal ("output pipe has been closed"); 2520} 2521 2522/* Strip off a legitimate source ending from the input string NAME of 2523 length LEN. Rather than having to know the names used by all of 2524 our front ends, we strip off an ending of a period followed by 2525 up to five characters. (Java uses ".class".) */ 2526 2527void 2528strip_off_ending (name, len) 2529 char *name; 2530 int len; 2531{ 2532 int i; 2533 for (i = 2; i < 6 && len > i; i++) 2534 { 2535 if (name[len - i] == '.') 2536 { 2537 name[len - i] = '\0'; 2538 break; 2539 } 2540 } 2541} 2542 2543/* Output a quoted string. */ 2544 2545void 2546output_quoted_string (asm_file, string) 2547 FILE *asm_file; 2548 const char *string; 2549{ 2550#ifdef OUTPUT_QUOTED_STRING 2551 OUTPUT_QUOTED_STRING (asm_file, string); 2552#else 2553 char c; 2554 2555 putc ('\"', asm_file); 2556 while ((c = *string++) != 0) 2557 { 2558 if (c == '\"' || c == '\\') 2559 putc ('\\', asm_file); 2560 putc (c, asm_file); 2561 } 2562 putc ('\"', asm_file); 2563#endif 2564} 2565 2566/* Output a file name in the form wanted by System V. */ 2567 2568void 2569output_file_directive (asm_file, input_name) 2570 FILE *asm_file; 2571 const char *input_name; 2572{ 2573 int len = strlen (input_name); 2574 const char *na = input_name + len; 2575 2576 /* NA gets INPUT_NAME sans directory names. */ 2577 while (na > input_name) 2578 { 2579 if (na[-1] == '/') 2580 break; 2581#ifdef DIR_SEPARATOR 2582 if (na[-1] == DIR_SEPARATOR) 2583 break; 2584#endif 2585 na--; 2586 } 2587 2588#ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME 2589 ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na); 2590#else 2591#ifdef ASM_OUTPUT_SOURCE_FILENAME 2592 ASM_OUTPUT_SOURCE_FILENAME (asm_file, na); 2593#else 2594 fprintf (asm_file, "\t.file\t"); 2595 output_quoted_string (asm_file, na); 2596 fputc ('\n', asm_file); 2597#endif 2598#endif 2599} 2600 2601#ifdef ASM_IDENTIFY_LANGUAGE 2602/* Routine to build language identifier for object file. */ 2603static void 2604output_lang_identify (asm_out_file) 2605 FILE *asm_out_file; 2606{ 2607 int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1; 2608 char *s = (char *) alloca (len); 2609 sprintf (s, "__gnu_compiled_%s", lang_identify ()); 2610 ASM_OUTPUT_LABEL (asm_out_file, s); 2611} 2612#endif 2613 2614/* Routine to open a dump file. */ 2615static void 2616open_dump_file (suffix, function_name) 2617 const char *suffix; 2618 const char *function_name; 2619{ 2620 char *dumpname; 2621 2622 TIMEVAR 2623 (dump_time, 2624 { 2625 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1); 2626 2627 if (rtl_dump_file != NULL) 2628 fclose (rtl_dump_file); 2629 2630 strcpy (dumpname, dump_base_name); 2631 strcat (dumpname, suffix); 2632 2633 rtl_dump_file = fopen (dumpname, "a"); 2634 2635 if (rtl_dump_file == NULL) 2636 pfatal_with_name (dumpname); 2637 2638 free (dumpname); 2639 2640 if (function_name) 2641 fprintf (rtl_dump_file, "\n;; Function %s\n\n", function_name); 2642 }); 2643 2644 return; 2645} 2646 2647/* Routine to close a dump file. */ 2648static void 2649close_dump_file (func, insns) 2650 void (*func) PROTO ((FILE *, rtx)); 2651 rtx insns; 2652{ 2653 TIMEVAR 2654 (dump_time, 2655 { 2656 if (func) 2657 func (rtl_dump_file, insns); 2658 2659 fflush (rtl_dump_file); 2660 fclose (rtl_dump_file); 2661 2662 rtl_dump_file = NULL; 2663 }); 2664 2665 return; 2666} 2667 2668/* Routine to dump rtl into a file. */ 2669static void 2670dump_rtl (suffix, decl, func, insns) 2671 const char *suffix; 2672 tree decl; 2673 void (*func) PROTO ((FILE *, rtx)); 2674 rtx insns; 2675{ 2676 open_dump_file (suffix, decl_printable_name (decl, 2)); 2677 close_dump_file (func, insns); 2678} 2679 2680/* Routine to empty a dump file. */ 2681static void 2682clean_dump_file (suffix) 2683 const char *suffix; 2684{ 2685 char *dumpname; 2686 2687 dumpname = (char *) xmalloc (strlen (dump_base_name) + strlen (suffix) + 1); 2688 2689 strcpy (dumpname, dump_base_name); 2690 strcat (dumpname, suffix); 2691 2692 rtl_dump_file = fopen (dumpname, "w"); 2693 2694 if (rtl_dump_file == NULL) 2695 pfatal_with_name (dumpname); 2696 2697 free (dumpname); 2698 2699 fclose (rtl_dump_file); 2700 rtl_dump_file = NULL; 2701 2702 return; 2703} 2704 2705/* Do any final processing required for the declarations in VEC, of 2706 which there are LEN. We write out inline functions and variables 2707 that have been deferred until this point, but which are required. 2708 Returns non-zero if anything was put out. */ 2709int 2710wrapup_global_declarations (vec, len) 2711 tree *vec; 2712 int len; 2713{ 2714 tree decl; 2715 int i; 2716 int reconsider; 2717 int output_something = 0; 2718 2719 for (i = 0; i < len; i++) 2720 { 2721 decl = vec[i]; 2722 2723 /* We're not deferring this any longer. */ 2724 DECL_DEFER_OUTPUT (decl) = 0; 2725 2726 if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0 2727 && incomplete_decl_finalize_hook != 0) 2728 (*incomplete_decl_finalize_hook) (decl); 2729 } 2730 2731 /* Now emit any global variables or functions that we have been 2732 putting off. We need to loop in case one of the things emitted 2733 here references another one which comes earlier in the list. */ 2734 do 2735 { 2736 reconsider = 0; 2737 for (i = 0; i < len; i++) 2738 { 2739 decl = vec[i]; 2740 2741 if (TREE_ASM_WRITTEN (decl) || DECL_EXTERNAL (decl)) 2742 continue; 2743 2744 /* Don't write out static consts, unless we still need them. 2745 2746 We also keep static consts if not optimizing (for debugging), 2747 unless the user specified -fno-keep-static-consts. 2748 ??? They might be better written into the debug information. 2749 This is possible when using DWARF. 2750 2751 A language processor that wants static constants to be always 2752 written out (even if it is not used) is responsible for 2753 calling rest_of_decl_compilation itself. E.g. the C front-end 2754 calls rest_of_decl_compilation from finish_decl. 2755 One motivation for this is that is conventional in some 2756 environments to write things like: 2757 static const char rcsid[] = "... version string ..."; 2758 intending to force the string to be in the executable. 2759 2760 A language processor that would prefer to have unneeded 2761 static constants "optimized away" would just defer writing 2762 them out until here. E.g. C++ does this, because static 2763 constants are often defined in header files. 2764 2765 ??? A tempting alternative (for both C and C++) would be 2766 to force a constant to be written if and only if it is 2767 defined in a main file, as opposed to an include file. */ 2768 2769 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) 2770 && (! TREE_READONLY (decl) 2771 || TREE_PUBLIC (decl) 2772 || (!optimize && flag_keep_static_consts) 2773 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) 2774 { 2775 reconsider = 1; 2776 rest_of_decl_compilation (decl, NULL_PTR, 1, 1); 2777 } 2778 2779 if (TREE_CODE (decl) == FUNCTION_DECL 2780 && DECL_INITIAL (decl) != 0 2781 && DECL_SAVED_INSNS (decl) != 0 2782 && (flag_keep_inline_functions 2783 || (TREE_PUBLIC (decl) && !DECL_COMDAT (decl)) 2784 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl)))) 2785 { 2786 reconsider = 1; 2787 temporary_allocation (); 2788 output_inline_function (decl); 2789 permanent_allocation (1); 2790 } 2791 } 2792 2793 if (reconsider) 2794 output_something = 1; 2795 } 2796 while (reconsider); 2797 2798 return output_something; 2799} 2800 2801/* Issue appropriate warnings for the global declarations in VEC (of 2802 which there are LEN). Output debugging information for them. */ 2803void 2804check_global_declarations (vec, len) 2805 tree *vec; 2806 int len; 2807{ 2808 tree decl; 2809 int i; 2810 2811 for (i = 0; i < len; i++) 2812 { 2813 decl = vec[i]; 2814 2815 if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) 2816 && ! TREE_ASM_WRITTEN (decl)) 2817 /* Cancel the RTL for this decl so that, if debugging info 2818 output for global variables is still to come, 2819 this one will be omitted. */ 2820 DECL_RTL (decl) = NULL; 2821 2822 /* Warn about any function 2823 declared static but not defined. 2824 We don't warn about variables, 2825 because many programs have static variables 2826 that exist only to get some text into the object file. */ 2827 if (TREE_CODE (decl) == FUNCTION_DECL 2828 && (warn_unused 2829 || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) 2830 && DECL_INITIAL (decl) == 0 2831 && DECL_EXTERNAL (decl) 2832 && ! DECL_ARTIFICIAL (decl) 2833 && ! TREE_PUBLIC (decl)) 2834 { 2835 if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))) 2836 pedwarn_with_decl (decl, 2837 "`%s' used but never defined"); 2838 else 2839 warning_with_decl (decl, 2840 "`%s' declared `static' but never defined"); 2841 /* This symbol is effectively an "extern" declaration now. */ 2842 TREE_PUBLIC (decl) = 1; 2843 assemble_external (decl); 2844 } 2845 2846 /* Warn about static fns or vars defined but not used, 2847 but not about inline functions or static consts 2848 since defining those in header files is normal practice. */ 2849 if (warn_unused 2850 && ((TREE_CODE (decl) == FUNCTION_DECL && ! DECL_INLINE (decl)) 2851 || (TREE_CODE (decl) == VAR_DECL && ! TREE_READONLY (decl))) 2852 && ! DECL_IN_SYSTEM_HEADER (decl) 2853 && ! DECL_EXTERNAL (decl) 2854 && ! TREE_PUBLIC (decl) 2855 && ! TREE_USED (decl) 2856 && (TREE_CODE (decl) == FUNCTION_DECL || ! DECL_REGISTER (decl)) 2857 /* The TREE_USED bit for file-scope decls 2858 is kept in the identifier, to handle multiple 2859 external decls in different scopes. */ 2860 && ! TREE_USED (DECL_NAME (decl))) 2861 warning_with_decl (decl, "`%s' defined but not used"); 2862 2863#ifdef SDB_DEBUGGING_INFO 2864 /* The COFF linker can move initialized global vars to the end. 2865 And that can screw up the symbol ordering. 2866 By putting the symbols in that order to begin with, 2867 we avoid a problem. mcsun!unido!fauern!tumuc!pes@uunet.uu.net. */ 2868 if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL 2869 && TREE_PUBLIC (decl) && DECL_INITIAL (decl) 2870 && ! DECL_EXTERNAL (decl) 2871 && DECL_RTL (decl) != 0) 2872 TIMEVAR (symout_time, sdbout_symbol (decl, 0)); 2873 2874 /* Output COFF information for non-global 2875 file-scope initialized variables. */ 2876 if (write_symbols == SDB_DEBUG 2877 && TREE_CODE (decl) == VAR_DECL 2878 && DECL_INITIAL (decl) 2879 && ! DECL_EXTERNAL (decl) 2880 && DECL_RTL (decl) != 0 2881 && GET_CODE (DECL_RTL (decl)) == MEM) 2882 TIMEVAR (symout_time, sdbout_toplevel_data (decl)); 2883#endif /* SDB_DEBUGGING_INFO */ 2884#ifdef DWARF_DEBUGGING_INFO 2885 /* Output DWARF information for file-scope tentative data object 2886 declarations, file-scope (extern) function declarations (which 2887 had no corresponding body) and file-scope tagged type declarations 2888 and definitions which have not yet been forced out. */ 2889 2890 if (write_symbols == DWARF_DEBUG 2891 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) 2892 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1)); 2893#endif 2894#ifdef DWARF2_DEBUGGING_INFO 2895 /* Output DWARF2 information for file-scope tentative data object 2896 declarations, file-scope (extern) function declarations (which 2897 had no corresponding body) and file-scope tagged type declarations 2898 and definitions which have not yet been forced out. */ 2899 2900 if (write_symbols == DWARF2_DEBUG 2901 && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) 2902 TIMEVAR (symout_time, dwarf2out_decl (decl)); 2903#endif 2904 } 2905} 2906 2907/* Compile an entire file of output from cpp, named NAME. 2908 Write a file of assembly output and various debugging dumps. */ 2909 2910static void 2911compile_file (name) 2912 char *name; 2913{ 2914 tree globals; 2915 int start_time; 2916 2917 int name_specified = name != 0; 2918 2919 if (dump_base_name == 0) 2920 dump_base_name = name ? name : "gccdump"; 2921 2922 parse_time = 0; 2923 varconst_time = 0; 2924 integration_time = 0; 2925 jump_time = 0; 2926 cse_time = 0; 2927 gcse_time = 0; 2928 loop_time = 0; 2929 cse2_time = 0; 2930 branch_prob_time = 0; 2931 flow_time = 0; 2932 combine_time = 0; 2933 regmove_time = 0; 2934 sched_time = 0; 2935 local_alloc_time = 0; 2936 global_alloc_time = 0; 2937 flow2_time = 0; 2938 sched2_time = 0; 2939#ifdef DELAY_SLOTS 2940 dbr_sched_time = 0; 2941#endif 2942 shorten_branch_time = 0; 2943 stack_reg_time = 0; 2944 final_time = 0; 2945 symout_time = 0; 2946 dump_time = 0; 2947 2948 /* Initialize data in various passes. */ 2949 2950 init_obstacks (); 2951 init_tree_codes (); 2952 name = init_parse (name); 2953 init_rtl (); 2954 init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL 2955 || debug_info_level == DINFO_LEVEL_VERBOSE 2956 || flag_test_coverage); 2957 init_regs (); 2958 init_decl_processing (); 2959 init_optabs (); 2960 init_stmt (); 2961 init_expmed (); 2962 init_expr_once (); 2963 init_loop (); 2964 init_reload (); 2965 init_alias_once (); 2966 2967 if (flag_caller_saves) 2968 init_caller_save (); 2969 2970 /* If auxiliary info generation is desired, open the output file. 2971 This goes in the same directory as the source file--unlike 2972 all the other output files. */ 2973 if (flag_gen_aux_info) 2974 { 2975 aux_info_file = fopen (aux_info_file_name, "w"); 2976 if (aux_info_file == 0) 2977 pfatal_with_name (aux_info_file_name); 2978 } 2979 2980 /* Clear the dump files. */ 2981 if (rtl_dump) 2982 clean_dump_file (".rtl"); 2983 if (jump_opt_dump) 2984 { 2985 clean_dump_file (".jump"); 2986 if (graph_dump_format != no_graph) 2987 clean_graph_dump_file (dump_base_name, ".jump"); 2988 } 2989 if (addressof_dump) 2990 { 2991 clean_dump_file (".addressof"); 2992 if (graph_dump_format != no_graph) 2993 clean_graph_dump_file (dump_base_name, ".addressof"); 2994 } 2995 if (cse_dump) 2996 { 2997 clean_dump_file (".cse"); 2998 if (graph_dump_format != no_graph) 2999 clean_graph_dump_file (dump_base_name, ".cse"); 3000 } 3001 if (loop_dump) 3002 { 3003 clean_dump_file (".loop"); 3004 if (graph_dump_format != no_graph) 3005 clean_graph_dump_file (dump_base_name, ".loop"); 3006 } 3007 if (cse2_dump) 3008 { 3009 clean_dump_file (".cse2"); 3010 if (graph_dump_format != no_graph) 3011 clean_graph_dump_file (dump_base_name, ".cse2"); 3012 } 3013 if (branch_prob_dump) 3014 { 3015 clean_dump_file (".bp"); 3016 if (graph_dump_format != no_graph) 3017 clean_graph_dump_file (dump_base_name, ".bp"); 3018 } 3019 if (flow_dump) 3020 { 3021 clean_dump_file (".flow"); 3022 if (graph_dump_format != no_graph) 3023 clean_graph_dump_file (dump_base_name, ".flow"); 3024 } 3025 if (combine_dump) 3026 { 3027 clean_dump_file (".combine"); 3028 if (graph_dump_format != no_graph) 3029 clean_graph_dump_file (dump_base_name, ".combine"); 3030 } 3031 if (regmove_dump) 3032 { 3033 clean_dump_file (".regmove"); 3034 if (graph_dump_format != no_graph) 3035 clean_graph_dump_file (dump_base_name, ".regmove"); 3036 } 3037 if (sched_dump) 3038 { 3039 clean_dump_file (".sched"); 3040 if (graph_dump_format != no_graph) 3041 clean_graph_dump_file (dump_base_name, ".sched"); 3042 } 3043 if (local_reg_dump) 3044 { 3045 clean_dump_file (".lreg"); 3046 if (graph_dump_format != no_graph) 3047 clean_graph_dump_file (dump_base_name, ".lreg"); 3048 } 3049 if (global_reg_dump) 3050 { 3051 clean_dump_file (".greg"); 3052 if (graph_dump_format != no_graph) 3053 clean_graph_dump_file (dump_base_name, ".greg"); 3054 } 3055 if (flow2_dump) 3056 { 3057 clean_dump_file (".flow2"); 3058 if (graph_dump_format != no_graph) 3059 clean_graph_dump_file (dump_base_name, ".flow2"); 3060 } 3061 if (sched2_dump) 3062 { 3063 clean_dump_file (".sched2"); 3064 if (graph_dump_format != no_graph) 3065 clean_graph_dump_file (dump_base_name, ".sched2"); 3066 } 3067 if (jump2_opt_dump) 3068 { 3069 clean_dump_file (".jump2"); 3070 if (graph_dump_format != no_graph) 3071 clean_graph_dump_file (dump_base_name, ".jump2"); 3072 } 3073#ifdef DELAY_SLOTS 3074 if (dbr_sched_dump) 3075 { 3076 clean_dump_file (".dbr"); 3077 if (graph_dump_format != no_graph) 3078 clean_graph_dump_file (dump_base_name, ".dbr"); 3079 } 3080#endif 3081 if (gcse_dump) 3082 { 3083 clean_dump_file (".gcse"); 3084 if (graph_dump_format != no_graph) 3085 clean_graph_dump_file (dump_base_name, ".gcse"); 3086 } 3087#ifdef STACK_REGS 3088 if (stack_reg_dump) 3089 { 3090 clean_dump_file (".stack"); 3091 if (graph_dump_format != no_graph) 3092 clean_graph_dump_file (dump_base_name, ".stack"); 3093 } 3094#endif 3095#ifdef MACHINE_DEPENDENT_REORG 3096 if (mach_dep_reorg_dump) 3097 { 3098 clean_dump_file (".mach"); 3099 if (graph_dump_format != no_graph) 3100 clean_graph_dump_file (dump_base_name, ".mach"); 3101 } 3102#endif 3103 3104 /* Open assembler code output file. */ 3105 3106 if (flag_syntax_only) 3107 asm_out_file = NULL; 3108 else 3109 { 3110 if (! name_specified && asm_file_name == 0) 3111 asm_out_file = stdout; 3112 else 3113 { 3114 int len = strlen (dump_base_name); 3115 register char *dumpname = (char *) xmalloc (len + 6); 3116 strcpy (dumpname, dump_base_name); 3117 strip_off_ending (dumpname, len); 3118 strcat (dumpname, ".s"); 3119 if (asm_file_name == 0) 3120 { 3121 asm_file_name = (char *) xmalloc (strlen (dumpname) + 1); 3122 strcpy (asm_file_name, dumpname); 3123 } 3124 if (!strcmp (asm_file_name, "-")) 3125 asm_out_file = stdout; 3126 else 3127 asm_out_file = fopen (asm_file_name, "w"); 3128 if (asm_out_file == 0) 3129 pfatal_with_name (asm_file_name); 3130 } 3131 3132#ifdef IO_BUFFER_SIZE 3133 setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE), 3134 _IOFBF, IO_BUFFER_SIZE); 3135#endif 3136 } 3137 3138 input_filename = name; 3139 3140 /* Put an entry on the input file stack for the main input file. */ 3141 input_file_stack 3142 = (struct file_stack *) xmalloc (sizeof (struct file_stack)); 3143 input_file_stack->next = 0; 3144 input_file_stack->name = input_filename; 3145 3146 /* Perform language-specific initialization. 3147 This may set main_input_filename. */ 3148 lang_init (); 3149 3150 /* If the input doesn't start with a #line, use the input name 3151 as the official input file name. */ 3152 if (main_input_filename == 0) 3153 main_input_filename = name; 3154 3155 if (flag_syntax_only) 3156 { 3157 write_symbols = NO_DEBUG; 3158 profile_flag = 0; 3159 profile_block_flag = 0; 3160 } 3161 else 3162 { 3163 ASM_FILE_START (asm_out_file); 3164 3165#ifdef ASM_COMMENT_START 3166 if (flag_verbose_asm) 3167 { 3168 /* Print the list of options in effect. */ 3169 print_version (asm_out_file, ASM_COMMENT_START); 3170 print_switch_values (asm_out_file, 0, MAX_LINE, 3171 ASM_COMMENT_START, " ", "\n"); 3172 /* Add a blank line here so it appears in assembler output but not 3173 screen output. */ 3174 fprintf (asm_out_file, "\n"); 3175 } 3176#endif 3177 3178 /* Output something to inform GDB that this compilation was by GCC. */ 3179#ifndef ASM_IDENTIFY_GCC 3180 fprintf (asm_out_file, "gcc2_compiled.:\n"); 3181#else 3182 ASM_IDENTIFY_GCC (asm_out_file); 3183#endif 3184 3185 /* Output something to identify which front-end produced this file. */ 3186#ifdef ASM_IDENTIFY_LANGUAGE 3187 ASM_IDENTIFY_LANGUAGE (asm_out_file); 3188#endif 3189 } /* ! flag_syntax_only */ 3190 3191#ifndef ASM_OUTPUT_SECTION_NAME 3192 if (flag_function_sections) 3193 { 3194 warning ("-ffunction-sections not supported for this target."); 3195 flag_function_sections = 0; 3196 } 3197 if (flag_data_sections) 3198 { 3199 warning ("-fdata-sections not supported for this target."); 3200 flag_data_sections = 0; 3201 } 3202#endif 3203 3204 if (flag_function_sections 3205 && (profile_flag || profile_block_flag)) 3206 { 3207 warning ("-ffunction-sections disabled; it makes profiling impossible."); 3208 flag_function_sections = 0; 3209 } 3210 3211#ifndef OBJECT_FORMAT_ELF 3212 if (flag_function_sections && write_symbols != NO_DEBUG) 3213 warning ("-ffunction-sections may affect debugging on some targets."); 3214#endif 3215 3216 /* ??? Note: There used to be a conditional here 3217 to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined. 3218 This was to guarantee separation between gcc_compiled. and 3219 the first function, for the sake of dbx on Suns. 3220 However, having the extra zero here confused the Emacs 3221 code for unexec, and might confuse other programs too. 3222 Therefore, I took out that change. 3223 In future versions we should find another way to solve 3224 that dbx problem. -- rms, 23 May 93. */ 3225 3226 /* Don't let the first function fall at the same address 3227 as gcc_compiled., if profiling. */ 3228 if (profile_flag || profile_block_flag) 3229 { 3230 /* It's best if we can write a nop here since some 3231 assemblers don't tolerate zeros in the text section. */ 3232 if (insn_template[CODE_FOR_nop] != 0) 3233 output_asm_insn (insn_template[CODE_FOR_nop], NULL_PTR); 3234 else 3235 assemble_zeros (UNITS_PER_WORD); 3236 } 3237 3238 /* If dbx symbol table desired, initialize writing it 3239 and output the predefined types. */ 3240#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) 3241 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) 3242 TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename, 3243 getdecls ())); 3244#endif 3245#ifdef SDB_DEBUGGING_INFO 3246 if (write_symbols == SDB_DEBUG) 3247 TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename, 3248 getdecls ())); 3249#endif 3250#ifdef DWARF_DEBUGGING_INFO 3251 if (write_symbols == DWARF_DEBUG) 3252 TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename)); 3253#endif 3254#ifdef DWARF2_UNWIND_INFO 3255 if (dwarf2out_do_frame ()) 3256 dwarf2out_frame_init (); 3257#endif 3258#ifdef DWARF2_DEBUGGING_INFO 3259 if (write_symbols == DWARF2_DEBUG) 3260 TIMEVAR (symout_time, dwarf2out_init (asm_out_file, main_input_filename)); 3261#endif 3262 3263 /* Initialize yet another pass. */ 3264 3265 init_final (main_input_filename); 3266 init_branch_prob (dump_base_name); 3267 3268 start_time = get_run_time (); 3269 3270 /* Call the parser, which parses the entire file 3271 (calling rest_of_compilation for each function). */ 3272 3273 if (yyparse () != 0) 3274 { 3275 if (errorcount == 0) 3276 notice ("Errors detected in input file (your bison.simple is out of date)\n"); 3277 3278 /* In case there were missing closebraces, 3279 get us back to the global binding level. */ 3280 while (! global_bindings_p ()) 3281 poplevel (0, 0, 0); 3282 } 3283 3284 /* Compilation is now finished except for writing 3285 what's left of the symbol table output. */ 3286 3287 parse_time += get_run_time () - start_time; 3288 3289 parse_time -= integration_time; 3290 parse_time -= varconst_time; 3291 3292 if (flag_syntax_only) 3293 goto finish_syntax; 3294 3295 globals = getdecls (); 3296 3297 /* Really define vars that have had only a tentative definition. 3298 Really output inline functions that must actually be callable 3299 and have not been output so far. */ 3300 3301 { 3302 int len = list_length (globals); 3303 tree *vec = (tree *) alloca (sizeof (tree) * len); 3304 int i; 3305 tree decl; 3306 3307 /* Process the decls in reverse order--earliest first. 3308 Put them into VEC from back to front, then take out from front. */ 3309 3310 for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) 3311 vec[len - i - 1] = decl; 3312 3313 wrapup_global_declarations (vec, len); 3314 3315 /* This must occur after the loop to output deferred functions. Else 3316 the profiler initializer would not be emitted if all the functions 3317 in this compilation unit were deferred. 3318 3319 output_func_start_profiler can not cause any additional functions or 3320 data to need to be output, so it need not be in the deferred function 3321 loop above. */ 3322 output_func_start_profiler (); 3323 3324 /* Now that all possible functions have been output, we can dump 3325 the exception table. */ 3326 3327 output_exception_table (); 3328 3329 check_global_declarations (vec, len); 3330 } 3331 3332 /* Write out any pending weak symbol declarations. */ 3333 3334 weak_finish (); 3335 3336 /* Do dbx symbols */ 3337#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) 3338 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) 3339 TIMEVAR (symout_time, 3340 { 3341 dbxout_finish (asm_out_file, main_input_filename); 3342 }); 3343#endif 3344 3345#ifdef DWARF_DEBUGGING_INFO 3346 if (write_symbols == DWARF_DEBUG) 3347 TIMEVAR (symout_time, 3348 { 3349 dwarfout_finish (); 3350 }); 3351#endif 3352 3353#ifdef DWARF2_UNWIND_INFO 3354 if (dwarf2out_do_frame ()) 3355 dwarf2out_frame_finish (); 3356#endif 3357 3358#ifdef DWARF2_DEBUGGING_INFO 3359 if (write_symbols == DWARF2_DEBUG) 3360 TIMEVAR (symout_time, 3361 { 3362 dwarf2out_finish (); 3363 }); 3364#endif 3365 3366 /* Output some stuff at end of file if nec. */ 3367 3368 end_final (dump_base_name); 3369 3370 if (branch_prob_dump) 3371 open_dump_file (".bp", NULL); 3372 3373 TIMEVAR (dump_time, end_branch_prob (rtl_dump_file)); 3374 3375 if (branch_prob_dump) 3376 close_dump_file (NULL, NULL_RTX); 3377 3378#ifdef ASM_FILE_END 3379 ASM_FILE_END (asm_out_file); 3380#endif 3381 3382 3383 /* Language-specific end of compilation actions. */ 3384 finish_syntax: 3385 lang_finish (); 3386 3387 /* Close the dump files. */ 3388 3389 if (flag_gen_aux_info) 3390 { 3391 fclose (aux_info_file); 3392 if (errorcount) 3393 unlink (aux_info_file_name); 3394 } 3395 3396 if (combine_dump) 3397 { 3398 open_dump_file (".combine", NULL); 3399 TIMEVAR (dump_time, dump_combine_total_stats (rtl_dump_file)); 3400 close_dump_file (NULL, NULL_RTX); 3401 } 3402 3403 /* Close non-debugging input and output files. Take special care to note 3404 whether fclose returns an error, since the pages might still be on the 3405 buffer chain while the file is open. */ 3406 3407 finish_parse (); 3408 3409 if (! flag_syntax_only 3410 && (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0)) 3411 fatal_io_error (asm_file_name); 3412 3413 /* Do whatever is necessary to finish printing the graphs. */ 3414 if (graph_dump_format != no_graph) 3415 { 3416 if (jump_opt_dump) 3417 finish_graph_dump_file (dump_base_name, ".jump"); 3418 if (addressof_dump) 3419 finish_graph_dump_file (dump_base_name, ".addressof"); 3420 if (cse_dump) 3421 finish_graph_dump_file (dump_base_name, ".cse"); 3422 if (loop_dump) 3423 finish_graph_dump_file (dump_base_name, ".loop"); 3424 if (cse2_dump) 3425 finish_graph_dump_file (dump_base_name, ".cse2"); 3426 if (branch_prob_dump) 3427 finish_graph_dump_file (dump_base_name, ".bp"); 3428 if (flow_dump) 3429 finish_graph_dump_file (dump_base_name, ".flow"); 3430 if (combine_dump) 3431 finish_graph_dump_file (dump_base_name, ".combine"); 3432 if (regmove_dump) 3433 finish_graph_dump_file (dump_base_name, ".regmove"); 3434 if (sched_dump) 3435 finish_graph_dump_file (dump_base_name, ".sched"); 3436 if (local_reg_dump) 3437 finish_graph_dump_file (dump_base_name, ".lreg"); 3438 if (global_reg_dump) 3439 finish_graph_dump_file (dump_base_name, ".greg"); 3440 if (flow2_dump) 3441 finish_graph_dump_file (dump_base_name, ".flow2"); 3442 if (sched2_dump) 3443 finish_graph_dump_file (dump_base_name, ".sched2"); 3444 if (jump2_opt_dump) 3445 finish_graph_dump_file (dump_base_name, ".jump2"); 3446#ifdef DELAY_SLOTS 3447 if (dbr_sched_dump) 3448 finish_graph_dump_file (dump_base_name, ".dbr"); 3449#endif 3450 if (gcse_dump) 3451 finish_graph_dump_file (dump_base_name, ".gcse"); 3452#ifdef STACK_REGS 3453 if (stack_reg_dump) 3454 finish_graph_dump_file (dump_base_name, ".stack"); 3455#endif 3456#ifdef MACHINE_DEPENDENT_REORG 3457 if (mach_dep_reorg_dump) 3458 finish_graph_dump_file (dump_base_name, ".mach"); 3459#endif 3460 } 3461 3462 /* Free up memory for the benefit of leak detectors. */ 3463 free_reg_info (); 3464 3465 /* Print the times. */ 3466 3467 if (! quiet_flag) 3468 { 3469 fprintf (stderr,"\n"); 3470 print_time ("parse", parse_time); 3471 3472 print_time ("integration", integration_time); 3473 print_time ("jump", jump_time); 3474 print_time ("cse", cse_time); 3475 print_time ("gcse", gcse_time); 3476 print_time ("loop", loop_time); 3477 print_time ("cse2", cse2_time); 3478 print_time ("branch-prob", branch_prob_time); 3479 print_time ("flow", flow_time); 3480 print_time ("combine", combine_time); 3481 print_time ("regmove", regmove_time); 3482 print_time ("sched", sched_time); 3483 print_time ("local-alloc", local_alloc_time); 3484 print_time ("global-alloc", global_alloc_time); 3485 print_time ("flow2", flow2_time); 3486 print_time ("sched2", sched2_time); 3487#ifdef DELAY_SLOTS 3488 print_time ("dbranch", dbr_sched_time); 3489#endif 3490 print_time ("shorten-branch", shorten_branch_time); 3491 print_time ("stack-reg", stack_reg_time); 3492 print_time ("final", final_time); 3493 print_time ("varconst", varconst_time); 3494 print_time ("symout", symout_time); 3495 print_time ("dump", dump_time); 3496 } 3497} 3498 3499/* This is called from various places for FUNCTION_DECL, VAR_DECL, 3500 and TYPE_DECL nodes. 3501 3502 This does nothing for local (non-static) variables. 3503 Otherwise, it sets up the RTL and outputs any assembler code 3504 (label definition, storage allocation and initialization). 3505 3506 DECL is the declaration. If ASMSPEC is nonzero, it specifies 3507 the assembler symbol name to be used. TOP_LEVEL is nonzero 3508 if this declaration is not within a function. */ 3509 3510void 3511rest_of_decl_compilation (decl, asmspec, top_level, at_end) 3512 tree decl; 3513 const char *asmspec; 3514 int top_level; 3515 int at_end; 3516{ 3517 /* Declarations of variables, and of functions defined elsewhere. */ 3518 3519/* The most obvious approach, to put an #ifndef around where 3520 this macro is used, doesn't work since it's inside a macro call. */ 3521#ifndef ASM_FINISH_DECLARE_OBJECT 3522#define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END) 3523#endif 3524 3525 /* Forward declarations for nested functions are not "external", 3526 but we need to treat them as if they were. */ 3527 if (TREE_STATIC (decl) || DECL_EXTERNAL (decl) 3528 || TREE_CODE (decl) == FUNCTION_DECL) 3529 TIMEVAR (varconst_time, 3530 { 3531 make_decl_rtl (decl, asmspec, top_level); 3532 /* Initialized extern variable exists to be replaced 3533 with its value, or represents something that will be 3534 output in another file. */ 3535 if (! (TREE_CODE (decl) == VAR_DECL 3536 && DECL_EXTERNAL (decl) && TREE_READONLY (decl) 3537 && DECL_INITIAL (decl) != 0 3538 && DECL_INITIAL (decl) != error_mark_node)) 3539 /* Don't output anything 3540 when a tentative file-scope definition is seen. 3541 But at end of compilation, do output code for them. */ 3542 if (! (! at_end && top_level 3543 && (DECL_INITIAL (decl) == 0 3544 || DECL_INITIAL (decl) == error_mark_node))) 3545 assemble_variable (decl, top_level, at_end, 0); 3546 if (decl == last_assemble_variable_decl) 3547 { 3548 ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl, 3549 top_level, at_end); 3550 } 3551 }); 3552 else if (DECL_REGISTER (decl) && asmspec != 0) 3553 { 3554 if (decode_reg_name (asmspec) >= 0) 3555 { 3556 DECL_RTL (decl) = 0; 3557 make_decl_rtl (decl, asmspec, top_level); 3558 } 3559 else 3560 error ("invalid register name `%s' for register variable", asmspec); 3561 } 3562#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) 3563 else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) 3564 && TREE_CODE (decl) == TYPE_DECL) 3565 TIMEVAR (symout_time, dbxout_symbol (decl, 0)); 3566#endif 3567#ifdef SDB_DEBUGGING_INFO 3568 else if (write_symbols == SDB_DEBUG && top_level 3569 && TREE_CODE (decl) == TYPE_DECL) 3570 TIMEVAR (symout_time, sdbout_symbol (decl, 0)); 3571#endif 3572} 3573 3574/* Called after finishing a record, union or enumeral type. */ 3575 3576void 3577rest_of_type_compilation (type, toplev) 3578#if defined(DBX_DEBUGGING_INFO) || defined(XCOFF_DEBUGGING_INFO) || defined (SDB_DEBUGGING_INFO) 3579 tree type; 3580 int toplev; 3581#else 3582 tree type ATTRIBUTE_UNUSED; 3583 int toplev ATTRIBUTE_UNUSED; 3584#endif 3585{ 3586#if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) 3587 if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) 3588 TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev)); 3589#endif 3590#ifdef SDB_DEBUGGING_INFO 3591 if (write_symbols == SDB_DEBUG) 3592 TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev)); 3593#endif 3594} 3595 3596/* This is called from finish_function (within yyparse) 3597 after each top-level definition is parsed. 3598 It is supposed to compile that function or variable 3599 and output the assembler code for it. 3600 After we return, the tree storage is freed. */ 3601 3602void 3603rest_of_compilation (decl) 3604 tree decl; 3605{ 3606 register rtx insns; 3607 int start_time = get_run_time (); 3608 int tem; 3609 /* Nonzero if we have saved the original DECL_INITIAL of the function, 3610 to be restored after we finish compiling the function 3611 (for use when compiling inline calls to this function). */ 3612 tree saved_block_tree = 0; 3613 /* Likewise, for DECL_ARGUMENTS. */ 3614 tree saved_arguments = 0; 3615 int failure = 0; 3616 int rebuild_label_notes_after_reload; 3617 3618 /* If we are reconsidering an inline function 3619 at the end of compilation, skip the stuff for making it inline. */ 3620 3621 if (DECL_SAVED_INSNS (decl) == 0) 3622 { 3623 int inlinable = 0; 3624 const char *lose; 3625 3626 /* If requested, consider whether to make this function inline. */ 3627 if (DECL_INLINE (decl) || flag_inline_functions) 3628 TIMEVAR (integration_time, 3629 { 3630 lose = function_cannot_inline_p (decl); 3631 if (lose || ! optimize) 3632 { 3633 if (warn_inline && DECL_INLINE (decl)) 3634 warning_with_decl (decl, lose); 3635 DECL_ABSTRACT_ORIGIN (decl) = 0; 3636 /* Don't really compile an extern inline function. 3637 If we can't make it inline, pretend 3638 it was only declared. */ 3639 if (DECL_EXTERNAL (decl)) 3640 { 3641 DECL_INITIAL (decl) = 0; 3642 goto exit_rest_of_compilation; 3643 } 3644 } 3645 else 3646 /* ??? Note that this has the effect of making it look 3647 like "inline" was specified for a function if we choose 3648 to inline it. This isn't quite right, but it's 3649 probably not worth the trouble to fix. */ 3650 inlinable = DECL_INLINE (decl) = 1; 3651 }); 3652 3653 insns = get_insns (); 3654 3655 /* Dump the rtl code if we are dumping rtl. */ 3656 3657 if (rtl_dump) 3658 { 3659 open_dump_file (".rtl", decl_printable_name (decl, 2)); 3660 3661 if (DECL_SAVED_INSNS (decl)) 3662 fprintf (rtl_dump_file, ";; (integrable)\n\n"); 3663 3664 close_dump_file (print_rtl, insns); 3665 } 3666 3667 /* If we can, defer compiling inlines until EOF. 3668 save_for_inline_copying can be extremely expensive. */ 3669 if (inlinable && ! decl_function_context (decl)) 3670 DECL_DEFER_OUTPUT (decl) = 1; 3671 3672 /* If function is inline, and we don't yet know whether to 3673 compile it by itself, defer decision till end of compilation. 3674 finish_compilation will call rest_of_compilation again 3675 for those functions that need to be output. Also defer those 3676 functions that we are supposed to defer. We cannot defer 3677 functions containing nested functions since the nested function 3678 data is in our non-saved obstack. We cannot defer nested 3679 functions for the same reason. */ 3680 3681 /* If this is a nested inline, remove ADDRESSOF now so we can 3682 finish compiling ourselves. Otherwise, wait until EOF. 3683 We have to do this because the purge_addressof transformation 3684 changes the DECL_RTL for many variables, which confuses integrate. */ 3685 if (inlinable) 3686 { 3687 if (decl_function_context (decl)) 3688 purge_addressof (insns); 3689 else 3690 DECL_DEFER_OUTPUT (decl) = 1; 3691 } 3692 3693 if (! current_function_contains_functions 3694 && (DECL_DEFER_OUTPUT (decl) 3695 || (DECL_INLINE (decl) 3696 && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl) 3697 && ! flag_keep_inline_functions) 3698 || DECL_EXTERNAL (decl))))) 3699 { 3700 DECL_DEFER_OUTPUT (decl) = 1; 3701 3702 /* If -Wreturn-type, we have to do a bit of compilation. 3703 However, if we just fall through we will call 3704 save_for_inline_copying() which results in excessive 3705 memory use. Instead, we just want to call 3706 jump_optimize() to figure out whether or not we can fall 3707 off the end of the function; we do the minimum amount of 3708 work necessary to make that safe. And, we set optimize 3709 to zero to keep jump_optimize from working too hard. */ 3710 if (warn_return_type) 3711 { 3712 int saved_optimize = optimize; 3713 optimize = 0; 3714 find_exception_handler_labels (); 3715 jump_optimize (get_insns(), !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES, 3716 !JUMP_AFTER_REGSCAN); 3717 optimize = saved_optimize; 3718 } 3719 3720#ifdef DWARF_DEBUGGING_INFO 3721 /* Generate the DWARF info for the "abstract" instance 3722 of a function which we may later generate inlined and/or 3723 out-of-line instances of. */ 3724 if (write_symbols == DWARF_DEBUG) 3725 { 3726 set_decl_abstract_flags (decl, 1); 3727 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); 3728 set_decl_abstract_flags (decl, 0); 3729 } 3730#endif 3731#ifdef DWARF2_DEBUGGING_INFO 3732 /* Generate the DWARF2 info for the "abstract" instance 3733 of a function which we may later generate inlined and/or 3734 out-of-line instances of. */ 3735 if (write_symbols == DWARF2_DEBUG) 3736 { 3737 set_decl_abstract_flags (decl, 1); 3738 TIMEVAR (symout_time, dwarf2out_decl (decl)); 3739 set_decl_abstract_flags (decl, 0); 3740 } 3741#endif 3742 TIMEVAR (integration_time, save_for_inline_nocopy (decl)); 3743 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable; 3744 goto exit_rest_of_compilation; 3745 } 3746 3747 /* If we have to compile the function now, save its rtl and subdecls 3748 so that its compilation will not affect what others get. */ 3749 if (inlinable || DECL_DEFER_OUTPUT (decl)) 3750 { 3751#ifdef DWARF_DEBUGGING_INFO 3752 /* Generate the DWARF info for the "abstract" instance of 3753 a function which we will generate an out-of-line instance 3754 of almost immediately (and which we may also later generate 3755 various inlined instances of). */ 3756 if (write_symbols == DWARF_DEBUG) 3757 { 3758 set_decl_abstract_flags (decl, 1); 3759 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); 3760 set_decl_abstract_flags (decl, 0); 3761 } 3762#endif 3763#ifdef DWARF2_DEBUGGING_INFO 3764 /* Generate the DWARF2 info for the "abstract" instance of 3765 a function which we will generate an out-of-line instance 3766 of almost immediately (and which we may also later generate 3767 various inlined instances of). */ 3768 if (write_symbols == DWARF2_DEBUG) 3769 { 3770 set_decl_abstract_flags (decl, 1); 3771 TIMEVAR (symout_time, dwarf2out_decl (decl)); 3772 set_decl_abstract_flags (decl, 0); 3773 } 3774#endif 3775 saved_block_tree = DECL_INITIAL (decl); 3776 saved_arguments = DECL_ARGUMENTS (decl); 3777 TIMEVAR (integration_time, save_for_inline_copying (decl)); 3778 RTX_INTEGRATED_P (DECL_SAVED_INSNS (decl)) = inlinable; 3779 } 3780 3781 /* If specified extern inline but we aren't inlining it, we are 3782 done. This goes for anything that gets here with DECL_EXTERNAL 3783 set, not just things with DECL_INLINE. */ 3784 if (DECL_EXTERNAL (decl)) 3785 goto exit_rest_of_compilation; 3786 } 3787 3788 if (! DECL_DEFER_OUTPUT (decl)) 3789 TREE_ASM_WRITTEN (decl) = 1; 3790 3791 /* Now that integrate will no longer see our rtl, we need not distinguish 3792 between the return value of this function and the return value of called 3793 functions. */ 3794 rtx_equal_function_value_matters = 0; 3795 3796 /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */ 3797 if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type) 3798 { 3799 goto exit_rest_of_compilation; 3800 } 3801 3802 /* Emit code to get eh context, if needed. */ 3803 emit_eh_context (); 3804 3805#ifdef FINALIZE_PIC 3806 /* If we are doing position-independent code generation, now 3807 is the time to output special prologues and epilogues. 3808 We do not want to do this earlier, because it just clutters 3809 up inline functions with meaningless insns. */ 3810 if (flag_pic) 3811 FINALIZE_PIC; 3812#endif 3813 3814 /* From now on, allocate rtl in current_obstack, not in saveable_obstack. 3815 Note that that may have been done above, in save_for_inline_copying. 3816 The call to resume_temporary_allocation near the end of this function 3817 goes back to the usual state of affairs. This must be done after 3818 we've built up any unwinders for exception handling, and done 3819 the FINALIZE_PIC work, if necessary. */ 3820 3821 rtl_in_current_obstack (); 3822 3823 insns = get_insns (); 3824 3825 /* Copy any shared structure that should not be shared. */ 3826 3827 unshare_all_rtl (current_function_decl, insns); 3828 3829#ifdef SETJMP_VIA_SAVE_AREA 3830 /* This must be performed before virutal register instantiation. */ 3831 if (current_function_calls_alloca) 3832 optimize_save_area_alloca (insns); 3833#endif 3834 3835 /* Instantiate all virtual registers. */ 3836 3837 instantiate_virtual_regs (current_function_decl, get_insns ()); 3838 3839 /* See if we have allocated stack slots that are not directly addressable. 3840 If so, scan all the insns and create explicit address computation 3841 for all references to such slots. */ 3842/* fixup_stack_slots (); */ 3843 3844 /* Find all the EH handlers. */ 3845 find_exception_handler_labels (); 3846 3847 /* Always do one jump optimization pass to ensure that JUMP_LABEL fields 3848 are initialized and to compute whether control can drop off the end 3849 of the function. */ 3850 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); 3851 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, !JUMP_NOOP_MOVES, 3852 JUMP_AFTER_REGSCAN)); 3853 3854 /* Now is when we stop if -fsyntax-only and -Wreturn-type. */ 3855 if (rtl_dump_and_exit || flag_syntax_only || DECL_DEFER_OUTPUT (decl)) 3856 goto exit_rest_of_compilation; 3857 3858 /* Dump rtl code after jump, if we are doing that. */ 3859 3860 if (jump_opt_dump) 3861 dump_rtl (".jump", decl, print_rtl, insns); 3862 3863 /* Perform common subexpression elimination. 3864 Nonzero value from `cse_main' means that jumps were simplified 3865 and some code may now be unreachable, so do 3866 jump optimization again. */ 3867 3868 if (optimize > 0) 3869 { 3870 if (cse_dump) 3871 open_dump_file (".cse", decl_printable_name (decl, 2)); 3872 3873 TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1)); 3874 3875 if (flag_thread_jumps) 3876 /* Hacks by tiemann & kenner. */ 3877 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 1)); 3878 3879 TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), 3880 0, rtl_dump_file)); 3881 if (tem || optimize > 1) 3882 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, 3883 !JUMP_NOOP_MOVES, 3884 !JUMP_AFTER_REGSCAN)); 3885 3886 /* Run this after jump optmizations remove all the unreachable code 3887 so that unreachable code will not keep values live. */ 3888 TIMEVAR (cse_time, delete_trivially_dead_insns (insns, max_reg_num ())); 3889 3890 /* Dump rtl code after cse, if we are doing that. */ 3891 3892 if (cse_dump) 3893 { 3894 close_dump_file (print_rtl, insns); 3895 if (graph_dump_format != no_graph) 3896 print_rtl_graph_with_bb (dump_base_name, ".cse", insns); 3897 } 3898 } 3899 3900 purge_addressof (insns); 3901 reg_scan (insns, max_reg_num (), 1); 3902 3903 if (addressof_dump) 3904 { 3905 dump_rtl (".addressof", decl, print_rtl, insns); 3906 if (graph_dump_format != no_graph) 3907 print_rtl_graph_with_bb (dump_base_name, ".addressof", insns); 3908 } 3909 3910 /* Perform global cse. */ 3911 3912 if (optimize > 0 && flag_gcse) 3913 { 3914 if (gcse_dump) 3915 open_dump_file (".gcse", IDENTIFIER_POINTER (DECL_NAME (decl))); 3916 3917 TIMEVAR (gcse_time, tem = gcse_main (insns, rtl_dump_file)); 3918 3919 /* If gcse altered any jumps, rerun jump optimizations to clean 3920 things up. */ 3921 if (tem) 3922 { 3923 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, 3924 !JUMP_NOOP_MOVES, 3925 !JUMP_AFTER_REGSCAN)); 3926 } 3927 3928 if (gcse_dump) 3929 { 3930 close_dump_file (print_rtl, insns); 3931 if (graph_dump_format != no_graph) 3932 print_rtl_graph_with_bb (dump_base_name, ".gcse", insns); 3933 } 3934 } 3935 /* Move constant computations out of loops. */ 3936 3937 if (optimize > 0) 3938 { 3939 if (loop_dump) 3940 open_dump_file (".loop", decl_printable_name (decl, 2)); 3941 3942 TIMEVAR 3943 (loop_time, 3944 { 3945 if (flag_rerun_loop_opt) 3946 { 3947 /* We only want to perform unrolling once. */ 3948 3949 loop_optimize (insns, rtl_dump_file, 0, 0); 3950 3951 3952 /* The first call to loop_optimize makes some instructions 3953 trivially dead. We delete those instructions now in the 3954 hope that doing so will make the heuristics in loop work 3955 better and possibly speed up compilation. */ 3956 delete_trivially_dead_insns (insns, max_reg_num ()); 3957 3958 /* The regscan pass is currently necessary as the alias 3959 analysis code depends on this information. */ 3960 reg_scan (insns, max_reg_num (), 1); 3961 } 3962 loop_optimize (insns, rtl_dump_file, flag_unroll_loops, 1); 3963 }); 3964 3965 /* Dump rtl code after loop opt, if we are doing that. */ 3966 3967 if (loop_dump) 3968 { 3969 close_dump_file (print_rtl, insns); 3970 if (graph_dump_format != no_graph) 3971 print_rtl_graph_with_bb (dump_base_name, ".loop", insns); 3972 } 3973 } 3974 3975 if (optimize > 0) 3976 { 3977 if (cse2_dump) 3978 open_dump_file (".cse2", decl_printable_name (decl, 2)); 3979 3980 if (flag_rerun_cse_after_loop) 3981 { 3982 /* Running another jump optimization pass before the second 3983 cse pass sometimes simplifies the RTL enough to allow 3984 the second CSE pass to do a better job. Jump_optimize can change 3985 max_reg_num so we must rerun reg_scan afterwards. 3986 ??? Rework to not call reg_scan so often. */ 3987 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); 3988 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, 3989 !JUMP_NOOP_MOVES, 3990 JUMP_AFTER_REGSCAN)); 3991 3992 TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0)); 3993 TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (), 3994 1, rtl_dump_file)); 3995 if (tem) 3996 TIMEVAR (jump_time, jump_optimize (insns, !JUMP_CROSS_JUMP, 3997 !JUMP_NOOP_MOVES, 3998 !JUMP_AFTER_REGSCAN)); 3999 } 4000 4001 if (flag_thread_jumps) 4002 { 4003 /* This pass of jump threading straightens out code 4004 that was kinked by loop optimization. */ 4005 TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); 4006 TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); 4007 } 4008 4009 /* Dump rtl code after cse, if we are doing that. */ 4010 4011 if (cse2_dump) 4012 { 4013 close_dump_file (print_rtl, insns); 4014 if (graph_dump_format != no_graph) 4015 print_rtl_graph_with_bb (dump_base_name, ".cse2", insns); 4016 } 4017 } 4018 4019 if (profile_arc_flag || flag_test_coverage || flag_branch_probabilities) 4020 { 4021 if (branch_prob_dump) 4022 open_dump_file (".bp", decl_printable_name (decl, 2)); 4023 4024 TIMEVAR 4025 (branch_prob_time, 4026 { 4027 branch_prob (insns, rtl_dump_file); 4028 }); 4029 4030 if (branch_prob_dump) 4031 { 4032 close_dump_file (print_rtl, insns); 4033 if (graph_dump_format != no_graph) 4034 print_rtl_graph_with_bb (dump_base_name, ".bp", insns); 4035 } 4036 } 4037 4038 /* We are no longer anticipating cse in this function, at least. */ 4039 4040 cse_not_expected = 1; 4041 4042 /* Now we choose between stupid (pcc-like) register allocation 4043 (if we got the -noreg switch and not -opt) 4044 and smart register allocation. */ 4045 4046 if (optimize > 0) /* Stupid allocation probably won't work */ 4047 obey_regdecls = 0; /* if optimizations being done. */ 4048 4049 regclass_init (); 4050 4051 /* Print function header into flow dump now 4052 because doing the flow analysis makes some of the dump. */ 4053 4054 if (flow_dump) 4055 open_dump_file (".flow", decl_printable_name (decl, 2)); 4056 4057 if (obey_regdecls) 4058 { 4059 TIMEVAR (flow_time, 4060 { 4061 regclass (insns, max_reg_num ()); 4062 stupid_life_analysis (insns, max_reg_num (), 4063 rtl_dump_file); 4064 }); 4065 } 4066 else 4067 { 4068 /* Do control and data flow analysis, 4069 and write some of the results to dump file. */ 4070 4071 TIMEVAR 4072 (flow_time, 4073 { 4074 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1); 4075 life_analysis (insns, max_reg_num (), rtl_dump_file, 1); 4076 }); 4077 4078 if (warn_uninitialized) 4079 { 4080 uninitialized_vars_warning (DECL_INITIAL (decl)); 4081 setjmp_args_warning (); 4082 } 4083 } 4084 4085 /* Dump rtl after flow analysis. */ 4086 4087 if (flow_dump) 4088 { 4089 close_dump_file (print_rtl_with_bb, insns); 4090 if (graph_dump_format != no_graph) 4091 print_rtl_graph_with_bb (dump_base_name, ".flow", insns); 4092 } 4093 4094 /* The first life analysis pass has finished. From now on we can not 4095 generate any new pseudos. */ 4096 no_new_pseudos = 1; 4097 4098 /* If -opt, try combining insns through substitution. */ 4099 4100 if (optimize > 0) 4101 { 4102 TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); 4103 4104 /* Dump rtl code after insn combination. */ 4105 4106 if (combine_dump) 4107 { 4108 dump_rtl (".combine", decl, print_rtl_with_bb, insns); 4109 if (graph_dump_format != no_graph) 4110 print_rtl_graph_with_bb (dump_base_name, ".combine", insns); 4111 } 4112 } 4113 4114 /* Register allocation pre-pass, to reduce number of moves 4115 necessary for two-address machines. */ 4116 if (optimize > 0 && (flag_regmove || flag_expensive_optimizations)) 4117 { 4118 if (regmove_dump) 4119 open_dump_file (".regmove", decl_printable_name (decl, 2)); 4120 4121 TIMEVAR (regmove_time, regmove_optimize (insns, max_reg_num (), 4122 rtl_dump_file)); 4123 4124 if (regmove_dump) 4125 { 4126 close_dump_file (print_rtl_with_bb, insns); 4127 if (graph_dump_format != no_graph) 4128 print_rtl_graph_with_bb (dump_base_name, ".regmove", insns); 4129 } 4130 } 4131 4132 /* Print function header into sched dump now 4133 because doing the sched analysis makes some of the dump. */ 4134 4135 if (optimize > 0 && flag_schedule_insns) 4136 { 4137 if (sched_dump) 4138 open_dump_file (".sched", decl_printable_name (decl, 2)); 4139 4140 /* Do control and data sched analysis, 4141 and write some of the results to dump file. */ 4142 4143 TIMEVAR (sched_time, schedule_insns (rtl_dump_file)); 4144 4145 /* Dump rtl after instruction scheduling. */ 4146 4147 if (sched_dump) 4148 { 4149 close_dump_file (print_rtl_with_bb, insns); 4150 if (graph_dump_format != no_graph) 4151 print_rtl_graph_with_bb (dump_base_name, ".sched", insns); 4152 } 4153 } 4154 4155 /* Determine if the current function is a leaf before running reload 4156 since this can impact optimizations done by the prologue and 4157 epilogue thus changing register elimination offsets. */ 4158 current_function_is_leaf = leaf_function_p (); 4159 4160 /* Unless we did stupid register allocation, 4161 allocate pseudo-regs that are used only within 1 basic block. 4162 4163 RUN_JUMP_AFTER_RELOAD records whether or not we need to rerun the 4164 jump optimizer after register allocation and reloading are finished. */ 4165 4166 if (!obey_regdecls) 4167 TIMEVAR (local_alloc_time, 4168 { 4169 recompute_reg_usage (insns, ! optimize_size); 4170 regclass (insns, max_reg_num ()); 4171 rebuild_label_notes_after_reload = local_alloc (); 4172 }); 4173 else 4174 rebuild_label_notes_after_reload = 0; 4175 4176 /* Dump rtl code after allocating regs within basic blocks. */ 4177 4178 if (local_reg_dump) 4179 { 4180 open_dump_file (".lreg", decl_printable_name (decl, 2)); 4181 4182 TIMEVAR (dump_time, dump_flow_info (rtl_dump_file)); 4183 TIMEVAR (dump_time, dump_local_alloc (rtl_dump_file)); 4184 4185 close_dump_file (print_rtl_with_bb, insns); 4186 if (graph_dump_format != no_graph) 4187 print_rtl_graph_with_bb (dump_base_name, ".lreg", insns); 4188 } 4189 4190 if (global_reg_dump) 4191 open_dump_file (".greg", decl_printable_name (decl, 2)); 4192 4193 /* Unless we did stupid register allocation, 4194 allocate remaining pseudo-regs, then do the reload pass 4195 fixing up any insns that are invalid. */ 4196 4197 TIMEVAR (global_alloc_time, 4198 { 4199 if (!obey_regdecls) 4200 failure = global_alloc (rtl_dump_file); 4201 else 4202 failure = reload (insns, 0, rtl_dump_file); 4203 }); 4204 4205 4206 if (failure) 4207 goto exit_rest_of_compilation; 4208 4209 /* Do a very simple CSE pass over just the hard registers. */ 4210 if (optimize > 0) 4211 reload_cse_regs (insns); 4212 4213 /* Register allocation and reloading may have turned an indirect jump into 4214 a direct jump. If so, we must rebuild the JUMP_LABEL fields of 4215 jumping instructions. */ 4216 if (rebuild_label_notes_after_reload) 4217 TIMEVAR (jump_time, rebuild_jump_labels (insns)); 4218 4219 /* If optimizing and we are performing instruction scheduling after 4220 reload, then go ahead and split insns now since we are about to 4221 recompute flow information anyway. 4222 4223 reload_cse_regs may expose more splitting opportunities, expecially 4224 for double-word operations. */ 4225 if (optimize > 0 && flag_schedule_insns_after_reload) 4226 { 4227 rtx insn; 4228 4229 for (insn = insns; insn; insn = NEXT_INSN (insn)) 4230 { 4231 rtx last; 4232 4233 if (GET_RTX_CLASS (GET_CODE (insn)) != 'i') 4234 continue; 4235 4236 last = try_split (PATTERN (insn), insn, 1); 4237 4238 if (last != insn) 4239 { 4240 PUT_CODE (insn, NOTE); 4241 NOTE_SOURCE_FILE (insn) = 0; 4242 NOTE_LINE_NUMBER (insn) = NOTE_INSN_DELETED; 4243 } 4244 } 4245 } 4246 4247 if (global_reg_dump) 4248 { 4249 TIMEVAR (dump_time, dump_global_regs (rtl_dump_file)); 4250 close_dump_file (print_rtl_with_bb, insns); 4251 if (graph_dump_format != no_graph) 4252 print_rtl_graph_with_bb (dump_base_name, ".greg", insns); 4253 } 4254 4255 /* Re-create the death notes which were deleted during reload. */ 4256 if (flow2_dump) 4257 open_dump_file (".flow2", decl_printable_name (decl, 2)); 4258 4259 if (optimize) 4260 { 4261 TIMEVAR 4262 (flow2_time, 4263 { 4264 find_basic_blocks (insns, max_reg_num (), rtl_dump_file, 1); 4265 life_analysis (insns, max_reg_num (), rtl_dump_file, 1); 4266 }); 4267 } 4268 4269 flow2_completed = 1; 4270 4271 /* On some machines, the prologue and epilogue code, or parts thereof, 4272 can be represented as RTL. Doing so lets us schedule insns between 4273 it and the rest of the code and also allows delayed branch 4274 scheduling to operate in the epilogue. */ 4275 4276 thread_prologue_and_epilogue_insns (insns); 4277 4278 if (flow2_dump) 4279 { 4280 close_dump_file (print_rtl_with_bb, insns); 4281 if (graph_dump_format != no_graph) 4282 print_rtl_graph_with_bb (dump_base_name, ".flow2", insns); 4283 } 4284 4285 if (optimize > 0 && flag_schedule_insns_after_reload) 4286 { 4287 if (sched2_dump) 4288 open_dump_file (".sched2", decl_printable_name (decl, 2)); 4289 4290 /* Do control and data sched analysis again, 4291 and write some more of the results to dump file. */ 4292 4293 TIMEVAR (sched2_time, schedule_insns (rtl_dump_file)); 4294 4295 /* Dump rtl after post-reorder instruction scheduling. */ 4296 4297 if (sched2_dump) 4298 { 4299 close_dump_file (print_rtl_with_bb, insns); 4300 if (graph_dump_format != no_graph) 4301 print_rtl_graph_with_bb (dump_base_name, ".sched2", insns); 4302 } 4303 } 4304 4305#ifdef LEAF_REGISTERS 4306 current_function_uses_only_leaf_regs 4307 = optimize > 0 && only_leaf_regs_used () && leaf_function_p (); 4308#endif 4309 4310 /* One more attempt to remove jumps to .+1 4311 left by dead-store-elimination. 4312 Also do cross-jumping this time 4313 and delete no-op move insns. */ 4314 4315 if (optimize > 0) 4316 { 4317 TIMEVAR (jump_time, jump_optimize (insns, JUMP_CROSS_JUMP, 4318 JUMP_NOOP_MOVES, 4319 !JUMP_AFTER_REGSCAN)); 4320 4321 /* Dump rtl code after jump, if we are doing that. */ 4322 4323 if (jump2_opt_dump) 4324 { 4325 dump_rtl (".jump2", decl, print_rtl_with_bb, insns); 4326 if (graph_dump_format != no_graph) 4327 print_rtl_graph_with_bb (dump_base_name, ".jump2", insns); 4328 } 4329 } 4330 4331 /* If a machine dependent reorganization is needed, call it. */ 4332#ifdef MACHINE_DEPENDENT_REORG 4333 MACHINE_DEPENDENT_REORG (insns); 4334 4335 if (mach_dep_reorg_dump) 4336 { 4337 dump_rtl (".mach", decl, print_rtl_with_bb, insns); 4338 if (graph_dump_format != no_graph) 4339 print_rtl_graph_with_bb (dump_base_name, ".mach", insns); 4340 } 4341#endif 4342 4343 /* If a scheduling pass for delayed branches is to be done, 4344 call the scheduling code. */ 4345 4346#ifdef DELAY_SLOTS 4347 if (optimize > 0 && flag_delayed_branch) 4348 { 4349 if (dbr_sched_dump) 4350 open_dump_file (".dbr", decl_printable_name (decl, 2)); 4351 4352 TIMEVAR (dbr_sched_time, dbr_schedule (insns, rtl_dump_file)); 4353 4354 if (dbr_sched_dump) 4355 { 4356 close_dump_file (print_rtl_with_bb, insns); 4357 if (graph_dump_format != no_graph) 4358 print_rtl_graph_with_bb (dump_base_name, ".dbr", insns); 4359 } 4360 } 4361#endif 4362 4363 /* Shorten branches. */ 4364 TIMEVAR (shorten_branch_time, 4365 { 4366 shorten_branches (get_insns ()); 4367 }); 4368 4369#ifdef STACK_REGS 4370 if (stack_reg_dump) 4371 open_dump_file (".stack", decl_printable_name (decl, 2)); 4372 4373 TIMEVAR (stack_reg_time, reg_to_stack (insns, rtl_dump_file)); 4374 4375 if (stack_reg_dump) 4376 { 4377 dump_rtl (".stack", decl, print_rtl_with_bb, insns); 4378 if (graph_dump_format != no_graph) 4379 print_rtl_graph_with_bb (dump_base_name, ".stack", insns); 4380 } 4381#endif 4382 4383 /* Now turn the rtl into assembler code. */ 4384 4385 TIMEVAR (final_time, 4386 { 4387 rtx x; 4388 char *fnname; 4389 4390 /* Get the function's name, as described by its RTL. 4391 This may be different from the DECL_NAME name used 4392 in the source file. */ 4393 4394 x = DECL_RTL (decl); 4395 if (GET_CODE (x) != MEM) 4396 abort (); 4397 x = XEXP (x, 0); 4398 if (GET_CODE (x) != SYMBOL_REF) 4399 abort (); 4400 fnname = XSTR (x, 0); 4401 4402 assemble_start_function (decl, fnname); 4403 final_start_function (insns, asm_out_file, optimize); 4404 final (insns, asm_out_file, optimize, 0); 4405 final_end_function (insns, asm_out_file, optimize); 4406 assemble_end_function (decl, fnname); 4407 if (! quiet_flag) 4408 fflush (asm_out_file); 4409 4410 /* Release all memory allocated by flow. */ 4411 free_basic_block_vars (0); 4412 4413 /* Release all memory held by regsets now */ 4414 regset_release_memory (); 4415 }); 4416 4417 /* Write DBX symbols if requested */ 4418 4419 /* Note that for those inline functions where we don't initially 4420 know for certain that we will be generating an out-of-line copy, 4421 the first invocation of this routine (rest_of_compilation) will 4422 skip over this code by doing a `goto exit_rest_of_compilation;'. 4423 Later on, finish_compilation will call rest_of_compilation again 4424 for those inline functions that need to have out-of-line copies 4425 generated. During that call, we *will* be routed past here. */ 4426 4427#ifdef DBX_DEBUGGING_INFO 4428 if (write_symbols == DBX_DEBUG) 4429 TIMEVAR (symout_time, dbxout_function (decl)); 4430#endif 4431 4432#ifdef DWARF_DEBUGGING_INFO 4433 if (write_symbols == DWARF_DEBUG) 4434 TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); 4435#endif 4436 4437#ifdef DWARF2_DEBUGGING_INFO 4438 if (write_symbols == DWARF2_DEBUG) 4439 TIMEVAR (symout_time, dwarf2out_decl (decl)); 4440#endif 4441 4442 exit_rest_of_compilation: 4443 4444 free_bb_mem (); 4445 4446 /* In case the function was not output, 4447 don't leave any temporary anonymous types 4448 queued up for sdb output. */ 4449#ifdef SDB_DEBUGGING_INFO 4450 if (write_symbols == SDB_DEBUG) 4451 sdbout_types (NULL_TREE); 4452#endif 4453 4454 /* Put back the tree of subblocks and list of arguments 4455 from before we copied them. 4456 Code generation and the output of debugging info may have modified 4457 the copy, but the original is unchanged. */ 4458 4459 if (saved_block_tree != 0) 4460 { 4461 DECL_INITIAL (decl) = saved_block_tree; 4462 DECL_ARGUMENTS (decl) = saved_arguments; 4463 DECL_ABSTRACT_ORIGIN (decl) = NULL_TREE; 4464 } 4465 4466 reload_completed = 0; 4467 flow2_completed = 0; 4468 no_new_pseudos = 0; 4469 4470 TIMEVAR (final_time, 4471 { 4472 /* Clear out the insn_length contents now that they are no 4473 longer valid. */ 4474 init_insn_lengths (); 4475 4476 /* Clear out the real_constant_chain before some of the rtx's 4477 it runs through become garbage. */ 4478 clear_const_double_mem (); 4479 4480 /* Cancel the effect of rtl_in_current_obstack. */ 4481 resume_temporary_allocation (); 4482 4483 /* Show no temporary slots allocated. */ 4484 init_temp_slots (); 4485 }); 4486 4487 /* Make sure volatile mem refs aren't considered valid operands for 4488 arithmetic insns. We must call this here if this is a nested inline 4489 function, since the above code leaves us in the init_recog state 4490 (from final.c), and the function context push/pop code does not 4491 save/restore volatile_ok. 4492 4493 ??? Maybe it isn't necessary for expand_start_function to call this 4494 anymore if we do it here? */ 4495 4496 init_recog_no_volatile (); 4497 4498 /* The parsing time is all the time spent in yyparse 4499 *except* what is spent in this function. */ 4500 4501 parse_time -= get_run_time () - start_time; 4502 4503 /* Reset global variables. */ 4504 free_basic_block_vars (0); 4505} 4506 4507static void 4508display_help () 4509{ 4510 int undoc; 4511 unsigned long i; 4512 const char * lang; 4513 4514#ifndef USE_CPPLIB 4515 printf ("Usage: %s input [switches]\n", progname); 4516 printf ("Switches:\n"); 4517#endif 4518 printf (" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"); 4519 printf (" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"); 4520 printf (" -fcall-saved-<register> Mark <register> as being preserved across functions\n"); 4521 printf (" -finline-limit-<number> Limits the size of inlined functions to <number>\n"); 4522 4523 for (i = NUM_ELEM (f_options); i--;) 4524 { 4525 const char * description = f_options[i].description; 4526 4527 if (description != NULL && * description != 0) 4528 printf (" -f%-21s %s\n", 4529 f_options[i].string, description); 4530 } 4531 4532 printf (" -O[number] Set optimisation level to [number]\n"); 4533 printf (" -Os Optimise for space rather than speed\n"); 4534 printf (" -pedantic Issue warnings needed by strict compliance to ANSI C\n"); 4535 printf (" -pedantic-errors Like -pedantic except that errors are produced\n"); 4536 printf (" -w Suppress warnings\n"); 4537 printf (" -W Enable extra warnings\n"); 4538 4539 for (i = NUM_ELEM (W_options); i--;) 4540 { 4541 const char * description = W_options[i].description; 4542 4543 if (description != NULL && * description != 0) 4544 printf (" -W%-21s %s\n", 4545 W_options[i].string, description); 4546 } 4547 4548 printf (" -Wid-clash-<num> Warn if 2 identifiers have the same first <num> chars\n"); 4549 printf (" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"); 4550 printf (" -p Enable function profiling\n"); 4551#if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) 4552 printf (" -a Enable block profiling \n"); 4553#endif 4554#if defined (BLOCK_PROFILER) || defined (FUNCTION_BLOCK_PROFILER) || defined FUNCTION_BLOCK_PROFILER_EXIT 4555 printf (" -ax Enable jump profiling \n"); 4556#endif 4557 printf (" -o <file> Place output into <file> \n"); 4558 printf (" -G <number> Put global and static data smaller than <number>\n"); 4559 printf (" bytes into a special section (on some targets)\n"); 4560 4561 for (i = NUM_ELEM (debug_args); i--;) 4562 { 4563 if (debug_args[i].description != NULL) 4564 printf (" -%-22s %s\n", debug_args[i].arg, debug_args[i].description); 4565 } 4566 4567 printf (" -aux-info <file> Emit declaration info into <file>.X\n"); 4568 printf (" -quiet Do not display functions compiled or elapsed time\n"); 4569 printf (" -version Display the compiler's version\n"); 4570 printf (" -d[letters] Enable dumps from specific passes of the compiler\n"); 4571 printf (" -dumpbase <file> Base name to be used for dumps from specific passes\n"); 4572#if defined HAIFA || defined INSN_SCHEDULING 4573 printf (" -sched-verbose-<number> Set the verbosity level of the scheduler\n"); 4574#endif 4575 printf (" --help Display this information\n"); 4576 4577 undoc = 0; 4578 lang = "language"; 4579 4580 /* Display descriptions of language specific options. 4581 If there is no description, note that there is an undocumented option. 4582 If the description is empty, do not display anything. (This allows 4583 options to be deliberately undocumented, for whatever reason). 4584 If the option string is missing, then this is a marker, indicating 4585 that the description string is in fact the name of a language, whose 4586 language specific options are to follow. */ 4587 4588 if (NUM_ELEM (documented_lang_options) > 1) 4589 { 4590 printf ("\nLanguage specific options:\n"); 4591 4592 for (i = 0; i < NUM_ELEM (documented_lang_options); i++) 4593 { 4594 const char * description = documented_lang_options[i].description; 4595 const char * option = documented_lang_options[i].option; 4596 4597 if (description == NULL) 4598 { 4599 undoc = 1; 4600 4601 if (extra_warnings) 4602 printf (" %-23.23s [undocumented]\n", option); 4603 } 4604 else if (* description == 0) 4605 continue; 4606 else if (option == NULL) 4607 { 4608 if (undoc) 4609 printf 4610 ("\nThere are undocumented %s specific options as well.\n", 4611 lang); 4612 undoc = 0; 4613 4614 printf ("\n Options for %s:\n", description); 4615 4616 lang = description; 4617 } 4618 else 4619 printf (" %-23.23s %s\n", option, description); 4620 } 4621 } 4622 4623 if (undoc) 4624 printf ("\nThere are undocumented %s specific options as well.\n", lang); 4625 4626 if (NUM_ELEM (target_switches) > 1 4627#ifdef TARGET_OPTIONS 4628 || NUM_ELEM (target_options) > 1 4629#endif 4630 ) 4631 { 4632 int doc = 0; 4633 4634 undoc = 0; 4635 4636 printf ("\nTarget specific options:\n"); 4637 4638 for (i = NUM_ELEM (target_switches); i--;) 4639 { 4640 const char * option = target_switches[i].name; 4641 const char * description = target_switches[i].description; 4642 4643 if (option == NULL || * option == 0) 4644 continue; 4645 else if (description == NULL) 4646 { 4647 undoc = 1; 4648 4649 if (extra_warnings) 4650 printf (" -m%-21.21s [undocumented]\n", option); 4651 } 4652 else if (* description != 0) 4653 doc += printf (" -m%-21.21s %s\n", option, description); 4654 } 4655 4656#ifdef TARGET_OPTIONS 4657 for (i = NUM_ELEM (target_options); i--;) 4658 { 4659 const char * option = target_options[i].prefix; 4660 const char * description = target_options[i].description; 4661 4662 if (option == NULL || * option == 0) 4663 continue; 4664 else if (description == NULL) 4665 { 4666 undoc = 1; 4667 4668 if (extra_warnings) 4669 printf (" -m%-21.21s [undocumented]\n", option); 4670 } 4671 else if (* description != 0) 4672 doc += printf (" -m%-21.21s %s\n", option, description); 4673 } 4674#endif 4675 if (undoc) 4676 { 4677 if (doc) 4678 printf ("\nThere are undocumented target specific options as well.\n"); 4679 else 4680 printf (" They exist, but they are not documented.\n"); 4681 } 4682 } 4683} 4684 4685/* Compare the user specified 'option' with the language 4686 specific 'lang_option'. Return true if they match, or 4687 if 'option' is a viable prefix of 'lang_option'. */ 4688 4689static int 4690check_lang_option (option, lang_option) 4691 char * option; 4692 char * lang_option; 4693{ 4694 lang_independent_options * indep_options; 4695 int len; 4696 int numopts; 4697 long k; 4698 char * space; 4699 4700 /* Ignore NULL entries. */ 4701 if (option == NULL || lang_option == NULL) 4702 return 0; 4703 4704 if ((space = strchr (lang_option, ' ')) != NULL) 4705 len = space - lang_option; 4706 else 4707 len = strlen (lang_option); 4708 4709 /* If they do not match to the first n characters then fail. */ 4710 if (strncmp (option, lang_option, len) != 0) 4711 return 0; 4712 4713 /* Do not accept a lang option, if it matches a normal -f or -W 4714 option. Chill defines a -fpack, but we want to support 4715 -fpack-struct. */ 4716 4717 /* An exact match is OK */ 4718 if ((int) strlen (option) == len) 4719 return 1; 4720 4721 /* If it is not an -f or -W option allow the match */ 4722 if (option[0] != '-') 4723 return 1; 4724 4725 switch (option[1]) 4726 { 4727 case 'f': 4728 indep_options = f_options; 4729 numopts = NUM_ELEM (f_options); 4730 break; 4731 case 'W': 4732 indep_options = W_options; 4733 numopts = NUM_ELEM (W_options); 4734 break; 4735 default: return 1; 4736 } 4737 4738 /* The option is a -f or -W option. 4739 Skip past the prefix and search for the remainder in the 4740 appropriate table of options. */ 4741 option += 2; 4742 4743 if (option[0] == 'n' && option[1] == 'o' && option[2] == '-') 4744 option += 3; 4745 4746 for (k = numopts; k--;) 4747 { 4748 if (!strcmp (option, indep_options[k].string)) 4749 { 4750 /* The option matched a language independent option, 4751 do not allow the language specific match. */ 4752 4753 return 0; 4754 } 4755 } 4756 4757 /* The option matches the start of the langauge specific option 4758 and it is not an exact match for a language independent option. */ 4759 return 1; 4760} 4761 4762/* Entry point of cc1/c++. Decode command args, then call compile_file. 4763 Exit code is 35 if can't open files, 34 if fatal error, 4764 33 if had nonfatal errors, else success. */ 4765 4766int 4767main (argc, argv) 4768 int argc; 4769 char **argv; 4770{ 4771 register int i; 4772 char *filename = 0; 4773 int flag_print_mem = 0; 4774 int version_flag = 0; 4775 char *p; 4776 4777 /* save in case md file wants to emit args as a comment. */ 4778 save_argc = argc; 4779 save_argv = argv; 4780 4781 p = argv[0] + strlen (argv[0]); 4782 while (p != argv[0] && p[-1] != '/' 4783#ifdef DIR_SEPARATOR 4784 && p[-1] != DIR_SEPARATOR 4785#endif 4786 ) 4787 --p; 4788 progname = p; 4789 4790#if defined (RLIMIT_STACK) && defined (HAVE_GETRLIMIT) && defined (HAVE_SETRLIMIT) 4791 /* Get rid of any avoidable limit on stack size. */ 4792 { 4793 struct rlimit rlim; 4794 4795 /* Set the stack limit huge so that alloca does not fail. */ 4796 getrlimit (RLIMIT_STACK, &rlim); 4797 rlim.rlim_cur = rlim.rlim_max; 4798 setrlimit (RLIMIT_STACK, &rlim); 4799 } 4800#endif 4801 4802#ifdef HAVE_LC_MESSAGES 4803 setlocale (LC_MESSAGES, ""); 4804#endif 4805 (void) bindtextdomain (PACKAGE, localedir); 4806 (void) textdomain (PACKAGE); 4807 4808 signal (SIGFPE, float_signal); 4809 4810#ifdef SIGPIPE 4811 signal (SIGPIPE, pipe_closed); 4812#endif 4813 4814 decl_printable_name = decl_name; 4815 lang_expand_expr = (lang_expand_expr_t) do_abort; 4816 4817 /* Initialize whether `char' is signed. */ 4818 flag_signed_char = DEFAULT_SIGNED_CHAR; 4819#ifdef DEFAULT_SHORT_ENUMS 4820 /* Initialize how much space enums occupy, by default. */ 4821 flag_short_enums = DEFAULT_SHORT_ENUMS; 4822#endif 4823 4824 /* Perform language-specific options intialization. */ 4825 lang_init_options (); 4826 4827 /* Scan to see what optimization level has been specified. That will 4828 determine the default value of many flags. */ 4829 for (i = 1; i < argc; i++) 4830 { 4831 if (!strcmp (argv[i], "-O")) 4832 { 4833 optimize = 1; 4834 optimize_size = 0; 4835 } 4836 else if (argv[i][0] == '-' && argv[i][1] == 'O') 4837 { 4838 /* Handle -Os, -O2, -O3, -O69, ... */ 4839 char *p = &argv[i][2]; 4840 4841 if ((p[0] == 's') && (p[1] == 0)) 4842 { 4843 optimize_size = 1; 4844 4845 /* Optimizing for size forces optimize to be 2. */ 4846 optimize = 2; 4847 } 4848 else 4849 { 4850 const int optimize_val = read_integral_parameter (p, p - 2, -1); 4851 if (optimize_val != -1) 4852 { 4853 optimize = optimize_val; 4854#ifdef __alpha__ 4855 if (optimize > 1) 4856 { 4857 #ifdef FORCE_OPTIMIZATION_DOWNGRADE 4858 optimize = 1; 4859 warning ("\n***\n***\t-O%d converted to \"-O1\" due to optimizer bugs on this platform\n***\n", 4860 optimize_val); 4861 #else 4862 warning ("\n***\n***\tThe -O%d flag TRIGGERS KNOWN OPTIMIZER BUGS ON THIS PLATFORM\n***\n", 4863 optimize_val); 4864 #endif 4865 } 4866#endif /*__alpha__*/ 4867 optimize_size = 0; 4868 } 4869 } 4870 } 4871 } 4872 4873 obey_regdecls = (optimize == 0); 4874 4875 if (optimize >= 1) 4876 { 4877 flag_defer_pop = 1; 4878 flag_thread_jumps = 1; 4879#ifdef DELAY_SLOTS 4880 flag_delayed_branch = 1; 4881#endif 4882#ifdef CAN_DEBUG_WITHOUT_FP 4883 flag_omit_frame_pointer = 1; 4884#endif 4885 } 4886 4887 if (optimize >= 2) 4888 { 4889 flag_cse_follow_jumps = 1; 4890 flag_cse_skip_blocks = 1; 4891 flag_gcse = 1; 4892 flag_expensive_optimizations = 1; 4893 flag_strength_reduce = 1; 4894 flag_rerun_cse_after_loop = 1; 4895 flag_rerun_loop_opt = 1; 4896 flag_caller_saves = 1; 4897 flag_force_mem = 1; 4898#ifdef INSN_SCHEDULING 4899 flag_schedule_insns = 1; 4900 flag_schedule_insns_after_reload = 1; 4901#endif 4902 flag_regmove = 1; 4903 } 4904 4905 if (optimize >= 3) 4906 { 4907 flag_inline_functions = 1; 4908 } 4909 4910 /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can 4911 modify it. */ 4912 target_flags = 0; 4913 set_target_switch (""); 4914 4915#ifdef OPTIMIZATION_OPTIONS 4916 /* Allow default optimizations to be specified on a per-machine basis. */ 4917 OPTIMIZATION_OPTIONS (optimize, optimize_size); 4918#endif 4919 4920 /* Initialize register usage now so switches may override. */ 4921 init_reg_sets (); 4922 4923 for (i = 1; i < argc; i++) 4924 { 4925 size_t j; 4926 4927 /* If this is a language-specific option, 4928 decode it in a language-specific way. */ 4929 for (j = NUM_ELEM (documented_lang_options); j--;) 4930 if (check_lang_option (argv[i], documented_lang_options[j].option)) 4931 break; 4932 4933 if (j != (size_t)-1) 4934 { 4935 /* If the option is valid for *some* language, 4936 treat it as valid even if this language doesn't understand it. */ 4937 int strings_processed = lang_decode_option (argc - i, argv + i); 4938 4939 if (!strcmp (argv[i], "--help")) 4940 { 4941 display_help (); 4942 exit (0); 4943 } 4944 4945 if (strings_processed != 0) 4946 i += strings_processed - 1; 4947 } 4948 else if (argv[i][0] == '-' && argv[i][1] != 0) 4949 { 4950 register char *str = argv[i] + 1; 4951 if (str[0] == 'Y') 4952 str++; 4953 4954 if (str[0] == 'm') 4955 set_target_switch (&str[1]); 4956 else if (!strcmp (str, "dumpbase")) 4957 { 4958 dump_base_name = argv[++i]; 4959 } 4960 else if (str[0] == 'd') 4961 { 4962 register char *p = &str[1]; 4963 while (*p) 4964 switch (*p++) 4965 { 4966 case 'a': 4967 branch_prob_dump = 1; 4968 combine_dump = 1; 4969#ifdef DELAY_SLOTS 4970 dbr_sched_dump = 1; 4971#endif 4972 flow_dump = 1; 4973 flow2_dump = 1; 4974 global_reg_dump = 1; 4975 jump_opt_dump = 1; 4976 addressof_dump = 1; 4977 jump2_opt_dump = 1; 4978 local_reg_dump = 1; 4979 loop_dump = 1; 4980 regmove_dump = 1; 4981 rtl_dump = 1; 4982 cse_dump = 1, cse2_dump = 1; 4983 gcse_dump = 1; 4984 sched_dump = 1; 4985 sched2_dump = 1; 4986#ifdef STACK_REGS 4987 stack_reg_dump = 1; 4988#endif 4989#ifdef MACHINE_DEPENDENT_REORG 4990 mach_dep_reorg_dump = 1; 4991#endif 4992 break; 4993 case 'A': 4994 flag_debug_asm = 1; 4995 break; 4996 case 'b': 4997 branch_prob_dump = 1; 4998 break; 4999 case 'c': 5000 combine_dump = 1; 5001 break; 5002#ifdef DELAY_SLOTS 5003 case 'd': 5004 dbr_sched_dump = 1; 5005 break; 5006#endif 5007 case 'f': 5008 flow_dump = 1; 5009 break; 5010 case 'F': 5011 addressof_dump = 1; 5012 break; 5013 case 'g': 5014 global_reg_dump = 1; 5015 break; 5016 case 'G': 5017 gcse_dump = 1; 5018 break; 5019 case 'j': 5020 jump_opt_dump = 1; 5021 break; 5022 case 'J': 5023 jump2_opt_dump = 1; 5024 break; 5025#ifdef STACK_REGS 5026 case 'k': 5027 stack_reg_dump = 1; 5028 break; 5029#endif 5030 case 'l': 5031 local_reg_dump = 1; 5032 break; 5033 case 'L': 5034 loop_dump = 1; 5035 break; 5036 case 'm': 5037 flag_print_mem = 1; 5038 break; 5039#ifdef MACHINE_DEPENDENT_REORG 5040 case 'M': 5041 mach_dep_reorg_dump = 1; 5042 break; 5043#endif 5044 case 'p': 5045 flag_print_asm_name = 1; 5046 break; 5047 case 'r': 5048 rtl_dump = 1; 5049 break; 5050 case 'R': 5051 sched2_dump = 1; 5052 break; 5053 case 's': 5054 cse_dump = 1; 5055 break; 5056 case 'S': 5057 sched_dump = 1; 5058 break; 5059 case 't': 5060 cse2_dump = 1; 5061 break; 5062 case 'N': 5063 regmove_dump = 1; 5064 break; 5065 case 'v': 5066 graph_dump_format = vcg; 5067 break; 5068 case 'w': 5069 flow2_dump = 1; 5070 break; 5071 case 'y': 5072 set_yydebug (1); 5073 break; 5074 case 'x': 5075 rtl_dump_and_exit = 1; 5076 break; 5077 case 'D': /* these are handled by the preprocessor */ 5078 case 'I': 5079 break; 5080 default: 5081 warning ("unrecognised gcc debugging option: %c", p[-1]); 5082 break; 5083 } 5084 } 5085 else if (str[0] == 'f') 5086 { 5087 register char *p = &str[1]; 5088 int found = 0; 5089 5090 /* Some kind of -f option. 5091 P's value is the option sans `-f'. 5092 Search for it in the table of options. */ 5093 5094 for (j = 0; 5095 !found && j < sizeof (f_options) / sizeof (f_options[0]); 5096 j++) 5097 { 5098 if (!strcmp (p, f_options[j].string)) 5099 { 5100 *f_options[j].variable = f_options[j].on_value; 5101 /* A goto here would be cleaner, 5102 but breaks the vax pcc. */ 5103 found = 1; 5104 } 5105 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' 5106 && ! strcmp (p+3, f_options[j].string)) 5107 { 5108 *f_options[j].variable = ! f_options[j].on_value; 5109 found = 1; 5110 } 5111 } 5112 5113 if (found) 5114 ; 5115 else if (!strncmp (p, "inline-limit-", 13)) 5116 inline_max_insns = 5117 read_integral_parameter (p + 13, p - 2, inline_max_insns); 5118#ifdef HAIFA 5119#ifdef INSN_SCHEDULING 5120 else if (!strncmp (p, "sched-verbose-",14)) 5121 fix_sched_param("verbose",&p[14]); 5122#endif 5123#endif /* HAIFA */ 5124 else if (!strncmp (p, "fixed-", 6)) 5125 fix_register (&p[6], 1, 1); 5126 else if (!strncmp (p, "call-used-", 10)) 5127 fix_register (&p[10], 0, 1); 5128 else if (!strncmp (p, "call-saved-", 11)) 5129 fix_register (&p[11], 0, 0); 5130 else 5131 error ("Invalid option `%s'", argv[i]); 5132 } 5133 else if (str[0] == 'O') 5134 { 5135 /* Already been treated above. Do nothing. */ 5136 } 5137 else if (!strcmp (str, "pedantic")) 5138 pedantic = 1; 5139 else if (!strcmp (str, "pedantic-errors")) 5140 flag_pedantic_errors = pedantic = 1; 5141 else if (!strcmp (str, "quiet")) 5142 quiet_flag = 1; 5143 else if (!strcmp (str, "version")) 5144 version_flag = 1; 5145 else if (!strcmp (str, "w")) 5146 inhibit_warnings = 1; 5147 else if (!strcmp (str, "W")) 5148 { 5149 extra_warnings = 1; 5150 /* We save the value of warn_uninitialized, since if they put 5151 -Wuninitialized on the command line, we need to generate a 5152 warning about not using it without also specifying -O. */ 5153 if (warn_uninitialized != 1) 5154 warn_uninitialized = 2; 5155 } 5156 else if (str[0] == 'W') 5157 { 5158 register char *p = &str[1]; 5159 int found = 0; 5160 5161 /* Some kind of -W option. 5162 P's value is the option sans `-W'. 5163 Search for it in the table of options. */ 5164 5165 for (j = 0; 5166 !found && j < sizeof (W_options) / sizeof (W_options[0]); 5167 j++) 5168 { 5169 if (!strcmp (p, W_options[j].string)) 5170 { 5171 *W_options[j].variable = W_options[j].on_value; 5172 /* A goto here would be cleaner, 5173 but breaks the vax pcc. */ 5174 found = 1; 5175 } 5176 if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' 5177 && ! strcmp (p+3, W_options[j].string)) 5178 { 5179 *W_options[j].variable = ! W_options[j].on_value; 5180 found = 1; 5181 } 5182 } 5183 5184 if (found) 5185 ; 5186 else if (!strncmp (p, "id-clash-", 9)) 5187 { 5188 const int id_clash_val 5189 = read_integral_parameter (p + 9, p - 2, -1); 5190 if (id_clash_val != -1) 5191 { 5192 id_clash_len = id_clash_val; 5193 warn_id_clash = 1; 5194 } 5195 } 5196 else if (!strncmp (p, "larger-than-", 12)) 5197 { 5198 const int larger_than_val 5199 = read_integral_parameter (p + 12, p - 2, -1); 5200 if (larger_than_val != -1) 5201 { 5202 larger_than_size = larger_than_val; 5203 warn_larger_than = 1; 5204 } 5205 } 5206 else 5207 error ("Invalid option `%s'", argv[i]); 5208 } 5209 else if (!strcmp (str, "p")) 5210 { 5211 profile_flag = 1; 5212 } 5213 else if (!strcmp (str, "a")) 5214 { 5215#if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) 5216 warning ("`-a' option (basic block profile) not supported"); 5217#else 5218 profile_block_flag = (profile_block_flag < 2) ? 1 : 3; 5219#endif 5220 } 5221 else if (!strcmp (str, "ax")) 5222 { 5223#if !defined (FUNCTION_BLOCK_PROFILER_EXIT) || !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) 5224 warning ("`-ax' option (jump profiling) not supported"); 5225#else 5226 profile_block_flag = (!profile_block_flag 5227 || profile_block_flag == 2) ? 2 : 3; 5228#endif 5229 } 5230 else if (str[0] == 'g') 5231 { 5232 unsigned level; 5233 /* A lot of code assumes write_symbols == NO_DEBUG if the 5234 debugging level is 0 (thus -gstabs1 -gstabs0 would lose track 5235 of what debugging type has been selected). This records the 5236 selected type. It is an error to specify more than one 5237 debugging type. */ 5238 static enum debug_info_type selected_debug_type = NO_DEBUG; 5239 /* Non-zero if debugging format has been explicitly set. 5240 -g and -ggdb don't explicitly set the debugging format so 5241 -gdwarf -g3 is equivalent to -gdwarf3. */ 5242 static int type_explicitly_set_p = 0; 5243 /* Indexed by enum debug_info_type. */ 5244 static const char *debug_type_names[] = 5245 { 5246 "none", "stabs", "coff", "dwarf-1", "dwarf-2", "xcoff" 5247 }; 5248 5249 /* The maximum admissible debug level value. */ 5250 static const unsigned max_debug_level = 3; 5251 5252 /* Look up STR in the table. */ 5253 for (da = debug_args; da->arg; da++) 5254 { 5255 const int da_len = strlen (da->arg); 5256 5257 if (! strncmp (str, da->arg, da_len)) 5258 { 5259 enum debug_info_type type = da->debug_type; 5260 const char *p = str + da_len; 5261 5262 if (*p && (*p < '0' || *p > '9')) 5263 continue; 5264 5265 /* A debug flag without a level defaults to level 2. 5266 Note we do not want to call read_integral_parameter 5267 for that case since it will call atoi which 5268 will return zero. 5269 5270 ??? We may want to generalize the interface to 5271 read_integral_parameter to better handle this case 5272 if this case shows up often. */ 5273 if (*p) 5274 level = read_integral_parameter (p, 0, 5275 max_debug_level + 1); 5276 else 5277 level = 2; 5278 5279 if (da_len > 1 && *p && !strncmp (str, "gdwarf", da_len)) 5280 { 5281 error ("use -gdwarf -g%d for DWARF v1, level %d", 5282 level, level); 5283 if (level == 2) 5284 error ("use -gdwarf-2 for DWARF v2"); 5285 } 5286 5287 if (level > max_debug_level) 5288 { 5289 warning ("ignoring option `%s' due to invalid debug level specification", 5290 str - 1); 5291 level = debug_info_level; 5292 } 5293 5294 if (type == NO_DEBUG) 5295 { 5296 type = PREFERRED_DEBUGGING_TYPE; 5297 if (da_len > 1 && strncmp (str, "ggdb", da_len) == 0) 5298 { 5299#if defined (DWARF2_DEBUGGING_INFO) && !defined (LINKER_DOES_NOT_WORK_WITH_DWARF2) 5300 type = DWARF2_DEBUG; 5301#else 5302#ifdef DBX_DEBUGGING_INFO 5303 type = DBX_DEBUG; 5304#endif 5305#endif 5306 } 5307 } 5308 5309 if (type == NO_DEBUG) 5310 warning ("`-%s' not supported by this configuration of GCC", 5311 str); 5312 5313 /* Does it conflict with an already selected type? */ 5314 if (type_explicitly_set_p 5315 /* -g/-ggdb don't conflict with anything */ 5316 && da->debug_type != NO_DEBUG 5317 && type != selected_debug_type) 5318 warning ("`-%s' ignored, conflicts with `-g%s'", 5319 str, debug_type_names[(int) selected_debug_type]); 5320 else 5321 { 5322 /* If the format has already been set, -g/-ggdb 5323 only change the debug level. */ 5324 if (type_explicitly_set_p 5325 && da->debug_type == NO_DEBUG) 5326 ; /* don't change debugging type */ 5327 else 5328 { 5329 selected_debug_type = type; 5330 type_explicitly_set_p = da->debug_type != NO_DEBUG; 5331 } 5332 write_symbols = (level == 0 5333 ? NO_DEBUG 5334 : selected_debug_type); 5335 use_gnu_debug_info_extensions = da->use_extensions_p; 5336 debug_info_level = (enum debug_info_level) level; 5337 } 5338 break; 5339 } 5340 } 5341 if (! da->arg) 5342 warning ("`-%s' not supported by this configuration of GCC", 5343 str); 5344 } 5345 else if (!strcmp (str, "o")) 5346 { 5347 asm_file_name = argv[++i]; 5348 } 5349 else if (str[0] == 'G') 5350 { 5351 const int g_switch_val = (str[1] != '\0') ? 5352 read_integral_parameter(str + 1, 0, -1) : 5353 read_integral_parameter(argv[++i], 0, -1); 5354 5355 if (g_switch_val != -1) 5356 { 5357 g_switch_set = TRUE; 5358 g_switch_value = g_switch_val; 5359 } 5360 else 5361 { 5362 error("Invalid option `-%s'",str); 5363 } 5364 } 5365 else if (!strncmp (str, "aux-info", 8)) 5366 { 5367 flag_gen_aux_info = 1; 5368 aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]); 5369 } 5370 else if (!strcmp (str, "-help")) 5371 { 5372 display_help (); 5373 exit (0); 5374 } 5375 else 5376 error ("Invalid option `%s'", argv[i]); 5377 } 5378 else if (argv[i][0] == '+') 5379 error ("Invalid option `%s'", argv[i]); 5380 else 5381 filename = argv[i]; 5382 } 5383 5384 /* Checker uses the frame pointer. */ 5385 if (flag_check_memory_usage) 5386 flag_omit_frame_pointer = 0; 5387 5388 if (optimize == 0) 5389 { 5390 /* Inlining does not work if not optimizing, 5391 so force it not to be done. */ 5392 flag_no_inline = 1; 5393 warn_inline = 0; 5394 5395 /* The c_decode_option and lang_decode_option functions set 5396 this to `2' if -Wall is used, so we can avoid giving out 5397 lots of errors for people who don't realize what -Wall does. */ 5398 if (warn_uninitialized == 1) 5399 warning ("-Wuninitialized is not supported without -O"); 5400 } 5401 5402#ifdef OVERRIDE_OPTIONS 5403 /* Some machines may reject certain combinations of options. */ 5404 OVERRIDE_OPTIONS; 5405#endif 5406 5407 if (exceptions_via_longjmp == 2) 5408 { 5409#ifdef DWARF2_UNWIND_INFO 5410 exceptions_via_longjmp = ! DWARF2_UNWIND_INFO; 5411#else 5412 exceptions_via_longjmp = 1; 5413#endif 5414 } 5415 5416 if (profile_block_flag == 3) 5417 { 5418 warning ("`-ax' and `-a' are conflicting options. `-a' ignored."); 5419 profile_block_flag = 2; 5420 } 5421 5422 /* Unrolling all loops implies that standard loop unrolling must also 5423 be done. */ 5424 if (flag_unroll_all_loops) 5425 flag_unroll_loops = 1; 5426 /* Loop unrolling requires that strength_reduction be on also. Silently 5427 turn on strength reduction here if it isn't already on. Also, the loop 5428 unrolling code assumes that cse will be run after loop, so that must 5429 be turned on also. */ 5430 if (flag_unroll_loops) 5431 { 5432 flag_strength_reduce = 1; 5433 flag_rerun_cse_after_loop = 1; 5434 } 5435 5436 /* Warn about options that are not supported on this machine. */ 5437#ifndef INSN_SCHEDULING 5438 if (flag_schedule_insns || flag_schedule_insns_after_reload) 5439 warning ("instruction scheduling not supported on this target machine"); 5440#endif 5441#ifndef DELAY_SLOTS 5442 if (flag_delayed_branch) 5443 warning ("this target machine does not have delayed branches"); 5444#endif 5445 5446 user_label_prefix = USER_LABEL_PREFIX; 5447 if (flag_leading_underscore != -1) 5448 { 5449 /* If the default prefix is more complicated than "" or "_", 5450 issue a warning and ignore this option. */ 5451 if (user_label_prefix[0] == 0 || 5452 (user_label_prefix[0] == '_' && user_label_prefix[1] == 0)) 5453 { 5454 user_label_prefix = flag_leading_underscore ? "_" : ""; 5455 } 5456 else 5457 warning ("-f%sleading-underscore not supported on this target machine", 5458 flag_leading_underscore ? "" : "no-"); 5459 } 5460 5461 /* If we are in verbose mode, write out the version and maybe all the 5462 option flags in use. */ 5463 if (version_flag) 5464 { 5465 print_version (stderr, ""); 5466 if (! quiet_flag) 5467 print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n"); 5468 } 5469 5470 compile_file (filename); 5471 5472#if !defined(OS2) && !defined(VMS) && (!defined(_WIN32) || defined (__CYGWIN__)) && !defined(__INTERIX) 5473 if (flag_print_mem) 5474 { 5475 char *lim = (char *) sbrk (0); 5476 5477 notice ("Data size %ld.\n", (long) (lim - (char *) &environ)); 5478 fflush (stderr); 5479 5480#ifndef __MSDOS__ 5481#ifdef USG 5482 system ("ps -l 1>&2"); 5483#else /* not USG */ 5484 system ("ps v"); 5485#endif /* not USG */ 5486#endif 5487 } 5488#endif /* ! OS2 && ! VMS && (! _WIN32 || CYGWIN) && ! __INTERIX */ 5489 5490 if (errorcount) 5491 exit (FATAL_EXIT_CODE); 5492 if (sorrycount) 5493 exit (FATAL_EXIT_CODE); 5494 exit (SUCCESS_EXIT_CODE); 5495 return 0; 5496} 5497 5498/* Decode -m switches. */ 5499/* Decode the switch -mNAME. */ 5500 5501static void 5502set_target_switch (name) 5503 const char *name; 5504{ 5505 register size_t j; 5506 int valid_target_option = 0; 5507 5508 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) 5509 if (!strcmp (target_switches[j].name, name)) 5510 { 5511 if (target_switches[j].value < 0) 5512 target_flags &= ~-target_switches[j].value; 5513 else 5514 target_flags |= target_switches[j].value; 5515 valid_target_option = 1; 5516 } 5517 5518#ifdef TARGET_OPTIONS 5519 if (!valid_target_option) 5520 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) 5521 { 5522 int len = strlen (target_options[j].prefix); 5523 if (!strncmp (target_options[j].prefix, name, len)) 5524 { 5525 *target_options[j].variable = name + len; 5526 valid_target_option = 1; 5527 } 5528 } 5529#endif 5530 5531 if (!valid_target_option) 5532 error ("Invalid option `%s'", name); 5533} 5534 5535/* Print version information to FILE. 5536 Each line begins with INDENT (for the case where FILE is the 5537 assembler output file). */ 5538 5539static void 5540print_version (file, indent) 5541 FILE *file; 5542 const char *indent; 5543{ 5544#ifndef __VERSION__ 5545#define __VERSION__ "[?]" 5546#endif 5547 fnotice (file, 5548#ifdef __GNUC__ 5549 "%s%s%s version %s (%s) compiled by GNU C version %s.\n" 5550#else 5551 "%s%s%s version %s (%s) compiled by CC.\n" 5552#endif 5553 , indent, *indent != 0 ? " " : "", 5554 language_string, version_string, TARGET_NAME, __VERSION__); 5555} 5556 5557/* Print an option value and return the adjusted position in the line. 5558 ??? We don't handle error returns from fprintf (disk full); presumably 5559 other code will catch a disk full though. */ 5560 5561static int 5562print_single_switch (file, pos, max, indent, sep, term, type, name) 5563 FILE *file; 5564 int pos, max; 5565 const char *indent, *sep, *term, *type, *name; 5566{ 5567 /* The ultrix fprintf returns 0 on success, so compute the result we want 5568 here since we need it for the following test. */ 5569 int len = strlen (sep) + strlen (type) + strlen (name); 5570 5571 if (pos != 0 5572 && pos + len > max) 5573 { 5574 fprintf (file, "%s", term); 5575 pos = 0; 5576 } 5577 if (pos == 0) 5578 { 5579 fprintf (file, "%s", indent); 5580 pos = strlen (indent); 5581 } 5582 fprintf (file, "%s%s%s", sep, type, name); 5583 pos += len; 5584 return pos; 5585} 5586 5587/* Print active target switches to FILE. 5588 POS is the current cursor position and MAX is the size of a "line". 5589 Each line begins with INDENT and ends with TERM. 5590 Each switch is separated from the next by SEP. */ 5591 5592static void 5593print_switch_values (file, pos, max, indent, sep, term) 5594 FILE *file; 5595 int pos, max; 5596 const char *indent, *sep, *term; 5597{ 5598 size_t j; 5599 char **p; 5600 5601 /* Print the options as passed. */ 5602 5603 pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term, 5604 _("options passed: "), ""); 5605 5606 for (p = &save_argv[1]; *p != NULL; p++) 5607 if (**p == '-') 5608 { 5609 /* Ignore these. */ 5610 if (strcmp (*p, "-o") == 0) 5611 { 5612 if (p[1] != NULL) 5613 p++; 5614 continue; 5615 } 5616 if (strcmp (*p, "-quiet") == 0) 5617 continue; 5618 if (strcmp (*p, "-version") == 0) 5619 continue; 5620 if ((*p)[1] == 'd') 5621 continue; 5622 5623 pos = print_single_switch (file, pos, max, indent, sep, term, *p, ""); 5624 } 5625 if (pos > 0) 5626 fprintf (file, "%s", term); 5627 5628 /* Print the -f and -m options that have been enabled. 5629 We don't handle language specific options but printing argv 5630 should suffice. */ 5631 5632 pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term, 5633 _("options enabled: "), ""); 5634 5635 for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) 5636 if (*f_options[j].variable == f_options[j].on_value) 5637 pos = print_single_switch (file, pos, max, indent, sep, term, 5638 "-f", f_options[j].string); 5639 5640 /* Print target specific options. */ 5641 5642 for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) 5643 if (target_switches[j].name[0] != '\0' 5644 && target_switches[j].value > 0 5645 && ((target_switches[j].value & target_flags) 5646 == target_switches[j].value)) 5647 { 5648 pos = print_single_switch (file, pos, max, indent, sep, term, 5649 "-m", target_switches[j].name); 5650 } 5651 5652#ifdef TARGET_OPTIONS 5653 for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) 5654 if (*target_options[j].variable != NULL) 5655 { 5656 char prefix[256]; 5657 sprintf (prefix, "-m%s", target_options[j].prefix); 5658 pos = print_single_switch (file, pos, max, indent, sep, term, 5659 prefix, *target_options[j].variable); 5660 } 5661#endif 5662 5663 fprintf (file, "%s", term); 5664} 5665 5666/* Record the beginning of a new source file, named FILENAME. */ 5667 5668void 5669debug_start_source_file (filename) 5670 register char *filename ATTRIBUTE_UNUSED; 5671{ 5672#ifdef DBX_DEBUGGING_INFO 5673 if (write_symbols == DBX_DEBUG) 5674 dbxout_start_new_source_file (filename); 5675#endif 5676#ifdef DWARF_DEBUGGING_INFO 5677 if (debug_info_level == DINFO_LEVEL_VERBOSE 5678 && write_symbols == DWARF_DEBUG) 5679 dwarfout_start_new_source_file (filename); 5680#endif /* DWARF_DEBUGGING_INFO */ 5681#ifdef DWARF2_DEBUGGING_INFO 5682 if (debug_info_level == DINFO_LEVEL_VERBOSE 5683 && write_symbols == DWARF2_DEBUG) 5684 dwarf2out_start_source_file (filename); 5685#endif /* DWARF2_DEBUGGING_INFO */ 5686#ifdef SDB_DEBUGGING_INFO 5687 if (write_symbols == SDB_DEBUG) 5688 sdbout_start_new_source_file (filename); 5689#endif 5690} 5691 5692/* Record the resumption of a source file. LINENO is the line number in 5693 the source file we are returning to. */ 5694 5695void 5696debug_end_source_file (lineno) 5697 register unsigned lineno ATTRIBUTE_UNUSED; 5698{ 5699#ifdef DBX_DEBUGGING_INFO 5700 if (write_symbols == DBX_DEBUG) 5701 dbxout_resume_previous_source_file (); 5702#endif 5703#ifdef DWARF_DEBUGGING_INFO 5704 if (debug_info_level == DINFO_LEVEL_VERBOSE 5705 && write_symbols == DWARF_DEBUG) 5706 dwarfout_resume_previous_source_file (lineno); 5707#endif /* DWARF_DEBUGGING_INFO */ 5708#ifdef DWARF2_DEBUGGING_INFO 5709 if (debug_info_level == DINFO_LEVEL_VERBOSE 5710 && write_symbols == DWARF2_DEBUG) 5711 dwarf2out_end_source_file (); 5712#endif /* DWARF2_DEBUGGING_INFO */ 5713#ifdef SDB_DEBUGGING_INFO 5714 if (write_symbols == SDB_DEBUG) 5715 sdbout_resume_previous_source_file (); 5716#endif 5717} 5718 5719/* Called from check_newline in c-parse.y. The `buffer' parameter contains 5720 the tail part of the directive line, i.e. the part which is past the 5721 initial whitespace, #, whitespace, directive-name, whitespace part. */ 5722 5723void 5724debug_define (lineno, buffer) 5725 register unsigned lineno ATTRIBUTE_UNUSED; 5726 register char *buffer ATTRIBUTE_UNUSED; 5727{ 5728#ifdef DWARF_DEBUGGING_INFO 5729 if (debug_info_level == DINFO_LEVEL_VERBOSE 5730 && write_symbols == DWARF_DEBUG) 5731 dwarfout_define (lineno, buffer); 5732#endif /* DWARF_DEBUGGING_INFO */ 5733#ifdef DWARF2_DEBUGGING_INFO 5734 if (debug_info_level == DINFO_LEVEL_VERBOSE 5735 && write_symbols == DWARF2_DEBUG) 5736 dwarf2out_define (lineno, buffer); 5737#endif /* DWARF2_DEBUGGING_INFO */ 5738} 5739 5740/* Called from check_newline in c-parse.y. The `buffer' parameter contains 5741 the tail part of the directive line, i.e. the part which is past the 5742 initial whitespace, #, whitespace, directive-name, whitespace part. */ 5743 5744void 5745debug_undef (lineno, buffer) 5746 register unsigned lineno ATTRIBUTE_UNUSED; 5747 register char *buffer ATTRIBUTE_UNUSED; 5748{ 5749#ifdef DWARF_DEBUGGING_INFO 5750 if (debug_info_level == DINFO_LEVEL_VERBOSE 5751 && write_symbols == DWARF_DEBUG) 5752 dwarfout_undef (lineno, buffer); 5753#endif /* DWARF_DEBUGGING_INFO */ 5754#ifdef DWARF2_DEBUGGING_INFO 5755 if (debug_info_level == DINFO_LEVEL_VERBOSE 5756 && write_symbols == DWARF2_DEBUG) 5757 dwarf2out_undef (lineno, buffer); 5758#endif /* DWARF2_DEBUGGING_INFO */ 5759} 5760