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