GCC Middle and Back End API Reference
opts.h File Reference

Go to the source code of this file.

Data Structures

struct  cl_option
struct  cl_option_state
struct  cl_enum_arg
struct  cl_enum
struct  cl_decoded_option
struct  cl_deferred_option
struct  cl_option_handler_func
struct  cl_option_handlers

Enumerations

enum  cl_var_type {
  CLVC_BOOLEAN, CLVC_EQUAL, CLVC_BIT_CLEAR, CLVC_BIT_SET,
  CLVC_STRING, CLVC_ENUM, CLVC_DEFER
}

Functions

char * opts_concat (const char *first,...)
size_t find_opt (const char *input, unsigned int lang_mask)
int integral_argument (const char *arg)
bool enum_value_to_arg (const struct cl_enum_arg *enum_args, const char **argp, int value, unsigned int lang_mask)
void decode_cmdline_options_to_array (unsigned int argc, const char **argv, unsigned int lang_mask, struct cl_decoded_option **decoded_options, unsigned int *decoded_options_count)
void init_options_once (void)
void init_options_struct (struct gcc_options *opts, struct gcc_options *opts_set)
void decode_cmdline_options_to_array_default_mask (unsigned int argc, const char **argv, struct cl_decoded_option **decoded_options, unsigned int *decoded_options_count)
void set_default_handlers (struct cl_option_handlers *handlers)
void decode_options (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_decoded_option *decoded_options, unsigned int decoded_options_count, location_t loc, diagnostic_context *dc)
int option_enabled (int opt_idx, void *opts)
bool get_option_state (struct gcc_options *, int, struct cl_option_state *)
void set_option (struct gcc_options *opts, struct gcc_options *opts_set, int opt_index, int value, const char *arg, int kind, location_t loc, diagnostic_context *dc)
void * option_flag_var (int opt_index, struct gcc_options *opts)
bool handle_generated_option (struct gcc_options *opts, struct gcc_options *opts_set, size_t opt_index, const char *arg, int value, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, diagnostic_context *dc)
void generate_option (size_t opt_index, const char *arg, int value, unsigned int lang_mask, struct cl_decoded_option *decoded)
void generate_option_input_file (const char *file, struct cl_decoded_option *decoded)
void read_cmdline_option (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_decoded_option *decoded, location_t loc, unsigned int lang_mask, const struct cl_option_handlers *handlers, diagnostic_context *dc)
void control_warning_option (unsigned int opt_index, int kind, bool imply, location_t loc, unsigned int lang_mask, const struct cl_option_handlers *handlers, struct gcc_options *opts, struct gcc_options *opts_set, diagnostic_context *dc)
void print_ignored_options (void)
void handle_common_deferred_options (void)
bool common_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, const struct cl_decoded_option *decoded, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, diagnostic_context *dc)
bool target_handle_option (struct gcc_options *opts, struct gcc_options *opts_set, const struct cl_decoded_option *decoded, unsigned int lang_mask, int kind, location_t loc, const struct cl_option_handlers *handlers, diagnostic_context *dc)
void finish_options (struct gcc_options *opts, struct gcc_options *opts_set, location_t loc)
void default_options_optimization (struct gcc_options *opts, struct gcc_options *opts_set, struct cl_decoded_option *decoded_options, unsigned int decoded_options_count, location_t loc, unsigned int lang_mask, const struct cl_option_handlers *handlers, diagnostic_context *dc)
void set_struct_debug_option (struct gcc_options *opts, location_t loc, const char *value)
bool opt_enum_arg_to_value (size_t opt_index, const char *arg, int *value, unsigned int lang_mask)

Variables

struct cl_option cl_options []
const unsigned int cl_options_count
const char *const lang_names []
const unsigned int cl_lang_count
struct cl_enum cl_enums []
const unsigned int cl_enums_count
const char ** in_fnames
unsigned num_in_fnames
struct obstack opts_obstack

Enumeration Type Documentation

   Specifies how a switch's VAR_VALUE relates to its FLAG_VAR.  
Enumerator:
CLVC_BOOLEAN 
     The switch is enabled when FLAG_VAR is nonzero.  
CLVC_EQUAL 
     The switch is enabled when FLAG_VAR == VAR_VALUE.  
CLVC_BIT_CLEAR 
     The switch is enabled when VAR_VALUE is not set in FLAG_VAR.  
CLVC_BIT_SET 
     The switch is enabled when VAR_VALUE is set in FLAG_VAR.  
CLVC_STRING 
     The switch takes a string argument and FLAG_VAR points to that
     argument.  
