1 /* 2 * Copyright (c) 1993-2019, NVIDIA CORPORATION. All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 */ 17 18 #ifndef SEMANT_H_ 19 #define SEMANT_H_ 20 21 /** 22 \file 23 \brief Fortran semantic analyzer data definitions. 24 */ 25 26 #include "symtab.h" 27 28 #define S_NULL 0 29 #define S_CONST 1 30 #define S_EXPR 2 31 #define S_LVALUE 3 32 #define S_LOGEXPR 4 33 #define S_STAR 5 34 #define S_VAL 6 35 #define S_IDENT 7 36 #define S_LABEL 8 37 #define S_STFUNC 9 38 #define S_REF 10 39 #define S_TRIPLE 11 40 #define S_KEYWORD 12 41 42 #define OP_NEG 0 43 #define OP_ADD 1 44 #define OP_SUB 2 45 #define OP_MUL 3 46 #define OP_DIV 4 47 #define OP_XTOI 5 48 #define OP_XTOK 6 49 #define OP_XTOX 7 50 #define OP_CMP 8 51 #define OP_AIF 9 52 #define OP_LD 10 53 #define OP_ST 11 54 #define OP_FUNC 12 55 #define OP_CON 13 56 #define OP_CAT 14 57 #define OP_LOG 15 58 #define OP_LEQV 16 59 #define OP_LNEQV 17 60 #define OP_LOR 18 61 #define OP_LAND 19 62 #define OP_EQ 20 63 #define OP_GE 21 64 #define OP_GT 22 65 #define OP_LE 23 66 #define OP_LT 24 67 #define OP_NE 25 68 #define OP_LNOT 26 69 70 /* Different types of atomic actions. */ 71 #define ATOMIC_UNDEF -1 72 #define ATOMIC_UPDATE 1 73 #define ATOMIC_READ 2 74 #define ATOMIC_WRITE 3 75 #define ATOMIC_CAPTURE 4 76 77 /* 78 * Generate lexical block debug information? Criteria: 79 * -debug 80 * not -Mvect (!flg.vect) 81 * not -Mconcur (!XBIT(34,0x200) 82 * lex block disabled (!XBIT(123,0x4000)) 83 */ 84 #define DBG_LEXBLK \ 85 flg.debug && !flg.vect && !XBIT(34, 0x200) && !XBIT(123, 0x400) 86 87 typedef struct xyyz { 88 struct xyyz *next; 89 union { 90 int sptr; 91 int ilm; 92 struct sst *stkp; 93 INT conval; 94 ISZ_T szv; 95 } t; 96 } ITEM; 97 #define ITEM_END ((ITEM *)1) 98 99 typedef struct { 100 int index_var; /* do index variable */ 101 int count_var; 102 int top_label; 103 int zerot_label; 104 int init_expr; 105 int limit_expr; 106 int step_expr; 107 int lastval_var; 108 int collapse; /* collapse level if loop is within a collapse set of 109 * loops; 1 is innermost 110 */ 111 char prev_dovar; /* DOVAR flag of index variable before it's entered */ 112 } DOINFO; 113 114 typedef struct reduc_sym { 115 int shared; /* shared symbol */ 116 int Private; /* private copy */ 117 struct reduc_sym *next; 118 } REDUC_SYM; 119 120 typedef struct reduc_tag { /* reduction clause item */ 121 int opr; /* if != 0, OP_xxx value */ 122 int intrin; /* if != 0, sptr to intrinsic */ 123 REDUC_SYM *list; /* list of shared variables & private copies */ 124 struct reduc_tag *next; 125 } REDUC; 126 127 typedef struct noscope_sym { 128 int oldsptr; 129 int newsptr; 130 int lineno; 131 bool is_dovar; 132 } NOSCOPE_SYM; 133 134 typedef struct { /* DO-IF stack entries */ 135 int Id; 136 int lineno; /* beginning line# of control structure */ 137 int nest; /* bit vector indicating the structures are present 138 * in the stack including the current structure 139 */ 140 int name; /* index into the symbol names area representing the 141 * name of the construct; 0 if construct is not named. 142 */ 143 int exit_label; /* For a DO loop, the label (target) of an EXIT 144 * stmt; 0 if the EXIT stmt is not present. 145 * For block-if construct, the label of the 146 * statement after the matching endif; created 147 * if else-if is present; 0 if else-if not present. 148 * For a case-construct, label of the statement after 149 * the case construct 150 */ 151 union { 152 struct { /* IF statements */ 153 int false_lab; 154 } u1; 155 struct { /* DO statements */ 156 int do_label; 157 int cycle_label; 158 DOINFO *doinfo; 159 } u2; 160 } u; 161 struct { /* OpenMP stuff */ 162 REDUC *reduc; /* reductions for parallel constructs */ 163 REDUC_SYM *lastprivate; /* lastprivate for parallel constructs */ 164 ITEM *allocated; /* list of allocated private variables */ 165 ITEM *dfltal; /* list of default private/firstprivate 166 * allocated variables. 167 */ 168 REDUC_SYM *dfltfp; /* list of default firstprivate variables */ 169 NOSCOPE_SYM *no_scope_base; /* list of variables without scope 170 * with default(none) 171 */ 172 int no_scope_avail; 173 int no_scope_size; 174 175 union { 176 struct { /* parallel sections */ 177 int sect_lab; /* sptr of label beginning a SECTIONS 178 * or SECTION. sptr of the global 179 * semaphore variable created for 180 * CRITICAL <ident> 181 */ 182 int sect_cnt; /* number of SECTION blocks */ 183 int sect_var; /* where to store section number */ 184 } v1; 185 struct { /* parallel do statements */ 186 int sched_type; /* one of DI_SCHxxx if a parallel do */ 187 int chunk; /* When the parallel do is parsed, this 188 * field is the sptr representing the chunk size 189 * (0 if not present). When the parallel do's 190 * corresponding DO statement is processed, this 191 * field, possibly NULL, is a 'doinfo' record whose 192 * interpretation depends on the scheduling type: 193 * DI_SCH_STATIC - information for iterating 194 * thru a chunk. 195 * Other - information for the outer 196 * scheduling loop. 197 */ 198 bool is_ordered; /* loop has the ordered attribute */ 199 } v2; 200 } v; 201 } omp; 202 } DOIF; 203 204 #define DI_IF 0 205 #define DI_DO 1 206 #define DI_DOW 2 207 #define DI_PAR 3 208 #define DI_PARDO 4 209 #define DI_PDO 5 210 #define DI_DOACROSS 6 211 #define DI_PARSECTS 7 212 #define DI_SECTS 8 213 #define DI_SINGLE 9 214 #define DI_CRITICAL 10 215 #define DI_MASTER 11 216 #define DI_ORDERED 12 217 #define DI_TASK 13 218 #define DI_ATOMIC_CAPTURE 14 219 220 #define DI_SCH_STATIC 0 221 #define DI_SCH_DYNAMIC 1 222 #define DI_SCH_GUIDED 2 223 #define DI_SCH_INTERLEAVE 3 224 #define DI_SCH_RUNTIME 4 225 #define DI_SCH_AUTO 5 226 #define DI_SCH_DIST_STATIC 6 227 228 #define DI_ID(d) sem.doif_base[d].Id 229 #define DI_LINENO(d) sem.doif_base[d].lineno 230 #define DI_NEST(d) sem.doif_base[d].nest 231 #define DI_NAME(d) sem.doif_base[d].name 232 #define DI_EXIT_LAB(d) sem.doif_base[d].exit_label 233 #define DI_FALSE_LAB(d) sem.doif_base[d].u.u1.false_lab 234 #define DI_DO_LABEL(d) sem.doif_base[d].u.u2.do_label 235 #define DI_CYCLE_LABEL(d) sem.doif_base[d].u.u2.cycle_label 236 #define DI_DOINFO(d) sem.doif_base[d].u.u2.doinfo 237 #define DI_SECT_LAB(d) sem.doif_base[d].omp.v.v1.sect_lab 238 #define DI_SECT_CNT(d) sem.doif_base[d].omp.v.v1.sect_cnt 239 #define DI_SECT_VAR(d) sem.doif_base[d].omp.v.v1.sect_var 240 #define DI_NOSCOPE_BASE(d) sem.doif_base[d].omp.no_scope_base 241 #define DI_NOSCOPE_SIZE(d) sem.doif_base[d].omp.no_scope_size 242 #define DI_NOSCOPE_AVL(d) sem.doif_base[d].omp.no_scope_avail 243 #define DI_CRITSYM(d) sem.doif_base[d].omp.v.v1.sect_lab 244 #define DI_SCHED_TYPE(d) sem.doif_base[d].omp.v.v2.sched_type 245 #define DI_CHUNK(d) sem.doif_base[d].omp.v.v2.chunk 246 #define DI_IS_ORDERED(d) sem.doif_base[d].omp.v.v2.is_ordered 247 #define DI_REDUC(d) sem.doif_base[d].omp.reduc 248 #define DI_LASTPRIVATE(d) sem.doif_base[d].omp.lastprivate 249 #define DI_ALLOCATED(d) sem.doif_base[d].omp.allocated 250 #define DI_DFLT_ALLOCATED(d) sem.doif_base[d].omp.dfltal 251 #define DI_DFLT_FIRSTPRIVATE(d) sem.doif_base[d].omp.dfltfp 252 #define DI_B(t) (1 << t) 253 #define DI_IN_NEST(d, t) (DI_NEST(d) & DI_B(t)) 254 255 #define NEED_LOOP(df, typ) \ 256 { \ 257 df = ++sem.doif_depth; \ 258 NEED(df + 1, sem.doif_base, DOIF, sem.doif_size, sem.doif_size + 8); \ 259 DI_EXIT_LAB(df) = DI_CYCLE_LABEL(df) = 0; \ 260 DI_NAME(df) = 0; \ 261 DI_LINENO(df) = gbl.lineno; \ 262 DI_ID(df) = typ; \ 263 DI_NOSCOPE_AVL(df) = 0; \ 264 DI_NOSCOPE_SIZE(df) = 0; \ 265 DI_NOSCOPE_BASE(df) = NULL; \ 266 DI_NEST(df) = DI_NEST(df - 1) | DI_B(typ); \ 267 } 268 269 /* Define Initializer Variable List */ 270 typedef struct VAR { /* used for elements of dinit variable list */ 271 short id; 272 #define Dostart 0 273 #define Doend 1 274 #define Varref 2 275 union { 276 struct { 277 int indvar; 278 int lowbd, upbd; 279 int step; 280 } dostart; 281 struct { 282 struct VAR *dostart; 283 } doend; 284 struct { 285 /* Semantic stack info for variable reference */ 286 int id; 287 int ptr; /* May be symbol ptr or ilm ptr */ 288 DTYPE dtype; 289 int shape; 290 } varref; 291 } u; 292 struct VAR *next; 293 } VAR; 294 295 /* Define Initializer Constant Tree */ 296 typedef struct CONST CONST; 297 298 typedef struct { 299 SPTR index_var; /* sptr of index variable */ 300 CONST *initval; 301 CONST *limitval; 302 CONST *stepval; 303 } IDOINFO; 304 305 typedef struct AEXPR { 306 int op; 307 CONST *lop; 308 CONST *rop; 309 } AEXPR; 310 311 struct CONST { 312 char id; 313 CONST *next; 314 CONST *subc; 315 ISZ_T repeatc; 316 SPTR sptr; 317 SPTR mbr; /* will be the sptr of the member when the initializer is an IDENT 318 * (presumbably, a PARAMETER) */ 319 DTYPE dtype; 320 int no_dinitp; 321 union { 322 INT conval; 323 AEXPR expr; 324 IDOINFO ido; 325 } u1; 326 }; 327 328 /***** KEEP AC values consistent with the front-end *****/ 329 #define AC_IDENT 1 330 #define AC_CONST 2 331 #define AC_EXPR 3 /* SST expr */ 332 #define AC_IEXPR 4 /* AC expression */ 333 #define AC_AST 5 334 #define AC_IDO 6 335 #define AC_REPEAT 7 336 #define AC_ACONST 8 337 #define AC_SCONST 9 338 #define AC_LIST 10 /* only used during DATA stmt processing */ 339 #define AC_VMSSTRUCT 11 340 #define AC_VMSUNION 12 341 #define AC_TYPEINIT 13 342 #define AC_ICONST \ 343 14 /* integer constant value, currently used to keep \ 344 * intrinsic routine selector \ 345 */ 346 #define AC_CONVAL \ 347 15 /* Type of ACL leaf item generated by calling \ 348 * eval_init_expr/eval_init_expr_item. The conval \ 349 * field contains the results of the evaluation. \ 350 * The type of the value is a literal constant if \ 351 * the type a TY_WORD. Otherwise, the value is the \ 352 * sptr of a constant. \ 353 */ 354 #define AC_ADD 1 355 #define AC_SUB 2 356 #define AC_MUL 3 357 #define AC_DIV 4 358 #define AC_EXP 5 359 #define AC_NEG 6 360 #define AC_INTR_CALL 7 361 #define AC_ARRAYREF 8 362 #define AC_MEMBR_SEL 9 363 #define AC_CONV 10 364 #define AC_CAT 11 365 #define AC_EXPK 12 366 #define AC_LEQV 13 367 #define AC_LNEQV 14 368 #define AC_LOR 15 369 #define AC_LAND 16 370 #define AC_EQ 17 371 #define AC_GE 18 372 #define AC_GT 19 373 #define AC_LE 20 374 #define AC_LT 21 375 #define AC_NE 22 376 #define AC_LNOT 23 377 #define AC_EXPX 24 378 #define AC_TRIPLE 25 379 380 #define AC_I_adjustl 1 381 #define AC_I_adjustr 2 382 #define AC_I_char 3 383 #define AC_I_ichar 4 384 #define AC_I_index 5 385 #define AC_I_int 6 386 #define AC_I_ishft 7 387 #define AC_I_ishftc 8 388 #define AC_I_kind 9 389 #define AC_I_lbound 10 390 #define AC_I_len 11 391 #define AC_I_len_trim 12 392 #define AC_I_nint 13 393 #define AC_I_null 14 394 #define AC_I_repeat 15 395 #define AC_I_reshape 16 396 #define AC_I_scan 17 397 #define AC_I_selected_int_kind 18 398 #define AC_I_selected_real_kind 19 399 #define AC_I_size 20 400 #define AC_I_transfer 21 401 #define AC_I_trim 22 402 #define AC_I_ubound 23 403 #define AC_I_verify 24 404 #define AC_I_shape 25 405 #define AC_I_min 26 406 #define AC_I_max 27 407 #define AC_I_fltconvert 28 408 #define AC_I_floor 29 409 #define AC_I_ceiling 30 410 #define AC_I_mod 31 411 #define AC_I_sqrt 32 412 #define AC_I_exp 33 413 #define AC_I_log 34 414 #define AC_I_log10 35 415 #define AC_I_sin 36 416 #define AC_I_cos 37 417 #define AC_I_tan 38 418 #define AC_I_asin 39 419 #define AC_I_acos 40 420 #define AC_I_atan 41 421 #define AC_I_atan2 42 422 #define AC_I_selected_char_kind 43 423 #define AC_I_abs 44 424 #define AC_I_iand 45 425 #define AC_I_ior 46 426 #define AC_I_ieor 47 427 #define AC_I_merge 48 428 #define AC_I_lshift 49 429 #define AC_I_rshift 50 430 #define AC_I_maxloc 51 431 #define AC_I_maxval 52 432 #define AC_I_minloc 53 433 #define AC_I_minval 54 434 #define AC_I_scale 55 435 #define AC_UNARY_OP(e) (e.op == AC_NEG || e.op == AC_CONV) 436 437 typedef struct { /* STRUCTURE stack entries */ 438 char type; /* 's': STRUCTURE; 'u': UNION; 'm: MAP */ 439 int sptr; /* Sym ptr to field name list having this structure */ 440 int dtype; /* Pointer to structure dtype */ 441 int last; /* last member; updated by link_members */ 442 CONST *ict_beg; /* Initializer Constant Tree begin */ 443 CONST *ict_end; /* Initializer Constant Tree end */ 444 } STSK; 445 /* access entries in STRUCTURE stack; 0 ==> top of stack, 1 ==> 1 back, etc. */ 446 #define STSK_ENT(i) sem.stsk_base[sem.stsk_depth - (i)-1] 447 448 typedef struct equiv_var { /* variable references in EQUIVALENCE statements */ 449 int sptr; 450 int lineno; 451 ITEM *subscripts; 452 ISZ_T byte_offset; 453 struct equiv_var *next; 454 /* the next field can be made smaller if more fields must be added */ 455 INT is_first; /* first in a group */ 456 } EQVV; 457 #define EQVV_END ((EQVV *)1) 458 459 /* define structures needed for statement function processing: */ 460 461 typedef struct _sfuse { 462 char usetyp; /* type of use: 463 * 0 - value 464 * 1 - address (loc intrinsic) 465 * 2 - argument to a function 466 */ 467 struct _sfuse *next; 468 int ilm; 469 } SFUSE; 470 471 typedef struct arginfo { 472 int ilm[3]; /* flags/ilms corresponding to usetyp in SFUSE: 473 * when searching for uses of the formal, marks whether or 474 * not its value ([0]) is needed, it appears in the loc 475 * intrinsic ([1]), or if it appears as an argument to 476 * a function ([2]). 477 * during evaluation, this array will locate the ilms 478 * suitable for use as a value, loc operand, or as an 479 * argument, respectively. 480 */ 481 int dtype; /* data type of dummy argument */ 482 SFUSE *uses; /* ptr to list of ITEM records locating the 483 * the uses of this dummy arg within the ILMS 484 */ 485 struct arginfo *next; /* next argument info record */ 486 } ARGINFO; 487 488 typedef struct { /* statement function descriptor */ 489 ILM_T *ilmp; /* ptr to ILM's */ 490 ARGINFO *args; /* ptr to list of arginfo records */ 491 SFUSE *links; /* ptr to list of links to be relocated */ 492 int rootilm; /* root of expression tree, 0 if none */ 493 ARGINFO *ident; /* for s.f. of form f(a) = a, points to arginfo 494 * record for a */ 495 SFUSE *new_temps; /* ptr to list of ILMs using temps which were created 496 * when the statement function was defined and need to 497 * be replaced when the statement function is 498 * referenced. 499 */ 500 } SFDSC; 501 502 /* 503 * define a stack for scope entries -- currently only used when entering 504 * parallel regions: 505 * a 'zero' level scope is for the outer/subprogram level. 506 * n > 0 - parallel nesting level. 507 * The scope stack is indexed by sem.scope. 508 */ 509 typedef struct scope_sym_tag { 510 int sptr; /* symbol appearing in the SHARED clause */ 511 int scope; /* its outer scope value */ 512 struct scope_sym_tag *next; 513 } SCOPE_SYM; 514 515 #define PAR_SCOPE_NONE 0 516 #define PAR_SCOPE_SHARED 1 517 #define PAR_SCOPE_PRIVATE 2 518 #define PAR_SCOPE_FIRSTPRIVATE 3 519 #define PAR_SCOPE_TASKNODEFAULT 4 520 521 typedef struct { 522 int rgn_scope; /* index of the scope entry of the containing 523 * parallel region. 524 */ 525 int par_scope; /* one of PAR_SCOPE_... */ 526 int di_par; /* index of the DOIF structure corresponding to 527 * this scope. 528 */ 529 int sym; /* the ST_BLOCK defining this scope */ 530 int autobj; /* list of automatic data objects for this 531 * scope 532 */ 533 int prev_sc; /* previous storage class */ 534 SCOPE_SYM *shared_list; /* List of symbols appearing in the SHARED 535 * clause for this scope when par_scope is 536 * 'shared'. 537 */ 538 } SCOPESTACK; 539 540 #define BLK_SYM(i) sem.scope_stack[i].sym 541 #define BLK_AUTOBJ(i) sem.scope_stack[i].autobj 542 543 /* declare global semant variables: */ 544 545 typedef struct { 546 bool wrilms; /* set to FALSE if don't need to write ILM's */ 547 int doif_size; /* size in records of DOIF stack area. */ 548 DOIF *doif_base; /* base pointer for DOIF stack area. */ 549 int doif_depth; /* current DO-IF nesting level */ 550 EQVV *eqvlist; /* pointer to head of equivalence list */ 551 int flabels; /* pointer to list of ftn ref'd labels */ 552 SPTR nml; /* pointer to list of namelist symbols */ 553 int funcval; /* pointer to variable for function ret val */ 554 int pgphase; /* statement type seen so far: 555 * 556 * 0 - nothing seen yet (initial value) 557 * 1 - SUBROUTINE, FUNCTION, BLOCKDATA, 558 * PROGRAM 559 * 2 - Specification statements 560 * 3 - DATA statements or statement function 561 * definitions 562 * 4 - Executable statements 563 * 5 - END statement 564 * 565 * NOTES: 566 * PARAMETER, NAMELIST, and IMPLICIT do not 567 * explicitly set pgphase unless pgphase is 568 * 0 in which case it's set to 1. These are 569 * allowed between pgphases 0/1 and 2. 570 */ 571 int gdtype; /* global data type */ 572 int ogdtype; /* original global data type (i.e. before *n 573 modification */ 574 int gcvlen; /* global character type size */ 575 int atemps; /* avail counter for array bounds temporaries */ 576 int itemps; /* avail counter for temporaries named 'ixxx' */ 577 int ptemps; /* avail counter for inliner ptr temporaries */ 578 bool savall; /* SAVE statement w.o. symbols specified */ 579 bool savloc; /* at least one local variable SAVE'd */ 580 bool none_implicit; /* insure that variables are declared - set 581 TRUE if IMPLICIT NONE seen */ 582 STSK *stsk_base; /* base pointer for structure stack area */ 583 int stsk_size; /* size in records of structure stack area */ 584 int stsk_depth; /* current structure depth (i.e. stack top) */ 585 int stag_dtype; /* structure tag dtype pointer */ 586 int psfunc; /* next <var ref> may be lhs of statement func */ 587 int dinit_error; /* error flag during DATA stmt processing */ 588 int dinit_count; /* # elements left in current dcl id to init */ 589 bool dinit_data; /* TRUE if in DATA stmt, FALSE if type dcl or 590 structure init stmt */ 591 struct { /* info for variable format expression */ 592 int temps; /* counter for temporary labels */ 593 int labels; /* pointer to list of vfe labels */ 594 } vf_expr; 595 bool ignore_stmt; /* TRUE => parser is to ignore current stmt */ 596 int switch_size; /* size of switch/CGOTO list area */ 597 int switch_avl; /* next available word in switch list area */ 598 int bu_switch_avl; /* switch_avl for bottom-up Minline */ 599 bool temps_reset; /* TRUE if semant general temps can be resused */ 600 bool in_stfunc; /* in statement function def */ 601 int p_adjarr; /* pointer to list of based adjustable array-objects */ 602 int in_dim; /* in <dimension list> */ 603 /* 604 * the following two members (bounds, and arrdim) are filled in 605 * when semantically processing <dim list> specifiers 606 */ 607 struct { 608 int lowtype; 609 int uptype; 610 ISZ_T lowb; 611 ISZ_T upb; 612 } bounds[7]; 613 struct { /* mark assumed size and adjustable arrays */ 614 int ndim; /* number of dimensions */ 615 int assumsz; /* 0, not assumed size 616 * 1, assumed size 617 * >1, last dimension not assumed size 618 */ 619 int adjarr; /* 0, not adjustable array 620 * >1, adjustable array 621 */ 622 int ndefer; /* number of deferred dimensions (:) */ 623 ILM_T *ilmp; /* ilm pointer to ilms if adjustable array */ 624 } arrdim; 625 int tkntyp; /* token effecting semant reduction */ 626 struct { /* atomic */ 627 int lineno; /* line number of atomic */ 628 bool seen; /* atomic directive just seen */ 629 bool pending; /* atomic directive not yet applied */ 630 int action_type; /* (read|write|update|capture) */ 631 } atomic; 632 int parallel; /* parallel nesting level - PARALLEL, DOACROSS, 633 * PARALLELDO, PARALLELSECTIONS: 634 * 0 - not parallel 635 * >0 - parallel nesting level (1 => outermost) 636 */ 637 bool expect_do; /* next statement after DOACROSS, PDO, or 638 * PARALLELDO needs to be a DO. 639 */ 640 bool close_pdo; /* A DO loop for a PDO, PARALLELDO, or DOACROSS 641 * has been processed and its removal from the 642 * DOIF stack is delayed until the next 643 * statement is processed. For PDO and 644 * PARALLELDO, the next statement may be the 645 * optional 'end' statement for the directive. 646 * For PDO, the decision to emit a barrier 647 * is also delayed since its ENDDO may specify 648 * NOWAIT. For DOACROSS and PARALLELDO, the 649 * the parallel region is closed when the 650 * DO loop is closed. 651 */ 652 int sc; /* SC_LOCAL or SC_PRIVATE for temporaries */ 653 int ctemps; /* avail counter for function value temps */ 654 int scope; /* counter to keep track of the current scope 655 * for constructs which define a new scope 656 * (primarily, the parallel constructs): 657 * 0 - outermost (subprogram) 658 * >0 - scope nesting level 659 */ 660 SCOPESTACK *scope_stack; /* pushed/popped as scopes are entered/left */ 661 int scope_size; /* size of scope stack */ 662 int threadprivate_dtype; /* dtype record used for the vector of pointers 663 * created for threadprivate common blocks. 664 */ 665 int it_dtype; /* dtype record used for the mp run-time 666 * iteration data structure. 667 */ 668 int its_dtype; /* dtype record used for the mp run-time 669 * iteration data structure. 670 */ 671 int blksymnum; 672 bool ignore_default_none; /* don't perform the OMP DEFAULT(NONE) check */ 673 int collapse; /* collapse value for the pardo or pdo */ 674 int collapse_depth; /* depth of collapse loop; 1 => innermost */ 675 int task; /* depth of task 676 * 0 - not in task 677 * >0 - task nesting level (1 => outermost) 678 */ 679 /* 680 * the following members are initialized to values which reflect the 681 * default type for the extents and subscripts of arrays. The type could 682 * either be 32-int or 64-bit (BIGOBJects & -Mlarge_arrays). 683 * 684 */ 685 struct { 686 int dtype; /* dtype used for the bound temps */ 687 int store; /* ILM opc for storing a bound value */ 688 int load; /* ILM opc for loading a bound value */ 689 int mul; /* ILM opc for multiplying */ 690 int sub; /* ILM opc for substract */ 691 int add; /* ILM opc for add */ 692 int con; /* ILM opc for integer constants */ 693 int zero; /* zero entry for zero */ 694 int one; /* sym etnry for one */ 695 } bnd; 696 } SEM; 697 698 extern SEM sem; 699 700 /* 701 * NTYPE - number of basic types; this must include the NCHARACTER 702 * type even though it may not be an available feature. 703 */ 704 #define NTYPE 21 705 706 #define NOPC 14 707 708 extern short promote_ilms[NTYPE]; 709 extern short ilm_opcode[NOPC][2][NTYPE + 1]; 710 extern INT cast_types[NTYPE][2][2]; 711 712 #define ILMA(n) (ilmb.ilm_base[n]) 713 714 #define IS_COMPARE(opc) (opc >= IM_EQ && opc <= IM_GT) 715 #define IS_LOGICAL(opc) \ 716 (IS_COMPARE(opc) || (opc >= IM_LAND && opc <= IM_LOR) || \ 717 (opc >= IM_AND64 && opc <= IM_AND) || (opc >= IM_OR64 && opc <= IM_OR) || \ 718 (opc >= IM_NOT64 && opc <= IM_LNOP) || opc == IM_LAND8 || opc == IM_LOR8 || \ 719 opc == IM_KAND || opc == IM_KOR || opc == IM_KNOT || opc == IM_LNOT8 || \ 720 opc == IM_LNOP8) 721 #define IS_INTRINSIC(st) (st == ST_INTRIN || st == ST_GENERIC || st == ST_PD) 722 723 #define INSIDE_STRUCT (sem.stsk_depth != 0) 724 725 #define GET_OPCODE(opc, dt) \ 726 (ilm_opcode[opc][(DTY(dt) == TY_ARRAY ? TRUE : FALSE)][DTYG(dt)]) 727 728 #define DCLCHK(sptr) \ 729 if (sem.none_implicit && !DCLDG(sptr) && !E38G(sptr)) { \ 730 error(38, !XBIT(124, 0x20000) ? 3 : 2, gbl.lineno, SYMNAME(sptr), CNULL); \ 731 E38P(sptr, 1); \ 732 } 733 734 #define DOCHK(sptr) \ 735 if (DOVARG(sptr)) \ 736 error(115, 2, gbl.lineno, SYMNAME(sptr), CNULL); 737 738 /* if sp == 0, bound is '*' */ 739 #define ILMBOUND(sp) \ 740 (((sp) == 0) \ 741 ? 0 \ 742 : (STYPEG(sp) == ST_CONST ? ad2ilm(IM_ICON, sp) \ 743 : ad2ilm(IM_ILD, ad2ilm(IM_BASE, sp)))) 744 745 #define DPVAL(a) ad2ilm(IM_DPVAL, a) 746 #define DPREF(a) ad2ilm(IM_DPREF, a) 747 #define DPSCON(a) ad2ilm(IM_DPSCON, a) 748 #define DPNULL ad1ilm(IM_DPNULL) 749 750 void dmp_const(CONST *acl, int indent); 751 752 /* declare external functions called only from within semant: */ 753 754 void emit_epar(void); /* semsmp.c: */ 755 void emit_bcs_ecs(int); 756 void end_parallel_clause(int); 757 void add_dflt_allocated(int); 758 void add_dflt_firstprivate(int, int); 759 INT chkcon(); 760 INT const_fold(); /* semutil.c: */ 761 ISZ_T chkcon_to_isz(struct sst *, bool); 762 INT chktyp(); 763 INT chk_scalartyp(); 764 INT chk_arr_extent(); 765 int mkexpr(); 766 int chkvar(); 767 int add_base(); 768 int chksubstr(); 769 int get_temp(int); 770 int get_itemp(int); 771 int mkvarref(); 772 int mklvalue(), mkmember(); 773 int mklabelvar64(int); 774 bool is_varref(); 775 void binop(); 776 void mklogint4(); 777 void link_members(); 778 void chkstruct(); 779 void assign(); 780 void do_begin(DOINFO *, int, int, int); 781 void do_parbegin(DOINFO *, int, int, int); 782 void do_lastval(DOINFO *, int, int, int); 783 void do_end(DOINFO *); 784 void cngtyp(); 785 void mklogint4(); 786 void negate_const(); 787 char *prtsst(); 788 DOINFO *get_doinfo(int); 789 790 void chk_adjarr(); 791 void gen_arrdsc(); /* semutil2.c: */ 792 int mk_arrdsc(); 793 void gen_allocate(int, int, int); 794 void gen_deallocate(int, int); 795 void sem_set_storage_class(int); 796 int enter_lexical_block(int); 797 void exit_lexical_block(int); 798 void dmp_doif(int); 799 800 int ad1ilm(int); 801 int ad2ilm(int, int); 802 int ad3ilm(int, int, int); /* ilmutil.c: */ 803 int ad4ilm(int, int, int, int); 804 int ad5ilm(int, int, int, int, int); 805 void dumpilmtrees(void); 806 int lnegate(); 807 void wrilms(int); 808 void add_ilms(ILM_T *); 809 void mkbranch(int, int, int); 810 void gwrilms(int nilms); 811 void fini_next_gilm(void); 812 void init_next_gilm(void); 813 void swap_next_gilm(void); 814 int rdilms(void); 815 void rewindilms(void); 816 #if DEBUG 817 /* FIXME those two functions do the same thing, also see _dumpilms */ 818 void dmpilms(void); 819 void dumpilms(void); 820 #endif 821 ILM_T *save_ilms(int); 822 void dinit(VAR *ivl, CONST *ict); /* dinit.c */ 823 bool dinit_ok(int); 824 void dmp_ivl(VAR *, FILE *); 825 void dmp_ict(CONST *, FILE *); 826 void semfin(); /* semfin.c */ 827 int mklogopnd(); 828 int ref_based_object(int); 829 int decl_private_sym(int); 830 void par_push_scope(bool); 831 void par_pop_scope(void); 832 int sem_check_scope(int, int); 833 834 /* semfunc.c */ 835 int func_call(); 836 int ref_intrin(); 837 int ref_pd(); 838 int mkarg(); 839 int ref_stfunc(); 840 int ref_entry(); 841 int chkarg(); 842 int select_gsame(int); 843 int mkipval(INT); 844 void subr_call(); 845 void define_stfunc(); 846 847 /* semutil0.c */ 848 void semant_init(void); 849 void semant_reinit(void); 850 851 #endif // SEMANT_H_ 852