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
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 #include "defs.h"
00076 #include "controls.h"
00077 #include "config.h"
00078 #include "erglob.h"
00079 #include "glob.h"
00080 #include "tracing.h"
00081
00082
00083 #define FOR_ALL_CONTROLS(i) for (i=CONTROL_FIRST; i<CONTROL_LAST; i++)
00084
00085 typedef struct str_list {
00086 const char* item;
00087 struct str_list *next;
00088 } STR_LIST;
00089
00090 #define STRLIST_item(x) (x)->item
00091
00092 #include "targ_ctrl.h"
00093
00094
00095 typedef struct {
00096 const char *name;
00097 CONTROL index;
00098 INT16 flags;
00099 INTPS first_def;
00100 INTPS sec_def;
00101 INTPS min_val,
00102 max_val;
00103 INTPS cur_val;
00104 INTPS prev_val;
00105 } CONTROL_INFO;
00106
00107 #define CI_HAS_AA_VAL 0x0001
00108 #define CI_HAS_ONCE_VAL 0x0002
00109
00110 #define CI_USER_SPECIFIED_IMPL 0x0004
00111
00112 #define CI_USER_SPECIFIED_EXPL 0x0008
00113
00114 #define CI_USER_SPECIFIED (CI_USER_SPECIFIED_IMPL|CI_USER_SPECIFIED_EXPL)
00115 #define CI_NAMELIST_TYPE 0x0010
00116
00117 #define CI_CAN_CHANGE 0x0020
00118 #define CI_SCOPE 0x0f00
00119 # define CI_SCOPE_LINE 0x0100
00120 # define CI_SCOPE_LOOP 0x0200
00121 # define CI_SCOPE_ROUTINE 0x0300
00122 # define CI_SCOPE_FILE 0x0400
00123 # define CI_SCOPE_COMPILATION 0x0500
00124 #define CI_HAS_CHANGED 0x1000
00125
00126 const char *ci_int_type_message = "Control %s expects integer values";
00127 const char *ci_nlist_type_message = "Control %s expects namelist values";
00128
00129 #define IS_INT_TYPED(ci) (Is_True(((ci)->flags&CI_NAMELIST_TYPE)==0,\
00130 (ci_int_type_message, ci->name)),(ci))
00131 #define IS_NLIST_TYPED(ci) (Is_True(((ci)->flags&CI_NAMELIST_TYPE),\
00132 (ci_nlist_type_message, ci->name)),(ci))
00133
00134 #define CI_int(ci,f) (IS_INT_TYPED(ci))->f
00135 #define CI_nlist(ci,f) ((STR_LIST*)(IS_NLIST_TYPED(ci))->f)
00136 #define Set_CI_int(ci,f,v) (IS_INT_TYPED(ci))->f=(v)
00137 #define Set_CI_nlist(ci,f,v) (IS_NLIST_TYPED(ci)->f)=((INTPS)(v))
00138
00139 #define CI_can_change(ci) ((ci)->flags & CI_CAN_CHANGE)
00140 #define CI_scope(ci) ((ci)->flags & CI_SCOPE)
00141
00142 #define CI_has_changed(ci) ((ci)->flags & CI_HAS_CHANGED)
00143 #define Set_CI_has_changed(ci) ((ci)->flags |= CI_HAS_CHANGED)
00144
00145 #define CI_has_AA_val(ci) ((ci)->flags & CI_HAS_AA_VAL)
00146 #define Set_CI_has_AA_val(ci) ((ci)->flags |= CI_HAS_AA_VAL)
00147 #define Reset_CI_has_AA_val(ci) ((ci)->flags &= ~CI_HAS_AA_VAL)
00148
00149 #define CI_has_once_val(ci) ((ci)->flags & CI_HAS_ONCE_VAL)
00150 #define Set_CI_has_once_val(ci) ((ci)->flags |= CI_HAS_ONCE_VAL)
00151 #define Reset_CI_has_once_val(ci) ((ci)->flags &= ~CI_HAS_ONCE_VAL)
00152
00153 #define CI_user_specified(ci) ((ci)->flags & CI_USER_SPECIFIED)
00154 #define Set_CI_user_specified(ci) ((ci)->flags |= CI_USER_SPECIFIED)
00155 #define Reset_CI_user_specified(ci) ((ci)->flags &= ~CI_USER_SPECIFIED)
00156
00157 #define CI_user_specified_impl(ci) ((ci)->flags & CI_USER_SPECIFIED_IMPL)
00158 #define Set_CI_user_specified_impl(ci) ((ci)->flags |= CI_USER_SPECIFIED_IMPL)
00159 #define Reset_CI_user_specified_impl(ci) ((ci)->flags &= ~CI_USER_SPECIFIED_IMPL)
00160
00161 #define CI_user_specified_expl(ci) ((ci)->flags & CI_USER_SPECIFIED_EXPL)
00162 #define Set_CI_user_specified_expl(ci) ((ci)->flags |= CI_USER_SPECIFIED_EXPL)
00163 #define Reset_CI_user_specified_expl(ci) ((ci)->flags &= ~CI_USER_SPECIFIED_EXPL)
00164
00165 #define CI_is_int_type(ci) (((ci)->flags & CI_NAMELIST_TYPE) == 0)
00166 #define CI_is_nlist_type(ci) ((ci)->flags & CI_NAMELIST_TYPE)
00167
00168
00169
00170
00171
00172 static BOOL Inside_A_Routine = FALSE;
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182 BOOL Diag_On_Pragmas
00183 #ifdef FRONT_END
00184 = TRUE
00185 #else
00186 = TRUE
00187 #endif
00188 ;
00189
00190
00191
00192
00193 static BOOL Diag_Controls = TRUE;
00194 #define Report_Error if (Diag_Controls) ErrMsg
00195
00196
00197
00198
00199
00200
00201
00202
00203 static STR_LIST ccv0 = {"cckr", NULL};
00204 static STR_LIST ccv1 = {"xansi", &ccv0};
00205 static STR_LIST ccv2 = {"cplus", &ccv1};
00206 static STR_LIST ccv = {"ansi", &ccv2};
00207
00208 static STR_LIST icv0 = {"signed", NULL};
00209 static STR_LIST icv = {"unsigned",&icv0};
00210
00211 static STR_LIST ocv0 = {"svr4", NULL};
00212 static STR_LIST ocv = {"svr3", &ocv0};
00213
00214 #define N CI_NAMELIST_TYPE
00215 #define MI 0x7fffffff
00216 #define H CI_CAN_CHANGE
00217 #define P CI_SCOPE_LOOP
00218 #define L CI_SCOPE_LINE
00219 #define R CI_SCOPE_ROUTINE
00220 #define F CI_SCOPE_FILE
00221 #define C CI_SCOPE_COMPILATION
00222
00223 CONTROL_INFO Aflag_Tbl[] = {
00224
00225 {NULL , CONTROL_MIN_CONTROL},
00226 {"acir" , CONTROL_ACIR , F, 1, 2, 0, 63},
00227 {"alias" , CONTROL_ALIAS , R, 1, 4, 0, 4},
00228 {"alndcl" , CONTROL_ALNDCL , R, 0, 1, 1, -1},
00229 {"alnref" , CONTROL_ALNREF , R, 0, 128, 0,255},
00230 {"alnstd" , CONTROL_ALNSTD , R, 0, 1, 0, 1},
00231 {"argoverlap", CONTROL_ARGOVERLAP ,N|R,0, 0, 0, 0},
00232 {"c" , CONTROL_C ,N|F,0, 0, (INTPS)&ccv},
00233 {"callmod" , CONTROL_CALLMOD , R, 0, 2, 0, 2},
00234 {"case" , CONTROL_CASE , F, 0, 1, 0, 1},
00235 {"char" , CONTROL_CHAR ,N|F,0, 0, (INTPS)&icv},
00236 {"chkargs" , CONTROL_CHKARGS , R, 0, 1, 0, 1},
00237 {"chkrec" , CONTROL_CHKREC , R, 0, 1, 0, 1},
00238 {"chksub" , CONTROL_CHKSUB , L, 0, 1, 0, 1},
00239 {"constp" , CONTROL_CONSTP ,H|R,0, 2, 0, 2},
00240 {"comname" , CONTROL_COMNAME , F, 1, 1, 0, 1},
00241 {"copyp" , CONTROL_COPYP ,H|R,0, 2, 0, 2},
00242 {"defargoverlap",CONTROL_DEFARGOVERLAP,L,0, 0, 0, 2},
00243 {"deffunc" , CONTROL_DEFFUNC , L, 1, 2, 0, 2},
00244 {"defkeepargs",CONTROL_DEFKEEPARGS, L, 1, 2, 0, 2},
00245 {"deflib" , CONTROL_DEFLIB , L, 2, 0, 0, 2},
00246 {"defnewmem" , CONTROL_DEFNEWMEM , L, 1, 2, 0, 2},
00247 {"defrec" , CONTROL_DEFREC , L, 1, 2, 0, 2},
00248 {"defsef" , CONTROL_DEFSEF , L, 1, 2, 0, 2},
00249 {"defsrc" , CONTROL_DEFSRC , L, 0, 2, 0, 2},
00250 {"defvol" , CONTROL_DEFVOL , L, 0, 2, 0, 2},
00251 {"diag" , CONTROL_DIAG , L, 1, 2, 0, 2},
00252 {"dline" , CONTROL_DLINE , L, 0, 1, 0, 1},
00253 {"domain" , CONTROL_DOMAIN , R, 1, 1, 0, 1},
00254 {"exits" , CONTROL_EXITS ,N|R,0, 0, 0, 0},
00255 {"fblank" , CONTROL_FBLANK , L, 0, 1, 0, 1},
00256 {"fcm" , CONTROL_FCM ,H|R,0, 1, 0, 2},
00257 {"fcols" , CONTROL_FCOLS , L,72, 0, 0, MI},
00258 {"feral" , CONTROL_FERAL ,N|L,0, 0, 0, 0},
00259 {"flow" , CONTROL_FLOW , R, 0, 1, 0, 1},
00260 {"fp" , CONTROL_FP , R, 0, 2, 0, 2},
00261 {"ftab" , CONTROL_FTAB , L, 1, 2, 0, 2},
00262 {"func" , CONTROL_FUNC ,N|L,0, 0, 0, 0},
00263 {"g" , CONTROL_G , F, 0, 2, 0, 3},
00264 {"inline" , CONTROL_INLINE ,N|L,0, 0, 0, 0},
00265 {"keepargs" , CONTROL_KEEPARGS ,N|L,0, 0, 0, 0},
00266 {"leaf" , CONTROL_LEAF , L, 0, 0, 0, 1},
00267 {"map" , CONTROL_MAP , F, 0, 1, 0, 1},
00268 {"memlimit" , CONTROL_MEMLIMIT ,H|F,0, 0, 0, MI},
00269 {"newmem" , CONTROL_NEWMEM ,N|L,0, 0, 0, 0},
00270 {"noargoverlap",CONTROL_NOARGOVERLAP,N|L,0, 0, 0, 0},
00271 {"nofunc" , CONTROL_NOFUNC ,N|L,0, 0, 0, 0},
00272 {"noinline" , CONTROL_NOINLINE ,N|L,0, 0, 0, 0},
00273 {"nokeepargs", CONTROL_NOKEEPARGS ,N|L,0, 0, 0, 0},
00274 {"nonewmem" , CONTROL_NONEWMEM ,N|L,0, 0, 0, 0},
00275 {"norec" , CONTROL_NOREC ,N|L,0, 0, 0, 0},
00276 {"nosef" , CONTROL_NOSEF ,N|L,0, 0, 0, 0},
00277 {"novol" , CONTROL_NOVOL ,N|L,0, 0, 0, 0},
00278 {"onetrip" , CONTROL_ONETRIP , P, 0, 1, 0, 1},
00279 {"oform" , CONTROL_OFORM ,N|C,0, 0, (INTPS) &ocv},
00280 {"mopt" , CONTROL_MOPT ,H|R,1, 3, 0, 3},
00281 {"prof" , CONTROL_PROF , R, 0, 1, 0, 1},
00282 {"ptrvol" , CONTROL_PTRVOL ,N|L,0, 0, 0, 0},
00283 {"quit" , CONTROL_QUIT , F, 0, 1, 0, 2},
00284 {"real" , CONTROL_REAL , F, 0, 0, 0, 8},
00285 {"recursive" , CONTROL_RECURSIVE ,N|L,0, 0, 0, 0},
00286 {"reg" , CONTROL_REG , R, 0, 3, 0, 3},
00287 {"retpts" , CONTROL_RETPTS , R, 0, 1, 0, 1},
00288 {"save" , CONTROL_SAVE , R, 0, 1, 0, 1},
00289 {"sched" , CONTROL_SCHED ,H|R,0, 1, 0, 1},
00290 {"sef" , CONTROL_SEF ,N|L,0, 0, 0, 0},
00291 {"stddiag" , CONTROL_STDDIAG , L, 0, 1, 0, 2},
00292 {"tame" , CONTROL_TAME ,N|L,0, 0, 0, 0},
00293 {"targ" , CONTROL_TARG ,N|C,TARG_FIRST_DEF, TARG_SECOND_DEF, (INTPS) &Possible_Targets},
00294 {"unroll" , CONTROL_UNROLL , P, 0, 1, 0, MI},
00295 {"unrollexact",CONTROL_UNROLLEXACT, P, 0, 1, 0, 1},
00296 {"volatile" , CONTROL_VOLATILE ,N|L,0, 0, 0, 0},
00297 {"whole" , CONTROL_WHOLE , C, 0, 1, 0, 1},
00298 {"wild" , CONTROL_WILD ,N|L,0, 0, 0, 0},
00299 {"xref" , CONTROL_XREF , F, 0, 1, 0, 1},
00300
00301
00302 {"ivrep" , CONTROL_IVREP ,H|R,0, 1, 0, 1},
00303 {"xopt" , CONTROL_XOPT , R, 0, 4, 0, 5},
00304
00305 {NULL , CONTROL_MAX_CONTROL}
00306 };
00307 #undef H
00308 #undef P
00309 #undef L
00310 #undef R
00311 #undef F
00312 #undef C
00313 #undef MI
00314 #undef N
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336 typedef struct o_gr_exp {
00337 const char *name;
00338 const char *val;
00339 } O_GR_EXP;
00340
00341 typedef struct {
00342 const char *name;
00343 INT16 flags, sec_def, min_val, max_val;
00344 O_GR_EXP *expansion;
00345 } CONTROL_GROUP_INFO;
00346
00347 #define CGI_IS_INT_TYPE 0x0001
00348 #define CGI_is_int_type(c) ((c)->flags & CGI_IS_INT_TYPE != 0)
00349
00350 static O_GR_EXP o_group_expansion[] = {
00351 { "no-opt",
00352 "callmod=0,constp=0,copyp=0,domain=1,flow=0,fcm=0,"
00353 "alias=0,mopt=0,reg=0,sched=0,unroll=0,whole=0" },
00354 { "local-opt",
00355 "callmod=0,constp=0,copyp=0,domain=1,flow=0,fcm=0,"
00356 "alias=1,mopt=1,reg=0,sched=0,unroll=0,whole=0" },
00357 { "global-opt",
00358 "callmod=1,constp=2,copyp=2,domain=1,flow=1,fcm=1,"
00359 "alias=3,mopt=3,reg=1,sched=1,unroll=0,whole=0" },
00360 { "swp-opt",
00361 "callmod=1,constp=2,copyp=2,domain=1,flow=1,fcm=1,"
00362 "alias=3,mopt=3,reg=1,sched=1,unroll=0,whole=0" },
00363 };
00364
00365 static O_GR_EXP f_group_expansion[] = {
00366 {"classic", "fcols=72,ftab=0,fblank=1" },
00367 {"svs72" , "fcols=72,ftab=0,fblank=0" },
00368 {"svs120" , "fcols=120,ftab=0,fblank=1" },
00369 {"normal" , "fcols=72,ftab=1,fblank=0" },
00370 {"vax72" , "fcols=72,ftab=1,fblank=1" },
00371 {"vax132" , "fcols=132,ftab=1,fblank=1" },
00372 {"mips72" , "fcols=72,ftab=2,fblank=0" },
00373 {"unix72" , "fcols=72,ftab=2,fblank=1" },
00374 {"unix" , "fcols=0,ftab=2,fblank=1" }
00375 };
00376
00377 static CONTROL_GROUP_INFO Control_Group_Tbl[] = {
00378 {"OPT", CGI_IS_INT_TYPE, 2, 0, 3, o_group_expansion},
00379 {"FORT", 0, 8, 0, 0, f_group_expansion},
00380 { NULL, 0, 0, 0, 0, 0, }
00381 };
00382
00383 static STR_LIST *make_nlist(char *name, STR_LIST *next)
00384 {
00385 STR_LIST *r = (STR_LIST *) Src_Alloc(sizeof(STR_LIST));
00386 r->item = strcpy((char *)Src_Alloc(strlen(name)+1),name);
00387 r->next = next;
00388 return r;
00389 }
00390
00391 #define IS_ID_CHAR(c) (((c)>='0'&&(c)<='9')||((c)=='-')||(nlist_ctrl&&\
00392 (((c)>='a'&&(c)<='z')||((c)=='_')||((c)>='A'&&(c)<='Z')||((c)=='$'))))
00393
00394 #define ERRORS_FOUND 1
00395 #define NO_ERRORS_FOUND 0
00396
00397 static INT store_ctrl(char *, STR_LIST *, INT);
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413 static BOOL
00414 is_nlist_typed ( char *name )
00415 {
00416 if (name[0] >= 'A' && name[0] <= 'Z') {
00417 CONTROL_GROUP_INFO *cgi;
00418 for (cgi = Control_Group_Tbl; cgi->name; cgi++)
00419 if (name[0] == cgi->name[0])
00420 return !(CGI_is_int_type(cgi));
00421 } else {
00422 CONTROL_INFO *a;
00423 INT i;
00424 for ( i=CONTROL_FIRST,a=Aflag_Tbl+(INT)i; i<CONTROL_LAST; i++,a++)
00425 if (a->name && strcmp(name, a->name) == 0)
00426 return CI_is_nlist_type(a);
00427 }
00428 return FALSE;
00429 }
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442 INT
00443 Process_Control_Opt ( const char *save_a, INT flags )
00444 {
00445 char *name, ch, *s, *a;
00446 INT nlist_ctrl, found_lpar;
00447 STR_LIST *nl;
00448
00449 a = strcpy((char *)Src_Alloc(strlen(save_a)+1), save_a);
00450 while (1) {
00451 name = a;
00452 ch = a[0];
00453 if (ch >= 'A' && ch <= 'Z') {
00454
00455 a++;
00456 } else if (ch >= 'a' && ch <= 'z') {
00457 a++;
00458 while ((ch = a[0]) && ch >= 'a' && ch <= 'z')
00459 a++;
00460 } else {
00461 Report_Error ( EC_Ctrl_Syntax, save_a );
00462 return ERRORS_FOUND;
00463 }
00464 name = strncpy((char *)Src_Alloc(a-name+1), name, a-name);
00465 if (a[0] == '\0') {
00466
00467 return store_ctrl(name, NULL, flags);
00468 }
00469
00470
00471
00472
00473 nlist_ctrl = is_nlist_typed(name);
00474 if (a[0] != '=') {
00475 if (a[0] == ',') {
00476 *a = '\0';
00477
00478 if (store_ctrl(name, NULL, flags))
00479 return ERRORS_FOUND;
00480 a++;
00481 continue;
00482 }
00483 } else {
00484 a[0] = '\0';
00485 a++;
00486 }
00487
00488 if (a[0] == '(' ) {
00489 a[0] = '\0';
00490 found_lpar = 1;
00491 a++;
00492 } else
00493 found_lpar = 0;
00494 nl = NULL;
00495 while (1) {
00496 INT ef;
00497 s = a;
00498 if (!IS_ID_CHAR(a[0])) {
00499 Report_Error ( EC_Ctrl_Syntax, save_a );
00500 return ERRORS_FOUND;
00501 }
00502 while ((ch = a[0]) && IS_ID_CHAR(ch)) a++;
00503 if (ch == '\0') {
00504 return store_ctrl(name, make_nlist(s, nl), flags);
00505 }
00506 if (found_lpar && ch == ',') {
00507 a[0] = '\0';
00508 a++;
00509 nl = make_nlist(s, nl);
00510 continue;
00511 }
00512 ch = a[0]; a[0] = '\0';
00513 ef = store_ctrl(name, make_nlist(s, nl), flags);
00514 a[0] = ch;
00515 if (ef) return ERRORS_FOUND;
00516 break;
00517 }
00518 if ((a[0] == ')') != found_lpar) {
00519 Report_Error ( EC_Ctrl_Paren, save_a );
00520 return ERRORS_FOUND;
00521 }
00522 if (a[0] == ')')
00523 *a++ = '\0';
00524 if (a[0] == ',')
00525 *a++ = '\0';
00526 if (a[0] == '\0')
00527 break;
00528 }
00529 return NO_ERRORS_FOUND;
00530 }
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541 static BOOL
00542 same_name_lists ( STR_LIST *a, STR_LIST *b )
00543 {
00544 STR_LIST *p;
00545 INT16 ac, bc;
00546 for (ac =0 , p = a; p; p = p->next) ac++;
00547 for (bc =0 , p = b; p; p = p->next) bc++;
00548 if (ac != bc)
00549 return FALSE;
00550 while (a) {
00551 BOOL found = FALSE;
00552 const char *ai = a->item;
00553 for (p = b; p; p = p->next)
00554 if (strcmp(p->item, ai) == 0) {
00555 found = TRUE;
00556 break;
00557 }
00558 if (!found)
00559 return FALSE;
00560 a = a->next;
00561 }
00562 return TRUE;
00563 }
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574 static void
00575 push_cur_val ( CONTROL_INFO *a )
00576 {
00577 Set_CI_has_once_val(a);
00578 a->prev_val = a->cur_val;
00579 }
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590 #define CI_name(a) ((a)->name)
00591
00592 #define debugging FALSE
00593 #define dprintf if (debugging) printf
00594
00595 static INT
00596 store_ctrl ( char *name, STR_LIST *name_list, INT flags )
00597 {
00598 CONTROL_INFO *a;
00599 BOOL ok_int;
00600 INT32 int_val;
00601
00602 if ( debugging ) {
00603 STR_LIST *nl = name_list;
00604 printf("store_ctrl: %s ", name);
00605 while (nl) {
00606 printf("%s,", nl->item);
00607 nl = nl->next;
00608 }
00609 printf("\n");
00610 }
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620 int_val = 0;
00621 if (name_list == NULL) {
00622 ok_int = TRUE;
00623 } else if (name_list->next == NULL) {
00624 const char *v = name_list->item;
00625 if (*v == '-') v++;
00626 else if (*v == '+') v++;
00627 while (v[0] >= '0' && v[0] <= '9') v++;
00628 ok_int = v[0] == '\0';
00629 if (ok_int) int_val = atoi(name_list->item);
00630 } else {
00631 ok_int = FALSE;
00632 }
00633
00634
00635 if (name[0] >= 'A' && name[0] <= 'Z') {
00636 CONTROL_GROUP_INFO *cgi;
00637 Is_True(name[1] == '\0', ("Multiple character group name ?"));
00638 for (cgi = Control_Group_Tbl; cgi->name; cgi++) {
00639 if (name[0] == cgi->name[0]) {
00640 INT v;
00641 if (CGI_is_int_type(cgi)) {
00642 if (!ok_int) {
00643 Report_Error ( EC_Ctrl_Integer, cgi->name );
00644 return ERRORS_FOUND;
00645 }
00646 v = name_list ? int_val : cgi->sec_def;
00647 if (v < cgi->min_val || v > cgi->max_val) {
00648 Report_Error ( EC_Group_Range, v, cgi->name,
00649 cgi->min_val, cgi->max_val);
00650 return ERRORS_FOUND;
00651 }
00652 } else {
00653
00654
00655
00656 if (name_list == NULL)
00657 v = cgi->sec_def;
00658 else {
00659 O_GR_EXP *o;
00660 if (name_list->next) {
00661 Report_Error ( EC_Group_Mult, cgi->name );
00662 return ERRORS_FOUND;
00663 }
00664 v = 0;
00665 for (o = cgi->expansion; o->val; o++,v++)
00666 if (strcmp(name_list->item, o->name) == 0)
00667 break;
00668 if (o == NULL) {
00669 Report_Error (EC_Inv_Ctrl_Val, name_list->item, cgi->name);
00670 return ERRORS_FOUND;
00671 }
00672 }
00673 }
00674 return Process_Control_Opt(cgi->expansion[v].val, flags | HCO_IMPLICIT);
00675 }
00676 }
00677 Report_Error ( EC_Unrec_Group, name );
00678 return ERRORS_FOUND;
00679 }
00680
00681 for (INT i=CONTROL_FIRST; i<CONTROL_LAST; i++ ) {
00682 a = &Aflag_Tbl[i];
00683
00684 if (a->name && strcmp(name, a->name) == 0) {
00685 BOOL changed;
00686 if ((flags & HCO_ONCE) && CI_scope(a) == CI_SCOPE_LOOP)
00687 Report_Error ( EC_Unimp_Once, a->name );
00688
00689 if (CI_is_nlist_type(a)) {
00690 STR_LIST *p;
00691
00692 dprintf ( " %s: namelist value\n", a->name );
00693 p = CI_nlist(a,min_val);
00694 if (name_list == NULL)
00695 name_list = CI_nlist(a, sec_def);
00696 if (p) {
00697
00698
00699 while (p) {
00700 if (strcmp(p->item,name_list->item) == 0)
00701 break;
00702 p = p->next;
00703 }
00704 if (p == NULL) {
00705 Report_Error ( EC_Inv_Ctrl_Val, name_list->item, a->name );
00706 return ERRORS_FOUND;
00707 }
00708 }
00709 if (same_name_lists(name_list, CI_nlist(a, cur_val)))
00710 changed = FALSE;
00711 else {
00712 if (CI_has_AA_val(a)) {
00713 Report_Error ( EC_Change_AA, CI_name(a) );
00714 }
00715 else {
00716 if (flags & HCO_ONCE)
00717 push_cur_val(a);
00718 Set_CI_nlist(a, cur_val, name_list);
00719 changed = TRUE;
00720 }
00721 }
00722
00723 } else {
00724 INT v;
00725 if (!ok_int) {
00726 Report_Error ( EC_Ctrl_Numeric, a->name );
00727 return ERRORS_FOUND;
00728 }
00729 v = (name_list) ? int_val : CI_int(a, sec_def);
00730 dprintf ( " %s: integer value %d (current %ld)\n",
00731 a->name, v, a->cur_val );
00732 if (v < CI_int(a, min_val) || v > CI_int(a, max_val)) {
00733 Report_Error ( EC_Ctrl_Range, v, a->name,
00734 CI_int(a,min_val), CI_int(a,max_val));
00735 return ERRORS_FOUND;
00736 }
00737 if ( v != a->cur_val ) {
00738 if (CI_has_AA_val(a)) {
00739 Report_Error ( EC_Change_AA, CI_name(a) );
00740 } else {
00741 if (flags & HCO_ONCE) push_cur_val(a);
00742 changed = TRUE;
00743 dprintf ( " %s: %d (was %ld)\n", a->name, v, a->cur_val );
00744 Set_CI_int (a, cur_val, v);
00745 }
00746 } else {
00747 changed = FALSE;
00748 dprintf ( " %s: unchanged\n", a->name );
00749 }
00750 }
00751
00752
00753
00754
00755 if (changed && (flags & HCO_PRAGMA)) {
00756 if (CI_scope(a) >= CI_SCOPE_FILE) {
00757 Report_Error ( EC_File_Scope, CI_name(a) );
00758 return ERRORS_FOUND;
00759 } else if (CI_scope(a) == CI_SCOPE_ROUTINE && Inside_A_Routine) {
00760 Report_Error ( EC_Routine_Scope, CI_name(a) );
00761 return ERRORS_FOUND;
00762 }
00763 Set_CI_has_changed(a);
00764 }
00765 if (flags & HCO_AAVAL)
00766 Set_CI_has_AA_val(a);
00767 if (CI_user_specified_expl(a) && changed && (flags & HCO_PRAGMA) == 0)
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777 Report_Error ( EC_Override, a->name,
00778 (flags & HCO_IMPLICIT) ? "implicit flag"
00779 : "another explicit setting");
00780 if (flags & HCO_IMPLICIT)
00781 Set_CI_user_specified_impl(a);
00782 else
00783 Set_CI_user_specified_expl(a);
00784 return NO_ERRORS_FOUND;
00785 }
00786 }
00787 Report_Error ( EC_Unimp_Actrl, name );
00788 return ERRORS_FOUND;
00789 }
00790
00791
00792
00793
00794 #define CI_allowed_vals(a) CI_nlist(a,min_val)
00795 void
00796 Init_Controls_Tbl ( void )
00797 {
00798 CONTROL_INFO *a;
00799 BOOL trace = Get_Trace ( TP_MISC, 1 );
00800
00801 for (INT i=CONTROL_FIRST; i<CONTROL_LAST; i++ ) {
00802 a = &Aflag_Tbl[i];
00803 if (a->name == NULL)
00804 break;
00805 Is_True(a->index == i,
00806 ("Aflag_Tbl index mismatch: i=%1d a->index=%1d(%s)", i, a->index, a->name));
00807 if (CI_is_int_type(a)) {
00808 if (a->max_val <= a->min_val) {
00809 Is_True(a->max_val == -1 && a->min_val == 1,
00810 ("inconsistent min_val and max_val of %s: %1d %1d",
00811 a->name, a->min_val, a->max_val));
00812 } else {
00813 Is_True(a->first_def >= a->min_val && a->first_def <= a->max_val,
00814 ("inconsistent first_def(%1d) of %s: %1d..%1d",
00815 a->first_def,a->name, a->min_val, a->max_val));
00816 Is_True(a->sec_def >= a->min_val && a->sec_def <= a->max_val,
00817 ("inconsistent sec_def(%1d) of %s: %1d..%1d",
00818 a->first_def,a->name, a->min_val, a->max_val));
00819 }
00820 } else {
00821
00822
00823
00824
00825 STR_LIST *v, *v1; INT sc;
00826 v = CI_allowed_vals(a);
00827 if (v) {
00828 sc = a->sec_def;
00829 while (sc-- > 0) v = v->next;
00830 v1 = (STR_LIST *) calloc(1, sizeof(STR_LIST));
00831 v1->item = v->item;
00832 Set_CI_nlist(a, sec_def, v1);
00833 v = CI_allowed_vals(a);
00834 sc = a->first_def;
00835 while (sc-- > 0) v = v->next;
00836 v1 = (STR_LIST *) calloc(1, sizeof(STR_LIST));
00837 v1->item = v->item;
00838 Set_CI_nlist(a, first_def, v1);
00839 }
00840 }
00841 a->cur_val = a->first_def;
00842 }
00843
00844 if ( trace ) {
00845 fprintf ( TFile, "\nInit_Controls_Tbl:\n" );
00846 Print_Controls ( TFile, "<init>", TRUE );
00847 }
00848 }
00849
00850 #ifndef DRIVER
00851
00852 typedef struct {
00853 INT32 value[(INT)CONTROL_MAX_CONTROL];
00854 } CTRL_VAL_SET;
00855
00856 CTRL_VAL_SET routine_top_values;
00857
00858
00859
00860
00861
00862
00863 CTRL_VAL_SET cmd_line_values;
00864
00865 static void
00866 save_ctrl_val_set ( CTRL_VAL_SET *s )
00867 {
00868 INT i;
00869 for (i=CONTROL_FIRST; i<CONTROL_MAX_CONTROL; i++)
00870 s->value[i] = Aflag_Tbl[i].cur_val;
00871 }
00872
00873 static void
00874 restore_ctrl_val_set ( CTRL_VAL_SET *r )
00875 {
00876 INT i;
00877 for (i=CONTROL_FIRST; i<CONTROL_MAX_CONTROL; i++)
00878 Aflag_Tbl[i].cur_val = r->value[i];
00879 }
00880
00881
00882 void
00883 Save_Routine_Top_Ctrls ( void )
00884 {
00885 BOOL trace = Get_Trace ( TP_MISC, 1 );
00886
00887 save_ctrl_val_set(&routine_top_values);
00888 Inside_A_Routine = TRUE;
00889
00890 if ( trace ) {
00891 fprintf ( TFile, "\nSave_Routine_Top_Ctrls:\n" );
00892 Print_Controls ( TFile, "<SRTC>", TRUE );
00893 }
00894 }
00895
00896 void
00897 Restore_Routine_Top_Ctrls ( void )
00898 {
00899 BOOL trace = Get_Trace ( TP_MISC, 1 );
00900
00901 restore_ctrl_val_set(&routine_top_values);
00902 Inside_A_Routine = FALSE;
00903
00904 if ( trace ) {
00905 fprintf ( TFile, "\nRestore_Routine_Top_Ctrls:\n" );
00906 Print_Controls ( TFile, "<RRTC>", TRUE );
00907 }
00908 }
00909
00910 void
00911 Restore_Cmd_Line_Ctrls ( void )
00912 {
00913 BOOL trace = Get_Trace ( TP_MISC, 1 );
00914
00915 restore_ctrl_val_set(&cmd_line_values);
00916
00917 if ( trace ) {
00918 fprintf ( TFile, "\nRestore_Cmd_Line_Ctrls:\n" );
00919 Print_Controls ( TFile, "<RCLC>", TRUE );
00920 }
00921 }
00922
00923 void
00924 Apply_Controls ( void )
00925 {
00926 INT i;
00927 CONTROL_INFO *a;
00928 INT32 control_ival;
00929
00930 save_ctrl_val_set(&cmd_line_values);
00931
00932 for ( i=CONTROL_FIRST,a=Aflag_Tbl+(INT)i; i<CONTROL_LAST; i++,a++) {
00933 if (CI_user_specified(a)) {
00934 switch (a->index) {
00935 case CONTROL_C:
00936 case CONTROL_CHAR:
00937 case CONTROL_ALIAS:
00938 case CONTROL_CASE:
00939 case CONTROL_CALLMOD:
00940 case CONTROL_DEFVOL:
00941 case CONTROL_DLINE:
00942 case CONTROL_MAP:
00943 case CONTROL_UNROLL:
00944 case CONTROL_UNROLLEXACT:
00945 break;
00946
00947 case CONTROL_ALNREF:
00948 Allow_Word_Aligned_Doubles = FALSE;
00949 control_ival = Get_Int_Ctrl_Val(CONTROL_ALNREF);
00950 if ( control_ival == 128 ) {
00951
00952 Allow_Word_Aligned_Doubles = TRUE;
00953 } else {
00954 Report_Error ( EC_Unimp_Align, a->name, control_ival );
00955 }
00956 break;
00957
00958 case CONTROL_DIAG:
00959 if (a->cur_val == 0)
00960 Min_Error_Severity = ES_ERROR;
00961 break;
00962
00963 default:
00964
00965 break;
00966 }
00967 }
00968 }
00969
00970
00971 Diag_Controls = Diag_On_Pragmas;
00972 }
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982 void
00983 Apply_Routine_Scope_Controls ( void )
00984 {
00985 Symbolic_Debug_Mode = SDM_NONE;
00986 switch (Get_Int_Ctrl_Val(CONTROL_FP)) {
00987 case 2:
00988 Symbolic_Debug_Mode |= SDM_USE_FP;
00989
00990 case 1:
00991 Symbolic_Debug_Mode |= SDM_GEN_FP;
00992 }
00993 if (Get_Int_Ctrl_Val(CONTROL_G))
00994 Symbolic_Debug_Mode |= (SDM_LINE|SDM_SYMBOL);
00995 Max_Symbolic_Debug_Mode = Symbolic_Debug_Mode;
00996 }
00997 #endif
00998
00999 INT32
01000 Get_Int_Ctrl_Val ( CONTROL a )
01001 {
01002 #ifdef Is_True_On
01003 Is_True((Aflag_Tbl[a].flags & CI_NAMELIST_TYPE) == 0,
01004 ("Control %s does not have integral value", Aflag_Tbl[a].name));
01005 #endif
01006 return CI_int((Aflag_Tbl+ (INT)a),cur_val);
01007 }
01008
01009 const char *
01010 Get_Name_Ctrl_Val ( CONTROL a )
01011 {
01012 #ifdef Is_True_On
01013 Is_True(Aflag_Tbl[a].flags & CI_NAMELIST_TYPE,
01014 ("Control %s does not have name-list value", Aflag_Tbl[a].name));
01015 #endif
01016 return STRLIST_item(CI_nlist((Aflag_Tbl+ (INT)a),cur_val));
01017 }
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031 void
01032 Pop_Controls ( INT32 level )
01033 {
01034 CONTROL_INFO *a;
01035 INT i;
01036
01037 for ( i=CONTROL_FIRST,a=Aflag_Tbl+(INT)i; i<CONTROL_LAST; i++,a++)
01038 if (CI_scope(a) == level && CI_has_once_val(a)) {
01039 Reset_CI_has_once_val(a);
01040 Aflag_Tbl[i].cur_val = Aflag_Tbl[i].prev_val;
01041 }
01042 }
01043
01044
01045
01046 void
01047 Pop_Once_Line_Controls ( void )
01048 {
01049 Pop_Controls(CI_SCOPE_LINE);
01050 }
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063 INT
01064 Process_Pragma ( char *x )
01065 {
01066 INT flags = HCO_PRAGMA;
01067
01068 INT rv = 0;
01069
01070 while (x[0] == ' ' || x[0] == '\t') x++;
01071 if (x[0] == '%' && (x[1]=='o' || x[1]=='O') && (x[2]=='n' || x[2]=='N') &&
01072 (x[3] == 'c' || x[3] == 'C') && (x[4] == 'e' || x[4] == 'E')) {
01073 flags = HCO_PRAGMA | HCO_ONCE;
01074 x += 5;
01075 } else
01076 flags = HCO_PRAGMA;
01077
01078
01079 while (1) {
01080 const char *r;
01081 char ch;
01082 while (x[0] == ' ' || x[0] == '\t') x++;
01083 if (x[0] == '\0') return rv;
01084 r = x;
01085 while (x[0] != '\0' && x[0] != ' ' && x[0] != '\t') x++;
01086 ch = x[0];
01087 x[0] = '\0';
01088 rv |= Process_Control_Opt(r, flags);
01089 if (ch == '\0') return rv;
01090 x[0] = ch;
01091 }
01092 }
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105 void
01106 Print_Controls ( FILE *fp, const char *tag, BOOL def )
01107 {
01108 CONTROL_INFO *a;
01109 BOOL defaulted;
01110
01111 for (INT i=CONTROL_FIRST; i<CONTROL_LAST; i++ ) {
01112 a = &Aflag_Tbl[i];
01113 defaulted = (a->cur_val == a->first_def);
01114 if ( def || !defaulted ) {
01115 fprintf(fp, "%s %s%s = ", tag, defaulted ? "*" : " ", a->name);
01116 if ( CI_is_int_type(a) )
01117 fprintf ( fp, "%ld\n", a->cur_val );
01118 else {
01119 STR_LIST *s = CI_nlist(a, cur_val);
01120 while (s) {
01121 fprintf ( fp, " %s%s", s->item, s->next ? ",":"" );
01122 s = s->next;
01123 }
01124 fprintf ( fp, "\n" );
01125 }
01126 }
01127 }
01128
01129 }
01130
01131
01132 void Fix_g_O( void )
01133 {
01134 #ifdef TARG_IA64
01135 if (Debug_Level == 2 || Debug_Level == 1) {
01136 #else
01137 if (Debug_Level >= 2) {
01138 #endif
01139 if (Opt_Level > 0) {
01140 #ifdef FRONT_END
01141 ErrMsg(EC_Fix_g_O);
01142 #endif
01143 Opt_Level = 0;
01144 }
01145
01146 Set_CI_int((Aflag_Tbl+CONTROL_CALLMOD),cur_val, 0);
01147 Set_CI_int((Aflag_Tbl+CONTROL_CONSTP),cur_val, 0);
01148 Set_CI_int((Aflag_Tbl+CONTROL_COPYP),cur_val, 0);
01149 Set_CI_int((Aflag_Tbl+CONTROL_DOMAIN),cur_val, 1);
01150 Set_CI_int((Aflag_Tbl+CONTROL_FLOW),cur_val, 0);
01151 Set_CI_int((Aflag_Tbl+CONTROL_FCM),cur_val, 0);
01152 Set_CI_int((Aflag_Tbl+CONTROL_ALIAS),cur_val, 0);
01153 Set_CI_int((Aflag_Tbl+CONTROL_MOPT),cur_val, 0);
01154 Set_CI_int((Aflag_Tbl+CONTROL_REG),cur_val, 0);
01155 Set_CI_int((Aflag_Tbl+CONTROL_SCHED),cur_val, 0);
01156 Set_CI_int((Aflag_Tbl+CONTROL_XOPT),cur_val, 0);
01157 }
01158 }