Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 00037 static char *source_file = __FILE__; 00038 00039 #include "x_string.h" // for strcasecmp(), strdup() 00040 00041 /* SGI includes */ 00042 #include "stamp.h" 00043 #include "defs.h" 00044 #include "config.h" 00045 #include "config_debug.h" 00046 #include "file_util.h" 00047 #include "flags.h" 00048 #include "glob.h" 00049 #include "tracing.h" 00050 #include "util.h" 00051 #include "wn.h" 00052 00053 #include "erglob.h" 00054 #include "erlib.h" 00055 #include "tracing.h" 00056 #include "err_host.tab" 00057 00058 /* conversion includes */ 00059 #include "sgi_cmd_line.h" 00060 #include "cwh_mkdepend.h" 00061 00062 /* Get the compiler build data */ 00063 extern char * mfef90_compiler_build_date; 00064 00065 #include <cmplrs/make_depend.h> 00066 #include <stdarg.h> 00067 #include <signal.h> 00068 00069 BOOL IO_Comments = TRUE; /* Emit I/O comments from lowerer */ 00070 BOOL Use_Three_Call= FALSE; 00071 00072 BOOL FE_Full_Split_Set = FALSE; 00073 BOOL FE_Full_Split = FALSE; 00074 BOOL FE_Endloop_Marker = FALSE; 00075 00076 static BOOL Matmul_Inline = FALSE; 00077 static BOOL Mv_Matmul_Inline = FALSE; 00078 static BOOL Matmul_Inline_Set = FALSE; 00079 static BOOL Mv_Matmul_Inline_Set = FALSE; 00080 00081 char *rii_file_name=NULL; 00082 BOOL enable_dsm_recompile = FALSE; 00083 BOOL enable_dsm_processing = FALSE; 00084 static BOOL enable_mp_processing = FALSE; 00085 00086 BOOL Full_arrayexp = TRUE; 00087 BOOL Full_arrayexp_set = FALSE; 00088 mUINT16 FE_align=8; 00089 00090 char *FE_gdar_filename = NULL; 00091 00092 INT32 global_chunk_pragma_value; 00093 BOOL global_chunk_pragma_set = FALSE; 00094 00095 INT32 global_schedtype_pragma_val; 00096 BOOL global_schedtype_pragma_set = FALSE; 00097 BOOL cleanUpWhirl = FALSE; 00098 00099 BOOL process_cri_mp_pragmas=FALSE; 00100 00101 BOOL disable_old_mp = FALSE; 00102 BOOL disable_open_mp = FALSE; 00103 00104 BOOL FE_Call_Never_Return = TRUE; 00105 00106 00107 /* 00108 * 00109 * Mempools 00110 * 00111 */ 00112 static MEM_POOL FE_Mempool_s; 00113 MEM_POOL *FE_Mempool=&FE_Mempool_s; 00114 00115 /* ==================================================================== 00116 * 00117 * Local data. 00118 * 00119 * ==================================================================== 00120 */ 00121 00122 /* MAX_DEBUG_LEVEL 2 :: Defined in flags.h */ 00123 # define DEF_DEBUG_LEVEL 0 00124 INT8 Debug_Level = DEF_DEBUG_LEVEL; /* -gn: debug level */ 00125 # define MAX_PROFILE_LEVEL 0 00126 # define DEF_PROFILE_LEVEL 0 00127 INT8 Profile_Level = DEF_PROFILE_LEVEL; /* -pn: profiling level */ 00128 # define MAX_MSG_LEVEL 2 00129 # define DEF_MSG_LEVEL 2 00130 00131 00132 00133 static OPTION_DESC Options_FE[] = { 00134 { OVK_NAME, OV_INTERNAL, FALSE, "cmdline", "cmdline", 00135 NULL, NULL, NULL, &FE_command_line, NULL }, 00136 { OVK_BOOL, OV_INTERNAL, FALSE, "iocomment", "ioc", 00137 0, 0, 0, &IO_Comments , NULL }, 00138 { OVK_BOOL, OV_INTERNAL, FALSE, "three_call", "three_call", 00139 0, 0, 0, &Use_Three_Call, NULL }, 00140 { OVK_BOOL, OV_INTERNAL, FALSE, "full_split", "full", 00141 0, 0, 0, &FE_Full_Split, &FE_Full_Split_Set }, 00142 { OVK_BOOL, OV_INTERNAL, FALSE, "arrayexp", "arrayexp", 00143 0, 0, 0, &Full_arrayexp, &Full_arrayexp_set }, 00144 { OVK_NAME, OV_INTERNAL, FALSE, "gdar", "gdar", 00145 NULL, NULL, NULL, &FE_gdar_filename, NULL }, 00146 { OVK_BOOL, OV_INTERNAL, FALSE, "endloop_markers", "endloop_marker", 00147 0, 0, 0, &FE_Endloop_Marker, NULL }, 00148 { OVK_BOOL, OV_INTERNAL, FALSE, "matmul_inline", "matmul_inline", 00149 0, 0, 0, &Matmul_Inline, &Matmul_Inline_Set }, 00150 { OVK_BOOL, OV_INTERNAL, FALSE, "mv_matmul_inline", "mv_matmul_inline", 00151 0, 0, 0, &Mv_Matmul_Inline, &Mv_Matmul_Inline_Set }, 00152 { OVK_BOOL, OV_INTERNAL, FALSE, "call_never_return", "call_never_return", 00153 0, 0, 0, &FE_Call_Never_Return, NULL }, 00154 00155 { OVK_COUNT, 0, FALSE, NULL, NULL, /* List terminator -- must be last */ 00156 0, 0, 0, NULL, NULL, NULL } 00157 }; 00158 00159 OPTION_GROUP FE_Option_Groups [] = { 00160 { "FE", ':', '=', Options_FE }, 00161 { NULL } /* List terminator -- must be last */ 00162 }; 00163 00164 00165 INT argc_cray; 00166 char **argv_cray; 00167 INT size_cray_argv; 00168 INT num_cray_args; 00169 00170 char **deferred_argv_cray; 00171 INT size_deferred_cray_argv; 00172 INT num_deferred_cray_args; 00173 00174 char **save_argv; 00175 INT save_argc; 00176 00177 static char *object_file_name=NULL; 00178 00179 static WN_PRAGMA_SCHEDTYPE_KIND 00180 identify_schedtype(char *text) 00181 { 00182 if (ux_strncasecmp(text, "simple",6)==0 || 00183 ux_strncasecmp(text, "static",6)==0) { 00184 return WN_PRAGMA_SCHEDTYPE_SIMPLE; 00185 } else if (ux_strncasecmp(text, "dynamic",7)==0) { 00186 return WN_PRAGMA_SCHEDTYPE_DYNAMIC; 00187 } else if (ux_strncasecmp(text, "interleaved",11)==0) { 00188 return WN_PRAGMA_SCHEDTYPE_INTERLEAVE; 00189 } else if ( ux_strncasecmp(text, "interleave",10)==0) { 00190 return WN_PRAGMA_SCHEDTYPE_INTERLEAVE; 00191 } else if (ux_strncasecmp(text, "runtime",7)==0) { 00192 return WN_PRAGMA_SCHEDTYPE_RUNTIME; 00193 } else if (ux_strncasecmp(text, "gss",3)==0) { 00194 return WN_PRAGMA_SCHEDTYPE_GSS; 00195 } else if (ux_strncasecmp(text, "guided",6)==0) { 00196 return WN_PRAGMA_SCHEDTYPE_GSS; 00197 } else if (ux_strncasecmp(text, "pseudolowered",13)==0) { 00198 return WN_PRAGMA_SCHEDTYPE_PSEUDOLOWERED; 00199 } else { 00200 ErrMsg(EC_Unknown_Mpsched,text); 00201 return WN_PRAGMA_SCHEDTYPE_UNKNOWN; 00202 } 00203 } 00204 00205 00206 void add_cray_args(char *arg) 00207 { 00208 /* Add a string to the Cray args */ 00209 00210 if (num_cray_args >= size_cray_argv) { 00211 /* Reallocate argv_cray */ 00212 size_cray_argv += 16; 00213 argv_cray = (char **) realloc(argv_cray,size_cray_argv*sizeof(char *)); 00214 } 00215 00216 if (arg) { 00217 argv_cray[num_cray_args] = ux_strdup(arg); 00218 } else { 00219 argv_cray[num_cray_args] = NULL; 00220 } 00221 ++num_cray_args; 00222 } 00223 00224 void add_deferred_cray_args(char *arg) 00225 { 00226 /* Add a string to the deferred Cray args */ 00227 00228 if (num_deferred_cray_args >= size_deferred_cray_argv) { 00229 /* Reallocate argv_cray */ 00230 size_deferred_cray_argv += 16; 00231 deferred_argv_cray = (char **) realloc(deferred_argv_cray, 00232 size_deferred_cray_argv*sizeof(char *)); 00233 } 00234 00235 if (arg) { 00236 deferred_argv_cray[num_deferred_cray_args] = ux_strdup(arg); 00237 } else { 00238 deferred_argv_cray[num_deferred_cray_args] = NULL; 00239 } 00240 ++num_deferred_cray_args; 00241 } 00242 00243 /* ==================================================================== 00244 * 00245 * Cray_Woff 00246 * 00247 * Process a set of warning numbers which are to be disabled. They are 00248 * given in the form: 00249 * 00250 * n1,n2,n3-n4,n5-n6,... 00251 * 00252 * where an individual number (e.g. n1 or n2) suppresses that numbered 00253 * warning, and a range (e.g. n3-n4 or n5-n6) disables all warnings 00254 * numbered in that range. 00255 * 00256 * This routine takes such a number list from -DEBUG:woff=... or from 00257 * -woff ..., converts it to the Cray format option, and passes it to 00258 * the Cray command line option handler. 00259 * 00260 * ==================================================================== 00261 */ 00262 00263 void 00264 Cray_Woff ( char *list ) 00265 { 00266 char *temp = (char *) malloc ( strlen(list)+3 ); 00267 00268 strcpy ( temp, "-M" ); 00269 strcat ( temp, list ); 00270 add_cray_args ( temp ); 00271 free ( temp ); 00272 } 00273 00274 /* ==================================================================== 00275 * 00276 * Process_Command_Line 00277 * 00278 * Process the command line arguments. Evaluate all flags except per- 00279 * source file control flags and set up global options. 00280 * 00281 * ==================================================================== 00282 */ 00283 00284 void Process_Command_Line (INT argc, char ** argv) 00285 00286 { 00287 INT i; 00288 char *cp; 00289 char *temp; 00290 char ch,c; 00291 BOOL pass_option; 00292 BOOL opt_set; 00293 INT j; 00294 FILE *f; 00295 INT command_line_length; 00296 00297 argc_cray = argc; 00298 num_cray_args = 1; 00299 size_cray_argv = argc + 1; 00300 00301 /* Get the space for (potential) copies of all the command-line options */ 00302 argv_cray = (char **) malloc(size_cray_argv*sizeof(char *)); 00303 argv_cray[0] = argv[0]; 00304 00305 /* Get the space for the deferred cray args */ 00306 num_deferred_cray_args=0; 00307 size_deferred_cray_argv = 1; /* Pretty arbitrary */ 00308 deferred_argv_cray = (char **)malloc(size_deferred_cray_argv*sizeof(char *)); 00309 00310 /* Process the command line */ 00311 for (i=1; i<argc; i++ ) { 00312 if ( argv[i] != NULL && *(argv[i]) == '-' ) { 00313 cp = argv[i]+1; /* Pointer to next flag character */ 00314 if (Process_Command_Line_Group(cp, Common_Option_Groups)) { 00315 pass_option = FALSE; 00316 switch ( *cp++ ) { 00317 case 'L': 00318 if ((strncmp(cp, "ANG:IEEE_minus_zero", 19) == 0) && 00319 (strncmp(cp, "ANG:IEEE_minus_zero=off", 23) != 0) && 00320 (strncmp(cp, "ANG:IEEE_minus_zero=OFF", 23) != 0)) { 00321 add_cray_args("-ez"); 00322 } 00323 } 00324 } else if (Process_Command_Line_Group(cp, FE_Option_Groups)) { 00325 pass_option = FALSE; 00326 } else { 00327 pass_option = TRUE; 00328 switch ( *cp++ ) { 00329 case 'a': 00330 if (strcmp(cp,"lign32")==0) { 00331 pass_option = TRUE; 00332 FE_align = 4; 00333 } else if (strcmp(cp,"lign64")==0) { 00334 pass_option = TRUE; 00335 FE_align = 8; 00336 } else if (strcmp(cp,"nsi")==0) { 00337 pass_option = FALSE; 00338 add_cray_args("-en"); 00339 } else if (strncmp(cp,"uto_use=",8)==0) { 00340 cp += 8; 00341 temp = (char *) malloc (strlen(cp) + 3); 00342 strcpy(temp,"-A"); 00343 strcat(temp,cp); 00344 add_cray_args(temp); 00345 free(temp); 00346 pass_option = FALSE; 00347 } 00348 break; 00349 00350 case 'c': 00351 if (strcmp(cp,"ol72")==0) { 00352 pass_option = FALSE; 00353 add_cray_args("-N72"); 00354 } else if (strcmp(cp,"ol80")==0) { 00355 pass_option = FALSE; 00356 add_cray_args("-N80"); 00357 } else if (strcmp(cp,"ol120")==0) { 00358 pass_option = FALSE; 00359 add_cray_args("-N120"); 00360 } else if (strcmp(cp,"if")==0) { 00361 pass_option = FALSE; 00362 add_cray_args("-Ca"); 00363 } else if (strncmp(cp,"hunk=",5)==0) { 00364 cp += 5; 00365 global_chunk_pragma_set = TRUE; 00366 global_chunk_pragma_value = Get_Numeric_Flag ( &cp, 0, INT32_MAX,0,argv[i] ); 00367 pass_option = FALSE; 00368 } else if (strcmp(cp,"ray_mp")==0) { 00369 pass_option = FALSE; 00370 process_cri_mp_pragmas = TRUE; 00371 add_cray_args("-Otask1"); 00372 } 00373 break; 00374 00375 case 'd': 00376 if (strcmp(cp,"16")==0) { 00377 pass_option = FALSE; 00378 add_cray_args("-sdoubleprecision16"); 00379 add_cray_args("-sdoublecomplex16"); 00380 } else if (strcmp(cp,"8")==0) { 00381 pass_option = FALSE; 00382 } else if (strcmp(cp,"sm")==0) { 00383 /* -dsm: enable the DSM directives */ 00384 enable_dsm_processing = TRUE; 00385 add_cray_args("-udsm"); 00386 pass_option = FALSE; 00387 } else if (strcmp(cp,"sm_recompile")==0) { 00388 /* -dsm_recompile: do not update rii file */ 00389 enable_dsm_recompile = TRUE; 00390 pass_option = FALSE; 00391 } else if (strcmp(cp,"efault64")==0) { 00392 pass_option = FALSE; 00393 add_cray_args("-ucray_compatible"); 00394 } else if (strcmp(cp,"isable_old_mp")==0) { 00395 pass_option = FALSE; 00396 disable_old_mp = TRUE; 00397 } else if (strcmp(cp,"isable_open_mp")==0) { 00398 pass_option = FALSE; 00399 disable_open_mp = TRUE; 00400 } 00401 else if (strcmp(cp,"_lines")==0) { 00402 pass_option = FALSE; 00403 add_cray_args("-ed"); 00404 } 00405 break; 00406 00407 case 'e': 00408 if (strcmp(cp,"xtend_source")==0) { 00409 pass_option = FALSE; 00410 add_cray_args("-N132"); 00411 } 00412 break; 00413 00414 case 'E': 00415 pass_option = FALSE; 00416 add_cray_args("-eZ"); 00417 break; 00418 00419 case 'f': 00420 if ( strcmp(cp,"ullwarn") == 0 ) { 00421 /* -fullwarn -- similar to -m2: */ 00422 Min_Error_Severity = ES_ADVISORY; 00423 add_cray_args("-m2"); 00424 pass_option = FALSE; 00425 } else if ( strcmp(cp,"tpp") == 0 ) { 00426 pass_option = FALSE; 00427 add_cray_args("-eT"); 00428 } else { /* Filename options -- ignore these except -fb: */ 00429 c = *cp++; 00430 if ( (ch=*cp++) != ',' && ch != ':' ) { 00431 if ( c == 0 ) c = '?'; 00432 pass_option = TRUE; 00433 break; 00434 } 00435 /* Process the various options: */ 00436 pass_option = FALSE; 00437 switch ( c ) { 00438 00439 case 'b': /* Library file already processed -- ignore: */ 00440 Lib_File_Name = ux_strdup(cp); 00441 break; 00442 00443 case 'B': /* WHIRL file: */ 00444 Irb_File_Name = ux_strdup(cp); 00445 break; 00446 00447 case 'C': /* CIF file */ 00448 temp = (char *) malloc (strlen(cp) + 4); 00449 strcpy(temp,"-CZ"); 00450 strcat(temp,cp); 00451 add_cray_args(temp); 00452 free(temp); 00453 pass_option = FALSE; 00454 break; 00455 00456 case 'D': /* Cray debug file */ 00457 temp = (char *) malloc (strlen(cp) + 8); 00458 strcpy(temp,"-ufile="); 00459 strcat(temp,cp); 00460 add_cray_args(temp); 00461 free(temp); 00462 pass_option = FALSE; 00463 break; 00464 00465 case 'S': /* Original source file name (used for -mp option) */ 00466 Orig_Src_File_Name = ux_strdup(cp); 00467 break; 00468 00469 case 'e': /* Error file: */ 00470 Err_File_Name = ux_strdup(cp); 00471 break; 00472 00473 case 'I': /* Ipa_File_Name: ignore it */ 00474 break; 00475 00476 case 'l': /* Listing file: */ 00477 Lst_File_Name = ux_strdup(cp); 00478 break; 00479 00480 case 'o': /* Object file: */ 00481 object_file_name = ux_strdup(cp); 00482 break; 00483 00484 case 't': /* Error file: */ 00485 Tracing_Enabled = TRUE; 00486 Trc_File_Name = ux_strdup(cp); 00487 break; 00488 00489 default: 00490 pass_option = TRUE; 00491 } 00492 } 00493 break; 00494 00495 case 'g': /* Debug level: */ 00496 Debug_Level = Get_Numeric_Flag 00497 ( &cp, 0, MAX_DEBUG_LEVEL, 00498 2, argv[i] ); 00499 if (!opt_set) 00500 Opt_Level = 0; 00501 pass_option = FALSE; 00502 add_cray_args("-Gd"); 00503 break; 00504 00505 case 'G': /* Sdata elt size */ 00506 Max_Sdata_Elt_Size = Get_Numeric_Flag 00507 ( &cp, 0, MAX_SDATA_ELT_SIZE, 00508 DEF_SDATA_ELT_SIZE, argv[i] ); 00509 pass_option = FALSE; 00510 break; 00511 00512 case 'i': 00513 if (strcmp(cp, "eee_minus_zero") == 0) { 00514 add_cray_args("-ez"); 00515 pass_option = FALSE; 00516 } 00517 else if ( strncmp(cp, "nclude=", 7) == 0) { 00518 /* -include= */ 00519 cp += 7; 00520 temp = (char *) malloc (strlen(cp) + 3); 00521 strcpy(temp+2,cp); 00522 temp[0] = '-'; temp[1] = 'I'; 00523 add_cray_args(temp); 00524 /* Also add -p<path> to pick up the right module information */ 00525 temp[1] = 'p'; 00526 add_cray_args(temp); 00527 free(temp); 00528 pass_option = FALSE; 00529 } else if (strcmp(cp,"4") == 0) { 00530 pass_option = FALSE; 00531 } else if (strcmp(cp,"8") == 0) { 00532 add_cray_args("-sinteger8"); 00533 add_cray_args("-slogical8"); 00534 pass_option = FALSE; 00535 } 00536 00537 break; 00538 00539 case 'k': 00540 if ( strcmp(cp,"eep") == 0 ) { 00541 add_cray_args("-ek"); /* set save_dot_i = TRUE */ 00542 pass_option = FALSE; 00543 } 00544 00545 break; 00546 00547 case 'm': 00548 { 00549 if (strcmp(cp,"p") == 0) { 00550 pass_option = FALSE; 00551 enable_mp_processing = TRUE; 00552 } else if (strncmp(cp,"p_chunk=",8) == 0) { 00553 cp += 8; 00554 global_chunk_pragma_set = TRUE; 00555 global_chunk_pragma_value = Get_Numeric_Flag ( &cp, 0, INT32_MAX,0,argv[i] ); 00556 pass_option = FALSE; 00557 } else if (strncmp(cp,"p_schedtype=",12) == 0) { 00558 cp += 12; 00559 global_schedtype_pragma_val = identify_schedtype(cp); 00560 if (global_schedtype_pragma_val != WN_PRAGMA_SCHEDTYPE_UNKNOWN) { 00561 global_schedtype_pragma_set = TRUE; 00562 } 00563 pass_option = FALSE; 00564 } else { 00565 int cray_num; 00566 char temp[4]; 00567 /* Message reporting: */ 00568 cray_num = 3; 00569 j = Get_Numeric_Flag ( &cp, 0, MAX_MSG_LEVEL, 00570 MAX_MSG_LEVEL, argv[i] ); 00571 switch (j) { 00572 case 0: 00573 Min_Error_Severity = ES_ERROR; 00574 cray_num=4; 00575 break; 00576 case 1: 00577 Min_Error_Severity = ES_WARNING; 00578 cray_num = 3; 00579 break; 00580 case 2: 00581 cray_num=0; 00582 Min_Error_Severity = ES_ADVISORY; 00583 break; 00584 } 00585 sprintf(temp,"-m%1d",cray_num); 00586 add_cray_args(temp); 00587 pass_option = FALSE; 00588 } 00589 } 00590 break; 00591 case 'M': 00592 if (strcmp(cp, "Dtarget") == 0) { 00593 mdtarget_file = ux_strdup(argv[i+1]); 00594 ++i; 00595 pass_option = FALSE; 00596 } else if (strcmp(cp, "Dupdate") == 0) { 00597 mdupdate_file = ux_strdup(argv[i+1]); 00598 ++i; 00599 pass_option = FALSE; 00600 } 00601 break; 00602 00603 case 'n': 00604 if ( strcmp(cp, "owarn") == 0) { 00605 /* -nowarn, edg's -w */ 00606 /* Suppress warnings */ 00607 Min_Error_Severity = ES_ERROR; 00608 add_cray_args("-m4"); 00609 pass_option = FALSE; 00610 } else if (strcmp(cp,"oextend_source")==0) { 00611 add_cray_args("-N72"); 00612 pass_option = FALSE; 00613 } else if (strcmp(cp,"ocpp")==0) { 00614 add_cray_args("-dT"); 00615 pass_option = FALSE; 00616 } else if (strcmp(cp,"oappend")==0) { 00617 add_cray_args("-eN"); 00618 pass_option = FALSE; 00619 } 00620 break; 00621 00622 case 'O': /* Optimization level: */ 00623 Opt_Level = Get_Numeric_Flag 00624 ( &cp, 0, MAX_OPT_LEVEL, DEF_O_LEVEL, argv[i] ); 00625 opt_set = TRUE; 00626 pass_option = FALSE; 00627 break; 00628 00629 case 'p': 00630 if (strcmp(cp,"ad_char_literals")==0) { 00631 pass_option = FALSE; 00632 add_cray_args("-ec"); 00633 } 00634 break; 00635 00636 case 'P': 00637 pass_option = FALSE; 00638 add_cray_args("-dk"); /* set output_pound_lines = FALSE */ 00639 break; 00640 00641 case 'r': 00642 if (strcmp(cp,"4") == 0) { 00643 pass_option = FALSE; 00644 } else if (strcmp(cp,"8") == 0) { 00645 add_cray_args("-sreal8"); 00646 add_cray_args("-scomplex8"); 00647 pass_option = FALSE; 00648 } else if (strncmp(cp,"ii",2) == 0) 00649 { 00650 /* -rii : set rii_file_name */ 00651 cp += 2; 00652 rii_file_name = ux_strdup(cp); 00653 pass_option = FALSE; 00654 } 00655 break; 00656 00657 case 's': 00658 if ( strcmp(cp,"how") == 0) { 00659 /* -show: Emit progress reports: */ 00660 Show_Progress = TRUE; 00661 pass_option = FALSE; 00662 } else if ( strcmp(cp,"tatic_threadprivate") == 0) { 00663 /* -static_threadprivate */ 00664 add_cray_args("-astatic_threadprivate"); 00665 pass_option = FALSE; 00666 } else if ( strcmp(cp,"tatic-data") == 0) { 00667 /* -static-data, same as -static */ 00668 add_cray_args("-ev"); 00669 pass_option = FALSE; 00670 } else if ( strcmp(cp,"tatic") == 0) { 00671 /* -static */ 00672 add_cray_args("-ev"); 00673 pass_option = FALSE; 00674 } 00675 break; 00676 00677 case 't': 00678 /* Trace specification: 00679 * The config.c routine expects to get a pointer to the 00680 * full option '-t...', but doesn't check the '-', so 00681 * point just before the 't': 00682 */ 00683 Process_Trace_Option ( cp-2 ); 00684 pass_option = FALSE; 00685 break; 00686 00687 case 'u': 00688 if (*cp=='\0') { 00689 /* Plain -u */ 00690 add_cray_args("-eI"); 00691 pass_option = FALSE; 00692 } 00693 break; 00694 00695 case 'v': 00696 if ( strcmp(cp,"ersion") == 0) { 00697 /* -version, edg's -v */ 00698 /* Print out compiler version. */ 00699 fprintf(stderr, "mfef90 version %s\nBuilt:%s\n",INCLUDE_STAMP, 00700 mfef90_compiler_build_date); 00701 pass_option = FALSE; 00702 } 00703 break; 00704 00705 case 'w': 00706 if (*cp=='\0') { 00707 add_cray_args("-m4"); 00708 pass_option = FALSE; 00709 Min_Error_Severity = ES_ERROR; 00710 } else if ( strncmp(cp, "off", 3) == 0) { 00711 Cray_Woff(cp+3); 00712 pass_option = FALSE; 00713 } else if ( *cp=='2') { /* -w2 print warnings */ 00714 Min_Error_Severity = ES_WARNING; 00715 } 00716 else if ( *cp=='3') { /* -w3: exit 1 on warnings */ 00717 Min_Error_Severity = ES_ERROR; 00718 } 00719 pass_option = FALSE; 00720 break; 00721 case 'z': 00722 if (*cp=='\0') { 00723 pass_option = TRUE; 00724 cleanUpWhirl = TRUE; 00725 } 00726 break; 00727 } /* switch */ 00728 if (pass_option) { 00729 add_cray_args(argv[i]); 00730 } 00731 } 00732 } else { 00733 /* add to the non-switch list */ 00734 add_deferred_cray_args(argv[i]); 00735 } 00736 } 00737 00738 /* Add the align switch */ 00739 if (FE_align==8) { 00740 add_cray_args("-adalign"); 00741 } 00742 00743 /* Read the command line and pass it along to the Cray front-end */ 00744 if (FE_command_line) { 00745 f = fopen(FE_command_line,"r"); 00746 command_line_length = 0; 00747 if (f) { 00748 while ( getc(f) != '\n' ) ++command_line_length; 00749 fseek (f,0,SEEK_SET); 00750 temp = (char *) malloc(command_line_length+2); 00751 fgets(temp,command_line_length+1,f); 00752 temp[command_line_length] = 0; 00753 fclose(f); 00754 add_cray_args("-CY"); 00755 add_cray_args(temp); 00756 free(temp); 00757 } 00758 } 00759 } 00760 00761 00762 /* ==================================================================== 00763 * Entry point from Cray compiler 00764 * ==================================================================== 00765 */ 00766 00767 void sgi_cmd_line (INT *argc, char ***argv) 00768 { 00769 INT i; 00770 INT len; 00771 char msg_num[10]; 00772 char *chp; 00773 option_list *opt_list; 00774 00775 00776 /* Set up SGI error handling */ 00777 00778 save_argv = (char **) malloc((*argc) * sizeof(char *)); 00779 save_argc = *argc; 00780 00781 for(i=0; i < *argc; i++) { 00782 len = strlen((*argv)[i]); 00783 save_argv[i] = (char *) malloc((len + 1)*sizeof(char)); 00784 strcpy(save_argv[i], (*argv)[i]); 00785 } 00786 00787 Set_Error_Tables (Phases, host_errlist); 00788 Init_Error_Handler ( 100 ); 00789 Set_Error_Line ( ERROR_LINE_UNKNOWN ); 00790 Set_Error_File ( NULL ); 00791 Set_Error_Phase ( "Front End Parse/Semantic"); 00792 Handle_Signals(); 00793 00794 /* Set the language to be F90 */ 00795 Language = LANG_F90; 00796 Preconfigure (); 00797 00798 /* set this so that Cray will open the file for us */ 00799 Process_Command_Line ( *argc, *argv); 00800 00801 MEM_Initialize() ; 00802 MEM_POOL_Initialize(FE_Mempool,"FE_Mempool",TRUE); 00803 MEM_POOL_Push(FE_Mempool); 00804 00805 Configure (); 00806 Configure_Source (NULL); 00807 // Configure_Target() ; 00808 IPA_Configure_Target (); 00809 00810 /* Set the target name for MDupdate */ 00811 if (mdtarget_file == NULL ) mdtarget_file = object_file_name; 00812 00813 /* Add a few more arguments after the target configuration */ 00814 if (Pointer_Size == 8) { 00815 add_cray_args("-spointer8"); 00816 } 00817 00818 /* 00819 * Solaris workaround 00820 * see ../fe90/target.m, since Solaris doesn't accept shortcircuit 00821 * options, remove it to avoid a warning message. 00822 */ 00823 #ifndef _SOLARIS_SOLARIS 00824 if (FTN_Short_Circuit_On) { 00825 add_cray_args("-Oshortcircuit0"); 00826 } else { 00827 add_cray_args("-Oshortcircuit1"); 00828 } 00829 #endif 00830 00831 /* add the Matrix-multiply inline options */ 00832 if (!Mv_Matmul_Inline_Set) { 00833 Mv_Matmul_Inline = (Opt_Level >= 3); 00834 } 00835 if (!Matmul_Inline_Set) { 00836 Matmul_Inline = (Opt_Level >= 3); 00837 } 00838 if (Matmul_Inline) { 00839 add_cray_args("-Omatmul_inline"); 00840 } 00841 if (Mv_Matmul_Inline) { 00842 add_cray_args("-Omv_matmul_inline"); 00843 } 00844 00845 /* Bounds checking */ 00846 00847 if (DEBUG_Subscript_Check) { 00848 add_cray_args("-Rb"); 00849 } 00850 00851 if (DEBUG_Fullwarn) { 00852 add_cray_args("-m2"); 00853 } 00854 00855 /* Cray_Woff(cp+3); */ 00856 00857 if (Current_DEBUG->error_set) { 00858 opt_list = Current_DEBUG->error; 00859 00860 while (opt_list != NULL) { 00861 chp = strtok(opt_list->val, ","); 00862 00863 while(chp != NULL) { 00864 add_cray_args("-M"); 00865 msg_num[0] = 'E'; 00866 strcpy(&msg_num[1], chp); 00867 add_cray_args(msg_num); 00868 chp = strtok(NULL, ","); 00869 } 00870 opt_list = opt_list->next; 00871 } 00872 } 00873 00874 if (Current_DEBUG->warning_set) { 00875 opt_list = Current_DEBUG->warning; 00876 00877 while (opt_list != NULL) { 00878 chp = strtok(opt_list->val, ","); 00879 00880 while(chp != NULL) { 00881 add_cray_args("-M"); 00882 msg_num[0] = 'W'; 00883 strcpy(&msg_num[1], chp); 00884 add_cray_args(msg_num); 00885 chp = strtok(NULL, ","); 00886 } 00887 opt_list = opt_list->next; 00888 } 00889 } 00890 00891 if (enable_mp_processing) { 00892 00893 if (! disable_old_mp) { 00894 add_cray_args("-ump"); 00895 } 00896 00897 if (! disable_open_mp) { 00898 add_cray_args("-uopen_mp"); 00899 } 00900 } 00901 00902 /* Add the deferred arguments */ 00903 for (i = 0 ; i < num_deferred_cray_args; i++) { 00904 add_cray_args(deferred_argv_cray[i]); 00905 } 00906 /* Add a final NULL arg */ 00907 add_cray_args(NULL); 00908 --num_cray_args; 00909 00910 /* Clean up the mess */ 00911 free(deferred_argv_cray); 00912 00913 argc_cray = num_cray_args; 00914 *argc = argc_cray; 00915 *argv = argv_cray; 00916 00917 if (Get_Trace(TP_IRB, 1) != 0) { 00918 fprintf(TFile,"Cray command line arguments:\n"); 00919 for (i = 0; i < argc_cray; i++) { 00920 fprintf(TFile,"Arg %d: |%s|\n",i,argv_cray[i]); 00921 } 00922 fprintf(TFile,"\n"); 00923 } 00924 return; 00925 } 00926