Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 /* ==================================================================== 00037 * ==================================================================== 00038 * 00039 * 00040 * Revision history: 00041 * 08-Sep-89 - Original Version 00042 * 01-Feb-91 - Copied for TP/Muse 00043 * 23-May-93 - Added group support 00044 * 29-Jan-94 - Removed last non-generic info to config.h 00045 * 00046 * Description: 00047 * 00048 * External interface to the command line processing utilities for the 00049 * Ragnarok compiler. 00050 * 00051 * NOTE: This interface should only be visible to modules involved in 00052 * configuration and other initialization. More widely-visible 00053 * configuration options belong in config.h and related files. See 00054 * config.h for a more complete discussion. 00055 * 00056 * 00057 * Exported types: 00058 * 00059 * OPTION_GROUP 00060 * Describes a command-line "option group", a set of related 00061 * options with their own specification namespace. Fields 00062 * are accessed by: 00063 * char *OGROUP_name(grp) Name (e.g., "OPT") of the group. 00064 * These need to be chosen carefully 00065 * so they don't conflict with other 00066 * command-line option names (e.g., 00067 * can't start with L or I without 00068 * restricting directory names that 00069 * can be specified with -L/-I). 00070 * By convention, hierarchical group 00071 * names consist of uppercase names 00072 * separated by underscores. (e.g., 00073 * CG_SWP provides SoftWare Pipelining 00074 * options for Code Generation.) 00075 * OGROUP_DESC *OGROUP_options(grp) 00076 * Array of option descriptors (see 00077 * below), terminated by one with kind 00078 * OVK_COUNT, describing the options 00079 * provided in the group. These exist 00080 * within their own namespace, so names 00081 * do not have to be chosen as carefully 00082 * as the option group name. 00083 * char OGROUP_separator(grp) Character used to separate options 00084 * within the group (usually ':'). 00085 * char OGROUP_valmarker(grp) Character used to separate option 00086 * names from values within the group 00087 * (usually '='). 00088 * char *OGROUP_description(grp) 00089 * One-line description of group. 00090 * 00091 * OPTION_DESC 00092 * Describes an option with an option group. Fields are accessed 00093 * by: 00094 * OPTION_KIND ODESC_kind(od) Kind of option, as given below. 00095 * OPTION_VISIBILITY ODESC_visibility(od) 00096 * Visibility of option, below. 00097 * char *ODESC_name(od) Full verbose name of option. 00098 * char *ODESC_abbrev(od) Shortest acceptable prefix allowed 00099 * for abbreviating option. MUST be 00100 * a prefix of the full name. If prefix 00101 * of more than one opt name in group, 00102 * ambiguity is resolved in favor of 00103 * first appearance in option array. 00104 * NULL means full option name must be 00105 * used. Empty string ("") means any 00106 * non-ambiguous prefix allowed as an 00107 * abbreviation. Abbreviations that 00108 * are not prefixes of the full option 00109 * name should be implemented with their 00110 * own OPTION_DESC (sharing the same 00111 * variable). 00112 * INT64 ODESC_def_val(od) Default value for numeric options. 00113 * INT64 ODESC_min_val(od) Minimum value for numeric options. 00114 * INT64 ODESC_max_val(od) Maximum value for numeric options. 00115 * void *variable Pointer to variable to be set if 00116 * option is given. 00117 * BOOL *specified Pointer to Boolean value to set if 00118 * option is given, or NULL if no such 00119 * notification is necessary. This is 00120 * useful for seeing if options were 00121 * explicitly set on the command line. 00122 * char *ODESC_description(od) 00123 * One-line description of option. 00124 * The "variable" and "specified" are not accessible after the 00125 * initialization of the data structures. 00126 * 00127 * OPTION_KIND 00128 * Enumerated type specifying the various types of options within 00129 * an option group. Valid values are: 00130 * OVK_NONE Option takes no value; its appearance 00131 * will simply set the variable to TRUE 00132 * OVK_BOOL Option takes Boolean value, defaulting 00133 * to TRUE if no value given. Valid values 00134 * are (case-insignificant) "NO", "YES", 00135 * "TRUE", "FALSE", "ON", "OFF", and "0". 00136 * OVK_INT32 Option takes INT32 value, defaulting 00137 * to the specified default if no value 00138 * given or if out of range. 00139 * OVK_INT64 Option takes INT64 value, defaulting 00140 * to the specified default if no value 00141 * given or if out of range. 00142 * OVK_UINT32 Option takes UINT32 value, defaulting 00143 * to the specified default if no value 00144 * given or if out of range. 00145 * OVK_UINT64 Option takes UINT64 value, defaulting 00146 * to the specified default if no value 00147 * given or if out of range. 00148 * OVK_NAME Option takes string value, defaulting to 00149 * the empty string ("") if no value given. 00150 * OVK_SELF Option takes string value, defaulting to 00151 * the option name if no value given. This 00152 * may be useful when you want several 00153 * options to set the same variable. 00154 * OVK_LIST Option takes list value, where the list 00155 * contains the option names and values. 00156 * OVK_OBSOLETE Option is obsolete. 00157 * OVK_UNIMPLEMENTED Option is unimplemented. 00158 * OVK_REPLACED Option is obsolete, replaced by another, 00159 * named by its ODESC_variable field. 00160 * OVK_COUNT Dummy value used to mark end of option 00161 * descriptor array. 00162 * TODO: 64-bit option values not yet implemented. 00163 * 00164 * OPTION_VISIBILITY 00165 * Enumerated type specifying the visibility (to users) of 00166 * options within an option group. Valid values are: 00167 * OVK_VISIBLE Users will see option on full listing. 00168 * Such options should have a valid 00169 * ODESC_description field, and should 00170 * appear in documentation. 00171 * OVK_SHY Users will see option on listing only 00172 * if they've set it or it's been 00173 * implicitly set by one of their options 00174 * (e.g. Ofast). 00175 * OVK_INTERNAL This option does not appear on user 00176 * listings. 00177 * 00178 * 00179 * Exported functions: 00180 * 00181 * void Initialize_Option_Groups ( OPTION_GROUP *og ) 00182 * Initialize auxiliary internal information for the given 00183 * array of option groups. Will be called automatically by 00184 * the a call to Process_Command_Line_Group, but if some 00185 * options have their initial static defaults modified by 00186 * other means before that, calling this explicitly earlier 00187 * will properly identify those as modified on listings. 00188 * 00189 * void Set_Option_Internal ( OPTION_GROUP *ogroup, char *name ); 00190 * Set the given option in the given group internal, meaning 00191 * that it won't appear on user listings. If the option name 00192 * is NULL, the entire group is set internal. This must be 00193 * called after initialization. 00194 * 00195 * BOOL Process_Command_Line_Group ( char *flag, OPTION_GROUP *og ) 00196 * Attempt to interpret <flag> as a command-line option group. 00197 * <flag> should point just past the initial "-". If <flag> 00198 * does not name an option group (as defined in og or Option_Groups, 00199 * see below), FALSE is returned. Otherwise processes the group, 00200 * setting the appropriate switches as specified in the group 00201 * desciption, possibly signalling errors or warnings for options 00202 * incorrectly specified. Returns TRUE whenever <flags> named 00203 * a valid group. 00204 * 00205 * void Print_Option_Group ( FILE *tf, OPTION_GROUP *og, char *pfx, 00206 * BOOL internal, BOOL full, BOOL update) 00207 * Print the current settings of the 'og' flags to 'tf'. 00208 * Start lines with pfx (for comments in assembly source file 00209 * output, for example). Identify internal use (tracing) vs. 00210 * customer output (listing files). For internal use, 'full' 00211 * causes all options to be printed, not just set/modified 00212 * ones. If 'update' is TRUE, internal set/modified flags are 00213 * cleared and those options won't be printed next time 00214 * (unless set again). 00215 * 00216 * void Trace_Option_Group ( FILE *tf, OPTION_GROUP *og, BOOL full) 00217 * Trace the current settings of the 'og' flags to 'tf'. 00218 * 00219 * Print_Option_Groups / Trace_Option_Groups 00220 * Same as the singular forms above, but print array of groups. 00221 * 00222 * OPTION_GROUP *Get_Command_Line_Group ( OPTION_GROUP *og, char *name ) 00223 * Given an option group array and a group name, return a 00224 * pointer to the array element which has the name (or NULL). 00225 * 00226 * INT32 Get_Numeric_Flag ( 00227 * char **cp, 00228 * UINT32 min, 00229 * UINT32 max, 00230 * UINT32 def, 00231 * char *flag) 00232 * Process a numeric flag from the command line. <flag> is a 00233 * pointer to the whole flag as given on the command line. 00234 * <cp> points to a pointer to a position within <flag> at 00235 * which the numeric value is expected. On exit, 00236 * point past the numeric value (if any). <min> and <max> 00237 * give the bounds for the expected value, while <def> gives 00238 * the default value. If either no numeric value is given, 00239 * or the value is outside the required range, the default is 00240 * returned (and a warning issued if outside the range); 00241 * otherwise the number specified by the flag is returned. 00242 * 00243 * 00244 * Exported variables: 00245 * 00246 * OPTION_GROUP Common_Option_Groups[] 00247 * List of option group descriptors common to all phases, terminated 00248 * by a NULL entry. Each phase can have its own list of other groups. 00249 * Statically initialized in config.c. Option groups are modified 00250 * by changing this initial value. After initialization, should 00251 * only be accessed by Process_Command_Line_Group. 00252 * 00253 * char Cmdname[] 00254 * The compiler invocation command. 00255 * 00256 * 00257 * SEE ALSO: 00258 * 00259 * com/config.h General configuration options. 00260 * com/controls.h Flag/pragma-based compiler control options. 00261 * 00262 * ==================================================================== 00263 * ==================================================================== 00264 */ 00265 00266 #ifndef flags_INCLUDED 00267 #define flags_INCLUDED 00268 00269 #ifdef _KEEP_RCS_ID 00270 #endif /* _KEEP_RCS_ID */ 00271 00272 #ifdef __cplusplus 00273 extern "C" { 00274 #endif 00275 00276 extern char Cmdname[]; 00277 00278 /* Interpret a numeric string such as '356' or '256': */ 00279 extern INT64 Get_Numeric_Flag ( 00280 char **cp, /* String to decode and advance */ 00281 INT64 min, /* Minimum valid value */ 00282 INT64 max, /* Maximum valid value */ 00283 INT64 def, /* Default value if none present */ 00284 char *flag /* Option string (for error messages) */ 00285 ); 00286 00287 /* Interpret a string such as '356K' or '256g' as a numeric value: */ 00288 extern BOOL Atoi_KMG ( /* Returns whether string was valid */ 00289 const char* s, /* String to interpret */ 00290 INT64* val, /* Result of interpretation */ 00291 BOOL suffix_required /* Is a suffix required? (Must be [kKmMgG]) */ 00292 ); 00293 00294 00295 /* Define the option kinds: */ 00296 typedef enum { 00297 OVK_INVALID, 00298 OVK_NONE, /* Option never takes a value */ 00299 OVK_BOOL, /* boolean value */ 00300 OVK_INT32, /* 32-bit integer value */ 00301 OVK_INT64, /* 64-bit integer value */ 00302 OVK_UINT32, /* 32-bit unsigned integer value */ 00303 OVK_UINT64, /* 64-bit unsigned integer value */ 00304 OVK_NAME, /* string value, defaulting to "" */ 00305 OVK_SELF, /* string value, defaulting to option name */ 00306 OVK_LIST, /* list of option name/value pairs */ 00307 OVK_OBSOLETE, /* Option is obsolete */ 00308 OVK_OLD_COUNT,/* Used to be COUNT. Here to avoid a revision mismatch. 00309 * Remove the reference in flags.c at some future time, 00310 * later remove this with another if needed. 00311 */ 00312 OVK_REPLACED, /* Option is obsolete, replaced by another */ 00313 OVK_UNIMPLEMENTED, /* Option is unimplemented */ 00314 00315 OVK_COUNT=63 /* end of list marker */ 00316 } OPTION_KIND; 00317 00318 /* Define the option visibility: */ 00319 typedef enum { 00320 OV_VISIBLE, /* Option freely visible to users */ 00321 OV_SHY, /* Option listed only if user explicitly sets it */ 00322 OV_INTERNAL /* Internal option never listed for users */ 00323 } OPTION_VISIBILITY; 00324 00325 /* Define the list returned for OVK_LIST: */ 00326 typedef struct option_list { 00327 struct option_list *next; 00328 char *opt; 00329 char *val; 00330 } OPTION_LIST; 00331 00332 #define OLIST_next(o) ((o)->next) 00333 #define OLIST_opt(o) ((o)->opt) 00334 #define OLIST_val(o) ((o)->val) 00335 00336 /* Define an option descriptor: */ 00337 typedef struct option_desc { 00338 mINT8 kind; 00339 mINT8 visibility; 00340 BOOL can_change_by_pragma; /* options pragma */ 00341 char * name; 00342 char * abbrev; 00343 INT64 def_val; 00344 INT64 min_val; 00345 INT64 max_val; 00346 void * variable; 00347 void * aux; 00348 char * description; 00349 } OPTION_DESC; 00350 00351 #define ODESC_kind(o) ((o)->kind) 00352 #define ODESC_visibility(o) ((o)->visibility) 00353 #define ODESC_can_change_by_pragma(o) ((o)->can_change_by_pragma) 00354 #define ODESC_name(o) ((o)->name) 00355 #define ODESC_abbrev(o) ((o)->abbrev) 00356 #define ODESC_def_val(o) ((o)->def_val) 00357 #define ODESC_min_val(o) ((o)->min_val) 00358 #define ODESC_max_val(o) ((o)->max_val) 00359 #define ODESC_variable(o) ((o)->variable) 00360 #define ODESC_description(o) ((o)->description) 00361 00362 /* Define an option group descriptor: */ 00363 typedef struct option_group { 00364 char * name; /* Group name */ 00365 char separator; /* Separator between sub-options */ 00366 char valmarker; /* ... between option name and value */ 00367 OPTION_DESC * options; /* Array of option descriptors */ 00368 void * aux; /* Auxiliary info for internal use */ 00369 char * description; /* Short description of group */ 00370 } OPTION_GROUP; 00371 00372 #define OGROUP_name(o) ((o)->name) 00373 #define OGROUP_options(o) ((o)->options) 00374 #define OGROUP_separator(o) ((o)->separator) 00375 #define OGROUP_valmarker(o) ((o)->valmarker) 00376 #define OGROUP_description(o) ((o)->description) 00377 00378 /* The option groups common to all compiler components: */ 00379 extern OPTION_GROUP Common_Option_Groups[]; 00380 00381 /* Initialize auxiliary info for an array of OPTION_GROUPs: */ 00382 extern void Initialize_Option_Groups ( OPTION_GROUP *ogroups ); 00383 00384 /* Set the given option in the given group internal, meaning that it 00385 * won't appear on user listings. If the option name is NULL, the 00386 * entire group is set internal. 00387 */ 00388 extern void Set_Option_Internal ( OPTION_GROUP *ogroup, char *name ); 00389 00390 /* Process the given option group: */ 00391 extern BOOL Process_Command_Line_Group ( 00392 char *flag, 00393 OPTION_GROUP *opt_groups ); 00394 00395 /* Print/trace the settings for the given option group: */ 00396 extern void Print_Option_Group ( 00397 FILE *tf, /* Listing/trace file */ 00398 OPTION_GROUP *opt_group, /* Which group? */ 00399 char *prefix, /* Prefix for output lines (comment) */ 00400 BOOL internal, /* Internal trace or user listing? */ 00401 BOOL full, /* All options or only set options? */ 00402 BOOL update ); /* Update set/mod flags after list? */ 00403 extern void Trace_Option_Group ( 00404 FILE *tf, /* Trace file */ 00405 OPTION_GROUP *opt_group, /* Which group? */ 00406 BOOL full ); /* All options or only set options? */ 00407 00408 /* Same as the above, but print an array of groups: */ 00409 extern void Print_Option_Groups ( 00410 FILE *tf, /* Listing/trace file */ 00411 OPTION_GROUP *opt_group, /* Group array */ 00412 char *prefix, /* Prefix for output lines (comment) */ 00413 BOOL internal, /* Internal trace or user listing? */ 00414 BOOL full, /* All options or only set options? */ 00415 BOOL update ); /* Update set/mod flags after list? */ 00416 extern void Trace_Option_Groups ( 00417 FILE *tf, /* Trace file */ 00418 OPTION_GROUP *opt_group, /* Group array */ 00419 BOOL full ); /* All options or only set options? */ 00420 00421 /* Get a group from an array, given its name: */ 00422 extern OPTION_GROUP *Get_Command_Line_Group ( 00423 OPTION_GROUP *og, 00424 char *name ); 00425 00426 extern void Trace_Command_Line_Group(FILE *, OPTION_GROUP *); 00427 00428 extern void Save_or_restore_options(char *, INT32, BOOL); 00429 00430 #ifdef __cplusplus 00431 } 00432 #endif 00433 #endif /* flags_INCLUDED */