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