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 static char USMID[] = "\n@(#)5.0_pl/sources/s_data.c 5.7 09/02/99 17:06:53\n";
00049
00050 # include "defines.h"
00051
00052 # include "host.m"
00053 # include "host.h"
00054 # include "target.m"
00055 # include "target.h"
00056
00057 # include "globals.m"
00058 # include "tokens.m"
00059 # include "sytb.m"
00060 # include "debug.m"
00061 # include "s_globals.m"
00062
00063 # include "globals.h"
00064 # include "tokens.h"
00065 # include "sytb.h"
00066 # include "s_globals.h"
00067 # include "s_data.h"
00068
00069
00070
00071
00072
00073
00074 static void adjust_char_value_len (int, int, long64, long64);
00075 static void build_loop_tbl (int, boolean);
00076 static boolean check_target_and_value (int, int);
00077 static void data_imp_do_semantics (int, int, boolean, boolean *);
00078 static void fold_all_subscripts (opnd_type *);
00079 static void gen_section_ref(int,long64,int,int,int,long64 *,long64 *,
00080 long64 *);
00081 static boolean good_data_imp_do_expr(int);
00082 static boolean imp_do_metamorphed (int);
00083 static boolean init_whole_array(int, long64 *, int, int, boolean *);
00084 static void interpret_data_imp_do(int);
00085 static void object_semantics (opnd_type *, expr_mode_type, expr_arg_type *,
00086 boolean, boolean);
00087 static boolean optimize_whole_array_init(int);
00088 static void process_data_imp_do_target(int, int, long64);
00089 static void section_semantics (int, opnd_type *, int *);
00090 static void set_global_value_variables (opnd_type *, opnd_type *, int);
00091 static void vv_subscript_semantics(int, int, expr_arg_type *);
00092
00093 # if 0
00094 static int reenter_const_as_hollerith(int, int, int, holler_type);
00095 # endif
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137 static boolean init_whole_array(int whole_sub_ir_idx,
00138 long64 *dup_count,
00139 int root_ir_idx,
00140 int init_ir_idx,
00141 boolean *optimized)
00142
00143 {
00144 static int attr_idx;
00145 int bd_idx;
00146 static long64 curr_subscript;
00147 int curr_subscript_idx;
00148 int eq_idx;
00149 int eq_tmp_idx;
00150 boolean first_call;
00151 int il_idx;
00152 int ir_idx;
00153 size_offset_type length;
00154 boolean long_value;
00155 boolean ok = TRUE;
00156 opnd_type opnd;
00157 int overlay_attr_idx;
00158 size_offset_type result;
00159 int var_attr_idx;
00160 boolean word_size_target;
00161
00162 # if defined(_SEPARATE_NONCOMMON_EQUIV_GROUPS)
00163 int sb_idx;
00164 # endif
00165
00166
00167 TRACE(Func_Entry, "init_whole_array", NULL);
00168
00169 if (obj_count == 0) {
00170 first_call = TRUE;
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186 if (IR_FLD_L(whole_sub_ir_idx) == AT_Tbl_Idx) {
00187 attr_idx = IR_IDX_L(whole_sub_ir_idx);
00188 }
00189 else {
00190 attr_idx = IR_IDX_R(IR_IDX_L(whole_sub_ir_idx));
00191 }
00192
00193 obj_count = CN_INT_TO_C(BD_LEN_IDX(ATD_ARRAY_IDX(attr_idx)));
00194
00195 if (BD_RANK(ATD_ARRAY_IDX(attr_idx)) == 1 ) {
00196 curr_subscript_idx = BD_LB_IDX(ATD_ARRAY_IDX(attr_idx), 1);
00197 curr_subscript = CN_INT_TO_C(curr_subscript_idx);
00198 }
00199 else {
00200 AT_DEFINED(attr_idx) = TRUE;
00201
00202 overlay_attr_idx = gen_compiler_tmp(IR_LINE_NUM_L(whole_sub_ir_idx),
00203 IR_COL_NUM_L(whole_sub_ir_idx),
00204 Shared, TRUE);
00205
00206 ATD_TYPE_IDX(overlay_attr_idx) = ATD_TYPE_IDX(attr_idx);
00207 ATD_STOR_BLK_IDX(overlay_attr_idx) = ATD_STOR_BLK_IDX(attr_idx);
00208 ATD_EQUIV(overlay_attr_idx) = TRUE;
00209 AT_REFERENCED(overlay_attr_idx) = Referenced;
00210 AT_SEMANTICS_DONE(overlay_attr_idx) = TRUE;
00211
00212 if (ATD_CLASS(attr_idx) != Struct_Component) {
00213
00214 ATD_OFFSET_FLD(overlay_attr_idx) = ATD_OFFSET_FLD(attr_idx);
00215 ATD_OFFSET_IDX(overlay_attr_idx) = ATD_OFFSET_IDX(attr_idx);
00216 ATD_OFFSET_ASSIGNED(overlay_attr_idx) =
00217 ATD_OFFSET_ASSIGNED(attr_idx);
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227 if (ATD_EQUIV(attr_idx)) {
00228 eq_idx = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
00229
00230 while (eq_idx != NULL_IDX) {
00231 eq_tmp_idx = eq_idx;
00232 eq_idx = EQ_NEXT_EQUIV_GRP(eq_idx);
00233
00234 while (eq_tmp_idx != NULL_IDX) {
00235
00236 if (EQ_ATTR_IDX(eq_tmp_idx) == attr_idx) {
00237 NTR_EQ_TBL(eq_idx);
00238 COPY_TBL_NTRY(equiv_tbl, eq_idx, eq_tmp_idx);
00239 EQ_NEXT_EQUIV_OBJ(eq_tmp_idx) = eq_idx;
00240 EQ_ATTR_IDX(eq_idx) = overlay_attr_idx;
00241 ATD_OFFSET_FLD(overlay_attr_idx)=
00242 ATD_OFFSET_FLD(attr_idx);
00243 ATD_OFFSET_IDX(overlay_attr_idx)=
00244 ATD_OFFSET_IDX(attr_idx);
00245 ATD_EQUIV(attr_idx) = TRUE;
00246 goto FOUND;
00247 }
00248 eq_tmp_idx = EQ_NEXT_EQUIV_OBJ(eq_tmp_idx);
00249 }
00250 }
00251 }
00252
00253
00254
00255
00256 NTR_EQ_TBL(eq_idx);
00257 NTR_EQ_TBL(eq_tmp_idx);
00258
00259 EQ_NEXT_EQUIV_GRP(eq_idx) = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
00260 SCP_FIRST_EQUIV_GRP(curr_scp_idx) = eq_idx;
00261 EQ_ATTR_IDX(eq_idx) = attr_idx;
00262 EQ_ATTR_IDX(eq_tmp_idx) = overlay_attr_idx;
00263 EQ_NEXT_EQUIV_OBJ(eq_idx) = eq_tmp_idx;
00264 ATD_EQUIV(attr_idx) = TRUE;
00265 ATD_VARIABLE_TMP_IDX(attr_idx) = overlay_attr_idx;
00266 ATD_FLD(attr_idx) = AT_Tbl_Idx;
00267
00268 # if defined(_SEPARATE_NONCOMMON_EQUIV_GROUPS)
00269
00270 sb_idx = ATD_STOR_BLK_IDX(attr_idx);
00271
00272 if (sb_idx == NULL_IDX ||
00273 (!SB_MODULE(sb_idx) && !SB_IS_COMMON(sb_idx))) {
00274
00275 if (SB_HOSTED_STATIC(sb_idx)) {
00276 sb_idx = create_equiv_stor_blk(attr_idx, SB_BLK_TYPE(sb_idx));
00277 SB_HOSTED_STATIC(sb_idx) = TRUE;
00278 }
00279 else {
00280 sb_idx = create_equiv_stor_blk(attr_idx, SB_BLK_TYPE(sb_idx));
00281 }
00282
00283 ATD_STOR_BLK_IDX(attr_idx) = sb_idx;
00284 ATD_STOR_BLK_IDX(overlay_attr_idx) = sb_idx;
00285 }
00286 # endif
00287
00288 }
00289 else {
00290
00291 ATD_OFFSET_FLD(overlay_attr_idx) = ATD_OFFSET_FLD(attr_idx);
00292 ATD_OFFSET_IDX(overlay_attr_idx) = ATD_CPNT_OFFSET_IDX(attr_idx);
00293 ATD_OFFSET_ASSIGNED(overlay_attr_idx) =
00294 ATD_OFFSET_ASSIGNED(attr_idx);
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309 ir_idx = IR_IDX_L(whole_sub_ir_idx);
00310
00311 if (ATD_OFFSET_IDX(overlay_attr_idx) == NULL_IDX) {
00312 ATD_OFFSET_FLD(overlay_attr_idx) = CN_Tbl_Idx;
00313 ATD_OFFSET_IDX(overlay_attr_idx) = CN_INTEGER_ZERO_IDX;
00314 }
00315
00316 # if defined(_DEBUG)
00317
00318
00319
00320 if (ATD_OFFSET_FLD(overlay_attr_idx) != CN_Tbl_Idx) {
00321 PRINTMSG(AT_DEF_LINE(overlay_attr_idx), 1201, Internal,
00322 AT_DEF_COLUMN(overlay_attr_idx),
00323 AT_OBJ_NAME_PTR(overlay_attr_idx));
00324 }
00325 # endif
00326
00327 result.fld = ATD_OFFSET_FLD(overlay_attr_idx);
00328 result.idx = ATD_OFFSET_IDX(overlay_attr_idx);
00329
00330 while (IR_FLD_L(ir_idx) == IR_Tbl_Idx) {
00331 ir_idx = IR_IDX_L(ir_idx);
00332 length.fld = ATD_OFFSET_FLD(IR_IDX_R(ir_idx));
00333 length.idx = ATD_CPNT_OFFSET_IDX(IR_IDX_R(ir_idx));
00334
00335 if (!size_offset_binary_calc(&length,
00336 &result,
00337 Plus_Opr,
00338 &result)) {
00339 break;
00340 }
00341 }
00342
00343 if (result.fld == NO_Tbl_Idx) {
00344 ATD_OFFSET_FLD(overlay_attr_idx) = CN_Tbl_Idx;
00345 ATD_OFFSET_IDX(overlay_attr_idx) = ntr_const_tbl(result.type_idx,
00346 FALSE,
00347 result.constant);
00348 }
00349 else {
00350 ATD_OFFSET_FLD(overlay_attr_idx) = result.fld;
00351 ATD_OFFSET_IDX(overlay_attr_idx) = result.idx;
00352 }
00353
00354 var_attr_idx = IR_IDX_L(ir_idx);
00355 ATD_OFFSET_ASSIGNED(overlay_attr_idx) = FALSE;
00356 ATD_DATA_INIT(overlay_attr_idx) = TRUE;
00357
00358 ATD_STOR_BLK_IDX(overlay_attr_idx) = ATD_STOR_BLK_IDX(var_attr_idx);
00359
00360 if (ATD_EQUIV(var_attr_idx)) {
00361 eq_idx = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
00362
00363 while (eq_idx != NULL_IDX) {
00364 eq_tmp_idx = eq_idx;
00365 eq_idx = EQ_NEXT_EQUIV_GRP(eq_idx);
00366
00367 while (eq_tmp_idx != NULL_IDX) {
00368
00369 if (EQ_ATTR_IDX(eq_tmp_idx) == var_attr_idx) {
00370
00371 if (ATD_OFFSET_IDX(var_attr_idx) == NULL_IDX) {
00372 ATD_OFFSET_FLD(var_attr_idx) = CN_Tbl_Idx;
00373 ATD_OFFSET_IDX(var_attr_idx) = CN_INTEGER_ZERO_IDX;
00374 }
00375 NTR_EQ_TBL(eq_idx);
00376 COPY_TBL_NTRY(equiv_tbl, eq_idx, eq_tmp_idx);
00377 EQ_NEXT_EQUIV_OBJ(eq_tmp_idx) = eq_idx;
00378 EQ_ATTR_IDX(eq_idx) = overlay_attr_idx;
00379
00380 result.fld = EQ_OFFSET_FLD(eq_idx);
00381 result.idx = EQ_OFFSET_IDX(eq_idx);
00382 length.fld = ATD_OFFSET_FLD(overlay_attr_idx);
00383 length.idx = ATD_OFFSET_IDX(overlay_attr_idx);
00384
00385 if (!size_offset_binary_calc(&result,
00386 &length,
00387 Plus_Opr,
00388 &result)) {
00389 break;
00390 }
00391
00392 if (result.fld == NO_Tbl_Idx) {
00393 EQ_OFFSET_FLD(eq_idx) = CN_Tbl_Idx;
00394 EQ_OFFSET_IDX(eq_idx) = ntr_const_tbl(
00395 result.type_idx,
00396 FALSE,
00397 result.constant);
00398 }
00399 else if (result.fld == CN_Tbl_Idx) {
00400 EQ_OFFSET_FLD(eq_idx) = result.fld;
00401 EQ_OFFSET_IDX(eq_idx) = result.idx;
00402 }
00403
00404 result.fld = ATD_OFFSET_FLD(var_attr_idx);
00405 result.idx = ATD_OFFSET_IDX(var_attr_idx);
00406
00407 if (!size_offset_binary_calc(&length,
00408 &result,
00409 Plus_Opr,
00410 &result)) {
00411 break;
00412 }
00413
00414 if (result.fld == NO_Tbl_Idx) {
00415 ATD_OFFSET_FLD(overlay_attr_idx) = CN_Tbl_Idx;
00416 ATD_OFFSET_IDX(overlay_attr_idx) = ntr_const_tbl(
00417 result.type_idx,
00418 FALSE,
00419 result.constant);
00420 }
00421 else {
00422 ATD_OFFSET_FLD(overlay_attr_idx) = result.fld;
00423 ATD_OFFSET_IDX(overlay_attr_idx) = result.idx;
00424 }
00425
00426 ATD_EQUIV(var_attr_idx) = TRUE;
00427 goto FOUND;
00428 }
00429 eq_tmp_idx = EQ_NEXT_EQUIV_OBJ(eq_tmp_idx);
00430 }
00431 }
00432 }
00433
00434
00435
00436
00437 NTR_EQ_TBL(eq_idx);
00438 NTR_EQ_TBL(eq_tmp_idx);
00439
00440 EQ_NEXT_EQUIV_GRP(eq_idx) = SCP_FIRST_EQUIV_GRP(curr_scp_idx);
00441 SCP_FIRST_EQUIV_GRP(curr_scp_idx)= eq_idx;
00442 EQ_OFFSET_IDX(eq_tmp_idx) = ATD_OFFSET_IDX(overlay_attr_idx);
00443 EQ_OFFSET_FLD(eq_tmp_idx) = ATD_OFFSET_FLD(overlay_attr_idx);
00444 EQ_ATTR_IDX(eq_idx) = var_attr_idx;
00445 EQ_ATTR_IDX(eq_tmp_idx) = overlay_attr_idx;
00446 EQ_NEXT_EQUIV_OBJ(eq_idx) = eq_tmp_idx;
00447 ATD_EQUIV(var_attr_idx) = TRUE;
00448
00449 # if defined(_SEPARATE_NONCOMMON_EQUIV_GROUPS)
00450
00451 sb_idx = ATD_STOR_BLK_IDX(var_attr_idx);
00452
00453 if (sb_idx == NULL_IDX ||
00454 (!SB_MODULE(sb_idx) && !SB_IS_COMMON(sb_idx))) {
00455
00456 if (SB_HOSTED_STATIC(sb_idx)) {
00457 sb_idx = create_equiv_stor_blk(attr_idx, SB_BLK_TYPE(sb_idx));
00458 SB_HOSTED_STATIC(sb_idx) = TRUE;
00459 }
00460 else {
00461 sb_idx = create_equiv_stor_blk(attr_idx, SB_BLK_TYPE(sb_idx));
00462 }
00463
00464 ATD_STOR_BLK_IDX(var_attr_idx) = sb_idx;
00465 ATD_STOR_BLK_IDX(overlay_attr_idx) = sb_idx;
00466 }
00467 # endif
00468
00469 NTR_IR_LIST_TBL(il_idx);
00470 IL_IDX(il_idx) = overlay_attr_idx;
00471 IL_FLD(il_idx) = AT_Tbl_Idx;
00472 IL_LINE_NUM(il_idx) = stmt_start_line;
00473 IL_COL_NUM(il_idx) = stmt_start_col;
00474
00475 if (ATD_FLD(var_attr_idx) == NO_Tbl_Idx) {
00476 ATD_FLD(var_attr_idx) = IL_Tbl_Idx;
00477 IL_LIST_CNT(il_idx) = 1;
00478 }
00479 else {
00480 IL_LIST_CNT(il_idx) = 1 +
00481 IL_LIST_CNT(ATD_VARIABLE_TMP_IDX(var_attr_idx));
00482 IL_NEXT_LIST_IDX(il_idx) = ATD_VARIABLE_TMP_IDX(var_attr_idx);
00483 }
00484 ATD_VARIABLE_TMP_IDX(var_attr_idx) = il_idx;
00485 }
00486
00487 FOUND:;
00488
00489
00490
00491 bd_idx = reserve_array_ntry(1);
00492 BD_RESOLVED(bd_idx) = TRUE;
00493 BD_LEN_FLD(bd_idx) = CN_Tbl_Idx;
00494 BD_LEN_IDX(bd_idx) = BD_LEN_IDX(ATD_ARRAY_IDX(attr_idx));
00495 BD_RANK(bd_idx) = 1;
00496 BD_ARRAY_CLASS(bd_idx) = Explicit_Shape;
00497 BD_ARRAY_SIZE(bd_idx) = Constant_Size;
00498 BD_LINE_NUM(bd_idx) = IR_LINE_NUM_L(whole_sub_ir_idx);
00499 BD_COLUMN_NUM(bd_idx) = IR_COL_NUM_L(whole_sub_ir_idx);
00500 BD_LB_FLD(bd_idx,1) = CN_Tbl_Idx;
00501 BD_LB_IDX(bd_idx,1) = CN_INTEGER_ONE_IDX;
00502 BD_UB_FLD(bd_idx,1) = CN_Tbl_Idx;
00503 BD_UB_IDX(bd_idx,1) = BD_LEN_IDX(ATD_ARRAY_IDX(attr_idx));
00504 BD_XT_FLD(bd_idx,1) = CN_Tbl_Idx;
00505 BD_XT_IDX(bd_idx,1) = BD_LEN_IDX(ATD_ARRAY_IDX(attr_idx));
00506 BD_SM_FLD(bd_idx,1) = CN_Tbl_Idx;
00507 BD_SM_IDX(bd_idx,1) = BD_SM_IDX(ATD_ARRAY_IDX(attr_idx),1);
00508
00509 ATD_ARRAY_IDX(overlay_attr_idx) = ntr_array_in_bd_tbl(bd_idx);
00510
00511 curr_subscript = 1;
00512 curr_subscript_idx = CN_INTEGER_ONE_IDX;
00513
00514 attr_idx = overlay_attr_idx;
00515 }
00516 }
00517 else {
00518 first_call = FALSE;
00519 curr_subscript += *dup_count;
00520 curr_subscript_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
00521 curr_subscript);
00522 }
00523
00524 word_size_target = FALSE;
00525
00526 if (TYP_LINEAR(ATD_TYPE_IDX(attr_idx)) == INTEGER_DEFAULT_TYPE ||
00527 TYP_LINEAR(ATD_TYPE_IDX(attr_idx)) == REAL_DEFAULT_TYPE) {
00528
00529 if (storage_bit_size_tbl[TYP_LINEAR(ATD_TYPE_IDX(attr_idx))] ==
00530 TARGET_BITS_PER_WORD) {
00531 word_size_target = TRUE;
00532 }
00533 }
00534
00535 long_value = FALSE;
00536
00537 if (value_desc.type == Typeless) {
00538
00539 if (TYP_BIT_LEN(CN_TYPE_IDX(OPND_IDX(value_opnd))) >
00540 TARGET_BITS_PER_WORD) {
00541 long_value = TRUE;
00542 }
00543 }
00544 else if (value_desc.type == Character) {
00545
00546 if (CN_INT_TO_C(TYP_IDX(value_desc.type_idx)) > TARGET_CHARS_PER_WORD) {
00547 long_value = TRUE;
00548 }
00549 }
00550
00551 if (word_size_target && long_value) {
00552 PRINTMSG(OPND_LINE_NUM(value_opnd), 733, Error, OPND_COL_NUM(value_opnd));
00553 }
00554 else {
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568 if (first_call &&
00569 IR_FLD_L(IR_IDX_L(init_ir_idx)) == AT_Tbl_Idx &&
00570 TYP_TYPE(ATD_TYPE_IDX(IR_IDX_L(IR_IDX_L(init_ir_idx)))) !=
00571 Structure) {
00572
00573 if (ATD_CLASS(attr_idx) == Compiler_Tmp) {
00574 IR_IDX_L(IR_IDX_L(init_ir_idx)) = attr_idx;
00575 }
00576
00577 if (TYP_TYPE(CN_TYPE_IDX(OPND_IDX(value_opnd))) == Character &&
00578 (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Integer ||
00579 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Real)) {
00580 *optimized = FALSE;
00581 }
00582 else {
00583 *optimized = optimize_whole_array_init(init_ir_idx);
00584 }
00585
00586 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
00587 ok = FALSE;
00588 goto EXIT;
00589 }
00590
00591 if (*optimized) {
00592 goto EXIT;
00593 }
00594 }
00595 else {
00596 *optimized = FALSE;
00597 }
00598 }
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608 gen_opnd(&opnd, root_ir_idx, IR_Tbl_Idx, stmt_start_line, stmt_start_col);
00609 copy_subtree(&opnd, &opnd);
00610 ir_idx = OPND_IDX(opnd);
00611 IR_FLD_L(init_ir_idx) = IR_Tbl_Idx;
00612 IR_IDX_L(init_ir_idx) = ir_idx;
00613
00614 while (IR_OPR(ir_idx) != Whole_Subscript_Opr) {
00615 ir_idx = IR_IDX_L(ir_idx);
00616 }
00617
00618 IR_OPR(ir_idx) = Subscript_Opr;
00619 IR_RANK(ir_idx) = 1;
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630 if (ATD_CLASS(attr_idx) == Compiler_Tmp) {
00631
00632 if (IR_FLD_L(ir_idx) == AT_Tbl_Idx) {
00633 IR_IDX_L(ir_idx) = attr_idx;
00634 }
00635 else {
00636 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
00637 IR_IDX_L(ir_idx) = attr_idx;
00638 IR_LINE_NUM_L(ir_idx) = stmt_start_line;
00639 IR_COL_NUM_L(ir_idx) = stmt_start_col;
00640 }
00641 }
00642
00643 il_idx = IR_IDX_R(ir_idx);
00644 IL_NEXT_LIST_IDX(il_idx) = NULL_IDX;
00645 IR_LIST_CNT_R(ir_idx) = 1;
00646
00647 IL_FLD(il_idx) = CN_Tbl_Idx;
00648 IL_IDX(il_idx) = curr_subscript_idx;
00649 IL_LINE_NUM(il_idx) = stmt_start_line;
00650 IL_COL_NUM(il_idx) = stmt_start_col;
00651
00652
00653 EXIT:
00654
00655 TRACE(Func_Exit, "init_whole_array", NULL);
00656
00657 return(ok);
00658
00659 }
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680 void data_stmt_semantics(void)
00681 {
00682 #ifdef KEY
00683 int array_ir_idx = 0;
00684 #else
00685 int array_ir_idx;
00686 #endif
00687 int attr_idx;
00688 int column;
00689 #ifdef KEY
00690 boolean compiler_gen_imp_do = FALSE;
00691 #else
00692 boolean compiler_gen_imp_do;
00693 #endif
00694 int const_il_idx;
00695 int dim_item_idx;
00696 int dup_cnt_il_idx;
00697 opnd_type dup_cnt_opnd;
00698 long64 dup_count;
00699 boolean dup_count_calculated = FALSE;
00700 boolean first_obj = TRUE;
00701 int first_triplet_idx;
00702 int i;
00703 int il_idx;
00704 int init_ir_idx;
00705 int ir_idx;
00706 size_offset_type length;
00707 int line;
00708 boolean metamorphed;
00709 expr_arg_type obj_desc;
00710 opnd_type obj_opnd;
00711 boolean optimized;
00712 opnd_type rep_factor_opnd;
00713 #ifdef KEY
00714 int root_ir_idx = 0;
00715 #else
00716 int root_ir_idx;
00717 #endif
00718 long64 section_inc_value;
00719 long64 section_start_value = 0;
00720 int stride_il_idx;
00721 size_offset_type stride_in_bits;
00722 opnd_type stride_opnd;
00723 #ifdef KEY
00724 int struct_ir_idx = 0;
00725
00726 int target_attr_idx = 0;
00727 boolean vv_sub_present = FALSE;
00728 #else
00729 int struct_ir_idx;
00730
00731 int target_attr_idx;
00732 boolean vv_sub_present;
00733 #endif
00734
00735
00736 TRACE (Func_Entry, "data_stmt_semantics", NULL);
00737
00738 OPND_IDX(rep_factor_opnd) = NULL_IDX;
00739 init_ir_idx = SH_IR_IDX(curr_stmt_sh_idx);
00740 obj_il_idx = IR_IDX_L(init_ir_idx);
00741 value_il_idx = IR_IDX_R(init_ir_idx);
00742 metamorphed = FALSE;
00743 obj_count = 0;
00744 rep_factor = 0;
00745
00746 while (obj_il_idx != NULL_IDX) {
00747
00748 if (first_obj) {
00749 first_obj = FALSE;
00750 }
00751 else {
00752 gen_sh(After, Data_Stmt, IL_LINE_NUM(obj_il_idx),
00753 IL_COL_NUM(obj_il_idx), FALSE, FALSE, TRUE);
00754
00755 NTR_IR_TBL(init_ir_idx);
00756 SH_IR_IDX(curr_stmt_sh_idx) = init_ir_idx;
00757 IR_OPR(init_ir_idx) = Init_Opr;
00758 IR_TYPE_IDX(init_ir_idx) = TYPELESS_DEFAULT_TYPE;
00759 IR_LINE_NUM(init_ir_idx) = IL_LINE_NUM(obj_il_idx);
00760 IR_COL_NUM(init_ir_idx) = IL_COL_NUM(obj_il_idx);
00761 }
00762
00763 RESTART:
00764
00765 if (obj_count == 0) {
00766 stride_opnd = null_opnd;
00767 array_ir_idx = NULL_IDX;
00768 struct_ir_idx = NULL_IDX;
00769
00770 target_attr_idx = NULL_IDX;
00771 obj_desc.rank = 0;
00772 compiler_gen_imp_do = FALSE;
00773 vv_sub_present = FALSE;
00774
00775 COPY_OPND(obj_opnd, IL_OPND(obj_il_idx));
00776
00777 if (OPND_FLD(obj_opnd) == AT_Tbl_Idx ||
00778 (OPND_FLD(obj_opnd) == IR_Tbl_Idx &&
00779 IR_OPR(OPND_IDX(obj_opnd)) != Implied_Do_Opr)) {
00780 object_semantics(&obj_opnd,
00781 Data_Stmt_Target,
00782 &obj_desc,
00783 TRUE,
00784 metamorphed);
00785
00786 if (OPND_FLD(obj_opnd) == AT_Tbl_Idx) {
00787 root_ir_idx = NULL_IDX;
00788 }
00789 else {
00790 root_ir_idx = OPND_IDX(obj_opnd);
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801 ir_idx = OPND_IDX(obj_opnd);
00802
00803 while (IR_FLD_L(ir_idx) == IR_Tbl_Idx) {
00804
00805 if (IR_OPR(ir_idx) == Struct_Opr) {
00806 break;
00807 }
00808 else {
00809 ir_idx = IR_IDX_L(ir_idx);
00810 }
00811 }
00812
00813 target_attr_idx = (IR_OPR(ir_idx) == Struct_Opr) ?
00814 IR_IDX_R(ir_idx) : IR_IDX_L(ir_idx);
00815 }
00816
00817 if (! SH_ERR_FLG(curr_stmt_sh_idx)) {
00818 COPY_OPND(IR_OPND_L(init_ir_idx), obj_opnd);
00819 }
00820 else {
00821 goto EXIT;
00822 }
00823 }
00824 }
00825
00826
00827
00828
00829
00830
00831
00832
00833 if (rep_factor == 0) {
00834 set_global_value_variables(&rep_factor_opnd,
00835 &dup_cnt_opnd,
00836 target_attr_idx);
00837
00838 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
00839 goto EXIT;
00840 }
00841 }
00842
00843
00844
00845
00846
00847
00848
00849 PROCESS_THE_TARGET:
00850
00851
00852
00853
00854
00855 if (obj_desc.rank > 0 && !obj_desc.pointer) {
00856
00857
00858
00859
00860 if (array_ir_idx == NULL_IDX) {
00861 array_ir_idx = OPND_IDX(obj_opnd);
00862
00863 while (IR_OPR(array_ir_idx) != Whole_Subscript_Opr &&
00864 IR_OPR(array_ir_idx) != Section_Subscript_Opr) {
00865
00866
00867
00868
00869
00870
00871
00872
00873 if (IR_OPR(array_ir_idx) == Struct_Opr) {
00874 struct_ir_idx = array_ir_idx;
00875 }
00876
00877 array_ir_idx = IR_IDX_L(array_ir_idx);
00878 }
00879 }
00880
00881 if (IR_OPR(array_ir_idx) == Whole_Subscript_Opr) {
00882
00883
00884
00885
00886 if (IR_FLD_L(array_ir_idx) == AT_Tbl_Idx) {
00887 dim_item_idx = IR_IDX_L(array_ir_idx);
00888 }
00889 else {
00890
00891
00892
00893
00894
00895
00896
00897
00898 if (struct_ir_idx == NULL_IDX) {
00899 dim_item_idx = IR_IDX_R(IR_IDX_L(array_ir_idx));
00900 }
00901 else {
00902 ir_idx = IR_IDX_L(array_ir_idx);
00903
00904 while (IR_FLD_L(ir_idx) == IR_Tbl_Idx) {
00905 ir_idx = IR_IDX_L(ir_idx);
00906 }
00907
00908 dim_item_idx = IR_IDX_L(ir_idx);
00909 }
00910
00911 }
00912
00913 if (compare_cn_and_value(BD_LEN_IDX(ATD_ARRAY_IDX(dim_item_idx)),
00914 0, Eq_Opr)) {
00915 SH_IR_IDX(curr_stmt_sh_idx) = NULL_IDX;
00916 obj_il_idx = IL_NEXT_LIST_IDX(obj_il_idx);
00917 continue;
00918 }
00919
00920 if (struct_ir_idx == NULL_IDX ||
00921 (struct_ir_idx != NULL_IDX && obj_desc.rank == 1)) {
00922
00923 if (init_whole_array(array_ir_idx,
00924 &dup_count,
00925 root_ir_idx,
00926 init_ir_idx,
00927 &optimized)) {
00928
00929 if (optimized) {
00930 obj_il_idx = IL_NEXT_LIST_IDX(obj_il_idx);
00931 continue;
00932 }
00933 }
00934 else {
00935 goto EXIT;
00936 }
00937 }
00938 else {
00939 IR_OPR(array_ir_idx) = Section_Subscript_Opr;
00940 goto PROCESS_THE_TARGET;
00941 }
00942 }
00943 else {
00944
00945
00946
00947 if (obj_count == 0) {
00948 il_idx = IR_IDX_R(array_ir_idx);
00949
00950 for (i = 1; i <= IR_LIST_CNT_R(array_ir_idx); ++i) {
00951
00952 if (IL_VECTOR_SUBSCRIPT(il_idx)) {
00953 vv_sub_present = TRUE;
00954 break;
00955 }
00956
00957 il_idx = IL_NEXT_LIST_IDX(il_idx);
00958 }
00959
00960
00961
00962
00963
00964
00965
00966 if (vv_sub_present) {
00967 vv_subscript_semantics(init_ir_idx,
00968 array_ir_idx,
00969 &obj_desc);
00970
00971 data_imp_do_semantics(init_ir_idx,
00972 IR_IDX_L(init_ir_idx),
00973 TRUE,
00974 &metamorphed);
00975
00976 obj_il_idx = IL_NEXT_LIST_IDX(obj_il_idx);
00977 continue;
00978 }
00979 else {
00980 section_semantics(array_ir_idx,
00981 &stride_opnd,
00982 &first_triplet_idx);
00983 }
00984 }
00985
00986 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
00987 goto EXIT;
00988 }
00989
00990 if (obj_count != 0) {
00991 gen_section_ref( array_ir_idx,
00992 rep_factor,
00993 first_triplet_idx,
00994 root_ir_idx,
00995 init_ir_idx,
00996 &dup_count,
00997 §ion_start_value,
00998 §ion_inc_value);
00999 dup_count_calculated = TRUE;
01000 }
01001 else {
01002 SH_IR_IDX(curr_stmt_sh_idx) = NULL_IDX;
01003 obj_il_idx = IL_NEXT_LIST_IDX(obj_il_idx);
01004 continue;
01005 }
01006 }
01007 }
01008 else {
01009
01010
01011
01012 if (OPND_FLD(obj_opnd) == AT_Tbl_Idx) {
01013 obj_count = 1;
01014 target_attr_idx = OPND_IDX(obj_opnd);
01015 }
01016 else {
01017
01018
01019
01020 if (IR_OPR(OPND_IDX(obj_opnd)) == Implied_Do_Opr) {
01021
01022 data_imp_do_semantics(init_ir_idx,
01023 IL_IDX(obj_il_idx),
01024 compiler_gen_imp_do,
01025 &metamorphed);
01026
01027 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
01028 goto EXIT;
01029 }
01030
01031 if (metamorphed) {
01032 IL_FLD(obj_il_idx) = IL_FLD(IR_IDX_L(init_ir_idx));
01033 IL_IDX(obj_il_idx) = IL_IDX(IR_IDX_L(init_ir_idx));
01034 goto RESTART;
01035 }
01036
01037 COPY_OPND(IR_OPND_L(init_ir_idx), obj_opnd);
01038 obj_il_idx = IL_NEXT_LIST_IDX(obj_il_idx);
01039
01040 continue;
01041 }
01042 else {
01043
01044
01045
01046
01047
01048 obj_count = 1;
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058 }
01059 }
01060 }
01061
01062
01063
01064 if (value_il_idx == NULL_IDX) {
01065 find_opnd_line_and_column(&obj_opnd, &line, &column);
01066 PRINTMSG(line, 667, Error, column);
01067 goto EXIT;
01068 }
01069
01070
01071
01072 if (! check_target_and_value(target_attr_idx, init_ir_idx)) {
01073 goto EXIT;
01074 }
01075
01076
01077
01078 NTR_IR_LIST_TBL(const_il_idx);
01079 IR_LIST_CNT_R(init_ir_idx) = 3;
01080 IR_FLD_R(init_ir_idx) = IL_Tbl_Idx;
01081 IR_IDX_R(init_ir_idx) = const_il_idx;
01082 COPY_OPND(IL_OPND(const_il_idx), value_opnd);
01083
01084
01085
01086 NTR_IR_LIST_TBL(dup_cnt_il_idx);
01087 IL_PREV_LIST_IDX(dup_cnt_il_idx) = const_il_idx;
01088 IL_NEXT_LIST_IDX(const_il_idx) = dup_cnt_il_idx;
01089
01090 if (OPND_IDX(rep_factor_opnd) == NULL_IDX) {
01091 find_opnd_line_and_column(&value_opnd, &line, &column);
01092 IL_LINE_NUM(dup_cnt_il_idx) = line;
01093 IL_COL_NUM(dup_cnt_il_idx) = column;
01094 IL_FLD(dup_cnt_il_idx) = CN_Tbl_Idx;
01095 IL_IDX(dup_cnt_il_idx) = CN_INTEGER_ONE_IDX;
01096 dup_count = 1;
01097 }
01098 else {
01099
01100 if (dup_count_calculated) {
01101 dup_count_calculated = FALSE;
01102 }
01103 else {
01104 dup_count = (obj_count <= rep_factor) ? obj_count : rep_factor;
01105 }
01106
01107 OPND_IDX(dup_cnt_opnd) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
01108 dup_count);
01109 COPY_OPND(IL_OPND(dup_cnt_il_idx), dup_cnt_opnd);
01110 }
01111
01112
01113
01114
01115 NTR_IR_LIST_TBL(stride_il_idx);
01116 IL_PREV_LIST_IDX(stride_il_idx) = dup_cnt_il_idx;
01117 IL_NEXT_LIST_IDX(dup_cnt_il_idx) = stride_il_idx;
01118
01119 if (dup_count == 1 ||
01120 (OPND_IDX(stride_opnd) == NULL_IDX && array_ir_idx == NULL_IDX)) {
01121 find_opnd_line_and_column(&obj_opnd, &line, &column);
01122 IL_LINE_NUM(stride_il_idx) = line;
01123 IL_COL_NUM(stride_il_idx) = column;
01124 IL_FLD(stride_il_idx) = CN_Tbl_Idx;
01125 IL_IDX(stride_il_idx) = CN_INTEGER_ZERO_IDX;
01126 }
01127 else {
01128
01129
01130
01131
01132
01133
01134 if (OPND_FLD(stride_opnd) == NO_Tbl_Idx) {
01135
01136 if (struct_ir_idx == NULL_IDX) {
01137 attr_idx = (IR_FLD_L(array_ir_idx) == AT_Tbl_Idx) ?
01138 IR_IDX_L(array_ir_idx) :
01139 IR_IDX_R(IR_IDX_L(array_ir_idx));
01140 }
01141 else {
01142 ir_idx = array_ir_idx;
01143
01144 while (IR_FLD_L(ir_idx) == IR_Tbl_Idx) {
01145 ir_idx = IR_IDX_L(ir_idx);
01146 }
01147
01148 attr_idx = IR_IDX_L(ir_idx);
01149 }
01150
01151 stride_in_bits = stor_bit_size_of(attr_idx, FALSE, FALSE);
01152
01153 if (OPND_IDX(stride_opnd) != NULL_IDX) {
01154 length.fld = CN_Tbl_Idx;
01155 length.idx = OPND_IDX(stride_opnd);
01156
01157 size_offset_binary_calc(&stride_in_bits,
01158 &length,
01159 Mult_Opr,
01160 &stride_in_bits);
01161 }
01162
01163 if (stride_in_bits.fld == NO_Tbl_Idx) {
01164 OPND_FLD(stride_opnd) = CN_Tbl_Idx;
01165 OPND_IDX(stride_opnd) = ntr_const_tbl(stride_in_bits.type_idx,
01166 FALSE,
01167 stride_in_bits.constant);
01168 }
01169 else {
01170 OPND_FLD(stride_opnd) = stride_in_bits.fld;
01171 OPND_IDX(stride_opnd) = stride_in_bits.idx;
01172 }
01173
01174 OPND_LINE_NUM(stride_opnd) = stmt_start_line;
01175 OPND_COL_NUM(stride_opnd) = stmt_start_col;
01176 }
01177
01178 COPY_OPND(IL_OPND(stride_il_idx), stride_opnd);
01179 }
01180
01181
01182
01183
01184 if (TYP_TYPE(ATD_TYPE_IDX(target_attr_idx)) == Character) {
01185 adjust_char_value_len(init_ir_idx,
01186 array_ir_idx,
01187 section_start_value,
01188 section_inc_value);
01189 }
01190
01191
01192
01193
01194
01195
01196 if ((obj_count -= dup_count) == 0) {
01197 obj_il_idx = IL_NEXT_LIST_IDX(obj_il_idx);
01198 }
01199
01200 if ((rep_factor -= dup_count) == 0) {
01201 value_il_idx = IL_NEXT_LIST_IDX(value_il_idx);
01202
01203 if (value_il_idx != NULL_IDX) {
01204 IL_PREV_LIST_IDX(value_il_idx) = NULL_IDX;
01205 }
01206
01207 if (value_il_idx == NULL_IDX && obj_count != 0) {
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218 if (OPND_FLD(obj_opnd) == IR_Tbl_Idx &&
01219 IR_OPR(OPND_IDX(obj_opnd)) == Whole_Subscript_Opr &&
01220 IL_NEXT_LIST_IDX(obj_il_idx) == NULL_IDX) {
01221
01222 if (IR_OPR(init_ir_idx) == Init_Opr) {
01223 PRINTMSG(IR_LINE_NUM_L(OPND_IDX(obj_opnd)), 698, Ansi,
01224 IR_COL_NUM_L(OPND_IDX(obj_opnd)));
01225 }
01226
01227 break;
01228 }
01229 else {
01230 find_opnd_line_and_column(&obj_opnd, &line, &column);
01231 PRINTMSG(line, 667, Error, column);
01232 obj_il_idx = NULL_IDX;
01233 }
01234 }
01235 }
01236
01237 }
01238
01239 if (value_il_idx != NULL_IDX) {
01240 PRINTMSG(IL_LINE_NUM(value_il_idx), 668, Error, IL_COL_NUM(value_il_idx));
01241 }
01242
01243 EXIT:
01244
01245 TRACE (Func_Exit, "data_stmt_semantics", NULL);
01246
01247 return;
01248
01249 }
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276 static void object_semantics(opnd_type *obj_opnd,
01277 expr_mode_type target_expr_mode,
01278 expr_arg_type *obj_desc,
01279 boolean fold_subscripts,
01280 boolean metamorphed)
01281
01282 {
01283 int attr_idx;
01284 opnd_type data_obj;
01285
01286
01287 TRACE (Func_Entry, "object_semantics", NULL);
01288
01289
01290
01291
01292 COPY_OPND(data_obj, *obj_opnd);
01293
01294 while (OPND_FLD(data_obj) == IR_Tbl_Idx) {
01295 COPY_OPND(data_obj, IR_OPND_L(OPND_IDX(data_obj)));
01296 }
01297
01298 if (AT_DCL_ERR(OPND_IDX(data_obj))) {
01299 SH_ERR_FLG(curr_stmt_sh_idx) = TRUE;
01300 goto EXIT;
01301 }
01302
01303
01304
01305 expr_mode = target_expr_mode;
01306 obj_desc->rank = 0;
01307
01308
01309
01310
01311 xref_state = (metamorphed) ? CIF_No_Usage_Rec :
01312 (cif_usage_code_type)
01313 (CIF_Symbol_Modification + 100);
01314
01315 if (expr_semantics(obj_opnd, obj_desc)) {
01316
01317 COPY_OPND(data_obj, *obj_opnd);
01318
01319 while (OPND_FLD(data_obj) == IR_Tbl_Idx) {
01320 COPY_OPND(data_obj, IR_OPND_L(OPND_IDX(data_obj)));
01321 }
01322
01323 attr_idx = OPND_IDX(data_obj);
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338 if (ATD_IN_COMMON(attr_idx)) {
01339
01340 if (SB_BLK_TYPE(ATD_STOR_BLK_IDX(attr_idx)) == Common) {
01341
01342 if (! metamorphed) {
01343
01344 if (SB_BLANK_COMMON(ATD_STOR_BLK_IDX(attr_idx))) {
01345 PRINTMSG(OPND_LINE_NUM(data_obj), 1109, Ansi,
01346 OPND_COL_NUM(data_obj));
01347 }
01348 else if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) != Blockdata) {
01349
01350 # if defined(_ALLOW_DATA_INIT_OF_COMMON)
01351 PRINTMSG(OPND_LINE_NUM(data_obj), 692, Ansi,
01352 OPND_COL_NUM(data_obj));
01353 # else
01354 PRINTMSG(OPND_LINE_NUM(data_obj), 1542, Warning,
01355 OPND_COL_NUM(data_obj));
01356 # endif
01357 }
01358 }
01359 }
01360 else if (SB_BLK_TYPE(ATD_STOR_BLK_IDX(attr_idx)) == Task_Common) {
01361 PRINTMSG(OPND_LINE_NUM(data_obj), 851, Error,
01362 OPND_COL_NUM(data_obj));
01363 }
01364 }
01365 else if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Blockdata &&
01366 !(ATD_EQUIV(attr_idx) &&
01367 SB_IS_COMMON(ATD_STOR_BLK_IDX(attr_idx)))) {
01368 PRINTMSG(OPND_LINE_NUM(data_obj), 825, Warning,
01369 OPND_COL_NUM(data_obj));
01370 }
01371
01372
01373
01374
01375 if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == CRI_Ch_Ptr) {
01376 # ifdef _EXTENDED_CRI_CHAR_POINTER
01377 transform_cri_ch_ptr(obj_opnd);
01378 # else
01379 PRINTMSG(OPND_LINE_NUM(data_obj), 695, Error, OPND_COL_NUM(data_obj));
01380 # endif
01381 }
01382
01383 if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure &&
01384 ATT_DEFAULT_INITIALIZED(TYP_IDX(ATD_TYPE_IDX(attr_idx)))) {
01385 PRINTMSG(OPND_LINE_NUM(data_obj), 1589, Error,
01386 OPND_COL_NUM(data_obj),
01387 AT_OBJ_NAME_PTR(attr_idx),
01388 AT_OBJ_NAME_PTR(TYP_IDX(ATD_TYPE_IDX(attr_idx))));
01389 }
01390
01391
01392
01393
01394
01395
01396
01397
01398 if (OPND_FLD((*obj_opnd)) == IR_Tbl_Idx && fold_subscripts) {
01399 fold_all_subscripts(obj_opnd);
01400 }
01401 }
01402
01403 EXIT:
01404
01405 expr_mode = Regular_Expr;
01406
01407 TRACE (Func_Exit, "object_semantics", NULL);
01408
01409 return;
01410
01411 }
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432 static void set_global_value_variables(opnd_type *rep_factor_opnd,
01433 opnd_type *dup_cnt_opnd,
01434 int target_attr_idx)
01435 {
01436 expr_arg_type expr_desc;
01437 #ifdef KEY
01438 int rep_count_ir_idx = 0;
01439 #else
01440 int rep_count_ir_idx;
01441 #endif
01442
01443
01444 TRACE (Func_Entry, "set_global_value_variables", NULL);
01445
01446
01447
01448
01449 while (rep_factor == 0 && value_il_idx != NULL_IDX) {
01450
01451 if (IL_FLD(value_il_idx) == IR_Tbl_Idx &&
01452 IR_OPR(IL_IDX(value_il_idx)) == Rep_Count_Opr) {
01453 rep_count_ir_idx = IL_IDX(value_il_idx);
01454 COPY_OPND(*rep_factor_opnd, IR_OPND_L(rep_count_ir_idx));
01455
01456 # ifdef _DEBUG
01457
01458 if (OPND_FLD((*rep_factor_opnd)) != CN_Tbl_Idx) {
01459 PRINTMSG(IR_LINE_NUM(rep_count_ir_idx), 626, Internal,
01460 IR_COL_NUM(rep_count_ir_idx),
01461 "CN_Tbl_Idx", "set_global_value_variables");
01462 }
01463
01464 # endif
01465
01466 expr_desc.type_idx = CN_TYPE_IDX(OPND_IDX((*rep_factor_opnd)));
01467 expr_desc.type = TYP_TYPE(expr_desc.type_idx);
01468 expr_desc.linear_type = TYP_LINEAR(expr_desc.type_idx);
01469
01470 rep_factor = CN_INT_TO_C(OPND_IDX((*rep_factor_opnd)));
01471
01472 if (rep_factor > 0) {
01473 COPY_OPND(*dup_cnt_opnd, *rep_factor_opnd);
01474 COPY_OPND(value_opnd, IR_OPND_R(rep_count_ir_idx));
01475 }
01476 else if (rep_factor == 0) {
01477 OPND_IDX((*rep_factor_opnd)) = NULL_IDX;
01478
01479 if (IL_PREV_LIST_IDX(value_il_idx) != NULL_IDX) {
01480 IL_NEXT_LIST_IDX(IL_PREV_LIST_IDX(value_il_idx)) =
01481 IL_NEXT_LIST_IDX(value_il_idx);
01482 }
01483
01484 if (IL_NEXT_LIST_IDX(value_il_idx) != NULL_IDX) {
01485 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(value_il_idx)) =
01486 IL_PREV_LIST_IDX(value_il_idx);
01487 }
01488
01489 value_il_idx = IL_NEXT_LIST_IDX(value_il_idx);
01490 continue;
01491 }
01492 else {
01493 PRINTMSG(OPND_LINE_NUM((*rep_factor_opnd)), 679, Error,
01494 OPND_COL_NUM((*rep_factor_opnd)));
01495 goto EXIT;
01496 }
01497 }
01498 else {
01499 COPY_OPND(value_opnd, IL_OPND(value_il_idx));
01500 rep_factor = 1;
01501 OPND_IDX((*rep_factor_opnd)) = NULL_IDX;
01502 rep_count_ir_idx = NULL_IDX;
01503 }
01504
01505 }
01506
01507 if (value_il_idx == NULL_IDX) {
01508 goto EXIT;
01509 }
01510
01511
01512
01513
01514
01515 if (OPND_FLD(value_opnd) == CN_Tbl_Idx) {
01516 value_desc.type_idx = CN_TYPE_IDX(OPND_IDX(value_opnd));
01517 value_desc.type = TYP_TYPE(value_desc.type_idx);
01518 value_desc.linear_type = TYP_LINEAR(value_desc.type_idx);
01519 }
01520 else if (OPND_FLD(value_opnd) == AT_Tbl_Idx &&
01521 AT_OBJ_CLASS(OPND_IDX(value_opnd)) == Data_Obj &&
01522 ATD_CLASS(OPND_IDX(value_opnd)) == Compiler_Tmp &&
01523 ATD_FLD(OPND_IDX(value_opnd)) == CN_Tbl_Idx) {
01524
01525 value_desc.type_idx = ATD_TYPE_IDX(OPND_IDX(value_opnd));
01526 value_desc.type = TYP_TYPE(value_desc.type_idx);
01527 value_desc.linear_type = TYP_LINEAR(value_desc.type_idx);
01528
01529 OPND_FLD(value_opnd) = CN_Tbl_Idx;
01530 OPND_IDX(value_opnd) = ATD_TMP_IDX(OPND_IDX(value_opnd));
01531
01532 if (rep_count_ir_idx == NULL_IDX) {
01533 COPY_OPND(IL_OPND(value_il_idx), value_opnd);
01534 }
01535 else {
01536 COPY_OPND(IR_OPND_R(rep_count_ir_idx), value_opnd);
01537 }
01538 }
01539 else if (OPND_FLD(value_opnd) == IR_Tbl_Idx &&
01540 IR_OPR(OPND_IDX(value_opnd)) == Null_Intrinsic_Opr) {
01541 value_desc.type_idx = ATD_TYPE_IDX(target_attr_idx);
01542 value_desc.type = TYP_TYPE(ATD_TYPE_IDX(target_attr_idx));
01543 value_desc.linear_type = TYP_LINEAR(ATD_TYPE_IDX(target_attr_idx));
01544 }
01545
01546 # ifdef _DEBUG
01547
01548 else {
01549 PRINTMSG(IR_LINE_NUM(rep_count_ir_idx), 626, Internal,
01550 IR_COL_NUM(rep_count_ir_idx),
01551 "CN_Tbl_Idx or AT_Tbl_Idx", "set_global_value_variables");
01552 }
01553
01554 # endif
01555
01556
01557 EXIT:
01558
01559 TRACE (Func_Exit, "set_global_value_variables", NULL);
01560
01561 return;
01562
01563 }
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587 static void section_semantics(int section_sub_ir_idx,
01588 opnd_type *stride_opnd,
01589 int *first_triplet_idx)
01590
01591 {
01592 long64 actual_stride;
01593 int attr_idx;
01594 int bd_idx;
01595 long64 dcl_lb;
01596 long64 dcl_ub;
01597 int end_il_idx;
01598 boolean error_found;
01599 expr_arg_type expr_desc;
01600 opnd_type expr_opnd;
01601 int i;
01602 int ignore_this_arg;
01603 int ignore_this_arg_too;
01604 int il_idx;
01605 int last_triplet_idx = NULL_IDX;
01606 long64 num_iterations;
01607 int start_il_idx;
01608 int stride_il_idx;
01609
01610
01611 TRACE(Func_Entry, "section_semantics", NULL);
01612
01613 obj_count = 1;
01614 *first_triplet_idx = NULL_IDX;
01615
01616
01617
01618 expr_desc = init_exp_desc;
01619 expr_desc.type = Integer;
01620 expr_desc.type_idx = INTEGER_DEFAULT_TYPE;
01621 expr_desc.linear_type = INTEGER_DEFAULT_TYPE;
01622
01623 il_idx = IR_IDX_R(section_sub_ir_idx);
01624
01625 for (lt_idx = 1; lt_idx <= IR_LIST_CNT_R(section_sub_ir_idx); ++lt_idx) {
01626 loop_tbl[lt_idx].sibling_idx = NULL_IDX;
01627
01628 if (IL_FLD(il_idx) == CN_Tbl_Idx) {
01629 loop_tbl[lt_idx].curr_value = CN_INT_TO_C(IL_IDX(il_idx));
01630 }
01631 else if (IL_FLD(il_idx) == IR_Tbl_Idx) {
01632
01633
01634
01635 if (IR_OPR(IL_IDX(il_idx)) != Triplet_Opr) {
01636 PRINTMSG(IL_LINE_NUM(il_idx), 704, Internal, IL_COL_NUM(il_idx));
01637 }
01638
01639 error_found = FALSE;
01640
01641
01642
01643
01644
01645
01646 attr_idx = find_base_attr(&IR_OPND_L(section_sub_ir_idx),
01647 &ignore_this_arg,
01648 &ignore_this_arg_too);
01649
01650 dcl_lb = CN_INT_TO_C(BD_LB_IDX(ATD_ARRAY_IDX(attr_idx), lt_idx));
01651 dcl_ub = CN_INT_TO_C(BD_UB_IDX(ATD_ARRAY_IDX(attr_idx), lt_idx));
01652
01653
01654
01655
01656 start_il_idx = IR_IDX_L(IL_IDX(il_idx));
01657
01658 if (IL_FLD(start_il_idx) == CN_Tbl_Idx) {
01659
01660 }
01661 else if (IL_FLD(start_il_idx) == IR_Tbl_Idx) {
01662 COPY_OPND(expr_opnd, IL_OPND(start_il_idx));
01663
01664 if (fold_aggragate_expression(&expr_opnd, &expr_desc, TRUE)) {
01665 COPY_OPND(IL_OPND(start_il_idx), expr_opnd);
01666 }
01667 else {
01668 PRINTMSG(IR_LINE_NUM(IL_IDX(start_il_idx)),
01669 861,
01670 Internal,
01671 IR_COL_NUM(IL_IDX(start_il_idx)),
01672 "section_semantics");
01673 }
01674 }
01675 else {
01676 PRINTMSG(IR_LINE_NUM(IL_IDX(start_il_idx)),
01677 704,
01678 Internal,
01679 IR_COL_NUM(IL_IDX(start_il_idx)));
01680 }
01681
01682 loop_tbl[lt_idx].start_value = CN_INT_TO_C(IL_IDX(start_il_idx));
01683 loop_tbl[lt_idx].curr_value = loop_tbl[lt_idx].start_value;
01684
01685
01686
01687
01688 end_il_idx = IL_NEXT_LIST_IDX(start_il_idx);
01689
01690 if (IL_FLD(end_il_idx) == CN_Tbl_Idx) {
01691
01692 }
01693 else if (IL_FLD(end_il_idx) == IR_Tbl_Idx) {
01694 COPY_OPND(expr_opnd, IL_OPND(end_il_idx));
01695
01696 if (fold_aggragate_expression(&expr_opnd, &expr_desc, TRUE)) {
01697 COPY_OPND(IL_OPND(end_il_idx), expr_opnd);
01698 }
01699 else {
01700 PRINTMSG(IR_LINE_NUM(IL_IDX(end_il_idx)),
01701 861,
01702 Internal,
01703 IR_COL_NUM(IL_IDX(end_il_idx)),
01704 "section_semantics");
01705 }
01706 }
01707 else {
01708 PRINTMSG(IR_LINE_NUM(IL_IDX(end_il_idx)),
01709 704,
01710 Internal,
01711 IR_COL_NUM(IL_IDX(end_il_idx)));
01712 }
01713
01714 loop_tbl[lt_idx].end_value = CN_INT_TO_C(IL_IDX(end_il_idx));
01715
01716
01717
01718
01719 stride_il_idx = IL_NEXT_LIST_IDX(end_il_idx);
01720
01721 if (IL_FLD(stride_il_idx) == CN_Tbl_Idx) {
01722
01723 }
01724 else if (IL_FLD(stride_il_idx) == IR_Tbl_Idx) {
01725 COPY_OPND(expr_opnd, IL_OPND(stride_il_idx));
01726
01727 if (fold_aggragate_expression(&expr_opnd, &expr_desc, TRUE)) {
01728 COPY_OPND(IL_OPND(stride_il_idx), expr_opnd);
01729 }
01730 else {
01731 PRINTMSG(IR_LINE_NUM(IL_IDX(stride_il_idx)),
01732 861,
01733 Internal,
01734 IR_COL_NUM(IL_IDX(stride_il_idx)),
01735 "section_semantics");
01736 }
01737 }
01738 else {
01739 PRINTMSG(IR_LINE_NUM(IL_IDX(stride_il_idx)),
01740 704,
01741 Internal,
01742 IR_COL_NUM(IL_IDX(stride_il_idx)));
01743 }
01744
01745 loop_tbl[lt_idx].inc_value = CN_INT_TO_C(IL_IDX(stride_il_idx));
01746
01747
01748
01749
01750 if (loop_tbl[lt_idx].inc_value > 0) {
01751
01752 if (loop_tbl[lt_idx].start_value < dcl_lb) {
01753
01754
01755
01756
01757 PRINTMSG(IL_LINE_NUM(start_il_idx),
01758 841,
01759 Error,
01760 IL_COL_NUM(start_il_idx));
01761 error_found = TRUE;
01762 }
01763
01764 if (loop_tbl[lt_idx].start_value > dcl_ub) {
01765
01766
01767
01768
01769 PRINTMSG(IL_LINE_NUM(start_il_idx),
01770 849,
01771 Error,
01772 IL_COL_NUM(start_il_idx));
01773 error_found = TRUE;
01774 }
01775
01776 num_iterations =
01777 (loop_tbl[lt_idx].end_value - loop_tbl[lt_idx].start_value +
01778 loop_tbl[lt_idx].inc_value) /
01779 loop_tbl[lt_idx].inc_value;
01780
01781 if (num_iterations > 0) {
01782 obj_count *= num_iterations;
01783
01784 if ((loop_tbl[lt_idx].start_value +
01785 (num_iterations - 1)*loop_tbl[lt_idx].inc_value) > dcl_ub) {
01786
01787
01788
01789
01790 PRINTMSG(IL_LINE_NUM(start_il_idx),
01791 905,
01792 Error,
01793 IL_COL_NUM(start_il_idx));
01794 error_found = TRUE;
01795 }
01796 }
01797 else {
01798 obj_count = 0;
01799 }
01800 }
01801 else if (loop_tbl[lt_idx].inc_value < 0) {
01802
01803 if (loop_tbl[lt_idx].start_value > dcl_ub) {
01804
01805
01806
01807
01808 PRINTMSG(IL_LINE_NUM(start_il_idx),
01809 849,
01810 Error,
01811 IL_COL_NUM(start_il_idx));
01812 error_found = TRUE;
01813 }
01814
01815 if (loop_tbl[lt_idx].start_value < dcl_lb) {
01816
01817
01818
01819
01820 PRINTMSG(IL_LINE_NUM(start_il_idx),
01821 841,
01822 Error,
01823 IL_COL_NUM(start_il_idx));
01824 error_found = TRUE;
01825 }
01826
01827 num_iterations =
01828 (loop_tbl[lt_idx].end_value - loop_tbl[lt_idx].start_value +
01829 loop_tbl[lt_idx].inc_value) /
01830 loop_tbl[lt_idx].inc_value;
01831
01832 if (num_iterations > 0) {
01833 obj_count *= num_iterations;
01834
01835 if ((loop_tbl[lt_idx].start_value +
01836 (num_iterations - 1)*loop_tbl[lt_idx].inc_value) < dcl_lb) {
01837
01838
01839
01840
01841 PRINTMSG(IL_LINE_NUM(start_il_idx),
01842 997,
01843 Error,
01844 IL_COL_NUM(start_il_idx));
01845 error_found = TRUE;
01846 }
01847 }
01848 else {
01849 obj_count = 0;
01850 }
01851 }
01852 else {
01853
01854
01855
01856 PRINTMSG(IL_LINE_NUM(stride_il_idx),
01857 998,
01858 Error,
01859 IL_COL_NUM(stride_il_idx));
01860 error_found = TRUE;
01861 }
01862
01863 if (! error_found) {
01864
01865
01866
01867
01868
01869
01870
01871
01872 if (*first_triplet_idx == NULL_IDX) {
01873 *first_triplet_idx = lt_idx;
01874 COPY_OPND(*stride_opnd, IL_OPND(stride_il_idx));
01875 OPND_FLD((*stride_opnd)) = NO_Tbl_Idx;
01876
01877 if (lt_idx != 1) {
01878 actual_stride = CN_INT_TO_C(IL_IDX(stride_il_idx));
01879 bd_idx = ATD_ARRAY_IDX(IR_IDX_L(section_sub_ir_idx));
01880
01881 for (i = 1; i < lt_idx; ++i) {
01882 actual_stride *= CN_INT_TO_C(BD_XT_IDX(bd_idx, i));
01883 }
01884
01885 OPND_IDX((*stride_opnd)) =C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
01886 actual_stride);
01887 }
01888 }
01889 else {
01890 loop_tbl[last_triplet_idx].sibling_idx = lt_idx;
01891 }
01892
01893 last_triplet_idx = lt_idx;
01894 }
01895 }
01896
01897 il_idx = IL_NEXT_LIST_IDX(il_idx);
01898
01899 }
01900
01901 TRACE(Func_Exit, "section_semantics", NULL);
01902
01903 return;
01904
01905 }
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943 static void gen_section_ref(int section_sub_ir_idx,
01944 long64 value_count,
01945 int first_triplet_idx,
01946 int root_ir_idx,
01947 int init_ir_idx,
01948 long64 *dup_count,
01949 long64 *section_start_value,
01950 long64 *section_inc_value)
01951
01952 {
01953 int i;
01954 int il_idx;
01955 int last_il_idx;
01956 long64 local_obj_count;
01957 int ir_idx;
01958 opnd_type opnd;
01959
01960
01961 TRACE(Func_Entry, "gen_section_ref", NULL);
01962
01963
01964
01965
01966
01967
01968 gen_opnd(&opnd, root_ir_idx, IR_Tbl_Idx, stmt_start_line, stmt_start_col);
01969 copy_subtree(&opnd, &opnd);
01970 ir_idx = OPND_IDX(opnd);
01971 IR_FLD_L(init_ir_idx) = IR_Tbl_Idx;
01972 IR_IDX_L(init_ir_idx) = ir_idx;
01973
01974 while (IR_OPR(ir_idx) != Section_Subscript_Opr) {
01975 ir_idx = IR_IDX_L(ir_idx);
01976 }
01977
01978 IR_OPR(ir_idx) = Subscript_Opr;
01979 IR_RANK(ir_idx) = 1;
01980
01981 NTR_IR_LIST_TBL(il_idx);
01982 IR_FLD_R(ir_idx) = IL_Tbl_Idx;
01983 IR_IDX_R(ir_idx) = il_idx;
01984 IL_FLD(il_idx) = CN_Tbl_Idx;
01985 IL_IDX(il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
01986 loop_tbl[1].curr_value);
01987 IL_LINE_NUM(il_idx) = stmt_start_line;
01988 IL_COL_NUM(il_idx) = stmt_start_col;
01989
01990 last_il_idx = il_idx;
01991
01992 for (i = 2; i <= IR_LIST_CNT_R(section_sub_ir_idx); ++i) {
01993 NTR_IR_LIST_TBL(il_idx);
01994 IL_NEXT_LIST_IDX(last_il_idx) = il_idx;
01995 IL_PREV_LIST_IDX(il_idx) = last_il_idx;
01996 last_il_idx = il_idx;
01997 IL_FLD(il_idx) = CN_Tbl_Idx;
01998 IL_IDX(il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
01999 loop_tbl[i].curr_value);
02000 IL_LINE_NUM(il_idx) = stmt_start_line;
02001 IL_COL_NUM(il_idx) = stmt_start_col;
02002 }
02003
02004
02005
02006
02007
02008 *section_start_value = loop_tbl[first_triplet_idx].curr_value;
02009 *section_inc_value = loop_tbl[first_triplet_idx].inc_value;
02010
02011
02012
02013
02014
02015 local_obj_count = (loop_tbl[first_triplet_idx].end_value -
02016 loop_tbl[first_triplet_idx].curr_value +
02017 loop_tbl[first_triplet_idx].inc_value) /
02018 loop_tbl[first_triplet_idx].inc_value;
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028 if (local_obj_count <= value_count) {
02029 *dup_count = local_obj_count;
02030
02031 if (obj_count != local_obj_count) {
02032 loop_tbl[first_triplet_idx].curr_value =
02033 loop_tbl[first_triplet_idx].start_value;
02034 lt_idx = loop_tbl[first_triplet_idx].sibling_idx;
02035
02036 while (lt_idx != NULL_IDX) {
02037 loop_tbl[lt_idx].curr_value += loop_tbl[lt_idx].inc_value;
02038
02039 if ((loop_tbl[lt_idx].inc_value > 0 &&
02040 loop_tbl[lt_idx].curr_value <= loop_tbl[lt_idx].end_value) ||
02041 (loop_tbl[lt_idx].inc_value < 0 &&
02042 loop_tbl[lt_idx].curr_value >= loop_tbl[lt_idx].end_value)) {
02043 break;
02044 }
02045
02046 loop_tbl[lt_idx].curr_value = loop_tbl[lt_idx].start_value;
02047 lt_idx = loop_tbl[lt_idx].sibling_idx;
02048 }
02049
02050 }
02051 }
02052 else {
02053 *dup_count = value_count;
02054 loop_tbl[first_triplet_idx].curr_value +=
02055 value_count * loop_tbl[first_triplet_idx].inc_value;
02056 }
02057
02058 TRACE(Func_Exit, "gen_section_ref", NULL);
02059
02060 return;
02061
02062 }
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085 static void vv_subscript_semantics(int init_ir_idx,
02086 int array_ir_idx,
02087 expr_arg_type *obj_desc)
02088 {
02089 int do_var_il_idx;
02090 int end_il_idx;
02091 int i;
02092 int il_idx;
02093 int imp_do_ir_idx;
02094 int inc_il_idx;
02095 expr_arg_type shape_desc;
02096 int shape_idx;
02097 opnd_type shape_opnd;
02098 int start_il_idx;
02099 int subscript_il_idx;
02100 int tmp_idx;
02101 #ifdef KEY
02102 int triplet_ir_idx = 0;
02103 #else
02104 int triplet_ir_idx;
02105 #endif
02106
02107
02108 TRACE (Func_Entry, "vv_subscript_semantics", NULL);
02109
02110
02111
02112
02113
02114 shape_idx = -1;
02115 subscript_il_idx = IR_IDX_R(array_ir_idx);
02116
02117 for (i = 1; i <= IR_LIST_CNT_R(array_ir_idx); ++i) {
02118
02119 switch (IL_FLD(subscript_il_idx)) {
02120
02121 case CN_Tbl_Idx:
02122 break;
02123
02124 case IR_Tbl_Idx:
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137 ++shape_idx;
02138
02139 NTR_IR_TBL(imp_do_ir_idx);
02140 IR_OPR(imp_do_ir_idx) = Implied_Do_Opr;
02141 IR_TYPE_IDX(imp_do_ir_idx) = TYPELESS_DEFAULT_TYPE;
02142 IR_LINE_NUM(imp_do_ir_idx) = IR_LINE_NUM(init_ir_idx);
02143 IR_COL_NUM(imp_do_ir_idx) = IR_COL_NUM(init_ir_idx);
02144
02145 NTR_IR_LIST_TBL(il_idx);
02146 IR_LIST_CNT_L(imp_do_ir_idx) = 1;
02147 IR_FLD_L(imp_do_ir_idx) = IL_Tbl_Idx;
02148 IR_IDX_L(imp_do_ir_idx) = il_idx;
02149
02150 COPY_OPND(IL_OPND(il_idx), IR_OPND_L(init_ir_idx));
02151
02152 IR_IDX_L(init_ir_idx) = imp_do_ir_idx;
02153
02154
02155
02156
02157 if (IR_OPR(IL_IDX(subscript_il_idx)) == Triplet_Opr) {
02158 triplet_ir_idx = IL_IDX(subscript_il_idx);
02159 }
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171 tmp_idx = gen_compiler_tmp(IR_LINE_NUM(imp_do_ir_idx),
02172 IR_COL_NUM(imp_do_ir_idx),
02173 Priv, TRUE);
02174 AT_SEMANTICS_DONE(tmp_idx) = TRUE;
02175 ATD_TYPE_IDX(tmp_idx) = INTEGER_DEFAULT_TYPE;
02176 ATD_STOR_BLK_IDX(tmp_idx) = SCP_SB_STACK_IDX(curr_scp_idx);
02177 ATD_LCV_IS_CONST(tmp_idx) = TRUE;
02178
02179
02180
02181
02182 AT_REFERENCED(tmp_idx) = Not_Referenced;
02183
02184 NTR_IR_LIST_TBL(do_var_il_idx);
02185 IL_LINE_NUM(do_var_il_idx) = IR_LINE_NUM(imp_do_ir_idx);
02186 IL_COL_NUM(do_var_il_idx) = IR_COL_NUM(imp_do_ir_idx);
02187 IL_FLD(do_var_il_idx) = AT_Tbl_Idx;
02188 IL_IDX(do_var_il_idx) = tmp_idx;
02189
02190 if (IL_VECTOR_SUBSCRIPT(subscript_il_idx)) {
02191 NTR_IR_LIST_TBL(start_il_idx);
02192 IL_NEXT_LIST_IDX(do_var_il_idx) = start_il_idx;
02193 IL_PREV_LIST_IDX(start_il_idx) = do_var_il_idx;
02194 IL_LINE_NUM(start_il_idx) = IR_LINE_NUM(init_ir_idx);
02195 IL_COL_NUM(start_il_idx) = IR_COL_NUM(init_ir_idx);
02196 IL_FLD(start_il_idx) = CN_Tbl_Idx;
02197 IL_IDX(start_il_idx) = CN_INTEGER_ONE_IDX;
02198
02199 NTR_IR_LIST_TBL(end_il_idx);
02200 IL_NEXT_LIST_IDX(start_il_idx) = end_il_idx;
02201 IL_PREV_LIST_IDX(end_il_idx) = start_il_idx;
02202
02203 if (obj_desc->shape[shape_idx].fld != CN_Tbl_Idx) {
02204 COPY_OPND(shape_opnd, obj_desc->shape[shape_idx]);
02205
02206 shape_desc = init_exp_desc;
02207 shape_desc.type = Integer;
02208 shape_desc.type_idx = INTEGER_DEFAULT_TYPE;
02209 shape_desc.linear_type = INTEGER_DEFAULT_TYPE;
02210
02211 if (fold_aggragate_expression(&shape_opnd,
02212 &shape_desc,
02213 TRUE)) {
02214 COPY_OPND(IL_OPND(end_il_idx), shape_opnd);
02215 }
02216 else {
02217 PRINTMSG(obj_desc->shape[shape_idx].line_num,
02218 861,
02219 Internal,
02220 obj_desc->shape[shape_idx].col_num,
02221 "vv_subscript_semantics");
02222 }
02223 }
02224 else {
02225 IL_LINE_NUM(end_il_idx) = IR_LINE_NUM(init_ir_idx);
02226 IL_COL_NUM(end_il_idx) = IR_COL_NUM(init_ir_idx);
02227 IL_FLD(end_il_idx) = CN_Tbl_Idx;
02228 IL_IDX(end_il_idx) = obj_desc->shape[shape_idx].idx;
02229 }
02230
02231 NTR_IR_LIST_TBL(inc_il_idx);
02232 IL_NEXT_LIST_IDX(end_il_idx) = inc_il_idx;
02233 IL_PREV_LIST_IDX(inc_il_idx) = end_il_idx;
02234 IL_LINE_NUM(inc_il_idx) = IR_LINE_NUM(init_ir_idx);
02235 IL_COL_NUM(inc_il_idx) = IR_COL_NUM(init_ir_idx);
02236 IL_FLD(inc_il_idx) = CN_Tbl_Idx;
02237 IL_IDX(inc_il_idx) = CN_INTEGER_ONE_IDX;
02238
02239
02240
02241
02242
02243 NTR_IR_LIST_TBL(il_idx);
02244 IL_NEXT_LIST_IDX(inc_il_idx) = il_idx;
02245 IL_PREV_LIST_IDX(il_idx) = inc_il_idx;
02246 COPY_OPND(IL_OPND(il_idx), IL_OPND(subscript_il_idx));
02247
02248 IR_LIST_CNT_R(imp_do_ir_idx) = 5;
02249 }
02250 else {
02251 IL_NEXT_LIST_IDX(do_var_il_idx) = IR_IDX_L(triplet_ir_idx);
02252 IR_LIST_CNT_R(imp_do_ir_idx) = 4;
02253 }
02254
02255 IR_FLD_R(imp_do_ir_idx) = IL_Tbl_Idx;
02256 IR_IDX_R(imp_do_ir_idx) = do_var_il_idx;
02257
02258 IL_FLD(subscript_il_idx) = AT_Tbl_Idx;
02259 IL_IDX(subscript_il_idx) = tmp_idx;
02260 IL_LINE_NUM(subscript_il_idx) = IR_LINE_NUM(init_ir_idx);
02261 IL_COL_NUM(subscript_il_idx) = IR_COL_NUM(init_ir_idx);
02262
02263 break;
02264
02265 default:
02266 PRINTMSG(IR_LINE_NUM(init_ir_idx), 179, Internal,
02267 IR_COL_NUM(init_ir_idx), "vv_section_semantics");
02268 }
02269
02270 subscript_il_idx = IL_NEXT_LIST_IDX(subscript_il_idx);
02271 }
02272
02273 TRACE (Func_Exit, "vv_subscript_semantics", NULL);
02274
02275 return;
02276
02277 }
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305 static boolean optimize_whole_array_init(int init_ir_idx)
02306 {
02307 int attr_idx;
02308 int i;
02309 opnd_type ignore_this_opnd;
02310 int ir_idx;
02311 expr_arg_type loc_exp_desc;
02312 opnd_type opnd;
02313 boolean optimized = TRUE;
02314 opnd_type rep_factor_opnd;
02315 boolean save_insert_subs_ok;
02316 opnd_type save_left_opnd;
02317 long64 save_rep_factor;
02318 opnd_type save_right_opnd;
02319 expr_arg_type save_value_desc;
02320 int save_value_il_idx;
02321 opnd_type save_value_opnd;
02322
02323
02324 TRACE(Func_Entry, "optimize_whole_array_init", NULL);
02325
02326 if (value_il_idx == NULL_IDX) {
02327 optimized = FALSE;
02328 goto EXIT;
02329 }
02330
02331 COPY_OPND(save_left_opnd, IR_OPND_L(init_ir_idx));
02332 COPY_OPND(save_right_opnd, IR_OPND_R(init_ir_idx));
02333 COPY_OPND(save_value_opnd, value_opnd);
02334 save_value_il_idx = value_il_idx;
02335 save_value_desc = value_desc;
02336 save_rep_factor = rep_factor;
02337
02338 IR_LIST_CNT_R(init_ir_idx) = 0;
02339
02340 if (IR_FLD_R(init_ir_idx) == NO_Tbl_Idx) {
02341 IR_FLD_R(init_ir_idx) = IL_Tbl_Idx;
02342 IR_IDX_R(init_ir_idx) = value_il_idx;
02343 }
02344
02345 COPY_OPND(opnd, IR_OPND_L(init_ir_idx));
02346
02347 while (OPND_FLD(opnd) == IR_Tbl_Idx) {
02348
02349 if (IR_OPR(OPND_IDX(opnd)) == Substring_Opr ||
02350 IR_OPR(OPND_IDX(opnd)) == Whole_Substring_Opr) {
02351 break;
02352 }
02353
02354 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
02355 }
02356
02357 attr_idx = IR_IDX_L(IR_IDX_L(init_ir_idx));
02358
02359 for (i = 1; i <= obj_count; ++i) {
02360
02361
02362
02363
02364
02365
02366 if (IL_FLD(value_il_idx) == IR_Tbl_Idx) {
02367 optimized = FALSE;
02368 COPY_OPND(IR_OPND_L(init_ir_idx), save_left_opnd);
02369 COPY_OPND(IR_OPND_R(init_ir_idx), save_right_opnd);
02370 COPY_OPND(value_opnd, save_value_opnd);
02371 value_il_idx = save_value_il_idx;
02372 value_desc = save_value_desc;
02373 rep_factor = save_rep_factor;
02374 goto EXIT;
02375 }
02376
02377 if (check_target_and_value(attr_idx, init_ir_idx)) {
02378 --rep_factor;
02379
02380 if (rep_factor == 0) {
02381 ++IR_LIST_CNT_R(init_ir_idx);
02382 value_il_idx = IL_NEXT_LIST_IDX(value_il_idx);
02383
02384 if (value_il_idx == NULL_IDX) {
02385 break;
02386 }
02387 else {
02388 set_global_value_variables(&rep_factor_opnd,
02389 &ignore_this_opnd,
02390 attr_idx);
02391
02392 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
02393 goto EXIT;
02394 }
02395 }
02396 }
02397 }
02398 else {
02399 goto EXIT;
02400 }
02401 }
02402
02403 if (value_il_idx != NULL_IDX) {
02404 IL_NEXT_LIST_IDX(IL_PREV_LIST_IDX(value_il_idx)) = NULL_IDX;
02405 IL_PREV_LIST_IDX(value_il_idx) = NULL_IDX;
02406 }
02407
02408
02409
02410
02411
02412
02413
02414 if (IR_LIST_CNT_R(init_ir_idx) < obj_count) {
02415
02416 if (IL_NEXT_LIST_IDX(obj_il_idx) == NULL_IDX) {
02417 PRINTMSG(IR_LINE_NUM_L(init_ir_idx), 698, Ansi,
02418 IR_COL_NUM_L(init_ir_idx));
02419 }
02420 else {
02421 PRINTMSG(IR_LINE_NUM_L(init_ir_idx), 667, Error,
02422 IR_COL_NUM_L(init_ir_idx));
02423 optimized = FALSE;
02424 obj_il_idx = NULL_IDX;
02425 goto EXIT;
02426 }
02427 }
02428
02429
02430
02431
02432
02433
02434 OPND_FLD(init_target_opnd) = AT_Tbl_Idx;
02435 OPND_IDX(init_target_opnd) = attr_idx;
02436 OPND_LINE_NUM(init_target_opnd) = stmt_start_line;
02437 OPND_COL_NUM(init_target_opnd) = stmt_start_col;
02438
02439 target_array_idx = ATD_ARRAY_IDX(attr_idx);
02440 target_type_idx = ATD_TYPE_IDX(attr_idx);
02441 check_type_conversion = TRUE;
02442 save_insert_subs_ok = insert_subs_ok;
02443 insert_subs_ok = FALSE;
02444
02445 NTR_IR_TBL(ir_idx);
02446 IR_OPR(ir_idx) = Constant_Array_Construct_Opr;
02447 IR_LINE_NUM(ir_idx) = stmt_start_line;
02448 IR_COL_NUM(ir_idx) = stmt_start_col;
02449 IR_TYPE_IDX(ir_idx) = target_type_idx;
02450
02451 COPY_OPND(IR_OPND_R(ir_idx), IR_OPND_R(init_ir_idx));
02452
02453 OPND_IDX(opnd) = ir_idx;
02454 OPND_FLD(opnd) = IR_Tbl_Idx;
02455
02456 loc_exp_desc = init_exp_desc;
02457 loc_exp_desc.type_idx = target_type_idx;
02458 loc_exp_desc.type = TYP_TYPE(target_type_idx);
02459 loc_exp_desc.linear_type = TYP_LINEAR(target_type_idx);
02460 loc_exp_desc.rank = 1;
02461
02462 if (IR_LIST_CNT_R(init_ir_idx) == obj_count) {
02463 loc_exp_desc.shape[0].fld = BD_XT_FLD(target_array_idx, 1);
02464 loc_exp_desc.shape[0].idx = BD_XT_IDX(target_array_idx, 1);
02465 }
02466 else {
02467 loc_exp_desc.shape[0].fld = CN_Tbl_Idx;
02468 loc_exp_desc.shape[0].idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
02469 IR_LIST_CNT_R(init_ir_idx));
02470 }
02471
02472 loc_exp_desc.constructor_size_level = Simple_Expr_Size;
02473
02474 create_constructor_constant(&opnd, &loc_exp_desc);
02475
02476 init_target_opnd = null_opnd;
02477 target_array_idx = NULL_IDX;
02478 insert_subs_ok = save_insert_subs_ok;
02479
02480 remove_sh(curr_stmt_sh_idx);
02481 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
02482
02483 obj_count = 0;
02484
02485 EXIT:
02486
02487 TRACE(Func_Exit, "optimize_whole_array_init", NULL);
02488
02489 return(optimized);
02490
02491 }
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514 static void data_imp_do_semantics(int init_ir_idx,
02515 int imp_do_idx,
02516 boolean compiler_gen_imp_do,
02517 boolean *metamorphed)
02518
02519 {
02520 int il_idx;
02521 int local_rep_count_ir_idx;
02522 long64 local_rep_factor;
02523 int local_value_il_idx;
02524 int rep_count_ir_idx;
02525 boolean save_runtime_bounds;
02526
02527
02528 TRACE (Func_Entry, "data_imp_do_semantics", NULL);
02529 save_runtime_bounds = cdir_switches.bounds;
02530 cdir_switches.bounds = TRUE;
02531
02532 *metamorphed = FALSE;
02533
02534
02535
02536
02537
02538
02539
02540
02541 arg_info_list_base = arg_info_list_top;
02542
02543
02544
02545
02546 last_lt_idx = NULL_IDX;
02547 curr_parent_idx = NULL_IDX;
02548
02549 build_loop_tbl(imp_do_idx, compiler_gen_imp_do);
02550
02551 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
02552 goto EXIT;
02553 }
02554
02555
02556
02557
02558
02559
02560
02561 if (IL_NEXT_LIST_IDX(obj_il_idx) == NULL_IDX) {
02562
02563 if (imp_do_metamorphed(init_ir_idx)) {
02564 *metamorphed = TRUE;
02565 goto EXIT;
02566 }
02567 }
02568
02569
02570
02571
02572
02573
02574
02575 if (IL_FLD(value_il_idx) == IR_Tbl_Idx &&
02576 rep_factor != CN_INT_TO_C(IR_IDX_L(IL_IDX(value_il_idx)))) {
02577
02578 IR_IDX_L(IL_IDX(value_il_idx)) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
02579 rep_factor);
02580 }
02581
02582
02583
02584
02585
02586
02587
02588 IR_LIST_CNT_R(init_ir_idx) = 1;
02589 IR_FLD_R(init_ir_idx) = IL_Tbl_Idx;
02590 IR_IDX_R(init_ir_idx) = value_il_idx;
02591
02592 lt_idx = 1;
02593
02594 interpret_data_imp_do(init_ir_idx);
02595
02596 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
02597 goto EXIT;
02598 }
02599
02600 if (rep_factor == 0) {
02601
02602
02603
02604 if (value_il_idx != NULL_IDX) {
02605 IL_NEXT_LIST_IDX(IL_PREV_LIST_IDX(value_il_idx)) = NULL_IDX;
02606 }
02607 }
02608 else if (IL_FLD(value_il_idx) == IR_Tbl_Idx) {
02609
02610
02611
02612
02613
02614
02615
02616
02617
02618
02619 rep_count_ir_idx = IL_IDX(value_il_idx);
02620
02621 local_rep_factor = CN_INT_TO_C(IR_IDX_L(rep_count_ir_idx)) - rep_factor;
02622
02623 local_value_il_idx = IL_PREV_LIST_IDX(value_il_idx);
02624
02625 NTR_IR_LIST_TBL(il_idx);
02626
02627 if (IR_LIST_CNT_R(init_ir_idx) == 1) {
02628 IR_IDX_R(init_ir_idx) = il_idx;
02629 }
02630 else {
02631 IL_NEXT_LIST_IDX(local_value_il_idx) = il_idx;
02632 IL_PREV_LIST_IDX(il_idx) = local_value_il_idx;
02633 }
02634
02635 local_value_il_idx = il_idx;
02636
02637 if (local_rep_factor > 1) {
02638 NTR_IR_TBL(local_rep_count_ir_idx);
02639 IR_TYPE_IDX(local_rep_count_ir_idx) = TYPELESS_DEFAULT_TYPE;
02640 IL_FLD(local_value_il_idx) = IR_Tbl_Idx;
02641 IL_IDX(local_value_il_idx) = local_rep_count_ir_idx;
02642 COPY_TBL_NTRY(ir_tbl, local_rep_count_ir_idx, rep_count_ir_idx);
02643
02644 IR_IDX_L(local_rep_count_ir_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
02645 local_rep_factor);
02646 COPY_OPND(IR_OPND_R(local_rep_count_ir_idx), value_opnd);
02647 }
02648 else {
02649 COPY_OPND(IL_OPND(local_value_il_idx), value_opnd);
02650 }
02651
02652
02653
02654
02655
02656
02657 if (rep_factor == 1) {
02658 COPY_OPND(IL_OPND(value_il_idx), IR_OPND_R(rep_count_ir_idx));
02659 }
02660 else {
02661 IR_IDX_L(rep_count_ir_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
02662 rep_factor);
02663 }
02664 }
02665
02666 EXIT:
02667
02668 cdir_switches.bounds = save_runtime_bounds;
02669
02670 TRACE (Func_Exit, "data_imp_do_semantics", NULL);
02671
02672 return;
02673
02674 }
02675
02676
02677
02678
02679
02680
02681
02682
02683
02684
02685
02686
02687
02688
02689
02690
02691
02692
02693
02694
02695
02696
02697
02698 static void build_loop_tbl(int imp_do_idx,
02699 boolean compiler_gen_imp_do)
02700
02701 {
02702 int attr_idx;
02703 int column;
02704 int do_var_tmp_idx;
02705 expr_arg_type expr_desc;
02706 int il_idx;
02707 int lcv_col;
02708 int lcv_line;
02709 int line;
02710 opnd_type opnd;
02711 #ifdef KEY
02712 boolean save_in_implied_do = FALSE;
02713 boolean save_imp_do_lcv = FALSE;
02714 int search_idx;
02715 boolean semantics_ok = FALSE;
02716 #else
02717 boolean save_in_implied_do;
02718 boolean save_imp_do_lcv;
02719 int search_idx;
02720 boolean semantics_ok;
02721 #endif
02722 int target_idx;
02723 int temp_ir_idx;
02724
02725
02726 TRACE (Func_Entry, "build_loop_tbl", NULL);
02727
02728 if (++last_lt_idx > LOOP_TBL_SIZE) {
02729 PRINTMSG(IR_LINE_NUM(imp_do_idx), 237, Internal, IR_COL_NUM(imp_do_idx),
02730 "DATA implied-DO loop_tbl");
02731 }
02732
02733 lt_idx = last_lt_idx;
02734
02735
02736
02737
02738
02739
02740
02741
02742
02743
02744
02745
02746
02747
02748
02749
02750
02751
02752
02753
02754
02755
02756
02757
02758
02759
02760
02761
02762
02763
02764
02765
02766 loop_tbl[lt_idx].num_targets = 0;
02767 loop_tbl[lt_idx].sibling_idx = NULL_IDX;
02768 loop_tbl[lt_idx].offspring_idx = NULL_IDX;
02769 loop_tbl[lt_idx].target_list = NULL_IDX;
02770 loop_tbl[lt_idx].curr_value = NULL_IDX;
02771
02772 if (curr_parent_idx == NULL_IDX) {
02773 loop_tbl[lt_idx].parent_idx = NULL_IDX;
02774 }
02775 else {
02776 loop_tbl[lt_idx].parent_idx = curr_parent_idx;
02777
02778 if (loop_tbl[curr_parent_idx].offspring_idx == NULL_IDX) {
02779 loop_tbl[curr_parent_idx].offspring_idx = lt_idx;
02780 }
02781 else {
02782 loop_tbl[loop_tbl[curr_parent_idx].curr_value].sibling_idx = lt_idx;
02783 }
02784
02785 loop_tbl[curr_parent_idx].curr_value = lt_idx;
02786 }
02787
02788 attr_idx = NULL_IDX;
02789
02790
02791
02792
02793
02794
02795
02796
02797
02798
02799
02800
02801 il_idx = IL_NEXT_LIST_IDX(IR_IDX_R(imp_do_idx));
02802
02803 if (compiler_gen_imp_do) {
02804 loop_tbl[lt_idx].start_value = CN_INT_TO_C(IL_IDX(il_idx));
02805 }
02806 else {
02807 COPY_OPND(opnd, IL_OPND(il_idx));
02808 expr_mode = Restricted_Imp_Do_Expr;
02809 expr_desc.rank = 0;
02810 xref_state = CIF_Symbol_Reference;
02811
02812 if (! expr_sem(&opnd, &expr_desc)) {
02813
02814
02815
02816
02817 SH_ERR_FLG(curr_stmt_sh_idx) = TRUE;
02818 goto EXIT;
02819 }
02820
02821 if (expr_desc.linear_type == Short_Typeless_Const) {
02822 OPND_IDX(opnd) = cast_typeless_constant(OPND_IDX(opnd),
02823 INTEGER_DEFAULT_TYPE,
02824 OPND_LINE_NUM(opnd),
02825 OPND_COL_NUM(opnd));
02826 expr_desc.type_idx = INTEGER_DEFAULT_TYPE;
02827 expr_desc.type = Integer;
02828 expr_desc.linear_type = INTEGER_DEFAULT_TYPE;
02829 }
02830
02831
02832 if (expr_desc.rank == 0 &&
02833 expr_desc.type == Integer) {
02834 COPY_OPND(IL_OPND(il_idx), opnd);
02835 loop_tbl[lt_idx].start_fld = IL_FLD(il_idx);
02836 loop_tbl[lt_idx].start_idx = IL_IDX(il_idx);
02837
02838 switch (loop_tbl[lt_idx].start_fld) {
02839
02840 case CN_Tbl_Idx:
02841 loop_tbl[lt_idx].start_value = CN_INT_TO_C(IL_IDX(il_idx));
02842 break;
02843
02844 case AT_Tbl_Idx:
02845 search_idx = loop_tbl[lt_idx].parent_idx;
02846
02847 while (search_idx != NULL_IDX) {
02848
02849 if (loop_tbl[search_idx].lcv_idx == IL_IDX(il_idx)) {
02850 loop_tbl[lt_idx].start_idx = search_idx;
02851 break;
02852 }
02853 else {
02854 search_idx = loop_tbl[search_idx].parent_idx;
02855 }
02856
02857 }
02858
02859 if (search_idx == NULL_IDX) {
02860 PRINTMSG(IL_LINE_NUM(il_idx), 658, Error, IL_COL_NUM(il_idx),
02861 AT_OBJ_NAME_PTR(IL_IDX(il_idx)));
02862 goto EXIT;
02863 }
02864
02865 break;
02866
02867 case IR_Tbl_Idx:
02868 if (good_data_imp_do_expr(loop_tbl[lt_idx].start_idx)) {
02869 arg_info_list_top = arg_info_list_base + 1;
02870
02871 loop_tbl[lt_idx].start_expr_desc_idx = arg_info_list_top;
02872
02873 if (arg_info_list_top > arg_info_list_size) {
02874 enlarge_info_list_table();
02875 }
02876
02877 arg_info_list[arg_info_list_top] = init_arg_info;
02878 arg_info_list[arg_info_list_top].ed = expr_desc;
02879 }
02880
02881 break;
02882
02883 default:
02884 PRINTMSG(IR_LINE_NUM(imp_do_idx), 179, Internal,
02885 IR_COL_NUM(imp_do_idx), "build_loop_tbl");
02886 }
02887 }
02888 else {
02889 PRINTMSG(IL_LINE_NUM(il_idx), 936, Error, IL_COL_NUM(il_idx));
02890 }
02891 }
02892
02893
02894
02895
02896
02897 il_idx = IL_NEXT_LIST_IDX(il_idx);
02898
02899 if (compiler_gen_imp_do) {
02900 loop_tbl[lt_idx].end_value = CN_INT_TO_C(IL_IDX(il_idx));
02901 }
02902 else {
02903 COPY_OPND(opnd, IL_OPND(il_idx));
02904 expr_desc.rank = 0;
02905 xref_state = CIF_Symbol_Reference;
02906
02907 if (! expr_sem(&opnd, &expr_desc)) {
02908 SH_ERR_FLG(curr_stmt_sh_idx) = TRUE;
02909 goto EXIT;
02910 }
02911
02912 if (expr_desc.linear_type == Short_Typeless_Const) {
02913 OPND_IDX(opnd) = cast_typeless_constant(OPND_IDX(opnd),
02914 INTEGER_DEFAULT_TYPE,
02915 OPND_LINE_NUM(opnd),
02916 OPND_COL_NUM(opnd));
02917 expr_desc.type_idx = INTEGER_DEFAULT_TYPE;
02918 expr_desc.type = Integer;
02919 expr_desc.linear_type = INTEGER_DEFAULT_TYPE;
02920 }
02921
02922 if (expr_desc.rank == 0 &&
02923 expr_desc.type == Integer) {
02924
02925 COPY_OPND(IL_OPND(il_idx), opnd);
02926 loop_tbl[lt_idx].end_fld = IL_FLD(il_idx);
02927 loop_tbl[lt_idx].end_idx = IL_IDX(il_idx);
02928
02929 switch (loop_tbl[lt_idx].end_fld) {
02930
02931 case CN_Tbl_Idx:
02932 loop_tbl[lt_idx].end_value = CN_INT_TO_C(IL_IDX(il_idx));
02933 break;
02934
02935 case AT_Tbl_Idx:
02936 search_idx = loop_tbl[lt_idx].parent_idx;
02937
02938 while (search_idx != NULL_IDX) {
02939
02940 if (loop_tbl[search_idx].lcv_idx == IL_IDX(il_idx)) {
02941 loop_tbl[lt_idx].end_idx = search_idx;
02942 break;
02943 }
02944 else {
02945 search_idx = loop_tbl[search_idx].parent_idx;
02946 }
02947
02948 }
02949
02950 if (search_idx == NULL_IDX) {
02951 PRINTMSG(IL_LINE_NUM(il_idx), 658, Error, IL_COL_NUM(il_idx),
02952 AT_OBJ_NAME_PTR(IL_IDX(il_idx)));
02953 goto EXIT;
02954 }
02955
02956 break;
02957
02958 case IR_Tbl_Idx:
02959 if (good_data_imp_do_expr(loop_tbl[lt_idx].end_idx)) {
02960 arg_info_list_top = arg_info_list_base + 1;
02961
02962 loop_tbl[lt_idx].end_expr_desc_idx = arg_info_list_top;
02963
02964 if (arg_info_list_top > arg_info_list_size) {
02965 enlarge_info_list_table();
02966 }
02967
02968 arg_info_list[arg_info_list_top] = init_arg_info;
02969 arg_info_list[arg_info_list_top].ed = expr_desc;
02970 }
02971
02972 break;
02973
02974 default:
02975 PRINTMSG(IR_LINE_NUM(imp_do_idx), 179, Internal,
02976 IR_COL_NUM(imp_do_idx), "build_loop_tbl");
02977 }
02978 }
02979 else {
02980 PRINTMSG(IL_LINE_NUM(il_idx), 936, Error, IL_COL_NUM(il_idx));
02981 }
02982 }
02983
02984
02985
02986
02987
02988
02989 if (IL_NEXT_LIST_IDX(il_idx) == NULL_IDX) {
02990 loop_tbl[lt_idx].inc_fld = CN_Tbl_Idx;
02991 loop_tbl[lt_idx].inc_idx = CN_INTEGER_ONE_IDX;
02992 loop_tbl[lt_idx].inc_value = CN_INT_TO_C(CN_INTEGER_ONE_IDX);
02993
02994 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(il_idx));
02995 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(il_idx)) = il_idx;
02996 il_idx = IL_NEXT_LIST_IDX(il_idx);
02997 IL_LINE_NUM(il_idx) = IL_LINE_NUM(IL_PREV_LIST_IDX(il_idx));
02998 IL_COL_NUM(il_idx) = IL_COL_NUM(IL_PREV_LIST_IDX(il_idx));
02999 IL_FLD(il_idx) = CN_Tbl_Idx;
03000 IL_IDX(il_idx) = CN_INTEGER_ONE_IDX;
03001 ++IR_LIST_CNT_R(imp_do_idx);
03002 }
03003 else if (compiler_gen_imp_do) {
03004 il_idx = IL_NEXT_LIST_IDX(il_idx);
03005 loop_tbl[lt_idx].inc_value = CN_INT_TO_C(IL_IDX(il_idx));
03006 }
03007 else {
03008 il_idx = IL_NEXT_LIST_IDX(il_idx);
03009 COPY_OPND(opnd, IL_OPND(il_idx));
03010 expr_desc.rank = 0;
03011 xref_state = CIF_Symbol_Reference;
03012
03013 if (! expr_sem(&opnd, &expr_desc)) {
03014 SH_ERR_FLG(curr_stmt_sh_idx) = TRUE;
03015 goto EXIT;
03016 }
03017
03018 if (expr_desc.linear_type == Short_Typeless_Const) {
03019 OPND_IDX(opnd) = cast_typeless_constant(OPND_IDX(opnd),
03020 INTEGER_DEFAULT_TYPE,
03021 OPND_LINE_NUM(opnd),
03022 OPND_COL_NUM(opnd));
03023 expr_desc.type_idx = INTEGER_DEFAULT_TYPE;
03024 expr_desc.type = Integer;
03025 expr_desc.linear_type = INTEGER_DEFAULT_TYPE;
03026 }
03027
03028 if (expr_desc.rank == 0 &&
03029 expr_desc.type == Integer) {
03030
03031 COPY_OPND(IL_OPND(il_idx), opnd);
03032 loop_tbl[lt_idx].inc_fld = IL_FLD(il_idx);
03033 loop_tbl[lt_idx].inc_idx = IL_IDX(il_idx);
03034
03035 switch (loop_tbl[lt_idx].inc_fld) {
03036
03037 case CN_Tbl_Idx:
03038 if (fold_relationals(IL_IDX(il_idx),
03039 CN_INTEGER_ZERO_IDX,
03040 Eq_Opr)) {
03041 PRINTMSG(IL_LINE_NUM(il_idx), 1084, Error,
03042 IL_COL_NUM(il_idx));
03043 }
03044 else {
03045 loop_tbl[lt_idx].inc_value = CN_INT_TO_C(IL_IDX(il_idx));
03046 }
03047
03048 break;
03049
03050 case AT_Tbl_Idx:
03051 search_idx = loop_tbl[lt_idx].parent_idx;
03052
03053 while (search_idx != NULL_IDX) {
03054
03055 if (loop_tbl[search_idx].lcv_idx == IL_IDX(il_idx)) {
03056 loop_tbl[lt_idx].inc_idx = search_idx;
03057 break;
03058 }
03059 else {
03060 search_idx = loop_tbl[search_idx].parent_idx;
03061 }
03062
03063 }
03064
03065 if (search_idx == NULL_IDX) {
03066 PRINTMSG(IL_LINE_NUM(il_idx), 658, Error, IL_COL_NUM(il_idx),
03067 AT_OBJ_NAME_PTR(IL_IDX(il_idx)));
03068 goto EXIT;
03069 }
03070
03071 break;
03072
03073 case IR_Tbl_Idx:
03074 if (good_data_imp_do_expr(loop_tbl[lt_idx].inc_idx)) {
03075 arg_info_list_top = arg_info_list_base + 1;
03076
03077 loop_tbl[lt_idx].inc_expr_desc_idx = arg_info_list_top;
03078
03079 if (arg_info_list_top > arg_info_list_size) {
03080 enlarge_info_list_table();
03081 }
03082
03083 arg_info_list[arg_info_list_top] = init_arg_info;
03084 arg_info_list[arg_info_list_top].ed = expr_desc;
03085 }
03086
03087 break;
03088
03089 default:
03090 PRINTMSG(IR_LINE_NUM(imp_do_idx), 179, Internal,
03091 IR_COL_NUM(imp_do_idx), "build_loop_tbl");
03092 }
03093 }
03094 else {
03095 PRINTMSG(IL_LINE_NUM(il_idx), 936, Error, IL_COL_NUM(il_idx));
03096 }
03097 }
03098
03099
03100
03101
03102
03103
03104
03105 il_idx = IR_IDX_R(imp_do_idx);
03106
03107 if (compiler_gen_imp_do) {
03108 loop_tbl[lt_idx].lcv_idx = IL_IDX(il_idx);
03109 }
03110 else {
03111 COPY_OPND(opnd, IL_OPND(il_idx));
03112 expr_desc.rank = 0;
03113 expr_mode = Regular_Expr;
03114 xref_state = CIF_No_Usage_Rec;
03115 save_in_implied_do = in_implied_do;
03116 in_implied_do = FALSE;
03117
03118 lcv_line = OPND_LINE_NUM(opnd);
03119 lcv_col = OPND_COL_NUM(opnd);
03120 attr_idx = find_base_attr(&opnd, &lcv_line, &lcv_col);
03121
03122 if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
03123 save_imp_do_lcv = ATD_IMP_DO_LCV(attr_idx);
03124 ATD_IMP_DO_LCV(attr_idx) = TRUE;
03125 }
03126
03127 semantics_ok = expr_semantics(&opnd, &expr_desc);
03128
03129 COPY_OPND(IL_OPND(il_idx), opnd);
03130 in_implied_do = save_in_implied_do;
03131
03132 if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
03133 ATD_IMP_DO_LCV(attr_idx) = save_imp_do_lcv;
03134 }
03135
03136 if (expr_desc.reference) {
03137
03138 if (expr_desc.type != Integer) {
03139 find_opnd_line_and_column(&opnd, &line, &column);
03140 PRINTMSG(line, 675, Error, column);
03141 semantics_ok = FALSE;
03142 }
03143
03144 if (OPND_FLD(opnd) == IR_Tbl_Idx &&
03145 IR_OPR(OPND_IDX(opnd)) == Whole_Subscript_Opr) {
03146 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
03147 }
03148
03149 if (OPND_FLD(opnd) == IR_Tbl_Idx &&
03150 IR_OPR(OPND_IDX(opnd)) == Dv_Deref_Opr) {
03151 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
03152 }
03153
03154
03155
03156 if (semantics_ok && OPND_FLD(opnd) != AT_Tbl_Idx) {
03157 find_opnd_line_and_column(&opnd, &line, &column);
03158 PRINTMSG(line, 199, Error, column);
03159 semantics_ok = FALSE;
03160 }
03161 else {
03162 attr_idx = OPND_IDX(opnd);
03163 }
03164
03165 if (semantics_ok && expr_desc.rank != 0) {
03166 find_opnd_line_and_column(&opnd, &line, &column);
03167 PRINTMSG(line, 837, Ansi, column);
03168 }
03169 }
03170 else {
03171
03172
03173
03174
03175 find_opnd_line_and_column(&opnd, &line, &column);
03176 PRINTMSG(line, 675, Error, column);
03177 semantics_ok = FALSE;
03178 }
03179
03180 if (semantics_ok) {
03181 find_opnd_line_and_column(&opnd, &line, &column);
03182
03183 if (AT_ATTR_LINK(attr_idx)) {
03184 PRINTMSG(line, 533, Error, column,
03185 AT_OBJ_NAME_PTR(attr_idx));
03186 semantics_ok = FALSE;
03187 }
03188 else {
03189 do_var_tmp_idx = gen_compiler_tmp(line, column, Priv, TRUE);
03190 AT_SEMANTICS_DONE(do_var_tmp_idx) = TRUE;
03191 ATD_TYPE_IDX(do_var_tmp_idx) = ATD_TYPE_IDX(attr_idx);
03192 ATD_STOR_BLK_IDX(do_var_tmp_idx) = SCP_SB_STACK_IDX(curr_scp_idx);
03193
03194 AT_ATTR_LINK(attr_idx) = do_var_tmp_idx;
03195 AT_IGNORE_ATTR_LINK(attr_idx) = TRUE;
03196
03197 ATD_IMP_DO_LCV(do_var_tmp_idx) = TRUE;
03198 ATD_LCV_IS_CONST(do_var_tmp_idx) = TRUE;
03199 ATD_TMP_NEEDS_CIF(do_var_tmp_idx) = TRUE;
03200
03201
03202 AT_NAME_IDX(do_var_tmp_idx) = AT_NAME_IDX(attr_idx);
03203 AT_NAME_LEN(do_var_tmp_idx) = AT_NAME_LEN(attr_idx);
03204
03205
03206
03207
03208 AT_REFERENCED(do_var_tmp_idx) = Not_Referenced;
03209
03210 IL_FLD(il_idx) = AT_Tbl_Idx;
03211 IL_IDX(il_idx) = do_var_tmp_idx;
03212 IL_LINE_NUM(il_idx) = line;
03213 IL_COL_NUM(il_idx) = column;
03214
03215 loop_tbl[lt_idx].lcv_idx = do_var_tmp_idx;
03216
03217
03218 if ((cif_flags & XREF_RECS) != 0) {
03219 cif_usage_rec(do_var_tmp_idx, AT_Tbl_Idx, line, column,
03220 CIF_Symbol_Modification);
03221 }
03222
03223 }
03224 }
03225 }
03226
03227
03228 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
03229 goto EXIT;
03230 }
03231
03232
03233
03234
03235
03236 in_implied_do = TRUE;
03237 target_idx = IR_IDX_L(imp_do_idx);
03238 loop_tbl[lt_idx].target_list = target_idx;
03239
03240 while (target_idx != NULL_IDX) {
03241 ++loop_tbl[lt_idx].num_targets;
03242
03243 if (IL_FLD(target_idx) == IR_Tbl_Idx &&
03244 IR_OPR(IL_IDX(target_idx)) == Implied_Do_Opr) {
03245 curr_parent_idx = lt_idx;
03246 build_loop_tbl(IL_IDX(target_idx), compiler_gen_imp_do);
03247 }
03248 else if (! compiler_gen_imp_do) {
03249 COPY_OPND(opnd, IL_OPND(target_idx));
03250 object_semantics(&opnd,
03251 Restricted_Imp_Do_Target,
03252 &expr_desc,
03253 FALSE,
03254 FALSE);
03255
03256 if (! SH_ERR_FLG(curr_stmt_sh_idx)) {
03257
03258
03259
03260
03261
03262
03263 if (expr_desc.rank != 0 || OPND_FLD(opnd) != IR_Tbl_Idx) {
03264 find_opnd_line_and_column(&opnd, &line, &column);
03265 PRINTMSG(line, 709, Error, column);
03266 goto EXIT;
03267 }
03268
03269
03270
03271
03272
03273 temp_ir_idx = OPND_IDX(opnd);
03274
03275 if (IR_OPR(temp_ir_idx) == Whole_Substring_Opr ||
03276 IR_OPR(temp_ir_idx) == Substring_Opr) {
03277 temp_ir_idx = IR_IDX_L(temp_ir_idx);
03278 }
03279
03280 if (IR_OPR(temp_ir_idx) != Subscript_Opr &&
03281 IR_OPR(temp_ir_idx) != Struct_Opr) {
03282 find_opnd_line_and_column(&opnd, &line, &column);
03283 PRINTMSG(line, 709, Error, column);
03284 goto EXIT;
03285 }
03286
03287 COPY_OPND(IL_OPND(target_idx), opnd);
03288 }
03289 }
03290
03291 target_idx = IL_NEXT_LIST_IDX(target_idx);
03292 }
03293
03294
03295
03296
03297 lt_idx = curr_parent_idx;
03298
03299 if (curr_parent_idx != NULL_IDX) {
03300 curr_parent_idx = loop_tbl[lt_idx].parent_idx;
03301 }
03302
03303
03304 EXIT:
03305
03306
03307
03308
03309
03310 if (semantics_ok && attr_idx != NULL_IDX) {
03311 AT_ATTR_LINK(attr_idx) = NULL_IDX;
03312 AT_IGNORE_ATTR_LINK(attr_idx) = FALSE;
03313 }
03314
03315 in_implied_do = save_in_implied_do;
03316 expr_mode = Regular_Expr;
03317
03318 TRACE (Func_Exit, "build_loop_tbl", NULL);
03319
03320 return;
03321
03322 }
03323
03324
03325
03326
03327
03328
03329
03330
03331
03332
03333
03334
03335
03336
03337
03338
03339
03340
03341
03342
03343 static boolean good_data_imp_do_expr(int ir_idx)
03344
03345 {
03346 boolean result = TRUE;
03347
03348
03349 TRACE (Func_Entry, "good_data_imp_do_expr", NULL);
03350
03351 switch (IR_OPR(ir_idx)) {
03352
03353 case Power_Opr:
03354 case Mult_Opr:
03355 case Div_Opr:
03356 case Uplus_Opr:
03357 case Uminus_Opr:
03358 case Plus_Opr:
03359 case Minus_Opr:
03360 case Paren_Opr:
03361 case Cvrt_Opr:
03362 case Cvrt_Unsigned_Opr:
03363 if (IR_FLD_L(ir_idx) == IR_Tbl_Idx) {
03364
03365 if (! good_data_imp_do_expr(IR_IDX_L(ir_idx))) {
03366 result = FALSE;
03367 }
03368 }
03369
03370 if (IR_FLD_R(ir_idx) == IR_Tbl_Idx) {
03371
03372 if (! good_data_imp_do_expr(IR_IDX_R(ir_idx))) {
03373 result = FALSE;
03374 }
03375 }
03376
03377 break;
03378
03379 case Struct_Opr:
03380 case Subscript_Opr:
03381 #ifdef KEY
03382
03383 result = TRUE;
03384 #else
03385 PRINTMSG(IR_LINE_NUM(ir_idx), 1081, Error, IR_COL_NUM(ir_idx));
03386 result = FALSE;
03387 #endif
03388 break;
03389
03390 default:
03391 PRINTMSG(IR_LINE_NUM(ir_idx), 179, Internal, 0,
03392 "good_data_imp_do_expr");
03393 }
03394
03395 TRACE (Func_Exit, "good_data_imp_do_expr", NULL);
03396
03397 return(result);
03398
03399 }
03400
03401
03402
03403
03404
03405
03406
03407
03408
03409
03410
03411
03412
03413
03414
03415
03416
03417
03418
03419
03420
03421
03422
03423
03424
03425
03426
03427
03428
03429
03430
03431
03432
03433
03434
03435
03436
03437
03438
03439
03440
03441
03442
03443
03444
03445
03446
03447
03448
03449
03450
03451
03452
03453
03454
03455
03456
03457
03458
03459
03460
03461
03462
03463
03464
03465
03466
03467
03468
03469
03470
03471
03472
03473
03474
03475
03476
03477
03478
03479
03480
03481
03482
03483
03484
03485
03486
03487
03488
03489
03490
03491
03492
03493
03494
03495
03496
03497
03498
03499
03500
03501
03502
03503
03504
03505
03506
03507
03508
03509 static boolean imp_do_metamorphed(int init_ir_idx)
03510 {
03511 int attr_idx;
03512 expr_arg_type expr_desc;
03513 opnd_type expr_opnd;
03514 int i;
03515 int il_idx;
03516 int ir_idx;
03517 int iter_count_ir_idx;
03518 int local_lt_idx;
03519 boolean loops_match_bounds;
03520 boolean metamorphed;
03521 int num_elements_idx;
03522 long num_single_values;
03523 int num_single_values_idx;
03524 int num_values_idx;
03525 int result_type_idx;
03526 long_type result_value[MAX_WORDS_FOR_NUMERIC];
03527 int subscript_ir_idx;
03528 int triplet_ir_idx;
03529 int t1_il_idx;
03530 int t2_il_idx;
03531
03532
03533 TRACE (Func_Entry, "imp_do_metamorphed", NULL);
03534
03535 metamorphed = FALSE;
03536 num_elements_idx = CN_INTEGER_ONE_IDX;
03537 num_values_idx = CN_INTEGER_ZERO_IDX;
03538 num_single_values = 0;
03539 num_single_values_idx = CN_INTEGER_ZERO_IDX;
03540
03541
03542
03543
03544
03545
03546 for (i = 1; i <= last_lt_idx; ++i) {
03547
03548 if (loop_tbl[i].num_targets != 1) {
03549 goto EXIT;
03550 }
03551 }
03552
03553
03554
03555
03556
03557
03558 subscript_ir_idx = IL_IDX(loop_tbl[last_lt_idx].target_list);
03559
03560 if (IR_OPR(subscript_ir_idx) != Subscript_Opr ||
03561 IR_FLD_L(subscript_ir_idx) != AT_Tbl_Idx) {
03562 goto EXIT;
03563 }
03564
03565 attr_idx = IR_IDX_L(subscript_ir_idx);
03566
03567 if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != Integer &&
03568 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != Real &&
03569 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != Complex &&
03570 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != Logical) {
03571 goto EXIT;
03572 }
03573
03574
03575
03576
03577
03578
03579
03580
03581
03582
03583
03584 loops_match_bounds = TRUE;
03585 local_lt_idx = last_lt_idx;
03586 il_idx = IR_IDX_R(subscript_ir_idx);
03587
03588
03589 for (i = 1; i <= IR_LIST_CNT_R(subscript_ir_idx); ++i) {
03590
03591 if (IL_FLD(il_idx) == AT_Tbl_Idx) {
03592
03593 if (IL_IDX(il_idx) != loop_tbl[local_lt_idx].lcv_idx) {
03594 goto EXIT;
03595 }
03596
03597 if (loop_tbl[local_lt_idx].start_fld == CN_Tbl_Idx &&
03598 loop_tbl[local_lt_idx].end_fld == CN_Tbl_Idx &&
03599 loop_tbl[local_lt_idx].inc_fld == CN_Tbl_Idx) {
03600
03601 if (fold_relationals(loop_tbl[local_lt_idx].start_idx,
03602 BD_LB_IDX(ATD_ARRAY_IDX(attr_idx), i),
03603 Ne_Opr) ||
03604 fold_relationals(loop_tbl[local_lt_idx].end_idx,
03605 BD_UB_IDX(ATD_ARRAY_IDX(attr_idx), i),
03606 Ne_Opr) ||
03607 fold_relationals(loop_tbl[local_lt_idx].inc_idx,
03608 CN_INTEGER_ONE_IDX,
03609 Ne_Opr)) {
03610 loops_match_bounds = FALSE;
03611 }
03612
03613
03614
03615
03616
03617 NTR_IR_TBL(iter_count_ir_idx);
03618 IR_OPR(iter_count_ir_idx) = Minus_Opr;
03619 IR_TYPE_IDX(iter_count_ir_idx) = INTEGER_DEFAULT_TYPE;
03620 IR_LINE_NUM(iter_count_ir_idx) = stmt_start_line;
03621 IR_COL_NUM(iter_count_ir_idx) = stmt_start_col;
03622 IR_FLD_L(iter_count_ir_idx) = CN_Tbl_Idx;
03623 IR_IDX_L(iter_count_ir_idx) = loop_tbl[local_lt_idx].end_idx;
03624 IR_LINE_NUM_L(iter_count_ir_idx) = stmt_start_line;
03625 IR_COL_NUM_L(iter_count_ir_idx) = stmt_start_col;
03626 IR_FLD_R(iter_count_ir_idx) = CN_Tbl_Idx;
03627 IR_IDX_R(iter_count_ir_idx) = loop_tbl[local_lt_idx].start_idx;
03628 IR_LINE_NUM_R(iter_count_ir_idx) = stmt_start_line;
03629 IR_COL_NUM_R(iter_count_ir_idx) = stmt_start_col;
03630
03631 NTR_IR_TBL(ir_idx);
03632 IR_OPR(ir_idx) = Plus_Opr;
03633 IR_TYPE_IDX(ir_idx) = INTEGER_DEFAULT_TYPE;
03634 IR_LINE_NUM(ir_idx) = stmt_start_line;
03635 IR_COL_NUM(ir_idx) = stmt_start_col;
03636 IR_FLD_L(ir_idx) = IR_Tbl_Idx;
03637 IR_IDX_L(ir_idx) = iter_count_ir_idx;
03638 IR_FLD_R(ir_idx) = CN_Tbl_Idx;
03639 IR_IDX_R(ir_idx) = loop_tbl[local_lt_idx].inc_idx;
03640 IR_LINE_NUM_R(ir_idx) = stmt_start_line;
03641 IR_COL_NUM_R(ir_idx) = stmt_start_col;
03642
03643 NTR_IR_TBL(iter_count_ir_idx);
03644 IR_OPR(iter_count_ir_idx) = Div_Opr;
03645 IR_TYPE_IDX(iter_count_ir_idx) = INTEGER_DEFAULT_TYPE;
03646 IR_LINE_NUM(iter_count_ir_idx) = stmt_start_line;
03647 IR_COL_NUM(iter_count_ir_idx) = stmt_start_col;
03648 IR_FLD_L(iter_count_ir_idx) = IR_Tbl_Idx;
03649 IR_IDX_L(iter_count_ir_idx) = ir_idx;
03650 IR_FLD_R(iter_count_ir_idx) = CN_Tbl_Idx;
03651 IR_IDX_R(iter_count_ir_idx) = loop_tbl[local_lt_idx].inc_idx;
03652 IR_LINE_NUM_R(iter_count_ir_idx) = stmt_start_line;
03653 IR_COL_NUM_R(iter_count_ir_idx) = stmt_start_col;
03654
03655 OPND_FLD(expr_opnd) = IR_Tbl_Idx;
03656 OPND_IDX(expr_opnd) = iter_count_ir_idx;
03657
03658 if (! expr_semantics(&expr_opnd, &expr_desc)) {
03659 PRINTMSG(IR_LINE_NUM(init_ir_idx), 857, Internal,
03660 IR_COL_NUM(init_ir_idx));
03661 }
03662
03663
03664
03665
03666 result_type_idx = INTEGER_DEFAULT_TYPE;
03667
03668 if (folder_driver( (char *) &CN_CONST(num_elements_idx),
03669 CN_TYPE_IDX(num_elements_idx),
03670 (char *) &CN_CONST(OPND_IDX(expr_opnd)),
03671 expr_desc.type_idx,
03672 result_value,
03673 &result_type_idx,
03674 IR_LINE_NUM(init_ir_idx),
03675 IR_COL_NUM(init_ir_idx),
03676 2,
03677 Mult_Opr)) {
03678 num_elements_idx = ntr_const_tbl(INTEGER_DEFAULT_TYPE,
03679 FALSE,
03680 result_value);
03681 }
03682 else {
03683 PRINTMSG(IR_LINE_NUM(init_ir_idx), 1024, Internal,
03684 IR_COL_NUM(init_ir_idx));
03685 }
03686
03687 --local_lt_idx;
03688 }
03689 else {
03690 goto EXIT;
03691 }
03692 }
03693 else if (IL_FLD(il_idx) == CN_Tbl_Idx) {
03694 loops_match_bounds = FALSE;
03695 }
03696 else {
03697 goto EXIT;
03698 }
03699
03700 il_idx = IL_NEXT_LIST_IDX(il_idx);
03701 }
03702
03703
03704
03705
03706
03707
03708
03709
03710 il_idx = value_il_idx;
03711
03712 while (il_idx != NULL_IDX) {
03713
03714 if (IL_FLD(il_idx) == CN_Tbl_Idx) {
03715
03716 if (TYP_TYPE(CN_TYPE_IDX(IL_IDX(il_idx))) != Character &&
03717 TYP_LINEAR(CN_TYPE_IDX(IL_IDX(il_idx))) != Long_Typeless) {
03718 ++num_single_values;
03719 }
03720 else {
03721 goto EXIT;
03722 }
03723 }
03724 else if (IL_FLD(il_idx) == IR_Tbl_Idx) {
03725 ir_idx = IL_IDX(il_idx);
03726
03727 if (IR_OPR(ir_idx) == Rep_Count_Opr) {
03728
03729 if (IR_FLD_R(ir_idx) == CN_Tbl_Idx &&
03730 (TYP_TYPE(CN_TYPE_IDX(IR_IDX_R(ir_idx))) == Character ||
03731 TYP_LINEAR(CN_TYPE_IDX(IR_IDX_R(ir_idx))) == Long_Typeless)) {
03732 goto EXIT;
03733 }
03734
03735
03736
03737 result_type_idx = INTEGER_DEFAULT_TYPE;
03738
03739 if (folder_driver( (char *) &CN_CONST(num_values_idx),
03740 CN_TYPE_IDX(num_values_idx),
03741 (char *) &CN_CONST(IR_IDX_L(ir_idx)),
03742 CN_TYPE_IDX(IR_IDX_L(ir_idx)),
03743 result_value,
03744 &result_type_idx,
03745 IR_LINE_NUM(ir_idx),
03746 IR_COL_NUM(ir_idx),
03747 2,
03748 Plus_Opr)) {
03749 num_values_idx = ntr_const_tbl(INTEGER_DEFAULT_TYPE,
03750 FALSE,
03751 result_value);
03752 }
03753 else {
03754 PRINTMSG(IL_LINE_NUM(il_idx), 1024, Internal,
03755 IL_COL_NUM(il_idx));
03756 }
03757 }
03758 else {
03759
03760
03761
03762 if (TYP_TYPE(CN_TYPE_IDX(IR_IDX_L(ir_idx))) != Character &&
03763 TYP_LINEAR(CN_TYPE_IDX(IR_IDX_L(ir_idx))) != Long_Typeless) {
03764 ++num_single_values;
03765 }
03766 else {
03767 goto EXIT;
03768 }
03769 }
03770 }
03771
03772 il_idx = IL_NEXT_LIST_IDX(il_idx);
03773 }
03774
03775
03776
03777
03778
03779 num_single_values_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
03780 num_single_values);
03781
03782 if (num_single_values_idx != CN_INTEGER_ZERO_IDX &&
03783 num_values_idx != CN_INTEGER_ZERO_IDX) {
03784
03785 result_type_idx = INTEGER_DEFAULT_TYPE;
03786
03787 if (folder_driver( (char *) &CN_CONST(num_single_values_idx),
03788 CG_INTEGER_DEFAULT_TYPE,
03789 (char *) &CN_CONST(num_values_idx),
03790 CN_TYPE_IDX(num_values_idx),
03791 result_value,
03792 &result_type_idx,
03793 IR_LINE_NUM(init_ir_idx),
03794 IR_COL_NUM(init_ir_idx),
03795 2,
03796 Plus_Opr)) {
03797
03798 num_values_idx = ntr_const_tbl(INTEGER_DEFAULT_TYPE,
03799 FALSE,
03800 result_value);
03801 }
03802 else {
03803 PRINTMSG(IR_LINE_NUM(init_ir_idx), 1024, Internal,
03804 IR_COL_NUM(init_ir_idx));
03805 }
03806 }
03807
03808 if (fold_relationals(num_values_idx, CN_INTEGER_ZERO_IDX, Eq_Opr)) {
03809 num_values_idx = num_single_values_idx;
03810 }
03811
03812 if (fold_relationals(num_elements_idx, num_values_idx, Ne_Opr)) {
03813 goto EXIT;
03814 }
03815
03816
03817
03818
03819
03820 metamorphed = TRUE;
03821
03822 PRINTMSG(IR_LINE_NUM(init_ir_idx), 1021, Note, IR_COL_NUM(init_ir_idx));
03823
03824 if (loops_match_bounds) {
03825
03826
03827
03828
03829
03830
03831
03832
03833
03834
03835
03836 if (IR_FLD_L(init_ir_idx) == NO_Tbl_Idx) {
03837 NTR_IR_LIST_TBL(IR_IDX_L(init_ir_idx));
03838 IR_LIST_CNT_L(init_ir_idx) = 1;
03839 IR_FLD_L(init_ir_idx) = IL_Tbl_Idx;
03840
03841 }
03842
03843 IL_FLD(IR_IDX_L(init_ir_idx)) = AT_Tbl_Idx;
03844 IL_IDX(IR_IDX_L(init_ir_idx)) = attr_idx;
03845 IL_LINE_NUM(IR_IDX_L(init_ir_idx)) = IR_LINE_NUM(init_ir_idx);
03846 IL_COL_NUM(IR_IDX_L(init_ir_idx)) = IR_COL_NUM(init_ir_idx);
03847 }
03848 else {
03849
03850
03851
03852
03853
03854
03855 IL_FLD(IR_IDX_L(init_ir_idx)) = IR_Tbl_Idx;
03856 IL_IDX(IR_IDX_L(init_ir_idx)) = subscript_ir_idx;
03857
03858 local_lt_idx = last_lt_idx;
03859 il_idx = IR_IDX_R(subscript_ir_idx);
03860
03861 for (i = 1; i <= IR_LIST_CNT_R(subscript_ir_idx); ++i) {
03862
03863 if (IL_FLD(il_idx) == AT_Tbl_Idx) {
03864 NTR_IR_TBL(triplet_ir_idx);
03865 IL_FLD(il_idx) = IR_Tbl_Idx;
03866 IL_IDX(il_idx) = triplet_ir_idx;
03867
03868 IR_OPR(triplet_ir_idx) = Triplet_Opr;
03869 IR_TYPE_IDX(triplet_ir_idx) = TYPELESS_DEFAULT_TYPE;
03870 IR_LINE_NUM(triplet_ir_idx) = IL_LINE_NUM(il_idx);
03871 IR_COL_NUM(triplet_ir_idx) = IL_COL_NUM(il_idx);
03872
03873 NTR_IR_LIST_TBL(t1_il_idx);
03874
03875 IR_LIST_CNT_L(triplet_ir_idx) = 1;
03876 IR_FLD_L(triplet_ir_idx) = IL_Tbl_Idx;
03877 IR_IDX_L(triplet_ir_idx) = t1_il_idx;
03878
03879 IL_LINE_NUM(t1_il_idx) = IL_LINE_NUM(il_idx);
03880 IL_COL_NUM(t1_il_idx) = IL_COL_NUM(il_idx);
03881 IL_FLD(t1_il_idx) = CN_Tbl_Idx;
03882 IL_IDX(t1_il_idx) = loop_tbl[local_lt_idx].start_idx;
03883
03884 NTR_IR_LIST_TBL(t2_il_idx);
03885
03886 ++IR_LIST_CNT_L(triplet_ir_idx);
03887 IL_NEXT_LIST_IDX(t1_il_idx) = t2_il_idx;
03888 IL_PREV_LIST_IDX(t2_il_idx) = t1_il_idx;
03889
03890 IL_LINE_NUM(t2_il_idx) = IL_LINE_NUM(il_idx);
03891 IL_COL_NUM(t2_il_idx) = IL_COL_NUM(il_idx);
03892 IL_FLD(t2_il_idx) = CN_Tbl_Idx;
03893 IL_IDX(t2_il_idx) = loop_tbl[local_lt_idx].end_idx;
03894
03895 t1_il_idx = t2_il_idx;
03896
03897 NTR_IR_LIST_TBL(t2_il_idx);
03898
03899 ++IR_LIST_CNT_L(triplet_ir_idx);
03900 IL_NEXT_LIST_IDX(t1_il_idx) = t2_il_idx;
03901 IL_PREV_LIST_IDX(t2_il_idx) = t1_il_idx;
03902
03903 IL_LINE_NUM(t2_il_idx) = IL_LINE_NUM(il_idx);
03904 IL_COL_NUM(t2_il_idx) = IL_COL_NUM(il_idx);
03905 IL_FLD(t2_il_idx) = CN_Tbl_Idx;
03906 IL_IDX(t2_il_idx) = loop_tbl[local_lt_idx].inc_idx;
03907
03908 --local_lt_idx;
03909 }
03910
03911 il_idx = IL_NEXT_LIST_IDX(il_idx);
03912 }
03913 }
03914
03915 EXIT:
03916
03917 TRACE (Func_Exit, "imp_do_metamorphed", NULL);
03918
03919 return(metamorphed);
03920
03921 }
03922
03923
03924
03925
03926
03927
03928
03929
03930
03931
03932
03933
03934
03935
03936
03937
03938
03939
03940 static void interpret_data_imp_do(int init_ir_idx)
03941 {
03942
03943 expr_arg_type expr_desc;
03944 opnd_type expr_opnd;
03945 boolean first_offspring_imp_do;
03946 int i;
03947 long_type loc_value[MAX_WORDS_FOR_NUMERIC];
03948 long64 num_iterations;
03949 #ifdef KEY
03950 int sister_idx = 0;
03951 #else
03952 int sister_idx;
03953 #endif
03954 int target_il_idx;
03955
03956
03957 TRACE (Func_Entry, "interpret_data_imp_do", NULL);
03958
03959
03960
03961
03962
03963 GET_LCV_CONST(loop_tbl[lt_idx].lcv_idx, loc_value[0],
03964 num_host_wds[TYP_LINEAR(ATD_TYPE_IDX(loop_tbl[lt_idx].lcv_idx))]);
03965
03966 ATD_FLD(loop_tbl[lt_idx].lcv_idx) = CN_Tbl_Idx;
03967 ATD_TMP_IDX(loop_tbl[lt_idx].lcv_idx) =
03968 ntr_const_tbl(ATD_TYPE_IDX(loop_tbl[lt_idx].lcv_idx),
03969 FALSE,
03970 loc_value);
03971
03972
03973 OPND_FLD(expr_opnd) = IR_Tbl_Idx;
03974
03975 if (loop_tbl[lt_idx].start_fld == AT_Tbl_Idx) {
03976 loop_tbl[lt_idx].start_value =
03977 loop_tbl[loop_tbl[lt_idx].start_idx].curr_value;
03978 }
03979 else if (loop_tbl[lt_idx].start_fld == IR_Tbl_Idx) {
03980 OPND_IDX(expr_opnd) = loop_tbl[lt_idx].start_idx;
03981
03982 expr_desc = arg_info_list[loop_tbl[lt_idx].start_expr_desc_idx].ed;
03983
03984 if (! fold_aggragate_expression(&expr_opnd, &expr_desc, TRUE)) {
03985 goto EXIT;
03986 }
03987
03988 loop_tbl[lt_idx].start_value = CN_INT_TO_C(OPND_IDX(expr_opnd));
03989 }
03990
03991 if (loop_tbl[lt_idx].end_fld == AT_Tbl_Idx) {
03992 loop_tbl[lt_idx].end_value =
03993 loop_tbl[loop_tbl[lt_idx].end_idx].curr_value;
03994 }
03995 else if (loop_tbl[lt_idx].end_fld == IR_Tbl_Idx) {
03996 OPND_IDX(expr_opnd) = loop_tbl[lt_idx].end_idx;
03997
03998 expr_desc = arg_info_list[loop_tbl[lt_idx].end_expr_desc_idx].ed;
03999
04000 if (! fold_aggragate_expression(&expr_opnd, &expr_desc, TRUE)) {
04001 goto EXIT;
04002 }
04003
04004 loop_tbl[lt_idx].end_value = CN_INT_TO_C(OPND_IDX(expr_opnd));
04005 }
04006
04007 if (loop_tbl[lt_idx].inc_fld == AT_Tbl_Idx) {
04008 loop_tbl[lt_idx].inc_value =
04009 loop_tbl[loop_tbl[lt_idx].inc_idx].curr_value;
04010 }
04011 else if (loop_tbl[lt_idx].inc_fld == IR_Tbl_Idx) {
04012 OPND_IDX(expr_opnd) = loop_tbl[lt_idx].inc_idx;
04013
04014 expr_desc = arg_info_list[loop_tbl[lt_idx].inc_expr_desc_idx].ed;
04015
04016 if (! fold_aggragate_expression(&expr_opnd, &expr_desc, TRUE)) {
04017 goto EXIT;
04018 }
04019
04020 loop_tbl[lt_idx].inc_value = CN_INT_TO_C(OPND_IDX(expr_opnd));
04021 }
04022
04023 num_iterations =
04024 (loop_tbl[lt_idx].end_value - loop_tbl[lt_idx].start_value +
04025 loop_tbl[lt_idx].inc_value) /
04026 loop_tbl[lt_idx].inc_value;
04027
04028 if (num_iterations < 0) {
04029 num_iterations = 0;
04030 }
04031
04032 if (num_iterations == 0) {
04033 goto EXIT;
04034 }
04035
04036 for (loop_tbl[lt_idx].curr_value = loop_tbl[lt_idx].start_value;
04037 (loop_tbl[lt_idx].inc_value > 0) ?
04038 loop_tbl[lt_idx].curr_value <= loop_tbl[lt_idx].end_value :
04039 loop_tbl[lt_idx].curr_value >= loop_tbl[lt_idx].end_value;
04040 loop_tbl[lt_idx].curr_value += loop_tbl[lt_idx].inc_value) {
04041
04042 C_TO_F_INT(loc_value,
04043 loop_tbl[lt_idx].curr_value,
04044 TYP_LINEAR(ATD_TYPE_IDX(loop_tbl[lt_idx].lcv_idx)));
04045 #ifdef KEY
04046 SET_LCV_CONST(loop_tbl[lt_idx].lcv_idx,
04047 (loc_value[0]),
04048 num_host_wds[TYP_LINEAR(ATD_TYPE_IDX(
04049 loop_tbl[lt_idx].lcv_idx))],
04050 num_host_wds[TYP_LINEAR(ATD_TYPE_IDX(
04051 loop_tbl[lt_idx].lcv_idx))]);
04052 #else
04053 SET_LCV_CONST(loop_tbl[lt_idx].lcv_idx,
04054 (loc_value[0]),
04055 num_host_wds[TYP_LINEAR(ATD_TYPE_IDX(
04056 loop_tbl[lt_idx].lcv_idx))]);
04057 #endif
04058
04059 target_il_idx = loop_tbl[lt_idx].target_list;
04060 first_offspring_imp_do = TRUE;
04061
04062 for (i = 1; i <= loop_tbl[lt_idx].num_targets; ++i) {
04063
04064 if (IR_OPR(IL_IDX(target_il_idx)) == Implied_Do_Opr) {
04065
04066
04067
04068
04069
04070
04071
04072 if (first_offspring_imp_do) {
04073 lt_idx = loop_tbl[lt_idx].offspring_idx;
04074 sister_idx = loop_tbl[lt_idx].sibling_idx;
04075 first_offspring_imp_do = FALSE;
04076 }
04077 else {
04078 lt_idx = sister_idx;
04079 sister_idx = loop_tbl[lt_idx].sibling_idx;
04080 }
04081
04082
04083 interpret_data_imp_do(init_ir_idx);
04084
04085 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
04086 goto EXIT;
04087 }
04088 }
04089 else {
04090
04091 process_data_imp_do_target(init_ir_idx,
04092 target_il_idx,
04093 num_iterations);
04094
04095 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
04096 goto EXIT;
04097 }
04098
04099 if (loop_tbl[lt_idx].num_targets == 1) {
04100 goto EXIT;
04101 }
04102 }
04103
04104 target_il_idx = IL_NEXT_LIST_IDX(target_il_idx);
04105 }
04106 }
04107
04108 EXIT:
04109
04110
04111 #ifdef KEY
04112 SET_LCV_CONST(loop_tbl[lt_idx].lcv_idx,
04113 CN_CONST(ATD_TMP_IDX(loop_tbl[lt_idx].lcv_idx)),
04114 num_host_wds[TYP_LINEAR(ATD_TYPE_IDX(loop_tbl[lt_idx].lcv_idx))], num_host_wds[TYP_LINEAR(CN_TYPE_IDX(ATD_TMP_IDX(loop_tbl[lt_idx].lcv_idx)))]);
04115 #else
04116 SET_LCV_CONST(loop_tbl[lt_idx].lcv_idx,
04117 CN_CONST(ATD_TMP_IDX(loop_tbl[lt_idx].lcv_idx)),
04118 num_host_wds[TYP_LINEAR(ATD_TYPE_IDX(loop_tbl[lt_idx].lcv_idx))]);
04119 #endif
04120
04121 lt_idx = loop_tbl[lt_idx].parent_idx;
04122
04123 TRACE (Func_Exit, "interpret_data_imp_do", NULL);
04124
04125 return;
04126
04127 }
04128
04129
04130
04131
04132
04133
04134
04135
04136
04137
04138
04139
04140
04141
04142
04143
04144
04145
04146
04147
04148
04149
04150
04151
04152
04153
04154
04155
04156
04157
04158
04159
04160
04161
04162
04163
04164
04165
04166
04167
04168
04169
04170
04171
04172
04173
04174
04175
04176
04177
04178
04179
04180
04181
04182
04183
04184
04185
04186
04187
04188
04189
04190
04191
04192
04193
04194
04195
04196
04197
04198
04199
04200
04201
04202
04203
04204
04205
04206
04207
04208
04209
04210
04211
04212
04213
04214
04215
04216
04217
04218
04219
04220
04221
04222
04223
04224
04225
04226
04227
04228
04229
04230
04231
04232
04233
04234
04235
04236
04237
04238
04239
04240
04241
04242
04243
04244
04245
04246
04247
04248
04249
04250
04251
04252
04253
04254
04255
04256
04257
04258
04259
04260
04261
04262
04263
04264
04265
04266
04267
04268 static void process_data_imp_do_target(int init_ir_idx,
04269 int target_il_idx,
04270 long64 num_iterations)
04271 {
04272 opnd_type ignore_this_opnd;
04273 int il_idx;
04274 boolean long_value;
04275 int ir_idx;
04276 opnd_type rep_factor_opnd;
04277 int target_attr_idx;
04278 boolean word_size_target;
04279
04280
04281 TRACE (Func_Entry, "process_data_imp_do_target", NULL);
04282
04283 ir_idx = IL_IDX(target_il_idx);
04284
04285 if (IR_OPR(ir_idx) == Whole_Substring_Opr ||
04286 IR_OPR(ir_idx) == Substring_Opr) {
04287 ir_idx = IR_IDX_L(ir_idx);
04288 }
04289
04290
04291
04292
04293
04294 if (IR_OPR(ir_idx) == Subscript_Opr ||
04295 IR_OPR(ir_idx) == Section_Subscript_Opr) {
04296
04297
04298
04299 target_attr_idx = (IR_FLD_L(ir_idx) == AT_Tbl_Idx) ?
04300 IR_IDX_L(ir_idx) : IR_IDX_R(IR_IDX_L(ir_idx));
04301 }
04302 else {
04303 target_attr_idx = IR_IDX_R(ir_idx);
04304 }
04305
04306 if (loop_tbl[lt_idx].num_targets == 1) {
04307
04308
04309
04310
04311 obj_count = num_iterations * loop_tbl[lt_idx].num_targets;
04312
04313 while (obj_count > 0) {
04314
04315 if (rep_factor == 0) {
04316 set_global_value_variables(&rep_factor_opnd,
04317 &ignore_this_opnd,
04318 target_attr_idx);
04319
04320 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
04321 goto EXIT;
04322 }
04323
04324 ++IR_LIST_CNT_R(init_ir_idx);
04325 }
04326
04327 word_size_target = FALSE;
04328
04329 if (TYP_LINEAR(ATD_TYPE_IDX(target_attr_idx)) ==
04330 INTEGER_DEFAULT_TYPE ||
04331 TYP_LINEAR(ATD_TYPE_IDX(target_attr_idx)) ==
04332 REAL_DEFAULT_TYPE) {
04333
04334 if (storage_bit_size_tbl[
04335 TYP_LINEAR(ATD_TYPE_IDX(target_attr_idx))] ==
04336 TARGET_BITS_PER_WORD) {
04337 word_size_target = TRUE;
04338 }
04339 }
04340
04341 long_value = FALSE;
04342
04343 if (value_desc.type == Typeless) {
04344 if (TYP_BIT_LEN(CN_TYPE_IDX(OPND_IDX(value_opnd))) >
04345 TARGET_BITS_PER_WORD) {
04346 long_value = TRUE;
04347 }
04348 }
04349 else if (value_desc.type == Character) {
04350
04351 if (CN_INT_TO_C(TYP_IDX(value_desc.type_idx)) >
04352 TARGET_CHARS_PER_WORD) {
04353 long_value = TRUE;
04354 }
04355 }
04356
04357 if (word_size_target && long_value) {
04358 PRINTMSG(OPND_LINE_NUM(value_opnd), 733, Error,
04359 OPND_COL_NUM(value_opnd));
04360
04361 --IR_LIST_CNT_R(init_ir_idx);
04362
04363
04364
04365
04366
04367
04368 if (TYP_TYPE(CN_TYPE_IDX(OPND_IDX(value_opnd))) == Typeless) {
04369 ls_word_len =
04370 TYP_BIT_LEN(CN_TYPE_IDX(OPND_IDX(value_opnd))) /
04371 TARGET_BITS_PER_WORD;
04372 }
04373 else {
04374 ls_word_len =
04375 CN_INT_TO_C(TYP_IDX(CN_TYPE_IDX(OPND_IDX(value_opnd)))) /
04376 TARGET_CHARS_PER_WORD;
04377
04378 if ((long)
04379 CN_INT_TO_C(TYP_IDX(CN_TYPE_IDX(OPND_IDX(value_opnd)))) %
04380 TARGET_CHARS_PER_WORD) {
04381 ++ls_word_len;
04382 }
04383 }
04384 }
04385
04386 check_target_and_value(target_attr_idx, init_ir_idx);
04387
04388 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
04389 goto EXIT;
04390 }
04391
04392 if (obj_count == rep_factor) {
04393 obj_count = 0;
04394 rep_factor = 0;
04395
04396 if (IL_FLD(value_il_idx) == CN_Tbl_Idx) {
04397 IL_IDX(value_il_idx) = OPND_IDX(value_opnd);
04398 }
04399 else {
04400 IR_IDX_R(IL_IDX(value_il_idx)) = OPND_IDX(value_opnd);
04401 }
04402
04403 value_il_idx = IL_NEXT_LIST_IDX(value_il_idx);
04404 }
04405 else if (obj_count > rep_factor) {
04406 obj_count -= rep_factor;
04407 rep_factor = 0;
04408
04409 if (IL_FLD(value_il_idx) == CN_Tbl_Idx) {
04410 IL_IDX(value_il_idx) = OPND_IDX(value_opnd);
04411 }
04412 else {
04413 IR_IDX_R(IL_IDX(value_il_idx)) = OPND_IDX(value_opnd);
04414 }
04415
04416 value_il_idx = IL_NEXT_LIST_IDX(value_il_idx);
04417
04418 if (value_il_idx == NULL_IDX) {
04419 PRINTMSG(IR_LINE_NUM(init_ir_idx), 667, Error,
04420 IR_COL_NUM(init_ir_idx));
04421 goto EXIT;
04422 }
04423 }
04424 else {
04425
04426
04427
04428
04429 rep_factor -= obj_count;
04430 obj_count = 0;
04431 }
04432 }
04433 }
04434 else {
04435
04436
04437
04438
04439 if (rep_factor == 0) {
04440 set_global_value_variables(&rep_factor_opnd,
04441 &ignore_this_opnd,
04442 target_attr_idx);
04443
04444 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
04445 goto EXIT;
04446 }
04447
04448 ++IR_LIST_CNT_R(init_ir_idx);
04449 }
04450
04451
04452 if ((TYP_TYPE(ATD_TYPE_IDX(target_attr_idx)) == Integer ||
04453 TYP_LINEAR(ATD_TYPE_IDX(target_attr_idx)) == REAL_DEFAULT_TYPE) &&
04454 (value_desc.linear_type == Long_Typeless ||
04455 (CN_HOLLERITH_TYPE(OPND_IDX(value_opnd)) != Not_Hollerith &&
04456 TYP_BIT_LEN(CN_TYPE_IDX(OPND_IDX(value_opnd))) >
04457 TARGET_BITS_PER_WORD) ||
04458 (value_desc.type == Character &&
04459 CN_INT_TO_C(TYP_IDX(value_desc.type_idx)) >
04460 TARGET_CHARS_PER_WORD))){
04461
04462 PRINTMSG(OPND_LINE_NUM(value_opnd),
04463 733, Error,
04464 OPND_COL_NUM(value_opnd));
04465 }
04466
04467 check_target_and_value(target_attr_idx, init_ir_idx);
04468
04469 if (rep_factor == 1) {
04470 rep_factor = 0;
04471 value_il_idx = IL_NEXT_LIST_IDX(value_il_idx);
04472 }
04473 else {
04474 --rep_factor;
04475 }
04476 }
04477
04478 EXIT:
04479
04480
04481
04482
04483
04484 if (SH_ERR_FLG(curr_stmt_sh_idx)) {
04485 il_idx = IR_IDX_R(init_ir_idx);
04486 IR_LIST_CNT_R(init_ir_idx) = 1;
04487
04488 while (IL_NEXT_LIST_IDX(il_idx) != NULL_IDX) {
04489 il_idx = IL_NEXT_LIST_IDX(il_idx);
04490 ++IR_LIST_CNT_R(init_ir_idx);
04491 }
04492 }
04493
04494 TRACE (Func_Exit, "process_data_imp_do_target", NULL);
04495
04496 return;
04497
04498 }
04499 #ifdef KEY
04500
04501
04502
04503
04504
04505
04506
04507
04508
04509
04510
04511
04512
04513
04514
04515
04516
04517
04518
04519
04520
04521
04522
04523
04524
04525
04526 static boolean force_hollerith_or_int_to_character(linear_type_type target_idx,
04527 int *source_idx)
04528 {
04529 if (CHARACTER_DEFAULT_TYPE != target_idx) {
04530 return FALSE;
04531 }
04532
04533 int type_byte_len = 1;
04534 boolean hollerith = FALSE;
04535 int orig_source_idx = *source_idx;
04536 basic_type_type orig_source_type = TYP_TYPE(CN_TYPE_IDX(orig_source_idx));
04537
04538
04539
04540
04541
04542 if (H_Hollerith == CN_HOLLERITH_TYPE(orig_source_idx)) {
04543
04544 type_byte_len = TARGET_CHARS_PER_WORD *
04545 ((TYP_BIT_LEN(CN_TYPE_IDX(orig_source_idx)) + TARGET_BITS_PER_WORD - 1) /
04546 TARGET_BITS_PER_WORD);
04547 CN_HOLLERITH_TYPE(orig_source_idx) = Not_Hollerith;
04548 CN_HOLLERITH_ENDIAN(orig_source_idx) = FALSE;
04549 hollerith = TRUE;
04550 }
04551
04552
04553 else if ((!on_off_flags.issue_ansi_messages) &&
04554 (orig_source_type == Integer || orig_source_type == Typeless)) {
04555
04556 }
04557
04558 else {
04559 return FALSE;
04560 }
04561
04562
04563 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
04564 TYP_TYPE(TYP_WORK_IDX) = Character;
04565 TYP_LINEAR(TYP_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
04566 TYP_DESC(TYP_WORK_IDX) = Default_Typed;
04567 TYP_CHAR_CLASS(TYP_WORK_IDX) = Const_Len_Char;
04568 TYP_FLD(TYP_WORK_IDX) = CN_Tbl_Idx;
04569 TYP_IDX(TYP_WORK_IDX) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
04570 type_byte_len);
04571 int type_index = ntr_type_tbl();
04572
04573
04574
04575 if (hollerith) {
04576 CN_TYPE_IDX(orig_source_idx) = type_index;
04577 }
04578 else {
04579 *source_idx = ntr_const_tbl(type_index, FALSE,
04580 &(CN_CONST(orig_source_idx)));
04581 }
04582
04583 return TRUE;
04584 }
04585 #endif
04586
04587
04588
04589
04590
04591
04592
04593
04594
04595
04596
04597
04598
04599
04600
04601
04602
04603
04604
04605
04606
04607
04608
04609
04610 static boolean check_target_and_value(int attr_idx,
04611 int init_ir_idx)
04612
04613 {
04614 long_type another_constant[MAX_WORDS_FOR_NUMERIC];
04615 int column;
04616 int line;
04617 boolean result = TRUE;
04618 int type_idx;
04619
04620
04621 TRACE (Func_Entry, "check_target_and_value", NULL);
04622
04623 if (value_desc.linear_type == Long_Typeless) {
04624 PRINTMSG(OPND_LINE_NUM(value_opnd), 1133, Error,
04625 OPND_COL_NUM(value_opnd));
04626 result = FALSE;
04627 goto EXIT;
04628 }
04629
04630 #ifdef KEY
04631 int source_idx = OPND_IDX(value_opnd);
04632 #endif
04633 if (check_asg_semantics(ATD_TYPE_IDX(attr_idx),
04634 value_desc.type_idx,
04635 OPND_LINE_NUM(value_opnd),
04636 OPND_COL_NUM(value_opnd))) {
04637
04638 if ((ATD_POINTER(attr_idx) &&
04639 (OPND_FLD(value_opnd) != IR_Tbl_Idx ||
04640 IR_OPR(OPND_IDX(value_opnd)) != Null_Intrinsic_Opr)) ||
04641
04642 (!ATD_POINTER(attr_idx) &&
04643 OPND_FLD(value_opnd) == IR_Tbl_Idx &&
04644 IR_OPR(OPND_IDX(value_opnd)) == Null_Intrinsic_Opr)) {
04645 find_opnd_line_and_column(&value_opnd, &line, &column);
04646 PRINTMSG(line, 1559, Error, column);
04647 }
04648
04649 if (ATD_POINTER(attr_idx) &&
04650 OPND_FLD(value_opnd) == IR_Tbl_Idx &&
04651 IR_OPR(OPND_IDX(value_opnd)) == Null_Intrinsic_Opr) {
04652 IR_OPR(init_ir_idx) = Null_Opr;
04653 }
04654
04655 if (CN_BOZ_CONSTANT(OPND_IDX(value_opnd)) &&
04656 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != Integer) {
04657
04658 PRINTMSG(OPND_LINE_NUM(value_opnd), 729, Ansi,
04659 OPND_COL_NUM(value_opnd),
04660 AT_OBJ_NAME_PTR(attr_idx));
04661 }
04662
04663 if ((TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != Character &&
04664 value_desc.type == Character) ||
04665 value_desc.linear_type == Short_Typeless_Const) {
04666
04667
04668
04669
04670 OPND_IDX(value_opnd) = cast_typeless_constant(OPND_IDX(value_opnd),
04671 ATD_TYPE_IDX(attr_idx),
04672 OPND_LINE_NUM(value_opnd),
04673 OPND_COL_NUM(value_opnd));
04674 value_desc.type = TYP_TYPE(ATD_TYPE_IDX(attr_idx));
04675 value_desc.type_idx = ATD_TYPE_IDX(attr_idx);
04676 value_desc.linear_type = TYP_LINEAR(ATD_TYPE_IDX(attr_idx));
04677 }
04678 else if (TYP_LINEAR(value_desc.type_idx) !=
04679 TYP_LINEAR(ATD_TYPE_IDX(attr_idx)) &&
04680 TYP_TYPE(value_desc.type_idx) != Character &&
04681 TYP_TYPE(value_desc.type_idx) != Typeless &&
04682 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != CRI_Ptr &&
04683 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != CRI_Parcel_Ptr &&
04684 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) != CRI_Ch_Ptr) {
04685
04686
04687
04688
04689
04690
04691
04692 type_idx = ATD_TYPE_IDX(attr_idx);
04693
04694 if (folder_driver( (char *) &CN_CONST(OPND_IDX(value_opnd)),
04695 value_desc.type_idx,
04696 NULL,
04697 NULL_IDX,
04698 another_constant,
04699 &type_idx,
04700 OPND_LINE_NUM(value_opnd),
04701 OPND_COL_NUM(value_opnd),
04702 1,
04703 Cvrt_Opr)) {
04704
04705 value_desc.type_idx = type_idx;
04706 value_desc.linear_type = TYP_LINEAR(type_idx);
04707 value_desc.type = TYP_TYPE(type_idx);
04708 OPND_IDX(value_opnd) = ntr_const_tbl(ATD_TYPE_IDX(attr_idx),
04709 FALSE,
04710 another_constant);
04711 }
04712 }
04713 }
04714 #ifdef KEY
04715 else if (force_hollerith_or_int_to_character(
04716 TYP_LINEAR(ATD_TYPE_IDX(attr_idx)), &source_idx)) {
04717 OPND_IDX(value_opnd) = source_idx;
04718 }
04719 #endif
04720 else {
04721 find_opnd_line_and_column(&value_opnd, &line, &column);
04722 PRINTMSG(line, 97, Error, column, AT_OBJ_NAME_PTR(attr_idx));
04723 result = FALSE;
04724 }
04725
04726 EXIT:
04727
04728 TRACE (Func_Exit, "check_target_and_value", NULL);
04729
04730 return(result);
04731
04732 }
04733
04734
04735
04736
04737
04738
04739
04740
04741
04742
04743
04744
04745
04746
04747
04748
04749
04750
04751
04752
04753
04754
04755
04756
04757
04758
04759 static void adjust_char_value_len(int init_ir_idx,
04760 int array_ir_idx,
04761 long64 section_start_value,
04762 long64 section_inc_value)
04763 {
04764
04765 int end_il_idx;
04766 long64 i;
04767 int il_idx;
04768 int imp_do_ir_idx;
04769 int inc_il_idx;
04770 int ir_idx;
04771 int new_init_ir_idx;
04772 int new_str_idx;
04773 char *new_str_ptr;
04774 long64 numeric_value;
04775 char *old_str_ptr;
04776 opnd_type opnd;
04777 int original_end_il_idx;
04778 long64 original_end_val;
04779 long64 original_start_val;
04780 long64 rep_count;
04781 int rep_count_il_idx;
04782 int rep_count_ir_idx;
04783 int start_il_idx;
04784 int substring_ir_idx;
04785 long64 target_length;
04786 #ifdef KEY
04787 int temp_idx = 0;
04788 #else
04789 int temp_idx;
04790 #endif
04791 int type_idx;
04792 int value_idx;
04793 long64 value_length;
04794
04795
04796
04797
04798
04799
04800
04801
04802
04803
04804
04805
04806
04807
04808 # if defined(_HOST_LITTLE_ENDIAN)
04809 long_type single_blank = (long_type)' ';
04810 #else
04811 long_type single_blank = (long_type)' ' <<
04812 (sizeof(long_type)*CHAR_BIT - CHAR_BIT);
04813 # endif
04814
04815
04816 TRACE (Func_Entry, "adjust_char_value_len", NULL);
04817
04818 substring_ir_idx = IR_IDX_L(init_ir_idx);
04819 il_idx = IR_IDX_R(substring_ir_idx);
04820 original_start_val = CN_INT_TO_C(IL_IDX(il_idx));
04821 original_end_il_idx = IL_NEXT_LIST_IDX(il_idx);
04822 original_end_val = CN_INT_TO_C(IL_IDX(original_end_il_idx));
04823 target_length = original_end_val - original_start_val + 1;
04824
04825 if (target_length > 0) {
04826 value_idx = IL_IDX(IR_IDX_R(init_ir_idx));
04827 value_length = CN_INT_TO_C(TYP_IDX(CN_TYPE_IDX(value_idx)));
04828
04829 if (target_length == value_length) {
04830 goto EXIT;
04831 }
04832
04833 if (target_length < value_length) {
04834
04835
04836
04837
04838 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
04839 TYP_TYPE(TYP_WORK_IDX) = Character;
04840 TYP_LINEAR(TYP_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
04841 TYP_CHAR_CLASS(TYP_WORK_IDX) = Const_Len_Char;
04842 TYP_FLD(TYP_WORK_IDX) = CN_Tbl_Idx;
04843 TYP_IDX(TYP_WORK_IDX) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
04844 target_length);
04845 type_idx = ntr_type_tbl();
04846
04847
04848
04849
04850
04851
04852
04853 new_str_idx = ntr_const_tbl(type_idx, TRUE, NULL);
04854 new_str_ptr = (char *) &CN_CONST(new_str_idx);
04855 old_str_ptr = (char *) &CN_CONST(value_idx);
04856
04857 for (i = 0; i < target_length; i++) {
04858 new_str_ptr[i] = old_str_ptr[i];
04859 }
04860
04861 while (target_length % TARGET_BYTES_PER_WORD != 0) {
04862 new_str_ptr[target_length] = ' ';
04863 target_length++;
04864 }
04865
04866 IL_IDX(IR_IDX_R(init_ir_idx)) = new_str_idx;
04867 }
04868 else {
04869
04870
04871
04872
04873
04874
04875
04876
04877
04878
04879
04880
04881
04882
04883
04884
04885
04886
04887
04888
04889
04890
04891
04892
04893
04894
04895
04896
04897
04898
04899 rep_count_il_idx = IL_NEXT_LIST_IDX(IR_IDX_R(init_ir_idx));
04900 rep_count = CN_INT_TO_C(IL_IDX(rep_count_il_idx));
04901
04902 if (array_ir_idx != NULL_IDX && rep_count >= 100 &&
04903 target_length <= 256) {
04904
04905 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
04906 TYP_TYPE(TYP_WORK_IDX) = Character;
04907 TYP_LINEAR(TYP_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
04908 TYP_CHAR_CLASS(TYP_WORK_IDX)= Const_Len_Char;
04909 TYP_FLD(TYP_WORK_IDX) = CN_Tbl_Idx;
04910 TYP_IDX(TYP_WORK_IDX) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
04911 target_length);
04912 type_idx = ntr_type_tbl();
04913
04914
04915
04916
04917
04918
04919
04920
04921 new_str_idx = ntr_const_tbl(type_idx, TRUE, NULL);
04922 new_str_ptr = (char *) &CN_CONST(new_str_idx);
04923 old_str_ptr = (char *) &CN_CONST(value_idx);
04924
04925 for (i = 0; i < value_length; i++) {
04926 new_str_ptr[i] = old_str_ptr[i];
04927 }
04928
04929 for (i = value_length; i < target_length; i++) {
04930 new_str_ptr[i] = ' ';
04931 }
04932
04933 while (target_length % TARGET_BYTES_PER_WORD != 0) {
04934 new_str_ptr[target_length] = ' ';
04935 target_length++;
04936 }
04937
04938 IL_IDX(IR_IDX_R(init_ir_idx)) = new_str_idx;
04939 }
04940 else {
04941
04942
04943
04944
04945
04946
04947
04948
04949
04950
04951 gen_sh(After, Data_Stmt,
04952 IR_LINE_NUM(init_ir_idx), IR_COL_NUM(init_ir_idx),
04953 FALSE, FALSE, TRUE);
04954
04955 if (rep_count == 1) {
04956 gen_opnd(&opnd, init_ir_idx, IR_Tbl_Idx,
04957 IR_LINE_NUM(init_ir_idx),
04958 IR_COL_NUM(init_ir_idx));
04959
04960 copy_subtree(&opnd, &opnd);
04961 new_init_ir_idx = OPND_IDX(opnd);
04962 SH_IR_IDX(curr_stmt_sh_idx) = new_init_ir_idx;
04963
04964 substring_ir_idx = IR_IDX_L(new_init_ir_idx);
04965 IR_OPR(substring_ir_idx) = Substring_Opr;
04966
04967
04968
04969
04970 il_idx = IR_IDX_R(new_init_ir_idx);
04971 IL_IDX(il_idx) = ntr_const_tbl(CHARACTER_DEFAULT_TYPE,
04972 FALSE,
04973 (long_type *) &single_blank);
04974
04975
04976
04977 il_idx = IL_NEXT_LIST_IDX(il_idx);
04978 numeric_value = target_length - value_length;
04979 IL_IDX(il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
04980 numeric_value);
04981
04982
04983
04984 il_idx = IL_NEXT_LIST_IDX(il_idx);
04985 numeric_value = 8;
04986 IL_IDX(il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
04987 numeric_value);
04988
04989
04990 }
04991 else {
04992
04993
04994
04995
04996
04997
04998
04999
05000 NTR_IR_TBL(new_init_ir_idx);
05001 SH_IR_IDX(curr_stmt_sh_idx) = new_init_ir_idx;
05002 IR_OPR(new_init_ir_idx) = Init_Opr;
05003 IR_TYPE_IDX(new_init_ir_idx) = TYPELESS_DEFAULT_TYPE;
05004 IR_LINE_NUM(new_init_ir_idx) = IR_LINE_NUM(init_ir_idx);
05005 IR_COL_NUM(new_init_ir_idx) = IR_COL_NUM(init_ir_idx);
05006
05007 NTR_IR_LIST_TBL(il_idx);
05008 IR_LIST_CNT_R(new_init_ir_idx) = 1;
05009 IR_FLD_R(new_init_ir_idx) = IL_Tbl_Idx;
05010 IR_IDX_R(new_init_ir_idx) = il_idx;
05011
05012 NTR_IR_TBL(rep_count_ir_idx);
05013 IL_FLD(il_idx) = IR_Tbl_Idx;
05014 IL_IDX(il_idx) = rep_count_ir_idx;
05015 IR_OPR(rep_count_ir_idx) = Rep_Count_Opr;
05016 IR_TYPE_IDX(rep_count_ir_idx) = TYPELESS_DEFAULT_TYPE;
05017 IR_LINE_NUM(rep_count_ir_idx) = IR_LINE_NUM(init_ir_idx);
05018 IR_COL_NUM(rep_count_ir_idx) = IR_COL_NUM(init_ir_idx);
05019
05020 COPY_OPND(IR_OPND_L(rep_count_ir_idx),
05021 IL_OPND(rep_count_il_idx));
05022
05023 NTR_IR_TBL(ir_idx);
05024 IR_FLD_R(rep_count_ir_idx) = IR_Tbl_Idx;
05025 IR_IDX_R(rep_count_ir_idx) = ir_idx;
05026 IR_OPR(ir_idx) = Rep_Count_Opr;
05027 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
05028 IR_LINE_NUM(ir_idx) = IR_LINE_NUM(init_ir_idx);
05029 IR_COL_NUM(ir_idx) = IR_COL_NUM(init_ir_idx);
05030
05031 IR_FLD_L(ir_idx) = CN_Tbl_Idx;
05032 numeric_value = target_length - value_length;
05033 IR_IDX_L(ir_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
05034 numeric_value);
05035 IR_LINE_NUM_L(ir_idx) = IR_LINE_NUM(init_ir_idx);
05036 IR_COL_NUM_L(ir_idx) = IR_COL_NUM(init_ir_idx);
05037
05038 IR_FLD_R(ir_idx) = CN_Tbl_Idx;
05039 IR_IDX_R(ir_idx) = ntr_const_tbl(CHARACTER_DEFAULT_TYPE,
05040 FALSE,
05041 (long_type *) &single_blank);
05042 IR_LINE_NUM_R(ir_idx) = IR_LINE_NUM(init_ir_idx);
05043 IR_COL_NUM_R(ir_idx) = IR_COL_NUM(init_ir_idx);
05044
05045
05046
05047
05048 NTR_IR_TBL(imp_do_ir_idx);
05049 IR_FLD_L(new_init_ir_idx) = IR_Tbl_Idx;
05050 IR_IDX_L(new_init_ir_idx) = imp_do_ir_idx;
05051 IR_OPR(imp_do_ir_idx) = Implied_Do_Opr;
05052 IR_TYPE_IDX(imp_do_ir_idx) = TYPELESS_DEFAULT_TYPE;
05053 IR_LINE_NUM(imp_do_ir_idx) = IR_LINE_NUM(init_ir_idx);
05054 IR_COL_NUM(imp_do_ir_idx) = IR_COL_NUM(init_ir_idx);
05055
05056
05057
05058
05059
05060
05061
05062
05063
05064
05065
05066 temp_idx = gen_compiler_tmp(IR_LINE_NUM(init_ir_idx),
05067 IR_COL_NUM(init_ir_idx),
05068 Priv, TRUE);
05069 AT_SEMANTICS_DONE(temp_idx) = TRUE;
05070 ATD_TYPE_IDX(temp_idx) = INTEGER_DEFAULT_TYPE;
05071 ATD_STOR_BLK_IDX(temp_idx) = SCP_SB_STACK_IDX(curr_scp_idx);
05072 ATD_LCV_IS_CONST(temp_idx) = TRUE;
05073
05074
05075
05076
05077 AT_REFERENCED(temp_idx) = Not_Referenced;
05078
05079
05080 NTR_IR_LIST_TBL(il_idx);
05081 IR_LIST_CNT_R(imp_do_ir_idx) = 1;
05082 IR_FLD_R(imp_do_ir_idx) = IL_Tbl_Idx;
05083 IR_IDX_R(imp_do_ir_idx) = il_idx;
05084 IL_FLD(il_idx) = AT_Tbl_Idx;
05085 IL_IDX(il_idx) = temp_idx;
05086 IL_LINE_NUM(il_idx) = stmt_start_line;
05087 IL_COL_NUM(il_idx) = stmt_start_col;
05088
05089
05090
05091
05092
05093
05094 NTR_IR_LIST_TBL(start_il_idx);
05095 IR_LIST_CNT_R(imp_do_ir_idx) = 2;
05096 IL_NEXT_LIST_IDX(il_idx) = start_il_idx;
05097 IL_PREV_LIST_IDX(start_il_idx) = il_idx;
05098
05099 NTR_IR_LIST_TBL(end_il_idx);
05100 IR_LIST_CNT_R(imp_do_ir_idx) = 3;
05101 IL_NEXT_LIST_IDX(start_il_idx) = end_il_idx;
05102 IL_PREV_LIST_IDX(end_il_idx) = start_il_idx;
05103
05104 NTR_IR_LIST_TBL(inc_il_idx);
05105 IR_LIST_CNT_R(imp_do_ir_idx) = 4;
05106 IL_NEXT_LIST_IDX(end_il_idx) = inc_il_idx;
05107 IL_PREV_LIST_IDX(inc_il_idx) = end_il_idx;
05108
05109 if (section_start_value == 0) {
05110 ir_idx = IR_IDX_L(substring_ir_idx);
05111
05112 while (IR_OPR(ir_idx) != Subscript_Opr) {
05113 ir_idx = IR_IDX_L(ir_idx);
05114 }
05115
05116 COPY_OPND(IL_OPND(start_il_idx), IL_OPND(IR_IDX_R(ir_idx)));
05117
05118 numeric_value = CN_INT_TO_C(IL_IDX(start_il_idx))+rep_count-1;
05119
05120 IL_FLD(end_il_idx) = CN_Tbl_Idx;
05121 IL_IDX(end_il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
05122 numeric_value);
05123 IL_LINE_NUM(end_il_idx) = stmt_start_line;
05124 IL_COL_NUM(end_il_idx) = stmt_start_col;
05125
05126 IL_FLD(inc_il_idx) = CN_Tbl_Idx;
05127 IL_IDX(inc_il_idx) = CN_INTEGER_ONE_IDX;
05128 IL_LINE_NUM(inc_il_idx) = stmt_start_line;
05129 IL_COL_NUM(inc_il_idx) = stmt_start_col;
05130 }
05131 else {
05132
05133
05134
05135
05136
05137
05138 IL_FLD(start_il_idx) = CN_Tbl_Idx;
05139 IL_IDX(start_il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
05140 section_start_value);
05141 IL_LINE_NUM(start_il_idx) = stmt_start_line;
05142 IL_COL_NUM(start_il_idx) = stmt_start_col;
05143
05144 numeric_value =
05145 section_start_value + (rep_count - 1)*section_inc_value;
05146
05147 IL_FLD(end_il_idx) = CN_Tbl_Idx;
05148 IL_IDX(end_il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
05149 numeric_value);
05150 IL_LINE_NUM(end_il_idx) = stmt_start_line;
05151 IL_COL_NUM(end_il_idx) = stmt_start_col;
05152
05153 IL_FLD(inc_il_idx) = CN_Tbl_Idx;
05154 IL_IDX(inc_il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
05155 section_inc_value);
05156 IL_LINE_NUM(inc_il_idx) = stmt_start_line;
05157 IL_COL_NUM(inc_il_idx) = stmt_start_col;
05158 }
05159
05160
05161
05162
05163 NTR_IR_LIST_TBL(il_idx);
05164 IR_LIST_CNT_L(imp_do_ir_idx) = 1;
05165 IR_FLD_L(imp_do_ir_idx) = IL_Tbl_Idx;
05166 IR_IDX_L(imp_do_ir_idx) = il_idx;
05167
05168 copy_subtree(&IR_OPND_L(init_ir_idx), &opnd);
05169 COPY_OPND(IL_OPND(il_idx), opnd);
05170
05171 substring_ir_idx = IL_IDX(il_idx);
05172 IR_OPR(substring_ir_idx) = Substring_Opr;
05173 }
05174
05175 IR_OPR(IR_IDX_L(init_ir_idx)) = Substring_Opr;
05176
05177
05178
05179 numeric_value = original_start_val + value_length - 1;
05180 IL_IDX(original_end_il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
05181 numeric_value);
05182
05183
05184
05185
05186 il_idx = IL_NEXT_LIST_IDX(original_end_il_idx);
05187 IL_IDX(il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
05188 value_length);
05189
05190
05191
05192
05193 ++numeric_value;
05194
05195 il_idx = IR_IDX_R(substring_ir_idx);
05196 IL_IDX(il_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
05197 numeric_value);
05198
05199 il_idx = IL_NEXT_LIST_IDX(il_idx);
05200 IL_IDX(il_idx) = IL_IDX(IL_PREV_LIST_IDX(il_idx));
05201
05202 il_idx = IL_NEXT_LIST_IDX(il_idx);
05203 IL_IDX(il_idx) = CN_INTEGER_ONE_IDX;
05204
05205 if (rep_count > 1) {
05206
05207
05208
05209
05210 ir_idx = IR_IDX_L(substring_ir_idx);
05211
05212 while (IR_OPR(ir_idx) != Subscript_Opr) {
05213 ir_idx = IR_IDX_L(ir_idx);
05214 }
05215
05216 IL_FLD(IR_IDX_R(ir_idx)) = AT_Tbl_Idx;
05217 IL_IDX(IR_IDX_R(ir_idx)) = temp_idx;
05218 IL_LINE_NUM(IR_IDX_R(ir_idx)) = stmt_start_line;
05219 IL_COL_NUM(IR_IDX_R(ir_idx)) = stmt_start_col;
05220
05221 }
05222 }
05223 }
05224 }
05225 else {
05226
05227
05228
05229
05230 }
05231
05232 EXIT:
05233
05234 TRACE (Func_Exit, "adjust_char_value_len", NULL);
05235
05236 return;
05237
05238 }
05239
05240
05241
05242
05243
05244
05245
05246
05247
05248
05249
05250
05251
05252
05253
05254
05255
05256
05257
05258 static void fold_all_subscripts(opnd_type *opnd)
05259 {
05260 int attr_idx;
05261 expr_arg_type expr_desc;
05262 int i;
05263 int il_idx;
05264 int ir_idx;
05265 opnd_type local_opnd;
05266 opnd_type my_opnd;
05267
05268
05269 TRACE (Func_Entry, "fold_all_subscripts", NULL);
05270
05271 COPY_OPND(local_opnd, (*opnd));
05272
05273 expr_desc = init_exp_desc;
05274 expr_desc.type = Integer;
05275 expr_desc.type_idx = INTEGER_DEFAULT_TYPE;
05276 expr_desc.linear_type = INTEGER_DEFAULT_TYPE;
05277
05278 while (OPND_FLD(local_opnd) == IR_Tbl_Idx) {
05279
05280 ir_idx = OPND_IDX(local_opnd);
05281
05282 switch (IR_OPR(ir_idx)) {
05283
05284 case Subscript_Opr:
05285
05286 attr_idx = (IR_FLD_L(ir_idx) == AT_Tbl_Idx) ?
05287 IR_IDX_L(ir_idx) :
05288 IR_IDX_R(IR_IDX_L(ir_idx));
05289
05290 il_idx = IR_IDX_R(ir_idx);
05291
05292 for (i = 1; i <= IR_LIST_CNT_R(ir_idx); ++i) {
05293
05294 # ifdef _F_MINUS_MINUS
05295 if (IL_PE_SUBSCRIPT(il_idx)) {
05296 continue;
05297 }
05298 # endif
05299
05300 if (IL_FLD(il_idx) == IR_Tbl_Idx) {
05301 COPY_OPND(my_opnd, IL_OPND(il_idx));
05302 fold_all_subscripts(&my_opnd);
05303
05304 if (IL_FLD(il_idx) == IR_Tbl_Idx) {
05305
05306 if (fold_aggragate_expression(&my_opnd,
05307 &expr_desc,
05308 TRUE)) {
05309 COPY_OPND(IL_OPND(il_idx), my_opnd);
05310 }
05311 else {
05312 PRINTMSG(IR_LINE_NUM(IL_IDX(il_idx)),
05313 861,
05314 Internal,
05315 IR_COL_NUM(IL_IDX(il_idx)),
05316 "object semantics");
05317 }
05318 }
05319 }
05320
05321 if (fold_relationals(IL_IDX(il_idx),
05322 BD_LB_IDX(ATD_ARRAY_IDX(attr_idx), i),
05323 Lt_Opr)) {
05324 PRINTMSG(IL_LINE_NUM(il_idx),
05325 831,
05326 Error,
05327 IL_COL_NUM(il_idx));
05328 }
05329
05330 if (fold_relationals(IL_IDX(il_idx),
05331 BD_UB_IDX(ATD_ARRAY_IDX(attr_idx), i),
05332 Gt_Opr)) {
05333 PRINTMSG(IL_LINE_NUM(il_idx),
05334 996,
05335 Error,
05336 IL_COL_NUM(il_idx));
05337 }
05338
05339 il_idx = IL_NEXT_LIST_IDX(il_idx);
05340 }
05341
05342 COPY_OPND(local_opnd, IR_OPND_L(ir_idx));
05343
05344 break;
05345
05346 case Struct_Opr:
05347 case Whole_Substring_Opr:
05348 case Substring_Opr:
05349 COPY_OPND(local_opnd, IR_OPND_L(ir_idx));
05350 break;
05351
05352 default:
05353 goto EXIT;
05354 }
05355 }
05356
05357 EXIT:
05358
05359 TRACE (Func_Exit, "fold_all_subscripts", NULL);
05360
05361 return;
05362
05363 }
05364
05365
05366
05367
05368
05369
05370
05371
05372
05373
05374
05375
05376
05377
05378
05379
05380
05381
05382
05383 # if 0
05384
05385 static int reenter_const_as_hollerith(int value_idx,
05386 int offset,
05387 int type_idx,
05388 holler_type hollerith_type)
05389
05390 {
05391 int cn_idx;
05392 long64 i;
05393 long64 words;
05394
05395 TRACE (Func_Entry, "reenter_const_as_hollerith", NULL);
05396
05397 cn_idx = ntr_const_tbl(type_idx,
05398 (TYP_TYPE(type_idx) == Character ? TRUE : FALSE),
05399 NULL);
05400
05401 if (TYP_TYPE(type_idx) == Typeless) {
05402 words = TARGET_BITS_TO_WORDS(TYP_BIT_LEN(type_idx));
05403 }
05404 else if (TYP_TYPE(type_idx) == Character) {
05405 words = TARGET_BYTES_TO_WORDS(CN_INT_TO_C(TYP_IDX(type_idx)));
05406 }
05407
05408 for (i = 0; i < words; i++) {
05409 CP_CONSTANT(CN_POOL_IDX(cn_idx) + i) =
05410 CP_CONSTANT(CN_POOL_IDX(value_idx) + offset + i);
05411 }
05412
05413 CN_HOLLERITH_TYPE(cn_idx) = hollerith_type;
05414
05415 TRACE (Func_Exit, "reenter_const_as_hollerith", NULL);
05416
05417 return(cn_idx);
05418
05419 }
05420
05421 # endif
05422
05423
05424
05425
05426
05427
05428
05429
05430
05431
05432
05433
05434
05435
05436
05437
05438
05439
05440 void data_repeat_semantics(int repeat_ir_idx)
05441
05442 {
05443 int column;
05444 expr_arg_type expr_desc;
05445 int line;
05446 int ok = TRUE;
05447 opnd_type opnd;
05448 int save_attr = NULL_IDX;
05449 expr_mode_type save_expr_mode = expr_mode;
05450
05451
05452 TRACE (Func_Entry, "data_repeat_semantics", NULL);
05453
05454 COPY_OPND(opnd, IR_OPND_L(repeat_ir_idx));
05455
05456 expr_desc.rank = 0;
05457 xref_state = CIF_Symbol_Reference;
05458
05459
05460
05461 expr_mode = Initialization_Expr;
05462
05463 switch (OPND_FLD(opnd)) {
05464
05465 case IR_Tbl_Idx:
05466
05467 if (IR_OPR(OPND_IDX(opnd)) == Paren_Opr) {
05468
05469 if (IR_FLD_L(OPND_IDX(opnd)) == AT_Tbl_Idx &&
05470 AT_OBJ_CLASS(IR_IDX_L(OPND_IDX(opnd))) == Data_Obj) {
05471 save_attr = IR_IDX_L(OPND_IDX(opnd));
05472 ATD_PARENT_OBJECT(save_attr) = TRUE;
05473 }
05474 }
05475 break;
05476
05477 case AT_Tbl_Idx:
05478
05479 if (AT_OBJ_CLASS(OPND_IDX(opnd)) == Data_Obj) {
05480 save_attr = OPND_IDX(opnd);
05481 ATD_PARENT_OBJECT(save_attr) = TRUE;
05482 }
05483 }
05484
05485
05486 if (expr_semantics(&opnd, &expr_desc)) {
05487 find_opnd_line_and_column(&opnd, &line, &column);
05488
05489
05490
05491
05492 switch (OPND_FLD(opnd)) {
05493 case CN_Tbl_Idx:
05494 break;
05495
05496 case AT_Tbl_Idx:
05497 ok = FALSE;
05498 PRINTMSG(line, 677, Error, column);
05499 break;
05500
05501 default:
05502 ok = FALSE;
05503 PRINTMSG(line, 678, Error, column);
05504 break;
05505 }
05506
05507 if (!ok) {
05508
05509
05510
05511 }
05512 else if (expr_desc.type != Integer && expr_desc.type != Typeless) {
05513 PRINTMSG(line, 678, Error, column);
05514 }
05515 else if (expr_desc.linear_type == Long_Typeless) {
05516 PRINTMSG(line, 1133, Error, column);
05517 }
05518 else if (expr_desc.rank > 0) {
05519 PRINTMSG(line, 678, Error, column);
05520 }
05521 else if (expr_desc.linear_type == Short_Typeless_Const) {
05522 OPND_IDX(opnd) = cast_typeless_constant(OPND_IDX(opnd),
05523 INTEGER_DEFAULT_TYPE,
05524 line,
05525 column);
05526 }
05527 }
05528
05529 COPY_OPND(IR_OPND_L(repeat_ir_idx), opnd);
05530
05531 expr_mode = save_expr_mode;
05532
05533 if (save_attr != NULL_IDX) {
05534 ATD_PARENT_OBJECT(save_attr) = FALSE;
05535 }
05536
05537 TRACE (Func_Exit, "data_repeat_semantics", NULL);
05538
05539 return;
05540
05541 }
05542
05543
05544
05545
05546
05547
05548
05549
05550
05551
05552
05553
05554
05555
05556
05557
05558
05559
05560 void constant_value_semantics(opnd_type *opnd,
05561 int uopr_ir_idx)
05562
05563 {
05564 #ifdef KEY
05565 int boz_const_col_num = 0;
05566 #else
05567 int boz_const_col_num;
05568 #endif
05569 int boz_const_line_num = 0;
05570 int column;
05571 expr_arg_type expr_desc;
05572 boolean have_null = FALSE;
05573 int line;
05574 int save_attr = NULL_IDX;
05575 expr_mode_type save_expr_mode = expr_mode;
05576
05577
05578 TRACE (Func_Entry, "constant_value_semantics", NULL);
05579
05580 switch (OPND_FLD((*opnd))) {
05581 case IR_Tbl_Idx:
05582 find_opnd_line_and_column(opnd, &line, &column);
05583
05584 if (IR_OPR(OPND_IDX((*opnd))) == Call_Opr &&
05585 AT_IS_INTRIN(IR_IDX_L(OPND_IDX((*opnd)))) &&
05586 strcmp(AT_OBJ_NAME_PTR(IR_IDX_L(OPND_IDX((*opnd)))), "NULL") == 0) {
05587 have_null = TRUE;
05588
05589 if (IR_IDX_R(OPND_IDX((*opnd))) != NULL_IDX) {
05590 PRINTMSG(line, 1573, Error, column);
05591 IR_OPND_R(OPND_IDX((*opnd))) = null_opnd;
05592 }
05593 }
05594
05595 if (IR_OPR(OPND_IDX((*opnd))) == Paren_Opr) {
05596
05597 if (IR_FLD_L(OPND_IDX((*opnd))) == AT_Tbl_Idx &&
05598 AT_OBJ_CLASS(IR_IDX_L(OPND_IDX((*opnd)))) == Data_Obj) {
05599 save_attr = IR_IDX_L(OPND_IDX((*opnd)));
05600 ATD_PARENT_OBJECT(save_attr) = TRUE;
05601 }
05602 }
05603
05604 if (uopr_ir_idx != NULL_IDX) {
05605
05606
05607
05608
05609
05610
05611
05612 boz_const_line_num = line;
05613 boz_const_col_num = column;
05614
05615 COPY_OPND(IR_OPND_L(uopr_ir_idx), (*opnd));
05616 OPND_FLD((*opnd)) = IR_Tbl_Idx;
05617 OPND_IDX((*opnd)) = uopr_ir_idx;
05618 }
05619 break;
05620
05621 case AT_Tbl_Idx:
05622
05623 if (AT_OBJ_CLASS(OPND_IDX((*opnd))) == Data_Obj) {
05624 save_attr = OPND_IDX((*opnd));
05625 ATD_PARENT_OBJECT(save_attr) = TRUE;
05626 }
05627
05628 if (uopr_ir_idx != NULL_IDX) {
05629 PRINTMSG(IR_LINE_NUM(uopr_ir_idx), 958, Error,
05630 IR_COL_NUM(uopr_ir_idx));
05631 }
05632 break;
05633
05634 case CN_Tbl_Idx:
05635
05636 if (uopr_ir_idx != NULL_IDX) {
05637
05638 if (CN_BOZ_CONSTANT(OPND_IDX((*opnd)))) {
05639 PRINTMSG(IR_LINE_NUM(uopr_ir_idx), 957, Ansi,
05640 IR_COL_NUM(uopr_ir_idx));
05641 }
05642 else if (TYP_TYPE(CN_TYPE_IDX(OPND_IDX((*opnd)))) != Integer &&
05643 TYP_TYPE(CN_TYPE_IDX(OPND_IDX((*opnd)))) != Real &&
05644 ! CN_BOOLEAN_CONSTANT(OPND_IDX((*opnd)))) {
05645
05646
05647
05648 PRINTMSG(IR_LINE_NUM(uopr_ir_idx), 958, Error,
05649 IR_COL_NUM(uopr_ir_idx));
05650 }
05651 COPY_OPND(IR_OPND_L(uopr_ir_idx), (*opnd));
05652 OPND_FLD((*opnd)) = IR_Tbl_Idx;
05653 OPND_IDX((*opnd)) = uopr_ir_idx;
05654 }
05655 break;
05656 }
05657
05658
05659
05660 expr_desc.rank = 0;
05661 expr_mode = Initialization_Expr;
05662 xref_state = CIF_Symbol_Reference;
05663
05664
05665
05666
05667
05668 comp_gen_expr = TRUE;
05669
05670 if (expr_semantics(opnd, &expr_desc)) {
05671 find_opnd_line_and_column(opnd, &line, &column);
05672
05673 switch (OPND_FLD((*opnd))) {
05674 case CN_Tbl_Idx:
05675
05676 if (boz_const_line_num != 0) {
05677 OPND_LINE_NUM((*opnd)) = boz_const_line_num;
05678 OPND_COL_NUM((*opnd)) = boz_const_col_num;
05679 line = boz_const_line_num;
05680 column = boz_const_col_num;
05681 }
05682
05683 break;
05684
05685 case AT_Tbl_Idx:
05686
05687 if (AT_OBJ_CLASS(OPND_IDX((*opnd))) == Data_Obj &&
05688 ATD_CLASS(OPND_IDX((*opnd))) == Compiler_Tmp &&
05689 ATD_FLD(OPND_IDX((*opnd))) == CN_Tbl_Idx) {
05690
05691 if (!expr_desc.constant) {
05692 PRINTMSG(line, 906, Error, column);
05693 *opnd = null_opnd;
05694 }
05695 }
05696 else {
05697 PRINTMSG(line, 1101, Error, column);
05698 }
05699 break;
05700
05701 case IR_Tbl_Idx:
05702
05703 if (!have_null) {
05704 PRINTMSG(line, 1648, Error, column);
05705 *opnd = null_opnd;
05706 }
05707 break;
05708
05709 }
05710 }
05711
05712 if (save_attr != NULL_IDX) {
05713 ATD_PARENT_OBJECT(save_attr) = FALSE;
05714 }
05715
05716
05717
05718
05719 comp_gen_expr = FALSE;
05720 expr_mode = save_expr_mode;
05721
05722 TRACE (Func_Exit, "constant_value_semantics", NULL);
05723
05724 return;
05725
05726 }