CLVC_ENUM 
     The switch takes an enumerated argument (VAR_ENUM says what
     enumeration) and FLAG_VAR points to that argument.  
CLVC_DEFER 
     The switch should be stored in the VEC pointed to by FLAG_VAR for
     later processing.  

Function Documentation

bool common_handle_option ( struct gcc_options *  opts,
struct gcc_options *  opts_set,
const struct cl_decoded_option decoded,
unsigned int  lang_mask,
int  kind,
location_t  loc,
const struct cl_option_handlers handlers,
diagnostic_context dc 
)
   Handle target- and language-independent options.  Return zero to
   generate an "unknown option" message.  Only options that need
   extra handling need to be listed here; if you simply want
   DECODED->value assigned to a variable, it happens automatically.  
           First display any single language specific options.  
           Next display any multi language specific options.  
           Then display any remaining, non-language options.  
           Note - by default we include undocumented options when listing
           specific classes.  If you only want to see documented options
           then add ",^undocumented" to the --help= option.  E.g.:

           --help=target,^undocumented  
           Walk along the argument string, parsing each word in turn.
           The format is:
           arg = [^]{word}[,{arg}]
           word = {optimizers|target|warnings|undocumented|
                   params|common|<language>}  
               Check to see if the string matches an option class name.  
               Check to see if the string matches a language name.
               Note - we rely upon the alpha-sorted nature of the entries in
               the lang_names array, specifically that shorter names appear
               before their longer variants.  (i.e. C before C++).  That way
               when we are attempting to match --help=c for example we will
               match with C first and not C++.  
                       The option's argument matches both the start of a
                       language name and the start of an option class name.
                       We have a special case for when the user has
                       specified "--help=c", but otherwise we have to issue
                       a warning.  
               Check to see if the string matches an option class name.  
                     Handle both -fsanitize and -fno-sanitize cases.  
         Currently handled in a prescan.  
         Deferred.  
         Deferred.  
         Deferred.  
         Deferred.  
         Deferred.  
         Deferred.  
         Deferred.  
         No break here - do -fprofile-use processing. 
         Indirect call profiling should do all useful transformations
         speculative devirutalization does.  
         No break here - do -fprofile-generate processing. 
         FIXME: Instrumentation we insert makes ipa-reference bitmaps
         quadratic.  Disable the pass until better memory representation
         is done.  
         The real switch is -fno-random-seed.  
         Deferred.  
         Deferred.  
         Handled with Var in common.opt.  
           This is the old stack checking method.  
           This is the new stack checking method.  
         The real switch is -fno-stack-limit.  
         Deferred.  
         Deferred.  
         -ftree-vectorizer-verbose is deprecated. It is defined in
         -terms of fopt-info=N. 
         Deferred.  
         FALLTHRU 
         No-op. Used by the driver and passed to us because it starts with f.
         If the flag was handled in a standard way, assume the lack of
         processing here is intentional.  

References lang_names, len, pflags, strlen(), and warning_at().

void control_warning_option ( unsigned int  opt_index,
int  kind,
bool  imply,
location_t  loc,
unsigned int  lang_mask,
const struct cl_option_handlers handlers,
struct gcc_options *  opts,
struct gcc_options *  opts_set,
diagnostic_context dc 
)
   Set a warning option OPT_INDEX (language mask LANG_MASK, option
   handlers HANDLERS) to have diagnostic kind KIND for option
   structures OPTS and OPTS_SET and diagnostic context DC (possibly
   NULL), at location LOC (UNKNOWN_LOCATION for -Werror=).  If IMPLY,
   the warning option in question is implied at this point.  This is
   used by -Werror= and #pragma GCC diagnostic.  
         -Werror=foo implies -Wfoo.  
void decode_cmdline_options_to_array ( unsigned int  argc,
const char **  argv,
unsigned int  lang_mask,
struct cl_decoded_option **  decoded_options,
unsigned int *  decoded_options_count 
)
   Decode command-line options (ARGC and ARGV being the arguments of
   main) into an array, setting *DECODED_OPTIONS to a pointer to that
   array and *DECODED_OPTIONS_COUNT to the number of entries in the
   array.  The first entry in the array is always one for the program
   name (OPT_SPECIAL_program_name).  LANG_MASK indicates the language
   flags applicable for decoding (including CL_COMMON and CL_TARGET if
   those options should be considered applicable).  Do not produce any
   diagnostics or set state outside of these variables.  
         Interpret "-" or a non-switch as a file name.  

References cancel_option(), and cl_options.

Referenced by init_options_once().

