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 static char USMID[] = "\n@(#)5.0_pl/sources/s_end.c 5.2 06/16/99 10:02:23\n";
00038
00039
00040 # include "defines.h"
00041
00042 # include "host.m"
00043 # include "host.h"
00044 # include "target.m"
00045 # include "target.h"
00046
00047 # include "globals.m"
00048 # include "tokens.m"
00049 # include "sytb.m"
00050 # include "s_globals.m"
00051 # include "debug.m"
00052
00053 # include "globals.h"
00054 # include "tokens.h"
00055 # include "sytb.h"
00056 # include "s_globals.h"
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 void end_stmt_semantics (void)
00082
00083 {
00084 int new_end_idx;
00085 int new_start_idx;
00086 int ptr;
00087
00088
00089 TRACE (Func_Entry, "end_stmt_semantics", NULL);
00090
00091 ptr = SCP_EXIT_IR_SH_IDX(curr_scp_idx);
00092
00093 if (ptr) {
00094 while (SH_NEXT_IDX(ptr) != NULL_IDX) {
00095 ptr = SH_NEXT_IDX(ptr);
00096 }
00097
00098 copy_entry_exit_sh_list(SCP_EXIT_IR_SH_IDX(curr_scp_idx), ptr,
00099 &new_start_idx, &new_end_idx);
00100
00101 insert_sh_chain_before(new_start_idx);
00102 }
00103
00104 if (opt_flags.inline_lvl > Inline_Lvl_0 ||
00105 opt_flags.modinline || dump_flags.preinline) {
00106 gen_directive_ir(Inline_Cdir_Opr);
00107 }
00108
00109 if (cdir_switches.bounds) {
00110 gen_directive_ir(Nobounds_Cdir_Opr);
00111 }
00112
00113 TRACE (Func_Exit, "end_stmt_semantics", NULL);
00114
00115 return;
00116
00117 }
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136 void end_subroutine_semantics (void)
00137
00138 {
00139 int new_end_idx;
00140 int new_start_idx;
00141 int ptr;
00142
00143
00144 TRACE (Func_Entry, "end_subroutine_semantics", NULL);
00145
00146 ptr = SCP_EXIT_IR_SH_IDX(curr_scp_idx);
00147
00148 if (ptr) {
00149 while (SH_NEXT_IDX(ptr) != NULL_IDX) {
00150 ptr = SH_NEXT_IDX(ptr);
00151 }
00152
00153 copy_entry_exit_sh_list(SCP_EXIT_IR_SH_IDX(curr_scp_idx), ptr,
00154 &new_start_idx, &new_end_idx);
00155
00156 insert_sh_chain_before(new_start_idx);
00157 }
00158
00159 if (opt_flags.inline_lvl > Inline_Lvl_0 ||
00160 opt_flags.modinline || dump_flags.preinline) {
00161 gen_directive_ir(Inline_Cdir_Opr);
00162 }
00163
00164 if (cdir_switches.bounds) {
00165 gen_directive_ir(Nobounds_Cdir_Opr);
00166 }
00167
00168 TRACE (Func_Exit, "end_subroutine_semantics", NULL);
00169
00170 return;
00171
00172 }
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 void end_function_semantics (void)
00193
00194 {
00195 int idx;
00196 int ir_idx;
00197 int new_end_idx;
00198 size_offset_type new_size;
00199 int new_start_idx;
00200 int ptr;
00201 int rslt_idx;
00202 size_offset_type result;
00203 size_offset_type size;
00204
00205
00206 TRACE (Func_Entry, "end_function_semantics", NULL);
00207
00208 rslt_idx = ATP_RSLT_IDX(SCP_ATTR_IDX(curr_scp_idx));
00209
00210 if (!ATD_IM_A_DOPE(rslt_idx) &&
00211 ATD_ARRAY_IDX(rslt_idx) == NULL_IDX &&
00212 TYP_TYPE(ATD_TYPE_IDX(rslt_idx)) != Structure &&
00213 TYP_TYPE(ATD_TYPE_IDX(rslt_idx)) != Character) {
00214
00215 ir_idx = SH_IR_IDX(curr_stmt_sh_idx);
00216
00217 # ifdef _SEPARATE_FUNCTION_RETURNS
00218
00219 if (SCP_ALT_ENTRY_CNT(curr_scp_idx) != 0 &&
00220 SCP_RETURN_LABEL(curr_scp_idx) != NULL_IDX) {
00221
00222
00223
00224 IR_OPR(ir_idx) = Br_Uncond_Opr;
00225 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
00226 IR_IDX_R(ir_idx) = SCP_RETURN_LABEL(curr_scp_idx);
00227 IR_LINE_NUM_R(ir_idx) = IR_LINE_NUM(ir_idx);
00228 IR_COL_NUM_R(ir_idx) = IR_COL_NUM(ir_idx);
00229 }
00230 else {
00231 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
00232 IR_IDX_R(ir_idx) = rslt_idx;
00233 IR_LINE_NUM_R(ir_idx) = IR_LINE_NUM(ir_idx);
00234 IR_COL_NUM_R(ir_idx) = IR_COL_NUM(ir_idx);
00235 }
00236 # else
00237
00238 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
00239 IR_LINE_NUM_R(ir_idx) = IR_LINE_NUM(ir_idx);
00240 IR_COL_NUM_R(ir_idx) = IR_COL_NUM(ir_idx);
00241
00242 if (SCP_ENTRY_IDX(curr_scp_idx)) {
00243 idx = SCP_ENTRY_IDX(curr_scp_idx);
00244 size = stor_bit_size_of(rslt_idx, TRUE, FALSE);
00245
00246
00247
00248 while (idx != NULL_IDX) {
00249 new_size = stor_bit_size_of(ATP_RSLT_IDX(AL_ATTR_IDX(idx)),
00250 TRUE,
00251 FALSE);
00252 size_offset_logical_calc(&new_size, &size, Gt_Opr, &result);
00253
00254 if (THIS_IS_TRUE(result.constant, result.type_idx)) {
00255 size = new_size;
00256 rslt_idx = ATP_RSLT_IDX(AL_ATTR_IDX(idx));
00257 }
00258 idx = AL_NEXT_IDX(idx);
00259 }
00260 }
00261
00262 IR_IDX_R(ir_idx) = rslt_idx;
00263 # endif
00264 }
00265 else {
00266
00267
00268
00269
00270 ir_idx = SH_IR_IDX(curr_stmt_sh_idx);
00271 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
00272 IR_LINE_NUM_R(ir_idx) = IR_LINE_NUM(ir_idx);
00273 IR_COL_NUM_R(ir_idx) = IR_COL_NUM(ir_idx);
00274 IR_IDX_R(ir_idx) = rslt_idx;
00275 }
00276
00277 ptr = SCP_EXIT_IR_SH_IDX(curr_scp_idx);
00278
00279 if (ptr) {
00280 while (SH_NEXT_IDX(ptr) != NULL_IDX) {
00281 ptr = SH_NEXT_IDX(ptr);
00282 }
00283
00284 copy_entry_exit_sh_list(SCP_EXIT_IR_SH_IDX(curr_scp_idx), ptr,
00285 &new_start_idx, &new_end_idx);
00286
00287 insert_sh_chain_before(new_start_idx);
00288 }
00289
00290 if (opt_flags.inline_lvl > Inline_Lvl_0 ||
00291 opt_flags.modinline || dump_flags.preinline) {
00292 ir_idx = gen_directive_ir(Inline_Cdir_Opr);
00293 }
00294
00295 if (cdir_switches.bounds) {
00296 ir_idx = gen_directive_ir(Nobounds_Cdir_Opr);
00297 }
00298
00299 TRACE (Func_Exit, "end_function_semantics", NULL);
00300
00301 return;
00302
00303 }
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321 void end_forall_semantics (void)
00322
00323 {
00324 int ir_idx;
00325 int list_idx;
00326 int sh_idx;
00327
00328
00329 TRACE (Func_Entry, "end_forall_semantics", NULL);
00330
00331 sh_idx = SH_PARENT_BLK_IDX(curr_stmt_sh_idx);
00332
00333 if (SH_ERR_FLG(curr_stmt_sh_idx) || SH_ERR_FLG(sh_idx)) {
00334 goto EXIT;
00335 }
00336
00337 # ifdef _DEBUG
00338 if (sh_idx == NULL_IDX) {
00339 PRINTMSG(SH_GLB_LINE(curr_stmt_sh_idx), 626, Internal,
00340 SH_COL_NUM(curr_stmt_sh_idx),
00341 "SH_PARENT_BLK_IDX", "end_forall_semantics");
00342 }
00343 # endif
00344
00345 ir_idx = SH_IR_IDX(sh_idx);
00346
00347 # ifdef _DEBUG
00348 if (IR_OPR(ir_idx) != Forall_Opr) {
00349 PRINTMSG(SH_GLB_LINE(curr_stmt_sh_idx), 626, Internal,
00350 SH_COL_NUM(curr_stmt_sh_idx),
00351 "Forall_Opr", "end_forall_semantics");
00352 }
00353 # endif
00354
00355 list_idx = IR_IDX_R(ir_idx);
00356
00357 while (list_idx &&
00358 IL_FLD(list_idx) == IL_Tbl_Idx) {
00359
00360 AT_ATTR_LINK(IL_IDX(IL_IDX(list_idx))) = NULL_IDX;
00361 AT_IGNORE_ATTR_LINK(IL_IDX(IL_IDX(list_idx))) = FALSE;
00362
00363 list_idx = IL_NEXT_LIST_IDX(list_idx);
00364 }
00365
00366 EXIT:
00367
00368 active_forall_sh_idx = SH_PARENT_BLK_IDX(active_forall_sh_idx);
00369
00370 if (active_forall_sh_idx == NULL_IDX) {
00371 within_forall_construct = FALSE;
00372 }
00373
00374 TRACE (Func_Exit, "end_forall_semantics", NULL);
00375
00376 return;
00377
00378 }
00379
00380 #ifndef _HIGH_LEVEL_IF_FORM
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399 void end_if_semantics (void)
00400
00401 {
00402 int if_ir_idx;
00403 int if_sh_idx;
00404 int il_idx;
00405 int ir_idx;
00406 int lbl_idx;
00407 int sh_idx;
00408 opnd_type tmp_opnd;
00409
00410
00411 TRACE (Func_Entry, "end_if_semantics", NULL);
00412
00413
00414
00415
00416
00417 if_sh_idx = SH_PARENT_BLK_IDX(curr_stmt_sh_idx);
00418
00419 while (SH_STMT_TYPE(if_sh_idx) != If_Cstrct_Stmt) {
00420
00421 if (SH_STMT_TYPE(if_sh_idx) == Else_Stmt) {
00422 if_sh_idx = IR_IDX_L(SH_IR_IDX(if_sh_idx));
00423 }
00424 else {
00425 if_sh_idx = IL_IDX(IL_NEXT_LIST_IDX(IR_IDX_R(SH_IR_IDX(if_sh_idx))));
00426 }
00427 }
00428
00429 if (SH_ERR_FLG(if_sh_idx)) {
00430 goto EXIT;
00431 }
00432
00433 lbl_idx = IL_IDX(IL_NEXT_LIST_IDX(IR_IDX_R(SH_IR_IDX(if_sh_idx))));
00434 AT_DEFINED(lbl_idx) = TRUE;
00435 AT_DEF_LINE(lbl_idx) = stmt_start_line;
00436 ATL_DEF_STMT_IDX(lbl_idx) = curr_stmt_sh_idx;
00437 AT_REFERENCED(lbl_idx) = Referenced;
00438
00439
00440
00441
00442
00443 if (SH_STMT_TYPE(SH_PARENT_BLK_IDX(curr_stmt_sh_idx)) == Else_If_Stmt) {
00444 gen_sh(Before, Continue_Stmt, stmt_start_line, stmt_start_col,
00445 FALSE,
00446 TRUE,
00447 TRUE);
00448
00449 sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
00450 NTR_IR_TBL(ir_idx);
00451 SH_IR_IDX(sh_idx) = ir_idx;
00452 IR_OPR(ir_idx) = Label_Opr;
00453 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
00454 IR_LINE_NUM(ir_idx) = stmt_start_line;
00455 IR_COL_NUM(ir_idx) = stmt_start_col;
00456 IR_LINE_NUM_L(ir_idx) = stmt_start_line;
00457 IR_COL_NUM_L(ir_idx) = stmt_start_col;
00458 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
00459 lbl_idx =
00460 IL_IDX(IR_IDX_R(SH_IR_IDX(SH_PARENT_BLK_IDX(curr_stmt_sh_idx))));
00461 IR_IDX_L(ir_idx) = lbl_idx;
00462
00463 AT_DEFINED(lbl_idx) = TRUE;
00464 AT_DEF_LINE(lbl_idx) = stmt_start_line;
00465 ATL_DEF_STMT_IDX(lbl_idx) = sh_idx;
00466 AT_REFERENCED(lbl_idx) = Referenced;
00467 }
00468
00469
00470
00471
00472
00473
00474
00475 gen_sh(Before, Continue_Stmt, stmt_start_line, stmt_start_col,
00476 FALSE,
00477 TRUE,
00478 TRUE);
00479
00480 sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
00481 NTR_IR_TBL(ir_idx);
00482 SH_IR_IDX(sh_idx) = ir_idx;
00483 IR_OPR(ir_idx) = Label_Opr;
00484 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
00485 IR_LINE_NUM(ir_idx) = stmt_start_line;
00486 IR_COL_NUM(ir_idx) = stmt_start_col;
00487 IR_LINE_NUM_L(ir_idx) = stmt_start_line;
00488 IR_COL_NUM_L(ir_idx) = stmt_start_col;
00489 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
00490
00491 if_ir_idx = SH_IR_IDX(if_sh_idx);
00492
00493 if (SH_STMT_TYPE(SH_PARENT_BLK_IDX(curr_stmt_sh_idx)) == If_Cstrct_Stmt) {
00494 lbl_idx = IL_IDX(IR_IDX_R(if_ir_idx));
00495 }
00496 else {
00497 lbl_idx = IL_IDX(IL_NEXT_LIST_IDX(IR_IDX_R(if_ir_idx)));
00498 }
00499
00500 IR_IDX_L(ir_idx) = lbl_idx;
00501
00502 AT_DEFINED(lbl_idx) = TRUE;
00503 AT_DEF_LINE(lbl_idx) = stmt_start_line;
00504 ATL_DEF_STMT_IDX(lbl_idx) = sh_idx;
00505 AT_REFERENCED(lbl_idx) = Referenced;
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515 if_sh_idx = SH_PARENT_BLK_IDX(curr_stmt_sh_idx);
00516
00517 while (SH_STMT_TYPE(if_sh_idx) != If_Cstrct_Stmt) {
00518
00519 if (SH_STMT_TYPE(if_sh_idx) == Else_Stmt) {
00520 sh_idx = if_sh_idx;
00521 if_sh_idx = IR_IDX_L(SH_IR_IDX(if_sh_idx));
00522 SH_IR_IDX(sh_idx) = NULL_IDX;
00523 }
00524 else {
00525 il_idx = IL_NEXT_LIST_IDX(IR_IDX_R(SH_IR_IDX(if_sh_idx)));
00526 COPY_OPND(tmp_opnd, IL_OPND(IR_IDX_R(SH_IR_IDX(if_sh_idx))));
00527 COPY_OPND(IR_OPND_R(SH_IR_IDX(if_sh_idx)), tmp_opnd);
00528 if_sh_idx = IL_IDX(il_idx);
00529 }
00530 }
00531
00532 COPY_OPND(tmp_opnd, IL_OPND(IR_IDX_R(if_ir_idx)));
00533 COPY_OPND(IR_OPND_R(if_ir_idx), tmp_opnd);
00534
00535 EXIT:
00536
00537 TRACE (Func_Exit, "end_if_semantics", NULL);
00538
00539 return;
00540
00541 }
00542
00543 #endif
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562 void end_select_semantics (void)
00563
00564 {
00565 int i;
00566 int il_idx;
00567 int ir_idx;
00568 int next_il_idx;
00569
00570
00571 TRACE (Func_Entry, "end_select_semantics", NULL);
00572
00573 if (! SH_ERR_FLG(SH_PARENT_BLK_IDX(curr_stmt_sh_idx))) {
00574
00575 ir_idx = SH_IR_IDX(SH_PARENT_BLK_IDX(curr_stmt_sh_idx));
00576 SH_IR_IDX(SH_PARENT_BLK_IDX(curr_stmt_sh_idx)) = IR_IDX_L(ir_idx);
00577
00578 il_idx = IR_IDX_R(ir_idx);
00579
00580 for (i = 1; i <= IR_LIST_CNT_R(ir_idx); i++) {
00581 next_il_idx = IL_NEXT_LIST_IDX(il_idx);
00582 FREE_IR_LIST_NODE(il_idx);
00583 il_idx = next_il_idx;
00584 }
00585
00586 FREE_IR_NODE(ir_idx);
00587 }
00588
00589 TRACE (Func_Exit, "end_select_semantics", NULL);
00590
00591 return;
00592
00593 }
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612 void end_where_semantics (void)
00613
00614 {
00615 int sh_idx;
00616
00617 TRACE (Func_Entry, "end_where_semantics", NULL);
00618
00619 where_ir_idx = NULL_IDX;
00620
00621 if (where_dealloc_stmt_idx) {
00622 SH_NEXT_IDX(where_dealloc_stmt_idx) = SH_NEXT_IDX(curr_stmt_sh_idx);
00623 SH_PREV_IDX(where_dealloc_stmt_idx) = curr_stmt_sh_idx;
00624 SH_PREV_IDX(SH_NEXT_IDX(curr_stmt_sh_idx)) = where_dealloc_stmt_idx;
00625 SH_NEXT_IDX(curr_stmt_sh_idx) = where_dealloc_stmt_idx;
00626
00627 where_dealloc_stmt_idx = NULL_IDX;
00628 }
00629
00630 sh_idx = SH_PARENT_BLK_IDX(curr_stmt_sh_idx);
00631
00632 while (sh_idx != NULL_IDX &&
00633 SH_STMT_TYPE(sh_idx) != Where_Cstrct_Stmt) {
00634 sh_idx = SH_PARENT_BLK_IDX(sh_idx);
00635 }
00636
00637 if (sh_idx != NULL_IDX &&
00638 (SH_PARENT_BLK_IDX(sh_idx) == NULL_IDX ||
00639 (SH_STMT_TYPE(SH_PARENT_BLK_IDX(sh_idx)) != Where_Cstrct_Stmt &&
00640 SH_STMT_TYPE(SH_PARENT_BLK_IDX(sh_idx)) != Else_Where_Stmt &&
00641 SH_STMT_TYPE(SH_PARENT_BLK_IDX(sh_idx)) != Else_Where_Mask_Stmt))) {
00642
00643 alloc_block_start_idx = NULL_IDX;
00644 alloc_block_end_idx = NULL_IDX;
00645 }
00646
00647 if (sh_idx != NULL_IDX &&
00648 SH_PARENT_BLK_IDX(sh_idx) != NULL_IDX) {
00649
00650 sh_idx = SH_PARENT_BLK_IDX(sh_idx);
00651
00652 if (SH_STMT_TYPE(sh_idx) == Where_Cstrct_Stmt ||
00653 SH_STMT_TYPE(sh_idx) == Else_Where_Stmt ||
00654 SH_STMT_TYPE(sh_idx) == Else_Where_Mask_Stmt) {
00655
00656 if (IR_FLD_L(SH_IR_IDX(sh_idx)) == IL_Tbl_Idx) {
00657 where_ir_idx = IL_IDX(IR_IDX_L(SH_IR_IDX(sh_idx)));
00658 }
00659 }
00660 else if (SH_STMT_TYPE(sh_idx) == Forall_Cstrct_Stmt) {
00661 active_forall_sh_idx = sh_idx;
00662 }
00663 # ifdef _DEBUG
00664 else {
00665 PRINTMSG(SH_GLB_LINE(sh_idx), 626, Internal, SH_COL_NUM(sh_idx),
00666 "Forall_Opr", "end_where_semantics");
00667 }
00668 # endif
00669 }
00670
00671 TRACE (Func_Exit, "end_where_semantics", NULL);
00672
00673 return;
00674
00675 }