Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
config.cxx
Go to the documentation of this file.
00001 
00002 /*
00003 
00004   Copyright (C) 2000, 2001 Silicon Graphics, Inc.  All Rights Reserved.
00005 
00006   This program is free software; you can redistribute it and/or modify it
00007   under the terms of version 2 of the GNU General Public License as
00008   published by the Free Software Foundation.
00009 
00010   This program is distributed in the hope that it would be useful, but
00011   WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00013 
00014   Further, this software is distributed without any warranty that it is
00015   free of the rightful claim of any third person regarding infringement 
00016   or the like.  Any license provided herein, whether implied or 
00017   otherwise, applies only to this software file.  Patent licenses, if 
00018   any, provided herein do not apply to combinations of this program with 
00019   other software, or any other product whatsoever.  
00020 
00021   You should have received a copy of the GNU General Public License along
00022   with this program; if not, write the Free Software Foundation, Inc., 59
00023   Temple Place - Suite 330, Boston MA 02111-1307, USA.
00024 
00025   Contact information:  Silicon Graphics, Inc., 1600 Amphitheatre Pky,
00026   Mountain View, CA 94043, or:
00027 
00028   http://www.sgi.com
00029 
00030   For further information regarding this notice, see:
00031 
00032   http://oss.sgi.com/projects/GenInfo/NoticeExplan
00033 
00034 */
00035 
00036 /* ====================================================================
00037  * ====================================================================
00038  *
00039  *
00040  * Revision history:
00041  *  06-Jun-90 - Original Version (moved from cdriver.c)
00042  *  01-Feb-91 - Copied for TP/Muse
00043  *  15-Jun-91 - Restructured and integrated Josie
00044  *  05-May-96 - Added -WOPT group.
00045  *
00046  * Description:
00047  *
00048  * Configuration data and routines to set up configuration.
00049  *
00050  * Refer to the discussion in config.h for the distribution of such
00051  * data and processing among the various configuration files.
00052  *
00053  * ====================================================================
00054  * ====================================================================
00055  */
00056 
00057 #ifdef _KEEP_RCS_ID
00058 /*REFERENCED*/
00059 #endif /* _KEEP_RCS_ID */
00060 
00061 
00062 #define USE_STANDARD_TYPES 1
00063 #include "defs.h"
00064 #undef USE_STANDARD_TYPES
00065 
00066 #ifdef FRONT_END        /* For setting fullwarn, woff in front end */
00067 # ifndef FRONT_F90
00068 #  ifdef EDGSRC
00069 #   include "basics.h"
00070 #   include "cmd_line.h"
00071 #   include "error.h"
00072 #  endif /* EDGSRC */
00073 # endif /* ~FRONT_F90 */
00074 #endif /*  FRONT_END */
00075 #include <ctype.h>      // For isdigit
00076 #include <elf.h>        // Open64 version 
00077 
00078 #include "x_string.h" // for strcasecmp()
00079 #include "em_elf.h"   
00080 #include "config.h"
00081 #include "config_platform.h"
00082 #include "config_targ.h"
00083 #include "erglob.h"
00084 #include "flags.h"
00085 #include "tracing.h"
00086 #include "glob.h"
00087 #include "symtab.h"
00088 #include "wn.h"
00089 
00090 #ifndef BACK_END
00091   static INT32 Ignore_Int;
00092 #endif
00093 
00094 /* The following contains the phase-specific option groups and their
00095  * associated variable definitions:
00096  */
00097 #include "config_targ2.cxx"
00098 #include "config_debug.cxx"
00099 #include "config_ipa.cxx"
00100 #include "config_list.cxx"
00101 #include "config_opt.cxx"
00102 #include "config_wopt.cxx"
00103 #include "config_vho.cxx"
00104 #include "config_flist.cxx"
00105 #include "config_clist.cxx"
00106 #include "config_purple.cxx"
00107 #include "config_promp.cxx"
00108 
00109 #ifdef BACK_END
00110 # include "config_lno.cxx"
00111 # include "instr_reader.h"
00112 #endif
00113 
00114 /* IR builder sometimes needs to know whether we're in front end: */
00115 #ifdef SINGLE_PROCESS
00116 INT16 In_Front_End = TRUE;      /* Start out there */
00117 #endif
00118 
00119 /* ====================================================================
00120  *
00121  * Global option flags
00122  *
00123  * ====================================================================
00124  */
00125 
00126 /***** General optimization control *****/
00127 BOOL Enable_LOH = FALSE;                /* Do loop overhead processing? */
00128 BOOL Enable_LOH_overridden = FALSE;     /* ... option seen? */
00129 BOOL CSE_Elim_Enabled = FALSE;          /* Is CSE-elim on? -- this does
00130                                          * not control it, it just
00131                                          * shadows the opt. level
00132                                          */
00133 
00134 #ifdef BACK_END
00135 # define DEF_DEBUG_LEVEL        0
00136 INT8 Debug_Level = DEF_DEBUG_LEVEL;     /* -gn: debug level */
00137 #endif
00138 
00139 
00140 /***** Alignment (misaligned memory reference) control *****/
00141 BOOL    UseAlignedCopyForStructs = FALSE;       /* control aggregrate copy */
00142 INT32   MinStructCopyLoopSize =    16;          /* 0 = always expand */
00143 INT32   MinStructCopyMemIntrSize=  0;           /* generate bcopy */
00144 INT32   Aggregate_Alignment = -1;               /* This alignment for aggregate layout */
00145 
00146 INT32 iolist_reuse_limit = 100;
00147 
00148 /***** Pointer optimizations, such as treating pointers as arrays *****/
00149 BOOL Ptr_Opt_Allowed = FALSE;
00150 
00151 /***** Put all-zero initialized file-level data in the BSS section? *****/
00152 BOOL Zeroinit_in_bss = TRUE;
00153 
00154 /* don't make strings gp-relative (to save gp space) */
00155 BOOL Strings_Not_Gprelative = FALSE;
00156 
00157 /***** IEEE 754 options *****/
00158 IEEE_LEVEL IEEE_Arithmetic = IEEE_ACCURATE; /* IEEE arithmetic? */
00159 BOOL IEEE_Arith_Set = FALSE;    /* ... option seen? */
00160 /* BOOL Force_IEEE_Comparisons = FALSE; */ /* IEEE NaN comparisons? */
00161                                            /* Moved to ISA/config_targ.cxx */
00162 
00163 /***** Speculation eagerness options *****/
00164 EAGER_LEVEL Eager_Level = EAGER_SAFE;   /* Eagerness to use: -Xn */
00165 static BOOL Eager_Level_Set = FALSE;    /* ... option seen? */
00166 
00167 /***** Constant folding and WHIRL simplifier options *****/
00168 ROUNDOFF Roundoff_Level = ROUNDOFF_NONE;/* -OPT_roundoff=n value */
00169 BOOL Roundoff_Set = FALSE;              /* ... option seen? */
00170 BOOL Fast_Complex_Allowed = FALSE;      /* Fast c_div and c_abs? */
00171 BOOL Fast_Complex_Set = FALSE;          /* ... option seen? */
00172 BOOL Fast_Bit_Allowed = FALSE;          /* Fast inlined bit intrinsics? */
00173 BOOL Fast_Bit_Set = FALSE;              /* ... option seen? */
00174 BOOL Fast_NINT_Allowed = FALSE;         /* Fast NINT and ANINT? */
00175 BOOL Fast_NINT_Set = FALSE;             /* ... option seen? */
00176 BOOL Fast_trunc_Allowed = FALSE;        /* Fast truncs for NINT/ANINT/AINT/AMOD? */
00177 BOOL Fast_trunc_Set = FALSE;            /* ... option seen? */
00178 BOOL Inline_Intrinsics_Allowed = TRUE;  /* Inline intrinsics? Or lib calls? */
00179 BOOL Inline_Intrinsics_Set = FALSE;     /* ... option seen? */
00180 BOOL Regions_Around_Inner_Loops = FALSE;/* Put REGIONs around inner loops? */
00181 BOOL Region_Boundary_Info = FALSE;      /* calc boundary info for regions */
00182 BOOL Simp_Multiply_To_Shift=FALSE;      /* Convert multiplies to shifts */
00183 BOOL Enable_NaryExpr= FALSE;            /* allow nary expression in the lowerer */
00184 BOOL Enable_NaryExpr_Set = FALSE;       /* ... option seen? */
00185 
00186 /***** LANGuage group options *****/
00187 static char *Language_Name = NULL;      /* Source language name */
00188 LANGUAGE Language = LANG_UNKNOWN;       /* See language.h */
00189 BOOL CXX_Bool_On = TRUE;
00190 BOOL CXX_Bool_Set = FALSE;
00191 BOOL CXX_Exceptions_On = TRUE;
00192 BOOL CXX_Exceptions_Set = FALSE;
00193 BOOL CXX_Alias_Const=FALSE;
00194 BOOL CXX_Alias_Const_Set=FALSE;
00195 BOOL LANG_Recursive = FALSE;
00196 BOOL LANG_Recursive_Set = FALSE;
00197 BOOL CXX_Wchar_On = TRUE;
00198 BOOL CXX_Wchar_Set = FALSE;
00199 BOOL CXX_Namespaces_On = TRUE; 
00200 BOOL CXX_Namespaces_Set = FALSE;
00201 BOOL CXX_Ansi_For_Init_Scope_On = FALSE;
00202 BOOL CXX_Ansi_For_Init_Scope_Set = FALSE;
00203 BOOL CXX_Standard_C_Plus_Plus_On = FALSE;
00204 BOOL CXX_Standard_C_Plus_Plus_Set = FALSE;
00205 BOOL C_Restrict_On = FALSE;
00206 BOOL C_Restrict_Set = FALSE;
00207 char *C_Auto_Restrict = NULL;
00208 BOOL C_Auto_Restrict_Set = FALSE;
00209 BOOL FTN_Short_Circuit_On = FALSE;
00210 BOOL FTN_Short_Circuit_Set = FALSE;
00211 BOOL Macro_Expand_Pragmas_On = FALSE;
00212 BOOL Macro_Expand_Pragmas_Set = FALSE;
00213 BOOL C_VLA_On = FALSE;
00214 BOOL C_VLA_Set = FALSE;
00215 BOOL CXX_Typename_On = TRUE; 
00216 BOOL CXX_Typename_Set = FALSE;
00217 BOOL CXX_Explicit_On = TRUE; 
00218 BOOL CXX_Explicit_Set = FALSE;
00219 BOOL CXX_Mutable_On = TRUE; 
00220 BOOL CXX_Mutable_Set = FALSE;
00221 BOOL CXX_Packed_On = FALSE; 
00222 BOOL CXX_Packed_Set = FALSE;
00223 BOOL LANG_Symtab_Verify_On = TRUE;
00224 BOOL LANG_Symtab_Verify_Set = TRUE;
00225 BOOL LANG_Ansi_Setjmp_On = TRUE; 
00226 BOOL LANG_Ansi_Setjmp_Set = FALSE;
00227 BOOL LANG_Ignore_Carriage_Return_On = TRUE; 
00228 BOOL LANG_Ignore_Carriage_Return_Set = FALSE;
00229 
00230 BOOL LANG_Pch;
00231 BOOL LANG_Pch_Set;
00232 char *LANG_Create_Pch;
00233 BOOL LANG_Create_Pch_Set;
00234 char *LANG_Use_Pch;
00235 BOOL LANG_Use_Pch_Set;
00236 char *LANG_Pchdir;
00237 char *LANG_cxx_dialect;
00238 BOOL LANG_Pchdir_Set;
00239 BOOL LANG_cxx_dialect_Set;
00240 BOOL LANG_Microsoft_Mode = FALSE;
00241 BOOL LANG_Microsoft_Mode_Set = FALSE;
00242 
00243 /***** INTERNAL group options *****/
00244 
00245 BOOL WHIRL_Merge_Types_On = FALSE; 
00246 BOOL WHIRL_Merge_Types_Set = FALSE;
00247 BOOL WHIRL_Comma_Rcomma_On = TRUE;
00248 BOOL WHIRL_Comma_Rcomma_Set = FALSE;
00249 BOOL WHIRL_Mtype_A_On = FALSE;
00250 #ifdef TARG_IA64
00251 BOOL WHIRL_Mtype_B_On = TRUE;
00252 #else
00253 BOOL WHIRL_Mtype_B_On = FALSE;
00254 #endif
00255 BOOL WHIRL_Mtype_BS_On = FALSE;
00256 BOOL WHIRL_Flatten_Field_On = FALSE;
00257 BOOL WHIRL_Vfcall_On = FALSE;
00258 BOOL WHIRL_Addr_Passed_On = FALSE;
00259 BOOL WHIRL_Addr_Saved_For_Passed_On = FALSE;
00260 BOOL WHIRL_Addr_Saved_On = TRUE;
00261 BOOL WHIRL_Keep_Cvt_On = DEFAULT_KEEP_CVT;
00262 
00263 BOOL Global_Pragmas_In_Dummy_PU_On = TRUE;
00264 BOOL Malloc_Free_On     = TRUE;
00265 BOOL Alloca_Dealloca_On = TRUE;
00266 BOOL Barrier_Lvalues_On = TRUE;
00267 
00268 /***** F90 Heap/stack allocation threshold */
00269 INT32 Heap_Allocation_Threshold=-1;      /* Allocate objects > this on the heap 
00270                                          * (-1 means always use stack), 0 always use heap
00271                                          * default is -1
00272                                          */
00273 
00274 /***** Miscellaneous code generation options *****/
00275 INT32 Short_Data = DEF_SDATA_ELT_SIZE;  /* Objects of this size in .sdata */
00276 static BOOL Short_Data_Set = FALSE;     /* ... option seen? */
00277 INT32 Short_Lits = DEF_SDATA_ELT_SIZE;  /* Literals of this size in .litX */
00278 static BOOL Short_Lits_Set = FALSE;     /* ... option seen? */
00279 INT32 Max_Sdata_Elt_Size = DEF_SDATA_ELT_SIZE;  /* -Gn: sdata size */
00280 BOOL Constant_GP = FALSE;               /* gp never changes? */
00281 
00282 /* ====================================================================
00283  *
00284  * Option groups (see flags.h)
00285  *
00286  * When defining a new option group, remember to not only add an
00287  * option descriptor list (e.g. Options_TENV), but also to add an
00288  * entry describing the group in Common_Option_Groups, below.
00289  *
00290  * ====================================================================
00291  */
00292 
00293 /* Temporary variables used for holding GOT size options during option
00294  * processing until Guaranteed_Small_GOT can be set properly:
00295  */
00296 static BOOL Use_Small_GOT = FALSE;
00297 static BOOL Use_Large_GOT = FALSE;
00298 INT32 Gspace_Available = DEFAULT_GSPACE;
00299 
00300 /* Always force EH Region offsets to be long */
00301 BOOL Force_Long_EH_Range_Offsets = FALSE;
00302 /* Force stack frame to use large model */
00303 BOOL Force_Large_Stack_Model = FALSE;
00304 BOOL Force_GP_Prolog;   /* force usage of gp prolog */
00305 
00306 OPTION_LIST *Registers_Not_Allocatable = NULL;
00307 
00308 /* Unique ident from IPA */
00309 INT32 Ipa_Ident_Number = 0;
00310 
00311 BOOL Indexed_Loads_Allowed = FALSE;
00312 
00313 /* Target environment options: */
00314 static OPTION_DESC Options_TENV[] = {
00315   { OVK_INT32,  OV_VISIBLE,     FALSE, "align_aggregates",      "align_ag",
00316     -1, 0, 16,  &Aggregate_Alignment, NULL,
00317     "Minimum alignment to use for aggregates (structs/arrays)" },
00318   { OVK_BOOL,   OV_INTERNAL,    FALSE, "aligned_copy",          NULL,
00319     0, 0, 0,    &UseAlignedCopyForStructs, NULL },
00320   { OVK_BOOL,   OV_SHY,         FALSE, "call_mcount",           NULL,
00321     0, 0, 0,    &Call_Mcount, NULL },
00322   { OVK_BOOL,   OV_SHY,         FALSE, "constant_gp",           NULL,
00323     0, 0, 0,    &Constant_GP, NULL },
00324   { OVK_BOOL,   OV_SHY,         FALSE, "cpic",                  "cp",
00325     0, 0, 0, &Gen_PIC_Call_Shared, NULL,
00326     "Generate code for executable programs which may call DSOs" },
00327   { OVK_BOOL,   OV_VISIBLE,     FALSE, "fixed_addresses",       "fi",
00328     0, 0, 0,    &PIC_Fixed_Addresses, NULL },
00329   { OVK_INT32,  OV_SHY,         FALSE, "Gspace",                NULL,
00330     DEFAULT_GSPACE,0,INT32_MAX, &Gspace_Available, NULL,
00331     "Maximum GP-relative space available" },
00332   { OVK_UINT32, OV_INTERNAL,    FALSE, "ipa_ident",             NULL, 
00333     0, 0, UINT32_MAX, &Ipa_Ident_Number, NULL,
00334     "Specify IPA timestamp number" },
00335   { OVK_BOOL,   OV_VISIBLE,     FALSE, "kernel",                NULL,
00336     0, 0, 0,    &Kernel_Code,   NULL,
00337     "Generate code for kernel use" },
00338   { OVK_BOOL,   OV_VISIBLE,     FALSE, "large_GOT",             "",
00339     0, 0, 0,    &Use_Large_GOT, NULL,
00340     "Assume GOT is larger than 64K bytes" },
00341   { OVK_NAME,   OV_SHY,         FALSE, "io_library",            NULL,
00342     0, 0, 0,    &Library_Name, NULL },
00343   { OVK_BOOL,   OV_INTERNAL,    FALSE, "large_stack",           NULL,
00344     0, 0, 0,    &Force_Large_Stack_Model, NULL,
00345     "Generate code assuming >32KB stack frame" },
00346   { OVK_BOOL,   OV_VISIBLE,     FALSE, "local_names",           "",
00347     0, 0, 0,    &PIC_Local_Names, NULL },
00348   { OVK_BOOL,   OV_SHY,         FALSE, "long_eh_offsets",       "long_eh", 
00349     0, 0, 0,    &Force_Long_EH_Range_Offsets, NULL },
00350   { OVK_BOOL,   OV_INTERNAL,    FALSE, "non_volatile_GOT",      "non_v",
00351     0, 0, 0,    &Non_Volatile_GOT, NULL,
00352     "Assume GOT is non-volatile" },
00353   { OVK_BOOL,   OV_INTERNAL,    FALSE, "no_page_offset",        "no_p",
00354     0, 0, 0,    &PIC_No_Page_Offset, NULL,
00355     "Don't use GOT page/offset addressing" },
00356   { OVK_BOOL,   OV_SHY,         FALSE, "pic2",                  "pi",
00357     0, 0, 0, &Gen_PIC_Shared, NULL,
00358     "Generate position-independent code suitable for DSOs" },
00359   { OVK_BOOL,   OV_SHY,         FALSE, "pic1",                  NULL,
00360     0, 0, 0, &Gen_PIC_Call_Shared, NULL,
00361     "Generate code for executable programs which may call DSOs" },
00362   { OVK_BOOL,   OV_SHY,         FALSE, "profile_call",          "prof",
00363     0, 0, 0,    &Gen_Profile, NULL },
00364   { OVK_NAME,   OV_SHY,         FALSE, "profile_name",          "",
00365     0, 0, 0, &Gen_Profile_Name, NULL },
00366   { OVK_BOOL,   OV_VISIBLE,     FALSE, "protected_names",       "",
00367     0, 0, 0,    &PIC_Protected_Names, NULL },
00368   { OVK_INT32,  OV_INTERNAL,    FALSE, "short_data",            "short_d",
00369     0, 0, 4096, &Short_Data,    &Short_Data_Set,
00370     "Maximum size of data to allocate GP-relative" },
00371   { OVK_INT32,  OV_INTERNAL,    FALSE, "short_literals",        "short_l",
00372     0, 0, 1024, &Short_Lits,    &Short_Lits_Set,
00373     "Maximum size of literals to allocate GP-relative" },
00374   { OVK_BOOL,   OV_VISIBLE,     FALSE, "small_GOT",             "sm",
00375     0, 0, 0,    &Use_Small_GOT, NULL,
00376     "Assume GOT is smaller than 64K bytes" },
00377   { OVK_INT32,  OV_INTERNAL,    FALSE, "struct_copy_loop_size", "struct_copy_loop",
00378     -1, 0, 4096,        &MinStructCopyLoopSize, NULL },
00379   { OVK_INT32,  OV_INTERNAL,    FALSE, "struct_copy_mem_intr_size", "struct_copy_mem",
00380     -1, 0, 4096,        &MinStructCopyMemIntrSize, NULL },
00381   { OVK_INT32,  OV_VISIBLE,     FALSE, "X",                     NULL,
00382     1, 0, 4,    &Eager_Level,   &Eager_Level_Set,
00383     "Exception-enable level" },
00384   { OVK_BOOL,   OV_VISIBLE,     FALSE, "zeroinit_in_bss",       NULL,
00385     0, 0, 0,    &Zeroinit_in_bss, NULL,
00386     "Place zero-initialized data in .bss section" },
00387   { OVK_BOOL,   OV_SHY,         FALSE, "strings_not_gprelative",        "strings_not_gprel",
00388     0, 0, 0,    &Strings_Not_Gprelative, NULL,
00389     "Do not put any strings in gp-relative sections" },
00390   { OVK_NAME,   OV_SHY,         FALSE, "emit_global_data",      "emit_global",
00391     0, 0, 0, &Emit_Global_Data, NULL,
00392     "only process the global data" },
00393   { OVK_NAME,   OV_SHY,         FALSE, "read_global_data",      "read_global",
00394     0, 0, 0, &Read_Global_Data, NULL,
00395     "only read the already-processed global data" },
00396   { OVK_BOOL,   OV_SHY,         FALSE, "force_gp_prolog",       "force_gp",
00397     0, 0, 0, &Force_GP_Prolog, NULL,
00398     "force gp_prolog to always be setup" },
00399   { OVK_LIST,   OV_VISIBLE,     FALSE, "registers_not_allocatable",     NULL,
00400     0, 0, 0, &Registers_Not_Allocatable, NULL,
00401     "list of registers that are reserved and not available for allocation" },
00402 
00403   /***** Options moved elsewhere -- retained for compatibility: *****/
00404   /* See -DEBUG:div_check */
00405   { OVK_INT32,   OV_INTERNAL,   FALSE, "check_div",     "check_div",
00406     1, 0, 3, &Initial_DEBUG.div_check, &Initial_DEBUG.div_check_set },
00407   /* See -DEBUG:trap_uninitialized */
00408   { OVK_BOOL,   OV_INTERNAL,    FALSE, "trapuv",        "",
00409     0, 0, 0, &Initial_DEBUG.trap_uv, &Initial_DEBUG.trap_uv_set },
00410   /* See -DEBUG:trapuv_right_justify */
00411   { OVK_BOOL,   OV_INTERNAL,    FALSE, "trapuv_right_justify",  "trapuv_right",
00412     0, 0, 0, &Initial_DEBUG.trap_uv_rjustify,
00413              &Initial_DEBUG.trap_uv_rjustify_set },
00414 
00415   /***** Options moved elsewhere -- replaced: *****/
00416   /* See -DEBUG:varargs_prototypes */
00417   { OVK_REPLACED, OV_INTERNAL,  FALSE, "varargs_prototypes",    "varargs_p",
00418     0, 0, 0,
00419     const_cast<char*>("-DEBUG:varargs_prototypes"), NULL },
00420 
00421   /***** Obsolete options: *****/
00422   { /* OVK_INT32, */
00423     OVK_OBSOLETE, OV_INTERNAL,  FALSE, "align_extern",          NULL,
00424     0, 0, 16,   NULL, NULL,
00425     "Assume this alignment for unknown objects" },
00426   { /* OVK_BOOL, */
00427     OVK_OBSOLETE, OV_SHY,       FALSE, "aligned",               NULL,
00428     0, 0, 0,    NULL, NULL,
00429     "Assume unknown objects are properly aligned" },
00430   { /* OVK_INT32, */
00431     OVK_OBSOLETE, OV_INTERNAL,  FALSE, "misalignment",          NULL,
00432     3, 0, 3,    NULL, NULL },
00433   { OVK_INT32,  OV_INTERNAL,    FALSE, "iolist_reuse",  "iolist_reuse",
00434     100, 1, INT32_MAX,  &iolist_reuse_limit,                    NULL,
00435     "Maximum number of iolists which will share stack space" },
00436 
00437   { OVK_COUNT }         /* List terminator -- must be last */
00438 };
00439 
00440 #ifdef BACK_END
00441 
00442 /* Phase selection options: */
00443 static OPTION_DESC Options_PHASE[] = {
00444     { OVK_BOOL, OV_INTERNAL,    FALSE, "lno",     "l",   0, 0, 0,
00445       &Run_lno, NULL},
00446     { OVK_BOOL, OV_INTERNAL,    FALSE, "wopt",    "w",   0, 0, 0,
00447       &Run_wopt,        NULL},
00448     { OVK_BOOL, OV_INTERNAL,    FALSE, "preopt", "p",    0, 0, 0,
00449       &Run_preopt,      NULL},
00450     { OVK_BOOL, OV_INTERNAL,    FALSE, "cg",      "c",   0, 0, 0,
00451       &Run_cg,  NULL},
00452     { OVK_BOOL, OV_INTERNAL,    FALSE, "clist",  NULL,   0, 0, 0,
00453       &Run_w2c, NULL},
00454     { OVK_BOOL, OV_INTERNAL,    FALSE, "flist",  NULL,   0, 0, 0,
00455       &Run_w2f, NULL},
00456     { OVK_BOOL, OV_INTERNAL,    FALSE, "mplist", NULL,   0, 0, 0,
00457       &Run_w2fc_early,  NULL},
00458     { OVK_BOOL, OV_INTERNAL,    FALSE, "purple", "", 0, 0, 0,
00459       &Run_purple,      NULL},
00460     { OVK_BOOL, OV_INTERNAL,    FALSE, "ipl",    "i",    0, 0, 0,
00461       &Run_ipl, NULL},
00462     { OVK_BOOL, OV_INTERNAL,    FALSE, "prompf", NULL,   0, 0, 0,
00463       &Run_prompf,      NULL},
00464     { OVK_NAME, OV_INTERNAL,    FALSE, "lpath",  "",     0, 0, 0,
00465       &LNO_Path,        NULL},
00466     { OVK_NAME, OV_INTERNAL,    FALSE, "wpath",  "",     0, 0, 0,
00467       &WOPT_Path,       NULL},
00468     { OVK_NAME, OV_INTERNAL,    FALSE, "cpath",  "",     0, 0, 0,
00469       &CG_Path, NULL},
00470     { OVK_NAME, OV_INTERNAL,    FALSE, "w2cpath", "", 0, 0, 0,
00471       &W2C_Path,        NULL},
00472     { OVK_NAME, OV_INTERNAL,    FALSE, "w2fpath", "", 0, 0, 0,
00473       &W2F_Path,        NULL},
00474     { OVK_NAME, OV_INTERNAL,    FALSE, "purpath", "", 0, 0, 0,
00475       &Purple_Path,     NULL},
00476     { OVK_NAME, OV_INTERNAL,    FALSE, "ipath",   "", 0, 0, 0,
00477       &Ipl_Path,        NULL},
00478     { OVK_NAME, OV_INTERNAL,    FALSE, "tpath",   "", 0, 0, 0,
00479       &Targ_Path,       NULL},
00480     { OVK_NAME, OV_INTERNAL,    FALSE, "prompf_anl_path", "", 0, 0, 0,
00481       &Prompf_Anl_Path, NULL},
00482     { OVK_COUNT}
00483 };
00484 #elif defined(QIKKI_BE)
00485 static OPTION_DESC Options_PHASE[] = {
00486     { OVK_NAME, OV_INTERNAL,    FALSE, "tpath",   "t", 0, 0, 0,
00487       &Targ_Path,       NULL},
00488     { OVK_COUNT}
00489 };
00490 #endif /* BACK_END */
00491 
00492 static OPTION_DESC Options_LANG[] = {
00493     { OVK_NAME, OV_INTERNAL,    FALSE, "",                      NULL,
00494       0, 0, 0,  &Language_Name,         NULL,
00495       "Language being compiled, from front end" },
00496     { OVK_BOOL, OV_VISIBLE,     FALSE, "bool",                  "",
00497       0, 0, 0,  &CXX_Bool_On,           &CXX_Bool_Set,
00498       "C++: enable builtin type 'bool'" },
00499     { OVK_BOOL, OV_VISIBLE,     FALSE, "exceptions",            "",
00500       0, 0, 0,  &CXX_Exceptions_On,     &CXX_Exceptions_Set,
00501       "C++: enable exceptions" },
00502 #if 0 // remove it till we have a robust design 
00503     { OVK_BOOL, OV_SHY,         FALSE, "alias_const",           "",
00504       0, 0, 0,  &CXX_Alias_Const,       &CXX_Alias_Const_Set },
00505 #endif
00506     { OVK_BOOL, OV_VISIBLE,     FALSE, "recursive",             "",
00507       0, 0, 0,  &LANG_Recursive,        &LANG_Recursive_Set,
00508       "FORTRAN: program contains recursion" },
00509     { OVK_BOOL, OV_VISIBLE,     FALSE, "wchar_t",               "",
00510       0, 0, 0,  &CXX_Wchar_On,          &CXX_Wchar_Set,
00511       "C++: enable builtin type 'wchar_t'" },
00512     { OVK_BOOL, OV_VISIBLE,     FALSE, "namespaces",            "namespace",
00513       0, 0, 0,  &CXX_Namespaces_On,     &CXX_Namespaces_Set,
00514       "C++: enable namespaces" },
00515     { OVK_BOOL, OV_VISIBLE,     FALSE, "ansi-for-init-scope",   "",
00516       0, 0, 0,  &CXX_Ansi_For_Init_Scope_On,    &CXX_Ansi_For_Init_Scope_Set},
00517     { OVK_BOOL, OV_VISIBLE,     FALSE, "std",   "",
00518       0, 0, 0,  &CXX_Standard_C_Plus_Plus_On,   &CXX_Standard_C_Plus_Plus_Set},
00519     { OVK_BOOL, OV_SHY,         FALSE, "restrict",              "",
00520       0, 0, 0,  &C_Restrict_On,         &C_Restrict_Set },
00521     { OVK_NAME, OV_VISIBLE,     FALSE, "autorestrict",          NULL,
00522       0, 0, 0,  &C_Auto_Restrict,               &C_Auto_Restrict_Set,
00523       "Automatically set the \"restrict\" qualifier on some or all pointers" },
00524     { OVK_BOOL, OV_INTERNAL,    FALSE, "scalar_formal_ref", "",
00525       0, 0, 0,  &Scalar_Formal_Ref,     NULL },
00526     { OVK_BOOL, OV_INTERNAL,    FALSE, "non_scalar_formal_ref", "",
00527       0, 0, 0,  &Non_Scalar_Formal_Ref, NULL },
00528     { OVK_BOOL, OV_INTERNAL,    FALSE, "short_circuit_conditionals", "",
00529       0, 0, 0,  &FTN_Short_Circuit_On, &FTN_Short_Circuit_Set },
00530     { OVK_BOOL, OV_VISIBLE,     FALSE, "vla",                   "",
00531       0, 0, 0,  &C_VLA_On,              &C_VLA_Set,
00532       "C/C++: enable variable length arrays" },
00533     { OVK_BOOL, OV_VISIBLE,     FALSE, "explicit",              "",
00534       0, 0, 0,  &CXX_Explicit_On,       &CXX_Explicit_Set,
00535       "C++: enable explicit keyword" },
00536     { OVK_BOOL, OV_VISIBLE,     FALSE, "typename",              "",
00537       0, 0, 0,  &CXX_Typename_On,       &CXX_Typename_Set,
00538       "C++: enable typename keyword" },
00539     { OVK_BOOL, OV_VISIBLE,     FALSE, "mutable",               "",
00540       0, 0, 0,  &CXX_Mutable_On,        &CXX_Mutable_Set,
00541       "C++: enable mutable keyword" },
00542     { OVK_BOOL, OV_VISIBLE,     FALSE, "macro_expand_pragmas",          "",
00543       0, 0, 0,  &Macro_Expand_Pragmas_On, &Macro_Expand_Pragmas_Set,
00544       "C/C++: enable macro expansion in pragmas" },
00545     { OVK_BOOL, OV_VISIBLE,     FALSE, "packed",                "",
00546       0, 0, 0,  &CXX_Packed_On, &CXX_Packed_Set,
00547       "C++: enable pragma pack" },
00548     { OVK_BOOL, OV_INTERNAL,    FALSE, "symtab_verify",         "",
00549       0, 0, 0,  &LANG_Symtab_Verify_On, &LANG_Symtab_Verify_Set },
00550     { OVK_BOOL, OV_VISIBLE,     FALSE, "pch",          NULL,
00551       0, 0, 0,  &LANG_Pch, &LANG_Pch_Set,
00552       "Create a precompiled header for this compilation unit" },
00553     { OVK_NAME, OV_VISIBLE,     FALSE, "create_pch",          NULL,
00554       0, 0, 0,  &LANG_Create_Pch, &LANG_Create_Pch_Set,
00555       "Create a precompiled header file named by this option" },
00556     { OVK_NAME, OV_VISIBLE,      FALSE, "use_pch",            NULL,
00557       0, 0, 0,  &LANG_Use_Pch, &LANG_Use_Pch_Set,
00558       "Use the precompiled header file named by this option" },
00559     { OVK_NAME, OV_VISIBLE,      FALSE, "pch_dir",            NULL,
00560       0, 0, 0,  &LANG_Pchdir, &LANG_Pchdir_Set,
00561       "Create/Use from the directory named by this option" },
00562     { OVK_BOOL, OV_VISIBLE,     FALSE, "ansi_setjmp",           "",
00563       0, 0, 0,  &LANG_Ansi_Setjmp_On,   &LANG_Ansi_Setjmp_Set,
00564       "C/C++: enable optimization of functions with calls to setjmp" },
00565     { OVK_BOOL, OV_VISIBLE,     FALSE, "microsoft_extensions",  "microsoft_extension",
00566       0, 0, 0,  &LANG_Microsoft_Mode,   &LANG_Microsoft_Mode_Set},
00567 
00568     { OVK_INT32,OV_VISIBLE,     TRUE, "heap_allocation_threshold", "heap_a",
00569       -1, -1, INT32_MAX, &Heap_Allocation_Threshold,    NULL,
00570       "Size threshold for switching from stack to heap allocation" },
00571     { OVK_NAME, OV_VISIBLE,     FALSE, "cxx_dialect", NULL,
00572       0, 0, 0,  &LANG_cxx_dialect,   &LANG_cxx_dialect_Set},
00573     { OVK_BOOL, OV_VISIBLE,     FALSE, "ignore_carriage_return",        "",
00574       0, 0, 0,  &LANG_Ignore_Carriage_Return_On, &LANG_Ignore_Carriage_Return_Set,
00575       "C/C++: ignore carriage returns in source" },
00576 
00577 
00578     { OVK_COUNT }                   /* List terminator -- must be last */
00579 };
00580 
00581 static OPTION_DESC Options_INTERNAL[] = {
00582 
00583     { OVK_BOOL, OV_INTERNAL,    FALSE, "comma_rcomma",          "",
00584       0, 0, 0,  &WHIRL_Comma_Rcomma_On, &WHIRL_Comma_Rcomma_Set },
00585     { OVK_BOOL, OV_INTERNAL,    FALSE, "merge_types",           "",
00586       0, 0, 0,  &WHIRL_Merge_Types_On,  &WHIRL_Merge_Types_Set },
00587     { OVK_BOOL, OV_INTERNAL,    FALSE, "mtype_a",               NULL,
00588       0, 0, 0,  &WHIRL_Mtype_A_On, NULL },
00589     { OVK_BOOL, OV_INTERNAL,    FALSE, "mtype_b",               NULL,
00590       0, 0, 0,  &WHIRL_Mtype_B_On, NULL },
00591     { OVK_BOOL, OV_INTERNAL,    FALSE, "mtype_bs",              NULL,
00592       0, 0, 0,  &WHIRL_Mtype_BS_On, NULL },
00593     { OVK_BOOL, OV_INTERNAL,    FALSE, "return_val",            NULL,
00594       0, 0, 0,  &WHIRL_Return_Val_On, NULL },
00595     { OVK_BOOL, OV_INTERNAL,    FALSE, "flatten_field",         NULL,
00596       0, 0, 0,  &WHIRL_Flatten_Field_On, NULL },
00597     { OVK_BOOL, OV_INTERNAL,    FALSE, "mldid_mstid",           NULL,
00598       0, 0, 0,  &WHIRL_Mldid_Mstid_On, NULL },
00599     { OVK_BOOL, OV_INTERNAL,    FALSE, "vfcall",                NULL,
00600       0, 0, 0,  &WHIRL_Vfcall_On, NULL },
00601     { OVK_BOOL, OV_INTERNAL,    FALSE, "addr_passed",           NULL,
00602       0, 0, 0,  &WHIRL_Addr_Passed_On, NULL },
00603     { OVK_BOOL, OV_INTERNAL,    FALSE, "addr_saved_for_passed", NULL,
00604       0, 0, 0,  &WHIRL_Addr_Saved_For_Passed_On, NULL },
00605     { OVK_BOOL, OV_INTERNAL,    FALSE, "addr_saved",            NULL,
00606       0, 0, 0,  &WHIRL_Addr_Saved_On, NULL },
00607     { OVK_BOOL, OV_INTERNAL,    FALSE, "keep_cvt",      NULL,
00608       0, 0, 0,  &WHIRL_Keep_Cvt_On, NULL },
00609     { OVK_BOOL, OV_INTERNAL,    FALSE, "return_info",   NULL,
00610       0, 0, 0,  &WHIRL_Return_Info_On, NULL },
00611     { OVK_BOOL, OV_INTERNAL,    FALSE, "global_pragmas",        NULL,
00612       0, 0, 0,  &Global_Pragmas_In_Dummy_PU_On, NULL },
00613     { OVK_BOOL, OV_INTERNAL,    FALSE, "malloc_free",   NULL,
00614       0, 0, 0,  &Malloc_Free_On, NULL },
00615     { OVK_BOOL, OV_INTERNAL,    FALSE, "alloca_dealloca",       NULL,
00616       0, 0, 0,  &Alloca_Dealloca_On, NULL },
00617     { OVK_BOOL, OV_INTERNAL,    FALSE, "barrier_lvalues",       NULL,
00618       0, 0, 0,  &Barrier_Lvalues_On, NULL },
00619     { OVK_BOOL, OV_INTERNAL,    FALSE, "mask_shift_counts",     NULL,
00620       0, 0, 0,  &ARCH_mask_shift_counts, NULL },
00621     { OVK_BOOL, OV_INTERNAL,    FALSE, "generate_nor",  NULL,
00622       0, 0, 0,  &ARCH_generate_nor, NULL },
00623 
00624     { OVK_COUNT }                   /* List terminator -- must be last */
00625 };
00626 
00627 OPTION_GROUP Common_Option_Groups[] = {
00628   { "DEBUG",    ':', '=', Options_DEBUG, NULL,
00629     "Options to assist debugging" },
00630   { "INLINE",   ':', '=', Options_INLINE, NULL,
00631     "Options to control subprogram inlining" },
00632   { "INTERNAL", ':', '=', Options_INTERNAL, NULL,
00633     "Options to control internal flags for testing" },
00634   { "IPA",      ':', '=', Options_IPA, NULL,
00635     "Options to control interprocedural analysis and optimization" },
00636   { "LANG",     ':', '=', Options_LANG, NULL,
00637     "Options to control source language interpretation" },
00638   { "LIST",     ':', '=', Options_LIST, NULL,
00639     "Options to control the listing file" },
00640   { "OPT",      ':', '=', Options_OPT, NULL,
00641     "Options to control general optimization" },
00642 #ifdef BACK_END
00643   { "LNO",      ':', '=', Options_LNO, NULL,
00644     "Options to control loop nest optimization" },
00645 #endif /* BACK_END */
00646 #if defined(BACK_END) || defined(QIKKI_BE)
00647   { "PHASE",    ':', '=', Options_PHASE, NULL,
00648     "Options to control phase invocation and locations" },
00649 #endif /* defined(BACK_END) || defined(QIKKI_BE) */
00650   { "TARG",     ':', '=', Options_TARG, NULL,
00651     "Options to specify the target machine characteristics" },
00652   { "TENV",     ':', '=', Options_TENV, NULL,
00653     "Options to set or assert target environment characteristics" },
00654   { "WOPT",     ':', '=', Options_WOPT, NULL,
00655     "Options to control internal WHIRL optimization" },
00656   { "VHO",      ':', '=', Options_VHO, NULL,
00657     "Options to control internal VH WHIRL optimization" },
00658   { "FLIST", ':', '=', Options_FLIST, NULL,
00659        "Options to control listing of transformed f77 source" },
00660   { "CLIST", ':', '=', Options_CLIST, NULL,
00661        "Options to control listing of transformed C source" },
00662   { "PURPLE", ':', '=', Options_PURPLE, NULL,
00663        "Options to control program region extraction process" },
00664   { "PROMP", ':', '=', Options_PROMP, NULL,
00665        "Options to control listing mp transformations" },
00666   { NULL }              /* List terminator -- must be last */
00667 };
00668 
00669 /* ====================================================================
00670  *
00671  * Miscellaneous data declarations and initialization
00672  *
00673  * ====================================================================
00674  */
00675 
00676 /* What is the model to be used for logical values in Fortran? */
00677 BOOL Use_C_Like_Logicals = TRUE;
00678 
00679 /* Is exception-handling enabled in C++? */
00680 BOOL Allow_Exceptions = TRUE;
00681 
00682 /***** Compiler debug/trace options *****/
00683 BOOL Tracing_Enabled = FALSE;           /* Any trace options set? */
00684 
00685 /***** Miscellaneous optimization options *****/
00686 /* Should idict commute operands in seeking match? */
00687 BOOL Idict_Commutable_Match = FALSE;
00688 BOOL Scalar_Formal_Ref = TRUE;          /* for fortran scalar formal refs */
00689 BOOL Non_Scalar_Formal_Ref = FALSE;     /* for fortran non_scalar formal refs */
00690 
00691 BOOL CG_mem_intrinsics = TRUE;          /* for memory intrinsic expansion */
00692 INT32 CG_memmove_inst_count = 16;       /* for intrinsic expansion of bzero etc */
00693 BOOL CG_memmove_inst_count_overridden = FALSE;
00694 BOOL CG_bcopy_cannot_overlap = FALSE;   /* for intrinsic expansion of bcopy */
00695 BOOL CG_memcpy_cannot_overlap = FALSE;  /* for intrinsic expansion of memcpy */
00696 BOOL CG_memmove_cannot_overlap = FALSE; /* for intrinsic expansion of memmove */
00697 BOOL CG_memmove_nonconst = FALSE;       /* expand mem intrinsics unknown size */
00698 
00699 /***** Miscellaneous GOPT options *****/
00700 INT32 Opt_Level = DEF_OPT_LEVEL;
00701 INT32 OPT_unroll_times = 4;             /* but see Configure_Target() */
00702 BOOL OPT_unroll_times_overridden = FALSE;
00703 INT32 OPT_unroll_size = 40;             /* but see Configure_CG_Options() */
00704 BOOL OPT_unroll_size_overridden = FALSE;
00705 INT32 Const_Copy_TN_CNT = DEF_CONST_COPY_TN_CNT;
00706 BOOL  Enable_BB_Splitting = TRUE;
00707 INT32 Split_BB_Length = DEF_BBLENGTH;
00708 BOOL Enable_SWP = FALSE;                /* but see cgdriver.c */
00709 BOOL Enable_SWP_overridden = FALSE;
00710 
00711 /***** What is the byte sex of the host and target? *****/
00712 UINT8 Host_Byte_Sex = BIG_ENDIAN;       /* Set in config_host.c */
00713 UINT8 Target_Byte_Sex = BIG_ENDIAN;     /* Set in config_targ.c */
00714 BOOL  Same_Byte_Sex = TRUE;             /* Set in config_targ.c */
00715 
00716 /***** Miscellaneous code generation options *****/
00717 BOOL Use_Base_Ptrs = TRUE;      /* Explicit ptrs to .DATA./.RDATA? */
00718 BOOL Gen_PIC_Call_Shared = FALSE; /* CPIC */
00719 BOOL Gen_PIC_Shared = FALSE;    /* PIC */
00720 BOOL Gen_PIC_Calls = FALSE;     /* PIC calls */
00721 BOOL Guaranteed_Small_GOT = TRUE; /* GOT < 64kB? */
00722 BOOL Non_Volatile_GOT = FALSE;  /* GOT entries volatile? */
00723 BOOL PIC_Local_Names = FALSE;   /* Names local by default? */
00724 BOOL PIC_Protected_Names = FALSE; /* Names protected by default? */
00725 BOOL PIC_Fixed_Addresses = FALSE; /* Names fixed by default? */
00726 BOOL PIC_No_Page_Offset = FALSE;  /* Don't use page/offset addressing? */
00727 BOOL Force_Mem_Formals = FALSE; /* Always force formals to memory? */
00728 BOOL Kernel_Code = FALSE;       /* Compiling OS kernel? */
00729 BOOL Varargs_Prototypes = TRUE; /* Varargs have prototypes for FP? */
00730 BOOL Gen_Profile = FALSE;       /* Generate a profile call for each user call */
00731 char *Gen_Profile_Name = "__profile_call"; 
00732 BOOL Call_Mcount = FALSE;       /* generate a call to mcount in pu entry */
00733 BOOL GP_Is_Preserved = FALSE;   /* GP is neither caller or callee-save */
00734 
00735 char *Emit_Global_Data = NULL;  /* only emit global data */
00736 char *Read_Global_Data = NULL;  /* only read global data */
00737 
00738 char *Library_Name = NULL;      /* -TENV:io_library=xxx */
00739 INT  target_io_library;
00740 
00741 BOOL Meld_Schedule = FALSE;     /* Attempt to meld basic blocks */
00742 BOOL Gap_Schedule = FALSE;      /* Attempt to perform gap scheduling */
00743 BOOL Attempt_Bypass = FALSE;    /* Attempt to use bypass registers */
00744 BOOL Isolate_Lines = FALSE;     /* Don't overlap source lines */
00745 BOOL Fill_Delay_Slots = FALSE;  /* Attempt to fill branch delay slots */
00746 BOOL Enable_GDSE = FALSE;       /* Allow global dead store elimination */
00747 BOOL Enable_CG_Peephole =FALSE; /* Enable peephole optimization in cgprep */
00748 
00749 #ifdef BACK_END
00750 /* back end phases options */
00751 BOOL Run_lno = FALSE;               /* run loop-nest optimizer */
00752 BOOL Run_wopt = FALSE;              /* run WHIRL global optimizer */
00753 BOOL Run_preopt = FALSE;            /* run WHIRL preopt optimizer */
00754 BOOL Run_ipl = FALSE;               /* run procedure summary phase  */
00755 BOOL Run_cg = FALSE;                /* run code generator */
00756 BOOL Run_w2c = FALSE;               /* run whirl2c */
00757 BOOL Run_w2f = FALSE;               /* run whirl2f */
00758 BOOL Run_w2fc_early = FALSE;        /* run whirl2fc after LNO auto par*/
00759 BOOL Run_purple = FALSE;            /* run purple code instrumenter */
00760 BOOL Run_prompf = FALSE;            /* run to generate prompf analysis file */
00761 char *LNO_Path = 0;                 /* path to lno.so */
00762 char *WOPT_Path = 0;                /* path to wopt.so */
00763 char *CG_Path = 0;                  /* path to cg.so */
00764 char *Ipl_Path = 0;                 /* path to ipl.so */
00765 char *W2C_Path = 0;                 /* path to whirl2c.so */
00766 char *W2F_Path = 0;                 /* path to whirl2f.so */
00767 char *Purple_Path = 0;              /* path to purple.so */
00768 char *Prompf_Anl_Path = 0;          /* path to prompf_anl.so */
00769 WN_MAP Prompf_Id_Map = WN_MAP_UNDEFINED; 
00770                         /* Maps WN constructs to unique identifiers */
00771 #endif /* BACK_END */
00772 char *Inline_Path = 0;                    /* path to inline.so */
00773 #if defined(BACK_END) || defined(QIKKI_BE)
00774 char *Targ_Path = 0;                /* path to targ_info .so */
00775 #endif /* defined(BACK_END) || defined(QIKKI_BE) */
00776 
00777 /* ====================================================================
00778  *
00779  * Preconfigure
00780  *
00781  * Configure compiler options prior to flag processing.
00782  *
00783  * ====================================================================
00784  */
00785 
00786 void
00787 Preconfigure (void)
00788 {
00789   OPTION_GROUP *og;
00790 
00791   /* Perform host-specific and target-specific configuration: */
00792   Preconfigure_Host ();
00793   Preconfigure_Target ();
00794 
00795   /* Initialize the option groups: */
00796   Initialize_Option_Groups ( Common_Option_Groups );
00797 
00798   og = Get_Command_Line_Group ( Common_Option_Groups, "TARG" );
00799   Set_Option_Internal ( og, "fp_regs" /* don't admit to this one */ );
00800   Set_Option_Internal ( og, "mips1" /* duplicates isa=mips1 */ );
00801   Set_Option_Internal ( og, "mips2" /* duplicates isa=mips2 */ );
00802   Set_Option_Internal ( og, "mips3" /* duplicates isa=mips3 */ );
00803   Set_Option_Internal ( og, "mips4" /* duplicates isa=mips4 */ );
00804   Set_Option_Internal ( og, "mips5" /* duplicates isa=mips5 */ );
00805   Set_Option_Internal ( og, "mips6" /* duplicates isa=mips6 */ );
00806 
00807   og = Get_Command_Line_Group ( Common_Option_Groups, "TENV" );
00808   Set_Option_Internal ( og, "pic1" /* same as -TENV:cpic */ );
00809   Set_Option_Internal ( og, "pic2" /* same as -TENV:pic */ );
00810 
00811 #ifdef BACK_END
00812   /* -PHASE is just for driver and internal use -- don't expose it */
00813   og = Get_Command_Line_Group ( Common_Option_Groups, "PHASE" );
00814   Set_Option_Internal ( og, NULL );
00815 
00816   /* -INLINE and -IPA aren't passed properly to back end, so don't
00817    * confuse the poor users by printing the defaults (PV 645705)
00818    */
00819   og = Get_Command_Line_Group ( Common_Option_Groups, "INLINE" );
00820   Set_Option_Internal ( og, NULL );
00821   og = Get_Command_Line_Group ( Common_Option_Groups, "IPA" );
00822   Set_Option_Internal ( og, NULL );
00823 
00824 #endif /* BACK_END */
00825 }
00826 
00827 /* ====================================================================
00828  *
00829  * Configure_Platform
00830  *
00831  * Process a platform name, setting Platform and Processor_Name, the
00832  * latter to be processed by Configure_Target.  The platform name may
00833  * come from either -OPT:Ofast=name or -TARG:platform=name.
00834  *
00835  * ====================================================================
00836  */
00837 
00838 static void
00839 Configure_Platform ( char *platform_name )
00840 {
00841   PLATFORM_OPTIONS *popts;
00842 
00843   /* If we've already set the platform, and the new name is empty,
00844    * don't re-default it:
00845    */
00846   if ( Platform != IP0
00847     && ( platform_name == NULL || *platform_name == 0 ) )
00848   {
00849     return;
00850   }
00851 
00852   /* Get platform and its associated options: */
00853   popts = Get_Platform_Options ( platform_name );
00854   Platform = POPTS_id(popts);
00855   
00856   /* Set the per-IP options: */
00857   if ( Processor_Name == NULL ) {
00858     Processor_Name = POPTS_pname(popts);
00859   }
00860 }
00861 
00862 /* ====================================================================
00863  *
00864  * Configure_Ofast
00865  *
00866  * Configure option defaults which depend on -Ofast (the baseline SPEC
00867  * optimizaiton option).  These currently include:
00868  *
00869  *   -OPT:Olimit=0 -- no limit on optimization region size.
00870  *   -OPT:roundoff=3 -- do any mathematically valid rearrangement.
00871  *   -OPT:div_split=ON -- allow splitting a/b => a*recip(b).
00872  *   -OPT:speculative_null_ptr_deref=ON -- allow speculation past the null
00873  *                                         ptr test. assumes page zero as 
00874  *                                         readable.
00875  *   -OPT:alias=typed -- pointers to different types don't alias.
00876  *   -WOPT:copy_ops=OFF -- don't copy-propagate operations that the IVR
00877  *              can't handle (OFF by default now, but just in case...).
00878  *   -WOPT:estr_fb_injury=ON -- SSAPRE strength reduction uses
00879  *                              feedback frequency rather than loop
00880  *                              nesting to decide whether each IV
00881  *                              update should be viewed as injury or
00882  *                              kill.
00883  *
00884  * This must be done before abi/isa/processor configuration.
00885  *
00886  * ====================================================================
00887  */
00888 
00889 static void
00890 Configure_Ofast ( void )
00891 {
00892   /* We assume that the driver has defaulted Opt_Level properly. */
00893   /* First set the options that are common to all targets: */
00894   if ( ! Olimit_Set ) {
00895     Olimit = 0;
00896     Olimit_Set = TRUE;
00897   }
00898   if ( ! Roundoff_Set ) {
00899     Roundoff_Level = ROUNDOFF_ANY;
00900     Roundoff_Set = TRUE;
00901   }
00902   if ( ! Div_Split_Set ) {
00903     Div_Split_Allowed = TRUE;
00904     Div_Split_Set = TRUE;
00905   }
00906 /* #645549: There exists an OS bug which gets triggered by NULL ptr
00907    speculation. Disable NULL ptr speculation for Ofast (base flags).
00908    They will however continue to be turned ON for SPEC peak flags.
00909 
00910   if ( ! GCM_Eager_Null_Ptr_Deref_Set ) {
00911     GCM_Eager_Null_Ptr_Deref = TRUE;
00912     GCM_Eager_Null_Ptr_Deref_Set = TRUE;
00913   }
00914 */
00915   if ( ! Alias_Pointer_Types_Set ) {
00916     Alias_Pointer_Types = TRUE;
00917     Alias_Pointer_Types_Set = TRUE;
00918   }
00919   if ( ! WOPT_Enable_Copy_Prop_Bad_Ops_Set ) {
00920     WOPT_Enable_Copy_Prop_Bad_Ops = FALSE;
00921     WOPT_Enable_Copy_Prop_Bad_Ops_Set = TRUE;
00922   }
00923   if ( ! WOPT_Enable_Estr_FB_Injury_Set ) {
00924     WOPT_Enable_Estr_FB_Injury = TRUE;
00925     WOPT_Enable_Estr_FB_Injury_Set = TRUE;
00926   }
00927 
00928   /* Get platform and its associated options: */
00929   Configure_Platform ( Ofast );
00930 }
00931 
00932 /* ====================================================================
00933  *
00934  * Configure
00935  *
00936  * Configure compiler options based on flag values.
00937  *
00938  * ====================================================================
00939  */
00940 
00941 #ifdef KEEP_WHIRLSTATS
00942 /* defined in wn.c */
00943 extern void whirlstats();
00944 #endif
00945 
00946 
00947 extern BOOL IR_set_dump_order (BOOL prefix); /* in ir_reader.c */
00948 
00949 void
00950 Configure (void)
00951 {
00952   static BOOL dev_warn_toggled = FALSE;
00953 
00954 #if !defined(SGI_FRONT_END_CPP)
00955   /* See if trees should be dumped in prefix order */
00956   if (Get_Trace(TKIND_INFO, TINFO_PREFIXDUMP)) {
00957      IR_set_dump_order(TRUE);
00958   }  
00959 #endif
00960 
00961   if ( ! dev_warn_toggled ) {
00962     if ( Get_Trace( TP_MISC, 0x40 ) ) {
00963       dev_warn_toggled = TRUE;
00964       DevWarn_Toggle();
00965     }
00966   }
00967 
00968 #ifdef KEEP_WHIRLSTATS
00969   atexit(whirlstats);
00970 #endif
00971 
00972   /* Configure the alias options first so the list is processed and
00973    * we can tell for -OPT:Ofast below what overrides have occurred:
00974    */
00975   Configure_Alias_Options ( Alias_Option );
00976 
00977   /* Check the -TARG:platform option (subordinate to Ofast): */
00978   if ( Platform_Name != NULL && *Platform_Name != 0 ) {
00979     Configure_Platform ( Platform_Name );
00980   }
00981 
00982   /* First, if -OPT:Ofast (a.k.a. SPEC) is set, configure defaults: */
00983   if ( Ofast != NULL ) {
00984     Configure_Ofast ();
00985   }
00986 
00987 
00988   /* Perform host-specific and target-specific configuration: */
00989   Configure_Host ();
00990   Configure_Target ();
00991 
00992   /* What size GOT to use?  Configure_Target sets it to small for
00993    * 32-bit pointers, large for 64-bit pointers.  Override it here
00994    * if TENV was used to specify it:
00995    */
00996   if ( Use_Large_GOT && Use_Small_GOT ) {
00997     /* Make up your mind! */
00998     ErrMsg ( EC_GOT_Size, Guaranteed_Small_GOT ? "small" : "large" );
00999   } else if ( Use_Large_GOT ) {
01000     Guaranteed_Small_GOT = FALSE;
01001   } else if ( Use_Small_GOT ) {
01002     Guaranteed_Small_GOT = TRUE;
01003   }
01004 
01005   if (Emit_Global_Data && Read_Global_Data) {
01006     /* Make up your mind! */
01007     FmtAssert (FALSE, ("can't specify options to both emit and read global data"));
01008   }
01009   else if (Emit_Global_Data) Global_File_Name = Emit_Global_Data;
01010   else if (Read_Global_Data) Global_File_Name = Read_Global_Data;
01011 
01012   /* Configure the treatment of short literals and data.  We give
01013    * precedence to the -TENV:short_lits=nnn:short_data=mmm options,
01014    * but -Gn can override either of them if not specified:
01015    */
01016   if ( ! Short_Lits_Set ) {
01017     Short_Lits = Max_Sdata_Elt_Size;
01018   }
01019   if ( ! Short_Data_Set ) {
01020     Short_Data = Max_Sdata_Elt_Size;
01021   }
01022 
01023   /* Turn on -OPT:Reorg_Common by default at -O3: */
01024   if ( ! OPT_Reorg_Common_Set && Opt_Level > 2 ) {
01025     OPT_Reorg_Common = TRUE;
01026   }
01027 
01028   if (Force_GP_Prolog) Force_Jalr = TRUE;
01029 }
01030 
01031 /* ====================================================================
01032  *
01033  * Configure_Source
01034  *
01035  * Configure compiler options for each source file.
01036  *
01037  * Note that we set the various optimization and code generation
01038  * options at this level to ultimately allow per-source respecification
01039  * with pragmas.
01040  *
01041  * ====================================================================
01042  */
01043 
01044 void
01045 Configure_Source ( char *filename )
01047 {
01048   /* Identify the source language: */
01049   if ( Language_Name != NULL ) {
01050     if ( ux_strcasecmp ( Language_Name, "KR_C" ) == 0 ) {
01051       Language = LANG_KR_C;
01052     } else if ( ux_strcasecmp ( Language_Name, "ANSI_C" ) == 0 ) {
01053       Language = LANG_ANSI_C;
01054     } else if ( ux_strcasecmp ( Language_Name, "CPLUS" ) == 0 ) {
01055       Language = LANG_CPLUS;
01056     } else if ( ux_strcasecmp ( Language_Name, "DELTA" ) == 0 ) {
01057       Language = LANG_DELTA;
01058     } else if ( ux_strcasecmp ( Language_Name, "F77" ) == 0 ) {
01059       Language = LANG_F77;
01060     } else if ( ux_strcasecmp ( Language_Name, "F90" ) == 0 ) {
01061       Language = LANG_F90;
01062     }
01063   }
01064 
01065   /* Configure the -DEBUG and -LIST groups: */
01066   DEBUG_Configure ();
01067   LIST_Configure ();
01068 
01069   /* Determine whether to use the CRAY or MIPS IO library */
01070   if (Library_Name != NULL) {
01071     if (ux_strcasecmp ( Library_Name,"cray") == 0 ) {
01072        target_io_library = IOLIB_CRAY;
01073     } else if (ux_strcasecmp ( Library_Name,"mips") == 0 ) {
01074        target_io_library = IOLIB_MIPS;
01075     }
01076   } else {
01077      /* For F90, use the CRAY libraries by default */
01078      if (Language == LANG_F90) {
01079         target_io_library = IOLIB_CRAY;
01080      /* For F77, use the MIPS libraries by default */
01081      } else {
01082         target_io_library = IOLIB_MIPS;
01083      }
01084   }
01085 
01086 #ifdef BACK_END
01087 
01088   /* If we're invoking CITE, turn on whirl2c/f: */
01089   if ( List_Cite ) {
01090     if ( Language == LANG_F77 || Language == LANG_F90 ) {
01091       Run_w2f = TRUE;
01092     } else if ( Language == LANG_KR_C || Language == LANG_ANSI_C
01093              || Language == LANG_CPLUS || Language == LANG_DELTA )
01094     {
01095       Run_w2c = TRUE;
01096     }
01097   }
01098 
01099   /* If we're invoking CITE, turn on whirl2c/f: */
01100   if (Run_w2fc_early) {
01101     if ( Language == LANG_F77 || Language == LANG_F90 ) {
01102       Run_w2f = TRUE;
01103     } else if ( Language == LANG_KR_C || Language == LANG_ANSI_C
01104              || Language == LANG_CPLUS || Language == LANG_DELTA )
01105     {
01106       Run_w2c = TRUE;
01107     }
01108   }
01109 #endif /* BACK_END */
01110 
01111   if ( Use_Large_GOT )  Guaranteed_Small_GOT = FALSE;
01112 
01113   /* if we get both TENV:CPIC and TENV:PIC, use only TENV:CPIC */
01114   if (Gen_PIC_Call_Shared && Gen_PIC_Shared) Gen_PIC_Shared = FALSE;
01115 
01116   /* Select optimization options: */
01117 
01118   /* Are we skipping any PUs for optimization? */
01119   Optimization_Skip_List = Build_Skiplist ( Opt_Skip );
01120   /* Are we skipping any regions for optimization? */
01121   Region_Skip_List = Build_Skiplist ( Region_Skip );
01122 
01123   /* F90 is a recursive language, so this needs to be set */
01124   if (!LANG_Recursive_Set && Language == LANG_F90)
01125      LANG_Recursive = TRUE;
01126 
01127   /* Since there seems to be little compile time reason not to be aggressive, 
01128    * make the folder aggressive by default
01129    */
01130   if ( ! Cfold_Aggr_Set )
01131     Enable_Cfold_Aggressive = TRUE;
01132 
01133   if (!Enable_CVT_Opt_Set)
01134     Enable_CVT_Opt = ( Opt_Level > 0);
01135 
01136   CSE_Elim_Enabled = Opt_Level > 0;
01137 
01138   /* Perform the %call16 -> %got_disp relocation change? */
01139   if ( ! Enable_GOT_Call_overridden )
01140     Enable_GOT_Call_Conversion = Opt_Level > 2;
01141 
01142   /* Force formal parameters to memory? */
01143   Force_Mem_Formals = ( Opt_Level < 1 );
01144 
01145   /* Optimize for space */
01146   if ( OPT_Space ) {
01147 
01148     /* TODO:  Other space optimizations to force? */
01149     if (!CG_memmove_inst_count_overridden)
01150       CG_memmove_inst_count = 8;
01151     if (! OPT_unroll_size_overridden)
01152       OPT_unroll_size = 20;
01153     /* reduce caller+callee "size" limit for inlining */
01154     INLINE_Max_Pu_Size=1000;
01155 #if 0 /* not ready for this yet. */
01156     /* don't inline divide expansions */
01157     if (!OPT_Inline_Divide_Set) OPT_Inline_Divide = FALSE;
01158 #endif
01159 
01160 #ifdef BACK_END
01161     /* LNO options to be turned off for SPACE */
01162     LNO_Outer_Unroll = 1;
01163     LNO_Split_Tiles = FALSE;
01164 #endif /* BACK_END */
01165   }
01166 
01167   /* symbolic debug stuff */
01168   Symbolic_Debug_Mode = SDM_NONE;
01169   if (Debug_Level > 0 && Debug_Level <= 2)
01170     Symbolic_Debug_Mode |= SDM_SEQLINE;
01171   if (Debug_Level > 0) {
01172     Symbolic_Debug_Mode |= SDM_SYMBOL;
01173     Symbolic_Debug_Mode |= SDM_LINE;
01174   }
01175 
01176 
01177   /* Disabling splitting of long basic blocks: */
01178   Enable_BB_Splitting = ! Get_Trace ( TP_FLOWOPT, 0x080 );
01179 
01180   if (Opt_Level > 2 && ! Olimit_Set)
01181         Olimit = DEFAULT_O3_OLIMIT;
01182   if (Olimit == 0) {
01183         /* 0 Olimit means no limit or infinite limit */
01184         Olimit = MAX_OLIMIT;
01185   }
01186   else if (Olimit < 10) {
01187         /* olimit too small to work properly */
01188         DevWarn("Olimit < 10 is too small; resetting to Olimit=10");
01189         Olimit = 10;
01190   }
01191   if (Opt_Level == 0 && ! Olimit_opt_Set)
01192         Olimit_opt = FALSE;
01193 
01194 #if !defined(SGI_FRONT_END_CPP) && !defined(QIKKI_BE)
01195   /* -OPT:rail or -OPT:rbi implies -OPT:compile_by_region
01196    * unless -OPT:compile_by_region=no is specified.
01197    */
01198   if (Regions_Around_Inner_Loops || Region_Boundary_Info)
01199     Set_PU_has_region (Get_Current_PU ());
01200 #endif /* !defined(SGI_FRONT_END_CPP) && !defined(QIKKI_BE) */
01201 
01202   /* Enable IEEE_arithmetic options */
01203   if (Opt_Level > 2 && !IEEE_Arith_Set) {
01204      IEEE_Arithmetic = IEEE_INEXACT;
01205   }
01206 
01207   Recip_Allowed = ARCH_recip_is_exact;
01208   /* IEEE arithmetic options: */
01209   if ( IEEE_Arithmetic > IEEE_ACCURATE ) {
01210     /* Minor roundoff differences for inexact results: */
01211     if ( ! Recip_Set )
01212       Recip_Allowed = IEEE_Arithmetic >= IEEE_INEXACT;
01213     if ( ! Rsqrt_Set )
01214       Rsqrt_Allowed = IEEE_Arithmetic >= IEEE_INEXACT;
01215     /* Potential non-IEEE results for exact operations: */
01216     if ( ! Div_Split_Set )
01217       Div_Split_Allowed = IEEE_Arithmetic >= IEEE_ANY;
01218   }
01219 
01220   /* Constant folding options: */
01221   if ( ! Roundoff_Set && Opt_Level > 2 ) {
01222     Roundoff_Level = ROUNDOFF_ASSOC;
01223   }
01224   if ( Roundoff_Level > ROUNDOFF_NONE ) {
01225 
01226     /* The following allow minor roundoff differences: */
01227     if ( ! Fast_Exp_Set )
01228       Fast_Exp_Allowed = Roundoff_Level >= ROUNDOFF_SIMPLE;
01229 
01230     /* The following allows folding of intrinsics with constant arguments: */
01231     if ( ! Cfold_Intrinsics_Set )
01232       Enable_Cfold_Intrinsics = Roundoff_Level >= ROUNDOFF_SIMPLE;
01233 
01234     /* The following allows arbitrary reassociation: */
01235     if ( ! Cfold_Reassoc_Set )
01236       Enable_Cfold_Reassociate = Roundoff_Level >= ROUNDOFF_ASSOC;
01237 
01238     /* reassociate in the lowerer to find MADD oportunities */
01239     if ( ! Enable_NaryExpr_Set )
01240       Enable_NaryExpr = Roundoff_Level >= ROUNDOFF_ASSOC;
01241 
01242     if (!Fast_Complex_Set)
01243       Fast_Complex_Allowed = Roundoff_Level >= ROUNDOFF_ANY;
01244     if (!Fast_NINT_Set)
01245       Fast_NINT_Allowed = Roundoff_Level >= ROUNDOFF_ANY;
01246     if (!Fast_trunc_Set)
01247       Fast_trunc_Allowed = Roundoff_Level >= ROUNDOFF_SIMPLE;
01248 
01249     if ( ! CIS_Set )
01250       CIS_Allowed |= Roundoff_Level >= ROUNDOFF_SIMPLE;
01251   }
01252 
01253 #if 0
01254   /* Set the relational operator folding in simplifier based on the optimizer
01255      setting of Allow_wrap_around_opt */
01256   if (!Simp_Unsafe_Relops_Set && Allow_wrap_around_opt_Set) {
01257      Simp_Unsafe_Relops = Allow_wrap_around_opt;
01258   }
01259   if (!Allow_wrap_around_opt_Set && Simp_Unsafe_Relops_Set ) {
01260      Allow_wrap_around_opt = Simp_Unsafe_Relops;
01261   }
01262 #endif
01263   if (!Simp_Unsafe_Relops_Set && Opt_Level > 2) {
01264      Simp_Unsafe_Relops = TRUE;
01265   }
01266   
01267   Enable_GDSE    = ((Opt_Level > 1) &&
01268                     (!Get_Trace(TP_GLOBOPT, 4096))
01269                     );
01270   /* The lowerer will do a simple treeheight reduction for
01271    * binary commutative ops
01272    */
01273   if (!OPT_Lower_Treeheight_Set)
01274      OPT_Lower_Treeheight = (Opt_Level > 1);
01275 
01276   /* Perform host-specific and target-specific configuration: */
01277 
01280   Configure_Source_Host ( filename );
01281   Configure_Source_Target ( filename );
01282 
01283   /* Set eagerness-level-based information.  This must come after the
01284    * call to Configure_Source_Target, since that routine sets the
01285    * FP exception enable masks.
01286    */
01287   if ( ! Eager_Level_Set && Opt_Level > 2 ) {
01288     Eager_Level = EAGER_ARITH;
01289   }
01290   if ( Eager_Level >= EAGER_ARITH ) {
01291     FP_Exception_Enable_Max &= ~(FPX_I|FPX_U|FPX_O|FPX_V);
01292   }
01293   if ( Eager_Level >= EAGER_DIVIDE ) {
01294     FP_Exception_Enable_Max &= ~FPX_Z;
01295   }
01296   if ( Eager_Level >= EAGER_MEMORY ) {
01297     Force_Memory_Dismiss = TRUE;
01298   }
01299 
01300 #ifdef BACK_END
01301   /* Configure the -LNO group: */
01302   LNO_Configure ();
01303 #endif /* BACK_END */
01304 
01305   /* Trace options: */
01306   if ( Get_Trace ( TP_MISC, 128 ) ) {
01307     Trace_Option_Groups ( TFile, Common_Option_Groups, TRUE );
01308   } else if ( Get_Trace ( TP_MISC, 32 ) ) {
01309     Trace_Option_Groups ( TFile, Common_Option_Groups, FALSE );
01310   }
01311 }
01312 
01313 /* ====================================================================
01314  *
01315  * Configure_Alias_Options
01316  *
01317  * Configure the options related to alias analysis.
01318  *
01319  * ====================================================================
01320  */
01321 
01322 void
01323 Configure_Alias_Options( OPTION_LIST *olist )
01324 {
01325   OPTION_LIST *ol;
01326   for (ol = olist; ol != NULL; ol = OLIST_next(ol)) {
01327     char *val = OLIST_val(ol);
01328     INT len = strlen (val);
01329     if (ux_strncasecmp( val, "any", len) == 0) {
01330       Alias_Pointer_Parms = TRUE;       /* observed by Fortran programs */
01331       Alias_Pointer_Cray = FALSE;       /* observed by Fortran programs */
01332       Alias_Pointer_Types = TRUE;       /* observed by C and C++ programs */
01333       Alias_Not_In_Union  = TRUE;       /* observed by C++ programs only */
01334       Alias_Pointer_Strongly_Typed = FALSE;     /* observed by C and C++ programs */
01335       Alias_Pointer_Types_Set = TRUE;
01336       Alias_Not_In_Union_Set  = TRUE;   /* observed by C++ programs only */
01337       Alias_Pointer_Named_Data = FALSE; /* observed by C and C++ programs */
01338       Alias_Pointer_Restricted = FALSE; /* observed by C and C++ programs */
01339       Alias_Pointer_Disjoint   = FALSE;
01340     } else if (ux_strncasecmp( val, "parm", len) == 0) {
01341       Alias_Pointer_Parms = TRUE;
01342     } else if (ux_strncasecmp( val, "typed", len) == 0) {
01343       Alias_Pointer_Types = TRUE;
01344       Alias_Pointer_Types_Set = TRUE;
01345     } else if (ux_strncasecmp( val, "unnamed", len) == 0) {
01346       Alias_Pointer_Named_Data = TRUE;
01347     } else if (ux_strncasecmp( val, "nounion",len) == 0) {
01348       Alias_Not_In_Union  = TRUE;       /* observed by C++ programs only */
01349       Alias_Not_In_Union_Set  = TRUE;   /* observed by C++ programs only */
01350     } else if (ux_strncasecmp( val, "restricted", len) == 0) {
01351       Alias_Pointer_Restricted = TRUE;
01352       Alias_Pointer_Named_Data = TRUE;
01353     } else if (ux_strncasecmp( val, "disjoint", len) == 0) {
01354       Alias_Pointer_Disjoint = TRUE;
01355       Alias_Pointer_Restricted = TRUE;
01356       Alias_Pointer_Named_Data = TRUE;
01357     } else if (ux_strncasecmp( val, "cray_pointer", len) == 0) {
01358       Alias_Pointer_Cray = TRUE;
01359     } else if (ux_strncasecmp( val, "strongly_typed", len) == 0) {
01360       Alias_Pointer_Strongly_Typed = TRUE;
01361     } else if (ux_strncasecmp( val, "no_parm", len) == 0) {
01362       Alias_Pointer_Parms = FALSE;
01363     } else if (ux_strncasecmp( val, "no_typed", len) == 0) {
01364       Alias_Pointer_Types = FALSE;
01365       Alias_Pointer_Types_Set = TRUE;
01366     } else if (ux_strncasecmp( val, "no_unnamed", len) == 0) {
01367       Alias_Pointer_Named_Data = FALSE;
01368     } else if (ux_strncasecmp( val, "no_restricted", len) == 0) {
01369       Alias_Pointer_Restricted = FALSE;
01370       Alias_Pointer_Named_Data = FALSE;
01371     } else if (ux_strncasecmp( val, "no_disjoint", len) == 0) {
01372       Alias_Pointer_Disjoint = FALSE;
01373       Alias_Pointer_Named_Data = FALSE;
01374     } else if (ux_strncasecmp( val, "no_cray_pointer", len) == 0) {
01375       Alias_Pointer_Cray = FALSE;
01376     } else if (ux_strncasecmp( val, "no_strongly_typed", len) == 0) {
01377       Alias_Pointer_Strongly_Typed = FALSE;
01378     } else if (ux_strncasecmp( val, "cckr_default", len) == 0) {
01379       Alias_Pointer_Cckr = TRUE;
01380     } else if (ux_strncasecmp( val, "common_scalar", len) == 0) {
01381       Alias_Common_Scalar = TRUE;
01382     } else if (ux_strncasecmp( val, "no_common_scalar", len) == 0) {
01383       Alias_Common_Scalar = FALSE;
01384     } else if (ux_strncasecmp( val, "no_f90_pointer_alias", len) == 0) {
01385       Alias_F90_Pointer_Unaliased = TRUE;
01386     } else if (ux_strncasecmp( val, "f90_pointer_alias", len) == 0) {
01387       Alias_F90_Pointer_Unaliased = FALSE;
01388     } else {
01389       ErrMsg ( EC_Inv_OPT, "alias", val );
01390     }
01391   }
01392 
01393   /* If we didn't explicitly set alias=typed, and this is a -cckr
01394    * compilation, turn off Alias_Pointer_Types:
01395    */
01396   if ( ! Alias_Pointer_Types_Set && Alias_Pointer_Cckr ) {
01397     Alias_Pointer_Types = FALSE;
01398   }
01399 }
01400 
01401 /* ====================================================================
01402  *
01403  * SKIPLIST
01404  *
01405  * Support for lists of PU numbers to skip (e.g. for optimization)
01406  * based on options in a command line group.  A typedef for SKIPLIST
01407  * is defined in config.h, but the type is opaque outside; for now,
01408  * Build_Skiplist and Query_Skiplist are the only visible interface.
01409  *
01410  * This interface is sufficiently generic that it could go into flags.*
01411  * in common/util.  It isn't there because that could end up breaking
01412  * the principle that flags.h should not be widely included (i.e. other
01413  * than by command line processing).
01414  *
01415  * ====================================================================
01416  */
01417 
01418 typedef enum {
01419   SK_NONE,      /* End of list */
01420   SK_AFTER,     /* Values after this one */
01421   SK_BEFORE,    /* Values before this one */
01422   SK_EQUAL      /* Just this one */
01423 } SKIPKIND;
01424 
01425 struct skiplist {
01426   mINT32 size;  /* Number of elements */
01427   mINT8 *kind;  /* Array of kinds */
01428   mINT32 *val;  /* Array of values */
01429 };
01430 
01431 #define SKIPLIST_size(sl)               ((sl)->size)
01432 #define SKIPLIST_kind_vec(sl)           ((sl)->kind)
01433 #define SKIPLIST_kind(sl,i)             ((SKIPKIND)((sl)->kind[i]))
01434 #define Set_SKIPLIST_kind(sl,i,v)       (((sl)->kind[i]) = (mINT8)(v))
01435 #define SKIPLIST_val_vec(sl)            ((sl)->val)
01436 #define SKIPLIST_val(sl,i)              ((sl)->val[i])
01437 
01438 /* ====================================================================
01439  *
01440  * Print_Skiplist
01441  *
01442  * Print a skiplist.  
01443  *
01444  * ====================================================================
01445  */
01446 
01447 static void
01448 Print_Skiplist ( FILE *tf, SKIPLIST *skip, char *lab )
01449 {
01450   INT32 i;
01451 
01452   if ( skip == NULL ) {
01453     fprintf ( tf, "SKIPLIST %s empty\n", lab );
01454     return;
01455   }
01456   fprintf ( tf, "SKIPLIST %s:\n", lab );
01457 
01458   for ( i = 0; SKIPLIST_kind(skip,i) != SK_NONE; i++ ) {
01459     switch ( SKIPLIST_kind(skip,i) ) {
01460       case SK_EQUAL:
01461         fprintf ( tf, "  equal %d\n", SKIPLIST_val(skip,i) );
01462         break;
01463       case SK_AFTER:
01464         fprintf ( tf, "  after %d\n", SKIPLIST_val(skip,i) );
01465         break;
01466       case SK_BEFORE:
01467         fprintf ( tf, "  before %d\n", SKIPLIST_val(skip,i) );
01468         break;
01469     }
01470   }
01471   fprintf ( tf, "SKIPLIST %s end\n\n", lab );
01472 }
01473 
01474 /* ====================================================================
01475  *
01476  * Build_Skiplist
01477  *
01478  * Build a skiplist from a group option list.  For now, we assume that
01479  * the only choices are skip_a* (after) skip_b* (before), and skip_e*
01480  * (equal).  See Query_Skiplist below for the list semantics.
01481  *
01482  * Note that we interpret skip_equal=1,3-5,7-10,12,35-39 as you might
01483  * hope.
01484  *
01485  * WARNING:  This routine does no error checking.  This option is for
01486  * internal use, and if the syntax is wrong, strange (non-fatal) things
01487  * may happen (typically ignoring the rest of the option).
01488  *
01489  * ====================================================================
01490  */
01491 
01492 SKIPLIST *
01493 Build_Skiplist ( OPTION_LIST *olist )
01494 {
01495   INT32 count = 0;
01496   OPTION_LIST *ol;
01497   SKIPLIST *sl;
01498   BOOL list_found = FALSE;
01499   char *p;
01500 
01501   /* Count the elements: */
01502   if ( olist == NULL ) return NULL;
01503   for ( ol = olist; ol != NULL; ol = OLIST_next(ol) ) {
01504 
01505     /* At least one entry: */
01506     ++count;
01507     
01508     /* Check for commas and ranges: */
01509     p = OLIST_val(ol);
01510     while ( *p != ':' && *p != 0 ) {
01511       if ( *p == ',' || *p == '-' ) {
01512         ++count;
01513         list_found = TRUE;
01514       }
01515       ++p;
01516     }
01517   }
01518 
01519   /* Allocate the skiplist: */
01520   sl = (SKIPLIST *) malloc ( sizeof(SKIPLIST) );
01521   SKIPLIST_size(sl) = count+1;
01522   SKIPLIST_kind_vec(sl) = (mINT8 *) calloc ( sizeof(mINT8), count+1 );
01523   SKIPLIST_val_vec(sl) = (mINT32 *) calloc ( sizeof(mINT32), count+1 );
01524 
01525   /* Fill the skiplist: */
01526   for ( count = 0, ol = olist;
01527         ol != NULL;
01528         ++count, ol = OLIST_next(ol) )
01529   {
01530     if ( !strncmp ( "skip_a", OLIST_opt(ol), 6 ) ||
01531          !strncmp ( "region_skip_a", OLIST_opt(ol), 13 ) ) {
01532       Set_SKIPLIST_kind ( sl, count, SK_AFTER );
01533     } else if ( !strncmp ( "skip_b", OLIST_opt(ol), 6 ) ||
01534                 !strncmp ( "region_skip_b", OLIST_opt(ol), 13 ) ) {
01535       Set_SKIPLIST_kind ( sl, count, SK_BEFORE );
01536     } else {
01537       Set_SKIPLIST_kind ( sl, count, SK_EQUAL );
01538     }
01539     SKIPLIST_val(sl,count) = atoi ( OLIST_val(ol) );
01540 
01541     /* If this is skip_equal, look for a list... */
01542     if ( list_found && SKIPLIST_kind(sl,count) == SK_EQUAL ) {
01543       p = OLIST_val(ol);
01544       while ( *p >= '0' && *p <= '9' ) ++p;
01545       if ( *p == '-' ) {
01546         Set_SKIPLIST_kind ( sl, count, SK_AFTER );
01547         --SKIPLIST_val(sl,count);
01548         ++p;
01549         ++count;
01550         Set_SKIPLIST_kind ( sl, count, SK_BEFORE );
01551         SKIPLIST_val(sl,count) = 1 + atoi ( p );
01552         while ( *p >= '0' && *p <= '9' ) ++p;
01553       }
01554       while ( *p++ == ',' ) {
01555         ++count;
01556         Set_SKIPLIST_kind ( sl, count, SK_EQUAL );
01557         SKIPLIST_val(sl,count) = atoi ( p );
01558         while ( *p >= '0' && *p <= '9' ) ++p;
01559         if ( *p == '-' ) {
01560           Set_SKIPLIST_kind ( sl, count, SK_AFTER );
01561           --SKIPLIST_val(sl,count);
01562           ++p;
01563           ++count;
01564           Set_SKIPLIST_kind ( sl, count, SK_BEFORE );
01565           SKIPLIST_val(sl,count) = 1 + atoi ( p );
01566           while ( *p >= '0' && *p <= '9' ) ++p;
01567         }
01568       }
01569     }
01570   }
01571   Set_SKIPLIST_kind ( sl, count, SK_NONE );
01572 
01573   if ( Get_Trace ( TP_MISC, 0x80 ) ) {
01574     Print_Skiplist ( TFile, sl, "Build_Skiplist" );
01575   }
01576 
01577   return sl;
01578 }
01579 
01580 /* ====================================================================
01581  *
01582  * Query_Skiplist
01583  *
01584  * Query a skiplist.  A TRUE result means that the element passed is in
01585  * the skiplist.  The semantics of the list is as follows:  Return TRUE
01586  * if elmt is equal to an SK_EQUAL element of the list.  Return TRUE if
01587  * elmt is greater than an SK_AFTER element AND it is less than an
01588  * immediately following SK_BEFORE element; otherwise skip over the
01589  * following SK_BEFORE element.  Return TRUE if elmt is smaller than an
01590  * SK_BEFORE which does not immediately follow an SK_AFTER.  If nothing
01591  * on the list produces a TRUE result, return FALSE.  That is, a list
01592  * consists of SK_EQUAL elements, SK_AFTER/SK_BEFORE pairs in that
01593  * order, or SK_AFTER and SK_BEFORE elements that aren't in such pairs.
01594  * Any match of one of these tests causes a skip.
01595  *
01596  * ====================================================================
01597  */
01598 
01599 BOOL
01600 Query_Skiplist ( SKIPLIST *skip, INT32 elmt )
01601 {
01602   INT32 i;
01603   BOOL ok;
01604 
01605   if ( skip == NULL ) return FALSE;
01606 
01607   for ( i = 0; SKIPLIST_kind(skip,i) != SK_NONE; i++ ) {
01608     switch ( SKIPLIST_kind(skip,i) ) {
01609       case SK_EQUAL:
01610         /* printf ( "<skip> equal %d ? %d\n", SKIPLIST_val(skip,i), elmt ); */
01611         if ( SKIPLIST_val(skip,i) == elmt ) return TRUE;
01612         break;
01613       case SK_AFTER:
01614         ok = ( SKIPLIST_val(skip,i) < elmt );
01615         /* printf ( "<skip> after %d ? %d\n", SKIPLIST_val(skip,i), elmt ); */
01616         if ( SKIPLIST_kind(skip,i+1) == SK_BEFORE 
01617           && SKIPLIST_val(skip,i+1) > SKIPLIST_val(skip,i)) 
01618         {
01619           if ( SKIPLIST_val(skip,++i) <= elmt ) ok = FALSE;
01620         }
01621         if ( ok ) return TRUE;
01622         break;
01623       case SK_BEFORE:
01624         /* printf ( "<skip> before %d ? %d\n", SKIPLIST_val(skip,i), elmt ); */
01625         if ( SKIPLIST_val(skip,i) > elmt ) return TRUE;
01626         break;
01627     }
01628   }
01629   return FALSE;
01630 }
01631 
01632 /* ====================================================================
01633  *
01634  * Process_Trace_Option
01635  *
01636  * Given a trace option -t..., process it.  The caller should already
01637  * have determined that it cannot be anything else.  The option should
01638  * be the full option string, with leading -t... (for error messages).
01639  * such options may be catenated, except for those which take name
01640  * operands which can't be delimited, which must be last.
01641  *
01642  * ====================================================================
01643  */
01644 
01645 BOOL
01646 Process_Trace_Option ( char *option )
01647 {
01648   char *cp = option+1;
01649   INT32 phase;
01650 
01651   Tracing_Enabled = TRUE;
01652 
01653   while ( cp && *cp == 't' ) {
01654     cp += 2;
01655 
01656     switch ( *(cp-1) ) {
01657     case 'a':
01658         Set_Trace (TKIND_ALLOC,
01659                    Get_Trace_Phase_Number ( &cp, option ) );
01660         break;
01661 
01662     case 'b':
01663         Set_Trace (TKIND_BB,
01664                    Get_Numeric_Flag (&cp, 0, 32767, 0, option));
01665         break;
01666 
01667     case 'c':
01668         Set_Trace (TKIND_CTRL,
01669                    Get_Numeric_Flag (&cp, 0, 32767, 0, option));
01670         break;
01671 
01672     case 'd':
01673         Set_Trace (TKIND_DEBUG,
01674                    Get_Numeric_Flag (&cp, 1, 32767, 0, option));
01675         break;
01676 
01677     /* ex: -Wb,-tf0 for function 0 in the file */
01678     case 'f':
01679         if ( isdigit (*cp) ) {
01680           Set_Trace_Pu_Number (
01681               Get_Numeric_Flag (&cp, 0, 0x7fffffff, 0, option) );
01682         } else {
01683           Set_Trace_Pu ( cp );
01684           cp = 0;               /* Done with this flag */
01685         }
01686         break;
01687 
01688     /* ex: -Wb,-tg1 for region 1 in each function (best when used with -tf) */
01689     case 'g':
01690         if ( isdigit (*cp) ) {
01691           Set_Trace_Region_Number (
01692               Get_Numeric_Flag (&cp, 0, 0x7fffffff, 0, option) );
01693         } else
01694           Is_True(FALSE,("Process_Trace_Option: regions don't have names"));
01695         break;
01696 
01697     case 'i':
01698         Set_Trace (TKIND_INFO,
01699                    Get_Numeric_Flag (&cp, 1, 32767, 0, option));
01700         break;
01701 
01702     case 'n':
01703         Set_Trace (TKIND_TN,
01704                    Get_Trace_Phase_Number ( &cp, option ) );
01705         break;
01706     
01707     case 'p':
01708         phase = Get_Trace_Phase_Number ( &cp, option );
01709         if ( phase != 0 && (*cp == ',' || *cp == '\0'))
01710           Set_Trace (TKIND_XPHASE, phase);
01711         break;
01712     
01713     case 'r':
01714         Set_Trace (TKIND_IR,
01715                    Get_Trace_Phase_Number ( &cp, option ) );
01716         break;
01717 
01718     case 's':
01719         Set_Trace (TKIND_SYMTAB,
01720                    Get_Trace_Phase_Number ( &cp, option ) );
01721         Symbol_Table_Out = TRUE;
01722         break;
01723 
01724     case 't':
01725         phase = Get_Trace_Phase_Number ( &cp, option );
01726         if ( *cp != ',' && *cp != ':' ) {
01727             ErrMsg ( EC_Trace_Flag, *cp, option );
01728             break;
01729         }
01730         cp++;       /* skip separator */
01731         Set_Trace (phase,
01732                    Get_Numeric_Flag (&cp, 1, 0xffffffff, 0,
01733                                      option));
01734         break;
01735 
01736 #ifdef FRONT_END
01737     case 'v':
01738         {
01739           /* Used by the EDG front ends to control tracing verbosity: */
01740           extern BOOL trace_verbose;    /* Type must match a_boolean */
01741           trace_verbose = TRUE;
01742         }
01743         break;
01744 #endif
01745 
01746     case 0:   
01747         ErrMsg ( EC_Trace_Flag, '?', option );
01748         return FALSE;
01749 
01750     default:
01751         --cp;
01752         ErrMsg ( EC_Trace_Flag, *cp, option );
01753         return FALSE;
01754     }
01755 
01756   }
01757 
01758   if ( cp && *cp != 0 ) {
01759     ErrMsg ( EC_Trace_Flag, '?', option );
01760     return FALSE;
01761   }
01762   return TRUE;
01763 
01764 }
01765 
01766 /* ====================================================================
01767  *
01768  * List_Compile_Options
01769  *
01770  * List options to the given file.  This is primarily an interface to
01771  * the flags.c routine Print_Option_Groups, but also prints a number of
01772  * non-group options.  The "internal" flag indicates whether to list
01773  * internal-only options.  The "full" flag indicates whether to list
01774  * all options if "internal" is set; otherwise option group listing
01775  * is controlled by List_Options and List_All_Options.
01776  *
01777  * ====================================================================
01778  */
01779 
01780 void
01781 List_Compile_Options (
01782   FILE *f,
01783   char *pfx,
01784   BOOL internal,
01785   BOOL full,
01786   BOOL update )
01787 {
01788   char *bar = SBar+12;  /* Shorten it a bit */
01789 
01790   fprintf ( f, "\n%s%s%s Compiling %s (%s)\n%s%s",
01791             pfx, bar, pfx, Src_File_Name, Irb_File_Name, pfx, bar ); 
01792   fprintf ( f, "\n%s%s%s Options:\n%s%s", pfx, bar, pfx, pfx, bar );
01793 
01794   fprintf ( f, "%s  Target:%s, ISA:%s, Pointer Size:%d\n",
01795             pfx, Targ_Name (Target), Isa_Name (Target_ISA),
01796             (Use_32_Bit_Pointers ? 32 : 64) );
01797   fprintf ( f, "%s  -O%d\t(Optimization level)\n", pfx, Opt_Level );
01798   fprintf ( f, "%s  -g%d\t(Debug level)\n", pfx, Debug_Level );
01799   
01800   if ( Min_Error_Severity == ES_ADVISORY )
01801       fprintf ( f, "%s  -m2\t(Report advisories)\n", pfx );
01802   else if ( Min_Error_Severity == ES_WARNING )
01803       fprintf ( f, "%s  -m1\t(Report warnings)\n", pfx );
01804   else
01805       fprintf ( f, "%s  -m0\t(Report errors only)\n", pfx );
01806   
01807   fprintf ( f, "%s%s\n", pfx, bar );
01808 
01809   if ( internal || List_Options ) {
01810     fprintf ( f, "%s Group options are marked with '#' if changed,\n"
01811                  "%s or with '=' if explicitly set to default value.\n",
01812               pfx, pfx );
01813     Print_Option_Groups ( f, Common_Option_Groups, pfx, internal,
01814                           internal ? full : List_All_Options , update );
01815   }
01816 }
01817 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines