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