00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifdef _KEEP_RCS_ID
00058
00059 #endif
00060
00061
00062 #define USE_STANDARD_TYPES 1
00063 #include "defs.h"
00064 #undef USE_STANDARD_TYPES
00065
00066 #ifdef FRONT_END
00067 # ifndef FRONT_F90
00068 # ifdef EDGSRC
00069 # include "basics.h"
00070 # include "cmd_line.h"
00071 # include "error.h"
00072 # endif
00073 # endif
00074 #endif
00075 #include <ctype.h>
00076 #include <elf.h>
00077
00078 #include "x_string.h"
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
00095
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
00115 #ifdef SINGLE_PROCESS
00116 INT16 In_Front_End = TRUE;
00117 #endif
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 BOOL Enable_LOH = FALSE;
00128 BOOL Enable_LOH_overridden = FALSE;
00129 BOOL CSE_Elim_Enabled = FALSE;
00130
00131
00132
00133
00134 #ifdef BACK_END
00135 # define DEF_DEBUG_LEVEL 0
00136 INT8 Debug_Level = DEF_DEBUG_LEVEL;
00137 #endif
00138
00139
00140
00141 BOOL UseAlignedCopyForStructs = FALSE;
00142 INT32 MinStructCopyLoopSize = 16;
00143 INT32 MinStructCopyMemIntrSize= 0;
00144 INT32 Aggregate_Alignment = -1;
00145
00146 INT32 iolist_reuse_limit = 100;
00147
00148
00149 BOOL Ptr_Opt_Allowed = FALSE;
00150
00151
00152 BOOL Zeroinit_in_bss = TRUE;
00153
00154
00155 BOOL Strings_Not_Gprelative = FALSE;
00156
00157
00158 IEEE_LEVEL IEEE_Arithmetic = IEEE_ACCURATE;
00159 BOOL IEEE_Arith_Set = FALSE;
00160
00161
00162
00163
00164 EAGER_LEVEL Eager_Level = EAGER_SAFE;
00165 static BOOL Eager_Level_Set = FALSE;
00166
00167
00168 ROUNDOFF Roundoff_Level = ROUNDOFF_NONE;
00169 BOOL Roundoff_Set = FALSE;
00170 BOOL Fast_Complex_Allowed = FALSE;
00171 BOOL Fast_Complex_Set = FALSE;
00172 BOOL Fast_Bit_Allowed = FALSE;
00173 BOOL Fast_Bit_Set = FALSE;
00174 BOOL Fast_NINT_Allowed = FALSE;
00175 BOOL Fast_NINT_Set = FALSE;
00176 BOOL Fast_trunc_Allowed = FALSE;
00177 BOOL Fast_trunc_Set = FALSE;
00178 BOOL Inline_Intrinsics_Allowed = TRUE;
00179 BOOL Inline_Intrinsics_Set = FALSE;
00180 BOOL Regions_Around_Inner_Loops = FALSE;
00181 BOOL Region_Boundary_Info = FALSE;
00182 BOOL Simp_Multiply_To_Shift=FALSE;
00183 BOOL Enable_NaryExpr= FALSE;
00184 BOOL Enable_NaryExpr_Set = FALSE;
00185
00186
00187 static char *Language_Name = NULL;
00188 LANGUAGE Language = LANG_UNKNOWN;
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
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
00269 INT32 Heap_Allocation_Threshold=-1;
00270
00271
00272
00273
00274
00275 INT32 Short_Data = DEF_SDATA_ELT_SIZE;
00276 static BOOL Short_Data_Set = FALSE;
00277 INT32 Short_Lits = DEF_SDATA_ELT_SIZE;
00278 static BOOL Short_Lits_Set = FALSE;
00279 INT32 Max_Sdata_Elt_Size = DEF_SDATA_ELT_SIZE;
00280 BOOL Constant_GP = FALSE;
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 static BOOL Use_Small_GOT = FALSE;
00297 static BOOL Use_Large_GOT = FALSE;
00298 INT32 Gspace_Available = DEFAULT_GSPACE;
00299
00300
00301 BOOL Force_Long_EH_Range_Offsets = FALSE;
00302
00303 BOOL Force_Large_Stack_Model = FALSE;
00304 BOOL Force_GP_Prolog;
00305
00306 OPTION_LIST *Registers_Not_Allocatable = NULL;
00307
00308
00309 INT32 Ipa_Ident_Number = 0;
00310
00311 BOOL Indexed_Loads_Allowed = FALSE;
00312
00313
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
00404
00405 { OVK_INT32, OV_INTERNAL, FALSE, "check_div", "check_div",
00406 1, 0, 3, &Initial_DEBUG.div_check, &Initial_DEBUG.div_check_set },
00407
00408 { OVK_BOOL, OV_INTERNAL, FALSE, "trapuv", "",
00409 0, 0, 0, &Initial_DEBUG.trap_uv, &Initial_DEBUG.trap_uv_set },
00410
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
00416
00417 { OVK_REPLACED, OV_INTERNAL, FALSE, "varargs_prototypes", "varargs_p",
00418 0, 0, 0,
00419 const_cast<char*>("-DEBUG:varargs_prototypes"), NULL },
00420
00421
00422 {
00423 OVK_OBSOLETE, OV_INTERNAL, FALSE, "align_extern", NULL,
00424 0, 0, 16, NULL, NULL,
00425 "Assume this alignment for unknown objects" },
00426 {
00427 OVK_OBSOLETE, OV_SHY, FALSE, "aligned", NULL,
00428 0, 0, 0, NULL, NULL,
00429 "Assume unknown objects are properly aligned" },
00430 {
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 }
00438 };
00439
00440 #ifdef BACK_END
00441
00442
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
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 }
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 }
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
00646 #if defined(BACK_END) || defined(QIKKI_BE)
00647 { "PHASE", ':', '=', Options_PHASE, NULL,
00648 "Options to control phase invocation and locations" },
00649 #endif
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 }
00667 };
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677 BOOL Use_C_Like_Logicals = TRUE;
00678
00679
00680 BOOL Allow_Exceptions = TRUE;
00681
00682
00683 BOOL Tracing_Enabled = FALSE;
00684
00685
00686
00687 BOOL Idict_Commutable_Match = FALSE;
00688 BOOL Scalar_Formal_Ref = TRUE;
00689 BOOL Non_Scalar_Formal_Ref = FALSE;
00690
00691 BOOL CG_mem_intrinsics = TRUE;
00692 INT32 CG_memmove_inst_count = 16;
00693 BOOL CG_memmove_inst_count_overridden = FALSE;
00694 BOOL CG_bcopy_cannot_overlap = FALSE;
00695 BOOL CG_memcpy_cannot_overlap = FALSE;
00696 BOOL CG_memmove_cannot_overlap = FALSE;
00697 BOOL CG_memmove_nonconst = FALSE;
00698
00699
00700 INT32 Opt_Level = DEF_OPT_LEVEL;
00701 INT32 OPT_unroll_times = 4;
00702 BOOL OPT_unroll_times_overridden = FALSE;
00703 INT32 OPT_unroll_size = 40;
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;
00709 BOOL Enable_SWP_overridden = FALSE;
00710
00711
00712 UINT8 Host_Byte_Sex = BIG_ENDIAN;
00713 UINT8 Target_Byte_Sex = BIG_ENDIAN;
00714 BOOL Same_Byte_Sex = TRUE;
00715
00716
00717 BOOL Use_Base_Ptrs = TRUE;
00718 BOOL Gen_PIC_Call_Shared = FALSE;
00719 BOOL Gen_PIC_Shared = FALSE;
00720 BOOL Gen_PIC_Calls = FALSE;
00721 BOOL Guaranteed_Small_GOT = TRUE;
00722 BOOL Non_Volatile_GOT = FALSE;
00723 BOOL PIC_Local_Names = FALSE;
00724 BOOL PIC_Protected_Names = FALSE;
00725 BOOL PIC_Fixed_Addresses = FALSE;
00726 BOOL PIC_No_Page_Offset = FALSE;
00727 BOOL Force_Mem_Formals = FALSE;
00728 BOOL Kernel_Code = FALSE;
00729 BOOL Varargs_Prototypes = TRUE;
00730 BOOL Gen_Profile = FALSE;
00731 char *Gen_Profile_Name = "__profile_call";
00732 BOOL Call_Mcount = FALSE;
00733 BOOL GP_Is_Preserved = FALSE;
00734
00735 char *Emit_Global_Data = NULL;
00736 char *Read_Global_Data = NULL;
00737
00738 char *Library_Name = NULL;
00739 INT target_io_library;
00740
00741 BOOL Meld_Schedule = FALSE;
00742 BOOL Gap_Schedule = FALSE;
00743 BOOL Attempt_Bypass = FALSE;
00744 BOOL Isolate_Lines = FALSE;
00745 BOOL Fill_Delay_Slots = FALSE;
00746 BOOL Enable_GDSE = FALSE;
00747 BOOL Enable_CG_Peephole =FALSE;
00748
00749 #ifdef BACK_END
00750
00751 BOOL Run_lno = FALSE;
00752 BOOL Run_wopt = FALSE;
00753 BOOL Run_preopt = FALSE;
00754 BOOL Run_ipl = FALSE;
00755 BOOL Run_cg = FALSE;
00756 BOOL Run_w2c = FALSE;
00757 BOOL Run_w2f = FALSE;
00758 BOOL Run_w2fc_early = FALSE;
00759 BOOL Run_purple = FALSE;
00760 BOOL Run_prompf = FALSE;
00761 char *LNO_Path = 0;
00762 char *WOPT_Path = 0;
00763 char *CG_Path = 0;
00764 char *Ipl_Path = 0;
00765 char *W2C_Path = 0;
00766 char *W2F_Path = 0;
00767 char *Purple_Path = 0;
00768 char *Prompf_Anl_Path = 0;
00769 WN_MAP Prompf_Id_Map = WN_MAP_UNDEFINED;
00770
00771 #endif
00772 char *Inline_Path = 0;
00773 #if defined(BACK_END) || defined(QIKKI_BE)
00774 char *Targ_Path = 0;
00775 #endif
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786 void
00787 Preconfigure (void)
00788 {
00789 OPTION_GROUP *og;
00790
00791
00792 Preconfigure_Host ();
00793 Preconfigure_Target ();
00794
00795
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" );
00800 Set_Option_Internal ( og, "mips1" );
00801 Set_Option_Internal ( og, "mips2" );
00802 Set_Option_Internal ( og, "mips3" );
00803 Set_Option_Internal ( og, "mips4" );
00804 Set_Option_Internal ( og, "mips5" );
00805 Set_Option_Internal ( og, "mips6" );
00806
00807 og = Get_Command_Line_Group ( Common_Option_Groups, "TENV" );
00808 Set_Option_Internal ( og, "pic1" );
00809 Set_Option_Internal ( og, "pic2" );
00810
00811 #ifdef BACK_END
00812
00813 og = Get_Command_Line_Group ( Common_Option_Groups, "PHASE" );
00814 Set_Option_Internal ( og, NULL );
00815
00816
00817
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
00825 }
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838 static void
00839 Configure_Platform ( char *platform_name )
00840 {
00841 PLATFORM_OPTIONS *popts;
00842
00843
00844
00845
00846 if ( Platform != IP0
00847 && ( platform_name == NULL || *platform_name == 0 ) )
00848 {
00849 return;
00850 }
00851
00852
00853 popts = Get_Platform_Options ( platform_name );
00854 Platform = POPTS_id(popts);
00855
00856
00857 if ( Processor_Name == NULL ) {
00858 Processor_Name = POPTS_pname(popts);
00859 }
00860 }
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889 static void
00890 Configure_Ofast ( void )
00891 {
00892
00893
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
00907
00908
00909
00910
00911
00912
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
00929 Configure_Platform ( Ofast );
00930 }
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941 #ifdef KEEP_WHIRLSTATS
00942
00943 extern void whirlstats();
00944 #endif
00945
00946
00947 extern BOOL IR_set_dump_order (BOOL prefix);
00948
00949 void
00950 Configure (void)
00951 {
00952 static BOOL dev_warn_toggled = FALSE;
00953
00954 #if !defined(SGI_FRONT_END_CPP)
00955
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
00973
00974
00975 Configure_Alias_Options ( Alias_Option );
00976
00977
00978 if ( Platform_Name != NULL && *Platform_Name != 0 ) {
00979 Configure_Platform ( Platform_Name );
00980 }
00981
00982
00983 if ( Ofast != NULL ) {
00984 Configure_Ofast ();
00985 }
00986
00987
00988
00989 Configure_Host ();
00990 Configure_Target ();
00991
00992
00993
00994
00995
00996 if ( Use_Large_GOT && Use_Small_GOT ) {
00997
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
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
01013
01014
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
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
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044 void
01045 Configure_Source ( char *filename )
01047 {
01048
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
01066 DEBUG_Configure ();
01067 LIST_Configure ();
01068
01069
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
01078 if (Language == LANG_F90) {
01079 target_io_library = IOLIB_CRAY;
01080
01081 } else {
01082 target_io_library = IOLIB_MIPS;
01083 }
01084 }
01085
01086 #ifdef BACK_END
01087
01088
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
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
01110
01111 if ( Use_Large_GOT ) Guaranteed_Small_GOT = FALSE;
01112
01113
01114 if (Gen_PIC_Call_Shared && Gen_PIC_Shared) Gen_PIC_Shared = FALSE;
01115
01116
01117
01118
01119 Optimization_Skip_List = Build_Skiplist ( Opt_Skip );
01120
01121 Region_Skip_List = Build_Skiplist ( Region_Skip );
01122
01123
01124 if (!LANG_Recursive_Set && Language == LANG_F90)
01125 LANG_Recursive = TRUE;
01126
01127
01128
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
01139 if ( ! Enable_GOT_Call_overridden )
01140 Enable_GOT_Call_Conversion = Opt_Level > 2;
01141
01142
01143 Force_Mem_Formals = ( Opt_Level < 1 );
01144
01145
01146 if ( OPT_Space ) {
01147
01148
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
01154 INLINE_Max_Pu_Size=1000;
01155 #if 0
01156
01157 if (!OPT_Inline_Divide_Set) OPT_Inline_Divide = FALSE;
01158 #endif
01159
01160 #ifdef BACK_END
01161
01162 LNO_Outer_Unroll = 1;
01163 LNO_Split_Tiles = FALSE;
01164 #endif
01165 }
01166
01167
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
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
01184 Olimit = MAX_OLIMIT;
01185 }
01186 else if (Olimit < 10) {
01187
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
01196
01197
01198 if (Regions_Around_Inner_Loops || Region_Boundary_Info)
01199 Set_PU_has_region (Get_Current_PU ());
01200 #endif
01201
01202
01203 if (Opt_Level > 2 && !IEEE_Arith_Set) {
01204 IEEE_Arithmetic = IEEE_INEXACT;
01205 }
01206
01207 Recip_Allowed = ARCH_recip_is_exact;
01208
01209 if ( IEEE_Arithmetic > IEEE_ACCURATE ) {
01210
01211 if ( ! Recip_Set )
01212 Recip_Allowed = IEEE_Arithmetic >= IEEE_INEXACT;
01213 if ( ! Rsqrt_Set )
01214 Rsqrt_Allowed = IEEE_Arithmetic >= IEEE_INEXACT;
01215
01216 if ( ! Div_Split_Set )
01217 Div_Split_Allowed = IEEE_Arithmetic >= IEEE_ANY;
01218 }
01219
01220
01221 if ( ! Roundoff_Set && Opt_Level > 2 ) {
01222 Roundoff_Level = ROUNDOFF_ASSOC;
01223 }
01224 if ( Roundoff_Level > ROUNDOFF_NONE ) {
01225
01226
01227 if ( ! Fast_Exp_Set )
01228 Fast_Exp_Allowed = Roundoff_Level >= ROUNDOFF_SIMPLE;
01229
01230
01231 if ( ! Cfold_Intrinsics_Set )
01232 Enable_Cfold_Intrinsics = Roundoff_Level >= ROUNDOFF_SIMPLE;
01233
01234
01235 if ( ! Cfold_Reassoc_Set )
01236 Enable_Cfold_Reassociate = Roundoff_Level >= ROUNDOFF_ASSOC;
01237
01238
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
01255
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
01271
01272
01273 if (!OPT_Lower_Treeheight_Set)
01274 OPT_Lower_Treeheight = (Opt_Level > 1);
01275
01276
01277
01280 Configure_Source_Host ( filename );
01281 Configure_Source_Target ( filename );
01282
01283
01284
01285
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
01302 LNO_Configure ();
01303 #endif
01304
01305
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
01316
01317
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;
01331 Alias_Pointer_Cray = FALSE;
01332 Alias_Pointer_Types = TRUE;
01333 Alias_Not_In_Union = TRUE;
01334 Alias_Pointer_Strongly_Typed = FALSE;
01335 Alias_Pointer_Types_Set = TRUE;
01336 Alias_Not_In_Union_Set = TRUE;
01337 Alias_Pointer_Named_Data = FALSE;
01338 Alias_Pointer_Restricted = FALSE;
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;
01349 Alias_Not_In_Union_Set = TRUE;
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
01394
01395
01396 if ( ! Alias_Pointer_Types_Set && Alias_Pointer_Cckr ) {
01397 Alias_Pointer_Types = FALSE;
01398 }
01399 }
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418 typedef enum {
01419 SK_NONE,
01420 SK_AFTER,
01421 SK_BEFORE,
01422 SK_EQUAL
01423 } SKIPKIND;
01424
01425 struct skiplist {
01426 mINT32 size;
01427 mINT8 *kind;
01428 mINT32 *val;
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
01441
01442
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
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
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
01502 if ( olist == NULL ) return NULL;
01503 for ( ol = olist; ol != NULL; ol = OLIST_next(ol) ) {
01504
01505
01506 ++count;
01507
01508
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
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
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
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
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
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
01611 if ( SKIPLIST_val(skip,i) == elmt ) return TRUE;
01612 break;
01613 case SK_AFTER:
01614 ok = ( SKIPLIST_val(skip,i) < elmt );
01615
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
01625 if ( SKIPLIST_val(skip,i) > elmt ) return TRUE;
01626 break;
01627 }
01628 }
01629 return FALSE;
01630 }
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
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
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;
01685 }
01686 break;
01687
01688
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++;
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
01740 extern BOOL trace_verbose;
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
01769
01770
01771
01772
01773
01774
01775
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;
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