void decode_cmdline_options_to_array_default_mask ( unsigned int  argc,
const char **  argv,
struct cl_decoded_option **  decoded_options,
unsigned int *  decoded_options_count 
)
   Decode command-line options to an array, like
   decode_cmdline_options_to_array and with the same arguments but
   using the default lang_mask.  
void decode_options ( struct gcc_options *  opts,
struct gcc_options *  opts_set,
struct cl_decoded_option decoded_options,
unsigned int  decoded_options_count,
location_t  loc,
diagnostic_context dc 
)
   Parse command line options and set default flag values.  Do minimal
   options processing.  The decoded options are in *DECODED_OPTIONS
   and *DECODED_OPTIONS_COUNT; settings go in OPTS, OPTS_SET and DC;
   the options are located at LOC.  
void default_options_optimization ( struct gcc_options *  opts,
struct gcc_options *  opts_set,
struct cl_decoded_option decoded_options,
unsigned int  decoded_options_count,
location_t  loc,
unsigned int  lang_mask,
const struct cl_option_handlers handlers,
diagnostic_context dc 
)
   Default the options in OPTS and OPTS_SET based on the optimization
   settings in DECODED_OPTIONS and DECODED_OPTIONS_COUNT.  
     Scan to see what optimization level has been specified.  That will
     determine the default value of many flags.  
             Optimizing for size forces optimize to be 2.  
             -Ofast only adds flags to -O3.  
             -Og selects optimization level 1.  
             Ignore other options in this prescan.  
     -O2 param settings.  
     Track fields in field-sensitive alias analysis.  
     For -O1 only do loop invariant motion for very small loops.  
       We want to crossjump as much as possible.  
     Allow default optimizations to be specified on a per-machine basis.  

Referenced by set_default_handlers().

bool enum_value_to_arg ( const struct cl_enum_arg enum_args,
const char **  argp,
int  value,
unsigned int  lang_mask 
)
   Look of VALUE in ENUM_ARGS for language LANG_MASK and store the
   corresponding string in *ARGP, returning true if the found string
   was marked as canonical, false otherwise.  If VALUE is not found
   (which may be the case for uninitialized values if the relevant
   option has not been passed), set *ARGP to NULL and return
   false.  
size_t find_opt ( const char *  input,
unsigned int  lang_mask 
)
void finish_options ( struct gcc_options *  opts,
struct gcc_options *  opts_set,
location_t  loc 
)
   After all options at LOC have been read into OPTS and OPTS_SET,
   finalize settings of those options and diagnose incompatible
   combinations.  
         First try to make OPTS->X_DUMP_BASE_NAME relative to the
         OPTS->X_DUMP_DIR_NAME directory.  Then try to make
         OPTS->X_DUMP_BASE_NAME relative to the OPTS->X_AUX_BASE_NAME
         directory, typically the directory to contain the object
         file.  
                 Copy directory component from OPTS->X_AUX_BASE_NAME.  
                 Append existing OPTS->X_DUMP_BASE_NAME.  
     Handle related options for unit-at-a-time, toplevel-reorder, and
     section-anchors.  
     Unless the user has asked for section anchors, we disable toplevel
     reordering at -O0 to disable transformations that might be surprising
     to end users and to get -fno-toplevel-reorder tested.  
         Inlining does not work if not optimizing,
         so force it not to be done.  
     The optimization to partition hot and cold basic blocks into separate
     sections of the .o and executable files does not work (currently)
     with exception handling.  This is because there is no support for
     generating unwind info.  If opts->x_flag_exceptions is turned on
     we need to turn off the partitioning optimization.  
     If user requested unwind info, then turn off the partitioning
     optimization.  
     If the target requested unwind info, then turn off the partitioning
     optimization with a different message.  Likewise, if the target does not
     support named sections.  
     Pipelining of outer loops is only possible when general pipelining
     capabilities are requested.  
         When generating IL, do not operate in whole-program mode.
         Otherwise, symbols will be privatized too early, causing link
         errors later.  
     We initialize opts->x_flag_split_stack to -1 so that targets can set a
     default value if they choose based on other options.  
     Tune vectorization related parametees according to cost model.  
     Set PARAM_MAX_STORES_TO_SINK to 0 if either vectorization or if-conversion
     is disabled.  
     The -gsplit-dwarf option requires -gpubnames.  
void generate_option ( size_t  opt_index,
const char *  arg,
int  value,
unsigned int  lang_mask,
struct cl_decoded_option decoded 
)
   Fill in *DECODED with an option described by OPT_INDEX, ARG and
   VALUE for a front end using LANG_MASK.  This is used when the
   compiler generates options internally.  

