toplev.c 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534
  1. /* Top level of GNU C compiler
  2. Copyright (C) 1987, 1988 Free Software Foundation, Inc.
  3. This file is part of GNU CC.
  4. GNU CC is distributed in the hope that it will be useful,
  5. but WITHOUT ANY WARRANTY. No author or distributor
  6. accepts responsibility to anyone for the consequences of using it
  7. or for whether it serves any particular purpose or works at all,
  8. unless he says so in writing. Refer to the GNU CC General Public
  9. License for full details.
  10. Everyone is granted permission to copy, modify and redistribute
  11. GNU CC, but only under the conditions described in the
  12. GNU CC General Public License. A copy of this license is
  13. supposed to have been given to you along with GNU CC so you
  14. can know your rights and responsibilities. It should be in a
  15. file named COPYING. Among other things, the copyright notice
  16. and this notice must be preserved on all copies. */
  17. /* This is the top level of cc1.
  18. It parses command args, opens files, invokes the various passes
  19. in the proper order, and counts the time used by each.
  20. Error messages and low-level interface to malloc also handled here. */
  21. #include "config.h"
  22. #include <stdio.h>
  23. #include <signal.h>
  24. #ifdef USG
  25. #include <sys/param.h>
  26. #include <sys/times.h>
  27. #include <time.h> /* Correct for hpux at least. Is it good on other USG? */
  28. #else
  29. #ifndef VMS
  30. #include <sys/time.h>
  31. #include <sys/resource.h>
  32. #endif
  33. #endif
  34. #ifndef _TYPES_
  35. #include <sys/types.h>
  36. #endif
  37. #include <sys/stat.h>
  38. #include "tree.h"
  39. #include "c-tree.h"
  40. #include "rtl.h"
  41. #include "flags.h"
  42. extern int yydebug;
  43. extern FILE *finput;
  44. extern void init_lex ();
  45. extern void init_decl_processing ();
  46. extern void init_tree ();
  47. extern void init_rtl ();
  48. extern void init_optabs ();
  49. extern void init_reg_sets ();
  50. extern void dump_flow_info ();
  51. extern void dump_local_alloc ();
  52. void rest_of_decl_compilation ();
  53. void error ();
  54. void error_with_file_and_line ();
  55. void set_target_switch ();
  56. /* Bit flags that specify the machine subtype we are compiling for.
  57. Bits are tested using macros TARGET_... defined in the tm-...h file
  58. and set by `-m...' switches. */
  59. int target_flags;
  60. /* Name of current original source file (what was input to cpp).
  61. This comes from each #-command in the actual input. */
  62. char *input_filename;
  63. /* Name of top-level original source file (what was input to cpp).
  64. This comes from the first #-command in the actual input. */
  65. char *main_input_filename;
  66. /* Current line number in real source file. */
  67. extern int lineno;
  68. /* FUNCTION_DECL for function now being parsed or compiled. */
  69. extern tree current_function_decl;
  70. /* Name to use as base of names for dump output files. */
  71. char *dump_base_name;
  72. /* Flags saying which kinds of debugging dump have been requested. */
  73. int rtl_dump = 0;
  74. int rtl_dump_and_exit = 0;
  75. int jump_opt_dump = 0;
  76. int cse_dump = 0;
  77. int loop_dump = 0;
  78. int flow_dump = 0;
  79. int combine_dump = 0;
  80. int local_reg_dump = 0;
  81. int global_reg_dump = 0;
  82. int jump2_opt_dump = 0;
  83. /* 1 => write gdb debugging output (using symout.c). -g
  84. 2 => write dbx debugging output (using dbxout.c). -G */
  85. int write_symbols = 0;
  86. /* Nonzero means do optimizations. -opt. */
  87. int optimize = 0;
  88. /* Nonzero for -fforce-mem: load memory value into a register
  89. before arithmetic on it. This makes better cse but slower compilation. */
  90. int flag_force_mem = 0;
  91. /* Nonzero for -fforce-addr: load memory address into a register before
  92. reference to memory. This makes better cse but slower compilation. */
  93. int flag_force_addr = 0;
  94. /* Nonzero for -fdefer-pop: don't pop args after each function call;
  95. instead save them up to pop many calls' args with one insns. */
  96. int flag_defer_pop = 1;
  97. /* Nonzero for -ffloat-store: don't allocate floats and doubles
  98. in extended-precision registers. */
  99. int flag_float_store = 0;
  100. /* Nonzero for -fcombine-regs:
  101. allow instruction combiner to combine an insn
  102. that just copies one reg to another. */
  103. int flag_combine_regs = 0;
  104. /* Nonzero for -fwritable-strings:
  105. store string constants in data segment and don't uniquize them. */
  106. int flag_writable_strings = 0;
  107. /* Nonzero means don't put addresses of constant functions in registers.
  108. Used for compiling the Unix kernel, where strange substitutions are
  109. done on the assembly output. */
  110. int flag_no_function_cse = 0;
  111. /* Nonzero for -fomit-frame-pointer:
  112. don't make a frame pointer in simple functions that don't require one. */
  113. int flag_omit_frame_pointer = 0;
  114. /* Nonzero to inhibit use of define_optimization peephole opts. */
  115. int flag_no_peephole = 0;
  116. /* Nonzero means `char' should be signed. */
  117. int flag_signed_char;
  118. /* Nonzero means allow type mismatches in conditional expressions;
  119. just make their values `void'. */
  120. int flag_cond_mismatch;
  121. /* Nonzero means don't recognize the keyword `asm'. */
  122. int flag_no_asm;
  123. /* Nonzero means warn about implicit declarations. */
  124. int warn_implicit;
  125. /* Nonzero means warn about function definitions that default the return type
  126. or that use a null return and have a return-type other than void. */
  127. int warn_return_type;
  128. /* Nonzero means do some things the same way PCC does. */
  129. int flag_traditional;
  130. /* Nonzero means all references through pointers are volatile. */
  131. int flag_volatile;
  132. /* Nonzero means do stupid register allocation. -noreg.
  133. This and `optimize' are controlled by different switches in cc1,
  134. but normally cc controls them both with the -O switch. */
  135. int obey_regdecls = 0;
  136. /* Don't print functions as they are compiled and don't print
  137. times taken by the various passes. -quiet. */
  138. int quiet_flag = 0;
  139. /* Don't print warning messages. -w. */
  140. int inhibit_warnings = 0;
  141. /* Do print extra warnings (such as for uninitialized variables). -W. */
  142. int extra_warnings = 0;
  143. /* Number of error messages and warning messages so far. */
  144. int errorcount = 0;
  145. int warningcount = 0;
  146. /* Nonzero if generating code to do profiling. */
  147. int profile_flag = 0;
  148. /* Nonzero for -pedantic switch: warn about anything
  149. that standard C forbids. */
  150. int pedantic = 0;
  151. /* Nonzero for -finline-functions: ok to inline functions that look like
  152. good inline candidates. */
  153. int flag_inline_functions;
  154. /* Nonzero for -fkeep-inline-functions: even if we make a function
  155. go inline everywhere, keep its defintion around for debugging
  156. purposes. */
  157. int flag_keep_inline_functions;
  158. /* Name for output file of assembly code, specified with -o. */
  159. char *asm_file_name;
  160. /* Name for output file of GDB symbol segment, specified with -symout. */
  161. char *sym_file_name;
  162. /* Output files for assembler code (real compiler output)
  163. and debugging dumps. */
  164. FILE *asm_out_file;
  165. FILE *rtl_dump_file;
  166. FILE *jump_opt_dump_file;
  167. FILE *cse_dump_file;
  168. FILE *loop_dump_file;
  169. FILE *flow_dump_file;
  170. FILE *combine_dump_file;
  171. FILE *local_reg_dump_file;
  172. FILE *global_reg_dump_file;
  173. FILE *jump2_opt_dump_file;
  174. /* Time accumulators, to count the total time spent in various passes. */
  175. int parse_time;
  176. int varconst_time;
  177. int integration_time;
  178. int jump_time;
  179. int cse_time;
  180. int loop_time;
  181. int flow_time;
  182. int combine_time;
  183. int local_alloc_time;
  184. int global_alloc_time;
  185. int final_time;
  186. int symout_time;
  187. int dump_time;
  188. /* Return time used so far, in microseconds. */
  189. int
  190. gettime ()
  191. {
  192. #ifdef USG
  193. struct tms tms;
  194. #else
  195. #ifndef VMS
  196. struct rusage rusage;
  197. #else /* VMS */
  198. struct
  199. {
  200. int proc_user_time;
  201. int proc_system_time;
  202. int child_user_time;
  203. int child_system_time;
  204. } vms_times;
  205. #endif
  206. #endif
  207. if (quiet_flag)
  208. return 0;
  209. #ifdef USG
  210. times (&tms);
  211. return (tms.tms_utime + tms.tms_stime) * (1000000 / HZ);
  212. #else
  213. #ifndef VMS
  214. getrusage (0, &rusage);
  215. return (rusage.ru_utime.tv_sec * 1000000 + rusage.ru_utime.tv_usec
  216. + rusage.ru_stime.tv_sec * 1000000 + rusage.ru_stime.tv_usec);
  217. #else /* VMS */
  218. times (&vms_times);
  219. return (vms_times.proc_user_time + vms_times.proc_system_time) * 10000;
  220. #endif
  221. #endif
  222. }
  223. #define TIMEVAR(VAR, BODY) \
  224. { int otime = gettime (); BODY; VAR += gettime () - otime; }
  225. void
  226. print_time (str, total)
  227. char *str;
  228. int total;
  229. {
  230. fprintf (stderr,
  231. "time in %s: %d.%06d\n",
  232. str, total / 1000000, total % 1000000);
  233. }
  234. /* Count an error or warning. Return 1 if the message should be printed. */
  235. int
  236. count_error (warningp)
  237. int warningp;
  238. {
  239. if (warningp && inhibit_warnings)
  240. return 0;
  241. if (warningp)
  242. warningcount++;
  243. else
  244. errorcount++;
  245. return 1;
  246. }
  247. /* Print a fatal error message. NAME is the text.
  248. Also include a system error message based on `errno'. */
  249. void
  250. pfatal_with_name (name)
  251. char *name;
  252. {
  253. fprintf (stderr, "cc1: ");
  254. perror (name);
  255. exit (35);
  256. }
  257. void
  258. fatal_io_error (name)
  259. char *name;
  260. {
  261. fprintf (stderr, "cc1:%s: I/O error\n", name);
  262. exit (35);
  263. }
  264. void
  265. fatal (s)
  266. char *s;
  267. {
  268. error (s, 0);
  269. exit (34);
  270. }
  271. /* Called when the start of a function definition is parsed,
  272. this function prints on stderr the name of the function. */
  273. void
  274. announce_function (decl)
  275. tree decl;
  276. {
  277. if (! quiet_flag)
  278. {
  279. fprintf (stderr, " %s", IDENTIFIER_POINTER (DECL_NAME (decl)));
  280. fflush (stderr);
  281. }
  282. }
  283. /* Prints out, if necessary, the name of the current function
  284. which caused an error. Called from all error and warning functions. */
  285. void
  286. report_error_function()
  287. {
  288. static tree last_error_function = NULL;
  289. if (last_error_function != current_function_decl)
  290. {
  291. if (current_function_decl == NULL)
  292. {
  293. if (!quiet_flag)
  294. fprintf (stderr, "\n");
  295. fprintf (stderr, "At top level:\n");
  296. }
  297. else
  298. {
  299. if (!quiet_flag)
  300. /* We already know this info. Don't print it twice.
  301. But make sure we are at the beginning of a line. */
  302. fprintf (stderr, "\n");
  303. else
  304. fprintf (stderr, "In function %s:\n",
  305. IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
  306. }
  307. last_error_function = current_function_decl;
  308. }
  309. }
  310. /* Report an error at the current line number.
  311. S and V are a string and an arg for `printf'. */
  312. void
  313. error (s, v)
  314. char *s;
  315. int v; /* @@also used as pointer */
  316. {
  317. error_with_file_and_line (input_filename, lineno, s, v);
  318. }
  319. /* Report an error at line LINE of file FILE.
  320. S and V are a string and an arg for `printf'. */
  321. void
  322. error_with_file_and_line (file, line, s, v)
  323. char *file;
  324. int line;
  325. char *s;
  326. int v;
  327. {
  328. count_error (0);
  329. report_error_function ();
  330. if (file)
  331. fprintf (stderr, "%s:%d: ", file, line);
  332. else
  333. fprintf (stderr, "cc1: ");
  334. fprintf (stderr, s, v);
  335. fprintf (stderr, "\n");
  336. }
  337. /* Report an error at the declaration DECL.
  338. S is string which uses %s to substitute the declaration name. */
  339. void
  340. error_with_decl (decl, s)
  341. tree decl;
  342. char *s;
  343. {
  344. count_error (0);
  345. report_error_function ();
  346. fprintf (stderr, "%s:%d: ",
  347. DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  348. if (DECL_NAME (decl))
  349. fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)));
  350. else
  351. fprintf (stderr, s, "((anonymous))");
  352. fprintf (stderr, "\n");
  353. }
  354. /* Report a warning at line LINE.
  355. S and V are a string and an arg for `printf'. */
  356. void
  357. warning_with_line (line, s, v)
  358. int line;
  359. char *s;
  360. int v;
  361. {
  362. if (count_error (1) == 0)
  363. return;
  364. report_error_function ();
  365. if (input_filename)
  366. fprintf (stderr, "%s:%d: ", input_filename, line);
  367. else
  368. fprintf (stderr, "cc1: ");
  369. fprintf (stderr, "warning: ");
  370. fprintf (stderr, s, v);
  371. fprintf (stderr, "\n");
  372. }
  373. /* Report a warning at the current line number.
  374. S and V are a string and an arg for `printf'. */
  375. void
  376. warning (s, v)
  377. char *s;
  378. int v; /* @@also used as pointer */
  379. {
  380. warning_with_line (lineno, s, v);
  381. }
  382. /* Report a warning at the declaration DECL.
  383. S is string which uses %s to substitute the declaration name. */
  384. void
  385. warning_with_decl (decl, s)
  386. tree decl;
  387. char *s;
  388. {
  389. if (count_error (1) == 0)
  390. return;
  391. report_error_function ();
  392. fprintf (stderr, "%s:%d: ",
  393. DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
  394. fprintf (stderr, "warning: ");
  395. if (DECL_NAME (decl))
  396. fprintf (stderr, s, IDENTIFIER_POINTER (DECL_NAME (decl)));
  397. else
  398. fprintf (stderr, s, "((anonymous))");
  399. fprintf (stderr, "\n");
  400. }
  401. /* When `malloc.c' is compiled with `rcheck' defined,
  402. it calls this function to report clobberage. */
  403. void
  404. botch (s)
  405. {
  406. abort ();
  407. }
  408. /* Same as `malloc' but report error if no memory available. */
  409. int
  410. xmalloc (size)
  411. unsigned size;
  412. {
  413. register int value = (int) malloc (size);
  414. if (value == 0)
  415. fatal ("Virtual memory exhausted.");
  416. return value;
  417. }
  418. /* Same as `realloc' but report error if no memory available. */
  419. int
  420. xrealloc (ptr, size)
  421. char *ptr;
  422. int size;
  423. {
  424. int result = realloc (ptr, size);
  425. if (!result)
  426. fatal ("Virtual memory exhausted.");
  427. return result;
  428. }
  429. /* Return the logarithm of X, base 2, considering X unsigned,
  430. if X is a power of 2. Otherwise, returns -1. */
  431. int
  432. exact_log2 (x)
  433. register unsigned int x;
  434. {
  435. register int log = 0;
  436. for (log = 0; log < HOST_BITS_PER_INT; log++)
  437. if (x == (1 << log))
  438. return log;
  439. return -1;
  440. }
  441. /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X.
  442. If X is 0, return -1. */
  443. int
  444. floor_log2 (x)
  445. register unsigned int x;
  446. {
  447. register int log = 0;
  448. for (log = 0; log < HOST_BITS_PER_INT; log++)
  449. if ((x & ((-1) << log)) == 0)
  450. return log - 1;
  451. return HOST_BITS_PER_INT - 1;
  452. }
  453. /* Compile an entire file of output from cpp, named NAME.
  454. Write a file of assembly output and various debugging dumps. */
  455. static void
  456. compile_file (name)
  457. char *name;
  458. {
  459. tree globals;
  460. int start_time;
  461. int dump_base_name_length = strlen (dump_base_name);
  462. parse_time = 0;
  463. varconst_time = 0;
  464. integration_time = 0;
  465. jump_time = 0;
  466. cse_time = 0;
  467. loop_time = 0;
  468. flow_time = 0;
  469. combine_time = 0;
  470. local_alloc_time = 0;
  471. global_alloc_time = 0;
  472. final_time = 0;
  473. symout_time = 0;
  474. dump_time = 0;
  475. /* Open input file. */
  476. finput = fopen (name, "r");
  477. if (finput == 0)
  478. pfatal_with_name (name);
  479. /* Initialize data in various passes. */
  480. init_tree ();
  481. init_lex ();
  482. init_rtl ();
  483. init_emit_once ();
  484. init_decl_processing ();
  485. init_optabs ();
  486. /* If rtl dump desired, open the output file. */
  487. if (rtl_dump)
  488. {
  489. register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  490. strcpy (dumpname, dump_base_name);
  491. strcat (dumpname, ".rtl");
  492. rtl_dump_file = fopen (dumpname, "w");
  493. if (rtl_dump_file == 0)
  494. pfatal_with_name (dumpname);
  495. }
  496. /* If jump_opt dump desired, open the output file. */
  497. if (jump_opt_dump)
  498. {
  499. register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  500. strcpy (dumpname, dump_base_name);
  501. strcat (dumpname, ".jump");
  502. jump_opt_dump_file = fopen (dumpname, "w");
  503. if (jump_opt_dump_file == 0)
  504. pfatal_with_name (dumpname);
  505. }
  506. /* If cse dump desired, open the output file. */
  507. if (cse_dump)
  508. {
  509. register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  510. strcpy (dumpname, dump_base_name);
  511. strcat (dumpname, ".cse");
  512. cse_dump_file = fopen (dumpname, "w");
  513. if (cse_dump_file == 0)
  514. pfatal_with_name (dumpname);
  515. }
  516. /* If loop dump desired, open the output file. */
  517. if (loop_dump)
  518. {
  519. register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  520. strcpy (dumpname, dump_base_name);
  521. strcat (dumpname, ".loop");
  522. loop_dump_file = fopen (dumpname, "w");
  523. if (loop_dump_file == 0)
  524. pfatal_with_name (dumpname);
  525. }
  526. /* If flow dump desired, open the output file. */
  527. if (flow_dump)
  528. {
  529. register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  530. strcpy (dumpname, dump_base_name);
  531. strcat (dumpname, ".flow");
  532. flow_dump_file = fopen (dumpname, "w");
  533. if (flow_dump_file == 0)
  534. pfatal_with_name (dumpname);
  535. }
  536. /* If combine dump desired, open the output file. */
  537. if (combine_dump)
  538. {
  539. register char *dumpname = (char *) xmalloc (dump_base_name_length + 10);
  540. strcpy (dumpname, dump_base_name);
  541. strcat (dumpname, ".combine");
  542. combine_dump_file = fopen (dumpname, "w");
  543. if (combine_dump_file == 0)
  544. pfatal_with_name (dumpname);
  545. }
  546. /* If local_reg dump desired, open the output file. */
  547. if (local_reg_dump)
  548. {
  549. register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  550. strcpy (dumpname, dump_base_name);
  551. strcat (dumpname, ".lreg");
  552. local_reg_dump_file = fopen (dumpname, "w");
  553. if (local_reg_dump_file == 0)
  554. pfatal_with_name (dumpname);
  555. }
  556. /* If global_reg dump desired, open the output file. */
  557. if (global_reg_dump)
  558. {
  559. register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  560. strcpy (dumpname, dump_base_name);
  561. strcat (dumpname, ".greg");
  562. global_reg_dump_file = fopen (dumpname, "w");
  563. if (global_reg_dump_file == 0)
  564. pfatal_with_name (dumpname);
  565. }
  566. /* If jump2_opt dump desired, open the output file. */
  567. if (jump2_opt_dump)
  568. {
  569. register char *dumpname = (char *) xmalloc (dump_base_name_length + 7);
  570. strcpy (dumpname, dump_base_name);
  571. strcat (dumpname, ".jump2");
  572. jump2_opt_dump_file = fopen (dumpname, "w");
  573. if (jump2_opt_dump_file == 0)
  574. pfatal_with_name (dumpname);
  575. }
  576. /* Open assembler code output file. */
  577. {
  578. register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  579. int len = strlen (dump_base_name);
  580. strcpy (dumpname, dump_base_name);
  581. if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  582. dumpname[len - 2] = 0;
  583. else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  584. dumpname[len - 3] = 0;
  585. strcat (dumpname, ".s");
  586. if (asm_file_name == 0)
  587. {
  588. asm_file_name = (char *) malloc (strlen (dumpname) + 1);
  589. strcpy (asm_file_name, dumpname);
  590. }
  591. asm_out_file = fopen (asm_file_name, "w");
  592. if (asm_out_file == 0)
  593. pfatal_with_name (asm_file_name ? asm_file_name : dumpname);
  594. fprintf (asm_out_file, ASM_FILE_START);
  595. }
  596. input_filename = name;
  597. /* the beginning of the file is a new line; check for # */
  598. /* With luck, we discover the real source file's name from that
  599. and put it in input_filename. */
  600. check_newline ();
  601. /* If GDB symbol table desired, open the GDB symbol output file. */
  602. if (write_symbols == 1)
  603. {
  604. register char *dumpname = (char *) xmalloc (dump_base_name_length + 6);
  605. int len = strlen (dump_base_name);
  606. strcpy (dumpname, dump_base_name);
  607. if (len > 2 && ! strcmp (".c", dumpname + len - 2))
  608. dumpname[len - 2] = 0;
  609. else if (len > 3 && ! strcmp (".co", dumpname + len - 3))
  610. dumpname[len - 3] = 0;
  611. strcat (dumpname, ".sym");
  612. if (sym_file_name == 0)
  613. sym_file_name = dumpname;
  614. symout_init (sym_file_name, asm_out_file, input_filename);
  615. }
  616. /* If dbx symbol table desired, initialize writing it
  617. and output the predefined types. */
  618. if (write_symbols == 2)
  619. dbxout_init (asm_out_file, main_input_filename);
  620. /* Initialize yet another pass. */
  621. init_final (main_input_filename);
  622. start_time = gettime ();
  623. /* Call the parser, which parses the entire file
  624. (calling rest_of_compilation for each function). */
  625. yyparse ();
  626. /* Compilation is now finished except for writing
  627. what's left of the symbol table output. */
  628. parse_time += gettime () - start_time;
  629. parse_time -= varconst_time;
  630. globals = getdecls ();
  631. /* Really define vars that have had only a tentative definition.
  632. Really output inline functions that must actually be callable
  633. and have not been output so far. */
  634. {
  635. tree decl;
  636. for (decl = globals; decl; decl = TREE_CHAIN (decl))
  637. {
  638. if (TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl)
  639. && ! TREE_ASM_WRITTEN (decl))
  640. rest_of_decl_compilation (decl, 0, 1, 1);
  641. if (TREE_CODE (decl) == FUNCTION_DECL
  642. && ! TREE_ASM_WRITTEN (decl)
  643. && DECL_INITIAL (decl) != 0
  644. && TREE_ADDRESSABLE (decl))
  645. output_inline_function (decl);
  646. }
  647. }
  648. /* Do dbx symbols */
  649. if (write_symbols == 2)
  650. TIMEVAR (symout_time,
  651. {
  652. dbxout_tags (gettags ());
  653. dbxout_types (get_permanent_types ());
  654. });
  655. /* Do gdb symbols */
  656. if (write_symbols == 1)
  657. TIMEVAR (symout_time,
  658. {
  659. struct stat statbuf;
  660. fstat (fileno (finput), &statbuf);
  661. symout_types (get_permanent_types ());
  662. symout_top_blocks (globals, gettags ());
  663. symout_finish (name, statbuf.st_ctime);
  664. });
  665. /* Close the dump files. */
  666. if (rtl_dump)
  667. fclose (rtl_dump_file);
  668. if (jump_opt_dump)
  669. fclose (jump_opt_dump_file);
  670. if (cse_dump)
  671. fclose (cse_dump_file);
  672. if (loop_dump)
  673. fclose (loop_dump_file);
  674. if (flow_dump)
  675. fclose (flow_dump_file);
  676. if (combine_dump)
  677. {
  678. dump_combine_total_stats (combine_dump_file);
  679. fclose (combine_dump_file);
  680. }
  681. if (local_reg_dump)
  682. fclose (local_reg_dump_file);
  683. if (global_reg_dump)
  684. fclose (global_reg_dump_file);
  685. if (jump2_opt_dump)
  686. fclose (jump2_opt_dump_file);
  687. /* Close non-debugging input and output files. */
  688. fclose (finput);
  689. if (ferror (asm_out_file) != 0)
  690. fatal_io_error (asm_file_name);
  691. fclose (asm_out_file);
  692. /* Print the times. */
  693. if (! quiet_flag)
  694. {
  695. fprintf (stderr,"\n");
  696. print_time ("parse", parse_time);
  697. print_time ("integration", integration_time);
  698. print_time ("jump", jump_time);
  699. print_time ("cse", cse_time);
  700. print_time ("loop", loop_time);
  701. print_time ("flow", flow_time);
  702. print_time ("combine", combine_time);
  703. print_time ("local-alloc", local_alloc_time);
  704. print_time ("global-alloc", global_alloc_time);
  705. print_time ("final", final_time);
  706. print_time ("varconst", varconst_time);
  707. print_time ("symout", symout_time);
  708. print_time ("dump", dump_time);
  709. }
  710. }
  711. /* This is called from finish_decl (within yyparse)
  712. for each declaration of a function or variable.
  713. This does nothing for automatic variables.
  714. Otherwise, it sets up the RTL and outputs any assembler code
  715. (label definition, storage allocation and initialization).
  716. DECL is the declaration. If ASMSPEC is nonzero, it specifies
  717. the assembler symbol name to be used. TOP_LEVEL is nonzero
  718. if this declaration is not within a function. */
  719. void
  720. rest_of_decl_compilation (decl, asmspec, top_level, at_end)
  721. tree decl;
  722. tree asmspec;
  723. int top_level;
  724. int at_end;
  725. {
  726. /* Declarations of variables, and of functions defined elsewhere. */
  727. if (TREE_STATIC (decl) || TREE_EXTERNAL (decl))
  728. TIMEVAR (varconst_time,
  729. {
  730. assemble_variable (decl, asmspec, top_level, write_symbols, at_end);
  731. });
  732. if (top_level)
  733. {
  734. if (write_symbols == 1)
  735. {
  736. TIMEVAR (symout_time,
  737. {
  738. /* The initizations make types when they contain
  739. string constants. The types are on the temporary
  740. obstack, so output them now before they go away. */
  741. symout_types (get_temporary_types ());
  742. });
  743. }
  744. else
  745. /* Clean out the temporary type list, since the types will go away. */
  746. get_temporary_types ();
  747. }
  748. }
  749. /* This is called from finish_function (within yyparse)
  750. after each top-level definition is parsed.
  751. It is supposed to compile that function or variable
  752. and output the assembler code for it.
  753. After we return, the tree storage is freed. */
  754. void
  755. rest_of_compilation (decl)
  756. tree decl;
  757. {
  758. register rtx insns;
  759. int start_time = gettime ();
  760. int tem;
  761. /* If we are reconsidering an inline function
  762. at the end of compilation, skip the stuff for making it inline. */
  763. if (DECL_SAVED_INSNS (decl) == 0)
  764. {
  765. /* If requested, consider whether to make this function inline. */
  766. if (flag_inline_functions || TREE_INLINE (decl))
  767. {
  768. TIMEVAR (integration_time,
  769. {
  770. int specd = TREE_INLINE (decl);
  771. char *lose = function_cannot_inline_p (decl);
  772. if (lose != 0 && specd)
  773. warning_with_decl (decl, lose);
  774. if (lose == 0)
  775. save_for_inline (decl);
  776. else
  777. TREE_INLINE (decl) = 0;
  778. });
  779. }
  780. insns = get_insns ();
  781. /* Dump the rtl code if we are dumping rtl. */
  782. if (rtl_dump)
  783. TIMEVAR (dump_time,
  784. {
  785. fprintf (rtl_dump_file, "\n;; Function %s\n\n",
  786. IDENTIFIER_POINTER (DECL_NAME (decl)));
  787. if (DECL_SAVED_INSNS (decl))
  788. fprintf (rtl_dump_file, ";; (integrable)\n\n");
  789. print_rtl (rtl_dump_file, insns);
  790. fflush (rtl_dump_file);
  791. });
  792. /* If function is inline, and we don't yet know whether to
  793. compile it by itself, defer decision till end of compilation.
  794. finish_compilation will call rest_of_compilation again
  795. for those functions that need to be output. */
  796. if (TREE_PUBLIC (decl) == 0
  797. && TREE_INLINE (decl)
  798. && ! flag_keep_inline_functions)
  799. goto exit_rest_of_compilation;
  800. }
  801. if (rtl_dump_and_exit)
  802. goto exit_rest_of_compilation;
  803. TREE_ASM_WRITTEN (decl) = 1;
  804. insns = get_insns ();
  805. /* Copy any shared structure that should not be shared. */
  806. unshare_all_rtl (insns);
  807. /* See if we have allocated stack slots that are not directly addressable.
  808. If so, scan all the insns and create explicit address computation
  809. for all references to such slots. */
  810. /* fixup_stack_slots (); */
  811. /* Do jump optimization the first time, if -opt.
  812. Also do it if -W, but in that case it doesn't change the rtl code,
  813. it only computes whether control can drop off the end of the function. */
  814. if (optimize || extra_warnings || warn_return_type)
  815. TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  816. /* Dump rtl code after jump, if we are doing that. */
  817. if (jump_opt_dump)
  818. TIMEVAR (dump_time,
  819. {
  820. fprintf (jump_opt_dump_file, "\n;; Function %s\n\n",
  821. IDENTIFIER_POINTER (DECL_NAME (decl)));
  822. print_rtl (jump_opt_dump_file, insns);
  823. fflush (jump_opt_dump_file);
  824. });
  825. /* Perform common subexpression elimination.
  826. Nonzero value from `cse_main' means that jumps were simplified
  827. and some code may now be unreachable, so do
  828. jump optimization again. */
  829. if (optimize)
  830. {
  831. TIMEVAR (cse_time, reg_scan (insns, max_reg_num (), 0));
  832. TIMEVAR (cse_time, tem = cse_main (insns, max_reg_num ()));
  833. if (tem)
  834. TIMEVAR (jump_time, jump_optimize (insns, 0, 0));
  835. }
  836. /* Dump rtl code after cse, if we are doing that. */
  837. if (cse_dump)
  838. TIMEVAR (dump_time,
  839. {
  840. fprintf (cse_dump_file, "\n;; Function %s\n\n",
  841. IDENTIFIER_POINTER (DECL_NAME (decl)));
  842. print_rtl (cse_dump_file, insns);
  843. fflush (cse_dump_file);
  844. });
  845. if (loop_dump)
  846. TIMEVAR (dump_time,
  847. {
  848. fprintf (loop_dump_file, "\n;; Function %s\n\n",
  849. IDENTIFIER_POINTER (DECL_NAME (decl)));
  850. });
  851. /* Move constant computations out of loops. */
  852. if (optimize)
  853. {
  854. TIMEVAR (loop_time,
  855. {
  856. reg_scan (insns, max_reg_num (), 1);
  857. loop_optimize (insns, max_reg_num (),
  858. loop_dump ? loop_dump_file : 0);
  859. });
  860. }
  861. /* Dump rtl code after loop opt, if we are doing that. */
  862. if (loop_dump)
  863. TIMEVAR (dump_time,
  864. {
  865. print_rtl (loop_dump_file, insns);
  866. fflush (loop_dump_file);
  867. });
  868. /* Now we choose between stupid (pcc-like) register allocation
  869. (if we got the -noreg switch and not -opt)
  870. and smart register allocation. */
  871. if (optimize) /* Stupid allocation probably won't work */
  872. obey_regdecls = 0; /* if optimizations being done. */
  873. regclass_init ();
  874. /* Print function header into flow dump now
  875. because doing the flow analysis makes some of the dump. */
  876. if (flow_dump)
  877. TIMEVAR (dump_time,
  878. {
  879. fprintf (flow_dump_file, "\n;; Function %s\n\n",
  880. IDENTIFIER_POINTER (DECL_NAME (decl)));
  881. });
  882. if (obey_regdecls)
  883. {
  884. TIMEVAR (flow_time,
  885. {
  886. regclass (insns, max_reg_num ());
  887. stupid_life_analysis (insns, max_reg_num (),
  888. flow_dump_file);
  889. });
  890. }
  891. else
  892. {
  893. /* Do control and data flow analysis,
  894. and write some of the results to dump file. */
  895. TIMEVAR (flow_time, flow_analysis (insns, max_reg_num (),
  896. flow_dump_file));
  897. if (extra_warnings)
  898. uninitialized_vars_warning (DECL_INITIAL (decl));
  899. }
  900. /* Dump rtl after flow analysis. */
  901. if (flow_dump)
  902. TIMEVAR (dump_time,
  903. {
  904. print_rtl (flow_dump_file, insns);
  905. fflush (flow_dump_file);
  906. });
  907. /* If -opt, try combining insns through substitution. */
  908. if (optimize)
  909. TIMEVAR (combine_time, combine_instructions (insns, max_reg_num ()));
  910. /* Dump rtl code after insn combination. */
  911. if (combine_dump)
  912. TIMEVAR (dump_time,
  913. {
  914. fprintf (combine_dump_file, "\n;; Function %s\n\n",
  915. IDENTIFIER_POINTER (DECL_NAME (decl)));
  916. dump_combine_stats (combine_dump_file);
  917. print_rtl (combine_dump_file, insns);
  918. fflush (combine_dump_file);
  919. });
  920. /* Unless we did stupid register allocation,
  921. allocate pseudo-regs that are used only within 1 basic block. */
  922. if (!obey_regdecls)
  923. TIMEVAR (local_alloc_time,
  924. {
  925. regclass (insns, max_reg_num ());
  926. local_alloc ();
  927. });
  928. /* Dump rtl code after allocating regs within basic blocks. */
  929. if (local_reg_dump)
  930. TIMEVAR (dump_time,
  931. {
  932. fprintf (local_reg_dump_file, "\n;; Function %s\n\n",
  933. IDENTIFIER_POINTER (DECL_NAME (decl)));
  934. dump_flow_info (local_reg_dump_file);
  935. dump_local_alloc (local_reg_dump_file);
  936. print_rtl (local_reg_dump_file, insns);
  937. fflush (local_reg_dump_file);
  938. });
  939. if (global_reg_dump)
  940. TIMEVAR (dump_time,
  941. fprintf (global_reg_dump_file, "\n;; Function %s\n\n",
  942. IDENTIFIER_POINTER (DECL_NAME (decl))));
  943. /* Unless we did stupid register allocation,
  944. allocate remaining pseudo-regs, then do the reload pass
  945. fixing up any insns that are invalid. */
  946. TIMEVAR (global_alloc_time,
  947. {
  948. if (!obey_regdecls)
  949. global_alloc (global_reg_dump ? global_reg_dump_file : 0);
  950. else
  951. reload (insns, 0,
  952. global_reg_dump ? global_reg_dump_file : 0);
  953. });
  954. if (global_reg_dump)
  955. TIMEVAR (dump_time,
  956. {
  957. dump_global_regs (global_reg_dump_file);
  958. print_rtl (global_reg_dump_file, insns);
  959. fflush (global_reg_dump_file);
  960. });
  961. /* One more attempt to remove jumps to .+1
  962. left by dead-store-elimination.
  963. Also do cross-jumping this time
  964. and delete no-op move insns. */
  965. if (optimize)
  966. {
  967. TIMEVAR (jump_time, jump_optimize (insns, 1, 1));
  968. }
  969. /* Dump rtl code after jump, if we are doing that. */
  970. if (jump2_opt_dump)
  971. TIMEVAR (dump_time,
  972. {
  973. fprintf (jump2_opt_dump_file, "\n;; Function %s\n\n",
  974. IDENTIFIER_POINTER (DECL_NAME (decl)));
  975. print_rtl (jump2_opt_dump_file, insns);
  976. fflush (jump2_opt_dump_file);
  977. });
  978. /* Now turn the rtl into assembler code. */
  979. TIMEVAR (final_time,
  980. {
  981. assemble_function (decl);
  982. final_start_function (insns, asm_out_file,
  983. write_symbols, optimize);
  984. final (insns, asm_out_file,
  985. write_symbols, optimize);
  986. final_end_function (insns, asm_out_file,
  987. write_symbols, optimize);
  988. fflush (asm_out_file);
  989. });
  990. /* Write GDB symbols if requested */
  991. if (write_symbols == 1)
  992. {
  993. TIMEVAR (symout_time,
  994. {
  995. symout_types (get_permanent_types ());
  996. symout_types (get_temporary_types ());
  997. DECL_BLOCK_SYMTAB_ADDRESS (decl)
  998. = symout_function (DECL_INITIAL (decl),
  999. DECL_ARGUMENTS (decl), 0);
  1000. });
  1001. }
  1002. else
  1003. get_temporary_types ();
  1004. /* Write DBX symbols if requested */
  1005. if (write_symbols == 2)
  1006. TIMEVAR (symout_time, dbxout_function (decl));
  1007. exit_rest_of_compilation:
  1008. /* The parsing time is all the time spent in yyparse
  1009. *except* what is spent in this function. */
  1010. parse_time -= gettime () - start_time;
  1011. }
  1012. /* Entry point of cc1. Decode command args, then call compile_file.
  1013. Exit code is 35 if can't open files, 34 if fatal error,
  1014. 33 if had nonfatal errors, else success. */
  1015. int
  1016. main (argc, argv, envp)
  1017. int argc;
  1018. char **argv;
  1019. char **envp;
  1020. {
  1021. register int i;
  1022. char *filename = 0;
  1023. int print_mem_flag = 0;
  1024. #ifdef RLIMIT_STACK
  1025. /* Get rid of any avoidable limit on stack size. */
  1026. {
  1027. struct rlimit rlim;
  1028. /* Set the stack limit huge so that alloca does not fail. */
  1029. getrlimit (RLIMIT_STACK, &rlim);
  1030. rlim.rlim_cur = rlim.rlim_max;
  1031. setrlimit (RLIMIT_STACK, &rlim);
  1032. }
  1033. #endif /* RLIMIT_STACK */
  1034. /* Initialize whether `char' is signed. */
  1035. flag_signed_char = DEFAULT_SIGNED_CHAR;
  1036. /* Initialize reg-sets now so switches may override. */
  1037. init_reg_sets ();
  1038. target_flags = 0;
  1039. set_target_switch ("");
  1040. for (i = 1; i < argc; i++)
  1041. if (argv[i][0] == '-')
  1042. {
  1043. register char *str = argv[i] + 1;
  1044. if (str[0] == 'Y')
  1045. str++;
  1046. if (str[0] == 'm')
  1047. set_target_switch (&str[1]);
  1048. else if (!strcmp (str, "dumpbase"))
  1049. {
  1050. dump_base_name = argv[++i];
  1051. }
  1052. else if (str[0] == 'd')
  1053. {
  1054. register char *p = &str[1];
  1055. while (*p)
  1056. switch (*p++)
  1057. {
  1058. case 'c':
  1059. combine_dump = 1;
  1060. break;
  1061. case 'f':
  1062. flow_dump = 1;
  1063. break;
  1064. case 'g':
  1065. global_reg_dump = 1;
  1066. break;
  1067. case 'j':
  1068. jump_opt_dump = 1;
  1069. break;
  1070. case 'J':
  1071. jump2_opt_dump = 1;
  1072. break;
  1073. case 'l':
  1074. local_reg_dump = 1;
  1075. break;
  1076. case 'L':
  1077. loop_dump = 1;
  1078. break;
  1079. case 'm':
  1080. print_mem_flag = 1;
  1081. break;
  1082. case 'r':
  1083. rtl_dump = 1;
  1084. break;
  1085. case 's':
  1086. cse_dump = 1;
  1087. break;
  1088. case 'y':
  1089. yydebug = 1;
  1090. break;
  1091. }
  1092. }
  1093. else if (str[0] == 'f')
  1094. {
  1095. register char *p = &str[1];
  1096. if (!strcmp (p, "float-store"))
  1097. flag_float_store = 1;
  1098. else if (!strcmp (p, "traditional"))
  1099. flag_traditional = 1;
  1100. else if (!strcmp (p, "volatile"))
  1101. flag_volatile = 1;
  1102. else if (!strcmp (p, "defer-pop"))
  1103. flag_defer_pop = 1;
  1104. else if (!strcmp (p, "no-defer-pop"))
  1105. flag_defer_pop = 0;
  1106. else if (!strcmp (p, "omit-frame-pointer"))
  1107. flag_omit_frame_pointer = 1;
  1108. else if (!strcmp (p, "no-omit-frame-pointer"))
  1109. flag_omit_frame_pointer = 0;
  1110. else if (!strcmp (p, "no-peephole"))
  1111. flag_no_peephole = 1;
  1112. else if (!strcmp (p, "signed-char"))
  1113. flag_signed_char = 1;
  1114. else if (!strcmp (p, "unsigned-char"))
  1115. flag_signed_char = 0;
  1116. else if (!strcmp (p, "force-mem"))
  1117. flag_force_mem = 1;
  1118. else if (!strcmp (p, "force-addr"))
  1119. flag_force_addr = 1;
  1120. else if (!strcmp (p, "combine-regs"))
  1121. flag_combine_regs = 1;
  1122. else if (!strcmp (p, "writable-strings"))
  1123. flag_writable_strings = 1;
  1124. else if (!strcmp (p, "no-function-cse"))
  1125. flag_no_function_cse = 1;
  1126. else if (!strcmp (p, "cond-mismatch"))
  1127. flag_cond_mismatch = 1;
  1128. else if (!strcmp (p, "no-asm"))
  1129. flag_no_asm = 1;
  1130. else if (!strncmp (p, "fixed-", 6))
  1131. fix_register (&p[6], 1, 1);
  1132. else if (!strncmp (p, "call-used-", 10))
  1133. fix_register (&p[10], 0, 1);
  1134. else if (!strncmp (p, "call-saved-", 11))
  1135. fix_register (&p[11], 0, 0);
  1136. else if (!strcmp (p, "inline-functions"))
  1137. flag_inline_functions = 1;
  1138. else if (!strcmp (p, "keep-inline-functions"))
  1139. flag_keep_inline_functions = 1;
  1140. else
  1141. error ("Invalid option, `%s'", argv[i]);
  1142. }
  1143. else if (!strcmp (str, "noreg"))
  1144. obey_regdecls = 1;
  1145. else if (!strcmp (str, "opt"))
  1146. optimize = 1;
  1147. else if (!strcmp (str, "pedantic"))
  1148. pedantic = 1;
  1149. else if (!strcmp (str, "traditional"))
  1150. flag_traditional = 1;
  1151. else if (!strcmp (str, "ansi"))
  1152. flag_no_asm = 1;
  1153. else if (!strcmp (str, "quiet"))
  1154. quiet_flag = 1;
  1155. else if (!strcmp (str, "version"))
  1156. {
  1157. extern char *version_string;
  1158. printf ("GNU C version %s", version_string);
  1159. #ifdef TARGET_VERSION
  1160. TARGET_VERSION;
  1161. #endif
  1162. #ifdef __GNUC__
  1163. #ifndef __VERSION__
  1164. #define __VERSION__ "[unknown]"
  1165. #endif
  1166. printf (" compiled by GNU C version %s.\n", __VERSION__);
  1167. #else
  1168. printf (" compiled by CC.\n");
  1169. #endif
  1170. }
  1171. else if (!strcmp (str, "w"))
  1172. inhibit_warnings = 1;
  1173. else if (!strcmp (str, "W"))
  1174. extra_warnings = 1;
  1175. else if (!strcmp (str, "Wimplicit"))
  1176. warn_implicit = 1;
  1177. else if (!strcmp (str, "Wreturn-type"))
  1178. warn_return_type = 1;
  1179. else if (!strcmp (str, "p"))
  1180. profile_flag = 1;
  1181. else if (!strcmp (str, "g"))
  1182. write_symbols = 1;
  1183. else if (!strcmp (str, "G"))
  1184. write_symbols = 2;
  1185. else if (!strcmp (str, "symout"))
  1186. {
  1187. if (write_symbols == 0)
  1188. write_symbols = 1;
  1189. sym_file_name = argv[++i];
  1190. }
  1191. else if (!strcmp (str, "o"))
  1192. {
  1193. asm_file_name = argv[++i];
  1194. }
  1195. else
  1196. error ("Invalid switch, %s.", argv[i]);
  1197. }
  1198. else
  1199. filename = argv[i];
  1200. if (filename == 0)
  1201. fatal ("no input file specified");
  1202. if (dump_base_name == 0)
  1203. dump_base_name = filename;
  1204. #ifdef OVERRIDE_OPTIONS
  1205. /* Some machines may reject certain combinations of options. */
  1206. OVERRIDE_OPTIONS;
  1207. #endif
  1208. compile_file (filename);
  1209. #ifndef USG
  1210. #ifndef VMS
  1211. if (print_mem_flag)
  1212. {
  1213. extern char **environ;
  1214. caddr_t lim = (caddr_t) sbrk (0);
  1215. fprintf (stderr, "Data size %d.\n",
  1216. (int) lim - (int) &environ);
  1217. fflush (stderr);
  1218. system ("ps v");
  1219. }
  1220. #endif /* not VMS */
  1221. #endif /* not USG */
  1222. if (errorcount)
  1223. exit (FATAL_EXIT_CODE);
  1224. exit (SUCCESS_EXIT_CODE);
  1225. return 34;
  1226. }
  1227. /* Decode -m switches. */
  1228. /* Here is a table, controlled by the tm-...h file, listing each -m switch
  1229. and which bits in `target_switches' it should set or clear.
  1230. If VALUE is positive, it is bits to set.
  1231. If VALUE is negative, -VALUE is bits to clear.
  1232. (The sign bit is not used so there is no confusion.) */
  1233. struct {char *name; int value;} target_switches []
  1234. = TARGET_SWITCHES;
  1235. /* Decode the switch -mNAME. */
  1236. void
  1237. set_target_switch (name)
  1238. char *name;
  1239. {
  1240. register int j;
  1241. for (j = 0; j < sizeof target_switches / sizeof target_switches[0]; j++)
  1242. if (!strcmp (target_switches[j].name, name))
  1243. {
  1244. if (target_switches[j].value < 0)
  1245. target_flags &= ~-target_switches[j].value;
  1246. else
  1247. target_flags |= target_switches[j].value;
  1248. break;
  1249. }
  1250. }