Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 /* ==================================================================== 00037 * ==================================================================== 00038 * 00039 * 00040 * Revision history: 00041 * 02-Nov-96 - Original Version. 00042 * 00043 * Description: 00044 * 00045 * Configure the -DEBUG option group (included in config.c). 00046 * 00047 * ==================================================================== 00048 * ==================================================================== 00049 */ 00050 00051 #ifdef _KEEP_RCS_ID 00052 /*REFERENCED*/ 00053 #endif /* _KEEP_RCS_ID */ 00054 00055 00056 /* This file is included in config.c, so it doesn't need its own set of 00057 * standard includes -- only the following: 00058 */ 00059 #include "config_debug.h" 00060 00061 /* ==================================================================== 00062 * 00063 * -DEBUG: option group 00064 * 00065 * Define the defaults for -DEBUG option group flags. 00066 * 00067 * NOTE: There are two copies of this defined -- one to copy when 00068 * initializing a new struct to the defaults, and one to serve as the 00069 * initial bottom of the Current_DEBUG stack. Fix both of them when 00070 * adding/changing things. 00071 * 00072 * ==================================================================== 00073 */ 00074 00075 static DEBUG_FLAGS Default_DEBUG = { 00076 NULL, /* next */ 00077 00078 /* default set? */ 00079 FALSE, FALSE, /* cmod_warn */ 00080 FALSE, FALSE, /* cray_port */ 00081 DIV_ZERO_CHECK, FALSE, /* div_check */ 00082 FALSE, FALSE, /* equiv_warn */ 00083 NULL, FALSE, /* error */ 00084 FALSE, FALSE, /* fullwarn */ 00085 FALSE, FALSE, /* full_iface_check */ 00086 FALSE, FALSE, /* i32_oflow_check */ 00087 FALSE, FALSE, /* int_oflow_check */ 00088 FALSE, FALSE, /* optimize space */ 00089 FALSE, FALSE, /* parm_alias_check */ 00090 FALSE, FALSE, /* ptr_incr_warn */ 00091 TRUE, FALSE, /* printf_warn */ 00092 NULL, FALSE, /* remark */ 00093 FALSE, FALSE, /* shift_check */ 00094 FALSE, FALSE, /* shift_warn */ 00095 FALSE, FALSE, /* subscript_check */ 00096 FALSE, FALSE, /* trap_uv */ 00097 FALSE, FALSE, /* trap_uv_rjustify */ 00098 FALSE, FALSE, /* trunc_check */ 00099 FALSE, FALSE, /* trunc_warn */ 00100 TRUE, FALSE, /* varargs_iface_check */ 00101 TRUE, FALSE, /* varargs_prototypes */ 00102 FALSE, FALSE, /* verbose_runtime */ 00103 NULL, FALSE, /* warning */ 00104 NULL, FALSE, /* woff */ 00105 TRUE, /* ir version check */ 00106 ALIGN_NORMAL, /* control ldl/ldr generation */ 00107 TRUE, /* ipalno version check */ 00108 FALSE, FALSE, /* conformance_check */ 00109 00110 { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 } /* buffer[16] */ 00111 }; 00112 00113 DEBUG_FLAGS Initial_DEBUG = { 00114 NULL, /* next */ 00115 00116 /* default set? */ 00117 FALSE, FALSE, /* cmod_warn */ 00118 FALSE, FALSE, /* cray_port */ 00119 DIV_ZERO_CHECK, FALSE, /* div_check */ 00120 FALSE, FALSE, /* equiv_warn */ 00121 NULL, FALSE, /* error */ 00122 FALSE, FALSE, /* fullwarn */ 00123 FALSE, FALSE, /* full_iface_check */ 00124 FALSE, FALSE, /* i32_oflow_check */ 00125 FALSE, FALSE, /* int_oflow_check */ 00126 FALSE, FALSE, /* optimize space */ 00127 FALSE, FALSE, /* parm_alias_check */ 00128 FALSE, FALSE, /* ptr_incr_warn */ 00129 TRUE, FALSE, /* printf_warn */ 00130 NULL, FALSE, /* remark */ 00131 FALSE, FALSE, /* shift_check */ 00132 FALSE, FALSE, /* shift_warn */ 00133 FALSE, FALSE, /* subscript_check */ 00134 FALSE, FALSE, /* trap_uv */ 00135 FALSE, FALSE, /* trap_uv_rjustify */ 00136 FALSE, FALSE, /* trunc_check */ 00137 FALSE, FALSE, /* trunc_warn */ 00138 TRUE, FALSE, /* varargs_iface_check */ 00139 TRUE, FALSE, /* varargs_prototypes */ 00140 FALSE, FALSE, /* verbose_runtime */ 00141 NULL, FALSE, /* warning */ 00142 NULL, FALSE, /* woff */ 00143 TRUE, /* ir version check */ 00144 ALIGN_NORMAL, /* control ldl/ldr generation */ 00145 TRUE, /* ipalno version check */ 00146 FALSE, FALSE, /* conformance_check */ 00147 00148 { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 } /* buffer[16] */ 00149 }; 00150 00151 static char *Debug_Alignment_Name= NULL; 00152 00153 DEBUG_FLAGS *Current_DEBUG = &Initial_DEBUG; 00154 00155 /* ==================================================================== 00156 * Descriptor for the -DEBUG option group. 00157 * ==================================================================== 00158 */ 00159 00160 #define ID Initial_DEBUG 00161 00162 static OPTION_DESC Options_DEBUG[] = { 00163 00164 { OVK_BOOL, OV_INTERNAL, TRUE, "const_mod_warning", "", 00165 0, 0, 0, &ID.cmod_warn, &ID.cmod_warn_set, 00166 "Warn about attempts to store into a constant" }, 00167 00168 { OVK_BOOL, OV_INTERNAL, TRUE, "cray_port", "", 00169 0, 0, 0, &ID.cray_port, &ID.cray_port_set, 00170 "Turn on all Cray porting options" }, 00171 00172 { OVK_INT32, OV_VISIBLE, TRUE, "div_check", "", 00173 DEFAULT_DIV_CHECK, 0, 3, &ID.div_check, &ID.div_check_set, 00174 "Check for divide by zero and/or division overflow" }, 00175 00176 { OVK_BOOL, OV_INTERNAL, TRUE, "equiv_warning", "", 00177 0, 0, 0, &ID.equiv_warn, &ID.equiv_warn_set, 00178 "Warn about EQUIVALENCE affected by 32- vs. 64-bit compilation" }, 00179 00180 { OVK_LIST, OV_VISIBLE, TRUE, "error", "", 00181 0, 0, 0, &ID.error, &ID.error_set, 00182 "Convert given warning messages to errors" }, 00183 00184 { OVK_BOOL, OV_VISIBLE, TRUE, "fullwarn", "", 00185 0, 0, 0, &ID.fullwarn, &ID.fullwarn_set, 00186 "Turn on all warning messages" }, 00187 00188 { OVK_BOOL, OV_SHY, TRUE, "full_interface_check", "", 00189 0, 0, 0, &ID.full_iface_check, &ID.full_iface_check_set, 00190 "Check all subprogram call interfaces" }, 00191 00192 { OVK_BOOL, OV_INTERNAL, TRUE, "int32_overflow_check", "", 00193 0, 0, 0, &ID.i32_oflow_check, &ID.i32_oflow_check_set, 00194 "Check 32-bit integer code for overflow" }, 00195 00196 { OVK_BOOL, OV_INTERNAL, TRUE, "int_overflow_check", "", 00197 0, 0, 0, &ID.int_oflow_check, &ID.int_oflow_check_set, 00198 "Check all integer code for overflow" }, 00199 00200 { OVK_BOOL, OV_INTERNAL, TRUE, "optimize_space", "", 00201 0, 0, 0, &ID.optimize_space, &ID.optimize_space_set, 00202 "Optimize debug space" }, 00203 00204 { OVK_BOOL, OV_INTERNAL, TRUE, "parameter_alias_check", "", 00205 0, 0, 0, &ID.parm_alias_check, &ID.parm_alias_check_set, 00206 "Check Fortran subprogram parameters for aliasing" }, 00207 00208 { OVK_BOOL, OV_INTERNAL, TRUE, "pointer_increment_warning", "", 00209 0, 0, 0, &ID.ptr_incr_warn, &ID.ptr_incr_warn_set, 00210 "Check increments of Fortran pointers against pointee size" }, 00211 00212 { OVK_BOOL, OV_INTERNAL, TRUE, "printf_warning", "", 00213 0, 0, 0, &ID.printf_warn, &ID.printf_warn_set, 00214 "Check literal printf format strings against parameter types" }, 00215 00216 { OVK_LIST, OV_VISIBLE, TRUE, "remark", "", 00217 0, 0, 0, &ID.remark, &ID.remark_set, 00218 "Convert given warning messages to remarks" }, 00219 00220 { OVK_BOOL, OV_INTERNAL, TRUE, "shift_check", "", 00221 0, 0, 0, &ID.shift_check, &ID.shift_check_set, 00222 "Check for variable shift counts larger than object" }, 00223 00224 { OVK_BOOL, OV_INTERNAL, TRUE, "shift_warning", "", 00225 0, 0, 0, &ID.shift_warn, &ID.shift_warn_set, 00226 "Warn about constant shift counts larger than object" }, 00227 00228 { OVK_BOOL, OV_VISIBLE, TRUE, "subscript_check", "", 00229 0, 0, 0, &ID.subscript_check, &ID.subscript_check_set, 00230 "Check for subscripts out of range" }, 00231 00232 { OVK_LIST, OV_VISIBLE, TRUE, "suppress", "", 00233 0, 0, 0, &ID.woff, &ID.woff_set, 00234 "Suppress given warning messages" }, 00235 00236 { OVK_BOOL, OV_VISIBLE, TRUE, "trap_uninitialized", "", 00237 0, 0, 0, &ID.trap_uv, &ID.trap_uv_set, 00238 "Trap references to uninitialized variables" }, 00239 00240 { OVK_BOOL, OV_INTERNAL, TRUE, "trapuv_right_justify", "", 00241 0, 0, 0, &ID.trap_uv_rjustify, &ID.trap_uv_rjustify_set, 00242 "" }, 00243 00244 { OVK_BOOL, OV_INTERNAL, TRUE, "trunc_check", "", 00245 0, 0, 0, &ID.trunc_check, &ID.trunc_check_set, 00246 "Check 64- to 32-bit assignments for truncation" }, 00247 00248 { OVK_BOOL, OV_INTERNAL, TRUE, "trunc_warning", "", 00249 0, 0, 0, &ID.trunc_warn, &ID.trunc_warn_set, 00250 "Warn about truncation on 64- to 32-bit assignments" }, 00251 00252 { OVK_BOOL, OV_VISIBLE, TRUE, "varargs_interface_check", "", 00253 0, 0, 0, &ID.varargs_iface_check,&ID.varargs_iface_check_set, 00254 "Check interfaces on calls to varargs routines" }, 00255 00256 { OVK_BOOL, OV_VISIBLE, TRUE, "varargs_prototypes", "", 00257 0, 0, 0, &ID.varargs_prototypes, &ID.varargs_prototypes_set, 00258 "Assume ANSI guarantee that varargs routines are prototyped" }, 00259 00260 { OVK_BOOL, OV_VISIBLE, TRUE, "verbose_runtime", "", 00261 0, 0, 0, &ID.verbose_runtime, &ID.verbose_runtime_set, 00262 "Generate verbose messages for runtime errors" }, 00263 00264 { OVK_LIST, OV_VISIBLE, TRUE, "warning", "", 00265 0, 0, 0, &ID.warning, &ID.warning_set, 00266 "Convert given messages to warnings" }, 00267 00268 { OVK_LIST, OV_VISIBLE, TRUE, "woff", "", 00269 0, 0, 0, &ID.woff, &ID.woff_set, 00270 "Suppress given warning messages" }, 00271 00272 { OVK_BOOL, OV_VISIBLE, TRUE, "ir_version_check", "", 00273 0, 0, 0, &ID.ir_version_check, NULL, 00274 "Check whether version of IR matches expected version" }, 00275 00276 { OVK_NAME, OV_VISIBLE, TRUE, "alignment", "", 00277 0, 0, 0, &Debug_Alignment_Name, NULL, 00278 "Do unaligned load/stores either as normal, compose, or fixade" }, 00279 00280 { OVK_BOOL, OV_VISIBLE, TRUE, "ipa_version_check", "", 00281 0, 0, 0, &ID.ipalno_version_check, NULL, 00282 "Check whether version of IPALNO matches expected version" }, 00283 00284 { OVK_BOOL, OV_VISIBLE, TRUE, "conform_check", "", 00285 0, 0, 0, &ID.conform_check, &ID.conform_check_set, 00286 "Check for conforming array assignments" }, 00287 00288 /* Obsolete/unsupported options: */ 00289 { OVK_REPLACED, OV_INTERNAL, TRUE, "bounds_check", NULL, 00290 0, 0, 0, 00291 const_cast<char*>("-DEBUG:subscript_check"), NULL, 00292 "Check array subscripts against bounds" }, 00293 00294 { OVK_REPLACED, OV_INTERNAL, TRUE, "trapuv", NULL, 00295 0, 0, 0, const_cast<char*>("-DEBUG:trap_uninitialized"), NULL, 00296 "Trap references to uninitialized variables" }, 00297 00298 { OVK_COUNT } /* List terminator -- must be last */ 00299 }; 00300 00301 #undef ID 00302 00303 /* ==================================================================== 00304 * 00305 * DEBUG_Init_Config 00306 * 00307 * Initialize the current top of stack to defaults, by copying the 00308 * Default_DEBUG struct to it. Be careful not to lose the next 00309 * pointer. 00310 * 00311 * ==================================================================== 00312 */ 00313 00314 void 00315 DEBUG_Init_Config ( void ) 00316 { 00317 DEBUG_FLAGS *next = Current_DEBUG->next; 00318 00319 *Current_DEBUG = Default_DEBUG; 00320 Current_DEBUG->next = next; 00321 } 00322 00323 /* ==================================================================== 00324 * 00325 * DEBUG_Push_Config 00326 * 00327 * Push a new struct on top of stack, either a copy of the current 00328 * TOS, or the defaults. 00329 * 00330 * TODO: To make the option group printing functionality work once the 00331 * configuration structs start changing, this function must also update 00332 * the addresses in the group descriptor to point to the current 00333 * top-of-stack structure. 00334 * 00335 * ==================================================================== 00336 */ 00337 00338 void 00339 DEBUG_Push_Config ( BOOL use_default ) 00340 { 00341 DEBUG_FLAGS *new_flags = 00342 (DEBUG_FLAGS *) malloc ( sizeof(DEBUG_FLAGS) ); 00343 00344 if ( new_flags == NULL ) { 00345 ErrMsg ( EC_No_Mem, "DEBUG_Push" ); 00346 } 00347 00348 *new_flags = use_default ? Default_DEBUG : *Current_DEBUG; 00349 new_flags->next = Current_DEBUG; 00350 Current_DEBUG = new_flags; 00351 } 00352 00353 00354 00355 /* ==================================================================== 00356 * 00357 * DEBUG_Pop_Config 00358 * 00359 * Pop a struct from top of stack and return TRUE if the old TOS was 00360 * not the original TOS, or do nothing and return FALSE. 00361 * 00362 * TODO: To make the option group printing functionality work once the 00363 * configuration structs start changing, this function must also update 00364 * the addresses in the group descriptor to point to the current 00365 * top-of-stack structure. 00366 * 00367 * ==================================================================== 00368 */ 00369 00370 BOOL 00371 DEBUG_Pop_Config ( void ) 00372 { 00373 if ( Current_DEBUG->next == NULL ) { 00374 /* This is the bottom of the stack: */ 00375 return FALSE; 00376 } else { 00377 /* Deallocate the top element and pop it: */ 00378 DEBUG_FLAGS *new_flags = Current_DEBUG->next; 00379 free ( Current_DEBUG ); 00380 Current_DEBUG = new_flags; 00381 return TRUE; 00382 } 00383 } 00384 00385 00386 00387 /* ==================================================================== 00388 * 00389 * DEBUG_Configure_Alignment 00390 * 00391 * Configure generation of memory alignment instructions (ldl/ldr): 00392 * 00393 * normal: 00394 * generate ldl/ldr as needed 00395 * fixade: 00396 * mark .mips.options as needing kernel fixup traps enabled 00397 * compose: 00398 * generate composite compiler generated instructions to simulate 00399 * the unaligned memory access 00400 * 00401 * ==================================================================== 00402 */ 00403 static void DEBUG_Configure_Alignment(char *val) 00404 { 00405 if (val) 00406 { 00407 INT32 len = strlen(val); 00408 00409 if (ux_strncasecmp(val, "normal", len)==0) 00410 DEBUG_Alignment = ALIGN_NORMAL; 00411 else if (ux_strncasecmp(val, "fixade", len)==0) 00412 DEBUG_Alignment = ALIGN_FIXADE; 00413 else if (ux_strncasecmp(val, "compose", len)==0) 00414 DEBUG_Alignment= ALIGN_COMPOSE; 00415 else 00416 { 00417 ErrMsg ( EC_Inv_OPT, "DEBUG:alignment", val); 00418 } 00419 if (!DEBUG_Alignment_Normal) 00420 DevWarn("-DEBUG:alignment set to %s", val); 00421 } 00422 } 00423 00424 00425 00426 00427 /* ==================================================================== 00428 * 00429 * DEBUG_Configure 00430 * 00431 * Configure the current top of stack struct. 00432 * 00433 * ==================================================================== 00434 */ 00435 00436 void 00437 DEBUG_Configure ( void ) 00438 { 00439 OPTION_LIST *ol = Current_DEBUG->woff; 00440 00441 #ifdef FRONT_F90 00442 extern void add_cray_args ( char * ); 00443 extern void Cray_Woff ( char * ); 00444 #endif /* FRONT_F90 */ 00445 00446 /* TODO: Remove once everything has been rolled over: */ 00447 /* Process -DEBUG:div_check */ 00448 00449 /* -DEBUG:trap_uv_rjustify implies -DEBUG:trap_uv : */ 00450 if ( DEBUG_Trap_Uv_Rjustify ) { 00451 if ( ! DEBUG_Trap_Uv_Set ) 00452 DEBUG_Trap_Uv = TRUE; 00453 } 00454 00455 /* -DEBUG:int_overflow_check implies int32_overflow_check and 00456 * div_check=3: 00457 */ 00458 if ( DEBUG_Int_Overflow_Check ) { 00459 if ( ! DEBUG_Int32_Overflow_Check_Set ) 00460 DEBUG_Int32_Overflow_Check = TRUE; 00461 if ( ! DEBUG_Div_Check_Set ) 00462 DEBUG_Div_Check = DIV_ZERO_CHECK | DIV_OFLOW_CHECK; 00463 } 00464 00465 /* -DEBUG:Cray_port implies all the Cray porting options: */ 00466 if ( DEBUG_Cray_Port ) { 00467 if ( ! DEBUG_Equiv_Warning_Set ) 00468 DEBUG_Equiv_Warning = TRUE; 00469 if ( ! DEBUG_Full_Interface_Check_Set ) 00470 DEBUG_Full_Interface_Check = TRUE; 00471 if ( ! DEBUG_Int32_Overflow_Check_Set ) 00472 DEBUG_Int32_Overflow_Check = TRUE; 00473 if ( ! DEBUG_Pointer_Increment_Warning_Set ) 00474 DEBUG_Pointer_Increment_Warning = TRUE; 00475 if ( ! DEBUG_Printf_Warning_Set ) 00476 DEBUG_Printf_Warning = TRUE; 00477 if ( ! DEBUG_Shift_Check_Set ) 00478 DEBUG_Shift_Check = TRUE; 00479 if ( ! DEBUG_Shift_Warning_Set ) 00480 DEBUG_Shift_Warning = TRUE; 00481 if ( ! DEBUG_Trunc_Check_Set ) 00482 DEBUG_Trunc_Check = TRUE; 00483 if ( ! DEBUG_Trunc_Warning_Set ) 00484 DEBUG_Trunc_Warning = TRUE; 00485 } 00486 00487 // DEBUG:subscript_check implies conform_check unless the latter 00488 // has been explicitly turned off 00489 if (DEBUG_Subscript_Check && !DEBUG_Conform_Check_Set) { 00490 DEBUG_Conform_Check = TRUE; 00491 } 00492 00493 /* Process -DEBUG:fullwarn */ 00494 if ( DEBUG_Fullwarn ) { 00495 Min_Error_Severity = ES_ADVISORY; 00496 #ifdef FRONT_END 00497 #ifdef FRONT_F90 00498 add_cray_args ( "-m2" ); 00499 #else 00500 #ifdef EDGSRC 00501 error_threshold = es_remark; 00502 #endif /* EDGSRC */ 00503 #endif /* FRONT_F90 */ 00504 #endif /* FRONT_END */ 00505 } 00506 00507 /* Process -DEBUG:suppress=...:woff=... */ 00508 while ( ol != NULL ) { 00509 char *msg = OLIST_val(ol); 00510 00511 #ifdef FRONT_END 00512 #ifdef FRONT_F90 00513 Cray_Woff ( msg ); 00514 #else /* FRONT_F90 */ 00515 #ifdef EDGSRC 00516 process_diag_override_option ( optk_diag_suppress, msg ); 00517 #endif /* EDGSRC */ 00518 #endif /* ~FRONT_F90 */ 00519 #endif /* FRONT_END */ 00520 00521 Rag_Handle_Woff_Args ( msg ); 00522 00523 ol = OLIST_next(ol); 00524 } 00525 00526 #ifdef FRONT_END 00527 #ifndef FRONT_F90 00528 #ifdef EDGSRC 00529 /* Process -DEBUG:remark=... */ 00530 for ( ol = Current_DEBUG->remark; ol != NULL; ol = OLIST_next(ol) ) { 00531 char *msg = OLIST_val(ol); 00532 00533 process_diag_override_option ( optk_diag_remark, msg ); 00534 } 00535 00536 /* Process -DEBUG:warning=... */ 00537 for ( ol = Current_DEBUG->warning; ol != NULL; ol = OLIST_next(ol) ) { 00538 char *msg = OLIST_val(ol); 00539 00540 process_diag_override_option ( optk_diag_warning, msg ); 00541 } 00542 00543 /* Process -DEBUG:error=... */ 00544 for ( ol = Current_DEBUG->error; ol != NULL; ol = OLIST_next(ol) ) { 00545 char *msg = OLIST_val(ol); 00546 00547 process_diag_override_option ( optk_diag_error, msg ); 00548 } 00549 #endif /* EDGSRC */ 00550 #endif /* ~FRONT_F90 */ 00551 #endif /* FRONT_END */ 00552 00553 DEBUG_Configure_Alignment(Debug_Alignment_Name); 00554 00555 } 00556