References cl_decoded_option::arg, cl_options, error_at(), cl_decoded_option::errors, cl_option::missing_argument_error, cl_decoded_option::opt_index, option(), cl_decoded_option::orig_option_with_args_text, cl_option_handlers::unknown_option_callback, cl_decoded_option::warn_message, and warning_at().

void generate_option_input_file ( const char *  file,
struct cl_decoded_option decoded 
)
   Fill in *DECODED with an option for input file FILE.  
bool get_option_state ( struct gcc_options *  opts,
int  option,
struct cl_option_state state 
)
   Fill STATE with the current state of option OPTION in OPTS.  Return
   true if there is some state to store.  
void handle_common_deferred_options ( void  )
   Process common options that have been deferred until after the
   handlers have been called for all options.  
             Deferred.  
             The real switch is -fno-random-seed.  
             The real switch is -fno-stack-limit.  

References stack_limit_rtx.

bool handle_generated_option ( struct gcc_options *  opts,
struct gcc_options *  opts_set,
size_t  opt_index,
const char *  arg,
int  value,
unsigned int  lang_mask,
int  kind,
location_t  loc,
const struct cl_option_handlers handlers,
diagnostic_context dc 
)
   Like handle_option, but OPT_INDEX, ARG and VALUE describe the
   option instead of DECODED.  This is used for callbacks when one
   option implies another instead of an option being decoded from the
   command line.  
void init_options_once ( void  )
   Initialize global options-related settings at start-up.  
     Perform language-specific options initialization.  

References decode_cmdline_options_to_array().

void init_options_struct ( struct gcc_options *  opts,
struct gcc_options *  opts_set 
)
int integral_argument ( const char *  arg)
bool opt_enum_arg_to_value ( size_t  opt_index,
const char *  arg,
int *  value,
unsigned int  lang_mask 
)
   Look up ARG in the enum used by option OPT_INDEX for language
   LANG_MASK, returning true and storing the value in *VALUE if found,
   and returning false without modifying *VALUE if not found.  

References cl_enum_arg::arg, enum_arg_ok_for_language(), and cl_option::flags.

int option_enabled ( int  opt_idx,
void *  opts 
)
void* option_flag_var ( int  opt_index,
struct gcc_options *  opts 
)
char* opts_concat ( const char *  first,
  ... 
)
void print_ignored_options ( void  )
   Produce a warning for each option previously buffered.  
void read_cmdline_option ( struct gcc_options *  opts,
struct gcc_options *  opts_set,
struct cl_decoded_option decoded,
location_t  loc,
unsigned int  lang_mask,
const struct cl_option_handlers handlers,
diagnostic_context dc 
)
   Handle the switch DECODED (location LOC) for the language indicated
   by LANG_MASK, using the handlers in *HANDLERS and setting fields in
   OPTS and OPTS_SET and using diagnostic context DC (if not NULL) for
   diagnostic options.  
void set_default_handlers ( struct cl_option_handlers handlers)
void set_option ( struct gcc_options *  opts,
struct gcc_options *  opts_set,
int  opt_index,
int  value,
const char *  arg,
int  kind,
location_t  loc,
diagnostic_context dc 
)
   Set any field in OPTS, and OPTS_SET if not NULL, for option
   OPT_INDEX according to VALUE and ARG, diagnostic kind KIND,
   location LOC, using diagnostic context DC if not NULL for
   diagnostic classification.  

References cl_enums, cl_enum::set, and cl_option::var_enum.

void set_struct_debug_option ( struct gcc_options *  opts,
location_t  loc,
const char *  value 
)
     various labels for comparison 
     Default is to apply to as much as possible. 
     What usage? 
     Generics or not? 
     What allowable environment? 
     Effect the specification. 
         No more -femit-struct-debug-detailed specifications.
         Do final checks. 
bool target_handle_option ( struct gcc_options *  opts,
struct gcc_options *  opts_set,
const struct cl_decoded_option decoded,
unsigned int  lang_mask,
int  kind,
location_t  loc,
const struct cl_option_handlers handlers,
diagnostic_context dc 
)
   Handle a back-end option; arguments and return value as for
   handle_option.  

References vec_check_alloc().


Variable Documentation

struct cl_enum cl_enums[]
const unsigned int cl_enums_count
const unsigned int cl_lang_count

Referenced by complain_wrong_lang().

const unsigned int cl_options_count
const char** in_fnames
   Input file names.  
const char* const lang_names[]
unsigned num_in_fnames
   The count of input filenames.  
struct obstack opts_obstack
   Obstack for option strings.