|
|
1.1 root 1: /* Top level of GNU C compiler 1.1.1.6 ! root 2: Copyright (C) 1987, 1988, 1989, 1992, 1993 Free Software Foundation, Inc. 1.1 root 3: 4: This file is part of GNU CC. 5: 6: GNU CC is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU CC is distributed in the hope that it will be useful, 12: but WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14: GNU General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU CC; see the file COPYING. If not, write to 18: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 19: 20: 21: /* This is the top level of cc1/c++. 22: It parses command args, opens files, invokes the various passes 23: in the proper order, and counts the time used by each. 24: Error messages and low-level interface to malloc also handled here. */ 25: 26: #include "config.h" 27: #include <sys/types.h> 28: #include <stdio.h> 29: #include <signal.h> 30: #include <setjmp.h> 31: 32: #include <sys/stat.h> 33: 34: #ifdef USG 35: #undef FLOAT 36: #include <sys/param.h> 37: /* This is for hpux. It is a real screw. They should change hpux. */ 38: #undef FLOAT 39: #include <sys/times.h> 40: #include <time.h> /* Correct for hpux at least. Is it good on other USG? */ 41: #undef FFS /* Some systems define this in param.h. */ 42: #else 43: #ifndef VMS 44: #include <sys/time.h> 45: #include <sys/resource.h> 46: #endif 47: #endif 48: 49: #include "input.h" 50: #include "tree.h" 51: /* #include "c-tree.h" */ 52: #include "rtl.h" 53: #include "flags.h" 54: #include "insn-attr.h" 1.1.1.5 root 55: #include "defaults.h" 1.1.1.2 root 56: 57: #ifdef XCOFF_DEBUGGING_INFO 58: #include "xcoffout.h" 59: #endif 1.1.1.6 ! root 60: ! 61: #include "bytecode.h" ! 62: #include "bc-emit.h" 1.1 root 63: 64: #ifdef VMS 65: /* The extra parameters substantially improve the I/O performance. */ 66: static FILE * 67: VMS_fopen (fname, type) 68: char * fname; 69: char * type; 70: { 71: if (strcmp (type, "w") == 0) 72: return fopen (fname, type, "mbc=16", "deq=64", "fop=tef", "shr=nil"); 73: return fopen (fname, type, "mbc=16"); 74: } 75: #define fopen VMS_fopen 76: #endif 77: 78: #ifndef DEFAULT_GDB_EXTENSIONS 79: #define DEFAULT_GDB_EXTENSIONS 1 80: #endif 81: 82: extern int rtx_equal_function_value_matters; 83: 1.1.1.4 root 84: #if ! (defined (VMS) || defined (OS2)) 1.1 root 85: extern char **environ; 1.1.1.4 root 86: #endif 1.1 root 87: extern char *version_string, *language_string; 88: 1.1.1.6 ! root 89: /* Carry information from ASM_DECLARE_OBJECT_NAME ! 90: to ASM_FINISH_DECLARE_OBJECT. */ ! 91: ! 92: extern int size_directive_output; ! 93: extern tree last_assemble_variable_decl; ! 94: 1.1 root 95: extern void init_lex (); 96: extern void init_decl_processing (); 97: extern void init_obstacks (); 98: extern void init_tree_codes (); 99: extern void init_rtl (); 100: extern void init_optabs (); 101: extern void init_stmt (); 102: extern void init_reg_sets (); 103: extern void dump_flow_info (); 104: extern void dump_sched_info (); 105: extern void dump_local_alloc (); 106: 107: void rest_of_decl_compilation (); 108: void error (); 109: void error_with_file_and_line (); 110: void fancy_abort (); 111: #ifndef abort 112: void abort (); 113: #endif 114: void set_target_switch (); 115: static void print_switch_values (); 116: static char *decl_name (); 117: 118: /* Name of program invoked, sans directories. */ 119: 120: char *progname; 121: 122: /* Copy of arguments to main. */ 123: int save_argc; 124: char **save_argv; 125: 126: /* Name of current original source file (what was input to cpp). 127: This comes from each #-command in the actual input. */ 128: 129: char *input_filename; 130: 131: /* Name of top-level original source file (what was input to cpp). 132: This comes from the #-command at the beginning of the actual input. 133: If there isn't any there, then this is the cc1 input file name. */ 134: 135: char *main_input_filename; 136: 137: /* Stream for reading from the input file. */ 138: 139: FILE *finput; 140: 141: /* Current line number in real source file. */ 142: 143: int lineno; 144: 145: /* Stack of currently pending input files. */ 146: 147: struct file_stack *input_file_stack; 148: 149: /* Incremented on each change to input_file_stack. */ 150: int input_file_stack_tick; 151: 152: /* FUNCTION_DECL for function now being parsed or compiled. */ 153: 154: extern tree current_function_decl; 155: 156: /* Name to use as base of names for dump output files. */ 157: 158: char *dump_base_name; 159: 160: /* Bit flags that specify the machine subtype we are compiling for. 161: Bits are tested using macros TARGET_... defined in the tm.h file 162: and set by `-m...' switches. Must be defined in rtlanal.c. */ 163: 164: extern int target_flags; 165: 166: /* Flags saying which kinds of debugging dump have been requested. */ 167: 168: int rtl_dump = 0; 169: int rtl_dump_and_exit = 0; 170: int jump_opt_dump = 0; 171: int cse_dump = 0; 172: int loop_dump = 0; 173: int cse2_dump = 0; 174: int flow_dump = 0; 175: int combine_dump = 0; 176: int sched_dump = 0; 177: int local_reg_dump = 0; 178: int global_reg_dump = 0; 179: int sched2_dump = 0; 180: int jump2_opt_dump = 0; 181: int dbr_sched_dump = 0; 182: int flag_print_asm_name = 0; 183: int stack_reg_dump = 0; 184: 185: /* Name for output file of assembly code, specified with -o. */ 186: 187: char *asm_file_name; 188: 189: /* Value of the -G xx switch, and whether it was passed or not. */ 190: int g_switch_value; 191: int g_switch_set; 192: 193: /* Type(s) of debugging information we are producing (if any). 194: See flags.h for the definitions of the different possible 195: types of debugging information. */ 196: enum debug_info_type write_symbols = NO_DEBUG; 197: 198: /* Level of debugging information we are producing. See flags.h 199: for the definitions of the different possible levels. */ 200: enum debug_info_level debug_info_level = DINFO_LEVEL_NONE; 201: 1.1.1.4 root 202: /* Nonzero means use GNU-only extensions in the generated symbolic 203: debugging information. */ 204: /* Currently, this only has an effect when write_symbols is set to 205: DBX_DEBUG, XCOFF_DEBUG, or DWARF_DEBUG. */ 206: int use_gnu_debug_info_extensions = 0; 1.1 root 207: 208: /* Nonzero means do optimizations. -O. 209: Particular numeric values stand for particular amounts of optimization; 210: thus, -O2 stores 2 here. However, the optimizations beyond the basic 211: ones are not controlled directly by this variable. Instead, they are 212: controlled by individual `flag_...' variables that are defaulted 213: based on this variable. */ 214: 215: int optimize = 0; 216: 217: /* Number of error messages and warning messages so far. */ 218: 219: int errorcount = 0; 220: int warningcount = 0; 221: int sorrycount = 0; 222: 1.1.1.6 ! root 223: /* Flag to output bytecode instead of native assembler */ ! 224: int output_bytecode = 0; ! 225: 1.1 root 226: /* Pointer to function to compute the name to use to print a declaration. */ 227: 228: char *(*decl_printable_name) (); 229: 230: /* Pointer to function to compute rtl for a language-specific tree code. */ 231: 232: struct rtx_def *(*lang_expand_expr) (); 233: 1.1.1.5 root 234: /* Pointer to function to finish handling an incomplete decl at the 235: end of compilation. */ 236: 237: void (*incomplete_decl_finalize_hook) () = 0; 238: 1.1 root 239: /* Nonzero if generating code to do profiling. */ 240: 241: int profile_flag = 0; 242: 243: /* Nonzero if generating code to do profiling on a line-by-line basis. */ 244: 245: int profile_block_flag; 246: 247: /* Nonzero for -pedantic switch: warn about anything 248: that standard spec forbids. */ 249: 250: int pedantic = 0; 251: 252: /* Temporarily suppress certain warnings. 253: This is set while reading code from a system header file. */ 254: 255: int in_system_header = 0; 256: 257: /* Nonzero means do stupid register allocation. 258: Currently, this is 1 if `optimize' is 0. */ 259: 260: int obey_regdecls = 0; 261: 262: /* Don't print functions as they are compiled and don't print 263: times taken by the various passes. -quiet. */ 264: 265: int quiet_flag = 0; 266: 267: /* -f flags. */ 268: 269: /* Nonzero means `char' should be signed. */ 270: 271: int flag_signed_char; 272: 273: /* Nonzero means give an enum type only as many bytes as it needs. */ 274: 275: int flag_short_enums; 276: 277: /* Nonzero for -fcaller-saves: allocate values in regs that need to 278: be saved across function calls, if that produces overall better code. 279: Optional now, so people can test it. */ 280: 281: #ifdef DEFAULT_CALLER_SAVES 282: int flag_caller_saves = 1; 283: #else 284: int flag_caller_saves = 0; 285: #endif 286: 1.1.1.5 root 287: /* Nonzero if structures and unions should be returned in memory. 288: 289: This should only be defined if compatibility with another compiler or 290: with an ABI is needed, because it results in slower code. */ 291: 292: #ifndef DEFAULT_PCC_STRUCT_RETURN 293: #define DEFAULT_PCC_STRUCT_RETURN 1 294: #endif 295: 1.1 root 296: /* Nonzero for -fpcc-struct-return: return values the same way PCC does. */ 297: 1.1.1.5 root 298: int flag_pcc_struct_return = DEFAULT_PCC_STRUCT_RETURN; 1.1 root 299: 300: /* Nonzero for -fforce-mem: load memory value into a register 301: before arithmetic on it. This makes better cse but slower compilation. */ 302: 303: int flag_force_mem = 0; 304: 305: /* Nonzero for -fforce-addr: load memory address into a register before 306: reference to memory. This makes better cse but slower compilation. */ 307: 308: int flag_force_addr = 0; 309: 310: /* Nonzero for -fdefer-pop: don't pop args after each function call; 311: instead save them up to pop many calls' args with one insns. */ 312: 1.1.1.5 root 313: int flag_defer_pop = 0; 1.1 root 314: 315: /* Nonzero for -ffloat-store: don't allocate floats and doubles 316: in extended-precision registers. */ 317: 318: int flag_float_store = 0; 319: 320: /* Nonzero for -fcse-follow-jumps: 321: have cse follow jumps to do a more extensive job. */ 322: 323: int flag_cse_follow_jumps; 324: 1.1.1.3 root 325: /* Nonzero for -fcse-skip-blocks: 326: have cse follow a branch around a block. */ 327: int flag_cse_skip_blocks; 328: 1.1 root 329: /* Nonzero for -fexpensive-optimizations: 330: perform miscellaneous relatively-expensive optimizations. */ 331: int flag_expensive_optimizations; 332: 333: /* Nonzero for -fthread-jumps: 334: have jump optimize output of loop. */ 335: 336: int flag_thread_jumps; 337: 338: /* Nonzero enables strength-reduction in loop.c. */ 339: 340: int flag_strength_reduce = 0; 341: 342: /* Nonzero enables loop unrolling in unroll.c. Only loops for which the 343: number of iterations can be calculated at compile-time (UNROLL_COMPLETELY, 344: UNROLL_MODULO) or at run-time (preconditioned to be UNROLL_MODULO) are 345: unrolled. */ 346: 347: int flag_unroll_loops; 348: 349: /* Nonzero enables loop unrolling in unroll.c. All loops are unrolled. 350: This is generally not a win. */ 351: 352: int flag_unroll_all_loops; 353: 354: /* Nonzero for -fwritable-strings: 355: store string constants in data segment and don't uniquize them. */ 356: 357: int flag_writable_strings = 0; 358: 359: /* Nonzero means don't put addresses of constant functions in registers. 360: Used for compiling the Unix kernel, where strange substitutions are 361: done on the assembly output. */ 362: 363: int flag_no_function_cse = 0; 364: 365: /* Nonzero for -fomit-frame-pointer: 366: don't make a frame pointer in simple functions that don't require one. */ 367: 368: int flag_omit_frame_pointer = 0; 369: 370: /* Nonzero to inhibit use of define_optimization peephole opts. */ 371: 372: int flag_no_peephole = 0; 373: 1.1.1.3 root 374: /* Nonzero allows GCC to violate some IEEE or ANSI rules regarding math 375: operations in the interest of optimization. For example it allows 376: GCC to assume arguments to sqrt are nonnegative numbers, allowing 377: faster code for sqrt to be generated. */ 378: 379: int flag_fast_math = 0; 380: 1.1 root 381: /* Nonzero means all references through pointers are volatile. */ 382: 383: int flag_volatile; 384: 1.1.1.5 root 385: /* Nonzero means treat all global and extern variables as global. */ 386: 387: int flag_volatile_global; 388: 1.1 root 389: /* Nonzero means just do syntax checking; don't output anything. */ 390: 391: int flag_syntax_only = 0; 392: 393: /* Nonzero means to rerun cse after loop optimization. This increases 394: compilation time about 20% and picks up a few more common expressions. */ 395: 396: static int flag_rerun_cse_after_loop; 397: 398: /* Nonzero for -finline-functions: ok to inline functions that look like 399: good inline candidates. */ 400: 401: int flag_inline_functions; 402: 403: /* Nonzero for -fkeep-inline-functions: even if we make a function 1.1.1.5 root 404: go inline everywhere, keep its definition around for debugging 1.1 root 405: purposes. */ 406: 407: int flag_keep_inline_functions; 408: 409: /* Nonzero means that functions declared `inline' will be treated 410: as `static'. Prevents generation of zillions of copies of unused 411: static inline functions; instead, `inlines' are written out 412: only when actually used. Used in conjunction with -g. Also 413: does the right thing with #pragma interface. */ 414: 415: int flag_no_inline; 416: 417: /* Nonzero means we should be saving declaration info into a .X file. */ 418: 419: int flag_gen_aux_info = 0; 420: 1.1.1.2 root 421: /* Specified name of aux-info file. */ 422: 423: static char *aux_info_file_name; 424: 1.1 root 425: /* Nonzero means make the text shared if supported. */ 426: 427: int flag_shared_data; 428: 429: /* Nonzero means schedule into delayed branch slots if supported. */ 430: 431: int flag_delayed_branch; 432: 433: /* Nonzero if we are compiling pure (sharable) code. 434: Value is 1 if we are doing reasonable (i.e. simple 435: offset into offset table) pic. Value is 2 if we can 436: only perform register offsets. */ 437: 438: int flag_pic; 439: 440: /* Nonzero means place uninitialized global data in the bss section. */ 441: 442: int flag_no_common; 443: 444: /* Nonzero means pretend it is OK to examine bits of target floats, 445: even if that isn't true. The resulting code will have incorrect constants, 446: but the same series of instructions that the native compiler would make. */ 447: 448: int flag_pretend_float; 449: 450: /* Nonzero means change certain warnings into errors. 451: Usually these are warnings about failure to conform to some standard. */ 452: 453: int flag_pedantic_errors = 0; 454: 455: /* flag_schedule_insns means schedule insns within basic blocks (before 456: local_alloc). 457: flag_schedule_insns_after_reload means schedule insns after 458: global_alloc. */ 459: 460: int flag_schedule_insns = 0; 461: int flag_schedule_insns_after_reload = 0; 462: 463: /* -finhibit-size-directive inhibits output of .size for ELF. 464: This is used only for compiling crtstuff.c, 465: and it may be extended to other effects 466: needed for crtstuff.c on other systems. */ 467: int flag_inhibit_size_directive = 0; 468: 1.1.1.3 root 469: /* -fverbose-asm causes extra commentary information to be produced in 470: the generated assembly code (to make it more readable). This option 471: is generally only of use to those who actually need to read the 472: generated assembly code (perhaps while debugging the compiler itself). */ 473: 474: int flag_verbose_asm = 0; 475: 1.1 root 476: /* -fgnu-linker specifies use of the GNU linker for initializations. 1.1.1.3 root 477: (Or, more generally, a linker that handles initializations.) 478: -fno-gnu-linker says that collect2 will be used. */ 479: #ifdef USE_COLLECT2 480: int flag_gnu_linker = 0; 481: #else 1.1 root 482: int flag_gnu_linker = 1; 1.1.1.3 root 483: #endif 1.1 root 484: 485: /* Table of language-independent -f options. 486: STRING is the option name. VARIABLE is the address of the variable. 487: ON_VALUE is the value to store in VARIABLE 488: if `-fSTRING' is seen as an option. 489: (If `-fno-STRING' is seen as an option, the opposite value is stored.) */ 490: 491: struct { char *string; int *variable; int on_value;} f_options[] = 492: { 493: {"float-store", &flag_float_store, 1}, 494: {"volatile", &flag_volatile, 1}, 1.1.1.5 root 495: {"volatile-global", &flag_volatile_global, 1}, 1.1 root 496: {"defer-pop", &flag_defer_pop, 1}, 497: {"omit-frame-pointer", &flag_omit_frame_pointer, 1}, 498: {"cse-follow-jumps", &flag_cse_follow_jumps, 1}, 1.1.1.3 root 499: {"cse-skip-blocks", &flag_cse_skip_blocks, 1}, 1.1 root 500: {"expensive-optimizations", &flag_expensive_optimizations, 1}, 501: {"thread-jumps", &flag_thread_jumps, 1}, 502: {"strength-reduce", &flag_strength_reduce, 1}, 503: {"unroll-loops", &flag_unroll_loops, 1}, 504: {"unroll-all-loops", &flag_unroll_all_loops, 1}, 505: {"writable-strings", &flag_writable_strings, 1}, 506: {"peephole", &flag_no_peephole, 0}, 507: {"force-mem", &flag_force_mem, 1}, 508: {"force-addr", &flag_force_addr, 1}, 509: {"function-cse", &flag_no_function_cse, 0}, 510: {"inline-functions", &flag_inline_functions, 1}, 511: {"keep-inline-functions", &flag_keep_inline_functions, 1}, 512: {"inline", &flag_no_inline, 0}, 513: {"syntax-only", &flag_syntax_only, 1}, 514: {"shared-data", &flag_shared_data, 1}, 515: {"caller-saves", &flag_caller_saves, 1}, 516: {"pcc-struct-return", &flag_pcc_struct_return, 1}, 1.1.1.5 root 517: {"reg-struct-return", &flag_pcc_struct_return, 0}, 1.1 root 518: {"delayed-branch", &flag_delayed_branch, 1}, 519: {"rerun-cse-after-loop", &flag_rerun_cse_after_loop, 1}, 520: {"pretend-float", &flag_pretend_float, 1}, 521: {"schedule-insns", &flag_schedule_insns, 1}, 522: {"schedule-insns2", &flag_schedule_insns_after_reload, 1}, 523: {"pic", &flag_pic, 1}, 524: {"PIC", &flag_pic, 2}, 1.1.1.3 root 525: {"fast-math", &flag_fast_math, 1}, 1.1 root 526: {"common", &flag_no_common, 0}, 527: {"inhibit-size-directive", &flag_inhibit_size_directive, 1}, 1.1.1.3 root 528: {"verbose-asm", &flag_verbose_asm, 1}, 1.1.1.6 ! root 529: {"gnu-linker", &flag_gnu_linker, 1}, ! 530: {"bytecode", &output_bytecode, 1} 1.1 root 531: }; 1.1.1.4 root 532: 533: /* Table of language-specific options. */ 534: 535: char *lang_options[] = 536: { 537: "-ftraditional", 538: "-traditional", 539: "-fnotraditional", 540: "-fno-traditional", 1.1.1.6 ! root 541: "-fallow-single-precision", 1.1.1.4 root 542: "-fsigned-char", 543: "-funsigned-char", 544: "-fno-signed-char", 545: "-fno-unsigned-char", 546: "-fsigned-bitfields", 547: "-funsigned-bitfields", 548: "-fno-signed-bitfields", 549: "-fno-unsigned-bitfields", 550: "-fshort-enums", 551: "-fno-short-enums", 552: "-fcond-mismatch", 553: "-fno-cond-mismatch", 554: "-fshort-double", 555: "-fno-short-double", 556: "-fasm", 557: "-fno-asm", 558: "-fbuiltin", 559: "-fno-builtin", 560: "-fno-ident", 561: "-fident", 1.1.1.6 ! root 562: "-fdollars-in-identifiers", ! 563: "-fno-dollars-in-identifiers", 1.1.1.4 root 564: "-ansi", 565: "-Wimplicit", 566: "-Wno-implicit", 567: "-Wwrite-strings", 568: "-Wno-write-strings", 569: "-Wcast-qual", 570: "-Wno-cast-qual", 571: "-Wpointer-arith", 572: "-Wno-pointer-arith", 573: "-Wstrict-prototypes", 574: "-Wno-strict-prototypes", 575: "-Wmissing-prototypes", 576: "-Wno-missing-prototypes", 577: "-Wredundant-decls", 578: "-Wno-redundant-decls", 579: "-Wnested-externs", 580: "-Wno-nested-externs", 581: "-Wtraditional", 582: "-Wno-traditional", 583: "-Wformat", 584: "-Wno-format", 585: "-Wchar-subscripts", 586: "-Wno-char-subscripts", 587: "-Wconversion", 588: "-Wno-conversion", 589: "-Wparentheses", 590: "-Wno-parentheses", 591: "-Wcomment", 592: "-Wno-comment", 593: "-Wcomments", 594: "-Wno-comments", 595: "-Wtrigraphs", 596: "-Wno-trigraphs", 597: "-Wimport", 598: "-Wno-import", 1.1.1.5 root 599: "-Wmissing-braces", 600: "-Wno-missing-braces", 1.1.1.4 root 601: "-Wall", 602: 603: /* These are for C++. */ 604: "-+e0", /* gcc.c tacks the `-' on the front. */ 605: "-+e1", 606: "-+e2", 607: "-fsave-memoized", 608: "-fno-save-memoized", 609: "-fcadillac", 610: "-fno-cadillac", 611: "-fgc", 612: "-fno-gc", 613: "-flabels-ok", 614: "-fno-labels-ok", 615: "-fstats", 616: "-fno-stats", 617: "-fthis-is-variable", 618: "-fno-this-is-variable", 619: "-fstrict-prototype", 620: "-fno-strict-prototype", 621: "-fall-virtual", 622: "-fno-all-virtual", 623: "-fmemoize-lookups", 624: "-fno-memoize-lookups", 625: "-felide-constructors", 626: "-fno-elide-constructors", 627: "-fhandle-exceptions", 628: "-fno-handle-exceptions", 629: "-fansi-exceptions", 630: "-fno-ansi-exceptions", 631: "-fspring-exceptions", 632: "-fno-spring-exceptions", 633: "-fdefault-inline", 634: "-fno-default-inline", 635: "-fenum-int-equiv", 636: "-fno-enum-int-equiv", 637: "-fdossier", 638: "-fno-dossier", 639: "-fxref", 640: "-fno-xref", 641: "-fnonnull-objects", 642: "-fno-nonnull-objects", 1.1.1.5 root 643: "-fimplement-inlines", 644: "-fno-implement-inlines", 1.1.1.6 ! root 645: "-fexternal-templates", ! 646: "-fno-external-templates", ! 647: "-fansi-overloading", ! 648: "-fno-ansi-overloading", 1.1.1.4 root 649: 650: "-Wreturn-type", 651: "-Wno-return-type", 652: "-Woverloaded-virtual", 653: "-Wno-overloaded-virtual", 654: "-Wenum-clash", 655: "-Wno-enum-clash", 1.1.1.5 root 656: "-Wtemplate-debugging", 657: "-Wno-template-debugging", 1.1.1.6 ! root 658: "-Wctor-dtor-privacy", ! 659: "-Wno-ctor-dtor-privacy", 1.1.1.4 root 660: 661: /* these are for obj c */ 662: "-lang-objc", 663: "-gen-decls", 1.1.1.5 root 664: "-fgnu-runtime", 665: "-fno-gnu-runtime", 666: "-fnext-runtime", 667: "-fno-next-runtime", 1.1.1.4 root 668: "-Wselector", 669: "-Wno-selector", 1.1.1.5 root 670: "-Wprotocol", 671: "-Wno-protocol", 1.1.1.6 ! root 672: ! 673: /* This is for GNAT and is temporary. */ ! 674: "-gnat", 1.1.1.4 root 675: 0 676: }; 1.1 root 677: 678: /* Options controlling warnings */ 679: 680: /* Don't print warning messages. -w. */ 681: 682: int inhibit_warnings = 0; 683: 684: /* Print various extra warnings. -W. */ 685: 686: int extra_warnings = 0; 687: 688: /* Treat warnings as errors. -Werror. */ 689: 690: int warnings_are_errors = 0; 691: 692: /* Nonzero to warn about unused local variables. */ 693: 694: int warn_unused; 695: 696: /* Nonzero to warn about variables used before they are initialized. */ 697: 698: int warn_uninitialized; 699: 700: /* Nonzero means warn about all declarations which shadow others. */ 701: 702: int warn_shadow; 703: 704: /* Warn if a switch on an enum fails to have a case for every enum value. */ 705: 706: int warn_switch; 707: 708: /* Nonzero means warn about function definitions that default the return type 709: or that use a null return and have a return-type other than void. */ 710: 711: int warn_return_type; 712: 713: /* Nonzero means warn about pointer casts that increase the required 714: alignment of the target type (and might therefore lead to a crash 715: due to a misaligned access). */ 716: 717: int warn_cast_align; 718: 719: /* Nonzero means warn about any identifiers that match in the first N 720: characters. The value N is in `id_clash_len'. */ 721: 722: int warn_id_clash; 723: int id_clash_len; 724: 725: /* Nonzero means warn if inline function is too large. */ 726: 727: int warn_inline; 728: 729: /* Warn if a function returns an aggregate, 730: since there are often incompatible calling conventions for doing this. */ 731: 732: int warn_aggregate_return; 733: 734: /* Likewise for -W. */ 735: 736: struct { char *string; int *variable; int on_value;} W_options[] = 737: { 738: {"unused", &warn_unused, 1}, 739: {"error", &warnings_are_errors, 1}, 740: {"shadow", &warn_shadow, 1}, 741: {"switch", &warn_switch, 1}, 742: {"aggregate-return", &warn_aggregate_return, 1}, 743: {"cast-align", &warn_cast_align, 1}, 1.1.1.2 root 744: {"uninitialized", &warn_uninitialized, 1}, 745: {"inline", &warn_inline, 1} 1.1 root 746: }; 747: 748: /* Output files for assembler code (real compiler output) 749: and debugging dumps. */ 750: 751: FILE *asm_out_file; 752: FILE *aux_info_file; 753: FILE *rtl_dump_file; 754: FILE *jump_opt_dump_file; 755: FILE *cse_dump_file; 756: FILE *loop_dump_file; 757: FILE *cse2_dump_file; 758: FILE *flow_dump_file; 759: FILE *combine_dump_file; 760: FILE *sched_dump_file; 761: FILE *local_reg_dump_file; 762: FILE *global_reg_dump_file; 763: FILE *sched2_dump_file; 764: FILE *jump2_opt_dump_file; 765: FILE *dbr_sched_dump_file; 766: FILE *stack_reg_dump_file; 767: 768: /* Time accumulators, to count the total time spent in various passes. */ 769: 770: int parse_time; 771: int varconst_time; 772: int integration_time; 773: int jump_time; 774: int cse_time; 775: int loop_time; 776: int cse2_time; 777: int flow_time; 778: int combine_time; 779: int sched_time; 780: int local_alloc_time; 781: int global_alloc_time; 782: int sched2_time; 783: int dbr_sched_time; 784: int shorten_branch_time; 785: int stack_reg_time; 786: int final_time; 787: int symout_time; 788: int dump_time; 789: 790: /* Return time used so far, in microseconds. */ 791: 792: int 793: get_run_time () 794: { 795: #ifdef USG 796: struct tms tms; 797: #else 798: #ifndef VMS 799: struct rusage rusage; 800: #else /* VMS */ 801: struct 802: { 803: int proc_user_time; 804: int proc_system_time; 805: int child_user_time; 806: int child_system_time; 807: } vms_times; 808: #endif 809: #endif 810: 811: if (quiet_flag) 812: return 0; 813: 814: #ifdef USG 815: times (&tms); 816: return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ); 817: #else 818: #ifndef VMS 819: getrusage (0, &rusage); 820: return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec 821: + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec); 822: #else /* VMS */ 823: times (&vms_times); 824: return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000; 825: #endif 826: #endif 827: } 828: 829: #define TIMEVAR(VAR, BODY) \ 830: do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0) 831: 832: void 833: print_time (str, total) 834: char *str; 835: int total; 836: { 837: fprintf (stderr, 838: "time in %s: %d.%06d\n", 839: str, total / 1000000, total % 1000000); 840: } 841: 842: /* Count an error or warning. Return 1 if the message should be printed. */ 843: 844: int 845: count_error (warningp) 846: int warningp; 847: { 848: if (warningp && inhibit_warnings) 849: return 0; 850: 851: if (warningp && !warnings_are_errors) 852: warningcount++; 853: else 854: { 855: static int warning_message = 0; 856: 857: if (warningp && !warning_message) 858: { 859: fprintf (stderr, "%s: warnings being treated as errors\n", progname); 860: warning_message = 1; 861: } 862: errorcount++; 863: } 864: 865: return 1; 866: } 867: 868: /* Print a fatal error message. NAME is the text. 869: Also include a system error message based on `errno'. */ 870: 871: void 872: pfatal_with_name (name) 873: char *name; 874: { 875: fprintf (stderr, "%s: ", progname); 876: perror (name); 877: exit (35); 878: } 879: 880: void 881: fatal_io_error (name) 882: char *name; 883: { 884: fprintf (stderr, "%s: %s: I/O error\n", progname, name); 885: exit (35); 886: } 887: 888: /* Called to give a better error message when we don't have an insn to match 889: what we are looking for or if the insn's constraints aren't satisfied, 890: rather than just calling abort(). */ 891: 892: void 893: fatal_insn_not_found (insn) 894: rtx insn; 895: { 1.1.1.6 ! root 896: if (!output_bytecode) ! 897: { ! 898: if (INSN_CODE (insn) < 0) ! 899: error ("internal error--unrecognizable insn:", 0); ! 900: else ! 901: error ("internal error--insn does not satisfy its constraints:", 0); ! 902: debug_rtx (insn); ! 903: } 1.1 root 904: if (asm_out_file) 905: fflush (asm_out_file); 906: if (aux_info_file) 907: fflush (aux_info_file); 908: if (rtl_dump_file) 909: fflush (rtl_dump_file); 910: if (jump_opt_dump_file) 911: fflush (jump_opt_dump_file); 912: if (cse_dump_file) 913: fflush (cse_dump_file); 914: if (loop_dump_file) 915: fflush (loop_dump_file); 916: if (cse2_dump_file) 917: fflush (cse2_dump_file); 918: if (flow_dump_file) 919: fflush (flow_dump_file); 920: if (combine_dump_file) 921: fflush (combine_dump_file); 922: if (sched_dump_file) 923: fflush (sched_dump_file); 924: if (local_reg_dump_file) 925: fflush (local_reg_dump_file); 926: if (global_reg_dump_file) 927: fflush (global_reg_dump_file); 928: if (sched2_dump_file) 929: fflush (sched2_dump_file); 930: if (jump2_opt_dump_file) 931: fflush (jump2_opt_dump_file); 932: if (dbr_sched_dump_file) 933: fflush (dbr_sched_dump_file); 934: if (stack_reg_dump_file) 935: fflush (stack_reg_dump_file); 936: abort (); 937: } 938: 939: /* This is the default decl_printable_name function. */ 940: 941: static char * 942: decl_name (decl, kind) 943: tree decl; 944: char **kind; 945: { 946: return IDENTIFIER_POINTER (DECL_NAME (decl)); 947: } 948: 949: static int need_error_newline; 950: 951: /* Function of last error message; 952: more generally, function such that if next error message is in it 953: then we don't have to mention the function name. */ 954: static tree last_error_function = NULL; 955: 956: /* Used to detect when input_file_stack has changed since last described. */ 957: static int last_error_tick; 958: 959: /* Called when the start of a function definition is parsed, 960: this function prints on stderr the name of the function. */ 961: 962: void 963: announce_function (decl) 964: tree decl; 965: { 966: if (! quiet_flag) 967: { 968: char *junk; 969: if (rtl_dump_and_exit) 970: fprintf (stderr, "%s ", IDENTIFIER_POINTER (DECL_NAME (decl))); 971: else 972: fprintf (stderr, " %s", (*decl_printable_name) (decl, &junk)); 973: fflush (stderr); 974: need_error_newline = 1; 975: last_error_function = current_function_decl; 976: } 977: } 978: 979: /* Prints out, if necessary, the name of the current function 980: which caused an error. Called from all error and warning functions. */ 981: 982: void 983: report_error_function (file) 984: char *file; 985: { 986: struct file_stack *p; 987: 988: if (need_error_newline) 989: { 990: fprintf (stderr, "\n"); 991: need_error_newline = 0; 992: } 993: 994: if (last_error_function != current_function_decl) 995: { 996: char *kind = "function"; 997: if (current_function_decl != 0 998: && TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE) 999: kind = "method"; 1000: 1001: if (file) 1002: fprintf (stderr, "%s: ", file); 1003: 1004: if (current_function_decl == NULL) 1005: fprintf (stderr, "At top level:\n"); 1006: else 1007: { 1008: char *name = (*decl_printable_name) (current_function_decl, &kind); 1009: fprintf (stderr, "In %s `%s':\n", kind, name); 1010: } 1011: 1012: last_error_function = current_function_decl; 1013: } 1014: if (input_file_stack && input_file_stack->next != 0 1015: && input_file_stack_tick != last_error_tick) 1016: { 1017: fprintf (stderr, "In file included"); 1018: for (p = input_file_stack->next; p; p = p->next) 1019: { 1020: fprintf (stderr, " from %s:%d", p->name, p->line); 1021: if (p->next) 1.1.1.6 ! root 1022: fprintf (stderr, ",\n "); 1.1 root 1023: } 1024: fprintf (stderr, ":\n"); 1025: last_error_tick = input_file_stack_tick; 1026: } 1027: } 1028: 1029: /* Report an error at the current line number. 1.1.1.6 ! root 1030: S is a string and ARGLIST are args for `printf'. We use HOST_WIDE_INT 1.1.1.4 root 1031: as the type for these args assuming it is wide enough to hold a 1032: pointer. This isn't terribly portable, but is the best we can do 1033: without vprintf universally available. */ 1.1 root 1034: 1.1.1.6 ! root 1035: #define arglist a1, a2, a3 ! 1036: #define arglist_dcl HOST_WIDE_INT a1, a2, a3; ! 1037: 1.1 root 1038: void 1.1.1.6 ! root 1039: error (s, arglist) 1.1 root 1040: char *s; 1.1.1.6 ! root 1041: arglist_dcl 1.1 root 1042: { 1.1.1.6 ! root 1043: error_with_file_and_line (input_filename, lineno, s, arglist); 1.1 root 1044: } 1045: 1046: /* Report an error at line LINE of file FILE. 1.1.1.6 ! root 1047: S and ARGLIST are a string and args for `printf'. */ 1.1 root 1048: 1049: void 1.1.1.6 ! root 1050: error_with_file_and_line (file, line, s, arglist) 1.1 root 1051: char *file; 1052: int line; 1053: char *s; 1.1.1.6 ! root 1054: arglist_dcl 1.1 root 1055: { 1056: count_error (0); 1057: 1058: report_error_function (file); 1059: 1060: if (file) 1061: fprintf (stderr, "%s:%d: ", file, line); 1062: else 1063: fprintf (stderr, "%s: ", progname); 1.1.1.6 ! root 1064: fprintf (stderr, s, arglist); ! 1065: 1.1 root 1066: fprintf (stderr, "\n"); 1067: } 1068: 1069: /* Report an error at the declaration DECL. 1.1.1.4 root 1070: S and V are a string and an arg which uses %s to substitute 1071: the declaration name. */ 1.1 root 1072: 1073: void 1074: error_with_decl (decl, s, v) 1075: tree decl; 1076: char *s; 1.1.1.4 root 1077: HOST_WIDE_INT v; 1.1 root 1078: { 1079: char *junk; 1080: count_error (0); 1081: 1082: report_error_function (DECL_SOURCE_FILE (decl)); 1083: 1084: fprintf (stderr, "%s:%d: ", 1085: DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); 1086: 1087: if (DECL_NAME (decl)) 1088: fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v); 1089: else 1090: fprintf (stderr, s, "((anonymous))", v); 1091: fprintf (stderr, "\n"); 1092: } 1093: 1094: /* Report an error at the line number of the insn INSN. 1.1.1.6 ! root 1095: S and ARGLIST are a string and args for `printf'. 1.1 root 1096: This is used only when INSN is an `asm' with operands, 1097: and each ASM_OPERANDS records its own source file and line. */ 1098: 1099: void 1.1.1.6 ! root 1100: error_for_asm (insn, s, arglist) 1.1 root 1101: rtx insn; 1102: char *s; 1.1.1.6 ! root 1103: arglist_dcl 1.1 root 1104: { 1105: char *filename; 1106: int line; 1107: rtx body = PATTERN (insn); 1108: rtx asmop; 1109: 1110: /* Find the (or one of the) ASM_OPERANDS in the insn. */ 1111: if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) 1112: asmop = SET_SRC (body); 1113: else if (GET_CODE (body) == ASM_OPERANDS) 1114: asmop = body; 1115: else if (GET_CODE (body) == PARALLEL 1116: && GET_CODE (XVECEXP (body, 0, 0)) == SET) 1117: asmop = SET_SRC (XVECEXP (body, 0, 0)); 1118: else if (GET_CODE (body) == PARALLEL 1119: && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) 1120: asmop = XVECEXP (body, 0, 0); 1121: 1122: filename = ASM_OPERANDS_SOURCE_FILE (asmop); 1123: line = ASM_OPERANDS_SOURCE_LINE (asmop); 1124: 1.1.1.6 ! root 1125: error_with_file_and_line (filename, line, s, arglist); ! 1126: } ! 1127: ! 1128: void ! 1129: fatal (s, arglist) ! 1130: char *s; ! 1131: arglist_dcl ! 1132: { ! 1133: error (s, arglist); ! 1134: exit (34); 1.1 root 1135: } 1136: 1137: /* Report a warning at line LINE. 1.1.1.6 ! root 1138: S and ARGLIST are a string and args for `printf'. */ 1.1 root 1139: 1140: void 1.1.1.6 ! root 1141: warning_with_file_and_line (file, line, s, arglist) 1.1 root 1142: char *file; 1143: int line; 1144: char *s; 1.1.1.6 ! root 1145: arglist_dcl 1.1 root 1146: { 1147: if (count_error (1) == 0) 1148: return; 1149: 1150: report_error_function (file); 1151: 1152: if (file) 1153: fprintf (stderr, "%s:%d: ", file, line); 1154: else 1155: fprintf (stderr, "%s: ", progname); 1156: 1157: fprintf (stderr, "warning: "); 1.1.1.6 ! root 1158: fprintf (stderr, s, arglist); 1.1 root 1159: fprintf (stderr, "\n"); 1160: } 1161: 1162: /* Report a warning at the current line number. 1.1.1.6 ! root 1163: S and ARGLIST are a string and args for `printf'. */ 1.1 root 1164: 1165: void 1.1.1.6 ! root 1166: warning (s, arglist) 1.1 root 1167: char *s; 1.1.1.6 ! root 1168: arglist_dcl 1.1 root 1169: { 1.1.1.6 ! root 1170: warning_with_file_and_line (input_filename, lineno, s, arglist); 1.1 root 1171: } 1172: 1173: /* Report a warning at the declaration DECL. 1174: S is string which uses %s to substitute the declaration name. 1175: V is a second parameter that S can refer to. */ 1176: 1177: void 1178: warning_with_decl (decl, s, v) 1179: tree decl; 1180: char *s; 1.1.1.4 root 1181: HOST_WIDE_INT v; 1.1 root 1182: { 1183: char *junk; 1184: 1185: if (count_error (1) == 0) 1186: return; 1187: 1188: report_error_function (DECL_SOURCE_FILE (decl)); 1189: 1190: fprintf (stderr, "%s:%d: ", 1191: DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl)); 1192: 1193: fprintf (stderr, "warning: "); 1194: if (DECL_NAME (decl)) 1195: fprintf (stderr, s, (*decl_printable_name) (decl, &junk), v); 1196: else 1197: fprintf (stderr, s, "((anonymous))", v); 1198: fprintf (stderr, "\n"); 1199: } 1200: 1201: /* Report a warning at the line number of the insn INSN. 1.1.1.6 ! root 1202: S and ARGLIST are a string and args for `printf'. 1.1 root 1203: This is used only when INSN is an `asm' with operands, 1204: and each ASM_OPERANDS records its own source file and line. */ 1205: 1206: void 1.1.1.6 ! root 1207: warning_for_asm (insn, s, arglist) 1.1 root 1208: rtx insn; 1209: char *s; 1.1.1.6 ! root 1210: arglist_dcl 1.1 root 1211: { 1212: char *filename; 1213: int line; 1214: rtx body = PATTERN (insn); 1215: rtx asmop; 1216: 1217: /* Find the (or one of the) ASM_OPERANDS in the insn. */ 1218: if (GET_CODE (body) == SET && GET_CODE (SET_SRC (body)) == ASM_OPERANDS) 1219: asmop = SET_SRC (body); 1220: else if (GET_CODE (body) == ASM_OPERANDS) 1221: asmop = body; 1222: else if (GET_CODE (body) == PARALLEL 1223: && GET_CODE (XVECEXP (body, 0, 0)) == SET) 1224: asmop = SET_SRC (XVECEXP (body, 0, 0)); 1225: else if (GET_CODE (body) == PARALLEL 1226: && GET_CODE (XVECEXP (body, 0, 0)) == ASM_OPERANDS) 1227: asmop = XVECEXP (body, 0, 0); 1228: 1229: filename = ASM_OPERANDS_SOURCE_FILE (asmop); 1230: line = ASM_OPERANDS_SOURCE_LINE (asmop); 1231: 1.1.1.6 ! root 1232: warning_with_file_and_line (filename, line, s, arglist); 1.1 root 1233: } 1234: 1235: /* These functions issue either warnings or errors depending on 1236: -pedantic-errors. */ 1237: 1238: void 1.1.1.6 ! root 1239: pedwarn (s, arglist) 1.1 root 1240: char *s; 1.1.1.6 ! root 1241: arglist_dcl 1.1 root 1242: { 1243: if (flag_pedantic_errors) 1.1.1.6 ! root 1244: error (s, arglist); 1.1 root 1245: else 1.1.1.6 ! root 1246: warning (s, arglist); 1.1 root 1247: } 1248: 1249: void 1250: pedwarn_with_decl (decl, s, v) 1251: tree decl; 1252: char *s; 1.1.1.4 root 1253: HOST_WIDE_INT v; 1.1 root 1254: { 1255: if (flag_pedantic_errors) 1256: error_with_decl (decl, s, v); 1257: else 1258: warning_with_decl (decl, s, v); 1259: } 1260: 1261: void 1.1.1.6 ! root 1262: pedwarn_with_file_and_line (file, line, s, arglist) 1.1 root 1263: char *file; 1264: int line; 1265: char *s; 1.1.1.6 ! root 1266: arglist_dcl 1.1 root 1267: { 1268: if (flag_pedantic_errors) 1.1.1.6 ! root 1269: error_with_file_and_line (file, line, s, arglist); 1.1 root 1270: else 1.1.1.6 ! root 1271: warning_with_file_and_line (file, line, s, arglist); 1.1 root 1272: } 1273: 1274: /* Apologize for not implementing some feature. 1.1.1.6 ! root 1275: S and ARGLIST are a string and args for `printf'. */ 1.1 root 1276: 1277: void 1.1.1.6 ! root 1278: sorry (s, arglist) 1.1 root 1279: char *s; 1.1.1.6 ! root 1280: arglist_dcl 1.1 root 1281: { 1282: sorrycount++; 1283: if (input_filename) 1284: fprintf (stderr, "%s:%d: ", input_filename, lineno); 1285: else 1286: fprintf (stderr, "%s: ", progname); 1287: 1288: fprintf (stderr, "sorry, not implemented: "); 1.1.1.6 ! root 1289: fprintf (stderr, s, arglist); 1.1 root 1290: fprintf (stderr, "\n"); 1291: } 1292: 1293: /* Apologize for not implementing some feature, then quit. 1.1.1.6 ! root 1294: S and ARGLIST are a string and args for `printf'. */ 1.1 root 1295: 1296: void 1.1.1.6 ! root 1297: really_sorry (s, arglist) 1.1 root 1298: char *s; 1.1.1.6 ! root 1299: arglist_dcl 1.1 root 1300: { 1301: if (input_filename) 1302: fprintf (stderr, "%s:%d: ", input_filename, lineno); 1303: else 1.1.1.5 root 1304: fprintf (stderr, "%s: ", progname); 1.1 root 1305: 1306: fprintf (stderr, "sorry, not implemented: "); 1.1.1.6 ! root 1307: fprintf (stderr, s, arglist); 1.1 root 1308: fatal (" (fatal)\n"); 1309: } 1310: 1311: /* More 'friendly' abort that prints the line and file. 1312: config.h can #define abort fancy_abort if you like that sort of thing. 1313: 1314: I don't think this is actually a good idea. 1315: Other sorts of crashes will look a certain way. 1316: It is a good thing if crashes from calling abort look the same way. 1317: -- RMS */ 1318: 1319: void 1320: fancy_abort () 1321: { 1322: fatal ("internal gcc abort"); 1323: } 1324: 1325: /* This calls abort and is used to avoid problems when abort if a macro. 1326: It is used when we need to pass the address of abort. */ 1327: 1328: void 1329: do_abort () 1330: { 1331: abort (); 1332: } 1333: 1334: /* When `malloc.c' is compiled with `rcheck' defined, 1335: it calls this function to report clobberage. */ 1336: 1337: void 1338: botch (s) 1339: { 1340: abort (); 1341: } 1342: 1343: /* Same as `malloc' but report error if no memory available. */ 1344: 1.1.1.4 root 1345: char * 1.1 root 1346: xmalloc (size) 1347: unsigned size; 1348: { 1.1.1.4 root 1349: register char *value = (char *) malloc (size); 1.1 root 1350: if (value == 0) 1351: fatal ("virtual memory exhausted"); 1352: return value; 1353: } 1354: 1355: /* Same as `realloc' but report error if no memory available. */ 1356: 1.1.1.4 root 1357: char * 1.1 root 1358: xrealloc (ptr, size) 1359: char *ptr; 1360: int size; 1361: { 1.1.1.4 root 1362: char *result = (char *) realloc (ptr, size); 1.1 root 1363: if (!result) 1364: fatal ("virtual memory exhausted"); 1365: return result; 1366: } 1367: 1368: /* Return the logarithm of X, base 2, considering X unsigned, 1.1.1.4 root 1369: if X is a power of 2. Otherwise, returns -1. 1370: 1371: This should be used via the `exact_log2' macro. */ 1.1 root 1372: 1373: int 1.1.1.4 root 1374: exact_log2_wide (x) 1375: register unsigned HOST_WIDE_INT x; 1.1 root 1376: { 1377: register int log = 0; 1378: /* Test for 0 or a power of 2. */ 1379: if (x == 0 || x != (x & -x)) 1380: return -1; 1381: while ((x >>= 1) != 0) 1382: log++; 1383: return log; 1384: } 1385: 1386: /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. 1.1.1.4 root 1387: If X is 0, return -1. 1388: 1389: This should be used via the floor_log2 macro. */ 1.1 root 1390: 1391: int 1.1.1.4 root 1392: floor_log2_wide (x) 1393: register unsigned HOST_WIDE_INT x; 1.1 root 1394: { 1395: register int log = -1; 1396: while (x != 0) 1397: log++, 1398: x >>= 1; 1399: return log; 1400: } 1401: 1402: int float_handled; 1403: jmp_buf float_handler; 1404: 1405: /* Specify where to longjmp to when a floating arithmetic error happens. 1406: If HANDLER is 0, it means don't handle the errors any more. */ 1407: 1408: void 1409: set_float_handler (handler) 1410: jmp_buf handler; 1411: { 1412: float_handled = (handler != 0); 1413: if (handler) 1414: bcopy (handler, float_handler, sizeof (float_handler)); 1415: } 1416: 1.1.1.4 root 1417: /* Specify, in HANDLER, where to longjmp to when a floating arithmetic 1418: error happens, pushing the previous specification into OLD_HANDLER. 1419: Return an indication of whether there was a previous handler in effect. */ 1420: 1421: int 1422: push_float_handler (handler, old_handler) 1423: jmp_buf handler, old_handler; 1424: { 1425: int was_handled = float_handled; 1426: 1427: float_handled = 1; 1428: if (was_handled) 1429: bcopy (float_handler, old_handler, sizeof (float_handler)); 1430: bcopy (handler, float_handler, sizeof (float_handler)); 1431: return was_handled; 1432: } 1433: 1434: /* Restore the previous specification of whether and where to longjmp to 1435: when a floating arithmetic error happens. */ 1436: 1437: void 1438: pop_float_handler (handled, handler) 1439: int handled; 1440: jmp_buf handler; 1441: { 1442: float_handled = handled; 1443: if (handled) 1444: bcopy (handler, float_handler, sizeof (float_handler)); 1445: } 1446: 1.1 root 1447: /* Signals actually come here. */ 1448: 1449: static void 1450: float_signal (signo) 1451: /* If this is missing, some compilers complain. */ 1452: int signo; 1453: { 1454: if (float_handled == 0) 1455: abort (); 1456: #if defined (USG) || defined (hpux) 1457: signal (SIGFPE, float_signal); /* re-enable the signal catcher */ 1458: #endif 1459: float_handled = 0; 1460: signal (SIGFPE, float_signal); 1461: longjmp (float_handler, 1); 1462: } 1463: 1464: /* Handler for SIGPIPE. */ 1465: 1466: static void 1467: pipe_closed (signo) 1468: /* If this is missing, some compilers complain. */ 1469: int signo; 1470: { 1471: fatal ("output pipe has been closed"); 1472: } 1473: 1474: /* Strip off a legitimate source ending from the input string NAME of 1475: length LEN. */ 1476: 1477: void 1478: strip_off_ending (name, len) 1479: char *name; 1480: int len; 1481: { 1482: if (len > 2 && ! strcmp (".c", name + len - 2)) 1483: name[len - 2] = 0; 1484: else if (len > 2 && ! strcmp (".m", name + len - 2)) 1485: name[len - 2] = 0; 1486: else if (len > 2 && ! strcmp (".i", name + len - 2)) 1487: name[len - 2] = 0; 1488: else if (len > 3 && ! strcmp (".ii", name + len - 3)) 1489: name[len - 3] = 0; 1490: else if (len > 3 && ! strcmp (".co", name + len - 3)) 1491: name[len - 3] = 0; 1492: else if (len > 3 && ! strcmp (".cc", name + len - 3)) 1493: name[len - 3] = 0; 1.1.1.4 root 1494: else if (len > 2 && ! strcmp (".C", name + len - 2)) 1495: name[len - 2] = 0; 1496: else if (len > 4 && ! strcmp (".cxx", name + len - 4)) 1497: name[len - 4] = 0; 1.1 root 1498: else if (len > 2 && ! strcmp (".f", name + len - 2)) 1499: name[len - 2] = 0; 1.1.1.6 ! root 1500: /* Ada will use extensions like .ada, .adb, and .ads, so just test ! 1501: for "ad". */ ! 1502: else if (len > 4 && ! strncmp (".ad", name + len - 4, 3)) 1.1 root 1503: name[len - 4] = 0; 1.1.1.5 root 1504: else if (len > 4 && ! strcmp (".atr", name + len - 4)) 1505: name[len - 4] = 0; 1.1 root 1506: } 1507: 1.1.1.6 ! root 1508: /* Output a quoted string. */ ! 1509: void ! 1510: output_quoted_string (asm_file, string) ! 1511: FILE *asm_file; ! 1512: char *string; ! 1513: { ! 1514: char c; ! 1515: ! 1516: putc ('\"', asm_file); ! 1517: while ((c = *string++) != 0) ! 1518: { ! 1519: if (c == '\"' || c == '\\') ! 1520: putc ('\\', asm_file); ! 1521: putc (c, asm_file); ! 1522: } ! 1523: putc ('\"', asm_file); ! 1524: } ! 1525: 1.1 root 1526: /* Output a file name in the form wanted by System V. */ 1527: 1528: void 1529: output_file_directive (asm_file, input_name) 1530: FILE *asm_file; 1531: char *input_name; 1532: { 1533: int len = strlen (input_name); 1534: char *na = input_name + len; 1535: 1536: /* NA gets INPUT_NAME sans directory names. */ 1537: while (na > input_name) 1538: { 1539: if (na[-1] == '/') 1540: break; 1541: na--; 1542: } 1543: 1544: #ifdef ASM_OUTPUT_MAIN_SOURCE_FILENAME 1545: ASM_OUTPUT_MAIN_SOURCE_FILENAME (asm_file, na); 1546: #else 1547: #ifdef ASM_OUTPUT_SOURCE_FILENAME 1548: ASM_OUTPUT_SOURCE_FILENAME (asm_file, na); 1549: #else 1.1.1.6 ! root 1550: fprintf (asm_file, "\t.file\t"); ! 1551: output_quoted_string (asm_file, na); ! 1552: fputc ('\n', asm_file); 1.1 root 1553: #endif 1554: #endif 1555: } 1556: 1.1.1.5 root 1557: /* Routine to build language identifier for object file. */ 1558: static void 1559: output_lang_identify (asm_out_file) 1560: FILE *asm_out_file; 1561: { 1562: int len = strlen (lang_identify ()) + sizeof ("__gnu_compiled_") + 1; 1563: char *s = (char *) alloca (len); 1564: sprintf (s, "__gnu_compiled_%s", lang_identify ()); 1565: ASM_OUTPUT_LABEL (asm_out_file, s); 1566: } 1567: 1.1 root 1568: /* Compile an entire file of output from cpp, named NAME. 1569: Write a file of assembly output and various debugging dumps. */ 1570: 1571: static void 1572: compile_file (name) 1573: char *name; 1574: { 1575: tree globals; 1576: int start_time; 1577: int dump_base_name_length; 1578: 1579: int name_specified = name != 0; 1580: 1581: if (dump_base_name == 0) 1582: dump_base_name = name ? name : "gccdump"; 1583: dump_base_name_length = strlen (dump_base_name); 1584: 1585: parse_time = 0; 1586: varconst_time = 0; 1587: integration_time = 0; 1588: jump_time = 0; 1589: cse_time = 0; 1590: loop_time = 0; 1591: cse2_time = 0; 1592: flow_time = 0; 1593: combine_time = 0; 1594: sched_time = 0; 1595: local_alloc_time = 0; 1596: global_alloc_time = 0; 1597: sched2_time = 0; 1598: dbr_sched_time = 0; 1599: shorten_branch_time = 0; 1600: stack_reg_time = 0; 1601: final_time = 0; 1602: symout_time = 0; 1603: dump_time = 0; 1604: 1605: /* Open input file. */ 1606: 1607: if (name == 0 || !strcmp (name, "-")) 1608: { 1609: finput = stdin; 1610: name = "stdin"; 1611: } 1612: else 1613: finput = fopen (name, "r"); 1614: if (finput == 0) 1615: pfatal_with_name (name); 1616: 1.1.1.3 root 1617: #ifdef IO_BUFFER_SIZE 1618: setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE); 1619: #endif 1620: 1.1 root 1621: /* Initialize data in various passes. */ 1622: 1623: init_obstacks (); 1624: init_tree_codes (); 1625: init_lex (); 1.1.1.6 ! root 1626: /* Some of these really don't need to be called when generating bytecode, ! 1627: but the options would have to be parsed first to know that. -bson */ 1.1 root 1628: init_rtl (); 1629: init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL 1630: || debug_info_level == DINFO_LEVEL_VERBOSE); 1631: init_decl_processing (); 1632: init_optabs (); 1633: init_stmt (); 1634: init_expmed (); 1.1.1.4 root 1635: init_expr_once (); 1.1 root 1636: init_loop (); 1637: init_reload (); 1638: 1639: if (flag_caller_saves) 1640: init_caller_save (); 1641: 1.1.1.2 root 1642: /* If auxiliary info generation is desired, open the output file. 1643: This goes in the same directory as the source file--unlike 1644: all the other output files. */ 1.1 root 1645: if (flag_gen_aux_info) 1646: { 1647: aux_info_file = fopen (aux_info_file_name, "w"); 1648: if (aux_info_file == 0) 1649: pfatal_with_name (aux_info_file_name); 1650: } 1651: 1652: /* If rtl dump desired, open the output file. */ 1653: if (rtl_dump) 1654: { 1655: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); 1656: strcpy (dumpname, dump_base_name); 1657: strcat (dumpname, ".rtl"); 1658: rtl_dump_file = fopen (dumpname, "w"); 1659: if (rtl_dump_file == 0) 1660: pfatal_with_name (dumpname); 1661: } 1662: 1663: /* If jump_opt dump desired, open the output file. */ 1664: if (jump_opt_dump) 1665: { 1666: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); 1667: strcpy (dumpname, dump_base_name); 1668: strcat (dumpname, ".jump"); 1669: jump_opt_dump_file = fopen (dumpname, "w"); 1670: if (jump_opt_dump_file == 0) 1671: pfatal_with_name (dumpname); 1672: } 1673: 1674: /* If cse dump desired, open the output file. */ 1675: if (cse_dump) 1676: { 1677: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); 1678: strcpy (dumpname, dump_base_name); 1679: strcat (dumpname, ".cse"); 1680: cse_dump_file = fopen (dumpname, "w"); 1681: if (cse_dump_file == 0) 1682: pfatal_with_name (dumpname); 1683: } 1684: 1685: /* If loop dump desired, open the output file. */ 1686: if (loop_dump) 1687: { 1688: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); 1689: strcpy (dumpname, dump_base_name); 1690: strcat (dumpname, ".loop"); 1691: loop_dump_file = fopen (dumpname, "w"); 1692: if (loop_dump_file == 0) 1693: pfatal_with_name (dumpname); 1694: } 1695: 1696: /* If cse2 dump desired, open the output file. */ 1697: if (cse2_dump) 1698: { 1699: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); 1700: strcpy (dumpname, dump_base_name); 1701: strcat (dumpname, ".cse2"); 1702: cse2_dump_file = fopen (dumpname, "w"); 1703: if (cse2_dump_file == 0) 1704: pfatal_with_name (dumpname); 1705: } 1706: 1707: /* If flow dump desired, open the output file. */ 1708: if (flow_dump) 1709: { 1710: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); 1711: strcpy (dumpname, dump_base_name); 1712: strcat (dumpname, ".flow"); 1713: flow_dump_file = fopen (dumpname, "w"); 1714: if (flow_dump_file == 0) 1715: pfatal_with_name (dumpname); 1716: } 1717: 1718: /* If combine dump desired, open the output file. */ 1719: if (combine_dump) 1720: { 1721: register char *dumpname = (char *) xmalloc (dump_base_name_length + 10); 1722: strcpy (dumpname, dump_base_name); 1723: strcat (dumpname, ".combine"); 1724: combine_dump_file = fopen (dumpname, "w"); 1725: if (combine_dump_file == 0) 1726: pfatal_with_name (dumpname); 1727: } 1728: 1729: /* If scheduling dump desired, open the output file. */ 1730: if (sched_dump) 1731: { 1732: register char *dumpname = (char *) xmalloc (dump_base_name_length + 7); 1733: strcpy (dumpname, dump_base_name); 1734: strcat (dumpname, ".sched"); 1735: sched_dump_file = fopen (dumpname, "w"); 1736: if (sched_dump_file == 0) 1737: pfatal_with_name (dumpname); 1738: } 1739: 1740: /* If local_reg dump desired, open the output file. */ 1741: if (local_reg_dump) 1742: { 1743: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); 1744: strcpy (dumpname, dump_base_name); 1745: strcat (dumpname, ".lreg"); 1746: local_reg_dump_file = fopen (dumpname, "w"); 1747: if (local_reg_dump_file == 0) 1748: pfatal_with_name (dumpname); 1749: } 1750: 1751: /* If global_reg dump desired, open the output file. */ 1752: if (global_reg_dump) 1753: { 1754: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); 1755: strcpy (dumpname, dump_base_name); 1756: strcat (dumpname, ".greg"); 1757: global_reg_dump_file = fopen (dumpname, "w"); 1758: if (global_reg_dump_file == 0) 1759: pfatal_with_name (dumpname); 1760: } 1761: 1762: /* If 2nd scheduling dump desired, open the output file. */ 1763: if (sched2_dump) 1764: { 1765: register char *dumpname = (char *) xmalloc (dump_base_name_length + 8); 1766: strcpy (dumpname, dump_base_name); 1767: strcat (dumpname, ".sched2"); 1768: sched2_dump_file = fopen (dumpname, "w"); 1769: if (sched2_dump_file == 0) 1770: pfatal_with_name (dumpname); 1771: } 1772: 1773: /* If jump2_opt dump desired, open the output file. */ 1774: if (jump2_opt_dump) 1775: { 1776: register char *dumpname = (char *) xmalloc (dump_base_name_length + 7); 1777: strcpy (dumpname, dump_base_name); 1778: strcat (dumpname, ".jump2"); 1779: jump2_opt_dump_file = fopen (dumpname, "w"); 1780: if (jump2_opt_dump_file == 0) 1781: pfatal_with_name (dumpname); 1782: } 1783: 1784: /* If dbr_sched dump desired, open the output file. */ 1785: if (dbr_sched_dump) 1786: { 1787: register char *dumpname = (char *) xmalloc (dump_base_name_length + 7); 1788: strcpy (dumpname, dump_base_name); 1789: strcat (dumpname, ".dbr"); 1790: dbr_sched_dump_file = fopen (dumpname, "w"); 1791: if (dbr_sched_dump_file == 0) 1792: pfatal_with_name (dumpname); 1793: } 1794: 1795: #ifdef STACK_REGS 1796: 1797: /* If stack_reg dump desired, open the output file. */ 1798: if (stack_reg_dump) 1799: { 1800: register char *dumpname = (char *) xmalloc (dump_base_name_length + 10); 1801: strcpy (dumpname, dump_base_name); 1802: strcat (dumpname, ".stack"); 1803: stack_reg_dump_file = fopen (dumpname, "w"); 1804: if (stack_reg_dump_file == 0) 1805: pfatal_with_name (dumpname); 1806: } 1807: 1808: #endif 1809: 1810: /* Open assembler code output file. */ 1811: 1812: if (! name_specified && asm_file_name == 0) 1813: asm_out_file = stdout; 1814: else 1815: { 1816: register char *dumpname = (char *) xmalloc (dump_base_name_length + 6); 1817: int len = strlen (dump_base_name); 1818: strcpy (dumpname, dump_base_name); 1819: strip_off_ending (dumpname, len); 1820: strcat (dumpname, ".s"); 1821: if (asm_file_name == 0) 1822: { 1823: asm_file_name = (char *) xmalloc (strlen (dumpname) + 1); 1824: strcpy (asm_file_name, dumpname); 1825: } 1826: if (!strcmp (asm_file_name, "-")) 1827: asm_out_file = stdout; 1828: else 1829: asm_out_file = fopen (asm_file_name, "w"); 1830: if (asm_out_file == 0) 1831: pfatal_with_name (asm_file_name); 1832: } 1833: 1.1.1.2 root 1834: #ifdef IO_BUFFER_SIZE 1.1.1.3 root 1835: setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE), 1836: _IOFBF, IO_BUFFER_SIZE); 1.1.1.2 root 1837: #endif 1838: 1.1 root 1839: input_filename = name; 1840: 1841: /* Perform language-specific initialization. 1842: This may set main_input_filename. */ 1843: lang_init (); 1844: 1845: /* If the input doesn't start with a #line, use the input name 1846: as the official input file name. */ 1847: if (main_input_filename == 0) 1848: main_input_filename = name; 1849: 1850: /* Put an entry on the input file stack for the main input file. */ 1851: input_file_stack 1852: = (struct file_stack *) xmalloc (sizeof (struct file_stack)); 1853: input_file_stack->next = 0; 1854: input_file_stack->name = input_filename; 1855: 1.1.1.6 ! root 1856: if (!output_bytecode) ! 1857: { ! 1858: ASM_FILE_START (asm_out_file); ! 1859: } 1.1 root 1860: 1.1.1.6 ! root 1861: /* Output something to inform GDB that this compilation was by GCC. Also ! 1862: serves to tell GDB file consists of bytecodes. */ ! 1863: if (output_bytecode) ! 1864: fprintf (asm_out_file, "bc_gcc2_compiled.:\n"); ! 1865: else ! 1866: { 1.1 root 1867: #ifndef ASM_IDENTIFY_GCC 1.1.1.6 ! root 1868: fprintf (asm_out_file, "gcc2_compiled.:\n"); 1.1 root 1869: #else 1.1.1.6 ! root 1870: ASM_IDENTIFY_GCC (asm_out_file); 1.1 root 1871: #endif 1.1.1.6 ! root 1872: } 1.1.1.5 root 1873: 1874: /* Output something to identify which front-end produced this file. */ 1875: #ifdef ASM_IDENTIFY_LANGUAGE 1876: ASM_IDENTIFY_LANGUAGE (asm_out_file); 1877: #endif 1878: 1.1.1.6 ! root 1879: if (output_bytecode) ! 1880: { ! 1881: if (profile_flag || profile_block_flag) ! 1882: error ("profiling not supported in bytecode compilation"); ! 1883: } ! 1884: else ! 1885: { ! 1886: /* ??? Note: There used to be a conditional here ! 1887: to call assemble_zeros without fail if DBX_DEBUGGING_INFO is defined. ! 1888: This was to guarantee separation between gcc_compiled. and ! 1889: the first function, for the sake of dbx on Suns. ! 1890: However, having the extra zero here confused the Emacs ! 1891: code for unexec, and might confuse other programs too. ! 1892: Therefore, I took out that change. ! 1893: In future versions we should find another way to solve ! 1894: that dbx problem. -- rms, 23 May 93. */ ! 1895: ! 1896: /* Don't let the first function fall at the same address ! 1897: as gcc_compiled., if profiling. */ ! 1898: if (profile_flag || profile_block_flag) ! 1899: assemble_zeros (UNITS_PER_WORD); ! 1900: } 1.1 root 1901: 1902: /* If dbx symbol table desired, initialize writing it 1903: and output the predefined types. */ 1.1.1.2 root 1904: #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) 1905: if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) 1.1 root 1906: TIMEVAR (symout_time, dbxout_init (asm_out_file, main_input_filename, 1907: getdecls ())); 1908: #endif 1909: #ifdef SDB_DEBUGGING_INFO 1910: if (write_symbols == SDB_DEBUG) 1911: TIMEVAR (symout_time, sdbout_init (asm_out_file, main_input_filename, 1912: getdecls ())); 1913: #endif 1914: #ifdef DWARF_DEBUGGING_INFO 1915: if (write_symbols == DWARF_DEBUG) 1916: TIMEVAR (symout_time, dwarfout_init (asm_out_file, main_input_filename)); 1917: #endif 1918: 1919: /* Initialize yet another pass. */ 1920: 1.1.1.6 ! root 1921: if (!output_bytecode) ! 1922: init_final (main_input_filename); 1.1 root 1923: 1924: start_time = get_run_time (); 1925: 1926: /* Call the parser, which parses the entire file 1927: (calling rest_of_compilation for each function). */ 1928: 1929: if (yyparse () != 0) 1930: if (errorcount == 0) 1931: fprintf (stderr, "Errors detected in input file (your bison.simple is out of date)"); 1932: 1933: /* Compilation is now finished except for writing 1934: what's left of the symbol table output. */ 1935: 1936: parse_time += get_run_time () - start_time; 1937: 1938: parse_time -= integration_time; 1939: parse_time -= varconst_time; 1940: 1941: globals = getdecls (); 1942: 1943: /* Really define vars that have had only a tentative definition. 1944: Really output inline functions that must actually be callable 1945: and have not been output so far. */ 1946: 1947: { 1948: int len = list_length (globals); 1949: tree *vec = (tree *) alloca (sizeof (tree) * len); 1950: int i; 1951: tree decl; 1952: 1953: /* Process the decls in reverse order--earliest first. 1954: Put them into VEC from back to front, then take out from front. */ 1955: 1956: for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl)) 1957: vec[len - i - 1] = decl; 1958: 1959: for (i = 0; i < len; i++) 1960: { 1961: decl = vec[i]; 1.1.1.5 root 1962: if (TREE_CODE (decl) == VAR_DECL && DECL_SIZE (decl) == 0 1963: && incomplete_decl_finalize_hook != 0) 1964: (*incomplete_decl_finalize_hook) (decl); 1965: 1.1 root 1966: if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl) 1967: && ! TREE_ASM_WRITTEN (decl)) 1968: { 1969: /* Don't write out static consts, unless we used them. 1970: (This used to write them out only if the address was 1971: taken, but that was wrong; if the variable was simply 1972: referred to, it still needs to exist or else it will 1973: be undefined in the linker.) */ 1974: if (! TREE_READONLY (decl) 1975: || TREE_PUBLIC (decl) 1976: || TREE_USED (decl) 1977: || TREE_ADDRESSABLE (decl) 1978: || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl))) 1.1.1.4 root 1979: rest_of_decl_compilation (decl, NULL_PTR, 1, 1); 1.1 root 1980: else 1981: /* Cancel the RTL for this decl so that, if debugging info 1982: output for global variables is still to come, 1983: this one will be omitted. */ 1984: DECL_RTL (decl) = NULL; 1985: } 1986: 1987: if (TREE_CODE (decl) == FUNCTION_DECL 1988: && ! TREE_ASM_WRITTEN (decl) 1989: && DECL_INITIAL (decl) != 0 1990: && (TREE_ADDRESSABLE (decl) 1991: || TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl))) 1.1.1.4 root 1992: && ! DECL_EXTERNAL (decl)) 1.1.1.6 ! root 1993: { ! 1994: temporary_allocation (); ! 1995: output_inline_function (decl); ! 1996: permanent_allocation (); ! 1997: } 1.1 root 1998: 1.1.1.2 root 1999: /* Warn about any function 2000: declared static but not defined. 2001: We don't warn about variables, 2002: because many programs have static variables 2003: that exist only to get some text into the object file. */ 1.1 root 2004: if ((warn_unused 2005: || TREE_USED (decl) 2006: || (DECL_NAME (decl) && TREE_USED (DECL_NAME (decl)))) 1.1.1.2 root 2007: && TREE_CODE (decl) == FUNCTION_DECL 1.1 root 2008: && DECL_INITIAL (decl) == 0 1.1.1.4 root 2009: && DECL_EXTERNAL (decl) 1.1 root 2010: && ! TREE_PUBLIC (decl)) 1.1.1.5 root 2011: { 2012: /* This should be a pedwarn, except that there is 2013: no easy way to prevent it from happening when the 2014: name is used only inside a sizeof. 2015: This at least avoids being incorrect. */ 2016: warning_with_decl (decl, 2017: "`%s' declared `static' but never defined"); 2018: /* This symbol is effectively an "extern" declaration now. */ 2019: TREE_PUBLIC (decl) = 1; 2020: assemble_external (decl); 2021: 2022: } 1.1 root 2023: /* Warn about static fns or vars defined but not used, 2024: but not about inline functions 2025: since unused inline statics is normal practice. */ 2026: if (warn_unused 2027: && (TREE_CODE (decl) == FUNCTION_DECL 2028: || TREE_CODE (decl) == VAR_DECL) 1.1.1.4 root 2029: && ! DECL_IN_SYSTEM_HEADER (decl) 2030: && ! DECL_EXTERNAL (decl) 1.1 root 2031: && ! TREE_PUBLIC (decl) 2032: && ! TREE_USED (decl) 1.1.1.4 root 2033: && ! DECL_INLINE (decl) 1.1.1.5 root 2034: && ! DECL_REGISTER (decl) 1.1 root 2035: /* The TREE_USED bit for file-scope decls 2036: is kept in the identifier, to handle multiple 2037: external decls in different scopes. */ 2038: && ! TREE_USED (DECL_NAME (decl))) 2039: warning_with_decl (decl, "`%s' defined but not used"); 2040: 2041: #ifdef SDB_DEBUGGING_INFO 2042: /* The COFF linker can move initialized global vars to the end. 2043: And that can screw up the symbol ordering. 2044: By putting the symbols in that order to begin with, 2045: we avoid a problem. [email protected]. */ 2046: if (write_symbols == SDB_DEBUG && TREE_CODE (decl) == VAR_DECL 2047: && TREE_PUBLIC (decl) && DECL_INITIAL (decl) 2048: && DECL_RTL (decl) != 0) 2049: TIMEVAR (symout_time, sdbout_symbol (decl, 0)); 2050: 2051: /* Output COFF information for non-global 2052: file-scope initialized variables. */ 2053: if (write_symbols == SDB_DEBUG 2054: && TREE_CODE (decl) == VAR_DECL 2055: && DECL_INITIAL (decl) 2056: && DECL_RTL (decl) != 0 2057: && GET_CODE (DECL_RTL (decl)) == MEM) 2058: TIMEVAR (symout_time, sdbout_toplevel_data (decl)); 2059: #endif /* SDB_DEBUGGING_INFO */ 2060: #ifdef DWARF_DEBUGGING_INFO 1.1.1.3 root 2061: /* Output DWARF information for file-scope tentative data object 1.1 root 2062: declarations, file-scope (extern) function declarations (which 2063: had no corresponding body) and file-scope tagged type declarations 2064: and definitions which have not yet been forced out. */ 2065: 2066: if (write_symbols == DWARF_DEBUG 2067: && (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))) 2068: TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 1)); 2069: #endif 2070: } 2071: } 2072: 2073: /* Do dbx symbols */ 1.1.1.2 root 2074: #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) 2075: if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) 1.1 root 2076: TIMEVAR (symout_time, 2077: { 2078: dbxout_finish (asm_out_file, main_input_filename); 2079: }); 2080: #endif 2081: 2082: #ifdef DWARF_DEBUGGING_INFO 2083: if (write_symbols == DWARF_DEBUG) 2084: TIMEVAR (symout_time, 2085: { 2086: dwarfout_finish (); 2087: }); 2088: #endif 2089: 2090: /* Output some stuff at end of file if nec. */ 2091: 1.1.1.6 ! root 2092: if (!output_bytecode) ! 2093: { ! 2094: end_final (main_input_filename); 1.1 root 2095: 2096: #ifdef ASM_FILE_END 1.1.1.6 ! root 2097: ASM_FILE_END (asm_out_file); 1.1 root 2098: #endif 1.1.1.6 ! root 2099: } 1.1 root 2100: 2101: after_finish_compilation: 2102: 2103: /* Language-specific end of compilation actions. */ 2104: 2105: lang_finish (); 2106: 2107: /* Close the dump files. */ 2108: 2109: if (flag_gen_aux_info) 2110: { 2111: fclose (aux_info_file); 2112: if (errorcount) 2113: unlink (aux_info_file_name); 2114: } 2115: 2116: if (rtl_dump) 2117: fclose (rtl_dump_file); 2118: 2119: if (jump_opt_dump) 2120: fclose (jump_opt_dump_file); 2121: 2122: if (cse_dump) 2123: fclose (cse_dump_file); 2124: 2125: if (loop_dump) 2126: fclose (loop_dump_file); 2127: 2128: if (cse2_dump) 2129: fclose (cse2_dump_file); 2130: 2131: if (flow_dump) 2132: fclose (flow_dump_file); 2133: 2134: if (combine_dump) 2135: { 2136: dump_combine_total_stats (combine_dump_file); 2137: fclose (combine_dump_file); 2138: } 2139: 2140: if (sched_dump) 2141: fclose (sched_dump_file); 2142: 2143: if (local_reg_dump) 2144: fclose (local_reg_dump_file); 2145: 2146: if (global_reg_dump) 2147: fclose (global_reg_dump_file); 2148: 2149: if (sched2_dump) 2150: fclose (sched2_dump_file); 2151: 2152: if (jump2_opt_dump) 2153: fclose (jump2_opt_dump_file); 2154: 2155: if (dbr_sched_dump) 2156: fclose (dbr_sched_dump_file); 2157: 2158: #ifdef STACK_REGS 2159: if (stack_reg_dump) 2160: fclose (stack_reg_dump_file); 2161: #endif 2162: 2163: /* Close non-debugging input and output files. Take special care to note 2164: whether fclose returns an error, since the pages might still be on the 2165: buffer chain while the file is open. */ 2166: 2167: fclose (finput); 2168: if (ferror (asm_out_file) != 0 || fclose (asm_out_file) != 0) 2169: fatal_io_error (asm_file_name); 2170: 2171: /* Print the times. */ 2172: 2173: if (! quiet_flag) 2174: { 2175: fprintf (stderr,"\n"); 2176: print_time ("parse", parse_time); 1.1.1.6 ! root 2177: ! 2178: if (!output_bytecode) ! 2179: { ! 2180: print_time ("integration", integration_time); ! 2181: print_time ("jump", jump_time); ! 2182: print_time ("cse", cse_time); ! 2183: print_time ("loop", loop_time); ! 2184: print_time ("cse2", cse2_time); ! 2185: print_time ("flow", flow_time); ! 2186: print_time ("combine", combine_time); ! 2187: print_time ("sched", sched_time); ! 2188: print_time ("local-alloc", local_alloc_time); ! 2189: print_time ("global-alloc", global_alloc_time); ! 2190: print_time ("sched2", sched2_time); ! 2191: print_time ("dbranch", dbr_sched_time); ! 2192: print_time ("shorten-branch", shorten_branch_time); ! 2193: print_time ("stack-reg", stack_reg_time); ! 2194: print_time ("final", final_time); ! 2195: print_time ("varconst", varconst_time); ! 2196: print_time ("symout", symout_time); ! 2197: print_time ("dump", dump_time); ! 2198: } 1.1 root 2199: } 2200: } 2201: 2202: /* This is called from various places for FUNCTION_DECL, VAR_DECL, 2203: and TYPE_DECL nodes. 2204: 2205: This does nothing for local (non-static) variables. 2206: Otherwise, it sets up the RTL and outputs any assembler code 2207: (label definition, storage allocation and initialization). 2208: 2209: DECL is the declaration. If ASMSPEC is nonzero, it specifies 2210: the assembler symbol name to be used. TOP_LEVEL is nonzero 2211: if this declaration is not within a function. */ 2212: 2213: void 2214: rest_of_decl_compilation (decl, asmspec, top_level, at_end) 2215: tree decl; 2216: char *asmspec; 2217: int top_level; 2218: int at_end; 2219: { 2220: /* Declarations of variables, and of functions defined elsewhere. */ 2221: 1.1.1.6 ! root 2222: /* The most obvious approach, to put an #ifndef around where ! 2223: this macro is used, doesn't work since it's inside a macro call. */ ! 2224: #ifndef ASM_FINISH_DECLARE_OBJECT ! 2225: #define ASM_FINISH_DECLARE_OBJECT(FILE, DECL, TOP, END) ! 2226: #endif ! 2227: 1.1 root 2228: /* Forward declarations for nested functions are not "external", 2229: but we need to treat them as if they were. */ 1.1.1.4 root 2230: if (TREE_STATIC (decl) || DECL_EXTERNAL (decl) 1.1 root 2231: || TREE_CODE (decl) == FUNCTION_DECL) 2232: TIMEVAR (varconst_time, 2233: { 2234: make_decl_rtl (decl, asmspec, top_level); 1.1.1.6 ! root 2235: /* Initialized extern variable exists to be replaced ! 2236: with its value, or represents something that will be ! 2237: output in another file. */ 1.1.1.3 root 2238: if (! (TREE_CODE (decl) == VAR_DECL 1.1.1.6 ! root 2239: && DECL_EXTERNAL (decl) && TREE_READONLY (decl) ! 2240: && DECL_INITIAL (decl) != 0 ! 2241: && DECL_INITIAL (decl) != error_mark_node)) 1.1.1.3 root 2242: /* Don't output anything 2243: when a tentative file-scope definition is seen. 2244: But at end of compilation, do output code for them. */ 2245: if (! (! at_end && top_level 2246: && (DECL_INITIAL (decl) == 0 1.1.1.6 ! root 2247: || DECL_INITIAL (decl) == error_mark_node))) ! 2248: assemble_variable (decl, top_level, at_end, 0); ! 2249: if (decl == last_assemble_variable_decl) ! 2250: { ! 2251: ASM_FINISH_DECLARE_OBJECT (asm_out_file, decl, ! 2252: top_level, at_end); ! 2253: } 1.1 root 2254: }); 1.1.1.4 root 2255: else if (DECL_REGISTER (decl) && asmspec != 0) 1.1 root 2256: { 2257: if (decode_reg_name (asmspec) >= 0) 2258: { 2259: DECL_RTL (decl) = 0; 2260: make_decl_rtl (decl, asmspec, top_level); 2261: } 2262: else 2263: error ("invalid register name `%s' for register variable", asmspec); 2264: } 1.1.1.2 root 2265: #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) 2266: else if ((write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) 2267: && TREE_CODE (decl) == TYPE_DECL) 1.1 root 2268: TIMEVAR (symout_time, dbxout_symbol (decl, 0)); 2269: #endif 2270: #ifdef SDB_DEBUGGING_INFO 2271: else if (write_symbols == SDB_DEBUG && top_level 2272: && TREE_CODE (decl) == TYPE_DECL) 2273: TIMEVAR (symout_time, sdbout_symbol (decl, 0)); 2274: #endif 2275: } 2276: 2277: /* Called after finishing a record, union or enumeral type. */ 2278: 2279: void 2280: rest_of_type_compilation (type, toplev) 2281: tree type; 2282: int toplev; 2283: { 1.1.1.2 root 2284: #if defined (DBX_DEBUGGING_INFO) || defined (XCOFF_DEBUGGING_INFO) 2285: if (write_symbols == DBX_DEBUG || write_symbols == XCOFF_DEBUG) 1.1 root 2286: TIMEVAR (symout_time, dbxout_symbol (TYPE_STUB_DECL (type), !toplev)); 2287: #endif 2288: #ifdef SDB_DEBUGGING_INFO 2289: if (write_symbols == SDB_DEBUG) 2290: TIMEVAR (symout_time, sdbout_symbol (TYPE_STUB_DECL (type), !toplev)); 2291: #endif 2292: } 2293: 2294: /* This is called from finish_function (within yyparse) 2295: after each top-level definition is parsed. 2296: It is supposed to compile that function or variable 2297: and output the assembler code for it. 2298: After we return, the tree storage is freed. */ 2299: 2300: void 2301: rest_of_compilation (decl) 2302: tree decl; 2303: { 2304: register rtx insns; 2305: int start_time = get_run_time (); 2306: int tem; 2307: /* Nonzero if we have saved the original DECL_INITIAL of the function, 2308: to be restored after we finish compiling the function 2309: (for use when compiling inline calls to this function). */ 2310: tree saved_block_tree = 0; 1.1.1.4 root 2311: /* Likewise, for DECL_ARGUMENTS. */ 2312: tree saved_arguments = 0; 2313: int failure = 0; 1.1 root 2314: 1.1.1.6 ! root 2315: if (output_bytecode) ! 2316: return; ! 2317: 1.1 root 2318: /* If we are reconsidering an inline function 2319: at the end of compilation, skip the stuff for making it inline. */ 2320: 2321: if (DECL_SAVED_INSNS (decl) == 0) 2322: { 1.1.1.4 root 2323: int specd = DECL_INLINE (decl); 1.1 root 2324: char *lose; 2325: 2326: /* If requested, consider whether to make this function inline. */ 2327: if (specd || flag_inline_functions) 2328: TIMEVAR (integration_time, 2329: { 2330: lose = function_cannot_inline_p (decl); 1.1.1.6 ! root 2331: /* If not optimzing, then make sure the DECL_INLINE ! 2332: bit is off. */ ! 2333: if (lose || ! optimize) 1.1 root 2334: { 2335: if (warn_inline && specd) 2336: warning_with_decl (decl, lose); 1.1.1.4 root 2337: DECL_INLINE (decl) = 0; 1.1.1.6 ! root 2338: /* Don't really compile an extern inline function. ! 2339: If we can't make it inline, pretend ! 2340: it was only declared. */ ! 2341: if (DECL_EXTERNAL (decl)) ! 2342: { ! 2343: DECL_INITIAL (decl) = 0; ! 2344: goto exit_rest_of_compilation; ! 2345: } 1.1 root 2346: } 2347: else 1.1.1.4 root 2348: DECL_INLINE (decl) = 1; 1.1 root 2349: }); 2350: 2351: insns = get_insns (); 2352: 2353: /* Dump the rtl code if we are dumping rtl. */ 2354: 2355: if (rtl_dump) 2356: TIMEVAR (dump_time, 2357: { 2358: fprintf (rtl_dump_file, "\n;; Function %s\n\n", 2359: IDENTIFIER_POINTER (DECL_NAME (decl))); 2360: if (DECL_SAVED_INSNS (decl)) 2361: fprintf (rtl_dump_file, ";; (integrable)\n\n"); 2362: print_rtl (rtl_dump_file, insns); 2363: fflush (rtl_dump_file); 2364: }); 2365: 2366: /* If function is inline, and we don't yet know whether to 2367: compile it by itself, defer decision till end of compilation. 2368: finish_compilation will call rest_of_compilation again 2369: for those functions that need to be output. */ 2370: 1.1.1.4 root 2371: if (DECL_INLINE (decl) 1.1 root 2372: && ((! TREE_PUBLIC (decl) && ! TREE_ADDRESSABLE (decl) 2373: && ! flag_keep_inline_functions) 1.1.1.4 root 2374: || DECL_EXTERNAL (decl))) 1.1 root 2375: { 1.1.1.4 root 2376: #ifdef DWARF_DEBUGGING_INFO 2377: /* Generate the DWARF info for the "abstract" instance 2378: of a function which we may later generate inlined and/or 2379: out-of-line instances of. */ 2380: if (write_symbols == DWARF_DEBUG) 2381: { 2382: set_decl_abstract_flags (decl, 1); 2383: TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); 2384: set_decl_abstract_flags (decl, 0); 2385: } 2386: #endif 1.1 root 2387: TIMEVAR (integration_time, save_for_inline_nocopy (decl)); 2388: goto exit_rest_of_compilation; 2389: } 2390: 1.1.1.4 root 2391: /* If we have to compile the function now, save its rtl and subdecls 1.1 root 2392: so that its compilation will not affect what others get. */ 1.1.1.4 root 2393: if (DECL_INLINE (decl)) 1.1 root 2394: { 1.1.1.4 root 2395: #ifdef DWARF_DEBUGGING_INFO 2396: /* Generate the DWARF info for the "abstract" instance of 2397: a function which we will generate an out-of-line instance 2398: of almost immediately (and which we may also later generate 2399: various inlined instances of). */ 2400: if (write_symbols == DWARF_DEBUG) 2401: { 2402: set_decl_abstract_flags (decl, 1); 2403: TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); 2404: set_decl_abstract_flags (decl, 0); 2405: } 2406: #endif 1.1 root 2407: saved_block_tree = DECL_INITIAL (decl); 1.1.1.4 root 2408: saved_arguments = DECL_ARGUMENTS (decl); 1.1 root 2409: TIMEVAR (integration_time, save_for_inline_copying (decl)); 2410: } 2411: } 2412: 2413: TREE_ASM_WRITTEN (decl) = 1; 2414: 2415: /* Now that integrate will no longer see our rtl, we need not distinguish 2416: between the return value of this function and the return value of called 2417: functions. */ 2418: rtx_equal_function_value_matters = 0; 2419: 1.1.1.3 root 2420: /* Don't return yet if -Wreturn-type; we need to do jump_optimize. */ 2421: if ((rtl_dump_and_exit || flag_syntax_only) && !warn_return_type) 1.1 root 2422: { 2423: goto exit_rest_of_compilation; 2424: } 2425: 2426: /* From now on, allocate rtl in current_obstack, not in saveable_obstack. 2427: Note that that may have been done above, in save_for_inline_copying. 2428: The call to resume_temporary_allocation near the end of this function 2429: goes back to the usual state of affairs. */ 2430: 2431: rtl_in_current_obstack (); 2432: 2433: #ifdef FINALIZE_PIC 2434: /* If we are doing position-independent code generation, now 2435: is the time to output special prologues and epilogues. 2436: We do not want to do this earlier, because it just clutters 2437: up inline functions with meaningless insns. */ 2438: if (flag_pic) 2439: FINALIZE_PIC; 2440: #endif 2441: 2442: insns = get_insns (); 2443: 2444: /* Copy any shared structure that should not be shared. */ 2445: 2446: unshare_all_rtl (insns); 2447: 2448: /* Instantiate all virtual registers. */ 2449: 2450: instantiate_virtual_regs (current_function_decl, get_insns ()); 2451: 2452: /* See if we have allocated stack slots that are not directly addressable. 2453: If so, scan all the insns and create explicit address computation 2454: for all references to such slots. */ 2455: /* fixup_stack_slots (); */ 2456: 2457: /* Do jump optimization the first time, if -opt. 2458: Also do it if -W, but in that case it doesn't change the rtl code, 2459: it only computes whether control can drop off the end of the function. */ 2460: 2461: if (optimize > 0 || extra_warnings || warn_return_type 2462: /* If function is `volatile', we should warn if it tries to return. */ 2463: || TREE_THIS_VOLATILE (decl)) 2464: { 2465: TIMEVAR (jump_time, reg_scan (insns, max_reg_num (), 0)); 2466: TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 1)); 2467: } 2468: 1.1.1.3 root 2469: /* Now is when we stop if -fsyntax-only and -Wreturn-type. */ 2470: if (rtl_dump_and_exit || flag_syntax_only) 2471: goto exit_rest_of_compilation; 2472: 1.1 root 2473: /* Dump rtl code after jump, if we are doing that. */ 2474: 2475: if (jump_opt_dump) 2476: TIMEVAR (dump_time, 2477: { 2478: fprintf (jump_opt_dump_file, "\n;; Function %s\n\n", 2479: IDENTIFIER_POINTER (DECL_NAME (decl))); 2480: print_rtl (jump_opt_dump_file, insns); 2481: fflush (jump_opt_dump_file); 2482: }); 2483: 2484: /* Perform common subexpression elimination. 2485: Nonzero value from `cse_main' means that jumps were simplified 2486: and some code may now be unreachable, so do 2487: jump optimization again. */ 2488: 2489: if (cse_dump) 2490: TIMEVAR (dump_time, 2491: { 2492: fprintf (cse_dump_file, "\n;; Function %s\n\n", 2493: IDENTIFIER_POINTER (DECL_NAME (decl))); 2494: }); 2495: 2496: if (optimize > 0) 2497: { 2498: TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 1)); 2499: 2500: if (flag_thread_jumps) 2501: /* Hacks by tiemann & kenner. */ 2502: TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); 2503: 2504: TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num (), 2505: 0, cse_dump_file)); 2506: TIMEVAR (cse_time, delete_dead_from_cse (insns, max_reg_num ())); 2507: 2508: if (tem) 2509: TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); 2510: } 2511: 2512: /* Dump rtl code after cse, if we are doing that. */ 2513: 2514: if (cse_dump) 2515: TIMEVAR (dump_time, 2516: { 2517: print_rtl (cse_dump_file, insns); 2518: fflush (cse_dump_file); 2519: }); 2520: 2521: if (loop_dump) 2522: TIMEVAR (dump_time, 2523: { 2524: fprintf (loop_dump_file, "\n;; Function %s\n\n", 2525: IDENTIFIER_POINTER (DECL_NAME (decl))); 2526: }); 2527: 2528: /* Move constant computations out of loops. */ 2529: 2530: if (optimize > 0) 2531: { 2532: TIMEVAR (loop_time, 2533: { 1.1.1.4 root 2534: loop_optimize (insns, loop_dump_file); 1.1 root 2535: }); 2536: } 2537: 2538: /* Dump rtl code after loop opt, if we are doing that. */ 2539: 2540: if (loop_dump) 2541: TIMEVAR (dump_time, 2542: { 2543: print_rtl (loop_dump_file, insns); 2544: fflush (loop_dump_file); 2545: }); 2546: 2547: if (cse2_dump) 2548: TIMEVAR (dump_time, 2549: { 2550: fprintf (cse2_dump_file, "\n;; Function %s\n\n", 2551: IDENTIFIER_POINTER (DECL_NAME (decl))); 2552: }); 2553: 2554: if (optimize > 0 && flag_rerun_cse_after_loop) 2555: { 2556: TIMEVAR (cse2_time, reg_scan (insns, max_reg_num (), 0)); 2557: 2558: TIMEVAR (cse2_time, tem = cse_main (insns, max_reg_num (), 2559: 1, cse2_dump_file)); 2560: if (tem) 2561: TIMEVAR (jump_time, jump_optimize (insns, 0, 0, 0)); 2562: } 2563: 2564: if (optimize > 0 && flag_thread_jumps) 2565: /* This pass of jump threading straightens out code 2566: that was kinked by loop optimization. */ 2567: TIMEVAR (jump_time, thread_jumps (insns, max_reg_num (), 0)); 2568: 2569: /* Dump rtl code after cse, if we are doing that. */ 2570: 2571: if (cse2_dump) 2572: TIMEVAR (dump_time, 2573: { 2574: print_rtl (cse2_dump_file, insns); 2575: fflush (cse2_dump_file); 2576: }); 2577: 2578: /* We are no longer anticipating cse in this function, at least. */ 2579: 2580: cse_not_expected = 1; 2581: 2582: /* Now we choose between stupid (pcc-like) register allocation 2583: (if we got the -noreg switch and not -opt) 2584: and smart register allocation. */ 2585: 2586: if (optimize > 0) /* Stupid allocation probably won't work */ 2587: obey_regdecls = 0; /* if optimizations being done. */ 2588: 2589: regclass_init (); 2590: 2591: /* Print function header into flow dump now 2592: because doing the flow analysis makes some of the dump. */ 2593: 2594: if (flow_dump) 2595: TIMEVAR (dump_time, 2596: { 2597: fprintf (flow_dump_file, "\n;; Function %s\n\n", 2598: IDENTIFIER_POINTER (DECL_NAME (decl))); 2599: }); 2600: 2601: if (obey_regdecls) 2602: { 2603: TIMEVAR (flow_time, 2604: { 2605: regclass (insns, max_reg_num ()); 2606: stupid_life_analysis (insns, max_reg_num (), 2607: flow_dump_file); 2608: }); 2609: } 2610: else 2611: { 2612: /* Do control and data flow analysis, 2613: and write some of the results to dump file. */ 2614: 2615: TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (), 2616: flow_dump_file)); 2617: if (warn_uninitialized) 2618: { 2619: uninitialized_vars_warning (DECL_INITIAL (decl)); 2620: setjmp_args_warning (); 2621: } 2622: } 2623: 2624: /* Dump rtl after flow analysis. */ 2625: 2626: if (flow_dump) 2627: TIMEVAR (dump_time, 2628: { 2629: print_rtl (flow_dump_file, insns); 2630: fflush (flow_dump_file); 2631: }); 2632: 2633: /* If -opt, try combining insns through substitution. */ 2634: 2635: if (optimize > 0) 2636: TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ())); 2637: 2638: /* Dump rtl code after insn combination. */ 2639: 2640: if (combine_dump) 2641: TIMEVAR (dump_time, 2642: { 2643: fprintf (combine_dump_file, "\n;; Function %s\n\n", 2644: IDENTIFIER_POINTER (DECL_NAME (decl))); 2645: dump_combine_stats (combine_dump_file); 2646: print_rtl (combine_dump_file, insns); 2647: fflush (combine_dump_file); 2648: }); 2649: 2650: /* Print function header into sched dump now 2651: because doing the sched analysis makes some of the dump. */ 2652: 2653: if (sched_dump) 2654: TIMEVAR (dump_time, 2655: { 2656: fprintf (sched_dump_file, "\n;; Function %s\n\n", 2657: IDENTIFIER_POINTER (DECL_NAME (decl))); 2658: }); 2659: 2660: if (optimize > 0 && flag_schedule_insns) 2661: { 2662: /* Do control and data sched analysis, 2663: and write some of the results to dump file. */ 2664: 2665: TIMEVAR (sched_time, schedule_insns (sched_dump_file)); 2666: } 2667: 2668: /* Dump rtl after instruction scheduling. */ 2669: 2670: if (sched_dump) 2671: TIMEVAR (dump_time, 2672: { 2673: print_rtl (sched_dump_file, insns); 2674: fflush (sched_dump_file); 2675: }); 2676: 2677: /* Unless we did stupid register allocation, 2678: allocate pseudo-regs that are used only within 1 basic block. */ 2679: 2680: if (!obey_regdecls) 2681: TIMEVAR (local_alloc_time, 2682: { 2683: regclass (insns, max_reg_num ()); 2684: local_alloc (); 2685: }); 2686: 2687: /* Dump rtl code after allocating regs within basic blocks. */ 2688: 2689: if (local_reg_dump) 2690: TIMEVAR (dump_time, 2691: { 2692: fprintf (local_reg_dump_file, "\n;; Function %s\n\n", 2693: IDENTIFIER_POINTER (DECL_NAME (decl))); 2694: dump_flow_info (local_reg_dump_file); 2695: dump_local_alloc (local_reg_dump_file); 2696: print_rtl (local_reg_dump_file, insns); 2697: fflush (local_reg_dump_file); 2698: }); 2699: 2700: if (global_reg_dump) 2701: TIMEVAR (dump_time, 2702: fprintf (global_reg_dump_file, "\n;; Function %s\n\n", 2703: IDENTIFIER_POINTER (DECL_NAME (decl)))); 2704: 2705: /* Unless we did stupid register allocation, 2706: allocate remaining pseudo-regs, then do the reload pass 2707: fixing up any insns that are invalid. */ 2708: 2709: TIMEVAR (global_alloc_time, 2710: { 2711: if (!obey_regdecls) 1.1.1.4 root 2712: failure = global_alloc (global_reg_dump_file); 1.1 root 2713: else 1.1.1.4 root 2714: failure = reload (insns, 0, global_reg_dump_file); 1.1 root 2715: }); 2716: 2717: if (global_reg_dump) 2718: TIMEVAR (dump_time, 2719: { 2720: dump_global_regs (global_reg_dump_file); 2721: print_rtl (global_reg_dump_file, insns); 2722: fflush (global_reg_dump_file); 2723: }); 2724: 1.1.1.4 root 2725: if (failure) 2726: goto exit_rest_of_compilation; 2727: 1.1 root 2728: reload_completed = 1; 2729: 1.1.1.4 root 2730: /* On some machines, the prologue and epilogue code, or parts thereof, 2731: can be represented as RTL. Doing so lets us schedule insns between 2732: it and the rest of the code and also allows delayed branch 2733: scheduling to operate in the epilogue. */ 2734: 2735: thread_prologue_and_epilogue_insns (insns); 2736: 1.1 root 2737: if (optimize > 0 && flag_schedule_insns_after_reload) 2738: { 2739: if (sched2_dump) 2740: TIMEVAR (dump_time, 2741: { 2742: fprintf (sched2_dump_file, "\n;; Function %s\n\n", 2743: IDENTIFIER_POINTER (DECL_NAME (decl))); 2744: }); 2745: 2746: /* Do control and data sched analysis again, 2747: and write some more of the results to dump file. */ 2748: 2749: TIMEVAR (sched2_time, schedule_insns (sched2_dump_file)); 2750: 2751: /* Dump rtl after post-reorder instruction scheduling. */ 2752: 2753: if (sched2_dump) 2754: TIMEVAR (dump_time, 2755: { 2756: print_rtl (sched2_dump_file, insns); 2757: fflush (sched2_dump_file); 2758: }); 2759: } 2760: 2761: #ifdef LEAF_REGISTERS 2762: leaf_function = 0; 2763: if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ()) 1.1.1.4 root 2764: leaf_function = 1; 1.1 root 2765: #endif 2766: 2767: /* One more attempt to remove jumps to .+1 2768: left by dead-store-elimination. 2769: Also do cross-jumping this time 2770: and delete no-op move insns. */ 2771: 2772: if (optimize > 0) 2773: { 2774: TIMEVAR (jump_time, jump_optimize (insns, 1, 1, 0)); 2775: } 2776: 2777: /* Dump rtl code after jump, if we are doing that. */ 2778: 2779: if (jump2_opt_dump) 2780: TIMEVAR (dump_time, 2781: { 2782: fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n", 2783: IDENTIFIER_POINTER (DECL_NAME (decl))); 2784: print_rtl (jump2_opt_dump_file, insns); 2785: fflush (jump2_opt_dump_file); 2786: }); 2787: 2788: /* If a scheduling pass for delayed branches is to be done, 2789: call the scheduling code. */ 2790: 2791: #ifdef DELAY_SLOTS 2792: if (optimize > 0 && flag_delayed_branch) 2793: { 2794: TIMEVAR (dbr_sched_time, dbr_schedule (insns, dbr_sched_dump_file)); 2795: if (dbr_sched_dump) 2796: { 2797: TIMEVAR (dump_time, 2798: { 2799: fprintf (dbr_sched_dump_file, "\n;; Function %s\n\n", 2800: IDENTIFIER_POINTER (DECL_NAME (decl))); 2801: print_rtl (dbr_sched_dump_file, insns); 2802: fflush (dbr_sched_dump_file); 2803: }); 2804: } 2805: } 2806: #endif 2807: 2808: if (optimize > 0) 2809: /* Shorten branches. */ 2810: TIMEVAR (shorten_branch_time, 2811: { 2812: shorten_branches (get_insns ()); 2813: }); 2814: 2815: #ifdef STACK_REGS 2816: TIMEVAR (stack_reg_time, reg_to_stack (insns, stack_reg_dump_file)); 2817: if (stack_reg_dump) 2818: { 2819: TIMEVAR (dump_time, 2820: { 2821: fprintf (stack_reg_dump_file, "\n;; Function %s\n\n", 2822: IDENTIFIER_POINTER (DECL_NAME (decl))); 2823: print_rtl (stack_reg_dump_file, insns); 2824: fflush (stack_reg_dump_file); 2825: }); 2826: } 2827: #endif 2828: 2829: /* Now turn the rtl into assembler code. */ 2830: 2831: TIMEVAR (final_time, 2832: { 2833: rtx x; 2834: char *fnname; 2835: 2836: /* Get the function's name, as described by its RTL. 2837: This may be different from the DECL_NAME name used 2838: in the source file. */ 2839: 2840: x = DECL_RTL (decl); 2841: if (GET_CODE (x) != MEM) 2842: abort (); 2843: x = XEXP (x, 0); 2844: if (GET_CODE (x) != SYMBOL_REF) 2845: abort (); 2846: fnname = XSTR (x, 0); 2847: 2848: assemble_start_function (decl, fnname); 2849: final_start_function (insns, asm_out_file, optimize); 2850: final (insns, asm_out_file, optimize, 0); 2851: final_end_function (insns, asm_out_file, optimize); 2852: assemble_end_function (decl, fnname); 2853: fflush (asm_out_file); 2854: }); 2855: 2856: /* Write DBX symbols if requested */ 2857: 2858: /* Note that for those inline functions where we don't initially 2859: know for certain that we will be generating an out-of-line copy, 2860: the first invocation of this routine (rest_of_compilation) will 2861: skip over this code by doing a `goto exit_rest_of_compilation;'. 2862: Later on, finish_compilation will call rest_of_compilation again 2863: for those inline functions that need to have out-of-line copies 2864: generated. During that call, we *will* be routed past here. */ 2865: 2866: #ifdef DBX_DEBUGGING_INFO 2867: if (write_symbols == DBX_DEBUG) 2868: TIMEVAR (symout_time, dbxout_function (decl)); 2869: #endif 2870: 2871: #ifdef DWARF_DEBUGGING_INFO 2872: if (write_symbols == DWARF_DEBUG) 2873: TIMEVAR (symout_time, dwarfout_file_scope_decl (decl, 0)); 2874: #endif 2875: 2876: exit_rest_of_compilation: 2877: 1.1.1.2 root 2878: /* In case the function was not output, 2879: don't leave any temporary anonymous types 2880: queued up for sdb output. */ 2881: #ifdef SDB_DEBUGGING_INFO 2882: if (write_symbols == SDB_DEBUG) 1.1.1.4 root 2883: sdbout_types (NULL_TREE); 1.1.1.2 root 2884: #endif 2885: 1.1.1.4 root 2886: /* Put back the tree of subblocks and list of arguments 2887: from before we copied them. 1.1 root 2888: Code generation and the output of debugging info may have modified 2889: the copy, but the original is unchanged. */ 2890: 2891: if (saved_block_tree != 0) 2892: DECL_INITIAL (decl) = saved_block_tree; 1.1.1.4 root 2893: if (saved_arguments != 0) 2894: DECL_ARGUMENTS (decl) = saved_arguments; 1.1 root 2895: 2896: reload_completed = 0; 2897: 2898: /* Clear out the real_constant_chain before some of the rtx's 2899: it runs through become garbage. */ 2900: 2901: clear_const_double_mem (); 2902: 2903: /* Cancel the effect of rtl_in_current_obstack. */ 2904: 2905: resume_temporary_allocation (); 2906: 2907: /* The parsing time is all the time spent in yyparse 2908: *except* what is spent in this function. */ 2909: 2910: parse_time -= get_run_time () - start_time; 2911: } 2912: 2913: /* Entry point of cc1/c++. Decode command args, then call compile_file. 2914: Exit code is 35 if can't open files, 34 if fatal error, 2915: 33 if had nonfatal errors, else success. */ 2916: 2917: int 2918: main (argc, argv, envp) 2919: int argc; 2920: char **argv; 2921: char **envp; 2922: { 2923: register int i; 2924: char *filename = 0; 2925: int flag_print_mem = 0; 2926: int version_flag = 0; 2927: char *p; 2928: 2929: /* save in case md file wants to emit args as a comment. */ 2930: save_argc = argc; 2931: save_argv = argv; 2932: 2933: p = argv[0] + strlen (argv[0]); 2934: while (p != argv[0] && p[-1] != '/') --p; 2935: progname = p; 2936: 2937: #ifdef RLIMIT_STACK 2938: /* Get rid of any avoidable limit on stack size. */ 2939: { 2940: struct rlimit rlim; 2941: 2942: /* Set the stack limit huge so that alloca does not fail. */ 2943: getrlimit (RLIMIT_STACK, &rlim); 2944: rlim.rlim_cur = rlim.rlim_max; 2945: setrlimit (RLIMIT_STACK, &rlim); 2946: } 2947: #endif /* RLIMIT_STACK */ 2948: 2949: signal (SIGFPE, float_signal); 2950: 1.1.1.5 root 2951: #ifdef SIGPIPE 1.1 root 2952: signal (SIGPIPE, pipe_closed); 1.1.1.5 root 2953: #endif 1.1 root 2954: 2955: decl_printable_name = decl_name; 2956: lang_expand_expr = (struct rtx_def *(*)()) do_abort; 2957: 2958: /* Initialize whether `char' is signed. */ 2959: flag_signed_char = DEFAULT_SIGNED_CHAR; 2960: #ifdef DEFAULT_SHORT_ENUMS 2961: /* Initialize how much space enums occupy, by default. */ 2962: flag_short_enums = DEFAULT_SHORT_ENUMS; 2963: #endif 2964: 2965: /* Scan to see what optimization level has been specified. That will 2966: determine the default value of many flags. */ 2967: for (i = 1; i < argc; i++) 2968: { 2969: if (!strcmp (argv[i], "-O")) 2970: { 2971: optimize = 1; 2972: } 2973: else if (argv[i][0] == '-' && argv[i][1] == 'O') 2974: { 2975: /* Handle -O2, -O3, -O69, ... */ 2976: char *p = &argv[i][2]; 2977: int c; 2978: 2979: while (c = *p++) 2980: if (! (c >= '0' && c <= '9')) 2981: break; 2982: if (c == 0) 2983: optimize = atoi (&argv[i][2]); 2984: } 2985: } 2986: 2987: obey_regdecls = (optimize == 0); 1.1.1.2 root 2988: if (optimize == 0) 2989: { 2990: flag_no_inline = 1; 2991: warn_inline = 0; 2992: } 1.1 root 2993: 2994: if (optimize >= 1) 2995: { 1.1.1.5 root 2996: flag_defer_pop = 1; 1.1 root 2997: flag_thread_jumps = 1; 2998: #ifdef DELAY_SLOTS 2999: flag_delayed_branch = 1; 3000: #endif 3001: } 3002: 3003: if (optimize >= 2) 3004: { 3005: flag_cse_follow_jumps = 1; 1.1.1.3 root 3006: flag_cse_skip_blocks = 1; 1.1 root 3007: flag_expensive_optimizations = 1; 3008: flag_strength_reduce = 1; 3009: flag_rerun_cse_after_loop = 1; 1.1.1.2 root 3010: flag_caller_saves = 1; 1.1 root 3011: #ifdef INSN_SCHEDULING 3012: flag_schedule_insns = 1; 3013: flag_schedule_insns_after_reload = 1; 3014: #endif 3015: } 3016: 3017: #ifdef OPTIMIZATION_OPTIONS 3018: /* Allow default optimizations to be specified on a per-machine basis. */ 3019: OPTIMIZATION_OPTIONS (optimize); 3020: #endif 3021: 3022: /* Initialize register usage now so switches may override. */ 3023: init_reg_sets (); 3024: 3025: target_flags = 0; 3026: set_target_switch (""); 3027: 3028: for (i = 1; i < argc; i++) 3029: { 1.1.1.4 root 3030: int j; 3031: /* If this is a language-specific option, 3032: decode it in a language-specific way. */ 3033: for (j = 0; lang_options[j] != 0; j++) 3034: if (!strncmp (argv[i], lang_options[j], 3035: strlen (lang_options[j]))) 3036: break; 3037: if (lang_options[j] != 0) 3038: /* If the option is valid for *some* language, 3039: treat it as valid even if this language doesn't understand it. */ 3040: lang_decode_option (argv[i]); 3041: else if (argv[i][0] == '-' && argv[i][1] != 0) 1.1 root 3042: { 3043: register char *str = argv[i] + 1; 3044: if (str[0] == 'Y') 3045: str++; 3046: 3047: if (str[0] == 'm') 3048: set_target_switch (&str[1]); 3049: else if (!strcmp (str, "dumpbase")) 3050: { 3051: dump_base_name = argv[++i]; 3052: } 3053: else if (str[0] == 'd') 3054: { 3055: register char *p = &str[1]; 3056: while (*p) 3057: switch (*p++) 3058: { 3059: case 'a': 3060: combine_dump = 1; 3061: dbr_sched_dump = 1; 3062: flow_dump = 1; 3063: global_reg_dump = 1; 3064: jump_opt_dump = 1; 3065: jump2_opt_dump = 1; 3066: local_reg_dump = 1; 3067: loop_dump = 1; 3068: rtl_dump = 1; 3069: cse_dump = 1, cse2_dump = 1; 3070: sched_dump = 1; 3071: sched2_dump = 1; 3072: stack_reg_dump = 1; 3073: break; 3074: case 'k': 3075: stack_reg_dump = 1; 3076: break; 3077: case 'c': 3078: combine_dump = 1; 3079: break; 3080: case 'd': 3081: dbr_sched_dump = 1; 3082: break; 3083: case 'f': 3084: flow_dump = 1; 3085: break; 3086: case 'g': 3087: global_reg_dump = 1; 3088: break; 3089: case 'j': 3090: jump_opt_dump = 1; 3091: break; 3092: case 'J': 3093: jump2_opt_dump = 1; 3094: break; 3095: case 'l': 3096: local_reg_dump = 1; 3097: break; 3098: case 'L': 3099: loop_dump = 1; 3100: break; 3101: case 'm': 3102: flag_print_mem = 1; 3103: break; 3104: case 'p': 3105: flag_print_asm_name = 1; 3106: break; 3107: case 'r': 3108: rtl_dump = 1; 3109: break; 3110: case 's': 3111: cse_dump = 1; 3112: break; 3113: case 't': 3114: cse2_dump = 1; 3115: break; 3116: case 'S': 3117: sched_dump = 1; 3118: break; 3119: case 'R': 3120: sched2_dump = 1; 3121: break; 3122: case 'y': 3123: set_yydebug (1); 3124: break; 3125: 3126: case 'x': 3127: rtl_dump_and_exit = 1; 3128: break; 3129: } 3130: } 3131: else if (str[0] == 'f') 3132: { 3133: register char *p = &str[1]; 3134: int found = 0; 3135: 3136: /* Some kind of -f option. 3137: P's value is the option sans `-f'. 3138: Search for it in the table of options. */ 3139: 3140: for (j = 0; 3141: !found && j < sizeof (f_options) / sizeof (f_options[0]); 3142: j++) 3143: { 3144: if (!strcmp (p, f_options[j].string)) 3145: { 3146: *f_options[j].variable = f_options[j].on_value; 3147: /* A goto here would be cleaner, 3148: but breaks the vax pcc. */ 3149: found = 1; 3150: } 3151: if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' 3152: && ! strcmp (p+3, f_options[j].string)) 3153: { 3154: *f_options[j].variable = ! f_options[j].on_value; 3155: found = 1; 3156: } 3157: } 3158: 3159: if (found) 3160: ; 3161: else if (!strncmp (p, "fixed-", 6)) 3162: fix_register (&p[6], 1, 1); 3163: else if (!strncmp (p, "call-used-", 10)) 3164: fix_register (&p[10], 0, 1); 3165: else if (!strncmp (p, "call-saved-", 11)) 3166: fix_register (&p[11], 0, 0); 1.1.1.4 root 3167: else 1.1 root 3168: error ("Invalid option `%s'", argv[i]); 3169: } 3170: else if (str[0] == 'O') 3171: { 3172: register char *p = str+1; 3173: while (*p && *p >= '0' && *p <= '9') 3174: p++; 3175: if (*p == '\0') 3176: ; 3177: else 3178: error ("Invalid option `%s'", argv[i]); 3179: } 3180: else if (!strcmp (str, "pedantic")) 3181: pedantic = 1; 3182: else if (!strcmp (str, "pedantic-errors")) 3183: flag_pedantic_errors = pedantic = 1; 3184: else if (!strcmp (str, "quiet")) 3185: quiet_flag = 1; 3186: else if (!strcmp (str, "version")) 3187: version_flag = 1; 3188: else if (!strcmp (str, "w")) 3189: inhibit_warnings = 1; 3190: else if (!strcmp (str, "W")) 3191: { 3192: extra_warnings = 1; 1.1.1.6 ! root 3193: /* We save the value of warn_uninitialized, since if they put ! 3194: -Wuninitialized on the command line, we need to generate a ! 3195: warning about not using it without also specifying -O. */ ! 3196: if (warn_uninitialized != 1) ! 3197: warn_uninitialized = 2; 1.1 root 3198: } 3199: else if (str[0] == 'W') 3200: { 3201: register char *p = &str[1]; 3202: int found = 0; 3203: 3204: /* Some kind of -W option. 3205: P's value is the option sans `-W'. 3206: Search for it in the table of options. */ 3207: 3208: for (j = 0; 3209: !found && j < sizeof (W_options) / sizeof (W_options[0]); 3210: j++) 3211: { 3212: if (!strcmp (p, W_options[j].string)) 3213: { 3214: *W_options[j].variable = W_options[j].on_value; 3215: /* A goto here would be cleaner, 3216: but breaks the vax pcc. */ 3217: found = 1; 3218: } 3219: if (p[0] == 'n' && p[1] == 'o' && p[2] == '-' 3220: && ! strcmp (p+3, W_options[j].string)) 3221: { 3222: *W_options[j].variable = ! W_options[j].on_value; 3223: found = 1; 3224: } 3225: } 3226: 3227: if (found) 3228: ; 3229: else if (!strncmp (p, "id-clash-", 9)) 3230: { 3231: char *endp = p + 9; 3232: 3233: while (*endp) 3234: { 3235: if (*endp >= '0' && *endp <= '9') 3236: endp++; 3237: else 1.1.1.4 root 3238: { 3239: error ("Invalid option `%s'", argv[i]); 3240: goto id_clash_lose; 3241: } 1.1 root 3242: } 3243: warn_id_clash = 1; 3244: id_clash_len = atoi (str + 10); 1.1.1.4 root 3245: id_clash_lose: ; 1.1 root 3246: } 3247: else 3248: error ("Invalid option `%s'", argv[i]); 3249: } 3250: else if (!strcmp (str, "p")) 1.1.1.6 ! root 3251: { ! 3252: if (!output_bytecode) ! 3253: profile_flag = 1; ! 3254: else ! 3255: error ("profiling not supported in bytecode compilation"); ! 3256: } 1.1 root 3257: else if (!strcmp (str, "a")) 3258: { 3259: #if !defined (BLOCK_PROFILER) || !defined (FUNCTION_BLOCK_PROFILER) 3260: warning ("`-a' option (basic block profile) not supported"); 3261: #else 3262: profile_block_flag = 1; 3263: #endif 3264: } 3265: else if (str[0] == 'g') 3266: { 3267: char *p = str + 1; 3268: char *q; 3269: unsigned len; 3270: unsigned level; 3271: 3272: while (*p && (*p < '0' || *p > '9')) 3273: p++; 3274: len = p - str; 3275: q = p; 3276: while (*q && (*q >= '0' && *q <= '9')) 3277: q++; 3278: if (*p) 3279: level = atoi (p); 3280: else 3281: level = 2; /* default debugging info level */ 3282: if (*q || level > 3) 3283: { 3284: warning ("invalid debug level specification in option: `-%s'", 3285: str); 3286: warning ("no debugging information will be generated"); 3287: level = 0; 3288: } 3289: 3290: /* If more than one debugging type is supported, 3291: you must define PREFERRED_DEBUGGING_TYPE 3292: to choose a format in a system-dependent way. */ 1.1.1.4 root 3293: /* This is one long line cause VAXC can't handle a \-newline. */ 3294: #if 1 < (defined (DBX_DEBUGGING_INFO) + defined (SDB_DEBUGGING_INFO) + defined (DWARF_DEBUGGING_INFO) + defined (XCOFF_DEBUGGING_INFO)) 1.1 root 3295: #ifdef PREFERRED_DEBUGGING_TYPE 3296: if (!strncmp (str, "ggdb", len)) 3297: write_symbols = PREFERRED_DEBUGGING_TYPE; 3298: #else /* no PREFERRED_DEBUGGING_TYPE */ 3299: You Lose! You must define PREFERRED_DEBUGGING_TYPE! 3300: #endif /* no PREFERRED_DEBUGGING_TYPE */ 3301: #endif /* More than one debugger format enabled. */ 3302: #ifdef DBX_DEBUGGING_INFO 3303: if (write_symbols != NO_DEBUG) 3304: ; 3305: else if (!strncmp (str, "ggdb", len)) 3306: write_symbols = DBX_DEBUG; 3307: else if (!strncmp (str, "gstabs", len)) 3308: write_symbols = DBX_DEBUG; 1.1.1.4 root 3309: else if (!strncmp (str, "gstabs+", len)) 3310: write_symbols = DBX_DEBUG; 1.1 root 3311: 3312: /* Always enable extensions for -ggdb or -gstabs+, 3313: always disable for -gstabs. 3314: For plain -g, use system-specific default. */ 3315: if (write_symbols == DBX_DEBUG && !strncmp (str, "ggdb", len) 3316: && len >= 2) 1.1.1.4 root 3317: use_gnu_debug_info_extensions = 1; 3318: else if (write_symbols == DBX_DEBUG && !strncmp (str, "gstabs+", len) 3319: && len >= 7) 3320: use_gnu_debug_info_extensions = 1; 1.1 root 3321: else if (write_symbols == DBX_DEBUG 3322: && !strncmp (str, "gstabs", len) && len >= 2) 1.1.1.4 root 3323: use_gnu_debug_info_extensions = 0; 1.1 root 3324: else 1.1.1.4 root 3325: use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS; 1.1 root 3326: #endif /* DBX_DEBUGGING_INFO */ 3327: #ifdef DWARF_DEBUGGING_INFO 3328: if (write_symbols != NO_DEBUG) 3329: ; 1.1.1.4 root 3330: else if (!strncmp (str, "g", len)) 3331: write_symbols = DWARF_DEBUG; 1.1 root 3332: else if (!strncmp (str, "ggdb", len)) 3333: write_symbols = DWARF_DEBUG; 3334: else if (!strncmp (str, "gdwarf", len)) 3335: write_symbols = DWARF_DEBUG; 1.1.1.4 root 3336: 3337: /* Always enable extensions for -ggdb or -gdwarf+, 3338: always disable for -gdwarf. 3339: For plain -g, use system-specific default. */ 3340: if (write_symbols == DWARF_DEBUG && !strncmp (str, "ggdb", len) 3341: && len >= 2) 3342: use_gnu_debug_info_extensions = 1; 3343: else if (write_symbols == DWARF_DEBUG && !strcmp (str, "gdwarf+")) 3344: use_gnu_debug_info_extensions = 1; 3345: else if (write_symbols == DWARF_DEBUG 3346: && !strncmp (str, "gdwarf", len) && len >= 2) 3347: use_gnu_debug_info_extensions = 0; 3348: else 3349: use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS; 1.1 root 3350: #endif 3351: #ifdef SDB_DEBUGGING_INFO 3352: if (write_symbols != NO_DEBUG) 3353: ; 1.1.1.4 root 3354: else if (!strncmp (str, "g", len)) 3355: write_symbols = SDB_DEBUG; 3356: else if (!strncmp (str, "gdb", len)) 1.1 root 3357: write_symbols = SDB_DEBUG; 3358: else if (!strncmp (str, "gcoff", len)) 3359: write_symbols = SDB_DEBUG; 3360: #endif /* SDB_DEBUGGING_INFO */ 1.1.1.2 root 3361: #ifdef XCOFF_DEBUGGING_INFO 3362: if (write_symbols != NO_DEBUG) 3363: ; 1.1.1.4 root 3364: else if (!strncmp (str, "g", len)) 3365: write_symbols = XCOFF_DEBUG; 1.1.1.2 root 3366: else if (!strncmp (str, "ggdb", len)) 3367: write_symbols = XCOFF_DEBUG; 3368: else if (!strncmp (str, "gxcoff", len)) 3369: write_symbols = XCOFF_DEBUG; 3370: 1.1.1.4 root 3371: /* Always enable extensions for -ggdb or -gxcoff+, 1.1.1.2 root 3372: always disable for -gxcoff. 3373: For plain -g, use system-specific default. */ 3374: if (write_symbols == XCOFF_DEBUG && !strncmp (str, "ggdb", len) 3375: && len >= 2) 1.1.1.4 root 3376: use_gnu_debug_info_extensions = 1; 3377: else if (write_symbols == XCOFF_DEBUG && !strcmp (str, "gxcoff+")) 3378: use_gnu_debug_info_extensions = 1; 1.1.1.3 root 3379: else if (write_symbols == XCOFF_DEBUG 1.1.1.2 root 3380: && !strncmp (str, "gxcoff", len) && len >= 2) 1.1.1.4 root 3381: use_gnu_debug_info_extensions = 0; 1.1.1.2 root 3382: else 1.1.1.4 root 3383: use_gnu_debug_info_extensions = DEFAULT_GDB_EXTENSIONS; 1.1.1.2 root 3384: #endif 1.1 root 3385: if (write_symbols == NO_DEBUG) 3386: warning ("`-%s' option not supported on this version of GCC", str); 3387: else if (level == 0) 3388: write_symbols = NO_DEBUG; 3389: else 1.1.1.3 root 3390: debug_info_level = (enum debug_info_level) level; 1.1 root 3391: } 3392: else if (!strcmp (str, "o")) 3393: { 3394: asm_file_name = argv[++i]; 3395: } 3396: else if (str[0] == 'G') 3397: { 3398: g_switch_set = TRUE; 3399: g_switch_value = atoi ((str[1] != '\0') ? str+1 : argv[++i]); 3400: } 1.1.1.2 root 3401: else if (!strncmp (str, "aux-info", 8)) 3402: { 3403: flag_gen_aux_info = 1; 3404: aux_info_file_name = (str[8] != '\0' ? str+8 : argv[++i]); 3405: } 1.1 root 3406: else 3407: error ("Invalid option `%s'", argv[i]); 3408: } 3409: else if (argv[i][0] == '+') 1.1.1.4 root 3410: error ("Invalid option `%s'", argv[i]); 1.1 root 3411: else 3412: filename = argv[i]; 3413: } 3414: 1.1.1.6 ! root 3415: /* Initialize for bytecode output. A good idea to do this as soon as ! 3416: possible after the "-f" options have been parsed. */ ! 3417: if (output_bytecode) ! 3418: { ! 3419: #ifndef TARGET_SUPPORTS_BYTECODE ! 3420: /* Just die with a fatal error if not supported */ ! 3421: fatal ("-fbytecode can not be used for this target"); ! 3422: #else ! 3423: bc_initialize (); ! 3424: #endif ! 3425: } ! 3426: 1.1.1.2 root 3427: if (optimize == 0) 3428: { 1.1.1.5 root 3429: /* Inlining does not work if not optimizing, 3430: so force it not to be done. */ 1.1.1.2 root 3431: flag_no_inline = 1; 3432: warn_inline = 0; 1.1.1.5 root 3433: 3434: /* The c_decode_option and lang_decode_option functions set 3435: this to `2' if -Wall is used, so we can avoid giving out 3436: lots of errors for people who don't realize what -Wall does. */ 3437: if (warn_uninitialized == 1) 3438: warning ("-Wuninitialized is not supported without -O"); 3439: } 3440: 3441: #if defined(DWARF_DEBUGGING_INFO) 3442: if (write_symbols == DWARF_DEBUG 3443: && strcmp (language_string, "GNU C++") == 0) 3444: { 3445: warning ("-g option not supported for C++ on SVR4 systems"); 3446: write_symbols = NO_DEBUG; 1.1.1.2 root 3447: } 1.1.1.5 root 3448: #endif /* defined(DWARF_DEBUGGING_INFO) */ 1.1.1.2 root 3449: 1.1 root 3450: #ifdef OVERRIDE_OPTIONS 3451: /* Some machines may reject certain combinations of options. */ 3452: OVERRIDE_OPTIONS; 3453: #endif 3454: 3455: /* Unrolling all loops implies that standard loop unrolling must also 3456: be done. */ 3457: if (flag_unroll_all_loops) 3458: flag_unroll_loops = 1; 3459: /* Loop unrolling requires that strength_reduction be on also. Silently 3460: turn on strength reduction here if it isn't already on. Also, the loop 3461: unrolling code assumes that cse will be run after loop, so that must 3462: be turned on also. */ 3463: if (flag_unroll_loops) 3464: { 3465: flag_strength_reduce = 1; 3466: flag_rerun_cse_after_loop = 1; 3467: } 3468: 3469: /* Warn about options that are not supported on this machine. */ 3470: #ifndef INSN_SCHEDULING 3471: if (flag_schedule_insns || flag_schedule_insns_after_reload) 3472: warning ("instruction scheduling not supported on this target machine"); 3473: #endif 3474: #ifndef DELAY_SLOTS 3475: if (flag_delayed_branch) 3476: warning ("this target machine does not have delayed branches"); 3477: #endif 3478: 3479: /* If we are in verbose mode, write out the version and maybe all the 3480: option flags in use. */ 3481: if (version_flag) 3482: { 3483: fprintf (stderr, "%s version %s", language_string, version_string); 3484: #ifdef TARGET_VERSION 3485: TARGET_VERSION; 3486: #endif 3487: #ifdef __GNUC__ 3488: #ifndef __VERSION__ 3489: #define __VERSION__ "[unknown]" 3490: #endif 3491: fprintf (stderr, " compiled by GNU C version %s.\n", __VERSION__); 3492: #else 3493: fprintf (stderr, " compiled by CC.\n"); 3494: #endif 3495: if (! quiet_flag) 3496: print_switch_values (); 3497: } 3498: 3499: /* Now that register usage is specified, convert it to HARD_REG_SETs. */ 1.1.1.6 ! root 3500: if (!output_bytecode) ! 3501: init_reg_sets_1 (); 1.1 root 3502: 3503: compile_file (filename); 3504: 1.1.1.6 ! root 3505: if (output_bytecode) ! 3506: bc_write_file (stdout); ! 3507: 1.1.1.3 root 3508: #ifndef OS2 1.1 root 3509: #ifndef VMS 3510: if (flag_print_mem) 3511: { 3512: char *lim = (char *) sbrk (0); 3513: 3514: fprintf (stderr, "Data size %d.\n", 1.1.1.4 root 3515: lim - (char *) &environ); 1.1 root 3516: fflush (stderr); 3517: 3518: #ifdef USG 3519: system ("ps -l 1>&2"); 3520: #else /* not USG */ 3521: system ("ps v"); 3522: #endif /* not USG */ 3523: } 3524: #endif /* not VMS */ 1.1.1.3 root 3525: #endif /* not OS2 */ 1.1 root 3526: 3527: if (errorcount) 3528: exit (FATAL_EXIT_CODE); 3529: if (sorrycount) 3530: exit (FATAL_EXIT_CODE); 3531: exit (SUCCESS_EXIT_CODE); 3532: return 34; 3533: } 3534: 3535: /* Decode -m switches. */ 3536: 3537: /* Here is a table, controlled by the tm.h file, listing each -m switch 3538: and which bits in `target_switches' it should set or clear. 3539: If VALUE is positive, it is bits to set. 3540: If VALUE is negative, -VALUE is bits to clear. 3541: (The sign bit is not used so there is no confusion.) */ 3542: 3543: struct {char *name; int value;} target_switches [] 3544: = TARGET_SWITCHES; 3545: 3546: /* This table is similar, but allows the switch to have a value. */ 3547: 3548: #ifdef TARGET_OPTIONS 3549: struct {char *prefix; char ** variable;} target_options [] 3550: = TARGET_OPTIONS; 3551: #endif 3552: 3553: /* Decode the switch -mNAME. */ 3554: 3555: void 3556: set_target_switch (name) 3557: char *name; 3558: { 3559: register int j; 3560: int valid = 0; 3561: 3562: for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) 3563: if (!strcmp (target_switches[j].name, name)) 3564: { 3565: if (target_switches[j].value < 0) 3566: target_flags &= ~-target_switches[j].value; 3567: else 3568: target_flags |= target_switches[j].value; 3569: valid = 1; 3570: } 3571: 3572: #ifdef TARGET_OPTIONS 3573: if (!valid) 3574: for (j = 0; j < sizeof target_options / sizeof target_options[0]; j++) 3575: { 3576: int len = strlen (target_options[j].prefix); 3577: if (!strncmp (target_options[j].prefix, name, len)) 3578: { 3579: *target_options[j].variable = name + len; 3580: valid = 1; 3581: } 3582: } 3583: #endif 3584: 3585: if (!valid) 3586: error ("Invalid option `%s'", name); 3587: } 3588: 3589: /* Variable used for communication between the following two routines. */ 3590: 3591: static int line_position; 3592: 3593: /* Print an option value and adjust the position in the line. */ 3594: 3595: static void 3596: print_single_switch (type, name) 3597: char *type, *name; 3598: { 3599: fprintf (stderr, " %s%s", type, name); 3600: 3601: line_position += strlen (type) + strlen (name) + 1; 3602: 3603: if (line_position > 65) 3604: { 3605: fprintf (stderr, "\n\t"); 3606: line_position = 8; 3607: } 3608: } 3609: 3610: /* Print default target switches for -version. */ 3611: 3612: static void 3613: print_switch_values () 3614: { 3615: register int j; 3616: 3617: fprintf (stderr, "enabled:"); 3618: line_position = 8; 3619: 3620: for (j = 0; j < sizeof f_options / sizeof f_options[0]; j++) 3621: if (*f_options[j].variable == f_options[j].on_value) 3622: print_single_switch ("-f", f_options[j].string); 3623: 3624: for (j = 0; j < sizeof W_options / sizeof W_options[0]; j++) 3625: if (*W_options[j].variable == W_options[j].on_value) 3626: print_single_switch ("-W", W_options[j].string); 3627: 3628: for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++) 3629: if (target_switches[j].name[0] != '\0' 3630: && target_switches[j].value > 0 3631: && ((target_switches[j].value & target_flags) 3632: == target_switches[j].value)) 3633: print_single_switch ("-m", target_switches[j].name); 3634: 3635: fprintf (stderr, "\n"); 3636: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.