Turn off profile-use optimizations when profile is not available
[official-gcc.git] / gcc-4_9 / gcc / opts.h
blob74e7622dba46053af8d28eecc0524e6753929154
1 /* Command line option handling.
2 Copyright (C) 2002-2014 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 for more details.
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
20 #ifndef GCC_OPTS_H
21 #define GCC_OPTS_H
23 #include "input.h"
24 #include "vec.h"
25 #include "obstack.h"
27 /* Specifies how a switch's VAR_VALUE relates to its FLAG_VAR. */
28 enum cl_var_type {
29 /* The switch is enabled when FLAG_VAR is nonzero. */
30 CLVC_BOOLEAN,
32 /* The switch is enabled when FLAG_VAR == VAR_VALUE. */
33 CLVC_EQUAL,
35 /* The switch is enabled when VAR_VALUE is not set in FLAG_VAR. */
36 CLVC_BIT_CLEAR,
38 /* The switch is enabled when VAR_VALUE is set in FLAG_VAR. */
39 CLVC_BIT_SET,
41 /* The switch takes a string argument and FLAG_VAR points to that
42 argument. */
43 CLVC_STRING,
45 /* The switch takes an enumerated argument (VAR_ENUM says what
46 enumeration) and FLAG_VAR points to that argument. */
47 CLVC_ENUM,
49 /* The switch should be stored in the VEC pointed to by FLAG_VAR for
50 later processing. */
51 CLVC_DEFER
54 struct cl_option
56 /* Text of the option, including initial '-'. */
57 const char *opt_text;
58 /* Help text for --help, or NULL. */
59 const char *help;
60 /* Error message for missing argument, or NULL. */
61 const char *missing_argument_error;
62 /* Warning to give when this option is used, or NULL. */
63 const char *warn_message;
64 /* Argument of alias target when positive option given, or NULL. */
65 const char *alias_arg;
66 /* Argument of alias target when negative option given, or NULL. */
67 const char *neg_alias_arg;
68 /* Alias target, or N_OPTS if not an alias. */
69 unsigned short alias_target;
70 /* Previous option that is an initial substring of this one, or
71 N_OPTS if none. */
72 unsigned short back_chain;
73 /* Option length, not including initial '-'. */
74 unsigned char opt_len;
75 /* Next option in a sequence marked with Negative, or -1 if none. */
76 int neg_index;
77 /* CL_* flags for this option. */
78 unsigned int flags;
79 /* Disabled in this configuration. */
80 BOOL_BITFIELD cl_disabled : 1;
81 /* Options marked with CL_SEPARATE take a number of separate
82 arguments (1 to 4) that is one more than the number in this
83 bit-field. */
84 unsigned int cl_separate_nargs : 2;
85 /* Option is an alias when used with separate argument. */
86 BOOL_BITFIELD cl_separate_alias : 1;
87 /* Alias to negative form of option. */
88 BOOL_BITFIELD cl_negative_alias : 1;
89 /* Option takes no argument in the driver. */
90 BOOL_BITFIELD cl_no_driver_arg : 1;
91 /* Reject this option in the driver. */
92 BOOL_BITFIELD cl_reject_driver : 1;
93 /* Reject no- form. */
94 BOOL_BITFIELD cl_reject_negative : 1;
95 /* Missing argument OK (joined). */
96 BOOL_BITFIELD cl_missing_ok : 1;
97 /* Argument is an integer >=0. */
98 BOOL_BITFIELD cl_uinteger : 1;
99 /* Argument is a HOST_WIDE_INT. */
100 BOOL_BITFIELD cl_host_wide_int : 1;
101 /* Argument should be converted to lowercase. */
102 BOOL_BITFIELD cl_tolower : 1;
103 /* Report argument with -fverbose-asm */
104 BOOL_BITFIELD cl_report : 1;
105 /* Offset of field for this option in struct gcc_options, or
106 (unsigned short) -1 if none. */
107 unsigned short flag_var_offset;
108 /* Index in cl_enums of enum used for this option's arguments, for
109 CLVC_ENUM options. */
110 unsigned short var_enum;
111 /* How this option's value is determined and sets a field. */
112 enum cl_var_type var_type;
113 /* Value or bit-mask with which to set a field. */
114 HOST_WIDE_INT var_value;
117 /* Records that the state of an option consists of SIZE bytes starting
118 at DATA. DATA might point to CH in some cases. */
119 struct cl_option_state {
120 const void *data;
121 size_t size;
122 char ch;
125 extern const struct cl_option cl_options[];
126 extern const unsigned int cl_options_count;
127 extern const char *const lang_names[];
128 extern const unsigned int cl_lang_count;
130 #define CL_PARAMS (1U << 16) /* Fake entry. Used to display --param info with --help. */
131 #define CL_WARNING (1U << 17) /* Enables an (optional) warning message. */
132 #define CL_OPTIMIZATION (1U << 18) /* Enables an (optional) optimization. */
133 #define CL_DRIVER (1U << 19) /* Driver option. */
134 #define CL_TARGET (1U << 20) /* Target-specific option. */
135 #define CL_COMMON (1U << 21) /* Language-independent. */
137 #define CL_MIN_OPTION_CLASS CL_PARAMS
138 #define CL_MAX_OPTION_CLASS CL_COMMON
140 /* From here on the bits describe attributes of the options.
141 Before this point the bits have described the class of the option.
142 This distinction is important because --help will not list options
143 which only have these higher bits set. */
145 #define CL_JOINED (1U << 22) /* If takes joined argument. */
146 #define CL_SEPARATE (1U << 23) /* If takes a separate argument. */
147 #define CL_UNDOCUMENTED (1U << 24) /* Do not output with --help. */
148 #define CL_NO_DWARF_RECORD (1U << 25) /* Do not add to producer string. */
149 #define CL_PCH_IGNORE (1U << 26) /* Do compare state for pch. */
151 /* Flags for an enumerated option argument. */
152 #define CL_ENUM_CANONICAL (1 << 0) /* Canonical for this value. */
153 #define CL_ENUM_DRIVER_ONLY (1 << 1) /* Only accepted in the driver. */
155 /* Structure describing an enumerated option argument. */
157 struct cl_enum_arg
159 /* The argument text, or NULL at the end of the array. */
160 const char *arg;
162 /* The corresponding integer value. */
163 int value;
165 /* Flags associated with this argument. */
166 unsigned int flags;
169 /* Structure describing an enumerated set of option arguments. */
171 struct cl_enum
173 /* Help text, or NULL if the values should not be listed in --help
174 output. */
175 const char *help;
177 /* Error message for unknown arguments, or NULL to use a generic
178 error. */
179 const char *unknown_error;
181 /* Array of possible values. */
182 const struct cl_enum_arg *values;
184 /* The size of the type used to store a value. */
185 size_t var_size;
187 /* Function to set a variable of this type. */
188 void (*set) (void *var, int value);
190 /* Function to get the value of a variable of this type. */
191 int (*get) (const void *var);
194 extern const struct cl_enum cl_enums[];
195 extern const unsigned int cl_enums_count;
197 /* Possible ways in which a command-line option may be erroneous.
198 These do not include not being known at all; an option index of
199 OPT_SPECIAL_unknown is used for that. */
201 #define CL_ERR_DISABLED (1 << 0) /* Disabled in this configuration. */
202 #define CL_ERR_MISSING_ARG (1 << 1) /* Argument required but missing. */
203 #define CL_ERR_WRONG_LANG (1 << 2) /* Option for wrong language. */
204 #define CL_ERR_UINT_ARG (1 << 3) /* Bad unsigned integer argument. */
205 #define CL_ERR_ENUM_ARG (1 << 4) /* Bad enumerated argument. */
206 #define CL_ERR_NEGATIVE (1 << 5) /* Negative form of option
207 not permitted (together
208 with OPT_SPECIAL_unknown). */
210 /* Structure describing the result of decoding an option. */
212 struct cl_decoded_option
214 /* The index of this option, or an OPT_SPECIAL_* value for
215 non-options and unknown options. */
216 size_t opt_index;
218 /* Any warning to give for use of this option, or NULL if none. */
219 const char *warn_message;
221 /* The string argument, or NULL if none. For OPT_SPECIAL_* cases,
222 the option or non-option command-line argument. */
223 const char *arg;
225 /* The original text of option plus arguments, with separate argv
226 elements concatenated into one string with spaces separating
227 them. This is for such uses as diagnostics and
228 -frecord-gcc-switches. */
229 const char *orig_option_with_args_text;
231 /* The canonical form of the option and its argument, for when it is
232 necessary to reconstruct argv elements (in particular, for
233 processing specs and passing options to subprocesses from the
234 driver). */
235 const char *canonical_option[4];
237 /* The number of elements in the canonical form of the option and
238 arguments; always at least 1. */
239 size_t canonical_option_num_elements;
241 /* For a boolean option, 1 for the true case and 0 for the "no-"
242 case. For an unsigned integer option, the value of the
243 argument. 1 in all other cases. */
244 int value;
246 /* Any flags describing errors detected in this option. */
247 int errors;
250 /* Structure describing an option deferred for handling after the main
251 option handlers. */
253 struct cl_deferred_option
255 /* Elements from struct cl_decoded_option used for deferred
256 options. */
257 size_t opt_index;
258 const char *arg;
259 int value;
262 /* Structure describing a single option-handling callback. */
264 struct cl_option_handler_func
266 /* The function called to handle the option. */
267 bool (*handler) (struct gcc_options *opts,
268 struct gcc_options *opts_set,
269 const struct cl_decoded_option *decoded,
270 unsigned int lang_mask, int kind, location_t loc,
271 const struct cl_option_handlers *handlers,
272 diagnostic_context *dc);
274 /* The mask that must have some bit in common with the flags for the
275 option for this particular handler to be used. */
276 unsigned int mask;
279 /* Structure describing the callbacks used in handling options. */
281 struct cl_option_handlers
283 /* Callback for an unknown option to determine whether to give an
284 error for it, and possibly store information to diagnose the
285 option at a later point. Return true if an error should be
286 given, false otherwise. */
287 bool (*unknown_option_callback) (const struct cl_decoded_option *decoded);
289 /* Callback to handle, and possibly diagnose, an option for another
290 language. */
291 void (*wrong_lang_callback) (const struct cl_decoded_option *decoded,
292 unsigned int lang_mask);
294 /* The number of individual handlers. */
295 size_t num_handlers;
297 /* The handlers themselves. */
298 struct cl_option_handler_func handlers[3];
301 /* Input file names. */
303 extern const char **in_fnames;
305 /* The count of input filenames. */
307 extern unsigned num_in_fnames;
309 /* GCC command-line arguments used during profile-gen, that are saved to the
310 profile data file. During profile-use, these can be compared to make sure
311 only those auxiliary modules are actually imported that use a compatible
312 set of GCC flags as the primary module. */
313 extern const char **lipo_cl_args;
315 /* The size of the above mentioned mentioned array. */
316 extern unsigned num_lipo_cl_args;
318 extern char *opts_concat (const char *first, ...);
320 /* Obstack for option strings. */
322 extern struct obstack opts_obstack;
324 size_t find_opt (const char *input, unsigned int lang_mask);
325 extern int integral_argument (const char *arg);
326 extern bool enum_value_to_arg (const struct cl_enum_arg *enum_args,
327 const char **argp, int value,
328 unsigned int lang_mask);
329 extern void decode_cmdline_options_to_array (unsigned int argc,
330 const char **argv,
331 unsigned int lang_mask,
332 struct cl_decoded_option **decoded_options,
333 unsigned int *decoded_options_count);
334 extern void init_options_once (void);
335 extern void init_options_struct (struct gcc_options *opts,
336 struct gcc_options *opts_set);
337 extern void decode_cmdline_options_to_array_default_mask (unsigned int argc,
338 const char **argv,
339 struct cl_decoded_option **decoded_options,
340 unsigned int *decoded_options_count);
341 extern void set_default_handlers (struct cl_option_handlers *handlers);
342 extern void decode_options (struct gcc_options *opts,
343 struct gcc_options *opts_set,
344 struct cl_decoded_option *decoded_options,
345 unsigned int decoded_options_count,
346 location_t loc,
347 diagnostic_context *dc);
348 extern int option_enabled (int opt_idx, void *opts);
349 extern bool get_option_state (struct gcc_options *, int,
350 struct cl_option_state *);
351 extern void set_option (struct gcc_options *opts,
352 struct gcc_options *opts_set,
353 int opt_index, int value, const char *arg, int kind,
354 location_t loc, diagnostic_context *dc);
355 extern void *option_flag_var (int opt_index, struct gcc_options *opts);
356 bool handle_generated_option (struct gcc_options *opts,
357 struct gcc_options *opts_set,
358 size_t opt_index, const char *arg, int value,
359 unsigned int lang_mask, int kind, location_t loc,
360 const struct cl_option_handlers *handlers,
361 diagnostic_context *dc);
362 void generate_option (size_t opt_index, const char *arg, int value,
363 unsigned int lang_mask,
364 struct cl_decoded_option *decoded);
365 void generate_option_input_file (const char *file,
366 struct cl_decoded_option *decoded);
367 extern void read_cmdline_option (struct gcc_options *opts,
368 struct gcc_options *opts_set,
369 struct cl_decoded_option *decoded,
370 location_t loc,
371 unsigned int lang_mask,
372 const struct cl_option_handlers *handlers,
373 diagnostic_context *dc);
374 extern void control_warning_option (unsigned int opt_index, int kind,
375 bool imply, location_t loc,
376 unsigned int lang_mask,
377 const struct cl_option_handlers *handlers,
378 struct gcc_options *opts,
379 struct gcc_options *opts_set,
380 diagnostic_context *dc);
381 extern void print_ignored_options (void);
382 extern void add_input_filename (const char *filename);
383 extern void add_module_info (unsigned mod_id, bool is_primary, int index);
384 extern void set_lipo_c_parsing_context (struct cpp_reader *parse_in, int i, bool verbose);
385 extern void coverage_note_define (const char *cpp_def, bool is_def);
386 extern void coverage_note_include (const char *filename);
387 extern void handle_common_deferred_options (void);
388 extern bool common_handle_option (struct gcc_options *opts,
389 struct gcc_options *opts_set,
390 const struct cl_decoded_option *decoded,
391 unsigned int lang_mask, int kind,
392 location_t loc,
393 const struct cl_option_handlers *handlers,
394 diagnostic_context *dc);
395 extern bool target_handle_option (struct gcc_options *opts,
396 struct gcc_options *opts_set,
397 const struct cl_decoded_option *decoded,
398 unsigned int lang_mask, int kind,
399 location_t loc,
400 const struct cl_option_handlers *handlers,
401 diagnostic_context *dc);
402 extern void finish_options (struct gcc_options *opts,
403 struct gcc_options *opts_set,
404 location_t loc);
405 extern void default_options_optimization (struct gcc_options *opts,
406 struct gcc_options *opts_set,
407 struct cl_decoded_option *decoded_options,
408 unsigned int decoded_options_count,
409 location_t loc,
410 unsigned int lang_mask,
411 const struct cl_option_handlers *handlers,
412 diagnostic_context *dc);
413 extern void set_struct_debug_option (struct gcc_options *opts,
414 location_t loc,
415 const char *value);
416 extern bool opt_enum_arg_to_value (size_t opt_index, const char *arg,
417 int *value, unsigned int lang_mask);
418 extern void write_compilation_info_to_asm (void);
419 extern void write_compilation_flags_to_asm (void);
420 extern void set_profile_use_options (struct gcc_options *,
421 struct gcc_options *, bool, bool);
422 #endif