150397Sobrien/* toplev.h - Various declarations for functions found in toplev.c
2169689Skan   Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2005
3132718Skan   Free Software Foundation, Inc.
450397Sobrien
590075SobrienThis file is part of GCC.
652284Sobrien
790075SobrienGCC is free software; you can redistribute it and/or modify it under
890075Sobrienthe terms of the GNU General Public License as published by the Free
990075SobrienSoftware Foundation; either version 2, or (at your option) any later
1090075Sobrienversion.
1152284Sobrien
1290075SobrienGCC is distributed in the hope that it will be useful, but WITHOUT ANY
1390075SobrienWARRANTY; without even the implied warranty of MERCHANTABILITY or
1490075SobrienFITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1590075Sobrienfor more details.
1652284Sobrien
1752284SobrienYou should have received a copy of the GNU General Public License
1890075Sobrienalong with GCC; see the file COPYING.  If not, write to the Free
19169689SkanSoftware Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
20169689Skan02110-1301, USA.  */
2152284Sobrien
2290075Sobrien#ifndef GCC_TOPLEV_H
2390075Sobrien#define GCC_TOPLEV_H
2450397Sobrien
2590075Sobrien/* If non-NULL, return one past-the-end of the matching SUBPART of
2690075Sobrien   the WHOLE string.  */
2790075Sobrien#define skip_leading_substring(whole,  part) \
2890075Sobrien   (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))
2950397Sobrien
30132718Skanextern int toplev_main (unsigned int, const char **);
31132718Skanextern int read_integral_parameter (const char *, const char *, const int);
32132718Skanextern void strip_off_ending (char *, int);
33132718Skanextern const char *trim_filename (const char *);
34132718Skanextern void _fatal_insn_not_found (rtx, const char *, int, const char *)
35132718Skan     ATTRIBUTE_NORETURN;
36132718Skanextern void _fatal_insn (const char *, rtx, const char *, int, const char *)
37132718Skan     ATTRIBUTE_NORETURN;
3850397Sobrien
3990075Sobrien#define fatal_insn(msgid, insn) \
4090075Sobrien	_fatal_insn (msgid, insn, __FILE__, __LINE__, __FUNCTION__)
4190075Sobrien#define fatal_insn_not_found(insn) \
4290075Sobrien	_fatal_insn_not_found (insn, __FILE__, __LINE__, __FUNCTION__)
4390075Sobrien
44132718Skan/* If we haven't already defined a frontend specific diagnostics
45132718Skan   style, use the generic one.  */
46132718Skan#ifndef GCC_DIAG_STYLE
47169689Skan#define GCC_DIAG_STYLE __gcc_tdiag__
48132718Skan#endif
4990075Sobrien/* None of these functions are suitable for ATTRIBUTE_PRINTF, because
5090075Sobrien   each language front end can extend them with its own set of format
51132718Skan   specifiers.  We must use custom format checks.  */
52169689Skan#if GCC_VERSION >= 4001
53132718Skan#define ATTRIBUTE_GCC_DIAG(m, n) __attribute__ ((__format__ (GCC_DIAG_STYLE, m, n))) ATTRIBUTE_NONNULL(m)
54132718Skan#else
55132718Skan#define ATTRIBUTE_GCC_DIAG(m, n) ATTRIBUTE_NONNULL(m)
56132718Skan#endif
57132718Skanextern void internal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
58132718Skan     ATTRIBUTE_NORETURN;
59169689Skanextern void warning0 (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
60169689Skan/* Pass one of the OPT_W* from options.h as the first parameter.  */
61169689Skanextern void warning (int, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
62169689Skanextern void error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
63132718Skanextern void fatal_error (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2)
64132718Skan     ATTRIBUTE_NORETURN;
65169689Skanextern void pedwarn (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
66169689Skanextern void sorry (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
67132718Skanextern void inform (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
68169689Skanextern void verbatim (const char *, ...) ATTRIBUTE_GCC_DIAG(1,2);
6990075Sobrien
70169689Skanextern void rest_of_decl_compilation (tree, int, int);
71132718Skanextern void rest_of_type_compilation (tree, int);
72169689Skanextern void tree_rest_of_compilation (tree);
73169689Skanextern void init_optimization_passes (void);
74169689Skanextern void finish_optimization_passes (void);
75169689Skanextern bool enable_rtl_dump_file (int);
7652284Sobrien
77132718Skanextern void announce_function (tree);
7852284Sobrien
79132718Skanextern void error_for_asm (rtx, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
80132718Skanextern void warning_for_asm (rtx, const char *, ...) ATTRIBUTE_GCC_DIAG(2,3);
81132718Skanextern void warn_deprecated_use (tree);
8250397Sobrien
8350397Sobrien#ifdef BUFSIZ
84132718Skanextern void output_quoted_string	(FILE *, const char *);
85132718Skanextern void output_file_directive	(FILE *, const char *);
8650397Sobrien#endif
8750397Sobrien
8852284Sobrien#ifdef BUFSIZ
8990075Sobrien  /* N.B. Unlike all the others, fnotice is just gettext+fprintf, and
9090075Sobrien     therefore it can have ATTRIBUTE_PRINTF.  */
91132718Skanextern void fnotice			(FILE *, const char *, ...)
92132718Skan     ATTRIBUTE_PRINTF_2;
9352284Sobrien#endif
9452284Sobrien
95169689Skanextern void wrapup_global_declaration_1 (tree);
96169689Skanextern bool wrapup_global_declaration_2 (tree);
97169689Skanextern bool wrapup_global_declarations (tree *, int);
98169689Skanextern void check_global_declaration_1 (tree);
99132718Skanextern void check_global_declarations (tree *, int);
100169689Skanextern void emit_debug_global_declarations (tree *, int);
101132718Skanextern void write_global_declarations (void);
10290075Sobrien
103132718Skan/* A unique local time stamp, might be zero if none is available.  */
104132718Skanextern unsigned local_tick;
105132718Skan
10690075Sobrienextern const char *progname;
10790075Sobrienextern const char *dump_base_name;
108117395Skanextern const char *aux_base_name;
109132718Skanextern const char *aux_info_file_name;
110132718Skanextern const char *asm_file_name;
111132718Skanextern bool exit_after_options;
11290075Sobrien
113117395Skanextern int target_flags_explicit;
114117395Skan
115169689Skan/* True if the user has tagged the function with the 'section'
116169689Skan   attribute.  */
117169689Skan
118169689Skanextern bool user_defined_section_attribute;
119169689Skan
120132718Skan/* See toplev.c.  */
121132718Skanextern int flag_crossjumping;
122132718Skanextern int flag_if_conversion;
123132718Skanextern int flag_if_conversion2;
124132718Skanextern int flag_keep_static_consts;
125132718Skanextern int flag_peel_loops;
126132718Skanextern int flag_rerun_cse_after_loop;
127132718Skanextern int flag_thread_jumps;
128132718Skanextern int flag_tracer;
129132718Skanextern int flag_unroll_loops;
130132718Skanextern int flag_unroll_all_loops;
131132718Skanextern int flag_unswitch_loops;
132132718Skanextern int flag_cprop_registers;
133132718Skanextern int time_report;
134132718Skan
135132718Skan/* Things to do with target switches.  */
136132718Skanextern void print_version (FILE *, const char *);
137132718Skanextern void * default_get_pch_validity (size_t *);
138132718Skanextern const char * default_pch_valid_p (const void *, size_t);
139132718Skan
14090075Sobrien/* The hashtable, so that the C front ends can pass it to cpplib.  */
14190075Sobrienextern struct ht *ident_hash;
14290075Sobrien
143117395Skan/* This function can be used by targets to set the flags originally
144117395Skan    implied by -ffast-math and -fno-fast-math.  */
14590075Sobrien
146132718Skanextern void set_fast_math_flags         (int);
14790075Sobrien
148132718Skan/* Handle -d switch.  */
149132718Skanextern void decode_d_option		(const char *);
150132718Skan
151117395Skan/* Return true iff flags are set as if -ffast-math.  */
152132718Skanextern bool fast_math_flags_set_p	(void);
153117395Skan
154169689Skan/* Return log2, or -1 if not exact.  */
155169689Skanextern int exact_log2                  (unsigned HOST_WIDE_INT);
15690075Sobrien
157169689Skan/* Return floor of log2, with -1 for zero.  */
158169689Skanextern int floor_log2                  (unsigned HOST_WIDE_INT);
15990075Sobrien
160169689Skan/* Inline versions of the above for speed.  */
161169689Skan#if GCC_VERSION >= 3004
162169689Skan# if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
163169689Skan#  define CLZ_HWI __builtin_clzl
164169689Skan#  define CTZ_HWI __builtin_ctzl
165169689Skan# elif HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
166169689Skan#  define CLZ_HWI __builtin_clzll
167169689Skan#  define CTZ_HWI __builtin_ctzll
168169689Skan# else
169169689Skan#  define CLZ_HWI __builtin_clz
170169689Skan#  define CTZ_HWI __builtin_ctz
171169689Skan# endif
172169689Skan
173169689Skanextern inline int
174169689Skanfloor_log2 (unsigned HOST_WIDE_INT x)
175169689Skan{
176169689Skan  return x ? HOST_BITS_PER_WIDE_INT - 1 - (int) CLZ_HWI (x) : -1;
177169689Skan}
178169689Skan
179169689Skanextern inline int
180169689Skanexact_log2 (unsigned HOST_WIDE_INT x)
181169689Skan{
182169689Skan  return x == (x & -x) && x ? (int) CTZ_HWI (x) : -1;
183169689Skan}
184169689Skan#endif /* GCC_VERSION >= 3004 */
185169689Skan
186132718Skan/* Functions used to get and set GCC's notion of in what directory
187132718Skan   compilation was started.  */
188132718Skan
189132718Skanextern const char *get_src_pwd	       (void);
190132718Skanextern bool set_src_pwd		       (const char *);
191132718Skan
19290075Sobrien#endif /* ! GCC_TOPLEV_H */
193