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 static char USMID[] = "\n@(#)5.0_pl/sources/s_utils.c 5.12 10/19/99 17:14:30\n";
00046
00047
00048 # include "defines.h"
00049
00050 # include "host.m"
00051 # include "host.h"
00052 # include "target.m"
00053 # include "target.h"
00054
00055 # include "globals.m"
00056 # include "tokens.m"
00057 # include "sytb.m"
00058 # include "s_globals.m"
00059 # include "debug.m"
00060 # include "s_utils.m"
00061
00062 # include "globals.h"
00063 # include "tokens.h"
00064 # include "sytb.h"
00065 # include "s_globals.h"
00066
00067 # if defined(_HOST_OS_UNICOS) && defined(_TARGET_OS_UNICOS)
00068 # include <fortran.h>
00069 # endif
00070 #ifdef KEY
00071
00072
00073
00074 #include "i_cvrt.h"
00075 #endif
00076
00077
00078
00079
00080
00081
00082 static int opr_to_str(operator_type, char *);
00083 static int create_dv_type_code(int);
00084 static long64 create_imp_do_loops(opnd_type *);
00085 static void just_find_dope_and_rank(opnd_type *, int *, int *);
00086 static void compute_char_element_len(opnd_type *,
00087 opnd_type *, opnd_type *);
00088 static void gen_conform_check_call(opnd_type *, opnd_type *, int, int, int);
00089 static void gen_bounds_check_call(char *, opnd_type *, opnd_type *,
00090 opnd_type *, int, int, int);
00091 static void gen_rbounds_check_call(char *, opnd_type *, opnd_type *,
00092 opnd_type *, opnd_type *,
00093 opnd_type *, int, int, int);
00094 static void gen_sbounds_check_call(char *, opnd_type *, opnd_type *,
00095 opnd_type *, int, int);
00096 static void gen_ptr_chk_call(char *, int, opnd_type *, int, int);
00097 static int put_file_name_in_cn(int);
00098 static int put_c_str_in_cn(char *);
00099 static void gen_dv_def_loops(opnd_type *);
00100 static void gen_init_stmt(opnd_type *, int, sh_position_type);
00101 static void reshape_reference_subscripts(opnd_type *);
00102 static void gen_dv_stride_mult(opnd_type *, int, opnd_type *,
00103 expr_arg_type *, int, int, int);
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 boolean resolve_ext_opr(opnd_type *opnd,
00122 boolean issue_msg,
00123 boolean save_in_call_list,
00124 boolean err_res,
00125 boolean *semantically_correct,
00126 expr_arg_type *exp_desc_l,
00127 expr_arg_type *exp_desc_r)
00128
00129 {
00130 opnd_type arg_1_opnd;
00131 opnd_type arg_2_opnd;
00132 int arg_idx;
00133 int attr_idx;
00134 int col;
00135 int darg_idx;
00136
00137 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
00138 int false_list_idx = NULL_IDX;
00139 # endif
00140
00141 boolean found = FALSE;
00142 int gen_idx = NULL_IDX;
00143 int i;
00144 int idx;
00145 int info_idx;
00146 int ir_idx;
00147 boolean is_function = TRUE;
00148 int len;
00149 int line;
00150 int list_idx;
00151 int list1_idx;
00152 int list2_idx;
00153 int loc_idx;
00154 int name_idx;
00155 int num_args;
00156 boolean ok = TRUE;
00157 int opnd_column;
00158 int opnd_line;
00159 int rslt_idx;
00160 int save_arg_info_list_base;
00161 int save_curr_stmt_sh_idx;
00162 int save_defer_stmt_expansion;
00163 int spec_idx = NULL_IDX;
00164 int sn_idx = NULL_IDX;
00165 char str_word[32];
00166 opnd_type tmp_opnd;
00167 char type_str_l[45];
00168 char type_str_r[45];
00169
00170
00171 TRACE (Func_Entry, "resolve_ext_opr", NULL);
00172
00173
00174
00175 if (max_call_list_size >= arg_list_size) {
00176 enlarge_call_list_tables();
00177 }
00178
00179 save_arg_info_list_base = arg_info_list_base;
00180 arg_info_list_base = arg_info_list_top;
00181 arg_info_list_top = arg_info_list_base + 2;
00182
00183 if (arg_info_list_top >= arg_info_list_size) {
00184 enlarge_info_list_table();
00185 }
00186
00187 ir_idx = OPND_IDX((*opnd));
00188 line = IR_LINE_NUM(ir_idx);
00189 col = IR_COL_NUM(ir_idx);
00190
00191 if (IR_OPR(ir_idx) == Defined_Bin_Opr) {
00192
00193 gen_idx = IR_IDX_L(ir_idx);
00194 strncpy(str_word, AT_OBJ_NAME_PTR(gen_idx), AT_NAME_LEN(gen_idx));
00195 str_word[AT_NAME_LEN(gen_idx)] = '\0';
00196 num_args = 2;
00197 COPY_OPND(arg_1_opnd, IL_OPND(IR_IDX_R(ir_idx)));
00198 COPY_OPND(arg_2_opnd, IL_OPND(IL_NEXT_LIST_IDX(IR_IDX_R(ir_idx))));
00199
00200 if (cif_flags & XREF_RECS) {
00201 cif_usage_rec(gen_idx, AT_Tbl_Idx, line, col, CIF_Symbol_Reference);
00202 }
00203 }
00204 else if (IR_OPR(ir_idx) == Defined_Un_Opr) {
00205 gen_idx = IR_IDX_L(ir_idx);
00206 strncpy(str_word, AT_OBJ_NAME_PTR(gen_idx), AT_NAME_LEN(gen_idx));
00207 str_word[AT_NAME_LEN(gen_idx)] = '\0';
00208 num_args = 1;
00209 COPY_OPND(arg_1_opnd, IR_OPND_R(ir_idx));
00210
00211 if (cif_flags & XREF_RECS) {
00212 cif_usage_rec(gen_idx, AT_Tbl_Idx, line, col, CIF_Symbol_Reference);
00213 }
00214 }
00215 else {
00216 len = opr_to_str(IR_OPR(ir_idx), str_word);
00217 gen_idx = srch_sym_tbl(str_word, len, &name_idx);
00218
00219 if (gen_idx == NULL_IDX) {
00220 gen_idx = srch_host_sym_tbl(str_word, len, &name_idx, TRUE);
00221 }
00222
00223 COPY_OPND(arg_1_opnd, IR_OPND_L(ir_idx));
00224
00225 if (IR_FLD_R(ir_idx) == NO_Tbl_Idx) {
00226 num_args = 1;
00227 }
00228 else {
00229 num_args = 2;
00230 COPY_OPND(arg_2_opnd, IR_OPND_R(ir_idx));
00231 }
00232 }
00233
00234 if (IR_OPR(ir_idx) == Asg_Opr) {
00235 is_function = FALSE;
00236 }
00237
00238 if (gen_idx == NULL_IDX ||
00239 AT_OBJ_CLASS(gen_idx) != Interface) {
00240 gen_idx = NULL_IDX;
00241 goto EXIT;
00242 }
00243
00244 for (i = 0; i < ATI_NUM_SPECIFICS(gen_idx); i++) {
00245
00246 sn_idx = (sn_idx == NULL_IDX) ? ATI_FIRST_SPECIFIC_IDX(gen_idx) :
00247 SN_SIBLING_LINK(sn_idx);
00248 spec_idx = SN_ATTR_IDX(sn_idx);
00249
00250
00251
00252 if (ATP_EXTRA_DARG(spec_idx)) {
00253
00254 if (num_args != ATP_NUM_DARGS(spec_idx) - 1) {
00255 continue;
00256 }
00257
00258 darg_idx = SN_ATTR_IDX(ATP_FIRST_IDX(spec_idx) + 1);
00259 }
00260 else {
00261
00262 if (num_args != ATP_NUM_DARGS(spec_idx)) {
00263 continue;
00264 }
00265
00266 darg_idx = SN_ATTR_IDX(ATP_FIRST_IDX(spec_idx));
00267 }
00268
00269
00270
00271 if (darg_idx == NULL_IDX) {
00272 continue;
00273 }
00274
00275 if (AT_OBJ_CLASS(darg_idx) == Data_Obj) {
00276
00277 if (ATD_IGNORE_TKR(darg_idx)) {
00278
00279
00280
00281 }
00282 else if (OPND_FLD(arg_1_opnd) == IR_Tbl_Idx &&
00283 IR_OPR(OPND_IDX(arg_1_opnd)) == Null_Intrinsic_Opr) {
00284
00285
00286 }
00287 else if (TYP_TYPE(ATD_TYPE_IDX(darg_idx)) != exp_desc_l->type) {
00288 continue;
00289 }
00290 else if (exp_desc_l->type == Structure) {
00291
00292 if (!compare_derived_types(exp_desc_l->type_idx,
00293 ATD_TYPE_IDX(darg_idx))) {
00294 continue;
00295 }
00296 }
00297 else if (exp_desc_l->type != Character &&
00298 TYP_LINEAR(ATD_TYPE_IDX(darg_idx)) != exp_desc_l->linear_type) {
00299 continue;
00300 }
00301
00302 if (ATD_IGNORE_TKR(darg_idx)) {
00303
00304
00305
00306 }
00307 else if (OPND_FLD(arg_1_opnd) == IR_Tbl_Idx &&
00308 IR_OPR(OPND_IDX(arg_1_opnd)) == Null_Intrinsic_Opr) {
00309
00310
00311 }
00312 else if (ATP_ELEMENTAL(spec_idx)) {
00313
00314 }
00315 else if (ATD_ARRAY_IDX(darg_idx) == NULL_IDX) {
00316
00317 if (exp_desc_l->rank) {
00318 continue;
00319 }
00320 }
00321 else {
00322
00323 if (BD_RANK(ATD_ARRAY_IDX(darg_idx)) != exp_desc_l->rank) {
00324 continue;
00325 }
00326 }
00327 }
00328 else if (AT_OBJ_CLASS(darg_idx) == Pgm_Unit) {
00329
00330 }
00331
00332 if (num_args == 2) {
00333 if (ATP_EXTRA_DARG(spec_idx)) {
00334 darg_idx = SN_ATTR_IDX(ATP_FIRST_IDX(spec_idx) + 2);
00335 }
00336 else {
00337 darg_idx = SN_ATTR_IDX(ATP_FIRST_IDX(spec_idx) + 1);
00338 }
00339
00340
00341 if (darg_idx == NULL_IDX) {
00342 continue;
00343 }
00344
00345 if (AT_OBJ_CLASS(darg_idx) == Data_Obj) {
00346
00347 if (ATD_IGNORE_TKR(darg_idx)) {
00348
00349
00350
00351 }
00352 else if (OPND_FLD(arg_2_opnd) == IR_Tbl_Idx &&
00353 IR_OPR(OPND_IDX(arg_2_opnd)) == Null_Intrinsic_Opr) {
00354
00355
00356 }
00357 else if (TYP_TYPE(ATD_TYPE_IDX(darg_idx)) != exp_desc_r->type) {
00358 continue;
00359 }
00360 else if (exp_desc_r->type == Structure) {
00361
00362 if (!compare_derived_types(exp_desc_r->type_idx,
00363 ATD_TYPE_IDX(darg_idx))) {
00364 continue;
00365 }
00366 }
00367 else if (exp_desc_r->type != Character &&
00368 TYP_LINEAR(ATD_TYPE_IDX(darg_idx)) != exp_desc_r->linear_type) {
00369 continue;
00370 }
00371
00372 if (ATD_IGNORE_TKR(darg_idx)) {
00373
00374
00375
00376 }
00377 else if (OPND_FLD(arg_2_opnd) == IR_Tbl_Idx &&
00378 IR_OPR(OPND_IDX(arg_2_opnd)) == Null_Intrinsic_Opr) {
00379
00380
00381 }
00382 else if (ATP_ELEMENTAL(spec_idx)) {
00383
00384 }
00385 else if (ATD_ARRAY_IDX(darg_idx) == NULL_IDX) {
00386
00387 if (exp_desc_r->rank) {
00388 continue;
00389 }
00390 }
00391 else {
00392
00393 if (BD_RANK(ATD_ARRAY_IDX(darg_idx)) != exp_desc_r->rank) {
00394 continue;
00395 }
00396 }
00397 }
00398 else if (AT_OBJ_CLASS(darg_idx) == Pgm_Unit) {
00399
00400 }
00401 }
00402
00403
00404
00405
00406
00407
00408 if (cif_flags & XREF_RECS &&
00409 IR_OPR(ir_idx) != Defined_Bin_Opr &&
00410 IR_OPR(ir_idx) != Defined_Un_Opr) {
00411
00412 cif_usage_rec(gen_idx, AT_Tbl_Idx, line, col, CIF_Symbol_Reference);
00413 }
00414
00415 if (ATP_SCP_IDX(spec_idx) != curr_scp_idx || AT_NOT_VISIBLE(spec_idx)) {
00416
00417
00418
00419
00420
00421 attr_idx = srch_sym_tbl(AT_OBJ_NAME_PTR(spec_idx),
00422 AT_NAME_LEN(spec_idx),
00423 &name_idx);
00424
00425 if (attr_idx != spec_idx) {
00426
00427
00428
00429
00430
00431 ADD_ATTR_TO_LOCAL_LIST(spec_idx);
00432 }
00433 }
00434
00435 AT_REFERENCED(spec_idx) = Referenced;
00436
00437 if (exp_desc_l->reference &&
00438 (cif_flags & XREF_RECS) != 0 &&
00439 xref_state != CIF_No_Usage_Rec) {
00440
00441 COPY_OPND(tmp_opnd, arg_1_opnd);
00442
00443 while (OPND_FLD(tmp_opnd) == IR_Tbl_Idx &&
00444 IR_OPR(OPND_IDX(tmp_opnd)) != Struct_Opr) {
00445
00446 COPY_OPND(tmp_opnd, IR_OPND_L(OPND_IDX(tmp_opnd)));
00447 }
00448
00449 find_opnd_line_and_column(&tmp_opnd, &opnd_line, &opnd_column);
00450
00451 cif_usage_rec(OPND_IDX(tmp_opnd),
00452 OPND_FLD(tmp_opnd),
00453 opnd_line,
00454 opnd_column,
00455 CIF_Symbol_Defined_Opr_Actual_Arg);
00456 }
00457
00458 NTR_IR_LIST_TBL(list1_idx);
00459 IL_ARG_DESC_VARIANT(list1_idx) = TRUE;
00460 COPY_OPND(IL_OPND(list1_idx), arg_1_opnd);
00461
00462 info_idx = arg_info_list_base + 1;
00463 arg_info_list[info_idx] = init_arg_info;
00464 arg_info_list[info_idx].ed = *exp_desc_l;
00465 arg_info_list[info_idx].maybe_modified = TRUE;
00466 IL_ARG_DESC_IDX(list1_idx) = info_idx;
00467
00468 if (num_args == 2) {
00469
00470 if (exp_desc_r->reference &&
00471 (cif_flags & XREF_RECS) != 0 &&
00472 xref_state != CIF_No_Usage_Rec) {
00473
00474 COPY_OPND(tmp_opnd, arg_2_opnd);
00475
00476 while (OPND_FLD(tmp_opnd) == IR_Tbl_Idx &&
00477 IR_OPR(OPND_IDX(tmp_opnd)) != Struct_Opr) {
00478
00479 COPY_OPND(tmp_opnd, IR_OPND_L(OPND_IDX(tmp_opnd)));
00480 }
00481
00482 find_opnd_line_and_column(&tmp_opnd, &opnd_line, &opnd_column);
00483
00484 cif_usage_rec(OPND_IDX(tmp_opnd),
00485 OPND_FLD(tmp_opnd),
00486 opnd_line,
00487 opnd_column,
00488 CIF_Symbol_Defined_Opr_Actual_Arg);
00489 }
00490
00491
00492 NTR_IR_LIST_TBL(list2_idx);
00493 IL_ARG_DESC_VARIANT(list2_idx) = TRUE;
00494 COPY_OPND(IL_OPND(list2_idx), arg_2_opnd);
00495 IL_NEXT_LIST_IDX(list1_idx) = list2_idx;
00496
00497 info_idx++;
00498
00499 arg_info_list[info_idx] = init_arg_info;
00500 arg_info_list[info_idx].ed = *exp_desc_r;
00501 arg_info_list[info_idx].maybe_modified = TRUE;
00502 IL_ARG_DESC_IDX(list2_idx) = info_idx;
00503 }
00504
00505 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
00506 IR_IDX_L(ir_idx) = spec_idx;
00507 IR_LINE_NUM_L(ir_idx) = IR_LINE_NUM(ir_idx);
00508 IR_COL_NUM_L(ir_idx) = IR_COL_NUM(ir_idx);
00509 IR_FLD_R(ir_idx) = IL_Tbl_Idx;
00510 IR_IDX_R(ir_idx) = list1_idx;
00511 IR_LIST_CNT_R(ir_idx) = num_args;
00512 IR_OPR(ir_idx) = Call_Opr;
00513
00514
00515 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
00516
00517 if (defer_stmt_expansion) {
00518 number_of_functions++;
00519 }
00520
00521 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
00522
00523 SCP_HAS_CALLS(curr_scp_idx) = TRUE;
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545 if ((cif_flags & MISC_RECS) != 0 && xref_state != CIF_No_Usage_Rec) {
00546 cif_call_site_rec(ir_idx, gen_idx);
00547 }
00548
00549 if (AT_OBJ_CLASS(spec_idx) == Pgm_Unit &&
00550 ATP_SCP_ALIVE(spec_idx)) {
00551
00552 if (ATP_PGM_UNIT(spec_idx) == Function &&
00553 !ATP_RSLT_NAME(spec_idx)) {
00554 PRINTMSG(IR_LINE_NUM(ir_idx), 344, Ansi, IR_COL_NUM(ir_idx));
00555 }
00556
00557 if (!ATP_RECURSIVE(spec_idx) && !AT_DCL_ERR(spec_idx) &&
00558 !on_off_flags.recursive) {
00559 PRINTMSG(IR_LINE_NUM(ir_idx), 343, Error, IR_COL_NUM(ir_idx));
00560 *semantically_correct = FALSE;
00561 }
00562 }
00563
00564 if (AT_DCL_ERR(spec_idx)) {
00565
00566
00567 *semantically_correct = FALSE;
00568 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
00569 found = TRUE;
00570 goto EXIT;
00571 }
00572
00573 stmt_expansion_control_start();
00574 save_defer_stmt_expansion = defer_stmt_expansion;
00575 defer_stmt_expansion = FALSE;
00576
00577 if (is_function) {
00578
00579
00580
00581 in_call_list = save_in_call_list;
00582 rslt_idx = ATP_RSLT_IDX(spec_idx);
00583 (*exp_desc_l) = init_exp_desc;
00584
00585 exp_desc_l->type_idx = ATD_TYPE_IDX(rslt_idx);
00586 exp_desc_l->type = TYP_TYPE(exp_desc_l->type_idx);
00587 exp_desc_l->linear_type = TYP_LINEAR(exp_desc_l->type_idx);
00588 exp_desc_l->pointer = ATD_POINTER(rslt_idx);
00589 exp_desc_l->target = ATD_TARGET(rslt_idx);
00590 exp_desc_l->allocatable = ATD_ALLOCATABLE(rslt_idx);
00591 exp_desc_l->dope_vector = ATD_IM_A_DOPE(rslt_idx);
00592
00593 IR_TYPE_IDX(ir_idx) = ATD_TYPE_IDX(rslt_idx);
00594
00595 if (ATD_ARRAY_IDX(ATP_RSLT_IDX(spec_idx))) {
00596 exp_desc_l->assumed_shape =
00597 (BD_ARRAY_CLASS(ATD_ARRAY_IDX(rslt_idx)) == Assumed_Shape);
00598 exp_desc_l->assumed_size =
00599 (BD_ARRAY_CLASS(ATD_ARRAY_IDX(rslt_idx)) == Assumed_Size);
00600 exp_desc_l->rank = BD_RANK(ATD_ARRAY_IDX(rslt_idx));
00601 }
00602
00603
00604 if (!no_func_expansion) {
00605
00606 flatten_function_call(opnd);
00607
00608 if (ATP_ELEMENTAL(spec_idx)) {
00609
00610 attr_idx = find_base_attr(opnd, &line, &col);
00611 exp_desc_l->rank = BD_RANK(ATD_ARRAY_IDX(attr_idx));
00612 }
00613
00614
00615
00616
00617
00618
00619 if ((cif_flags & MISC_RECS) != 0 &&
00620 xref_state != CIF_No_Usage_Rec) {
00621 cif_object_rec_for_func_result(spec_idx);
00622 }
00623
00624 exp_desc_l->tmp_reference = TRUE;
00625
00626 if (exp_desc_l->type == Character ||
00627 exp_desc_l->rank) {
00628
00629 attr_idx = find_base_attr(opnd, &line, &col);
00630
00631 if (exp_desc_l->type == Character) {
00632 IR_TYPE_IDX(ir_idx) = ATD_TYPE_IDX(attr_idx);
00633 exp_desc_l->type_idx = ATD_TYPE_IDX(attr_idx);
00634 exp_desc_l->type = TYP_TYPE(exp_desc_l->type_idx);
00635 exp_desc_l->linear_type = TYP_LINEAR(exp_desc_l->type_idx);
00636 get_char_len(opnd, &(exp_desc_l->char_len));
00637 }
00638
00639 if (exp_desc_l->rank) {
00640 get_shape_from_attr(exp_desc_l,
00641 attr_idx,
00642 exp_desc_l->rank,
00643 line,
00644 col);
00645
00646 exp_desc_l->contig_array = TRUE;
00647 }
00648 }
00649 }
00650 else {
00651 set_shape_for_deferred_funcs(exp_desc_l, ir_idx);
00652 }
00653
00654 IR_TYPE_IDX(ir_idx) = exp_desc_l->type_idx;
00655 IR_RANK(ir_idx) = exp_desc_l->rank;
00656 }
00657
00658 if (!no_func_expansion) {
00659
00660 if (! is_function) {
00661
00662
00663 COPY_OPND(tmp_opnd, IR_OPND_R(ir_idx));
00664 ok = final_arg_work(&tmp_opnd, spec_idx, num_args, NULL) && ok;
00665 COPY_OPND(IR_OPND_R(ir_idx), tmp_opnd);
00666 }
00667
00668 if (ATP_PROC(spec_idx) != Dummy_Proc &&
00669 ATP_PROC(spec_idx) != Intrin_Proc &&
00670 ! ATP_VFUNCTION(spec_idx) &&
00671 (cmd_line_flags.runtime_argument ||
00672 cmd_line_flags.runtime_arg_call)) {
00673
00674 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
00675 list1_idx = IR_IDX_R(ir_idx);
00676 list2_idx = NULL_IDX;
00677
00678 idx = 0;
00679
00680 while (list1_idx) {
00681 if (IL_FLD(list1_idx) == IR_Tbl_Idx &&
00682 IR_OPR(IL_IDX(list1_idx)) == False_Parm_Opr) {
00683
00684 false_list_idx = list1_idx;
00685
00686 IL_NEXT_LIST_IDX(list2_idx) = NULL_IDX;
00687 break;
00688 }
00689
00690 list2_idx = list1_idx;
00691 list1_idx = IL_NEXT_LIST_IDX(list1_idx);
00692 idx++;
00693 }
00694
00695 IR_LIST_CNT_R(ir_idx) = idx;
00696 # endif
00697
00698 ATP_ARGCHCK_CALL(spec_idx) = TRUE;
00699
00700 NTR_IR_TBL(loc_idx);
00701 IR_OPR(loc_idx) = Aloc_Opr;
00702 IR_TYPE_IDX(loc_idx) = CRI_Ptr_8;
00703 IR_LINE_NUM(loc_idx) = line;
00704 IR_COL_NUM(loc_idx) = col;
00705 IR_FLD_L(loc_idx) = AT_Tbl_Idx;
00706
00707 OPND_FLD(tmp_opnd) = IR_Tbl_Idx;
00708 OPND_IDX(tmp_opnd) = ir_idx;
00709 idx = create_argchck_descriptor(&tmp_opnd);
00710 IR_IDX_L(loc_idx) = idx;
00711 IR_LINE_NUM_L(loc_idx) = line;
00712 IR_COL_NUM_L(loc_idx) = col;
00713
00714 NTR_IR_LIST_TBL(list2_idx);
00715 IL_ARG_DESC_VARIANT(list2_idx) = TRUE;
00716 IL_FLD(list2_idx) = IR_Tbl_Idx;
00717 IL_IDX(list2_idx) = loc_idx;
00718
00719 if (IR_LIST_CNT_R(ir_idx) == 0) {
00720 IR_FLD_R(ir_idx) = IL_Tbl_Idx;
00721 IR_IDX_R(ir_idx) = list2_idx;
00722 IR_LIST_CNT_R(ir_idx) = 1;
00723 }
00724 else {
00725 list1_idx = IR_IDX_R(ir_idx);
00726 while (IL_NEXT_LIST_IDX(list1_idx)) {
00727 list1_idx = IL_NEXT_LIST_IDX(list1_idx);
00728 }
00729
00730 IL_NEXT_LIST_IDX(list1_idx) = list2_idx;
00731 (IR_LIST_CNT_R(ir_idx))++;
00732 }
00733
00734 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
00735 if (false_list_idx != NULL_IDX) {
00736 IL_NEXT_LIST_IDX(list2_idx) = false_list_idx;
00737 list1_idx = false_list_idx;
00738 while (list1_idx) {
00739 (IR_LIST_CNT_R(ir_idx))++;
00740 list1_idx = IL_NEXT_LIST_IDX(list1_idx);
00741 }
00742 }
00743 # endif
00744 }
00745 }
00746
00747 defer_stmt_expansion = save_defer_stmt_expansion;
00748 stmt_expansion_control_end(opnd);
00749
00750 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
00751
00752 found = TRUE;
00753 break;
00754 }
00755
00756 EXIT:
00757
00758 if (ok && found && (ATP_PURE(SCP_ATTR_IDX(curr_scp_idx)) ||
00759 ATP_ELEMENTAL(SCP_ATTR_IDX(curr_scp_idx)))) {
00760
00761 if (ATP_PURE(SCP_ATTR_IDX(curr_scp_idx))) {
00762
00763 if (!ATP_PURE(spec_idx) && !ATP_ELEMENTAL(spec_idx)) {
00764 PRINTMSG(IR_LINE_NUM(ir_idx), 1274, Error, IR_COL_NUM(ir_idx),
00765 AT_OBJ_NAME_PTR(spec_idx),
00766 "pure or elemental",
00767 "pure");
00768
00769 }
00770 }
00771 else if (ATP_ELEMENTAL(SCP_ATTR_IDX(curr_scp_idx))) {
00772
00773 if (!ATP_PURE(spec_idx) && !ATP_ELEMENTAL(spec_idx)) {
00774 PRINTMSG(IR_LINE_NUM(ir_idx), 1274, Error, IR_COL_NUM(ir_idx),
00775 AT_OBJ_NAME_PTR(spec_idx),
00776 "pure or elemental",
00777 "elemental");
00778
00779 }
00780 }
00781
00782
00783
00784
00785 list_idx = IR_IDX_R(ir_idx);
00786
00787 if (ATP_EXTRA_DARG(spec_idx)) {
00788 arg_idx = ATP_FIRST_IDX(spec_idx) + 1;
00789 idx = ATP_NUM_DARGS(spec_idx) - 1;
00790 }
00791 else {
00792 arg_idx = ATP_FIRST_IDX(spec_idx);
00793 idx = ATP_NUM_DARGS(spec_idx);
00794 }
00795 for (;idx > 0; idx--) {
00796
00797 if (AT_OBJ_CLASS(SN_ATTR_IDX(arg_idx)) == Data_Obj &&
00798 (ATD_POINTER(SN_ATTR_IDX(arg_idx)) ||
00799 ATD_INTENT(SN_ATTR_IDX(arg_idx)) == Intent_Inout ||
00800 ATD_INTENT(SN_ATTR_IDX(arg_idx)) == Intent_Out)) {
00801 COPY_OPND(tmp_opnd, IL_OPND(list_idx));
00802 attr_idx = find_left_attr(&tmp_opnd);
00803
00804 if (AT_OBJ_CLASS(attr_idx) == Data_Obj && ATD_PURE(attr_idx)) {
00805 find_opnd_line_and_column((opnd_type *) &IL_OPND(list_idx),
00806 &opnd_line,
00807 &opnd_column);
00808 PRINTMSG(opnd_line, 1273, Error, opnd_column,
00809 AT_OBJ_NAME_PTR(attr_idx),
00810 AT_OBJ_NAME_PTR(SN_ATTR_IDX(arg_idx)),
00811 ATP_PURE(SCP_ATTR_IDX(curr_scp_idx))?"pure":"elemental");
00812 ok = FALSE;
00813
00814
00815 }
00816 }
00817 arg_idx++;
00818 list_idx = IL_NEXT_LIST_IDX(list_idx);
00819 }
00820 }
00821
00822 if (found) {
00823
00824
00825
00826
00827
00828 if (spec_idx == gen_idx && AT_NOT_VISIBLE(spec_idx)) {
00829 PRINTMSG(IR_LINE_NUM(ir_idx), 486, Error,
00830 IR_COL_NUM(ir_idx),
00831 AT_OBJ_NAME_PTR(spec_idx),
00832 AT_OBJ_NAME_PTR(AT_MODULE_IDX((spec_idx))));
00833 *semantically_correct = FALSE;
00834 }
00835
00836 switch (expr_mode) {
00837 case Restricted_Imp_Do_Expr:
00838 case Data_Stmt_Target_Expr:
00839 PRINTMSG(IR_LINE_NUM(ir_idx), 62, Error,
00840 IR_COL_NUM(ir_idx),
00841 str_word);
00842 *semantically_correct = FALSE;
00843 break;
00844
00845 case Specification_Expr:
00846 PRINTMSG(IR_LINE_NUM(ir_idx), 880, Error,
00847 IR_COL_NUM(ir_idx),
00848 str_word);
00849 *semantically_correct = FALSE;
00850 break;
00851
00852 case Stmt_Func_Expr:
00853 PRINTMSG(IR_LINE_NUM(ir_idx), 757, Error,
00854 IR_COL_NUM(ir_idx),
00855 str_word);
00856 *semantically_correct = FALSE;
00857 break;
00858 }
00859 }
00860 else if (issue_msg) {
00861
00862 if (gen_idx != NULL_IDX) {
00863 PRINTMSG(IR_LINE_NUM(ir_idx), 380, Error,
00864 IR_COL_NUM(ir_idx), str_word);
00865 *semantically_correct = FALSE;
00866 }
00867 else {
00868
00869 if (exp_desc_l->linear_type == Long_Typeless ||
00870 (num_args == 2 && exp_desc_r->linear_type == Long_Typeless)) {
00871
00872 if (exp_desc_l->linear_type == Long_Typeless) {
00873 find_opnd_line_and_column((opnd_type *) &IR_OPND_L(ir_idx),
00874 &opnd_line,
00875 &opnd_column);
00876 PRINTMSG(opnd_line, 1133, Error, opnd_column);
00877 *semantically_correct = FALSE;
00878 }
00879
00880 if (num_args == 2 &&
00881 exp_desc_r->linear_type == Long_Typeless) {
00882 find_opnd_line_and_column((opnd_type *) &IR_OPND_R(ir_idx),
00883 &opnd_line,
00884 &opnd_column);
00885 PRINTMSG(opnd_line, 1133, Error, opnd_column);
00886 *semantically_correct = FALSE;
00887 }
00888 }
00889 else if (! is_function) {
00890
00891 if (exp_desc_r->rank != exp_desc_l->rank && exp_desc_r->rank != 0) {
00892
00893
00894
00895 PRINTMSG(IR_LINE_NUM(ir_idx), 324, Error, IR_COL_NUM(ir_idx),
00896 exp_desc_r->rank, exp_desc_l->rank);
00897 *semantically_correct = FALSE;
00898 }
00899
00900 if (err_res) {
00901 strcpy(type_str_l, get_basic_type_str(exp_desc_l->type_idx));
00902 strcpy(type_str_r, get_basic_type_str(exp_desc_r->type_idx));
00903
00904 PRINTMSG(IR_LINE_NUM(ir_idx), 356, Error,
00905 IR_COL_NUM(ir_idx),
00906 type_str_r,
00907 type_str_l);
00908 *semantically_correct = FALSE;
00909 }
00910 }
00911 else if (expr_mode == Restricted_Imp_Do_Expr ||
00912 expr_mode == Data_Stmt_Target_Expr) {
00913
00914 PRINTMSG(IR_LINE_NUM(ir_idx), 62, Error,
00915 IR_COL_NUM(ir_idx), str_word);
00916 *semantically_correct = FALSE;
00917 }
00918 else if (num_args == 1) {
00919
00920 PRINTMSG(IR_LINE_NUM(ir_idx), 392, Error,
00921 IR_COL_NUM(ir_idx),
00922 get_basic_type_str(exp_desc_l->type_idx),
00923 str_word);
00924 *semantically_correct = FALSE;
00925 }
00926 else {
00927
00928
00929 if (exp_desc_r->rank != exp_desc_l->rank &&
00930 exp_desc_r->rank * exp_desc_l->rank != 0) {
00931
00932
00933
00934 PRINTMSG(IR_LINE_NUM(ir_idx), 302, Error, IR_COL_NUM(ir_idx),
00935 exp_desc_l->rank, exp_desc_r->rank, str_word);
00936 *semantically_correct = FALSE;
00937 }
00938
00939 if (err_res) {
00940
00941 #ifdef KEY
00942
00943
00944
00945
00946 if (!((Eq_Opr == IR_OPR(ir_idx) || Ne_Opr == IR_OPR(ir_idx)) &&
00947 eq_ne_on_logical(0, exp_desc_l, exp_desc_r))) {
00948 #endif
00949
00950 strcpy(type_str_l, get_basic_type_str(exp_desc_l->type_idx));
00951 strcpy(type_str_r, get_basic_type_str(exp_desc_r->type_idx));
00952
00953 PRINTMSG(IR_LINE_NUM(ir_idx), 303, Error,
00954 IR_COL_NUM(ir_idx),
00955 type_str_l,
00956 type_str_r,
00957 str_word);
00958 *semantically_correct = FALSE;
00959 #ifdef KEY
00960 }
00961 #endif
00962 }
00963 }
00964 }
00965 }
00966
00967 if (*semantically_correct &&
00968 found &&
00969 ATP_PROC(spec_idx) != Intrin_Proc) {
00970
00971 #ifdef KEY
00972
00973 if (! (ATP_PURE(spec_idx) || ATP_ELEMENTAL(spec_idx)))
00974 #else
00975 if (! ATP_PURE(spec_idx))
00976 #endif
00977 {
00978 if (within_forall_mask_expr) {
00979 PRINTMSG(IR_LINE_NUM(ir_idx), 1611, Error, IR_COL_NUM(ir_idx),
00980 AT_OBJ_NAME_PTR(spec_idx),
00981 "forall scalar-mask-expr");
00982 *semantically_correct = FALSE;
00983 }
00984 else if (within_forall_construct) {
00985 PRINTMSG(IR_LINE_NUM(ir_idx), 1611, Error, IR_COL_NUM(ir_idx),
00986 AT_OBJ_NAME_PTR(spec_idx),
00987 "forall-body-construct");
00988 *semantically_correct = FALSE;
00989 }
00990 }
00991 }
00992
00993 if (found) {
00994 PRINTMSG(IR_LINE_NUM(ir_idx), 399, Comment, IR_COL_NUM(ir_idx),
00995 str_word, AT_OBJ_NAME_PTR(spec_idx));
00996 }
00997
00998
00999
01000 arg_info_list_top = arg_info_list_base;
01001 arg_info_list_base = save_arg_info_list_base;
01002
01003 TRACE (Func_Exit, "resolve_ext_opr", NULL);
01004
01005 return(found);
01006
01007 }
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025 static int opr_to_str(operator_type opr,
01026 char *str)
01027
01028 {
01029 int i;
01030 int len = 0;
01031
01032 TRACE (Func_Entry, "opr_to_str", NULL);
01033
01034 for (i = 0; i < 8; i++) {
01035 str[i] = '\0';
01036 }
01037
01038 switch (opr) {
01039 case Uplus_Opr :
01040 strncpy(str, "+", 1);
01041 len = 1;
01042 break;
01043 case Uminus_Opr :
01044 strncpy(str, "-", 1);
01045 len = 1;
01046 break;
01047 case Power_Opr :
01048 strncpy(str, "**", 2);
01049 len = 2;
01050 break;
01051 case Mult_Opr :
01052 strncpy(str, "*", 1);
01053 len = 1;
01054 break;
01055 case Div_Opr :
01056 strncpy(str, "/", 1);
01057 len = 1;
01058 break;
01059 case Plus_Opr :
01060 strncpy(str, "+", 1);
01061 len = 1;
01062 break;
01063 case Minus_Opr :
01064 strncpy(str, "-", 1);
01065 len = 1;
01066 break;
01067 case Concat_Opr :
01068 strncpy(str, "//", 2);
01069 len = 2;
01070 break;
01071 case Eq_Opr :
01072 strncpy(str, "eq", 2);
01073 len = 2;
01074 break;
01075 case Ne_Opr :
01076 strncpy(str, "ne", 2);
01077 len = 2;
01078 break;
01079 case Lg_Opr :
01080 strncpy(str, "lg", 2);
01081 len = 2;
01082 break;
01083 case Lt_Opr :
01084 strncpy(str, "lt", 2);
01085 len = 2;
01086 break;
01087 case Le_Opr :
01088 strncpy(str, "le", 2);
01089 len = 2;
01090 break;
01091 case Gt_Opr :
01092 strncpy(str, "gt", 2);
01093 len = 2;
01094 break;
01095 case Ge_Opr :
01096 strncpy(str, "ge", 2);
01097 len = 2;
01098 break;
01099 case Not_Opr :
01100 strncpy(str, "not", 3);
01101 len = 3;
01102 break;
01103 case And_Opr :
01104 strncpy(str, "and", 3);
01105 len = 3;
01106 break;
01107 case Or_Opr :
01108 strncpy(str, "or", 2);
01109 len = 2;
01110 break;
01111 case Eqv_Opr :
01112 strncpy(str, "eqv", 3);
01113 len = 3;
01114 break;
01115 case Neqv_Opr :
01116 strncpy(str, "neqv", 4);
01117 len = 4;
01118 break;
01119 case Asg_Opr :
01120 strncpy(str, "=", 1);
01121 len = 1;
01122 break;
01123 }
01124
01125 TRACE (Func_Exit, "opr_to_str", NULL);
01126
01127 return(len);
01128
01129 }
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153 int find_base_attr(opnd_type *root_opnd,
01154 int *line,
01155 int *col)
01156
01157 {
01158 int attr_idx = NULL_IDX;
01159 opnd_type opnd;
01160
01161 TRACE (Func_Entry, "find_base_attr", NULL);
01162
01163 *line = 0;
01164 *col = 0;
01165
01166 COPY_OPND(opnd, (*root_opnd));
01167
01168 while (attr_idx == NULL_IDX) {
01169 switch (OPND_FLD(opnd)) {
01170 case AT_Tbl_Idx :
01171 attr_idx = OPND_IDX(opnd);
01172 *line = OPND_LINE_NUM(opnd);
01173 *col = OPND_COL_NUM(opnd);
01174 goto EXIT;
01175
01176 case IR_Tbl_Idx :
01177
01178 if (IR_OPR(OPND_IDX(opnd)) == Struct_Opr) {
01179 COPY_OPND(opnd, IR_OPND_R(OPND_IDX(opnd)));
01180 }
01181 else {
01182 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
01183 }
01184 break;
01185
01186 case CN_Tbl_Idx :
01187 *line = OPND_LINE_NUM(opnd);
01188 *col = OPND_COL_NUM(opnd);
01189 goto EXIT;
01190
01191 default :
01192 goto EXIT;
01193 }
01194 }
01195
01196 EXIT:
01197
01198 TRACE (Func_Exit, "find_base_attr", ((attr_idx == NULL_IDX) ? NULL :
01199 AT_OBJ_NAME_PTR(attr_idx)));
01200
01201 return(attr_idx);
01202
01203 }
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228 int find_left_attr(opnd_type *root_opnd)
01229
01230 {
01231 int attr_idx = NULL_IDX;
01232 opnd_type opnd;
01233
01234
01235 TRACE (Func_Entry, "find_left_attr", NULL);
01236
01237 COPY_OPND(opnd, (*root_opnd));
01238
01239 while (attr_idx == NULL_IDX) {
01240 switch (OPND_FLD(opnd)) {
01241 case AT_Tbl_Idx :
01242 attr_idx = OPND_IDX(opnd);
01243 goto EXIT;
01244
01245 case IR_Tbl_Idx :
01246
01247 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
01248 break;
01249
01250 default :
01251 goto EXIT;
01252 }
01253 }
01254
01255 EXIT:
01256
01257 TRACE (Func_Exit, "find_left_attr", NULL);
01258
01259 return(attr_idx);
01260
01261 }
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279 boolean cmp_ref_trees(opnd_type *opnd1,
01280 opnd_type *opnd2)
01281
01282 {
01283 int column;
01284 int line;
01285 int list1_idx;
01286 int list2_idx;
01287 boolean match = TRUE;
01288
01289
01290 TRACE (Func_Entry, "cmp_ref_trees", NULL);
01291
01292 if (OPND_FLD((*opnd1)) != OPND_FLD((*opnd2))) {
01293 match = FALSE;
01294 }
01295 else {
01296 switch(OPND_FLD((*opnd1))) {
01297 case NO_Tbl_Idx :
01298 match = TRUE;
01299 break;
01300
01301 case CN_Tbl_Idx :
01302 case AT_Tbl_Idx :
01303
01304 if (OPND_IDX((*opnd1)) == OPND_IDX((*opnd2))) {
01305 match = TRUE;
01306 }
01307 else {
01308 match = FALSE;
01309 }
01310 break;
01311
01312 case IL_Tbl_Idx :
01313
01314 if (OPND_LIST_CNT((*opnd1)) == OPND_LIST_CNT((*opnd2))) {
01315 list1_idx = OPND_IDX((*opnd1));
01316 list2_idx = OPND_IDX((*opnd2));
01317
01318 while (list1_idx != NULL_IDX && match) {
01319 match = cmp_ref_trees((opnd_type *)&IL_OPND(list1_idx),
01320 (opnd_type *)&IL_OPND(list2_idx));
01321 list1_idx = IL_NEXT_LIST_IDX(list1_idx);
01322 list2_idx = IL_NEXT_LIST_IDX(list2_idx);
01323 }
01324 }
01325 else {
01326 match = FALSE;
01327 }
01328 break;
01329
01330 case SH_Tbl_Idx :
01331 find_opnd_line_and_column(opnd1, &line, &column);
01332 PRINTMSG(line, 963, Internal, column);
01333 break;
01334
01335 case IR_Tbl_Idx :
01336
01337 if (IR_OPR(OPND_IDX((*opnd1))) == IR_OPR(OPND_IDX((*opnd2)))) {
01338 match = cmp_ref_trees((opnd_type*)&IR_OPND_L(OPND_IDX((*opnd1))),
01339 (opnd_type*)&IR_OPND_L(OPND_IDX((*opnd2))));
01340 match = match &&
01341 cmp_ref_trees((opnd_type *)&IR_OPND_R(OPND_IDX((*opnd1))),
01342 (opnd_type *)&IR_OPND_R(OPND_IDX((*opnd2))));
01343 }
01344 else {
01345 match = FALSE;
01346 }
01347 break;
01348 }
01349 }
01350
01351 TRACE (Func_Exit, "cmp_ref_trees", NULL);
01352
01353 return(match);
01354
01355 }
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373 void enlarge_call_list_tables(void)
01374
01375 {
01376 int new_size;
01377
01378 TRACE (Func_Entry, "enlarge_call_list_tables", NULL);
01379
01380
01381 new_size = ((max_call_list_size/CALL_LIST_TBL_INC) + 1)
01382 * CALL_LIST_TBL_INC;
01383
01384 if (arg_list_size == 0) {
01385
01386
01387
01388 MEM_ALLOC(arg_list, int, new_size);
01389
01390 }
01391 else {
01392
01393 MEM_REALLOC(arg_list, int, new_size);
01394
01395 }
01396
01397 arg_list_size = new_size;
01398
01399 TRACE (Func_Exit, "enlarge_call_list_tables", NULL);
01400
01401 return;
01402
01403 }
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421 void enlarge_info_list_table(void)
01422
01423 {
01424 int new_size;
01425
01426 TRACE (Func_Entry, "enlarge_info_list_table", NULL);
01427
01428
01429 new_size = arg_info_list_size + ((max_call_list_size/CALL_LIST_TBL_INC) + 1)
01430 * CALL_LIST_TBL_INC;
01431
01432 if (arg_info_list_size == 0) {
01433
01434
01435
01436 MEM_ALLOC(arg_info_list, arg_strct_type, new_size);
01437
01438 }
01439 else {
01440
01441 MEM_REALLOC(arg_info_list, arg_strct_type, new_size);
01442
01443 }
01444
01445 arg_info_list_size = new_size;
01446
01447 TRACE (Func_Exit, "enlarge_info_list_table", NULL);
01448
01449 return;
01450
01451 }
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469 void dope_vector_setup(opnd_type *r_opnd,
01470 expr_arg_type *exp_desc,
01471 opnd_type *l_opnd,
01472 boolean ptr_assign)
01473
01474 {
01475 act_arg_type a_type;
01476 int attr_idx = NULL_IDX;
01477 opnd_type base_opnd;
01478 int col;
01479 int dim = 1;
01480 int dope_idx = NULL_IDX;
01481 int dv_idx;
01482 int dv2_idx;
01483 int i;
01484 int line;
01485 int list_idx;
01486 int loc_idx;
01487 int max_idx;
01488 int mult_idx;
01489 opnd_type opnd;
01490 int opnd_column;
01491 int opnd_line;
01492 opnd_type r_dv_opnd;
01493 int rank_idx = NULL_IDX;
01494 int stride_idx;
01495 opnd_type stride_opnd;
01496 #ifdef KEY
01497 int subscript_idx = 0;
01498 #else
01499 int subscript_idx;
01500 #endif
01501 boolean whole_array;
01502
01503
01504 TRACE (Func_Entry, "dope_vector_setup", NULL);
01505
01506
01507
01508
01509 find_opnd_line_and_column(l_opnd, &opnd_line, &opnd_column);
01510
01511 # ifdef _DEBUG
01512
01513 if (OPND_FLD((*l_opnd)) != AT_Tbl_Idx &&
01514 (OPND_FLD((*l_opnd)) != IR_Tbl_Idx ||
01515 IR_OPR(OPND_IDX((*l_opnd))) != Struct_Opr)) {
01516 PRINTMSG(opnd_line, 624, Internal, opnd_column);
01517 }
01518 # endif
01519
01520
01521
01522
01523
01524 if (! ptr_assign) {
01525 NTR_IR_TBL(dv_idx);
01526 IR_OPR(dv_idx) = Dv_Set_Base_Addr;
01527 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01528 IR_LINE_NUM(dv_idx) = opnd_line;
01529 IR_COL_NUM(dv_idx) = opnd_column;
01530 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01531 NTR_IR_TBL(loc_idx);
01532 IR_OPR(loc_idx) = Loc_Opr;
01533
01534 if (exp_desc->type == Character) {
01535 IR_TYPE_IDX(loc_idx) = CRI_Ch_Ptr_8;
01536 }
01537 else {
01538 IR_TYPE_IDX(loc_idx) = CRI_Ptr_8;
01539 }
01540
01541 IR_LINE_NUM(loc_idx) = opnd_line;
01542 IR_COL_NUM(loc_idx) = opnd_column;
01543
01544 IR_FLD_R(dv_idx) = IR_Tbl_Idx;
01545 IR_IDX_R(dv_idx) = loc_idx;
01546
01547 if (exp_desc->rank == 0) {
01548 COPY_OPND(IR_OPND_L(loc_idx), (*r_opnd));
01549 just_find_dope_and_rank(r_opnd, &rank_idx, &dope_idx);
01550 }
01551 else {
01552 make_base_subtree(r_opnd, &base_opnd, &rank_idx, &dope_idx);
01553 COPY_OPND(IR_OPND_L(loc_idx), base_opnd);
01554 }
01555
01556 # ifdef _TRANSFORM_CHAR_SEQUENCE
01557 # ifdef _TARGET_OS_UNICOS
01558 if (exp_desc->type == Structure &&
01559 ATT_CHAR_SEQ(TYP_IDX(exp_desc->type_idx))) {
01560
01561 IR_TYPE_IDX(loc_idx) = CRI_Ch_Ptr_8;
01562 COPY_OPND(opnd, IR_OPND_L(loc_idx));
01563 transform_char_sequence_ref(&opnd, exp_desc->type_idx);
01564 COPY_OPND(IR_OPND_L(loc_idx), opnd);
01565 }
01566 # endif
01567 # endif
01568
01569 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01570 FALSE, FALSE, TRUE);
01571
01572 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01573 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01574
01575 }
01576 else {
01577 just_find_dope_and_rank(r_opnd, &rank_idx, &dope_idx);
01578 }
01579
01580
01581
01582
01583
01584
01585
01586 if (rank_idx != NULL_IDX) {
01587 attr_idx = find_base_attr(&IR_OPND_L(rank_idx), &line, &col);
01588
01589 if (ATD_IM_A_DOPE(attr_idx)) {
01590 COPY_OPND(r_dv_opnd, IR_OPND_L(IR_IDX_L(rank_idx)));
01591 }
01592 subscript_idx = IR_IDX_R(rank_idx);
01593 }
01594 else if (exp_desc->rank != 0) {
01595 attr_idx = find_base_attr(r_opnd, &line, &col);
01596
01597 if (ATD_IM_A_DOPE(attr_idx)) {
01598 COPY_OPND(r_dv_opnd, IR_OPND_L(OPND_IDX((*r_opnd))));
01599 }
01600 }
01601 else {
01602 find_opnd_line_and_column(r_opnd, &line, &col);
01603 }
01604
01605 if (exp_desc->rank > 0 &&
01606 ! exp_desc->section) {
01607
01608 whole_array = TRUE;
01609 }
01610 else {
01611 whole_array = FALSE;
01612 }
01613
01614
01615
01616
01617
01618 a_type = get_act_arg_type(exp_desc);
01619
01620 if (a_type == Array_Ptr ||
01621 a_type == Array_Tmp_Ptr ||
01622 a_type == Whole_Ass_Shape ||
01623 a_type == Dv_Contig_Section) {
01624
01625 NTR_IR_TBL(dv_idx);
01626 IR_OPR(dv_idx) = Dv_Set_A_Contig;
01627 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01628 IR_LINE_NUM(dv_idx) = opnd_line;
01629 IR_COL_NUM(dv_idx) = opnd_column;
01630 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01631
01632 NTR_IR_TBL(dv2_idx);
01633 IR_OPR(dv2_idx) = Dv_Access_A_Contig;
01634 IR_TYPE_IDX(dv2_idx) = CG_INTEGER_DEFAULT_TYPE;
01635 IR_LINE_NUM(dv2_idx) = opnd_line;
01636 IR_COL_NUM(dv2_idx) = opnd_column;
01637 COPY_OPND(IR_OPND_L(dv2_idx), IR_OPND_L(dope_idx));
01638 IR_FLD_R(dv_idx) = IR_Tbl_Idx;
01639 IR_IDX_R(dv_idx) = dv2_idx;
01640
01641 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01642 FALSE, FALSE, TRUE);
01643
01644 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01645 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01646
01647 }
01648 else if (a_type == Whole_Allocatable ||
01649 a_type == Whole_Tmp_Allocatable ||
01650 a_type == Whole_Sequence ||
01651 a_type == Whole_Tmp_Sequence ||
01652 a_type == Whole_Array_Constant ||
01653 a_type == Contig_Section) {
01654
01655 NTR_IR_TBL(dv_idx);
01656 IR_OPR(dv_idx) = Dv_Set_A_Contig;
01657 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01658 IR_LINE_NUM(dv_idx) = opnd_line;
01659 IR_COL_NUM(dv_idx) = opnd_column;
01660 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01661 IR_FLD_R(dv_idx) = CN_Tbl_Idx;
01662 IR_IDX_R(dv_idx) = CN_INTEGER_ONE_IDX;
01663 IR_LINE_NUM_R(dv_idx) = opnd_line;
01664 IR_COL_NUM_R(dv_idx) = opnd_column;
01665
01666 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01667 FALSE, FALSE, TRUE);
01668
01669 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01670 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01671 }
01672 else {
01673 NTR_IR_TBL(dv_idx);
01674 IR_OPR(dv_idx) = Dv_Set_A_Contig;
01675 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01676 IR_LINE_NUM(dv_idx) = opnd_line;
01677 IR_COL_NUM(dv_idx) = opnd_column;
01678 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01679 IR_FLD_R(dv_idx) = CN_Tbl_Idx;
01680 IR_IDX_R(dv_idx) = CN_INTEGER_ZERO_IDX;
01681 IR_LINE_NUM_R(dv_idx) = opnd_line;
01682 IR_COL_NUM_R(dv_idx) = opnd_column;
01683
01684 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01685 FALSE, FALSE, TRUE);
01686
01687 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01688 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01689 }
01690
01691
01692
01693
01694
01695 NTR_IR_TBL(dv_idx);
01696 IR_OPR(dv_idx) = Dv_Set_Assoc;
01697 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01698 IR_LINE_NUM(dv_idx) = opnd_line;
01699 IR_COL_NUM(dv_idx) = opnd_column;
01700 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01701 IR_FLD_R(dv_idx) = CN_Tbl_Idx;
01702 IR_IDX_R(dv_idx) = CN_INTEGER_ONE_IDX;
01703 IR_LINE_NUM_R(dv_idx) = opnd_line;
01704 IR_COL_NUM_R(dv_idx) = opnd_column;
01705
01706 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01707 FALSE, FALSE, TRUE);
01708
01709 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01710 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01711
01712
01713 for (i = 1; i <= exp_desc->rank; i++) {
01714
01715
01716
01717
01718
01719 NTR_IR_TBL(dv_idx);
01720 IR_OPR(dv_idx) = Dv_Set_Low_Bound;
01721 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01722 IR_LINE_NUM(dv_idx) = opnd_line;
01723 IR_COL_NUM(dv_idx) = opnd_column;
01724 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01725
01726 if (whole_array) {
01727
01728 if (ATD_IM_A_DOPE(attr_idx) &&
01729 BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) != Assumed_Shape) {
01730 NTR_IR_TBL(dv2_idx);
01731 IR_OPR(dv2_idx) = Dv_Access_Low_Bound;
01732 IR_TYPE_IDX(dv2_idx) = SA_INTEGER_DEFAULT_TYPE;
01733 IR_LINE_NUM(dv2_idx) = opnd_line;
01734 IR_COL_NUM(dv2_idx) = opnd_column;
01735 COPY_OPND(IR_OPND_L(dv2_idx), r_dv_opnd);
01736 IR_DV_DIM(dv2_idx) = i;
01737 IR_FLD_R(dv_idx) = IR_Tbl_Idx;
01738 IR_IDX_R(dv_idx) = dv2_idx;
01739 }
01740 else {
01741 IR_FLD_R(dv_idx) = BD_LB_FLD(ATD_ARRAY_IDX(attr_idx), i);
01742 IR_IDX_R(dv_idx) = BD_LB_IDX(ATD_ARRAY_IDX(attr_idx), i);
01743 IR_LINE_NUM_R(dv_idx) = opnd_line;
01744 IR_COL_NUM_R(dv_idx) = opnd_column;
01745
01746 if (IR_FLD_R(dv_idx) == AT_Tbl_Idx) {
01747 ADD_TMP_TO_SHARED_LIST(IR_IDX_R(dv_idx));
01748 }
01749 }
01750 }
01751 else {
01752
01753 IR_FLD_R(dv_idx) = CN_Tbl_Idx;
01754 IR_IDX_R(dv_idx) = CN_INTEGER_ONE_IDX;
01755 IR_LINE_NUM_R(dv_idx) = opnd_line;
01756 IR_COL_NUM_R(dv_idx) = opnd_column;
01757 }
01758
01759 IR_DV_DIM(dv_idx) = i;
01760
01761 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01762 FALSE, FALSE, TRUE);
01763
01764 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01765 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01766
01767
01768
01769
01770
01771
01772 NTR_IR_TBL(dv_idx);
01773 IR_OPR(dv_idx) = Dv_Set_Extent;
01774 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01775 IR_LINE_NUM(dv_idx) = opnd_line;
01776 IR_COL_NUM(dv_idx) = opnd_column;
01777 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01778
01779 NTR_IR_TBL(max_idx);
01780 IR_OPR(max_idx) = Max_Opr;
01781 IR_TYPE_IDX(max_idx) = CG_INTEGER_DEFAULT_TYPE;
01782 IR_LINE_NUM(max_idx) = opnd_line;
01783 IR_COL_NUM(max_idx) = opnd_column;
01784
01785 NTR_IR_LIST_TBL(list_idx);
01786 IR_FLD_L(max_idx) = IL_Tbl_Idx;
01787 IR_LIST_CNT_L(max_idx) = 2;
01788 IR_IDX_L(max_idx) = list_idx;
01789
01790 IL_FLD(list_idx) = CN_Tbl_Idx;
01791 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
01792 IL_LINE_NUM(list_idx) = opnd_line;
01793 IL_COL_NUM(list_idx) = opnd_column;
01794
01795 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
01796 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
01797 list_idx = IL_NEXT_LIST_IDX(list_idx);
01798
01799 COPY_OPND(IL_OPND(list_idx), exp_desc->shape[i-1]);
01800 IL_LINE_NUM(list_idx) = opnd_line;
01801 IL_COL_NUM(list_idx) = opnd_column;
01802
01803 IR_FLD_R(dv_idx) = IR_Tbl_Idx;
01804 IR_IDX_R(dv_idx) = max_idx;
01805
01806 IR_DV_DIM(dv_idx) = i;
01807
01808 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01809 FALSE, FALSE, TRUE);
01810
01811 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01812 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01813
01814
01815
01816
01817
01818 NTR_IR_TBL(dv_idx);
01819 IR_OPR(dv_idx) = Dv_Set_Stride_Mult;
01820 IR_TYPE_IDX(dv_idx) = SA_INTEGER_DEFAULT_TYPE;
01821 IR_LINE_NUM(dv_idx) = opnd_line;
01822 IR_COL_NUM(dv_idx) = opnd_column;
01823 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01824
01825 if (whole_array) {
01826
01827 gen_dv_stride_mult(&stride_opnd,
01828 attr_idx,
01829 &r_dv_opnd,
01830 exp_desc,
01831 i,
01832 opnd_line,
01833 opnd_column);
01834
01835 COPY_OPND(IR_OPND_R(dv_idx), stride_opnd);
01836 }
01837 else {
01838 while (IL_FLD(subscript_idx) != IR_Tbl_Idx ||
01839 IR_OPR(IL_IDX(subscript_idx)) != Triplet_Opr) {
01840 subscript_idx = IL_NEXT_LIST_IDX(subscript_idx);
01841 dim++;
01842 }
01843
01844 gen_dv_stride_mult(&stride_opnd,
01845 attr_idx,
01846 &r_dv_opnd,
01847 exp_desc,
01848 dim,
01849 opnd_line,
01850 opnd_column);
01851
01852 stride_idx = IL_NEXT_LIST_IDX(IL_NEXT_LIST_IDX(IR_IDX_L(
01853 IL_IDX(subscript_idx))));
01854 mult_idx = gen_ir(OPND_FLD(stride_opnd), OPND_IDX(stride_opnd),
01855 Mult_Opr, CG_INTEGER_DEFAULT_TYPE, opnd_line, opnd_column,
01856 IL_FLD(stride_idx), IL_IDX(stride_idx));
01857
01858 IR_FLD_R(dv_idx) = IR_Tbl_Idx;;
01859 IR_IDX_R(dv_idx) = mult_idx;
01860
01861 subscript_idx = IL_NEXT_LIST_IDX(subscript_idx);
01862 dim++;
01863 }
01864
01865 IR_DV_DIM(dv_idx) = i;
01866
01867 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01868 FALSE, FALSE, TRUE);
01869
01870 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01871 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01872
01873 }
01874
01875
01876
01877
01878
01879 NTR_IR_TBL(dv_idx);
01880 IR_OPR(dv_idx) = Dv_Set_Ptr_Alloc;
01881 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01882 IR_LINE_NUM(dv_idx) = opnd_line;
01883 IR_COL_NUM(dv_idx) = opnd_column;
01884 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01885
01886 if (dope_idx != NULL_IDX) {
01887 NTR_IR_TBL(dv2_idx);
01888 IR_OPR(dv2_idx) = Dv_Access_Ptr_Alloc;
01889 IR_TYPE_IDX(dv2_idx) = CG_INTEGER_DEFAULT_TYPE;
01890 IR_LINE_NUM(dv2_idx) = opnd_line;
01891 IR_COL_NUM(dv2_idx) = opnd_column;
01892 COPY_OPND(IR_OPND_L(dv2_idx), IR_OPND_L(dope_idx));
01893 IR_FLD_R(dv_idx) = IR_Tbl_Idx;
01894 IR_IDX_R(dv_idx) = dv2_idx;
01895 }
01896 else {
01897 IR_FLD_R(dv_idx) = CN_Tbl_Idx;
01898 #ifdef KEY
01899
01900
01901
01902
01903
01904
01905
01906 IR_IDX_R(dv_idx) = (ptr_assign && NULL_IDX == dope_idx &&
01907 AT_Tbl_Idx == OPND_FLD((*r_opnd)) &&
01908 AT_IS_DARG(OPND_IDX((*r_opnd)))) ?
01909 CN_INTEGER_ONE_IDX :
01910 CN_INTEGER_ZERO_IDX;
01911 #else
01912 IR_IDX_R(dv_idx) = CN_INTEGER_ZERO_IDX;
01913 #endif
01914 IR_LINE_NUM_R(dv_idx) = opnd_line;
01915 IR_COL_NUM_R(dv_idx) = opnd_column;
01916 }
01917
01918 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01919 FALSE, FALSE, TRUE);
01920
01921 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01922 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01923
01924
01925
01926
01927
01928 NTR_IR_TBL(dv_idx);
01929 IR_OPR(dv_idx) = Dv_Set_Orig_Base;
01930 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01931 IR_LINE_NUM(dv_idx) = opnd_line;
01932 IR_COL_NUM(dv_idx) = opnd_column;
01933 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01934
01935 if (dope_idx != NULL_IDX) {
01936 NTR_IR_TBL(dv2_idx);
01937 IR_OPR(dv2_idx) = Dv_Access_Orig_Base;
01938 IR_TYPE_IDX(dv2_idx) = SA_INTEGER_DEFAULT_TYPE;
01939 IR_LINE_NUM(dv2_idx) = opnd_line;
01940 IR_COL_NUM(dv2_idx) = opnd_column;
01941 COPY_OPND(IR_OPND_L(dv2_idx), IR_OPND_L(dope_idx));
01942 IR_FLD_R(dv_idx) = IR_Tbl_Idx;
01943 IR_IDX_R(dv_idx) = dv2_idx;
01944 }
01945 else {
01946 IR_FLD_R(dv_idx) = CN_Tbl_Idx;
01947 IR_IDX_R(dv_idx) = CN_INTEGER_ZERO_IDX;
01948 IR_LINE_NUM_R(dv_idx) = opnd_line;
01949 IR_COL_NUM_R(dv_idx) = opnd_column;
01950 }
01951
01952 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01953 FALSE, FALSE, TRUE);
01954
01955 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01956 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01957
01958
01959
01960
01961
01962 NTR_IR_TBL(dv_idx);
01963 IR_OPR(dv_idx) = Dv_Set_Orig_Size;
01964 IR_TYPE_IDX(dv_idx) = CG_INTEGER_DEFAULT_TYPE;
01965 IR_LINE_NUM(dv_idx) = opnd_line;
01966 IR_COL_NUM(dv_idx) = opnd_column;
01967 COPY_OPND(IR_OPND_L(dv_idx), (*l_opnd));
01968
01969 if (dope_idx != NULL_IDX) {
01970 NTR_IR_TBL(dv2_idx);
01971 IR_OPR(dv2_idx) = Dv_Access_Orig_Size;
01972 IR_TYPE_IDX(dv2_idx) = SA_INTEGER_DEFAULT_TYPE;
01973 IR_LINE_NUM(dv2_idx) = opnd_line;
01974 IR_COL_NUM(dv2_idx) = opnd_column;
01975 COPY_OPND(IR_OPND_L(dv2_idx), IR_OPND_L(dope_idx));
01976 IR_FLD_R(dv_idx) = IR_Tbl_Idx;
01977 IR_IDX_R(dv_idx) = dv2_idx;
01978 }
01979 else {
01980 IR_FLD_R(dv_idx) = CN_Tbl_Idx;
01981 IR_IDX_R(dv_idx) = CN_INTEGER_ZERO_IDX;
01982 IR_LINE_NUM_R(dv_idx) = opnd_line;
01983 IR_COL_NUM_R(dv_idx) = opnd_column;
01984 }
01985
01986 gen_sh(Before, Assignment_Stmt, stmt_start_line, stmt_start_col,
01987 FALSE, FALSE, TRUE);
01988
01989 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = dv_idx;
01990 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
01991
01992 TRACE (Func_Exit, "dope_vector_setup", NULL);
01993
01994 return;
01995
01996 }
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014 void make_io_type_code(int type_idx,
02015 long_type *value)
02016
02017 {
02018 long_type dec_len = 0;
02019 int dp_flag = 0;
02020 #ifdef KEY
02021 int dv_type = 0;
02022 #else
02023 int dv_type;
02024 #endif
02025 long_type int_len = 0;
02026 int kind_star = 0;
02027
02028 f90_type_t *type_code;
02029
02030
02031 TRACE (Func_Entry, "make_io_type_code", NULL);
02032
02033 switch(TYP_DESC(type_idx)) {
02034 case Default_Typed:
02035 kind_star = DV_DEFAULT_TYPED;
02036 break;
02037
02038 case Star_Typed:
02039 kind_star = DV_STAR_TYPED;
02040 break;
02041
02042 case Kind_Typed:
02043 if (TYP_TYPE(type_idx) == Real &&
02044 TYP_KIND_DOUBLE(type_idx)) {
02045 kind_star = DV_KIND_DOUBLE;
02046 }
02047 else if (TYP_KIND_CONST(type_idx)) {
02048 kind_star = DV_KIND_CONST;
02049 }
02050 else {
02051 kind_star = DV_KIND_TYPED;
02052 }
02053 break;
02054 }
02055
02056 # ifndef _TARGET_OS_MAX
02057 if (TYP_DECLARED_DBL(type_idx) &&
02058 kind_star == DV_DEFAULT_TYPED) {
02059
02060 dp_flag = 1;
02061 }
02062 # endif
02063
02064 switch (TYP_TYPE(type_idx)) {
02065 case Typeless:
02066
02067
02068
02069 dec_len = (long) TYP_BIT_LEN(type_idx) / TARGET_BYTES_PER_WORD;
02070 int_len = (long) TYP_BIT_LEN(type_idx);
02071 dv_type = DV_TYPELESS;
02072
02073 break;
02074
02075 case Integer:
02076
02077 dec_len = (long) TYP_DCL_VALUE(type_idx);
02078 int_len = storage_bit_size_tbl[TYP_LINEAR(type_idx)];
02079 dv_type = DV_INTEGER;
02080
02081 break;
02082
02083 case Logical:
02084
02085 dec_len = (long) TYP_DCL_VALUE(type_idx);
02086 int_len = storage_bit_size_tbl[TYP_LINEAR(type_idx)];
02087 dv_type = DV_LOGICAL;
02088
02089 break;
02090
02091 case Real:
02092
02093 dec_len = (long) TYP_DCL_VALUE(type_idx);
02094 int_len = storage_bit_size_tbl[TYP_LINEAR(type_idx)];
02095 dv_type = DV_REAL;
02096
02097 break;
02098
02099 case Complex:
02100
02101 dec_len = (long) TYP_DCL_VALUE(type_idx);
02102 int_len = storage_bit_size_tbl[TYP_LINEAR(type_idx)];
02103 dv_type = DV_COMPLEX;
02104
02105 break;
02106
02107 case Character:
02108
02109 if (kind_star == DV_DEFAULT_TYPED) {
02110 dec_len = 0;
02111 }
02112 else {
02113 dec_len = 1;
02114 }
02115 int_len = 8;
02116 dv_type = DV_ASCII_CHAR;
02117
02118 break;
02119
02120 case Structure:
02121
02122 if (ATT_CHAR_SEQ(TYP_IDX(type_idx))) {
02123 dv_type = DV_ASCII_CHAR_SEQUENCE_STRUCT;
02124 }
02125 else {
02126 dv_type = DV_STRUCT;
02127 }
02128
02129 break;
02130
02131 case CRI_Ptr:
02132 case CRI_Ch_Ptr:
02133
02134 int_len = storage_bit_size_tbl[TYP_LINEAR(type_idx)];
02135 dv_type = DV_INTEGER;
02136
02137 break;
02138 }
02139
02140 # ifdef _TYPE_CODE_64_BIT
02141 type_code = (f90_type_t *)value;
02142
02143 type_code->unused = 0;
02144 type_code->type = dv_type;
02145 type_code->dpflag = dp_flag;
02146 type_code->kind_or_star = kind_star;
02147 type_code->int_len = int_len;
02148 type_code->dec_len = dec_len;
02149 # else
02150
02151 *value = ((dv_type << DV_TYPE_SHIFT) |
02152 (dp_flag << DV_DP_SHIFT) |
02153 (kind_star << DV_KIND_STAR_SHIFT) |
02154 (int_len << DV_INT_LEN_SHIFT) |
02155 (dec_len << DV_DEC_LEN_SHIFT));
02156 # endif
02157
02158 TRACE (Func_Exit, "make_io_type_code", NULL);
02159
02160 return;
02161
02162 }
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181 static int create_dv_type_code(int attr_idx)
02182
02183 {
02184 int constant_idx = NULL_IDX;
02185 long_type constant[2];
02186
02187 TRACE (Func_Entry, "create_dv_type_code", NULL);
02188
02189 make_io_type_code(ATD_TYPE_IDX(attr_idx), constant);
02190
02191 constant_idx = ntr_const_tbl(IO_TYPE_CODE_TYPE, FALSE, constant);
02192
02193 TRACE (Func_Exit, "create_dv_type_code", NULL);
02194
02195 return(constant_idx);
02196
02197 }
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215 void gen_common_dv_init(opnd_type *dv_opnd,
02216 int dv_attr_idx,
02217 sh_position_type position)
02218
02219 {
02220 int col;
02221 int ir_idx;
02222 size_offset_type length;
02223 int line;
02224 int mult_idx;
02225 size_offset_type result;
02226 int type_idx;
02227
02228
02229 TRACE (Func_Entry, "gen_common_dv_init", NULL);
02230
02231 find_opnd_line_and_column(dv_opnd, &line, &col);
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243 NTR_IR_TBL(ir_idx);
02244 IR_OPR(ir_idx) = Dv_Set_El_Len;
02245 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
02246 IR_LINE_NUM(ir_idx) = line;
02247 IR_COL_NUM(ir_idx) = col;
02248
02249 COPY_OPND(IR_OPND_L(ir_idx), (*dv_opnd));
02250
02251 type_idx = ATD_TYPE_IDX(dv_attr_idx);
02252
02253 if (TYP_TYPE(type_idx) == Structure) {
02254 IR_FLD_R(ir_idx) = (fld_type) ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
02255 IR_IDX_R(ir_idx) = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
02256 IR_LINE_NUM_R(ir_idx) = line;
02257 IR_COL_NUM_R(ir_idx) = col;
02258 }
02259 else if (TYP_TYPE(type_idx) == Character) {
02260
02261 IR_FLD_R(ir_idx) = TYP_FLD(type_idx);
02262 IR_IDX_R(ir_idx) = TYP_IDX(type_idx);
02263 IR_LINE_NUM_R(ir_idx) = line;
02264 IR_COL_NUM_R(ir_idx) = col;
02265
02266 if (IR_FLD_R(ir_idx) == AT_Tbl_Idx) {
02267 ADD_TMP_TO_SHARED_LIST(IR_IDX_R(ir_idx));
02268 }
02269
02270 if (! char_len_in_bytes) {
02271
02272
02273
02274
02275 if (TYP_FLD(type_idx) == CN_Tbl_Idx) {
02276 result.fld = CN_Tbl_Idx;
02277 result.idx = CN_INTEGER_CHAR_BIT_IDX;
02278 length.fld = TYP_FLD(type_idx);
02279 length.idx = TYP_IDX(type_idx);
02280
02281 size_offset_binary_calc(&length,
02282 &result,
02283 Mult_Opr,
02284 &result);
02285
02286 if (result.fld == NO_Tbl_Idx) {
02287 IR_FLD_R(ir_idx) = CN_Tbl_Idx;
02288 IR_IDX_R(ir_idx) = ntr_const_tbl(result.type_idx,
02289 FALSE,
02290 result.constant);
02291 }
02292 else {
02293 IR_FLD_R(ir_idx) = result.fld;
02294 IR_IDX_R(ir_idx) = result.idx;
02295 }
02296
02297 IR_LINE_NUM_R(ir_idx) = line;
02298 IR_COL_NUM_R(ir_idx) = col;
02299 }
02300 else {
02301 NTR_IR_TBL(mult_idx);
02302 IR_OPR(mult_idx) = Mult_Opr;
02303 IR_TYPE_IDX(mult_idx) = CG_INTEGER_DEFAULT_TYPE;
02304 IR_LINE_NUM(mult_idx) = line;
02305 IR_COL_NUM(mult_idx) = col;
02306 IR_FLD_L(mult_idx) = CN_Tbl_Idx;
02307 IR_IDX_L(mult_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 8);
02308 IR_LINE_NUM_L(mult_idx) = line;
02309 IR_COL_NUM_L(mult_idx) = col;
02310
02311 IR_FLD_R(mult_idx) = TYP_FLD(type_idx);
02312 IR_IDX_R(mult_idx) = TYP_IDX(type_idx);
02313 IR_LINE_NUM_R(mult_idx) = line;
02314 IR_COL_NUM_R(mult_idx) = col;
02315
02316 IR_FLD_R(ir_idx) = IR_Tbl_Idx;
02317 IR_IDX_R(ir_idx) = mult_idx;
02318 }
02319 }
02320 }
02321 else {
02322 IR_FLD_R(ir_idx) = CN_Tbl_Idx;
02323 IR_IDX_R(ir_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
02324 storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
02325 IR_LINE_NUM_R(ir_idx) = line;
02326 IR_COL_NUM_R(ir_idx) = col;
02327 }
02328
02329 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
02330
02331 if (position == After) {
02332 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
02333 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
02334 }
02335 else {
02336 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
02337 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
02338 }
02339
02340
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358 NTR_IR_TBL(ir_idx);
02359 IR_OPR(ir_idx) = Dv_Set_P_Or_A;
02360 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
02361 IR_LINE_NUM(ir_idx) = line;
02362 IR_COL_NUM(ir_idx) = col;
02363
02364 COPY_OPND(IR_OPND_L(ir_idx), (*dv_opnd));
02365
02366 IR_FLD_R(ir_idx) = CN_Tbl_Idx;
02367
02368 if (ATD_ALLOCATABLE(dv_attr_idx)) {
02369 IR_IDX_R(ir_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 2);
02370 }
02371 else if (ATD_POINTER(dv_attr_idx)) {
02372 IR_IDX_R(ir_idx) = CN_INTEGER_ONE_IDX;
02373 }
02374 else {
02375 IR_IDX_R(ir_idx) = CN_INTEGER_ZERO_IDX;
02376 }
02377 IR_LINE_NUM_R(ir_idx) = line;
02378 IR_COL_NUM_R(ir_idx) = col;
02379
02380 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
02381
02382 if (position == After) {
02383 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
02384 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
02385 }
02386 else {
02387 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
02388 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
02389 }
02390
02391
02392
02393
02394
02395
02396
02397 if (!ATD_IN_COMMON(dv_attr_idx))
02398 {
02399 NTR_IR_TBL(ir_idx);
02400 IR_OPR(ir_idx) = Dv_Set_A_Contig;
02401 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
02402 IR_LINE_NUM(ir_idx) = line;
02403 IR_COL_NUM(ir_idx) = col;
02404
02405 COPY_OPND(IR_OPND_L(ir_idx), (*dv_opnd));
02406
02407 IR_FLD_R(ir_idx) = CN_Tbl_Idx;
02408
02409 if (ATD_ALLOCATABLE(dv_attr_idx)) {
02410 IR_IDX_R(ir_idx) = CN_INTEGER_ONE_IDX;
02411 }
02412 else {
02413 IR_IDX_R(ir_idx) = CN_INTEGER_ZERO_IDX;
02414 }
02415 IR_LINE_NUM_R(ir_idx) = line;
02416 IR_COL_NUM_R(ir_idx) = col;
02417
02418 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
02419
02420 if (position == After) {
02421 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
02422 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
02423 }
02424 else {
02425 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
02426 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
02427 }
02428 }
02429
02430
02431
02432
02433
02434
02435 NTR_IR_TBL(ir_idx);
02436 IR_OPR(ir_idx) =Dv_Set_N_Dim ;
02437 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
02438 IR_LINE_NUM(ir_idx) = line;
02439 IR_COL_NUM(ir_idx) = col;
02440
02441 COPY_OPND(IR_OPND_L(ir_idx), (*dv_opnd));
02442
02443 IR_FLD_R(ir_idx) = CN_Tbl_Idx;
02444 IR_IDX_R(ir_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
02445 (ATD_ARRAY_IDX(dv_attr_idx) ?
02446 BD_RANK(ATD_ARRAY_IDX(dv_attr_idx)) : 0));
02447 IR_LINE_NUM_R(ir_idx) = line;
02448 IR_COL_NUM_R(ir_idx) = col;
02449
02450 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
02451
02452 if (position == After) {
02453 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
02454 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
02455 }
02456 else {
02457 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
02458 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
02459 }
02460
02461
02462
02463
02464
02465
02466 NTR_IR_TBL(ir_idx);
02467 IR_OPR(ir_idx) = Dv_Set_Typ_Code;
02468 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
02469 IR_LINE_NUM(ir_idx) = line;
02470 IR_COL_NUM(ir_idx) = col;
02471
02472 COPY_OPND(IR_OPND_L(ir_idx), (*dv_opnd));
02473
02474 IR_FLD_R(ir_idx) = CN_Tbl_Idx;
02475 IR_IDX_R(ir_idx) = create_dv_type_code(dv_attr_idx);
02476 IR_LINE_NUM_R(ir_idx) = line;
02477 IR_COL_NUM_R(ir_idx) = col;
02478
02479 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
02480
02481 if (position == After) {
02482 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
02483 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
02484 }
02485 else {
02486 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
02487 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
02488 }
02489
02490
02491
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503 TRACE (Func_Exit, "gen_common_dv_init", NULL);
02504
02505 return;
02506
02507 }
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525 void gen_static_dv_whole_def(opnd_type *dv_opnd,
02526 int attr_idx,
02527 sh_position_type position)
02528
02529 {
02530 int col;
02531 long_type constant[2];
02532 int const_idx;
02533 ext_dope_type *dv_ptr;
02534 int ir_idx;
02535 int i;
02536 int line;
02537 int mult_idx;
02538 int num_words;
02539 long_type rank;
02540 int type_idx;
02541
02542
02543 TRACE (Func_Entry, "gen_static_dv_whole_def", NULL);
02544
02545 find_opnd_line_and_column(dv_opnd, &line, &col);
02546
02547 rank = (ATD_ARRAY_IDX(attr_idx) ? (long)BD_RANK(ATD_ARRAY_IDX(attr_idx)) :0);
02548
02549 num_words = DV_HD_WORD_SIZE + (rank * DV_DIM_WORD_SIZE);
02550
02551 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
02552 TYP_TYPE(TYP_WORK_IDX) = Typeless;
02553 #if defined (TARG_X8664) && defined (_HOST64)
02554 TYP_BIT_LEN(TYP_WORK_IDX) = num_words * ((SET_POINTER_SIZE)?64:32);
02555 #else
02556 TYP_BIT_LEN(TYP_WORK_IDX) = num_words * TARGET_BITS_PER_WORD;
02557 #endif
02558 type_idx = ntr_type_tbl();
02559
02560 const_idx = ntr_const_tbl(type_idx, FALSE, NULL);
02561
02562
02563 if (ATD_CLASS(attr_idx) == Compiler_Tmp) {
02564 ATD_FLD(attr_idx) = CN_Tbl_Idx;
02565 ATD_TMP_IDX(attr_idx) = const_idx;
02566 ATD_TMP_INIT_NOT_DONE(attr_idx) = TRUE;
02567 }
02568 else {
02569 gen_init_stmt(dv_opnd,
02570 const_idx,
02571 position);
02572 }
02573
02574 dv_ptr = (ext_dope_type *)&CN_CONST(const_idx);
02575 type_idx = ATD_TYPE_IDX(attr_idx);
02576
02577
02578
02579
02580
02581
02582
02583
02584 if (TYP_TYPE(type_idx) == Structure) {
02585
02586 if (compare_cn_and_value(ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx)),
02587 MAX_DV_EL_LEN,
02588 Ge_Opr)) {
02589 PRINTMSG(line, 1174, Error, col,
02590 CN_INT_TO_C(ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx))),
02591 MAX_DV_EL_LEN);
02592 DV_SET_EL_LEN(*dv_ptr, MAX_DV_EL_LEN);
02593 }
02594 else {
02595 DV_SET_EL_LEN(*dv_ptr,
02596 CN_INT_TO_C(ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx))));
02597 }
02598 }
02599 else if (TYP_TYPE(type_idx) == Character) {
02600
02601 if (TYP_FLD(type_idx) == CN_Tbl_Idx) {
02602
02603 if (char_len_in_bytes) {
02604
02605 if (compare_cn_and_value(TYP_IDX(type_idx),
02606 MAX_DV_EL_LEN,
02607 Ge_Opr)) {
02608 PRINTMSG(line, 1174, Error, col,
02609 CN_INT_TO_C(TYP_IDX(type_idx)),
02610 MAX_DV_EL_LEN);
02611 DV_SET_EL_LEN(*dv_ptr, MAX_DV_EL_LEN);
02612 }
02613 else {
02614 DV_SET_EL_LEN(*dv_ptr, CN_INT_TO_C(TYP_IDX(type_idx)));
02615 }
02616 }
02617 else {
02618
02619 if (compare_cn_and_value(TYP_IDX(type_idx),
02620 MAX_DV_EL_LEN/8,
02621 Ge_Opr)) {
02622 PRINTMSG(line, 1174, Error, col,
02623 CN_INT_TO_C(TYP_IDX(type_idx)),
02624 MAX_DV_EL_LEN/8);
02625 DV_SET_EL_LEN(*dv_ptr, MAX_DV_EL_LEN);
02626 }
02627 else {
02628 DV_SET_EL_LEN(*dv_ptr, CN_INT_TO_C(TYP_IDX(type_idx)) * 8);
02629 }
02630 }
02631 }
02632 else {
02633
02634
02635
02636
02637 NTR_IR_TBL(ir_idx);
02638 IR_OPR(ir_idx) = Dv_Set_El_Len;
02639 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
02640 IR_LINE_NUM(ir_idx) = line;
02641 IR_COL_NUM(ir_idx) = col;
02642
02643 COPY_OPND(IR_OPND_L(ir_idx), (*dv_opnd));
02644
02645 if (char_len_in_bytes) {
02646
02647
02648 IR_FLD_R(ir_idx) = TYP_FLD(type_idx);
02649 IR_IDX_R(ir_idx) = TYP_IDX(type_idx);
02650 IR_LINE_NUM_R(ir_idx) = line;
02651 IR_COL_NUM_R(ir_idx) = col;
02652 }
02653 else {
02654 NTR_IR_TBL(mult_idx);
02655 IR_OPR(mult_idx) = Mult_Opr;
02656 IR_TYPE_IDX(mult_idx) = CG_INTEGER_DEFAULT_TYPE;
02657 IR_LINE_NUM(mult_idx) = line;
02658 IR_COL_NUM(mult_idx) = col;
02659 IR_FLD_L(mult_idx) = CN_Tbl_Idx;
02660 IR_IDX_L(mult_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 8);
02661 IR_LINE_NUM_L(mult_idx) = line;
02662 IR_COL_NUM_L(mult_idx) = col;
02663
02664 IR_FLD_R(mult_idx) = TYP_FLD(type_idx);
02665 IR_IDX_R(mult_idx) = TYP_IDX(type_idx);
02666 IR_LINE_NUM_R(mult_idx) = line;
02667 IR_COL_NUM_R(mult_idx) = col;
02668
02669 IR_FLD_R(ir_idx) = IR_Tbl_Idx;
02670 IR_IDX_R(ir_idx) = mult_idx;
02671 }
02672
02673 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
02674
02675 if (position == After) {
02676 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
02677 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
02678 }
02679 else {
02680 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
02681 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
02682 }
02683 }
02684 }
02685 else {
02686 DV_SET_EL_LEN(*dv_ptr, storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
02687 }
02688
02689
02690
02691
02692
02693 if (ATD_ALLOCATABLE(attr_idx)) {
02694 DV_SET_P_OR_A(*dv_ptr, 2);
02695 }
02696 else if (ATD_POINTER(attr_idx)) {
02697 DV_SET_P_OR_A(*dv_ptr, 1);
02698 }
02699
02700
02701
02702
02703
02704 DV_SET_NUM_DIMS(*dv_ptr, rank);
02705
02706
02707
02708
02709
02710 make_io_type_code(type_idx, constant);
02711 # ifdef _TYPE_CODE_64_BIT
02712 DV_SET_TYPE_CODE(*dv_ptr, *(f90_type_t *)constant);
02713 # else
02714 DV_SET_TYPE_CODE(*dv_ptr, *constant);
02715 # endif
02716
02717 if (cmd_line_flags.runtime_bounds &&
02718 ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
02719
02720 for (i = 0; i < BD_RANK(ATD_ARRAY_IDX(attr_idx)); i++) {
02721
02722
02723
02724
02725
02726 DV_SET_LOW_BOUND(*dv_ptr, i, 1);
02727
02728
02729
02730
02731
02732
02733
02734
02735
02736
02737
02738 DV_SET_STRIDE_MULT(*dv_ptr, i, 1);
02739
02740 }
02741 }
02742
02743 #ifdef KEY
02744
02745
02746
02747
02748
02749
02750
02751
02752
02753 if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX && !DV_ASSOC(*dv_ptr)) {
02754 DV_SET_A_CONTIG(*dv_ptr, 1);
02755 }
02756 #endif
02757
02758 TRACE (Func_Exit, "gen_static_dv_whole_def", NULL);
02759
02760 return;
02761
02762 }
02763
02764
02765
02766
02767
02768
02769
02770
02771
02772
02773
02774
02775
02776
02777
02778
02779
02780 static long64 create_imp_do_loops(opnd_type *top_opnd)
02781
02782 {
02783
02784 int col;
02785 long64 count = 1;
02786 long64 end;
02787 int i;
02788 int imp_idx;
02789 int line;
02790 int list_idx;
02791 opnd_type opnd;
02792 long64 start;
02793 int tmp_idx;
02794 int trip_list_idx;
02795
02796
02797 TRACE (Func_Entry, "create_imp_do_loops", NULL);
02798
02799 COPY_OPND(opnd, (*top_opnd));
02800 find_opnd_line_and_column(&opnd, &line, &col);
02801
02802 while (OPND_FLD(opnd) == IR_Tbl_Idx) {
02803
02804 if (IR_OPR(OPND_IDX(opnd)) == Whole_Subscript_Opr) {
02805
02806 trip_list_idx = IR_IDX_R(OPND_IDX(opnd));
02807
02808 for (i = 0; i < IR_LIST_CNT_R(OPND_IDX(opnd)); i++) {
02809
02810 NTR_IR_TBL(imp_idx);
02811 IR_OPR(imp_idx) = Implied_Do_Opr;
02812 IR_TYPE_IDX(imp_idx) = TYPELESS_DEFAULT_TYPE;
02813 IR_LINE_NUM(imp_idx) = line;
02814 IR_COL_NUM(imp_idx) = col;
02815
02816 NTR_IR_LIST_TBL(list_idx);
02817 IR_FLD_L(imp_idx) = IL_Tbl_Idx;
02818 IR_LIST_CNT_L(imp_idx) = 1;
02819 IR_IDX_L(imp_idx) = list_idx;
02820
02821 COPY_OPND(IL_OPND(list_idx), (*top_opnd));
02822 OPND_FLD((*top_opnd)) = IR_Tbl_Idx;
02823 OPND_IDX((*top_opnd)) = imp_idx;
02824
02825
02826
02827 tmp_idx = gen_compiler_tmp(line, col, Priv, TRUE);
02828 ATD_TYPE_IDX(tmp_idx) = CG_INTEGER_DEFAULT_TYPE;
02829 AT_SEMANTICS_DONE(tmp_idx)= TRUE;
02830 ATD_STOR_BLK_IDX(tmp_idx) = SCP_SB_STACK_IDX(curr_scp_idx);
02831 ATD_IMP_DO_LCV(tmp_idx) = TRUE;
02832 ATD_LCV_IS_CONST(tmp_idx) = TRUE;
02833
02834
02835
02836 NTR_IR_LIST_TBL(list_idx);
02837 IR_FLD_R(imp_idx) = IL_Tbl_Idx;
02838 IR_LIST_CNT_R(imp_idx) = 4;
02839 IR_IDX_R(imp_idx) = list_idx;
02840
02841 IL_FLD(list_idx) = AT_Tbl_Idx;
02842 IL_IDX(list_idx) = tmp_idx;
02843 IL_LINE_NUM(list_idx) = line;
02844 IL_COL_NUM(list_idx) = col;
02845
02846
02847
02848 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
02849 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
02850 list_idx = IL_NEXT_LIST_IDX(list_idx);
02851
02852 COPY_OPND(IL_OPND(list_idx),
02853 IL_OPND(IR_IDX_L(IL_IDX(trip_list_idx))));
02854
02855 start = CN_INT_TO_C(IL_IDX(list_idx));
02856
02857
02858
02859 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
02860 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
02861 list_idx = IL_NEXT_LIST_IDX(list_idx);
02862
02863 COPY_OPND(IL_OPND(list_idx),
02864 IL_OPND(IL_NEXT_LIST_IDX(IR_IDX_L(
02865 IL_IDX(trip_list_idx)))));
02866
02867 end = CN_INT_TO_C(IL_IDX(list_idx));
02868
02869 count = count * ((end - start) + 1);
02870
02871
02872
02873 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
02874 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
02875 list_idx = IL_NEXT_LIST_IDX(list_idx);
02876
02877 COPY_OPND(IL_OPND(list_idx),
02878 IL_OPND(IL_NEXT_LIST_IDX(IL_NEXT_LIST_IDX(
02879 IR_IDX_L(IL_IDX(trip_list_idx))))));
02880
02881
02882
02883
02884 IL_FLD(trip_list_idx) = AT_Tbl_Idx;
02885 IL_IDX(trip_list_idx) = tmp_idx;
02886 IL_LINE_NUM(trip_list_idx) = line;
02887 IL_COL_NUM(trip_list_idx) = col;
02888
02889 trip_list_idx = IL_NEXT_LIST_IDX(trip_list_idx);
02890 }
02891 }
02892
02893 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
02894 }
02895
02896
02897 TRACE (Func_Exit, "create_imp_do_loops", NULL);
02898
02899 return(count);
02900
02901 }
02902
02903
02904
02905
02906
02907
02908
02909
02910
02911
02912
02913
02914
02915
02916
02917
02918
02919
02920 void gen_entry_dope_code(int attr_idx)
02921
02922 {
02923 expr_arg_type exp_desc;
02924 void (*func)();
02925 opnd_type opnd;
02926 int opr;
02927
02928
02929 TRACE (Func_Entry, "gen_entry_dope_code", NULL);
02930
02931 if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Module) {
02932 func = gen_static_dv_whole_def;
02933 opr = Init_Opr;
02934 }
02935 else if (ATD_AUTOMATIC(attr_idx) ||
02936 ATD_CLASS(attr_idx) == Function_Result) {
02937 func = gen_dv_whole_def_init;
02938 opr = Asg_Opr;
02939 }
02940 else if (ATD_IN_COMMON(attr_idx)) {
02941
02942 # if defined(_TARGET_OS_SOLARIS) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
02943 func = gen_common_dv_init;
02944 opr = Init_Opr;
02945 # else
02946 func = gen_static_dv_whole_def;
02947 opr = Init_Opr;
02948 # endif
02949 }
02950 else if (ATD_SAVED(attr_idx) ||
02951 #ifdef KEY
02952 ATD_DATA_INIT(attr_idx) ||
02953 #endif
02954 ATP_SAVE_ALL(SCP_ATTR_IDX(curr_scp_idx))) {
02955 func = gen_static_dv_whole_def;
02956 opr = Init_Opr;
02957 }
02958 else {
02959 func = gen_dv_whole_def_init;
02960 opr = Asg_Opr;
02961 }
02962
02963 if (AT_DCL_ERR(attr_idx)) {
02964 goto EXIT;
02965 }
02966
02967 # if defined(_TARGET_OS_SOLARIS) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
02968
02969 if (ATP_PGM_UNIT(SCP_ATTR_IDX(curr_scp_idx)) == Module &&
02970 ATD_IN_COMMON(attr_idx)) {
02971
02972
02973
02974 }
02975 else
02976 # endif
02977 if (ATD_IM_A_DOPE(attr_idx)) {
02978 OPND_FLD(opnd) = AT_Tbl_Idx;
02979 OPND_IDX(opnd) = attr_idx;
02980 OPND_LINE_NUM(opnd) = SH_GLB_LINE(curr_stmt_sh_idx);
02981 OPND_COL_NUM(opnd) = SH_COL_NUM(curr_stmt_sh_idx);
02982 (*func)(&opnd, attr_idx, After);
02983 }
02984 else if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure &&
02985 (ATT_POINTER_CPNT(TYP_IDX(ATD_TYPE_IDX(attr_idx))) ||
02986 #ifdef KEY
02987 ATT_ALLOCATABLE_CPNT(TYP_IDX(ATD_TYPE_IDX(attr_idx))) ||
02988 #endif
02989 ATT_DEFAULT_INITIALIZED(TYP_IDX(ATD_TYPE_IDX(attr_idx)))) &&
02990 ! AT_DCL_ERR(TYP_IDX(ATD_TYPE_IDX(attr_idx)))) {
02991
02992 OPND_FLD(opnd) = AT_Tbl_Idx;
02993 OPND_IDX(opnd) = attr_idx;
02994 OPND_LINE_NUM(opnd) = SH_GLB_LINE(curr_stmt_sh_idx);
02995 OPND_COL_NUM(opnd) = SH_COL_NUM(curr_stmt_sh_idx);
02996
02997 # if defined(_TARGET_OS_MAX)
02998 if (ATD_ARRAY_IDX(attr_idx) ||
02999 ATD_PE_ARRAY_IDX(attr_idx))
03000 # else
03001 if (ATD_ARRAY_IDX(attr_idx))
03002 # endif
03003 {
03004 gen_whole_subscript(&opnd, &exp_desc);
03005 }
03006
03007 process_cpnt_inits(&opnd,
03008 TYP_IDX(ATD_TYPE_IDX(attr_idx)),
03009 func,
03010 opr,
03011 After);
03012 }
03013
03014 EXIT:
03015
03016 TRACE (Func_Exit, "gen_entry_dope_code", NULL);
03017
03018 return;
03019
03020 }
03021
03022
03023
03024
03025
03026
03027
03028
03029
03030
03031
03032
03033
03034
03035
03036
03037
03038
03039
03040
03041
03042 void process_cpnt_inits(opnd_type *left_opnd,
03043 int type_idx,
03044 void (*func)(),
03045 int opr,
03046 sh_position_type position)
03047
03048 {
03049 int attr_idx;
03050 opnd_type cn_opnd;
03051 int col;
03052 #ifdef KEY
03053 int const_idx = 0;
03054 #else
03055 int const_idx;
03056 #endif
03057 expr_arg_type exp_desc;
03058 int i;
03059 int init_idx;
03060 int ir_idx;
03061 int line;
03062 int list_idx;
03063 boolean need_loops = FALSE;
03064 opnd_type opnd;
03065 int placeholder_sh_idx = NULL_IDX;
03066 int save_curr_stmt_sh_idx;
03067 int save_target_array_idx;
03068 int sub_idx;
03069 int sn_idx;
03070 int tmp_idx;
03071 opnd_type tmp_opnd;
03072
03073 TRACE (Func_Entry, "process_cpnt_inits", NULL);
03074
03075 find_opnd_line_and_column(left_opnd, &line, &col);
03076
03077 # ifdef _DEBUG
03078 if (opr != Asg_Opr &&
03079 opr != Init_Opr) {
03080 PRINTMSG(line, 626, Internal, col,
03081 "Asg_Opr or Init_Opr", "process_cpnt_inits");
03082 }
03083 # endif
03084
03085 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
03086
03087 if (position == After) {
03088 save_curr_stmt_sh_idx = SH_NEXT_IDX(save_curr_stmt_sh_idx);
03089 }
03090
03091 # if defined(_GEN_LOOPS_FOR_DV_WHOLE_DEF)
03092 if (func == (void (*)())gen_dv_whole_def_init ||
03093 func == (void (*)())gen_dv_whole_def ||
03094 func == (void (*)())gen_sf_dv_whole_def) {
03095
03096 need_loops = TRUE;
03097 }
03098 # endif
03099
03100 if (ATT_DEFAULT_INITIALIZED(type_idx) &&
03101 opr == Asg_Opr) {
03102 need_loops = TRUE;
03103 }
03104
03105 if (need_loops) {
03106 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
03107
03108 if (position == Before) {
03109 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
03110 }
03111 placeholder_sh_idx = curr_stmt_sh_idx;
03112
03113 gen_dv_def_loops(left_opnd);
03114
03115 # ifdef _DEBUG
03116 if (placeholder_sh_idx != curr_stmt_sh_idx) {
03117 PRINTMSG(line, 626, Internal, col,
03118 "placeholder_sh_idx == curr_stmt_sh_idx",
03119 "process_cpnt_inits");
03120 }
03121 # endif
03122 }
03123
03124 sn_idx = ATT_FIRST_CPNT_IDX(type_idx);
03125
03126 while (sn_idx != NULL_IDX) {
03127 attr_idx = SN_ATTR_IDX(sn_idx);
03128
03129 #ifdef KEY
03130 if (ATD_POINTER(attr_idx) || ATD_ALLOCATABLE(attr_idx))
03131 #else
03132 if (ATD_POINTER(attr_idx))
03133 #endif
03134 {
03135 NTR_IR_TBL(ir_idx);
03136 IR_OPR(ir_idx) = Struct_Opr;
03137 IR_TYPE_IDX(ir_idx) = ATD_TYPE_IDX(attr_idx);
03138 IR_LINE_NUM(ir_idx) = line;
03139 IR_COL_NUM(ir_idx) = col;
03140 COPY_OPND(IR_OPND_L(ir_idx), (*left_opnd));
03141 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
03142 IR_IDX_R(ir_idx) = attr_idx;
03143 IR_LINE_NUM_R(ir_idx) = line;
03144 IR_COL_NUM_R(ir_idx) = col;
03145 OPND_FLD(opnd) = IR_Tbl_Idx;
03146 OPND_IDX(opnd) = ir_idx;
03147
03148 if (IR_FLD_L(ir_idx) == IR_Tbl_Idx) {
03149 IR_RANK(ir_idx) = IR_RANK(IR_IDX_L(ir_idx));
03150 }
03151
03152 (*func)(&opnd, attr_idx, position);
03153 }
03154 else if (ATD_CPNT_INIT_IDX(attr_idx) != NULL_IDX) {
03155
03156 NTR_IR_TBL(ir_idx);
03157
03158 IR_OPR(ir_idx) = Struct_Opr;
03159 IR_TYPE_IDX(ir_idx) = ATD_TYPE_IDX(attr_idx);
03160 IR_LINE_NUM(ir_idx) = line;
03161 IR_COL_NUM(ir_idx) = col;
03162
03163 COPY_OPND(IR_OPND_L(ir_idx), (*left_opnd));
03164
03165 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
03166 IR_IDX_R(ir_idx) = attr_idx;
03167 IR_LINE_NUM_R(ir_idx) = line;
03168 IR_COL_NUM_R(ir_idx) = col;
03169
03170 if (IR_FLD_L(ir_idx) == IR_Tbl_Idx) {
03171 IR_RANK(ir_idx) = IR_RANK(IR_IDX_L(ir_idx));
03172 }
03173
03174 gen_opnd(&opnd, ir_idx, IR_Tbl_Idx, line, col);
03175
03176 if (opr == Asg_Opr) {
03177
03178 if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
03179 exp_desc = init_exp_desc;
03180 gen_whole_subscript(&opnd, &exp_desc);
03181 }
03182 else if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
03183 gen_whole_substring(&opnd, 0);
03184 }
03185
03186 NTR_IR_TBL(init_idx);
03187
03188 IR_OPR(init_idx) = Asg_Opr;
03189 IR_LINE_NUM(init_idx) = line;
03190 IR_COL_NUM(init_idx) = col;
03191 IR_TYPE_IDX(init_idx) = ATD_TYPE_IDX(attr_idx);
03192 COPY_OPND(IR_OPND_L(init_idx), opnd);
03193 IR_LINE_NUM_L(init_idx)= line;
03194 IR_COL_NUM_L(init_idx) = col;
03195
03196
03197 IR_IDX_R(init_idx) = ATD_CPNT_INIT_IDX(attr_idx);
03198 IR_FLD_R(init_idx) = (fld_type) ATD_FLD(attr_idx);
03199 IR_LINE_NUM_R(init_idx) = line;
03200 IR_COL_NUM_R(init_idx) = col;
03201
03202 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
03203
03204 if (position == After) {
03205 SH_IR_IDX(curr_stmt_sh_idx) = init_idx;
03206 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
03207 }
03208 else {
03209 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = init_idx;
03210 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
03211 }
03212 }
03213 else {
03214
03215
03216 if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
03217 NTR_IR_TBL(sub_idx);
03218 IR_OPR(sub_idx) = Subscript_Opr;
03219 IR_TYPE_IDX(sub_idx) = ATD_TYPE_IDX(attr_idx);
03220 IR_LINE_NUM(sub_idx) = line;
03221 IR_COL_NUM(sub_idx) = col;
03222
03223 COPY_OPND(IR_OPND_L(sub_idx), opnd);
03224
03225 NTR_IR_LIST_TBL(list_idx);
03226 IR_FLD_R(sub_idx) = IL_Tbl_Idx;
03227 IR_IDX_R(sub_idx) = list_idx;
03228 IR_LIST_CNT_R(sub_idx) = 1;
03229
03230 IL_FLD(list_idx) = BD_LB_FLD(ATD_ARRAY_IDX(attr_idx),1);
03231 IL_IDX(list_idx) = BD_LB_IDX(ATD_ARRAY_IDX(attr_idx),1);
03232 IL_LINE_NUM(list_idx) = line;
03233 IL_COL_NUM(list_idx) = col;
03234
03235 for (i = 2; i<= BD_RANK(ATD_ARRAY_IDX(attr_idx)); i++) {
03236 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03237 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03238 list_idx = IL_NEXT_LIST_IDX(list_idx);
03239
03240 IR_LIST_CNT_R(sub_idx) += 1;
03241
03242 IL_FLD(list_idx) = BD_LB_FLD(ATD_ARRAY_IDX(attr_idx),i);
03243 IL_IDX(list_idx) = BD_LB_IDX(ATD_ARRAY_IDX(attr_idx),i);
03244 IL_LINE_NUM(list_idx) = line;
03245 IL_COL_NUM(list_idx) = col;
03246 }
03247
03248 gen_opnd(&opnd, sub_idx, IR_Tbl_Idx, line, col);
03249 }
03250
03251 if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
03252 gen_whole_substring(&opnd, 0);
03253 }
03254
03255 if (ATD_FLD(attr_idx) != CN_Tbl_Idx) {
03256
03257 gen_opnd(&tmp_opnd, ATD_CPNT_INIT_IDX(attr_idx),
03258 (fld_type) ATD_FLD(attr_idx), line, col);
03259
03260 tmp_idx = find_left_attr(&tmp_opnd);
03261
03262 if (ATD_FLD(tmp_idx) == CN_Tbl_Idx) {
03263 const_idx = ATD_TMP_IDX(tmp_idx);
03264 }
03265 else if (ATD_FLD(tmp_idx) == IR_Tbl_Idx &&
03266 IR_OPR(ATD_TMP_IDX(tmp_idx)) == Mult_Opr) {
03267
03268
03269
03270
03271 const_idx = IR_IDX_R(ATD_TMP_IDX(tmp_idx));
03272
03273 save_target_array_idx = target_array_idx;
03274 target_array_idx = ATD_ARRAY_IDX(attr_idx);
03275
03276 exp_desc = init_exp_desc;
03277 exp_desc.type_idx = CN_TYPE_IDX(const_idx);
03278 exp_desc.type = TYP_TYPE(exp_desc.type_idx);
03279 exp_desc.linear_type = TYP_LINEAR(exp_desc.type_idx);
03280 exp_desc.constant = TRUE;
03281 exp_desc.foldable = TRUE;
03282
03283 gen_opnd(&cn_opnd, const_idx, CN_Tbl_Idx, line, col);
03284 fold_aggragate_expression(&cn_opnd,
03285 &exp_desc,
03286 TRUE);
03287 target_array_idx = save_target_array_idx;
03288
03289 const_idx = OPND_IDX(cn_opnd);
03290 }
03291 }
03292 else {
03293 const_idx = ATD_CPNT_INIT_IDX(attr_idx);
03294 }
03295
03296 gen_init_stmt(&opnd,
03297 const_idx,
03298 position);
03299 }
03300 }
03301 else if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure &&
03302 (ATT_POINTER_CPNT(TYP_IDX(ATD_TYPE_IDX(attr_idx))) ||
03303 #ifdef KEY
03304 ATT_ALLOCATABLE_CPNT(TYP_IDX(ATD_TYPE_IDX(attr_idx))) ||
03305 #endif
03306 ATT_DEFAULT_INITIALIZED(TYP_IDX(ATD_TYPE_IDX(attr_idx))))) {
03307
03308 NTR_IR_TBL(ir_idx);
03309 IR_OPR(ir_idx) = Struct_Opr;
03310 IR_TYPE_IDX(ir_idx) = ATD_TYPE_IDX(attr_idx);
03311 IR_LINE_NUM(ir_idx) = line;
03312 IR_COL_NUM(ir_idx) = col;
03313 COPY_OPND(IR_OPND_L(ir_idx), (*left_opnd));
03314 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
03315 IR_IDX_R(ir_idx) = attr_idx;
03316 IR_LINE_NUM_R(ir_idx) = line;
03317 IR_COL_NUM_R(ir_idx) = col;
03318 OPND_FLD(opnd) = IR_Tbl_Idx;
03319 OPND_IDX(opnd) = ir_idx;
03320
03321 if (IR_FLD_L(ir_idx) == IR_Tbl_Idx) {
03322 IR_RANK(ir_idx) = IR_RANK(IR_IDX_L(ir_idx));
03323 }
03324
03325 if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
03326 exp_desc = init_exp_desc;
03327 gen_whole_subscript(&opnd, &exp_desc);
03328 }
03329
03330 process_cpnt_inits(&opnd,
03331 TYP_IDX(ATD_TYPE_IDX(attr_idx)),
03332 func,
03333 opr,
03334 position);
03335
03336 }
03337
03338 sn_idx = SN_SIBLING_LINK(sn_idx);
03339 }
03340
03341
03342
03343 if (placeholder_sh_idx != NULL_IDX) {
03344 remove_sh(placeholder_sh_idx);
03345 FREE_SH_NODE(placeholder_sh_idx);
03346 }
03347
03348 if (position == Before) {
03349 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
03350 }
03351 else {
03352 if (save_curr_stmt_sh_idx != NULL_IDX) {
03353 curr_stmt_sh_idx = SH_PREV_IDX(save_curr_stmt_sh_idx);
03354 }
03355 else {
03356
03357 while (SH_NEXT_IDX(curr_stmt_sh_idx) != NULL_IDX) {
03358 curr_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
03359 }
03360 }
03361 }
03362
03363 TRACE (Func_Exit, "process_cpnt_inits", NULL);
03364
03365 return;
03366
03367 }
03368
03369
03370
03371
03372
03373
03374
03375
03376
03377
03378
03379
03380
03381
03382
03383
03384
03385 static void gen_init_stmt(opnd_type *left_opnd,
03386 int const_idx,
03387 sh_position_type position)
03388
03389 {
03390 int array_attr_idx;
03391 opnd_type base_opnd;
03392 int bd_idx;
03393 int col;
03394 long64 count = 0;
03395 int init_idx;
03396 int line;
03397 int list_idx;
03398 int mult_idx;
03399 int num_loops = 0;
03400 opnd_type opnd;
03401 int rank_idx = NULL_IDX;
03402 long_type result[MAX_WORDS_FOR_INTEGER];
03403 long64 sm_bits;
03404 int type_idx;
03405 int unused = NULL_IDX;
03406 int unused2;
03407 long_type the_constant[MAX_WORDS_FOR_INTEGER];
03408
03409
03410 TRACE (Func_Entry, "gen_init_stmt", NULL);
03411
03412 find_opnd_line_and_column(left_opnd, &line, &col);
03413
03414 NTR_IR_TBL(init_idx);
03415 IR_OPR(init_idx) = Init_Opr;
03416 IR_TYPE_IDX(init_idx) = TYPELESS_DEFAULT_TYPE;
03417 IR_LINE_NUM(init_idx) = line;
03418 IR_COL_NUM(init_idx) = col;
03419
03420 COPY_OPND(IR_OPND_L(init_idx), (*left_opnd));
03421
03422 COPY_OPND(opnd, (*left_opnd));
03423 while (OPND_FLD(opnd) == IR_Tbl_Idx) {
03424 if (IR_OPR(OPND_IDX(opnd)) == Whole_Subscript_Opr) {
03425 num_loops++;
03426 }
03427 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
03428 }
03429
03430 if (num_loops > 0) {
03431
03432 if (num_loops == 1) {
03433
03434 COPY_OPND(opnd, (*left_opnd));
03435 make_base_subtree(&opnd, &base_opnd, &rank_idx, &unused);
03436
03437 # ifdef _DEBUG
03438 if (rank_idx == NULL_IDX) {
03439 PRINTMSG(line, 626, Internal, col,
03440 "whole array subscript",
03441 "gen_init_stmt");
03442 }
03443 # endif
03444 array_attr_idx = find_base_attr(&IR_OPND_L(rank_idx),
03445 &unused,
03446 &unused2);
03447
03448 bd_idx = ATD_ARRAY_IDX(array_attr_idx);
03449
03450 COPY_OPND(IR_OPND_L(init_idx), base_opnd);
03451
03452 NTR_IR_LIST_TBL(list_idx);
03453 IR_FLD_R(init_idx) = IL_Tbl_Idx;
03454 IR_IDX_R(init_idx) = list_idx;
03455 IR_LIST_CNT_R(init_idx) = 3;
03456
03457
03458
03459 IL_FLD(list_idx) = CN_Tbl_Idx;
03460 IL_IDX(list_idx) = const_idx;
03461 IL_LINE_NUM(list_idx) = line;
03462 IL_COL_NUM(list_idx) = col;
03463
03464
03465
03466 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03467 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03468 list_idx = IL_NEXT_LIST_IDX(list_idx);
03469
03470 # ifdef _DEBUG
03471 if (BD_LEN_FLD(bd_idx) != CN_Tbl_Idx) {
03472 PRINTMSG(line, 626, Internal, col,
03473 "constant array length",
03474 "gen_init_stmt");
03475 }
03476 # endif
03477 IL_FLD(list_idx) = CN_Tbl_Idx;
03478 IL_IDX(list_idx) = BD_LEN_IDX(bd_idx);
03479 IL_LINE_NUM(list_idx) = line;
03480 IL_COL_NUM(list_idx) = col;
03481
03482
03483
03484 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03485 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03486 list_idx = IL_NEXT_LIST_IDX(list_idx);
03487
03488 # ifdef _SM_UNIT_IS_ELEMENT
03489 sm_bits = sm_unit_in_bits(ATD_TYPE_IDX(array_attr_idx));
03490 C_TO_F_INT(the_constant, sm_bits, Integer_8);
03491 # else
03492 if (TYP_TYPE(ATD_TYPE_IDX(array_attr_idx)) == Structure &&
03493 ATT_CHAR_SEQ(TYP_IDX(ATD_TYPE_IDX(array_attr_idx)))) {
03494 C_TO_F_INT(the_constant, 8, CG_INTEGER_DEFAULT_TYPE);
03495 }
03496 else {
03497 sm_bits = sm_unit_in_bits(ATD_TYPE_IDX(array_attr_idx));
03498 C_TO_F_INT(the_constant, sm_bits, Integer_8);
03499 }
03500 # endif
03501
03502 type_idx = (CG_INTEGER_DEFAULT_TYPE >
03503 TYP_LINEAR(CN_TYPE_IDX(BD_SM_IDX(bd_idx, 1))) ?
03504 CG_INTEGER_DEFAULT_TYPE :
03505 CN_TYPE_IDX(BD_SM_IDX(bd_idx, 1)));
03506
03507
03508 if (folder_driver((char *)&CN_CONST(BD_SM_IDX(bd_idx, 1)),
03509 CN_TYPE_IDX(BD_SM_IDX(bd_idx, 1)),
03510 (char *) the_constant,
03511 CG_INTEGER_DEFAULT_TYPE,
03512 result,
03513 &type_idx,
03514 line,
03515 col,
03516 2,
03517 Mult_Opr)) {
03518
03519 IL_FLD(list_idx) = CN_Tbl_Idx;
03520 IL_IDX(list_idx) = ntr_const_tbl(type_idx,
03521 FALSE,
03522 result);
03523 IL_LINE_NUM(list_idx) = line;
03524 IL_COL_NUM(list_idx) = col;
03525 }
03526 }
03527 else {
03528
03529
03530 copy_subtree(left_opnd, &opnd);
03531 count = create_imp_do_loops(&opnd);
03532 COPY_OPND(IR_OPND_L(init_idx), opnd);
03533
03534 NTR_IR_LIST_TBL(list_idx);
03535 IR_FLD_R(init_idx) = IL_Tbl_Idx;
03536 IR_IDX_R(init_idx) = list_idx;
03537 IR_LIST_CNT_R(init_idx) = 1;
03538
03539 NTR_IR_TBL(mult_idx);
03540 IR_OPR(mult_idx) = Mult_Opr;
03541 IR_TYPE_IDX(mult_idx) = CG_INTEGER_DEFAULT_TYPE;
03542 IR_LINE_NUM(mult_idx) = line;
03543 IR_COL_NUM(mult_idx) = col;
03544 IR_FLD_L(mult_idx) = CN_Tbl_Idx;
03545 IR_IDX_L(mult_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, count);
03546
03547 IR_LINE_NUM_L(mult_idx) = line;
03548 IR_COL_NUM_L(mult_idx) = col;
03549 IR_FLD_R(mult_idx) = CN_Tbl_Idx;
03550 IR_IDX_R(mult_idx) = const_idx;
03551 IR_LINE_NUM_R(mult_idx) = line;
03552 IR_COL_NUM_R(mult_idx) = col;
03553
03554 IL_FLD(list_idx) = IR_Tbl_Idx;
03555 IL_IDX(list_idx) = mult_idx;
03556 }
03557 }
03558 else {
03559
03560 NTR_IR_LIST_TBL(list_idx);
03561 IR_FLD_R(init_idx) = IL_Tbl_Idx;
03562 IR_IDX_R(init_idx) = list_idx;
03563 IR_LIST_CNT_R(init_idx) = 3;
03564
03565 IL_FLD(list_idx) = CN_Tbl_Idx;
03566 IL_IDX(list_idx) = const_idx;
03567 IL_LINE_NUM(list_idx) = line;
03568 IL_COL_NUM(list_idx) = col;
03569
03570 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03571 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03572 list_idx = IL_NEXT_LIST_IDX(list_idx);
03573
03574 IL_FLD(list_idx) = CN_Tbl_Idx;
03575 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
03576 IL_LINE_NUM(list_idx) = line;
03577 IL_COL_NUM(list_idx) = col;
03578
03579 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03580 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03581 list_idx = IL_NEXT_LIST_IDX(list_idx);
03582
03583 IL_FLD(list_idx) = CN_Tbl_Idx;
03584 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
03585 IL_LINE_NUM(list_idx) = line;
03586 IL_COL_NUM(list_idx) = col;
03587 }
03588
03589 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
03590
03591 if (position == After) {
03592 SH_IR_IDX(curr_stmt_sh_idx) = init_idx;
03593 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
03594 }
03595 else {
03596 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = init_idx;
03597 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
03598 }
03599
03600
03601 TRACE (Func_Exit, "gen_init_stmt", NULL);
03602
03603 return;
03604
03605 }
03606 #ifdef KEY
03607
03608
03609
03610
03611
03612
03613
03614
03615
03616
03617
03618 int
03619 do_count_allocatable_cpnt(int attr_idx, int is_array) {
03620 if (!is_array) {
03621 return 0;
03622 }
03623 int element_type_idx = ATD_TYPE_IDX(attr_idx);
03624 if (TYP_TYPE(element_type_idx) != Structure ||
03625 !ATT_ALLOCATABLE_CPNT(TYP_IDX(element_type_idx))) {
03626 return 0;
03627 }
03628 int count = 0;
03629 for (int sn_idx = ATT_FIRST_CPNT_IDX(TYP_IDX(element_type_idx));
03630 sn_idx != NULL_IDX;
03631 sn_idx = SN_SIBLING_LINK(sn_idx)) {
03632 int cpnt_attr_idx = SN_ATTR_IDX(sn_idx);
03633 if (ATD_ALLOCATABLE(cpnt_attr_idx)) {
03634 count += 1;
03635 }
03636
03637 else if (TYP_TYPE(ATD_TYPE_IDX(cpnt_attr_idx)) == Structure) {
03638 count += do_count_allocatable_cpnt(cpnt_attr_idx, 1);
03639 }
03640 }
03641 return count;
03642 }
03643
03644
03645
03646
03647
03648
03649
03650
03651
03652
03653
03654 static int
03655 do_one_operand(int line, int col, int list_idx, fld_type fld, int idx) {
03656 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03657 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03658 list_idx = IL_NEXT_LIST_IDX(list_idx);
03659
03660 IL_FLD(list_idx) = fld;
03661 IL_IDX(list_idx) = idx;
03662 IL_LINE_NUM(list_idx) = line;
03663 IL_COL_NUM(list_idx) = col;
03664 return list_idx;
03665 }
03666
03667
03668
03669
03670
03671
03672
03673
03674
03675
03676
03677 static int
03678 do_alloc_cpnt(int line, int col, int list_idx, int n_allocatable_cpnt) {
03679
03680
03681
03682
03683
03684 return do_one_operand(line, col, list_idx, CN_Tbl_Idx,
03685 (n_allocatable_cpnt ? CN_INTEGER_ONE_IDX : CN_INTEGER_ZERO_IDX));
03686
03687 }
03688
03689
03690
03691
03692
03693
03694
03695
03696
03697
03698
03699
03700
03701
03702
03703 static int
03704 do_alloc_cpnt_offset(int line, int col, int list_idx, int attr_idx,
03705 int n_allocatable_cpnt) {
03706
03707 if (0 == n_allocatable_cpnt) {
03708 return list_idx;
03709 }
03710
03711
03712
03713
03714
03715 int element_type_idx = ATD_TYPE_IDX(attr_idx);
03716 for (int sn_idx = ATT_FIRST_CPNT_IDX(TYP_IDX(element_type_idx));
03717 sn_idx != NULL_IDX;
03718 sn_idx = SN_SIBLING_LINK(sn_idx)) {
03719 int cpnt_attr_idx = SN_ATTR_IDX(sn_idx);
03720 if (ATD_ALLOCATABLE(cpnt_attr_idx)) {
03721 list_idx = do_one_operand(line, col, list_idx,
03722 ATD_OFFSET_FLD(cpnt_attr_idx), ATD_CPNT_OFFSET_IDX(cpnt_attr_idx));
03723 }
03724
03725 else if (TYP_TYPE(ATD_TYPE_IDX(cpnt_attr_idx)) == Structure) {
03726 list_idx = do_alloc_cpnt_offset(line, col, list_idx, cpnt_attr_idx,
03727 n_allocatable_cpnt);
03728 }
03729 }
03730 return list_idx;
03731 }
03732 #endif
03733
03734
03735
03736
03737
03738
03739
03740
03741
03742
03743
03744
03745
03746
03747
03748
03749
03750 void gen_dv_whole_def(opnd_type *dv_opnd,
03751 opnd_type *r_opnd,
03752 expr_arg_type *exp_desc)
03753
03754 {
03755 act_arg_type a_type;
03756 int asg_idx;
03757 #ifdef KEY
03758 int attr_idx = 0;
03759 #else
03760 int attr_idx;
03761 #endif
03762 opnd_type base_opnd;
03763 int col;
03764 int dim = 1;
03765 int dope_idx = NULL_IDX;
03766 int dv_attr_idx;
03767 int dv2_idx;
03768 int i;
03769 int ir_idx;
03770 opnd_type len_opnd;
03771 int line;
03772 int list_idx;
03773 int list2_idx;
03774 int loc_idx;
03775 int max_idx;
03776 int mult_idx;
03777 opnd_type opnd;
03778 long rank;
03779 int rank_idx = NULL_IDX;
03780 opnd_type r_dv_opnd;
03781 int stride_idx;
03782 opnd_type stride_opnd;
03783 #ifdef KEY
03784 int subscript_idx = 0;
03785 #else
03786 int subscript_idx;
03787 #endif
03788 int type_idx;
03789 boolean whole_array;
03790
03791
03792 TRACE (Func_Entry, "gen_dv_whole_def", NULL);
03793
03794 dv_attr_idx = find_base_attr(dv_opnd, &line, &col);
03795
03796 NTR_IR_TBL(asg_idx);
03797 IR_OPR(asg_idx) = Dv_Def_Asg_Opr;
03798 IR_TYPE_IDX(asg_idx) = CG_INTEGER_DEFAULT_TYPE;
03799 IR_LINE_NUM(asg_idx) = line;
03800 IR_COL_NUM(asg_idx) = col;
03801
03802 NTR_IR_TBL(ir_idx);
03803 IR_OPR(ir_idx) = Dv_Whole_Def_Opr;
03804 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
03805 IR_LINE_NUM(ir_idx) = line;
03806 IR_COL_NUM(ir_idx) = col;
03807
03808 COPY_OPND(IR_OPND_L(asg_idx), (*dv_opnd));
03809 IR_FLD_R(asg_idx) = IR_Tbl_Idx;
03810 IR_IDX_R(asg_idx) = ir_idx;
03811
03812 NTR_IR_LIST_TBL(list_idx);
03813 IR_FLD_L(ir_idx) = IL_Tbl_Idx;
03814 IR_IDX_L(ir_idx) = list_idx;
03815
03816 rank = (ATD_ARRAY_IDX(dv_attr_idx) ?
03817 (long) BD_RANK(ATD_ARRAY_IDX(dv_attr_idx)) : 0);
03818 #ifdef KEY
03819 int n_allocatable_cpnt = IR_DV_N_ALLOC_CPNT(ir_idx) =
03820 do_count_allocatable_cpnt(dv_attr_idx, rank);
03821 IR_LIST_CNT_L(ir_idx) = 11 + (3 * rank) + n_allocatable_cpnt;
03822 #else
03823 IR_LIST_CNT_L(ir_idx) = 10 + (3 * rank);
03824 #endif
03825 IR_DV_DIM(ir_idx) = rank;
03826
03827
03828
03829
03830
03831 NTR_IR_TBL(loc_idx);
03832 IR_OPR(loc_idx) = Loc_Opr;
03833 IR_LINE_NUM(loc_idx) = line;
03834 IR_COL_NUM(loc_idx) = col;
03835
03836 if (exp_desc->type == Character) {
03837 IR_TYPE_IDX(loc_idx) = CRI_Ch_Ptr_8;
03838 }
03839 else {
03840 IR_TYPE_IDX(loc_idx) = CRI_Ptr_8;
03841 }
03842
03843 IL_FLD(list_idx) = IR_Tbl_Idx;
03844 IL_IDX(list_idx) = loc_idx;
03845
03846 if (exp_desc->rank == 0) {
03847 COPY_OPND(IR_OPND_L(loc_idx), (*r_opnd));
03848 just_find_dope_and_rank(r_opnd, &rank_idx, &dope_idx);
03849 }
03850 else {
03851 make_base_subtree(r_opnd, &base_opnd, &rank_idx, &dope_idx);
03852 COPY_OPND(IR_OPND_L(loc_idx), base_opnd);
03853 }
03854
03855 # ifdef _TRANSFORM_CHAR_SEQUENCE
03856 # ifdef _TARGET_OS_UNICOS
03857 if (exp_desc->type == Structure &&
03858 ATT_CHAR_SEQ(TYP_IDX(exp_desc->type_idx))) {
03859
03860 IR_TYPE_IDX(loc_idx) = CRI_Ch_Ptr_8;
03861 COPY_OPND(opnd, IR_OPND_L(loc_idx));
03862 transform_char_sequence_ref(&opnd, exp_desc->type_idx);
03863 COPY_OPND(IR_OPND_L(loc_idx), opnd);
03864 }
03865 # endif
03866 # endif
03867
03868
03869
03870
03871
03872
03873 if (rank_idx != NULL_IDX) {
03874 attr_idx = find_base_attr(&IR_OPND_L(rank_idx), &line, &col);
03875
03876 if (ATD_IM_A_DOPE(attr_idx)) {
03877 COPY_OPND(r_dv_opnd, IR_OPND_L(IR_IDX_L(rank_idx)));
03878 }
03879 subscript_idx = IR_IDX_R(rank_idx);
03880 }
03881 else if (exp_desc->rank != 0) {
03882 attr_idx = find_base_attr(r_opnd, &line, &col);
03883
03884 if (ATD_IM_A_DOPE(attr_idx)) {
03885 COPY_OPND(r_dv_opnd, IR_OPND_L(OPND_IDX((*r_opnd))));
03886 }
03887 }
03888 else {
03889 find_opnd_line_and_column(r_opnd, &line, &col);
03890 }
03891
03892 if (exp_desc->rank > 0 &&
03893 ! exp_desc->section) {
03894
03895 whole_array = TRUE;
03896 }
03897 else {
03898 whole_array = FALSE;
03899 }
03900
03901
03902
03903
03904
03905 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03906 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03907 list_idx = IL_NEXT_LIST_IDX(list_idx);
03908 type_idx = ATD_TYPE_IDX(dv_attr_idx);
03909
03910 if (TYP_TYPE(type_idx) == Structure) {
03911 IL_FLD(list_idx) = ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
03912 IL_IDX(list_idx) = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
03913 IL_LINE_NUM(list_idx) = line;
03914 IL_COL_NUM(list_idx) = col;
03915 }
03916 else if (TYP_TYPE(type_idx) == Character) {
03917
03918 COPY_OPND(opnd, exp_desc->char_len);
03919 OPND_LINE_NUM(opnd) = line;
03920 OPND_COL_NUM(opnd) = col;
03921 compute_char_element_len(&opnd, r_opnd, &len_opnd);
03922
03923 COPY_OPND(IL_OPND(list_idx), len_opnd);
03924 IL_LINE_NUM(list_idx) = line;
03925 IL_COL_NUM(list_idx) = col;
03926 }
03927 else {
03928 IL_FLD(list_idx) = CN_Tbl_Idx;
03929 IL_IDX(list_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
03930 storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
03931 IL_LINE_NUM(list_idx) = line;
03932 IL_COL_NUM(list_idx) = col;
03933 }
03934
03935
03936
03937
03938
03939 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03940 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03941 list_idx = IL_NEXT_LIST_IDX(list_idx);
03942
03943 IL_FLD(list_idx) = CN_Tbl_Idx;
03944 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
03945 IL_LINE_NUM(list_idx) = line;
03946 IL_COL_NUM(list_idx) = col;
03947
03948
03949
03950
03951
03952 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03953 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03954 list_idx = IL_NEXT_LIST_IDX(list_idx);
03955
03956 if (dope_idx != NULL_IDX) {
03957
03958 NTR_IR_TBL(dv2_idx);
03959 IR_OPR(dv2_idx) = Dv_Access_Ptr_Alloc;
03960 IR_TYPE_IDX(dv2_idx) = CG_INTEGER_DEFAULT_TYPE;
03961 IR_LINE_NUM(dv2_idx) = line;
03962 IR_COL_NUM(dv2_idx) = col;
03963 COPY_OPND(IR_OPND_L(dv2_idx), IR_OPND_L(dope_idx));
03964 IL_FLD(list_idx) = IR_Tbl_Idx;
03965 IL_IDX(list_idx) = dv2_idx;
03966 }
03967 else {
03968 IL_FLD(list_idx) = CN_Tbl_Idx;
03969 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
03970 IL_LINE_NUM(list_idx) = line;
03971 IL_COL_NUM(list_idx) = col;
03972 }
03973
03974
03975
03976
03977
03978
03979 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
03980 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
03981 list_idx = IL_NEXT_LIST_IDX(list_idx);
03982
03983 IL_FLD(list_idx) = CN_Tbl_Idx;
03984
03985 if (ATD_ALLOCATABLE(dv_attr_idx)) {
03986 IL_IDX(list_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 2);
03987 }
03988 else if (ATD_POINTER(dv_attr_idx)) {
03989 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
03990 }
03991 else {
03992 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
03993 }
03994 IL_LINE_NUM(list_idx) = line;
03995 IL_COL_NUM(list_idx) = col;
03996
03997
03998
03999
04000
04001
04002
04003 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04004 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04005 list_idx = IL_NEXT_LIST_IDX(list_idx);
04006
04007 a_type = get_act_arg_type(exp_desc);
04008
04009 if (a_type == Array_Ptr ||
04010 a_type == Array_Tmp_Ptr ||
04011 a_type == Whole_Ass_Shape ||
04012 a_type == Dv_Contig_Section) {
04013
04014 NTR_IR_TBL(dv2_idx);
04015 IR_OPR(dv2_idx) = Dv_Access_A_Contig;
04016 IR_TYPE_IDX(dv2_idx) = CG_INTEGER_DEFAULT_TYPE;
04017 IR_LINE_NUM(dv2_idx) = line;
04018 IR_COL_NUM(dv2_idx) = col;
04019 COPY_OPND(IR_OPND_L(dv2_idx), IR_OPND_L(dope_idx));
04020 IL_FLD(list_idx) = IR_Tbl_Idx;
04021 IL_IDX(list_idx) = dv2_idx;
04022
04023 }
04024 else if (a_type == Whole_Allocatable ||
04025 a_type == Whole_Tmp_Allocatable ||
04026 a_type == Whole_Sequence ||
04027 a_type == Whole_Tmp_Sequence ||
04028 a_type == Whole_Array_Constant ||
04029 a_type == Contig_Section) {
04030
04031 IL_FLD(list_idx) = CN_Tbl_Idx;
04032 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
04033 IL_LINE_NUM(list_idx) = line;
04034 IL_COL_NUM(list_idx) = col;
04035 }
04036 else {
04037 IL_FLD(list_idx) = CN_Tbl_Idx;
04038 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
04039 IL_LINE_NUM(list_idx) = line;
04040 IL_COL_NUM(list_idx) = col;
04041 }
04042
04043
04044
04045
04046
04047
04048 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04049 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04050 list_idx = IL_NEXT_LIST_IDX(list_idx);
04051
04052 IL_FLD(list_idx) = CN_Tbl_Idx;
04053 IL_IDX(list_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, rank);
04054 IL_LINE_NUM(list_idx) = line;
04055 IL_COL_NUM(list_idx) = col;
04056
04057
04058
04059
04060
04061
04062 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04063 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04064 list_idx = IL_NEXT_LIST_IDX(list_idx);
04065
04066 IL_FLD(list_idx) = CN_Tbl_Idx;
04067 IL_IDX(list_idx) = create_dv_type_code(dv_attr_idx);
04068 IL_LINE_NUM(list_idx) = line;
04069 IL_COL_NUM(list_idx) = col;
04070
04071
04072
04073
04074
04075 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04076 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04077 list_idx = IL_NEXT_LIST_IDX(list_idx);
04078
04079 if (dope_idx != NULL_IDX) {
04080
04081 NTR_IR_TBL(dv2_idx);
04082 IR_OPR(dv2_idx) = Dv_Access_Orig_Base;
04083 IR_TYPE_IDX(dv2_idx) = SA_INTEGER_DEFAULT_TYPE;
04084 IR_LINE_NUM(dv2_idx) = line;
04085 IR_COL_NUM(dv2_idx) = col;
04086 COPY_OPND(IR_OPND_L(dv2_idx), IR_OPND_L(dope_idx));
04087 IL_FLD(list_idx) = IR_Tbl_Idx;
04088 IL_IDX(list_idx) = dv2_idx;
04089 }
04090 else {
04091 IL_FLD(list_idx) = CN_Tbl_Idx;
04092 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
04093 IL_LINE_NUM(list_idx) = line;
04094 IL_COL_NUM(list_idx) = col;
04095 }
04096
04097
04098
04099
04100
04101
04102 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04103 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04104 list_idx = IL_NEXT_LIST_IDX(list_idx);
04105
04106 if (dope_idx != NULL_IDX) {
04107
04108 NTR_IR_TBL(dv2_idx);
04109 IR_OPR(dv2_idx) = Dv_Access_Orig_Size;
04110 IR_TYPE_IDX(dv2_idx) = SA_INTEGER_DEFAULT_TYPE;
04111 IR_LINE_NUM(dv2_idx) = line;
04112 IR_COL_NUM(dv2_idx) = col;
04113 COPY_OPND(IR_OPND_L(dv2_idx), IR_OPND_L(dope_idx));
04114 IL_FLD(list_idx) = IR_Tbl_Idx;
04115 IL_IDX(list_idx) = dv2_idx;
04116 }
04117 else {
04118 IL_FLD(list_idx) = CN_Tbl_Idx;
04119 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
04120 IL_LINE_NUM(list_idx) = line;
04121 IL_COL_NUM(list_idx) = col;
04122 }
04123
04124 #ifdef KEY
04125 list_idx = do_alloc_cpnt(line, col, list_idx, n_allocatable_cpnt);
04126 #endif
04127
04128 for (i = 1; i <= rank; i++) {
04129
04130
04131
04132
04133
04134 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04135 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04136 list_idx = IL_NEXT_LIST_IDX(list_idx);
04137
04138 if (whole_array) {
04139
04140 if (ATD_IM_A_DOPE(attr_idx) &&
04141 BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) != Assumed_Shape) {
04142 NTR_IR_TBL(dv2_idx);
04143 IR_OPR(dv2_idx) = Dv_Access_Low_Bound;
04144 IR_TYPE_IDX(dv2_idx) = SA_INTEGER_DEFAULT_TYPE;
04145 IR_LINE_NUM(dv2_idx) = line;
04146 IR_COL_NUM(dv2_idx) = col;
04147 COPY_OPND(IR_OPND_L(dv2_idx), r_dv_opnd);
04148 IR_DV_DIM(dv2_idx) = i;
04149 IL_FLD(list_idx) = IR_Tbl_Idx;
04150 IL_IDX(list_idx) = dv2_idx;
04151 }
04152 else {
04153 IL_FLD(list_idx) = BD_LB_FLD(ATD_ARRAY_IDX(attr_idx), i);
04154 IL_IDX(list_idx) = BD_LB_IDX(ATD_ARRAY_IDX(attr_idx), i);
04155 IL_LINE_NUM(list_idx) = line;
04156 IL_COL_NUM(list_idx) = col;
04157
04158 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
04159 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
04160 }
04161 }
04162 }
04163 else {
04164
04165 IL_FLD(list_idx) = CN_Tbl_Idx;
04166 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
04167 IL_LINE_NUM(list_idx) = line;
04168 IL_COL_NUM(list_idx) = col;
04169 }
04170
04171
04172
04173
04174
04175
04176 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04177 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04178 list_idx = IL_NEXT_LIST_IDX(list_idx);
04179
04180 NTR_IR_TBL(max_idx);
04181 IR_OPR(max_idx) = Max_Opr;
04182 IR_TYPE_IDX(max_idx) = CG_INTEGER_DEFAULT_TYPE;
04183 IR_LINE_NUM(max_idx) = line;
04184 IR_COL_NUM(max_idx) = col;
04185
04186 NTR_IR_LIST_TBL(list2_idx);
04187 IR_FLD_L(max_idx) = IL_Tbl_Idx;
04188 IR_LIST_CNT_L(max_idx) = 2;
04189 IR_IDX_L(max_idx) = list2_idx;
04190
04191 IL_FLD(list2_idx) = CN_Tbl_Idx;
04192 IL_IDX(list2_idx) = CN_INTEGER_ZERO_IDX;
04193 IL_LINE_NUM(list2_idx) = line;
04194 IL_COL_NUM(list2_idx) = col;
04195
04196 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list2_idx));
04197 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list2_idx)) = list2_idx;
04198 list2_idx = IL_NEXT_LIST_IDX(list2_idx);
04199
04200 COPY_OPND(IL_OPND(list2_idx), exp_desc->shape[i-1]);
04201 IL_LINE_NUM(list2_idx) = line;
04202 IL_COL_NUM(list2_idx) = col;
04203
04204 IL_FLD(list_idx) = IR_Tbl_Idx;
04205 IL_IDX(list_idx) = max_idx;
04206
04207
04208
04209
04210
04211 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04212 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04213 list_idx = IL_NEXT_LIST_IDX(list_idx);
04214
04215 if (whole_array) {
04216
04217 gen_dv_stride_mult(&stride_opnd,
04218 attr_idx,
04219 &r_dv_opnd,
04220 exp_desc,
04221 i,
04222 line,
04223 col);
04224
04225 COPY_OPND(IL_OPND(list_idx), stride_opnd);
04226
04227 }
04228 else {
04229 while (IL_FLD(subscript_idx) != IR_Tbl_Idx ||
04230 IR_OPR(IL_IDX(subscript_idx)) != Triplet_Opr) {
04231 subscript_idx = IL_NEXT_LIST_IDX(subscript_idx);
04232 dim++;
04233 }
04234
04235 gen_dv_stride_mult(&stride_opnd,
04236 attr_idx,
04237 &r_dv_opnd,
04238 exp_desc,
04239 dim,
04240 line,
04241 col);
04242
04243 stride_idx = IL_NEXT_LIST_IDX(IL_NEXT_LIST_IDX(IR_IDX_L(
04244 IL_IDX(subscript_idx))));
04245
04246 mult_idx = gen_ir(OPND_FLD(stride_opnd), OPND_IDX(stride_opnd),
04247 Mult_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
04248 IL_FLD(stride_idx), IL_IDX(stride_idx));
04249
04250 IL_FLD(list_idx) = IR_Tbl_Idx;
04251 IL_IDX(list_idx) = mult_idx;
04252
04253 subscript_idx = IL_NEXT_LIST_IDX(subscript_idx);
04254 dim++;
04255 }
04256 }
04257
04258 #ifdef KEY
04259 list_idx = do_alloc_cpnt_offset(line, col, list_idx, dv_attr_idx,
04260 n_allocatable_cpnt);
04261 #endif
04262
04263 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
04264
04265 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
04266 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
04267
04268 TRACE (Func_Exit, "gen_dv_whole_def", NULL);
04269
04270 return;
04271
04272 }
04273
04274
04275
04276
04277
04278
04279
04280
04281
04282
04283
04284
04285
04286
04287
04288
04289
04290 static void gen_dv_stride_mult(opnd_type *stride_opnd,
04291 int attr_idx,
04292 opnd_type *r_dv_opnd,
04293 expr_arg_type *exp_desc,
04294 int dim,
04295 int line,
04296 int col)
04297
04298 {
04299 # if defined(_EXTENDED_CRI_CHAR_POINTER)
04300 int clen_idx;
04301 # endif
04302
04303 int cn_idx;
04304 int dv_idx;
04305 int ir_idx;
04306 long64 res_sm_unit_in_bits;
04307 long64 src_sm_unit_in_bits;
04308
04309
04310 TRACE (Func_Entry, "gen_dv_stride_mult", NULL);
04311
04312
04313
04314 if (exp_desc->type == Structure &&
04315 ATT_CHAR_SEQ(TYP_IDX(exp_desc->type_idx))) {
04316 res_sm_unit_in_bits = sm_unit_in_bits(Character_1);
04317 }
04318 else {
04319 res_sm_unit_in_bits = sm_unit_in_bits(exp_desc->type_idx);
04320 #if 0
04321
04322 # ifdef _WHIRL_HOST64_TARGET64
04323 if (res_sm_unit_in_bits > 32)
04324 res_sm_unit_in_bits = 32;
04325 # endif
04326 #endif
04327 }
04328
04329
04330
04331 if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Structure &&
04332 ATT_CHAR_SEQ(TYP_IDX(ATD_TYPE_IDX(attr_idx)))) {
04333 src_sm_unit_in_bits = sm_unit_in_bits(Character_1);
04334 }
04335 else {
04336 src_sm_unit_in_bits = sm_unit_in_bits(ATD_TYPE_IDX(attr_idx));
04337 }
04338
04339 # ifdef _DEBUG
04340 if (res_sm_unit_in_bits == 0 || src_sm_unit_in_bits == 0) {
04341 PRINTMSG(line, 626, Internal, col,
04342 "stride_mult_unit_in_bits",
04343 "gen_dv_stride_mult");
04344 }
04345 # endif
04346
04347
04348 if (ATD_IM_A_DOPE(attr_idx)) {
04349 NTR_IR_TBL(dv_idx);
04350 IR_OPR(dv_idx) = Dv_Access_Stride_Mult;
04351 IR_TYPE_IDX(dv_idx) = SA_INTEGER_DEFAULT_TYPE;
04352 IR_LINE_NUM(dv_idx) = line;
04353 IR_COL_NUM(dv_idx) = col;
04354 COPY_OPND(IR_OPND_L(dv_idx), (*r_dv_opnd));
04355 IR_DV_DIM(dv_idx) = dim;
04356
04357 OPND_FLD((*stride_opnd)) = IR_Tbl_Idx;
04358 OPND_IDX((*stride_opnd)) = dv_idx;
04359 #ifdef _WHIRL_HOST64_TARGET64
04360
04361
04362
04363
04364
04365
04366
04367 res_sm_unit_in_bits=src_sm_unit_in_bits;
04368 #endif
04369 }
04370 else {
04371 OPND_FLD((*stride_opnd)) = BD_SM_FLD(ATD_ARRAY_IDX(attr_idx), dim);
04372 OPND_IDX((*stride_opnd)) = BD_SM_IDX(ATD_ARRAY_IDX(attr_idx), dim);
04373 OPND_LINE_NUM((*stride_opnd)) = line;
04374 OPND_COL_NUM((*stride_opnd)) = col;
04375
04376 if (OPND_FLD((*stride_opnd)) == AT_Tbl_Idx) {
04377 ADD_TMP_TO_SHARED_LIST(OPND_IDX((*stride_opnd)));
04378 }
04379
04380 # if defined(_EXTENDED_CRI_CHAR_POINTER)
04381 if (ATD_CLASS(attr_idx) == CRI__Pointee &&
04382 # if defined(KEY)
04383 AT_IS_DARG(attr_idx) &&
04384 # endif
04385 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
04386
04387 NTR_IR_TBL(ir_idx);
04388 IR_OPR(ir_idx) = Mult_Opr;
04389 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
04390 IR_LINE_NUM(ir_idx) = line;
04391 IR_COL_NUM(ir_idx) = col;
04392
04393 COPY_OPND(IR_OPND_L(ir_idx), (*stride_opnd));
04394
04395 NTR_IR_TBL(clen_idx);
04396 IR_OPR(clen_idx) = Clen_Opr;
04397 IR_TYPE_IDX(clen_idx) = CG_INTEGER_DEFAULT_TYPE;
04398 IR_LINE_NUM(clen_idx) = line;
04399 IR_COL_NUM(clen_idx) = col;
04400 IR_FLD_L(clen_idx) = AT_Tbl_Idx;
04401 IR_IDX_L(clen_idx) = attr_idx;
04402 IR_LINE_NUM_L(clen_idx) = line;
04403 IR_COL_NUM_L(clen_idx) = col;
04404
04405 IR_FLD_R(ir_idx) = IR_Tbl_Idx;
04406 IR_IDX_R(ir_idx) = clen_idx;
04407
04408 OPND_FLD((*stride_opnd)) = IR_Tbl_Idx;
04409 OPND_IDX((*stride_opnd)) = ir_idx;
04410 }
04411 # endif
04412 }
04413
04414 # ifndef _SM_UNIT_IS_ELEMENT
04415 if (src_sm_unit_in_bits != res_sm_unit_in_bits) {
04416
04417
04418
04419
04420
04421 cn_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
04422 (src_sm_unit_in_bits / res_sm_unit_in_bits));
04423
04424 ir_idx = gen_ir(OPND_FLD((*stride_opnd)),
04425 OPND_IDX((*stride_opnd)),
04426 Mult_Opr,
04427 CG_INTEGER_DEFAULT_TYPE,
04428 line,
04429 col,
04430 CN_Tbl_Idx,
04431 cn_idx);
04432
04433 OPND_FLD((*stride_opnd)) = IR_Tbl_Idx;
04434 OPND_IDX((*stride_opnd)) = ir_idx;
04435 }
04436 # endif
04437
04438
04439 TRACE (Func_Exit, "gen_dv_stride_mult", NULL);
04440
04441 return;
04442
04443 }
04444
04445 #ifdef KEY
04446
04447
04448
04449
04450
04451
04452
04453
04454 static void
04455 insert_dv_deref(int line, int col, int parent_idx, int child_idx) {
04456 int dv_deref_idx;
04457 NTR_IR_TBL(dv_deref_idx);
04458 IR_OPR(dv_deref_idx) = Dv_Deref_Opr;
04459 IR_TYPE_IDX(dv_deref_idx) = ATD_TYPE_IDX(child_idx);
04460 IR_LINE_NUM_L(dv_deref_idx) = IR_LINE_NUM(dv_deref_idx) = line;
04461 IR_COL_NUM_L(dv_deref_idx) = IR_COL_NUM(dv_deref_idx) = col;
04462 IR_FLD_L(dv_deref_idx) = AT_Tbl_Idx;
04463 IR_IDX_L(dv_deref_idx) = child_idx;
04464 IR_FLD_R(dv_deref_idx) = NO_Tbl_Idx;
04465 IR_IDX_R(dv_deref_idx) = NULL_IDX;
04466 IR_FLD_L(parent_idx) = IR_Tbl_Idx;
04467 IR_IDX_L(parent_idx) = dv_deref_idx;
04468 }
04469
04470
04471
04472
04473
04474
04475
04476
04477
04478
04479 int
04480 pre_gen_loops(int line, int col, int *next_sh_idx) {
04481 gen_sh(After, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
04482 *next_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
04483 return curr_stmt_sh_idx;
04484 }
04485
04486
04487
04488
04489
04490
04491
04492
04493 void
04494 post_gen_loops(int placeholder_sh_idx, int next_sh_idx) {
04495 remove_sh(placeholder_sh_idx);
04496 FREE_SH_NODE(placeholder_sh_idx);
04497 if (next_sh_idx != NULL_IDX) {
04498 curr_stmt_sh_idx = SH_PREV_IDX(next_sh_idx);
04499 }
04500 else {
04501 while (SH_NEXT_IDX(curr_stmt_sh_idx) != NULL_IDX) {
04502 curr_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
04503 }
04504 }
04505 }
04506
04507
04508
04509
04510
04511
04512
04513
04514
04515
04516
04517
04518
04519
04520
04521
04522
04523
04524
04525
04526
04527
04528
04529 void
04530 gen_loops(opnd_type *opnd_l, opnd_type *opnd_r, boolean deref)
04531 {
04532 int col;
04533 int line;
04534 opnd_type temp_l;
04535
04536 TRACE (Func_Entry, "gen_loops", NULL);
04537
04538 find_opnd_line_and_column(opnd_l, &line, &col);
04539
04540 opnd_type next;
04541 int subscripts[STATIC_SUBSCRIPT_SIZE];
04542 int subscript_cnt = 0;
04543 for (COPY_OPND(temp_l, *opnd_l);
04544 (OPND_FLD(temp_l) == IR_Tbl_Idx);
04545 COPY_OPND(temp_l, next)) {
04546
04547 operator_type ir_opr = IR_OPR(OPND_IDX(temp_l));
04548 if (ir_opr == Whole_Subscript_Opr || ir_opr == Section_Subscript_Opr) {
04549
04550 IR_OPR(OPND_IDX(temp_l)) = Subscript_Opr;
04551
04552 for (int list_idx = IR_IDX_R(OPND_IDX(temp_l));
04553 list_idx != NULL_IDX;
04554 list_idx = IL_NEXT_LIST_IDX(list_idx)) {
04555
04556 if (IL_FLD(list_idx) == IR_Tbl_Idx &&
04557 IR_OPR(IL_IDX(list_idx)) == Triplet_Opr) {
04558
04559 int tmp_idx = subscripts[subscript_cnt++] =
04560 gen_compiler_tmp(line, col, Priv, TRUE);
04561
04562 ATD_TYPE_IDX(tmp_idx) = CG_INTEGER_DEFAULT_TYPE;
04563 ATD_STOR_BLK_IDX(tmp_idx) = SCP_SB_STACK_IDX(curr_scp_idx);
04564 AT_SEMANTICS_DONE(tmp_idx) = TRUE;
04565
04566 int list_idx2 = IR_IDX_L(IL_IDX(list_idx));
04567 opnd_type start_opnd;
04568 opnd_type stride_opnd;
04569 opnd_type end_opnd;
04570
04571 COPY_OPND(start_opnd, IL_OPND(list_idx2));
04572
04573 list_idx2 = IL_NEXT_LIST_IDX(list_idx2);
04574 COPY_OPND(end_opnd, IL_OPND(list_idx2));
04575
04576 list_idx2 = IL_NEXT_LIST_IDX(list_idx2);
04577 COPY_OPND(stride_opnd, IL_OPND(list_idx2));
04578
04579 create_loop_stmts(tmp_idx, &start_opnd, &end_opnd, &stride_opnd,
04580 curr_stmt_sh_idx,
04581 curr_stmt_sh_idx);
04582
04583 IL_FLD(list_idx) = AT_Tbl_Idx;
04584 IL_IDX(list_idx) = tmp_idx;
04585 IL_LINE_NUM(list_idx) = line;
04586 IL_COL_NUM(list_idx) = col;
04587 }
04588 }
04589 }
04590
04591 next = IR_OPND_L(OPND_IDX(temp_l));
04592 if (deref && ir_opr != Dv_Deref_Opr && OPND_FLD(next) == AT_Tbl_Idx &&
04593 ATD_IM_A_DOPE(OPND_IDX(next))) {
04594 insert_dv_deref(line, col, OPND_IDX(temp_l), OPND_IDX(next));
04595 }
04596 }
04597
04598 if (opnd_r) {
04599 subscript_cnt = 0;
04600 opnd_type temp_r;
04601 for (COPY_OPND(temp_r, (*opnd_r));
04602 OPND_FLD(temp_r) == IR_Tbl_Idx;
04603 COPY_OPND(temp_r, next)) {
04604
04605 operator_type ir_opr = IR_OPR(OPND_IDX(temp_r));
04606 if (ir_opr == Whole_Subscript_Opr || ir_opr == Section_Subscript_Opr) {
04607
04608 IR_OPR(OPND_IDX(temp_r)) = Subscript_Opr;
04609
04610 for (int list_idx = IR_IDX_R(OPND_IDX(temp_r));
04611 list_idx != NULL_IDX;
04612 list_idx = IL_NEXT_LIST_IDX(list_idx)) {
04613
04614 if (IL_FLD(list_idx) == IR_Tbl_Idx &&
04615 IR_OPR(IL_IDX(list_idx)) == Triplet_Opr) {
04616
04617 IL_FLD(list_idx) = AT_Tbl_Idx;
04618 IL_IDX(list_idx) = subscripts[subscript_cnt++];
04619 IL_LINE_NUM(list_idx) = line;
04620 IL_COL_NUM(list_idx) = col;
04621 }
04622 }
04623 }
04624
04625 next = IR_OPND_L(OPND_IDX(temp_r));
04626 if (deref && ir_opr != Dv_Deref_Opr && OPND_FLD(next) == AT_Tbl_Idx &&
04627 ATD_IM_A_DOPE(OPND_IDX(next))) {
04628 insert_dv_deref(line, col, OPND_IDX(temp_r), OPND_IDX(next));
04629 }
04630 }
04631 }
04632
04633 TRACE (Func_Exit, "gen_loops", NULL);
04634 }
04635
04636
04637
04638
04639
04640
04641
04642
04643
04644
04645
04646
04647
04648
04649
04650
04651
04652 static void
04653 gen_dv_def_loops(opnd_type *dv_opnd)
04654
04655 {
04656 gen_loops(dv_opnd, 0, FALSE);
04657 }
04658 #endif
04659
04660
04661
04662
04663
04664
04665
04666
04667
04668
04669
04670
04671
04672
04673
04674
04675 void gen_dv_whole_def_init(opnd_type *dv_opnd,
04676 int dv_attr_idx,
04677 sh_position_type position)
04678
04679 {
04680 int asg_idx;
04681 int col;
04682 int i;
04683 int ir_idx;
04684 size_offset_type length;
04685 int line;
04686 int list_idx;
04687 int mult_idx;
04688 long rank;
04689 size_offset_type result;
04690 int type_idx;
04691
04692
04693 TRACE (Func_Entry, "gen_dv_whole_def_init", NULL);
04694
04695 find_opnd_line_and_column(dv_opnd, &line, &col);
04696
04697 NTR_IR_TBL(asg_idx);
04698 IR_OPR(asg_idx) = Dv_Def_Asg_Opr;
04699 IR_TYPE_IDX(asg_idx) = CG_INTEGER_DEFAULT_TYPE;
04700 IR_LINE_NUM(asg_idx) = line;
04701 IR_COL_NUM(asg_idx) = col;
04702
04703 NTR_IR_TBL(ir_idx);
04704 IR_OPR(ir_idx) = Dv_Whole_Def_Opr;
04705 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
04706 IR_LINE_NUM(ir_idx) = line;
04707 IR_COL_NUM(ir_idx) = col;
04708
04709 COPY_OPND(IR_OPND_L(asg_idx), (*dv_opnd));
04710 IR_FLD_R(asg_idx) = IR_Tbl_Idx;
04711 IR_IDX_R(asg_idx) = ir_idx;
04712
04713 NTR_IR_LIST_TBL(list_idx);
04714 IR_FLD_L(ir_idx) = IL_Tbl_Idx;
04715 IR_IDX_L(ir_idx) = list_idx;
04716
04717 rank = ATD_ARRAY_IDX(dv_attr_idx) ?
04718 (long) BD_RANK(ATD_ARRAY_IDX(dv_attr_idx)) : 0;
04719 #ifdef KEY
04720 int n_allocatable_cpnt = IR_DV_N_ALLOC_CPNT(ir_idx) =
04721 do_count_allocatable_cpnt(dv_attr_idx, rank);
04722 IR_LIST_CNT_L(ir_idx) = 11 + (3 * rank) + n_allocatable_cpnt;
04723 #else
04724 IR_LIST_CNT_L(ir_idx) = 10 + (3 * rank);
04725 #endif
04726 IR_DV_DIM(ir_idx) = rank;
04727
04728
04729
04730
04731
04732 #ifdef KEY
04733
04734
04735
04736 IL_FLD(list_idx) = IR_Tbl_Idx;
04737 IL_LINE_NUM(list_idx) = line;
04738 IL_COL_NUM(list_idx) = col;
04739
04740 int fcd_idx;
04741 NTR_IR_TBL(fcd_idx);
04742 IL_IDX(list_idx) = fcd_idx;
04743 IR_OPR(fcd_idx) = Aloc_Opr;
04744 IR_TYPE_IDX(fcd_idx) = CRI_Ptr_8;
04745 IR_LINE_NUM(fcd_idx) = line;
04746 IR_COL_NUM(fcd_idx) = col;
04747
04748 IR_FLD_L(fcd_idx) = CN_Tbl_Idx;
04749 IR_IDX_L(fcd_idx) = (SA_INTEGER_DEFAULT_TYPE == CG_INTEGER_DEFAULT_TYPE) ?
04750 CN_INTEGER_ZERO_IDX :
04751 C_INT_TO_CN(SA_INTEGER_DEFAULT_TYPE, 0);
04752 IR_LINE_NUM_L(fcd_idx) = line;
04753 IR_COL_NUM_L(fcd_idx) = col;
04754 #else
04755
04756 #endif
04757
04758
04759
04760
04761
04762 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04763 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04764 list_idx = IL_NEXT_LIST_IDX(list_idx);
04765 type_idx = ATD_TYPE_IDX(dv_attr_idx);
04766
04767 if (TYP_TYPE(type_idx) == Structure) {
04768 IL_FLD(list_idx) = (fld_type) ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
04769 IL_IDX(list_idx) = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
04770 IL_LINE_NUM(list_idx) = line;
04771 IL_COL_NUM(list_idx) = col;
04772 }
04773 else if (TYP_TYPE(type_idx) == Character) {
04774
04775 IL_FLD(list_idx) = TYP_FLD(type_idx);
04776 IL_IDX(list_idx) = TYP_IDX(type_idx);
04777 IL_LINE_NUM(list_idx) = line;
04778 IL_COL_NUM(list_idx) = col;
04779
04780 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
04781 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
04782 }
04783
04784 if (! char_len_in_bytes) {
04785
04786
04787
04788 if (TYP_FLD(type_idx) == CN_Tbl_Idx) {
04789 result.fld = CN_Tbl_Idx;
04790 result.idx = CN_INTEGER_CHAR_BIT_IDX;
04791 length.fld = TYP_FLD(type_idx);
04792 length.idx = TYP_IDX(type_idx);
04793
04794 size_offset_binary_calc(&length,
04795 &result,
04796 Mult_Opr,
04797 &result);
04798
04799 if (result.fld == NO_Tbl_Idx) {
04800 IL_FLD(list_idx) = CN_Tbl_Idx;
04801 IL_IDX(list_idx) = ntr_const_tbl(result.type_idx,
04802 FALSE,
04803 result.constant);
04804 }
04805 else {
04806 IL_FLD(list_idx) = result.fld;
04807 IL_IDX(list_idx) = result.idx;
04808 }
04809
04810 IL_LINE_NUM(list_idx) = line;
04811 IL_COL_NUM(list_idx) = col;
04812 }
04813 else {
04814 NTR_IR_TBL(mult_idx);
04815 IR_OPR(mult_idx) = Mult_Opr;
04816 IR_TYPE_IDX(mult_idx) = CG_INTEGER_DEFAULT_TYPE;
04817 IR_LINE_NUM(mult_idx) = line;
04818 IR_COL_NUM(mult_idx) = col;
04819 IR_FLD_L(mult_idx) = CN_Tbl_Idx;
04820 IR_IDX_L(mult_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 8);
04821 IR_LINE_NUM_L(mult_idx) = line;
04822 IR_COL_NUM_L(mult_idx) = col;
04823
04824 IR_FLD_R(mult_idx) = TYP_FLD(type_idx);
04825 IR_IDX_R(mult_idx) = TYP_IDX(type_idx);
04826 IR_LINE_NUM_R(mult_idx) = line;
04827 IR_COL_NUM_R(mult_idx) = col;
04828
04829 IL_FLD(list_idx) = IR_Tbl_Idx;
04830 IL_IDX(list_idx) = mult_idx;
04831 }
04832 }
04833 }
04834 else {
04835 IL_FLD(list_idx) = CN_Tbl_Idx;
04836 IL_IDX(list_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
04837 storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
04838 IL_LINE_NUM(list_idx) = line;
04839 IL_COL_NUM(list_idx) = col;
04840 }
04841
04842
04843
04844
04845
04846 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04847 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04848 list_idx = IL_NEXT_LIST_IDX(list_idx);
04849
04850 IL_FLD(list_idx) = CN_Tbl_Idx;
04851 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
04852 IL_LINE_NUM(list_idx) = line;
04853 IL_COL_NUM(list_idx) = col;
04854
04855
04856
04857
04858
04859 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04860 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04861 list_idx = IL_NEXT_LIST_IDX(list_idx);
04862
04863 IL_FLD(list_idx) = CN_Tbl_Idx;
04864 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
04865 IL_LINE_NUM(list_idx) = line;
04866 IL_COL_NUM(list_idx) = col;
04867
04868
04869
04870
04871
04872
04873 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04874 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04875 list_idx = IL_NEXT_LIST_IDX(list_idx);
04876
04877 IL_FLD(list_idx) = CN_Tbl_Idx;
04878
04879 if (ATD_ALLOCATABLE(dv_attr_idx)) {
04880 IL_IDX(list_idx) = CN_INTEGER_TWO_IDX;
04881 }
04882 else if (ATD_POINTER(dv_attr_idx)) {
04883 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
04884 }
04885 else {
04886 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
04887 }
04888 IL_LINE_NUM(list_idx) = line;
04889 IL_COL_NUM(list_idx) = col;
04890
04891
04892
04893
04894
04895
04896
04897 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04898 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04899 list_idx = IL_NEXT_LIST_IDX(list_idx);
04900
04901 IL_FLD(list_idx) = CN_Tbl_Idx;
04902
04903 if (ATD_ALLOCATABLE(dv_attr_idx)) {
04904 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
04905 }
04906 else {
04907 #ifdef KEY
04908
04909
04910
04911
04912
04913
04914
04915
04916 IL_IDX(list_idx) = rank ? CN_INTEGER_ONE_IDX : CN_INTEGER_ZERO_IDX;
04917 #else
04918 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
04919 #endif
04920 }
04921 IL_LINE_NUM(list_idx) = line;
04922 IL_COL_NUM(list_idx) = col;
04923
04924
04925
04926
04927
04928
04929 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04930 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04931 list_idx = IL_NEXT_LIST_IDX(list_idx);
04932
04933 IL_FLD(list_idx) = CN_Tbl_Idx;
04934 IL_IDX(list_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, rank);
04935 IL_LINE_NUM(list_idx) = line;
04936 IL_COL_NUM(list_idx) = col;
04937
04938
04939
04940
04941
04942
04943 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04944 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04945 list_idx = IL_NEXT_LIST_IDX(list_idx);
04946
04947 IL_FLD(list_idx) = CN_Tbl_Idx;
04948 IL_IDX(list_idx) = create_dv_type_code(dv_attr_idx);
04949 IL_LINE_NUM(list_idx) = line;
04950 IL_COL_NUM(list_idx) = col;
04951
04952
04953
04954
04955
04956 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04957 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04958 list_idx = IL_NEXT_LIST_IDX(list_idx);
04959
04960 IL_FLD(list_idx) = CN_Tbl_Idx;
04961 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
04962 IL_LINE_NUM(list_idx) = line;
04963 IL_COL_NUM(list_idx) = col;
04964
04965
04966
04967
04968
04969 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04970 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04971 list_idx = IL_NEXT_LIST_IDX(list_idx);
04972
04973 IL_FLD(list_idx) = CN_Tbl_Idx;
04974 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
04975 IL_LINE_NUM(list_idx) = line;
04976 IL_COL_NUM(list_idx) = col;
04977
04978 #ifdef KEY
04979 list_idx = do_alloc_cpnt(line, col, list_idx, n_allocatable_cpnt);
04980 #endif
04981
04982 for (i = 1; i <= rank; i++) {
04983
04984
04985
04986
04987
04988 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
04989 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
04990 list_idx = IL_NEXT_LIST_IDX(list_idx);
04991
04992 if (cmd_line_flags.runtime_bounds) {
04993 IL_FLD(list_idx) = CN_Tbl_Idx;
04994 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
04995 IL_LINE_NUM(list_idx) = line;
04996 IL_COL_NUM(list_idx) = col;
04997 }
04998
04999
05000
05001
05002
05003 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
05004 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
05005 list_idx = IL_NEXT_LIST_IDX(list_idx);
05006
05007 if (cmd_line_flags.runtime_bounds) {
05008 IL_FLD(list_idx) = CN_Tbl_Idx;
05009 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
05010 IL_LINE_NUM(list_idx) = line;
05011 IL_COL_NUM(list_idx) = col;
05012 }
05013
05014
05015
05016
05017
05018 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
05019 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
05020 list_idx = IL_NEXT_LIST_IDX(list_idx);
05021
05022 if (cmd_line_flags.runtime_bounds) {
05023 IL_FLD(list_idx) = CN_Tbl_Idx;
05024 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
05025 IL_LINE_NUM(list_idx) = line;
05026 IL_COL_NUM(list_idx) = col;
05027 }
05028 }
05029
05030 #ifdef KEY
05031 list_idx = do_alloc_cpnt_offset(line, col, list_idx, dv_attr_idx,
05032 n_allocatable_cpnt);
05033 #endif
05034
05035 gen_sh(position, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
05036
05037 if (position == After) {
05038 SH_IR_IDX(curr_stmt_sh_idx) = asg_idx;
05039 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
05040 }
05041 else {
05042 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
05043 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
05044 }
05045
05046 TRACE (Func_Exit, "gen_dv_whole_def_init", NULL);
05047
05048 return;
05049
05050 }
05051
05052
05053
05054
05055
05056
05057
05058
05059
05060
05061
05062
05063
05064
05065
05066
05067
05068
05069
05070
05071
05072 void make_base_subtree(opnd_type *old_opnd,
05073 opnd_type *new_opnd,
05074 int *rank_idx,
05075 int *dope_idx)
05076
05077 {
05078 int col;
05079 int dummy_idx;
05080 fld_type fld;
05081 int idx;
05082 int line;
05083 int list_idx;
05084 int list2_idx;
05085 int new_root = NULL_IDX;
05086 opnd_type n_opnd;
05087 opnd_type o_opnd;
05088
05089
05090 TRACE (Func_Entry, "make_base_subtree", NULL);
05091
05092 find_opnd_line_and_column(old_opnd, &line, &col);
05093
05094 OPND_FLD((*new_opnd)) = OPND_FLD((*old_opnd));
05095 idx = OPND_IDX((*old_opnd));
05096 fld = OPND_FLD((*old_opnd));
05097
05098
05099 if (idx != NULL_IDX) {
05100
05101 switch(fld) {
05102
05103 case NO_Tbl_Idx :
05104 break;
05105
05106 case IR_Tbl_Idx :
05107
05108 if (IR_OPR(idx) == Triplet_Opr) {
05109 COPY_OPND(o_opnd, IL_OPND(IR_IDX_L(idx)));
05110 make_base_subtree(&o_opnd, new_opnd, rank_idx, &dummy_idx);
05111 goto SKIP;
05112 }
05113 else if (IR_OPR(idx) == Call_Opr) {
05114
05115
05116
05117
05118 new_root = idx;
05119 }
05120 else {
05121
05122 NTR_IR_TBL(new_root);
05123
05124 COPY_TBL_NTRY(ir_tbl, new_root, idx);
05125
05126
05127 IR_RANK(new_root) = 0;
05128
05129 if (IR_OPR(new_root) == Whole_Subscript_Opr ||
05130 IR_OPR(new_root) == Section_Subscript_Opr) {
05131
05132 if (*rank_idx != NULL_IDX) {
05133 PRINTMSG(IR_LINE_NUM(idx), 545, Internal, IR_COL_NUM(idx));
05134 }
05135 *rank_idx = idx;
05136
05137 IR_OPR(new_root) = Subscript_Opr;
05138 }
05139 else if (IR_OPR(idx) == Dv_Deref_Opr &&
05140 *dope_idx == NULL_IDX) {
05141 *dope_idx = idx;
05142 }
05143
05144 COPY_OPND(o_opnd, IR_OPND_L(idx));
05145 make_base_subtree(&o_opnd, &n_opnd, rank_idx, dope_idx);
05146 COPY_OPND(IR_OPND_L(new_root), n_opnd);
05147
05148 COPY_OPND(o_opnd, IR_OPND_R(idx));
05149 make_base_subtree(&o_opnd, &n_opnd, rank_idx, &dummy_idx);
05150 COPY_OPND(IR_OPND_R(new_root), n_opnd);
05151 }
05152
05153 break;
05154
05155 case AT_Tbl_Idx :
05156 case CN_Tbl_Idx :
05157
05158 new_root = idx;
05159 OPND_LINE_NUM((*new_opnd)) = line;
05160 OPND_COL_NUM((*new_opnd)) = col;
05161 break;
05162
05163 case IL_Tbl_Idx :
05164
05165 NTR_IR_LIST_TBL(new_root);
05166 COPY_TBL_NTRY(ir_list_tbl, new_root, idx);
05167 OPND_LIST_CNT((*new_opnd)) = OPND_LIST_CNT((*old_opnd));
05168 COPY_OPND(o_opnd, IL_OPND(idx));
05169 make_base_subtree(&o_opnd, &n_opnd, rank_idx, &dummy_idx);
05170 COPY_OPND(IL_OPND(new_root), n_opnd);
05171 list2_idx = new_root;
05172 idx = IL_NEXT_LIST_IDX(idx);
05173
05174 while (idx != NULL_IDX) {
05175 NTR_IR_LIST_TBL(list_idx);
05176 COPY_TBL_NTRY(ir_list_tbl, list_idx, idx);
05177
05178 if (! IL_ARG_DESC_VARIANT(list_idx)) {
05179 IL_PREV_LIST_IDX(list_idx) = list2_idx;
05180 }
05181 IL_NEXT_LIST_IDX(list2_idx) = list_idx;
05182 list2_idx = list_idx;
05183
05184 COPY_OPND(o_opnd, IL_OPND(idx));
05185 make_base_subtree(&o_opnd, &n_opnd, rank_idx, &dummy_idx);
05186 COPY_OPND(IL_OPND(list_idx), n_opnd);
05187 idx = IL_NEXT_LIST_IDX(idx);
05188 }
05189 break;
05190 }
05191 }
05192
05193 OPND_IDX((*new_opnd)) = new_root;
05194 OPND_FLD((*new_opnd)) = fld;
05195
05196 SKIP:
05197
05198 TRACE (Func_Exit, "make_base_subtree", NULL);
05199
05200 return;
05201
05202 }
05203
05204
05205
05206
05207
05208
05209
05210
05211
05212
05213
05214
05215
05216
05217
05218
05219
05220
05221
05222 static void just_find_dope_and_rank(opnd_type *old_opnd,
05223 int *rank_idx,
05224 int *dope_idx)
05225
05226 {
05227 opnd_type opnd;
05228
05229 TRACE (Func_Entry, "just_find_dope_and_rank", NULL);
05230
05231 COPY_OPND(opnd, (*old_opnd));
05232
05233 while (OPND_FLD(opnd) == IR_Tbl_Idx) {
05234
05235 if (IR_OPR(OPND_IDX(opnd)) == Section_Subscript_Opr ||
05236 IR_OPR(OPND_IDX(opnd)) == Whole_Subscript_Opr) {
05237
05238 if (*rank_idx != NULL_IDX) {
05239 PRINTMSG(IR_LINE_NUM(OPND_IDX(opnd)), 545, Internal,
05240 IR_COL_NUM(OPND_IDX(opnd)));
05241 }
05242 *rank_idx = OPND_IDX(opnd);
05243 }
05244 else if (IR_OPR(OPND_IDX(opnd)) == Dv_Deref_Opr &&
05245 *dope_idx == NULL_IDX) {
05246 *dope_idx = OPND_IDX(opnd);
05247 }
05248
05249 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
05250 }
05251
05252 TRACE (Func_Exit, "just_find_dope_and_rank", NULL);
05253
05254 return;
05255
05256 }
05257
05258
05259
05260
05261
05262
05263
05264
05265
05266
05267
05268
05269
05270
05271
05272
05273
05274
05275 void process_deferred_functions(opnd_type *opnd)
05276
05277 {
05278 int col;
05279 int ir_idx;
05280 int line;
05281 int list_idx;
05282 opnd_type loc_opnd;
05283 int save_curr_stmt_sh_idx;
05284 int sh_idx;
05285
05286 TRACE (Func_Entry, "process_deferred_functions", NULL);
05287
05288 find_opnd_line_and_column(opnd, &line, &col);
05289
05290 switch (OPND_FLD((*opnd))) {
05291 case IR_Tbl_Idx:
05292
05293 ir_idx = OPND_IDX((*opnd));
05294
05295 if (IR_OPR(ir_idx) == Stmt_Expansion_Opr) {
05296 # ifdef _DEBUG
05297 if (IR_FLD_L(ir_idx) == NO_Tbl_Idx) {
05298 PRINTMSG(IR_LINE_NUM(ir_idx), 626, Internal, IR_COL_NUM(ir_idx),
05299 "no dags", "process_deferred_functions");
05300 }
05301 # endif
05302 if (STMT_EXPAND_BEFORE_START_SH(ir_idx)) {
05303
05304 OPND_FLD(loc_opnd) = SH_Tbl_Idx;
05305 OPND_IDX(loc_opnd) = STMT_EXPAND_BEFORE_START_SH(ir_idx);
05306 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
05307 curr_stmt_sh_idx = STMT_EXPAND_BEFORE_START_SH(ir_idx);
05308 process_deferred_functions(&loc_opnd);
05309 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
05310
05311 sh_idx = STMT_EXPAND_BEFORE_START_SH(ir_idx);
05312 while (SH_PREV_IDX(sh_idx)) {
05313 sh_idx = SH_PREV_IDX(sh_idx);
05314 }
05315 STMT_EXPAND_BEFORE_START_SH(ir_idx) = sh_idx;
05316
05317 sh_idx = STMT_EXPAND_BEFORE_END_SH(ir_idx);
05318 while (SH_NEXT_IDX(sh_idx)) {
05319 sh_idx = SH_NEXT_IDX(sh_idx);
05320 }
05321 STMT_EXPAND_BEFORE_END_SH(ir_idx) = sh_idx;
05322
05323 insert_sh_chain(STMT_EXPAND_BEFORE_START_SH(ir_idx),
05324 STMT_EXPAND_BEFORE_END_SH(ir_idx),
05325 Before);
05326 }
05327
05328 if (STMT_EXPAND_AFTER_START_SH(ir_idx)) {
05329
05330 OPND_FLD(loc_opnd) = SH_Tbl_Idx;
05331 OPND_IDX(loc_opnd) = STMT_EXPAND_AFTER_START_SH(ir_idx);
05332 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
05333 curr_stmt_sh_idx = STMT_EXPAND_AFTER_START_SH(ir_idx);
05334 process_deferred_functions(&loc_opnd);
05335 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
05336
05337 sh_idx = STMT_EXPAND_AFTER_START_SH(ir_idx);
05338 while (SH_PREV_IDX(sh_idx)) {
05339 sh_idx = SH_PREV_IDX(sh_idx);
05340 }
05341 STMT_EXPAND_AFTER_START_SH(ir_idx) = sh_idx;
05342
05343 sh_idx = STMT_EXPAND_AFTER_END_SH(ir_idx);
05344 while (SH_NEXT_IDX(sh_idx)) {
05345 sh_idx = SH_NEXT_IDX(sh_idx);
05346 }
05347 STMT_EXPAND_AFTER_END_SH(ir_idx) = sh_idx;
05348
05349 insert_sh_chain(STMT_EXPAND_AFTER_START_SH(ir_idx),
05350 STMT_EXPAND_AFTER_END_SH(ir_idx),
05351 After);
05352 }
05353
05354 COPY_OPND((*opnd), IR_OPND_L(ir_idx));
05355 IR_OPND_L(ir_idx) = null_opnd;
05356
05357
05358
05359 }
05360 else {
05361 if (IR_FLD_L(ir_idx) != SH_Tbl_Idx) {
05362 process_deferred_functions(&IR_OPND_L(ir_idx));
05363 }
05364
05365 if (IR_FLD_R(ir_idx) != SH_Tbl_Idx) {
05366 process_deferred_functions(&IR_OPND_R(ir_idx));
05367 }
05368 }
05369 break;
05370
05371 case SH_Tbl_Idx:
05372 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
05373 curr_stmt_sh_idx = OPND_IDX((*opnd));
05374
05375 while (curr_stmt_sh_idx != NULL_IDX) {
05376 OPND_FLD(loc_opnd) = IR_Tbl_Idx;
05377 OPND_IDX(loc_opnd) = SH_IR_IDX(curr_stmt_sh_idx);
05378 process_deferred_functions(&loc_opnd);
05379 SH_IR_IDX(curr_stmt_sh_idx) = OPND_IDX(loc_opnd);
05380 curr_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
05381 }
05382 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
05383 break;
05384
05385 case IL_Tbl_Idx:
05386 list_idx = OPND_IDX((*opnd));
05387 while (list_idx) {
05388 if (IL_FLD(list_idx) != SH_Tbl_Idx) {
05389 process_deferred_functions(&IL_OPND(list_idx));
05390 }
05391 list_idx = IL_NEXT_LIST_IDX(list_idx);
05392 }
05393 break;
05394
05395 }
05396
05397 TRACE (Func_Exit, "process_deferred_functions", NULL);
05398
05399 return;
05400
05401 }
05402
05403
05404
05405
05406
05407
05408
05409
05410
05411
05412
05413
05414
05415
05416
05417
05418
05419
05420
05421
05422
05423
05424
05425
05426
05427 void short_circuit_branch(void)
05428
05429 {
05430 int asg_idx;
05431 int br_true_idx;
05432 int col;
05433 int ir_idx;
05434 int label_idx;
05435 boolean left_is_worse;
05436 int line;
05437 int log_idx;
05438 int not_cnt = 0;
05439 int not_idx;
05440 opnd_type not_opnd;
05441 opnd_type opnd;
05442 int opnd_column;
05443 int opnd_line;
05444 int save_curr_stmt_sh_idx;
05445 int tmp_idx;
05446
05447
05448 TRACE (Func_Entry, "short_circuit_branch", NULL);
05449
05450 br_true_idx = SH_IR_IDX(curr_stmt_sh_idx);
05451
05452 line = IR_LINE_NUM(br_true_idx);
05453 col = IR_COL_NUM(br_true_idx);
05454
05455 COPY_OPND(opnd, IR_OPND_L(br_true_idx));
05456
05457 while (OPND_FLD(opnd) == IR_Tbl_Idx) {
05458
05459 switch(IR_OPR(OPND_IDX(opnd))) {
05460 case Not_Opr:
05461 not_cnt++;
05462
05463 if (not_cnt == 1) {
05464 COPY_OPND(not_opnd, opnd);
05465 }
05466 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
05467 break;
05468
05469 case Or_Opr:
05470 case And_Opr:
05471
05472 log_idx = OPND_IDX(opnd);
05473
05474 if (IR_SHORT_CIRCUIT_L(log_idx)) {
05475 left_is_worse = TRUE;
05476 }
05477 # if defined(_TARGET_OS_SOLARIS) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
05478 else {
05479 left_is_worse = FALSE;
05480 }
05481 # else
05482
05483 else if (IR_SHORT_CIRCUIT_R(log_idx)) {
05484 left_is_worse = FALSE;
05485 }
05486 else {
05487
05488 if (not_cnt%2 == 0) {
05489
05490 COPY_OPND(IR_OPND_L(br_true_idx), opnd);
05491 }
05492 else {
05493 COPY_OPND(IR_OPND_L(OPND_IDX(not_opnd)), opnd);
05494 COPY_OPND(IR_OPND_L(br_true_idx), not_opnd);
05495 }
05496 goto OUT;
05497 }
05498 # endif
05499
05500 if (not_cnt%2 == 0) {
05501
05502 COPY_OPND(IR_OPND_L(br_true_idx), opnd);
05503 }
05504 else {
05505
05506 COPY_OPND(IR_OPND_L(br_true_idx), opnd);
05507
05508 if (IR_OPR(log_idx) == Or_Opr) {
05509 IR_OPR(log_idx) = And_Opr;
05510 }
05511 else {
05512 IR_OPR(log_idx) = Or_Opr;
05513 }
05514 COPY_OPND(IR_OPND_L(OPND_IDX(not_opnd)),
05515 IR_OPND_L(log_idx));
05516 COPY_OPND(IR_OPND_L(log_idx), not_opnd);
05517
05518 NTR_IR_TBL(ir_idx);
05519 IR_OPR(ir_idx) = Not_Opr;
05520 IR_TYPE_IDX(ir_idx) = LOGICAL_DEFAULT_TYPE;
05521 IR_LINE_NUM(ir_idx) = IR_LINE_NUM(OPND_IDX(not_opnd));
05522 IR_COL_NUM(ir_idx) = IR_COL_NUM(OPND_IDX(not_opnd));
05523 COPY_OPND(IR_OPND_L(ir_idx), IR_OPND_R(log_idx));
05524 IR_FLD_R(log_idx) = IR_Tbl_Idx;
05525 IR_IDX_R(log_idx) = ir_idx;
05526 }
05527
05528 if (IR_OPR(log_idx) == Or_Opr) {
05529
05530
05531
05532 gen_sh(Before, If_Stmt, line, col, FALSE, FALSE, TRUE);
05533
05534 NTR_IR_TBL(ir_idx);
05535 IR_OPR(ir_idx) = Br_True_Opr;
05536 IR_TYPE_IDX(ir_idx) = LOGICAL_DEFAULT_TYPE;
05537 IR_LINE_NUM(ir_idx) = line;
05538 IR_COL_NUM(ir_idx) = col;
05539
05540
05541
05542
05543
05544
05545
05546
05547
05548
05549
05550
05551
05552 if (IR_FLD_R(br_true_idx) == IL_Tbl_Idx) {
05553 COPY_OPND(opnd, IL_OPND(IR_IDX_R(br_true_idx)));
05554 COPY_OPND(IR_OPND_R(ir_idx), opnd);
05555 }
05556 else {
05557 COPY_OPND(IR_OPND_R(ir_idx), IR_OPND_R(br_true_idx));
05558 }
05559
05560
05561 if (left_is_worse) {
05562 COPY_OPND(IR_OPND_L(ir_idx), IR_OPND_R(log_idx));
05563 COPY_OPND(IR_OPND_L(br_true_idx), IR_OPND_L(log_idx));
05564 }
05565 else {
05566 COPY_OPND(IR_OPND_L(ir_idx), IR_OPND_L(log_idx));
05567 COPY_OPND(IR_OPND_L(br_true_idx), IR_OPND_R(log_idx));
05568 }
05569
05570 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
05571 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
05572
05573 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
05574 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
05575
05576 short_circuit_branch();
05577
05578 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
05579
05580 short_circuit_branch();
05581 }
05582 else {
05583
05584
05585 label_idx = gen_internal_lbl(stmt_start_line);
05586
05587 gen_sh(After, Continue_Stmt, line, col, FALSE, TRUE, TRUE);
05588
05589 NTR_IR_TBL(ir_idx);
05590 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
05591 IR_OPR(ir_idx) = Label_Opr;
05592 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
05593 IR_LINE_NUM(ir_idx) = line;
05594 IR_COL_NUM(ir_idx) = col;
05595 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
05596 IR_IDX_L(ir_idx) = label_idx;
05597 AT_REFERENCED(label_idx) = Referenced;
05598 IR_COL_NUM_L(ir_idx) = col;
05599 IR_LINE_NUM_L(ir_idx) = line;
05600
05601 AT_DEFINED(label_idx) = TRUE;
05602 ATL_DEF_STMT_IDX(label_idx) = curr_stmt_sh_idx;
05603
05604 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
05605 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
05606
05607 NTR_IR_TBL(ir_idx);
05608 IR_OPR(ir_idx) = Br_True_Opr;
05609 IR_TYPE_IDX(ir_idx) = LOGICAL_DEFAULT_TYPE;
05610 IR_LINE_NUM(ir_idx) = line;
05611 IR_COL_NUM(ir_idx) = col;
05612 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
05613 IR_IDX_R(ir_idx) = label_idx;
05614 IR_LINE_NUM_R(ir_idx) = line;
05615 IR_COL_NUM_R(ir_idx) = col;
05616
05617 NTR_IR_TBL(not_idx);
05618 IR_OPR(not_idx) = Not_Opr;
05619 IR_TYPE_IDX(not_idx) = LOGICAL_DEFAULT_TYPE;
05620 IR_LINE_NUM(not_idx) = line;
05621 IR_COL_NUM(not_idx) = col;
05622 IR_FLD_L(ir_idx) = IR_Tbl_Idx;
05623 IR_IDX_L(ir_idx) = not_idx;
05624
05625 if (left_is_worse) {
05626 COPY_OPND(IR_OPND_L(not_idx), IR_OPND_R(log_idx));
05627 COPY_OPND(IR_OPND_L(br_true_idx), IR_OPND_L(log_idx));
05628 }
05629 else {
05630 COPY_OPND(IR_OPND_L(not_idx), IR_OPND_L(log_idx));
05631 COPY_OPND(IR_OPND_L(br_true_idx), IR_OPND_R(log_idx));
05632 }
05633
05634 gen_sh(Before, If_Stmt, line, col, FALSE, FALSE, TRUE);
05635
05636 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
05637 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
05638
05639 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
05640 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
05641
05642 short_circuit_branch();
05643
05644 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
05645
05646 short_circuit_branch();
05647 }
05648
05649 goto EXIT;
05650
05651 case Paren_Opr:
05652 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
05653 break;
05654
05655 default:
05656 if (not_cnt%2 == 0) {
05657
05658 COPY_OPND(IR_OPND_L(br_true_idx), opnd);
05659 }
05660 else {
05661 COPY_OPND(IR_OPND_L(OPND_IDX(not_opnd)), opnd);
05662 COPY_OPND(IR_OPND_L(br_true_idx), not_opnd);
05663 }
05664
05665 goto OUT;
05666 }
05667 }
05668
05669 OUT:
05670
05671 COPY_OPND(opnd, IR_OPND_L(br_true_idx));
05672
05673
05674
05675
05676
05677
05678
05679 if (tree_produces_dealloc(&opnd)) {
05680 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
05681 find_opnd_line_and_column(&opnd, &opnd_line, &opnd_column);
05682
05683 GEN_COMPILER_TMP_ASG(asg_idx,
05684 tmp_idx,
05685 TRUE,
05686 opnd_line,
05687 opnd_column,
05688 LOGICAL_DEFAULT_TYPE,
05689 Priv);
05690
05691 gen_sh(Before, Assignment_Stmt, opnd_line,
05692 opnd_column, FALSE, FALSE, TRUE);
05693
05694 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
05695
05696 SH_IR_IDX(curr_stmt_sh_idx) = asg_idx;
05697 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
05698
05699 process_deferred_functions(&opnd);
05700 COPY_OPND(IR_OPND_R(asg_idx), opnd);
05701
05702 IR_FLD_L(br_true_idx) = AT_Tbl_Idx;
05703 IR_IDX_L(br_true_idx) = tmp_idx;
05704 IR_LINE_NUM_L(br_true_idx) = opnd_line;
05705 IR_COL_NUM_L(br_true_idx) = opnd_column;
05706 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
05707 }
05708 else {
05709 process_deferred_functions(&opnd);
05710 COPY_OPND(IR_OPND_L(br_true_idx), opnd);
05711 }
05712
05713
05714 EXIT:
05715
05716 TRACE (Func_Exit, "short_circuit_branch", NULL);
05717
05718 return;
05719
05720 }
05721
05722
05723
05724
05725
05726
05727
05728
05729
05730
05731
05732
05733
05734
05735
05736
05737
05738
05739
05740
05741
05742
05743 boolean tree_produces_dealloc(opnd_type *root)
05744
05745 {
05746 int i;
05747 int list_idx;
05748 opnd_type opnd;
05749 boolean has_dealloc = FALSE;
05750
05751
05752 TRACE (Func_Entry, "tree_produces_dealloc", NULL);
05753
05754 if (OPND_FLD((*root)) == IR_Tbl_Idx) {
05755
05756 if (IR_OPR(OPND_IDX((*root))) == Stmt_Expansion_Opr) {
05757
05758 if (STMT_EXPAND_AFTER_START_SH(OPND_IDX((*root))) != NULL_IDX) {
05759 has_dealloc = TRUE;
05760 }
05761 }
05762 else if (IR_OPR(OPND_IDX((*root))) == Array_Construct_Opr ||
05763 IR_OPR(OPND_IDX((*root))) == Adjustl_Opr ||
05764 IR_OPR(OPND_IDX((*root))) == Adjustr_Opr) {
05765
05766 has_dealloc = TRUE;
05767 goto EXIT;
05768 }
05769 else {
05770
05771 if (IR_FLD_L(OPND_IDX((*root))) == IR_Tbl_Idx ||
05772 IR_FLD_L(OPND_IDX((*root))) == IL_Tbl_Idx) {
05773
05774 COPY_OPND(opnd, IR_OPND_L(OPND_IDX((*root))));
05775 has_dealloc = tree_produces_dealloc(&opnd);
05776
05777 if (has_dealloc) {
05778 goto EXIT;
05779 }
05780 }
05781
05782 if (IR_FLD_R(OPND_IDX((*root))) == IR_Tbl_Idx ||
05783 IR_FLD_R(OPND_IDX((*root))) == IL_Tbl_Idx) {
05784
05785 COPY_OPND(opnd, IR_OPND_R(OPND_IDX((*root))));
05786 has_dealloc = tree_produces_dealloc(&opnd);
05787
05788 if (has_dealloc) {
05789 goto EXIT;
05790 }
05791 }
05792 }
05793 }
05794 else if (OPND_FLD((*root)) == IL_Tbl_Idx) {
05795
05796 list_idx = OPND_IDX((*root));
05797
05798 for (i = 0; i < OPND_LIST_CNT((*root)); i++) {
05799
05800 if (IL_FLD(list_idx) == IR_Tbl_Idx ||
05801 IL_FLD(list_idx) == IL_Tbl_Idx) {
05802
05803 COPY_OPND(opnd, IL_OPND(list_idx));
05804 has_dealloc = tree_produces_dealloc(&opnd);
05805
05806 if (has_dealloc) {
05807 goto EXIT;
05808 }
05809 }
05810
05811 list_idx = IL_NEXT_LIST_IDX(list_idx);
05812 }
05813 }
05814
05815 EXIT:
05816
05817 TRACE (Func_Exit, "tree_produces_dealloc", NULL);
05818
05819 return(has_dealloc);
05820
05821 }
05822
05823
05824
05825
05826
05827
05828
05829
05830
05831
05832
05833
05834
05835
05836
05837
05838
05839 void create_loop_stmts(int lcv_attr,
05840 opnd_type *start_opnd,
05841 opnd_type *end_opnd,
05842 opnd_type *inc_opnd,
05843 int body_start_sh_idx,
05844 int body_end_sh_idx)
05845
05846 {
05847 int col;
05848 int ir_idx;
05849 int line;
05850 int save_curr_stmt_sh_idx;
05851
05852 # if !defined(_HIGH_LEVEL_DO_LOOP_FORM)
05853 int asg_idx;
05854 int br_around_label;
05855 int br_back_label;
05856 int div_idx;
05857 opnd_type end_tmp_opnd;
05858 expr_arg_type exp_desc;
05859 opnd_type inc_tmp_opnd;
05860 int log_idx;
05861 int minus_idx;
05862 int mult_idx;
05863 opnd_type opnd;
05864 int opnd_col;
05865 int opnd_line;
05866 int plus_idx;
05867 cif_usage_code_type save_xref_state;
05868 opnd_type start_tmp_opnd;
05869 int tmp_idx;
05870 opnd_type trip_count_tmp_opnd;
05871 opnd_type trip_counter_tmp_opnd;
05872 # else
05873 int list_idx;
05874 int list_idx2;
05875 # endif
05876
05877
05878 TRACE (Func_Entry, "create_loop_stmts", NULL);
05879
05880 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
05881
05882 line = stmt_start_line;
05883 col = stmt_start_col;
05884
05885 # if defined(_HIGH_LEVEL_DO_LOOP_FORM)
05886 curr_stmt_sh_idx = body_end_sh_idx;
05887
05888 ir_idx = gen_ir(NO_Tbl_Idx, NULL_IDX,
05889 Loop_End_Opr, TYPELESS_DEFAULT_TYPE, line, col,
05890 NO_Tbl_Idx, NULL_IDX);
05891
05892 gen_sh(After, Continue_Stmt, line, col, FALSE, FALSE, TRUE);
05893 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
05894 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
05895 SH_LOOP_END(curr_stmt_sh_idx) = TRUE;
05896
05897 curr_stmt_sh_idx = body_start_sh_idx;
05898
05899 NTR_IR_LIST_TBL(list_idx);
05900 gen_opnd(&IL_OPND(list_idx), lcv_attr, AT_Tbl_Idx, line, col);
05901
05902 NTR_IR_LIST_TBL(list_idx2);
05903 IL_NEXT_LIST_IDX(list_idx) = list_idx2;
05904 IL_PREV_LIST_IDX(list_idx2) = list_idx;
05905
05906 COPY_OPND(IL_OPND(list_idx2), (*start_opnd));
05907
05908 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx2));
05909 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx2)) = list_idx2;
05910 list_idx2 = IL_NEXT_LIST_IDX(list_idx2);
05911
05912 COPY_OPND(IL_OPND(list_idx2), (*end_opnd));
05913
05914 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx2));
05915 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx2)) = list_idx2;
05916 list_idx2 = IL_NEXT_LIST_IDX(list_idx2);
05917
05918 COPY_OPND(IL_OPND(list_idx2), (*inc_opnd));
05919
05920
05921 ir_idx = gen_ir(SH_Tbl_Idx, SH_NEXT_IDX(body_end_sh_idx),
05922 Loop_Info_Opr, TYPELESS_DEFAULT_TYPE, line, col,
05923 IL_Tbl_Idx, list_idx);
05924
05925 gen_sh(Before, Do_Iterative_Stmt, line, col, FALSE, FALSE, TRUE);
05926 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
05927 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
05928
05929 SH_PARENT_BLK_IDX(SH_NEXT_IDX(body_end_sh_idx)) =
05930 SH_PREV_IDX(curr_stmt_sh_idx);
05931
05932 # else
05933
05934
05935
05936
05937 curr_stmt_sh_idx = body_end_sh_idx;
05938
05939 br_around_label = gen_internal_lbl(line);
05940
05941 ir_idx = gen_ir(AT_Tbl_Idx, br_around_label,
05942 Label_Opr, TYPELESS_DEFAULT_TYPE, line, col,
05943 NO_Tbl_Idx, NULL_IDX);
05944
05945 gen_sh(After, Continue_Stmt, line, col, FALSE, TRUE, TRUE);
05946 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
05947
05948 AT_DEFINED(br_around_label) = TRUE;
05949 ATL_DEF_STMT_IDX(br_around_label) = curr_stmt_sh_idx;
05950
05951 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
05952
05953
05954
05955
05956
05957
05958
05959
05960 curr_stmt_sh_idx = body_start_sh_idx;
05961
05962
05963
05964
05965
05966
05967 if (OPND_FLD((*start_opnd)) == CN_Tbl_Idx &&
05968 TYP_LINEAR(CN_TYPE_IDX(OPND_IDX((*start_opnd)))) ==
05969 Short_Typeless_Const) {
05970
05971 find_opnd_line_and_column(start_opnd, &opnd_line, &opnd_col);
05972 OPND_IDX((*start_opnd)) = cast_typeless_constant(OPND_IDX((*start_opnd)),
05973 ATD_TYPE_IDX(lcv_attr),
05974 opnd_line,
05975 opnd_col);
05976 }
05977
05978 if (OPND_FLD((*start_opnd)) == CN_Tbl_Idx ||
05979 (OPND_FLD((*start_opnd)) == AT_Tbl_Idx &&
05980 ATD_CLASS(OPND_IDX((*start_opnd))) == Compiler_Tmp)) {
05981
05982 COPY_OPND(start_tmp_opnd, (*start_opnd));
05983 }
05984 else {
05985
05986 GEN_COMPILER_TMP_ASG(asg_idx,
05987 tmp_idx,
05988 TRUE,
05989 line,
05990 col,
05991 ATD_TYPE_IDX(lcv_attr),
05992 Priv);
05993
05994 COPY_OPND(IR_OPND_R(asg_idx), (*start_opnd));
05995
05996 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
05997
05998 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
05999 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
06000
06001 gen_opnd(&start_tmp_opnd, tmp_idx, AT_Tbl_Idx, line, col);
06002 }
06003
06004
06005
06006
06007
06008 if (OPND_FLD((*end_opnd)) == CN_Tbl_Idx &&
06009 TYP_LINEAR(CN_TYPE_IDX(OPND_IDX((*end_opnd)))) ==
06010 Short_Typeless_Const) {
06011
06012 find_opnd_line_and_column(end_opnd, &opnd_line, &opnd_col);
06013 OPND_IDX((*end_opnd)) = cast_typeless_constant(OPND_IDX((*end_opnd)),
06014 ATD_TYPE_IDX(lcv_attr),
06015 opnd_line,
06016 opnd_col);
06017 }
06018
06019 if (OPND_FLD((*end_opnd)) == CN_Tbl_Idx ||
06020 (OPND_FLD((*end_opnd)) == AT_Tbl_Idx &&
06021 ATD_CLASS(OPND_IDX((*end_opnd))) == Compiler_Tmp)) {
06022
06023 COPY_OPND(end_tmp_opnd, (*end_opnd));
06024 }
06025 else {
06026
06027 GEN_COMPILER_TMP_ASG(asg_idx,
06028 tmp_idx,
06029 TRUE,
06030 line,
06031 col,
06032 ATD_TYPE_IDX(lcv_attr),
06033 Priv);
06034
06035 COPY_OPND(IR_OPND_R(asg_idx), (*end_opnd));
06036
06037 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06038
06039 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
06040 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
06041
06042 gen_opnd(&end_tmp_opnd, tmp_idx, AT_Tbl_Idx, line, col);
06043 }
06044
06045
06046
06047
06048
06049 if (OPND_FLD((*inc_opnd)) == CN_Tbl_Idx &&
06050 TYP_LINEAR(CN_TYPE_IDX(OPND_IDX((*inc_opnd)))) ==
06051 Short_Typeless_Const) {
06052
06053 find_opnd_line_and_column(inc_opnd, &opnd_line, &opnd_col);
06054 OPND_IDX((*inc_opnd)) = cast_typeless_constant(OPND_IDX((*inc_opnd)),
06055 ATD_TYPE_IDX(lcv_attr),
06056 opnd_line,
06057 opnd_col);
06058 }
06059
06060 if (OPND_FLD((*inc_opnd)) == CN_Tbl_Idx ||
06061 (OPND_FLD((*inc_opnd)) == AT_Tbl_Idx &&
06062 ATD_CLASS(OPND_IDX((*inc_opnd))) == Compiler_Tmp)) {
06063
06064 COPY_OPND(inc_tmp_opnd, (*inc_opnd));
06065 }
06066 else {
06067
06068 GEN_COMPILER_TMP_ASG(asg_idx,
06069 tmp_idx,
06070 TRUE,
06071 line,
06072 col,
06073 ATD_TYPE_IDX(lcv_attr),
06074 Priv);
06075
06076 COPY_OPND(IR_OPND_R(asg_idx), (*inc_opnd));
06077
06078 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06079
06080 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
06081 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
06082
06083 gen_opnd(&inc_tmp_opnd, tmp_idx, AT_Tbl_Idx, line, col);
06084 }
06085
06086
06087
06088
06089
06090 asg_idx = gen_ir(AT_Tbl_Idx, lcv_attr,
06091 Asg_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06092 OPND_FLD(start_tmp_opnd), OPND_IDX(start_tmp_opnd));
06093
06094 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06095
06096 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
06097 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
06098
06099
06100
06101
06102
06103
06104 minus_idx = gen_ir(OPND_FLD(end_tmp_opnd), OPND_IDX(end_tmp_opnd),
06105 Minus_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06106 OPND_FLD(start_tmp_opnd), OPND_IDX(start_tmp_opnd));
06107
06108 plus_idx = gen_ir(IR_Tbl_Idx, minus_idx,
06109 Plus_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06110 OPND_FLD(inc_tmp_opnd), OPND_IDX(inc_tmp_opnd));
06111
06112 div_idx = gen_ir(IR_Tbl_Idx, plus_idx,
06113 Div_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06114 OPND_FLD(inc_tmp_opnd), OPND_IDX(inc_tmp_opnd));
06115
06116 OPND_FLD(opnd) = IR_Tbl_Idx;
06117 OPND_IDX(opnd) = div_idx;
06118
06119 save_xref_state = xref_state;
06120 xref_state = CIF_No_Usage_Rec;
06121 expr_semantics(&opnd, &exp_desc);
06122 xref_state = save_xref_state;
06123
06124 if (OPND_FLD(opnd) == CN_Tbl_Idx ||
06125 (OPND_FLD(opnd) == AT_Tbl_Idx &&
06126 ATD_CLASS(OPND_IDX(opnd)) == Compiler_Tmp)) {
06127
06128 COPY_OPND(trip_count_tmp_opnd, opnd);
06129 }
06130 else {
06131
06132 GEN_COMPILER_TMP_ASG(asg_idx,
06133 tmp_idx,
06134 TRUE,
06135 line,
06136 col,
06137 exp_desc.type_idx,
06138 Priv);
06139
06140 COPY_OPND(IR_OPND_R(asg_idx), opnd);
06141
06142 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06143
06144 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
06145 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
06146
06147 gen_opnd(&trip_count_tmp_opnd, tmp_idx, AT_Tbl_Idx, line, col);
06148 }
06149
06150
06151
06152
06153
06154
06155 log_idx = gen_ir(OPND_FLD(trip_count_tmp_opnd),OPND_IDX(trip_count_tmp_opnd),
06156 Le_Opr, LOGICAL_DEFAULT_TYPE, line, col,
06157 CN_Tbl_Idx, CN_INTEGER_ZERO_IDX);
06158
06159 ir_idx = gen_ir(IR_Tbl_Idx, log_idx,
06160 Br_True_Opr, LOGICAL_DEFAULT_TYPE, line, col,
06161 AT_Tbl_Idx, br_around_label);
06162
06163 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06164
06165 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
06166 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
06167
06168
06169
06170
06171
06172 GEN_COMPILER_TMP_ASG(asg_idx,
06173 tmp_idx,
06174 TRUE,
06175 line,
06176 col,
06177 CG_INTEGER_DEFAULT_TYPE,
06178 Priv);
06179
06180 gen_opnd(&IR_OPND_R(asg_idx), CN_INTEGER_ZERO_IDX, CN_Tbl_Idx, line, col);
06181
06182 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06183
06184 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
06185 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
06186
06187 gen_opnd(&trip_counter_tmp_opnd, tmp_idx, AT_Tbl_Idx, line, col);
06188
06189
06190
06191
06192
06193 br_back_label = gen_internal_lbl(line);
06194
06195 ir_idx = gen_ir(AT_Tbl_Idx, br_back_label,
06196 Label_Opr, TYPELESS_DEFAULT_TYPE, line, col,
06197 NO_Tbl_Idx, NULL_IDX);
06198
06199 gen_sh(Before, Continue_Stmt, line, col, FALSE, TRUE, TRUE);
06200 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
06201
06202 AT_DEFINED(br_back_label) = TRUE;
06203 ATL_DEF_STMT_IDX(br_back_label) = SH_PREV_IDX(curr_stmt_sh_idx);
06204
06205 if (in_constructor) {
06206 ATL_CONSTRUCTOR_LOOP(br_back_label) = TRUE;
06207 }
06208
06209 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
06210
06211
06212
06213
06214
06215 mult_idx = gen_ir(OPND_FLD(trip_counter_tmp_opnd),
06216 OPND_IDX(trip_counter_tmp_opnd),
06217 Mult_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06218 OPND_FLD(inc_tmp_opnd), OPND_IDX(inc_tmp_opnd));
06219
06220 plus_idx = gen_ir(OPND_FLD(start_tmp_opnd), OPND_IDX(start_tmp_opnd),
06221 Plus_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06222 IR_Tbl_Idx, mult_idx);
06223
06224 asg_idx = gen_ir(AT_Tbl_Idx, lcv_attr,
06225 Asg_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06226 IR_Tbl_Idx, plus_idx);
06227
06228 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06229
06230 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
06231 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
06232
06233
06234
06235
06236
06237
06238
06239
06240
06241 curr_stmt_sh_idx = body_end_sh_idx;
06242
06243
06244
06245
06246
06247 plus_idx = gen_ir(OPND_FLD(trip_counter_tmp_opnd),
06248 OPND_IDX(trip_counter_tmp_opnd),
06249 Plus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
06250 CN_Tbl_Idx, CN_INTEGER_ONE_IDX);
06251
06252 asg_idx = gen_ir(OPND_FLD(trip_counter_tmp_opnd),
06253 OPND_IDX(trip_counter_tmp_opnd),
06254 Asg_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
06255 IR_Tbl_Idx, plus_idx);
06256
06257 gen_sh(After, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06258 SH_IR_IDX(curr_stmt_sh_idx) = asg_idx;
06259 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
06260
06261
06262
06263
06264
06265 log_idx = gen_ir(OPND_FLD(trip_counter_tmp_opnd),
06266 OPND_IDX(trip_counter_tmp_opnd),
06267 Lt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
06268 OPND_FLD(trip_count_tmp_opnd),OPND_IDX(trip_count_tmp_opnd));
06269
06270 ir_idx = gen_ir(IR_Tbl_Idx, log_idx,
06271 Br_True_Opr, LOGICAL_DEFAULT_TYPE, line, col,
06272 AT_Tbl_Idx, br_back_label);
06273
06274 gen_sh(After, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06275
06276 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
06277 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
06278
06279
06280
06281
06282
06283
06284 mult_idx =gen_ir(OPND_FLD(trip_count_tmp_opnd),OPND_IDX(trip_count_tmp_opnd),
06285 Mult_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06286 OPND_FLD(inc_tmp_opnd), OPND_IDX(inc_tmp_opnd));
06287
06288 plus_idx = gen_ir(OPND_FLD(start_tmp_opnd), OPND_IDX(start_tmp_opnd),
06289 Plus_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06290 IR_Tbl_Idx, mult_idx);
06291
06292 asg_idx = gen_ir(AT_Tbl_Idx, lcv_attr,
06293 Asg_Opr, ATD_TYPE_IDX(lcv_attr), line, col,
06294 IR_Tbl_Idx, plus_idx);
06295
06296 gen_sh(After, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
06297
06298 SH_IR_IDX(curr_stmt_sh_idx) = asg_idx;
06299 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
06300
06301 # endif
06302
06303
06304 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
06305
06306 TRACE (Func_Exit, "create_loop_stmts", NULL);
06307
06308 return;
06309
06310 }
06311
06312
06313
06314
06315
06316
06317
06318
06319
06320
06321
06322
06323
06324
06325
06326
06327
06328
06329 int create_bd_ntry_for_const(expr_arg_type *exp_desc,
06330 int line,
06331 int col)
06332
06333 {
06334 int bd_idx;
06335 size_offset_type extent;
06336 int i;
06337 size_offset_type num_elements;
06338 size_offset_type stride;
06339
06340
06341 TRACE (Func_Entry, "create_bd_ntry_for_const", NULL);
06342
06343 bd_idx = reserve_array_ntry(exp_desc->rank);
06344 BD_RANK(bd_idx) = exp_desc->rank;
06345 BD_LINE_NUM(bd_idx) = line;
06346 BD_COLUMN_NUM(bd_idx) = col;
06347 BD_ARRAY_SIZE(bd_idx) = Constant_Size;
06348 BD_ARRAY_CLASS(bd_idx) = Explicit_Shape;
06349 BD_RESOLVED(bd_idx) = TRUE;
06350
06351 num_elements.idx = CN_INTEGER_ONE_IDX;
06352 num_elements.fld = CN_Tbl_Idx;
06353
06354 for (i = 1; i <= exp_desc->rank; i++) {
06355 BD_LB_FLD(bd_idx,i) = CN_Tbl_Idx;
06356 BD_LB_IDX(bd_idx,i) = CN_INTEGER_ONE_IDX;
06357
06358 if (OPND_FLD(exp_desc->shape[i-1]) == CN_Tbl_Idx) {
06359 BD_UB_FLD(bd_idx,i) = OPND_FLD(exp_desc->shape[i-1]);
06360 BD_UB_IDX(bd_idx,i) = OPND_IDX(exp_desc->shape[i-1]);
06361 }
06362 else {
06363 PRINTMSG(line, 966, Internal, col);
06364 }
06365
06366 BD_XT_FLD(bd_idx,i) = BD_UB_FLD(bd_idx,i);
06367 BD_XT_IDX(bd_idx,i) = BD_UB_IDX(bd_idx,i);
06368
06369 extent.fld = BD_XT_FLD(bd_idx,i);
06370 extent.idx = BD_XT_IDX(bd_idx,i);
06371
06372 size_offset_binary_calc(&extent,
06373 &num_elements,
06374 Mult_Opr,
06375 &num_elements);
06376 }
06377
06378 if (num_elements.fld == NO_Tbl_Idx) {
06379 BD_LEN_FLD(bd_idx) = CN_Tbl_Idx;
06380 BD_LEN_IDX(bd_idx) = ntr_const_tbl(num_elements.type_idx,
06381 FALSE,
06382 num_elements.constant);
06383 }
06384 else {
06385 BD_LEN_FLD(bd_idx) = num_elements.fld;
06386 BD_LEN_IDX(bd_idx) = num_elements.idx;
06387 }
06388
06389
06390
06391 set_stride_for_first_dim(exp_desc->type_idx, &stride);
06392
06393 BD_SM_FLD(bd_idx, 1) = stride.fld;
06394 BD_SM_IDX(bd_idx, 1) = stride.idx;
06395
06396 for (i = 2; i <= BD_RANK(bd_idx); i++) {
06397 extent.fld = BD_XT_FLD(bd_idx,i-1);
06398 extent.idx = BD_XT_IDX(bd_idx,i-1);
06399
06400 size_offset_binary_calc(&extent, &stride, Mult_Opr, &stride);
06401
06402 if (stride.fld == NO_Tbl_Idx) {
06403 stride.fld = CN_Tbl_Idx;
06404 stride.idx = ntr_const_tbl(stride.type_idx,
06405 FALSE,
06406 stride.constant);
06407 }
06408
06409 BD_SM_FLD(bd_idx, i) = stride.fld;
06410 BD_SM_IDX(bd_idx, i) = stride.idx;
06411 }
06412
06413 bd_idx = ntr_array_in_bd_tbl(bd_idx);
06414
06415 TRACE (Func_Exit, "create_bd_ntry_for_const", NULL);
06416
06417 return(bd_idx);
06418
06419 }
06420
06421
06422
06423
06424
06425
06426
06427
06428
06429
06430
06431
06432
06433
06434
06435
06436
06437 void fold_clen_opr(opnd_type *opnd,
06438 expr_arg_type *exp_desc)
06439
06440 {
06441 int attr_idx;
06442 int clen_idx;
06443 int col;
06444 int ir_idx;
06445 int line;
06446 int list_idx;
06447 int shift_idx;
06448 int type_idx;
06449
06450
06451 TRACE (Func_Entry, "fold_clen_opr", NULL);
06452
06453 find_opnd_line_and_column(opnd, &line, &col);
06454
06455 if (OPND_FLD((*opnd)) != IR_Tbl_Idx ||
06456 IR_OPR(OPND_IDX((*opnd))) != Clen_Opr) {
06457
06458 goto EXIT;
06459 }
06460
06461 clen_idx = OPND_IDX((*opnd));
06462
06463 exp_desc->type_idx = IR_TYPE_IDX(clen_idx);
06464 exp_desc->type = TYP_TYPE(exp_desc->type_idx);
06465 exp_desc->linear_type = TYP_LINEAR(exp_desc->type_idx);
06466
06467 switch (IR_FLD_L(clen_idx)) {
06468 case AT_Tbl_Idx :
06469 attr_idx = IR_IDX_L(clen_idx);
06470
06471 if (AT_OBJ_CLASS(attr_idx) == Data_Obj &&
06472 (ATD_IM_A_DOPE(attr_idx) ||
06473 ATD_POINTER(attr_idx) ||
06474 ATD_ALLOCATABLE(attr_idx))) {
06475
06476 if (char_len_in_bytes) {
06477
06478
06479
06480 NTR_IR_TBL(ir_idx);
06481 IR_OPR(ir_idx) = Dv_Access_El_Len;
06482 IR_TYPE_IDX(ir_idx) = SA_INTEGER_DEFAULT_TYPE;
06483 IR_LINE_NUM(ir_idx) = line;
06484 IR_COL_NUM(ir_idx) = col;
06485 COPY_OPND(IR_OPND_L(ir_idx), IR_OPND_L(clen_idx));
06486
06487 OPND_FLD((*opnd)) = IR_Tbl_Idx;
06488 OPND_IDX((*opnd)) = ir_idx;
06489 }
06490 else {
06491
06492
06493
06494 NTR_IR_TBL(ir_idx);
06495 IR_OPR(ir_idx) = Dv_Access_El_Len;
06496 IR_TYPE_IDX(ir_idx) = SA_INTEGER_DEFAULT_TYPE;
06497 IR_LINE_NUM(ir_idx) = line;
06498 IR_COL_NUM(ir_idx) = col;
06499 COPY_OPND(IR_OPND_L(ir_idx), IR_OPND_L(clen_idx));
06500 NTR_IR_TBL(shift_idx);
06501 IR_OPR(shift_idx) = Shiftr_Opr;
06502 IR_TYPE_IDX(shift_idx) = SA_INTEGER_DEFAULT_TYPE;
06503 IR_LINE_NUM(shift_idx) = line;
06504 IR_COL_NUM(shift_idx) = col;
06505
06506 NTR_IR_LIST_TBL(list_idx);
06507
06508 IR_FLD_L(shift_idx) = IL_Tbl_Idx;
06509 IR_IDX_L(shift_idx) = list_idx;
06510 IR_LIST_CNT_L(shift_idx) = 2;
06511 IL_FLD(list_idx) = IR_Tbl_Idx;
06512 IL_IDX(list_idx) = ir_idx;
06513
06514 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
06515 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
06516 list_idx = IL_NEXT_LIST_IDX(list_idx);
06517
06518 IL_FLD(list_idx) = CN_Tbl_Idx;
06519 IL_LINE_NUM(list_idx) = line;
06520 IL_COL_NUM(list_idx) = col;
06521 IL_IDX(list_idx) = CN_INTEGER_THREE_IDX;
06522
06523 OPND_FLD((*opnd)) = IR_Tbl_Idx;
06524 OPND_IDX((*opnd)) = shift_idx;
06525 }
06526
06527 exp_desc->type_idx = CG_INTEGER_DEFAULT_TYPE;
06528 exp_desc->type = Integer;
06529 exp_desc->linear_type = CG_INTEGER_DEFAULT_TYPE;
06530 }
06531 break;
06532
06533 case CN_Tbl_Idx :
06534 type_idx = CN_TYPE_IDX(IR_IDX_L(clen_idx));
06535 OPND_FLD((*opnd)) = TYP_FLD(type_idx);
06536 OPND_IDX((*opnd)) = TYP_IDX(type_idx);
06537 OPND_LINE_NUM((*opnd)) = line;
06538 OPND_COL_NUM((*opnd)) = col;
06539 exp_desc->constant = TRUE;
06540 exp_desc->foldable = TRUE;
06541
06542 if (TYP_FLD(type_idx) == CN_Tbl_Idx) {
06543 exp_desc->type_idx = CN_TYPE_IDX(TYP_IDX(type_idx));
06544 }
06545 else {
06546 exp_desc->type_idx = ATD_TYPE_IDX(TYP_IDX(type_idx));
06547 }
06548
06549 exp_desc->type = TYP_TYPE(exp_desc->type_idx);
06550 exp_desc->linear_type = TYP_LINEAR(exp_desc->type_idx);
06551 break;
06552
06553 case IR_Tbl_Idx :
06554
06555 ir_idx = IR_IDX_L(clen_idx);
06556
06557 if ((IR_OPR(ir_idx) == Substring_Opr ||
06558 IR_OPR(ir_idx) == Whole_Substring_Opr) &&
06559 IL_FLD(IL_NEXT_LIST_IDX(IL_NEXT_LIST_IDX(IR_IDX_R(ir_idx))))
06560 != NO_Tbl_Idx) {
06561
06562 COPY_OPND((*opnd), IL_OPND(IL_NEXT_LIST_IDX(IL_NEXT_LIST_IDX(
06563 IR_IDX_R(ir_idx)))));
06564
06565 if (OPND_FLD((*opnd)) == CN_Tbl_Idx) {
06566 exp_desc->type_idx = CN_TYPE_IDX(OPND_IDX((*opnd)));
06567 exp_desc->constant = TRUE;
06568 exp_desc->foldable = TRUE;
06569 }
06570 else if (OPND_FLD((*opnd)) == IR_Tbl_Idx) {
06571 exp_desc->type_idx = IR_TYPE_IDX(OPND_IDX((*opnd)));
06572 }
06573 else if (OPND_FLD((*opnd)) == AT_Tbl_Idx) {
06574 exp_desc->type_idx = ATD_TYPE_IDX(OPND_IDX((*opnd)));
06575 }
06576
06577 exp_desc->type = TYP_TYPE(exp_desc->type_idx);
06578 exp_desc->linear_type = TYP_LINEAR(exp_desc->type_idx);
06579 }
06580 break;
06581 }
06582
06583 EXIT:
06584
06585 TRACE (Func_Exit, "fold_clen_opr", NULL);
06586
06587 return;
06588
06589 }
06590
06591
06592
06593
06594
06595
06596
06597
06598
06599
06600
06601
06602
06603
06604
06605
06606
06607 void set_shape_for_deferred_funcs(expr_arg_type *exp_desc,
06608 int call_idx)
06609
06610 {
06611 int attr_idx;
06612 int bd_idx;
06613 int ch_idx = NULL_IDX;
06614 int col;
06615 int dummy_idx;
06616 boolean has_sf = FALSE;
06617 int i;
06618 int ir_idx;
06619 int line;
06620 int list_idx;
06621 expr_arg_type loc_exp_desc;
06622 int minus_idx;
06623 opnd_type opnd;
06624 int plus_idx;
06625 int pgm_idx;
06626 cif_usage_code_type save_xref_state;
06627 int sn_idx;
06628
06629
06630 TRACE (Func_Entry, "set_shape_for_deferred_funcs", NULL);
06631
06632 pgm_idx = IR_IDX_L(call_idx);
06633 attr_idx = ATP_RSLT_IDX(IR_IDX_L(call_idx));
06634 bd_idx = ATD_ARRAY_IDX(attr_idx);
06635
06636 if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
06637 ch_idx = ATD_TYPE_IDX(attr_idx);
06638 }
06639
06640 if ((bd_idx && BD_ARRAY_SIZE(bd_idx) == Var_Len_Array) ||
06641 (ch_idx && TYP_FLD(ch_idx) == AT_Tbl_Idx)) {
06642
06643 has_sf = TRUE;
06644
06645
06646
06647 list_idx = IR_IDX_R(call_idx);
06648 sn_idx = ATP_FIRST_IDX(pgm_idx);
06649
06650 if (ATP_EXTRA_DARG(pgm_idx)) {
06651 sn_idx++;
06652 }
06653
06654 for (i = 0; i < IR_LIST_CNT_R(call_idx); i++) {
06655 dummy_idx = SN_ATTR_IDX(sn_idx);
06656
06657 ATD_SF_DARG(dummy_idx) = TRUE;
06658
06659 ATD_SF_LINK(dummy_idx) = IL_ARG_DESC_IDX(list_idx);
06660 COPY_OPND(opnd, IL_OPND(list_idx));
06661
06662 if (arg_info_list[ATD_SF_LINK(dummy_idx)].ed.reference &&
06663 OPND_FLD(opnd) == IR_Tbl_Idx) {
06664
06665 if (IR_OPR(OPND_IDX(opnd)) == Whole_Substring_Opr) {
06666 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
06667 }
06668
06669 if (OPND_FLD(opnd) == IR_Tbl_Idx &&
06670 IR_OPR(OPND_IDX(opnd)) == Whole_Subscript_Opr) {
06671
06672 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
06673 }
06674
06675
06676
06677
06678 }
06679
06680 ATD_FLD(dummy_idx) = OPND_FLD(opnd);
06681 ATD_SF_ARG_IDX(dummy_idx) = OPND_IDX(opnd);
06682
06683 sn_idx++;
06684 list_idx = IL_NEXT_LIST_IDX(list_idx);
06685 }
06686 }
06687
06688 line = IR_LINE_NUM(call_idx);
06689 col = IR_COL_NUM(call_idx);
06690
06691 if (ch_idx) {
06692
06693
06694 if (TYP_CHAR_CLASS(ch_idx) == Const_Len_Char) {
06695 exp_desc->char_len.fld = TYP_FLD(ch_idx);
06696 exp_desc->char_len.idx = TYP_IDX(ch_idx);
06697 }
06698 else if (TYP_FLD(ch_idx) == AT_Tbl_Idx) {
06699
06700 if (TYP_CHAR_CLASS(ch_idx) == Assumed_Size_Char) {
06701
06702 COPY_OPND(opnd, IR_OPND_R(ATD_TMP_IDX(TYP_IDX(ch_idx))));
06703 }
06704 else {
06705 COPY_OPND(opnd, IR_OPND_R(ATD_TMP_IDX(TYP_ORIG_LEN_IDX(ch_idx))));
06706 }
06707
06708 copy_subtree(&opnd, &opnd);
06709
06710 loc_exp_desc.rank = 0;
06711 save_xref_state = xref_state;
06712 xref_state = CIF_No_Usage_Rec;
06713 expr_semantics(&opnd, &loc_exp_desc);
06714 xref_state = save_xref_state;
06715
06716 COPY_OPND((exp_desc->char_len), opnd);
06717 }
06718 }
06719
06720 if (bd_idx) {
06721
06722 switch (BD_ARRAY_CLASS(bd_idx)) {
06723
06724 case Explicit_Shape :
06725
06726 if (BD_ARRAY_SIZE(bd_idx) == Constant_Size) {
06727 get_shape_from_attr(exp_desc,
06728 attr_idx,
06729 exp_desc->rank,
06730 IR_LINE_NUM(call_idx),
06731 IR_COL_NUM(call_idx));
06732 }
06733 else if (BD_ARRAY_SIZE(bd_idx) == Var_Len_Array) {
06734
06735
06736
06737 for (i = 0; i < BD_RANK(bd_idx); i++) {
06738
06739 NTR_IR_TBL(plus_idx);
06740 IR_OPR(plus_idx) = Plus_Opr;
06741 IR_TYPE_IDX(plus_idx) = CG_INTEGER_DEFAULT_TYPE;
06742 IR_LINE_NUM(plus_idx) = line;
06743 IR_COL_NUM(plus_idx) = col;
06744
06745 IR_FLD_R(plus_idx) = CN_Tbl_Idx;
06746 IR_IDX_R(plus_idx) = CN_INTEGER_ONE_IDX;
06747 IR_LINE_NUM_R(plus_idx) = line;
06748 IR_COL_NUM_R(plus_idx) = col;
06749
06750 NTR_IR_TBL(minus_idx);
06751 IR_OPR(minus_idx) = Minus_Opr;
06752 IR_TYPE_IDX(minus_idx) = CG_INTEGER_DEFAULT_TYPE;
06753 IR_LINE_NUM(minus_idx) = line;
06754 IR_COL_NUM(minus_idx) = col;
06755
06756 IR_FLD_L(plus_idx) = IR_Tbl_Idx;
06757 IR_IDX_L(plus_idx) = minus_idx;
06758
06759 if (BD_LB_FLD(bd_idx,i+1) == AT_Tbl_Idx) {
06760 COPY_OPND(IR_OPND_R(minus_idx),
06761 IR_OPND_R(ATD_TMP_IDX(BD_LB_IDX(bd_idx,i+1))));
06762 }
06763 else {
06764 IR_FLD_R(minus_idx) = BD_LB_FLD(bd_idx, i+1);
06765 IR_IDX_R(minus_idx) = BD_LB_IDX(bd_idx, i+1);
06766 IR_LINE_NUM_R(minus_idx) = line;
06767 IR_COL_NUM_R(minus_idx) = col;
06768 }
06769
06770 COPY_OPND(opnd, IR_OPND_R(minus_idx));
06771 copy_subtree(&opnd, &opnd);
06772 COPY_OPND(IR_OPND_R(minus_idx), opnd);
06773
06774 if (BD_UB_FLD(bd_idx,i+1) == AT_Tbl_Idx) {
06775 COPY_OPND(IR_OPND_L(minus_idx),
06776 IR_OPND_R(ATD_TMP_IDX(BD_UB_IDX(bd_idx,i+1))));
06777 }
06778 else {
06779 IR_FLD_L(minus_idx) = BD_UB_FLD(bd_idx, i+1);
06780 IR_IDX_L(minus_idx) = BD_UB_IDX(bd_idx, i+1);
06781 IR_LINE_NUM_L(minus_idx) = line;
06782 IR_COL_NUM_L(minus_idx) = col;
06783 }
06784
06785 COPY_OPND(opnd, IR_OPND_L(minus_idx));
06786 copy_subtree(&opnd, &opnd);
06787 COPY_OPND(IR_OPND_L(minus_idx), opnd);
06788
06789 OPND_FLD(opnd) = IR_Tbl_Idx;
06790 OPND_IDX(opnd) = plus_idx;
06791
06792 loc_exp_desc.rank = 0;
06793 save_xref_state = xref_state;
06794 xref_state = CIF_No_Usage_Rec;
06795 expr_semantics(&opnd, &loc_exp_desc);
06796 xref_state = save_xref_state;
06797
06798 COPY_OPND((exp_desc->shape[i]), opnd);
06799 SHAPE_FOLDABLE(exp_desc->shape[i]) = loc_exp_desc.foldable;
06800 SHAPE_WILL_FOLD_LATER(exp_desc->shape[i]) =
06801 loc_exp_desc.will_fold_later;
06802 }
06803 }
06804 break;
06805
06806 case Assumed_Size :
06807
06808
06809 PRINTMSG(IR_LINE_NUM(call_idx), 968, Internal,
06810 IR_COL_NUM(call_idx));
06811
06812 break;
06813
06814 case Deferred_Shape :
06815 case Assumed_Shape :
06816
06817
06818
06819 for (i = 0; i < BD_RANK(bd_idx); i++) {
06820
06821 NTR_IR_TBL(ir_idx);
06822 IR_OPR(ir_idx) = Dv_Access_Extent;
06823 IR_TYPE_IDX(ir_idx) = SA_INTEGER_DEFAULT_TYPE;
06824 IR_DV_DIM(ir_idx) = i + 1;
06825
06826 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
06827 IR_IDX_L(ir_idx) = attr_idx;
06828
06829 IR_LINE_NUM(ir_idx) = IR_LINE_NUM(call_idx);
06830 IR_COL_NUM(ir_idx) = IR_COL_NUM(call_idx);
06831 IR_LINE_NUM_L(ir_idx) = IR_LINE_NUM(call_idx);
06832 IR_COL_NUM_L(ir_idx) = IR_COL_NUM(call_idx);
06833
06834 exp_desc->shape[i].fld = IR_Tbl_Idx;
06835 exp_desc->shape[i].idx = ir_idx;
06836 SHAPE_FOLDABLE(exp_desc->shape[i]) = FALSE;
06837 SHAPE_WILL_FOLD_LATER(exp_desc->shape[i]) = FALSE;
06838 }
06839 break;
06840
06841
06842 }
06843 }
06844
06845 if (has_sf) {
06846 sn_idx = ATP_FIRST_IDX(pgm_idx);
06847
06848 if (ATP_EXTRA_DARG(pgm_idx)) {
06849 sn_idx++;
06850 }
06851
06852 for (i = 0; i < IR_LIST_CNT_R(call_idx); i++) {
06853 ATD_SF_DARG(SN_ATTR_IDX(sn_idx)) = FALSE;
06854 sn_idx++;
06855 }
06856 }
06857
06858
06859 TRACE (Func_Exit, "set_shape_for_deferred_funcs", NULL);
06860
06861 return;
06862
06863 }
06864
06865
06866
06867
06868
06869
06870
06871
06872
06873
06874
06875
06876
06877
06878
06879
06880
06881
06882
06883
06884 boolean gen_internal_dope_vector(int_dope_type *dope_vec,
06885 opnd_type *r_opnd,
06886 boolean just_init,
06887 expr_arg_type *exp_desc)
06888
06889 {
06890 #ifdef KEY
06891 int bd_idx = 0;
06892 int cn_idx = 0;
06893 #else
06894 int bd_idx;
06895 int cn_idx;
06896 #endif
06897 int column;
06898 long_type constant[2];
06899 int i;
06900 # if defined(_HOST_OS_UNICOS) && defined(_TARGET_OS_UNICOS)
06901 _fcd fcd_r;
06902 # endif
06903 int line;
06904 boolean ok = TRUE;
06905 opnd_type opnd;
06906 int type_idx;
06907
06908
06909 TRACE (Func_Entry, "gen_internal_dope_vector", NULL);
06910
06911 type_idx = exp_desc->type_idx;
06912
06913
06914
06915
06916
06917 if (just_init) {
06918
06919 }
06920 else if (OPND_FLD((*r_opnd)) == CN_Tbl_Idx) {
06921 cn_idx = OPND_IDX((*r_opnd));
06922 }
06923 else if ((exp_desc->reference ||
06924 exp_desc->tmp_reference) &&
06925 ! exp_desc->section) {
06926
06927 COPY_OPND(opnd, (*r_opnd));
06928
06929 while (OPND_FLD(opnd) == IR_Tbl_Idx) {
06930 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
06931 }
06932
06933 if (ATD_FLD(OPND_IDX(opnd)) == IR_Tbl_Idx) {
06934 COPY_OPND(opnd, (*r_opnd));
06935
06936 if (fold_aggragate_expression(&opnd, exp_desc, TRUE)) {
06937 cn_idx = OPND_IDX(opnd);
06938
06939 if (exp_desc->rank) {
06940 bd_idx = create_bd_ntry_for_const(exp_desc,
06941 stmt_start_line,
06942 stmt_start_col);
06943 }
06944 }
06945 else {
06946 ok = FALSE;
06947 goto EXIT;
06948 }
06949 }
06950 else {
06951 if (ATD_CLASS(OPND_IDX(opnd)) == Constant) {
06952 cn_idx = ATD_CONST_IDX(OPND_IDX(opnd));
06953 }
06954 else {
06955 cn_idx = ATD_TMP_IDX(OPND_IDX(opnd));
06956 }
06957
06958 bd_idx = ATD_ARRAY_IDX(OPND_IDX(opnd));
06959 }
06960 }
06961 else {
06962 COPY_OPND(opnd, (*r_opnd));
06963
06964 if (fold_aggragate_expression(&opnd, exp_desc, TRUE)) {
06965 cn_idx = OPND_IDX(opnd);
06966
06967 if (exp_desc->rank) {
06968 bd_idx = create_bd_ntry_for_const(exp_desc,
06969 stmt_start_line,
06970 stmt_start_col);
06971 }
06972 }
06973 else {
06974 ok = FALSE;
06975 goto EXIT;
06976 }
06977 }
06978
06979 # ifdef _TARGET_OS_MAX
06980 if (! just_init &&
06981 TYP_LINEAR(CN_TYPE_IDX(cn_idx)) == Complex_4) {
06982
06983
06984 constant[0] = CN_CONST(cn_idx) << 32;
06985 constant[0] |= (CP_CONSTANT(CN_POOL_IDX(cn_idx) + 1) & 0xFFFFFFFF);
06986
06987 cn_idx = ntr_const_tbl(Integer_8,
06988 FALSE,
06989 constant);
06990 }
06991 else
06992 # endif
06993 if (! just_init &&
06994 exp_desc->rank == 0 &&
06995 exp_desc->type != Character &&
06996 exp_desc->type != Structure &&
06997 storage_bit_size_tbl[TYP_LINEAR(CN_TYPE_IDX(cn_idx))] <
06998 TARGET_BITS_PER_WORD) {
06999
07000
07001
07002
07003 constant[0] = CN_CONST(cn_idx) << (TARGET_BITS_PER_WORD -
07004 storage_bit_size_tbl[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]);
07005
07006 cn_idx = ntr_const_tbl(CG_INTEGER_DEFAULT_TYPE,
07007 FALSE,
07008 constant);
07009 }
07010
07011
07012
07013
07014
07015 if (just_init) {
07016 dope_vec->base_addr = 0;
07017 }
07018 # if defined(_HOST_OS_UNICOS) && defined(_TARGET_OS_UNICOS)
07019
07020
07021
07022 else if (exp_desc->type == Character) {
07023 fcd_r = _cptofcd((char *)&CN_CONST(cn_idx),
07024 CN_INT_TO_C(TYP_IDX(exp_desc->type_idx)));
07025 dope_vec->base_addr = *(int *)&fcd_r;
07026 }
07027 else if (exp_desc->type == Structure &&
07028 ATT_CHAR_SEQ(TYP_IDX(exp_desc->type_idx))) {
07029 fcd_r = _cptofcd((char *)&CN_CONST(cn_idx),
07030 (CN_INT_TO_C(ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(exp_desc->type_idx)))) >> 3);
07031 dope_vec->base_addr = *(int *)&fcd_r;
07032 }
07033 # endif
07034 else {
07035 dope_vec->base_addr = (long)&CN_CONST(cn_idx);
07036 }
07037
07038
07039
07040
07041
07042 find_opnd_line_and_column(r_opnd, &line, &column);
07043
07044 if (exp_desc->type == Structure) {
07045
07046 cn_idx = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
07047 if (compare_cn_and_value(cn_idx,
07048 MAX_DV_EL_LEN,
07049 Ge_Opr)) {
07050 PRINTMSG(line, 1174, Error, column, CN_INT_TO_C(cn_idx),MAX_DV_EL_LEN);
07051 dope_vec->el_len = MAX_DV_EL_LEN;
07052 }
07053 else {
07054 dope_vec->el_len = CN_INT_TO_C(cn_idx);
07055 }
07056 }
07057 else if (exp_desc->type == Character) {
07058
07059 if (exp_desc->char_len.fld == CN_Tbl_Idx) {
07060
07061 if (char_len_in_bytes) {
07062
07063 if (compare_cn_and_value(exp_desc->char_len.idx,
07064 MAX_DV_EL_LEN,
07065 Ge_Opr)) {
07066 PRINTMSG(line, 1174, Error, column,
07067 CN_INT_TO_C(exp_desc->char_len.idx),
07068 MAX_DV_EL_LEN);
07069 dope_vec->el_len = MAX_DV_EL_LEN;
07070 }
07071 else {
07072 dope_vec->el_len = CN_INT_TO_C(exp_desc->char_len.idx);
07073 }
07074 }
07075 else {
07076
07077 if (compare_cn_and_value(exp_desc->char_len.idx,
07078 MAX_DV_EL_LEN/8,
07079 Ge_Opr)) {
07080 PRINTMSG(line, 1174, Error, column,
07081 CN_INT_TO_C(exp_desc->char_len.idx),
07082 MAX_DV_EL_LEN/8);
07083 dope_vec->el_len = MAX_DV_EL_LEN;
07084 }
07085 else {
07086 dope_vec->el_len = CN_INT_TO_C(exp_desc->char_len.idx)*8;
07087 }
07088 }
07089 }
07090 else {
07091 PRINTMSG(line, 969, Internal, column);
07092 }
07093 }
07094 else {
07095 dope_vec->el_len = storage_bit_size_tbl[exp_desc->linear_type];
07096 }
07097
07098
07099
07100
07101
07102 if (just_init) {
07103 dope_vec->assoc = 0;
07104 }
07105 else {
07106 dope_vec->assoc = 1;
07107 }
07108
07109
07110
07111
07112
07113 dope_vec->ptr_alloc = 0;
07114
07115
07116
07117
07118
07119 dope_vec->p_or_a = 1;
07120
07121
07122
07123
07124
07125 dope_vec->a_contig = 0;
07126
07127
07128
07129
07130
07131 dope_vec->unused_1 = 0;
07132
07133 # if defined(_TARGET64) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
07134
07135
07136
07137
07138 dope_vec->unused_2 = 0;
07139 # endif
07140
07141
07142
07143
07144
07145
07146 dope_vec->num_dims = exp_desc->rank;
07147
07148 # if defined(_TARGET64) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
07149 # ifndef _TYPE_CODE_64_BIT
07150
07151
07152
07153
07154 dope_vec->unused_3 = 0;
07155 # endif
07156 # endif
07157
07158
07159
07160
07161
07162 make_io_type_code(type_idx, constant);
07163 # ifdef _TYPE_CODE_64_BIT
07164 dope_vec->type_code = *(f90_type_t *)constant;
07165 # else
07166 dope_vec->type_code = *constant;
07167 # endif
07168
07169
07170
07171
07172
07173 dope_vec->orig_base = 0;
07174
07175
07176
07177
07178
07179 #ifdef KEY
07180
07181
07182 #endif
07183
07184 dope_vec->orig_size = 0;
07185
07186 for (i = 0; i < exp_desc->rank; i++) {
07187
07188
07189
07190
07191
07192 if (just_init) {
07193 dope_vec->dim[i].low_bound = 0;
07194 }
07195 else {
07196
07197 dope_vec->dim[i].low_bound = 1;
07198 }
07199
07200
07201
07202
07203
07204
07205 if (just_init) {
07206 dope_vec->dim[i].extent = 0;
07207 }
07208 else if (compare_cn_and_value(BD_XT_IDX(bd_idx, i+1), 0, Lt_Opr)) {
07209 dope_vec->dim[i].extent = 0;
07210 }
07211 else {
07212 dope_vec->dim[i].extent = CN_INT_TO_C(BD_XT_IDX(bd_idx, i+1));
07213 }
07214
07215
07216
07217
07218
07219 if (just_init) {
07220 dope_vec->dim[i].stride_mult = 0;
07221 }
07222 else {
07223 dope_vec->dim[i].stride_mult = CN_INT_TO_C(BD_SM_IDX(bd_idx, i+1));
07224 }
07225 }
07226
07227 EXIT:
07228
07229 TRACE (Func_Exit, "gen_internal_dope_vector", NULL);
07230
07231 return(ok);
07232
07233 }
07234
07235
07236
07237
07238
07239
07240
07241
07242
07243
07244
07245
07246
07247
07248
07249
07250
07251
07252
07253 void transform_char_sequence_ref(opnd_type *top_opnd,
07254 int type_idx)
07255
07256 {
07257 int col;
07258 int ir_idx;
07259 size_offset_type length;
07260 int line;
07261 int list_idx;
07262 size_offset_type num_chars;
07263 opnd_type opnd;
07264
07265 # if 0
07266 int attr_idx;
07267 int bd_idx;
07268 int i;
07269 # endif
07270
07271 TRACE (Func_Entry, "transform_char_sequence_ref", NULL);
07272
07273 switch (OPND_FLD((*top_opnd))) {
07274 case AT_Tbl_Idx :
07275
07276 if (TYP_TYPE(ATD_TYPE_IDX(OPND_IDX((*top_opnd)))) == Structure &&
07277 ATT_CHAR_SEQ(TYP_IDX(ATD_TYPE_IDX(OPND_IDX((*top_opnd)))))) {
07278
07279 goto REFERENCE;
07280 }
07281 else {
07282 goto EXIT;
07283 }
07284
07285 case IR_Tbl_Idx :
07286
07287 # ifdef _DEBUG
07288 if (IR_TYPE_IDX(OPND_IDX((*top_opnd))) == NULL_IDX) {
07289 print_ir(OPND_IDX((*top_opnd)));
07290 find_opnd_line_and_column(top_opnd, &line, &col);
07291 PRINTMSG(line, 993, Internal, col);
07292 }
07293 # endif
07294
07295 if ((IR_OPR(OPND_IDX((*top_opnd))) == Struct_Opr ||
07296 IR_OPR(OPND_IDX((*top_opnd))) == Dv_Deref_Opr ||
07297 IR_OPR(OPND_IDX((*top_opnd))) == Subscript_Opr ||
07298 IR_OPR(OPND_IDX((*top_opnd))) == Whole_Subscript_Opr ||
07299 IR_OPR(OPND_IDX((*top_opnd))) == Section_Subscript_Opr) &&
07300 TYP_TYPE(IR_TYPE_IDX(OPND_IDX((*top_opnd)))) == Structure &&
07301 ATT_CHAR_SEQ(TYP_IDX(IR_TYPE_IDX(OPND_IDX((*top_opnd)))))) {
07302
07303 goto REFERENCE;
07304 }
07305 else if (TYP_TYPE(IR_TYPE_IDX(OPND_IDX((*top_opnd)))) != Structure ||
07306 ! ATT_CHAR_SEQ(TYP_IDX(IR_TYPE_IDX(OPND_IDX((*top_opnd)))))) {
07307
07308 COPY_OPND(opnd, IR_OPND_L(OPND_IDX((*top_opnd))));
07309 transform_char_sequence_ref(&opnd, type_idx);
07310 COPY_OPND(IR_OPND_L(OPND_IDX((*top_opnd))), opnd);
07311
07312 COPY_OPND(opnd, IR_OPND_R(OPND_IDX((*top_opnd))));
07313 transform_char_sequence_ref(&opnd, type_idx);
07314 COPY_OPND(IR_OPND_R(OPND_IDX((*top_opnd))), opnd);
07315
07316 goto EXIT;
07317 }
07318 else {
07319 COPY_OPND(opnd, IR_OPND_L(OPND_IDX((*top_opnd))));
07320 transform_char_sequence_ref(&opnd, type_idx);
07321 COPY_OPND(IR_OPND_L(OPND_IDX((*top_opnd))), opnd);
07322
07323 COPY_OPND(opnd, IR_OPND_R(OPND_IDX((*top_opnd))));
07324 transform_char_sequence_ref(&opnd, type_idx);
07325 COPY_OPND(IR_OPND_R(OPND_IDX((*top_opnd))), opnd);
07326
07327 find_opnd_line_and_column(top_opnd, &line, &col);
07328
07329 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
07330
07331 TYP_TYPE(TYP_WORK_IDX) = Character;
07332 TYP_LINEAR(TYP_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
07333 TYP_DESC(TYP_WORK_IDX) = Default_Typed;
07334 TYP_CHAR_CLASS(TYP_WORK_IDX) = Const_Len_Char;
07335 TYP_FLD(TYP_WORK_IDX) = CN_Tbl_Idx;
07336
07337 num_chars.idx = CN_INTEGER_CHAR_BIT_IDX;
07338 num_chars.fld = CN_Tbl_Idx;
07339
07340 length.fld = ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
07341 length.idx = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
07342
07343 size_offset_binary_calc(&length, &num_chars, Div_Opr, &num_chars);
07344
07345 if (num_chars.fld == NO_Tbl_Idx) {
07346 TYP_FLD(TYP_WORK_IDX) = CN_Tbl_Idx;
07347 TYP_IDX(TYP_WORK_IDX) = ntr_const_tbl(num_chars.type_idx,
07348 FALSE,
07349 num_chars.constant);
07350 }
07351 else {
07352 TYP_FLD(TYP_WORK_IDX) = num_chars.fld;
07353 TYP_IDX(TYP_WORK_IDX) = num_chars.idx;
07354 }
07355
07356 IR_TYPE_IDX(OPND_IDX((*top_opnd))) = ntr_type_tbl();
07357 goto EXIT;
07358 }
07359
07360
07361
07362 case IL_Tbl_Idx :
07363 list_idx = OPND_IDX((*top_opnd));
07364
07365 while (list_idx) {
07366 COPY_OPND(opnd, IL_OPND(list_idx));
07367 transform_char_sequence_ref(&opnd, type_idx);
07368 COPY_OPND(IL_OPND(list_idx), opnd);
07369
07370 list_idx = IL_NEXT_LIST_IDX(list_idx);
07371 }
07372 goto EXIT;
07373
07374 case CN_Tbl_Idx :
07375 case SH_Tbl_Idx :
07376 case NO_Tbl_Idx :
07377 goto EXIT;
07378 }
07379
07380 REFERENCE:
07381
07382 find_opnd_line_and_column(top_opnd, &line, &col);
07383
07384 num_chars.idx = CN_INTEGER_CHAR_BIT_IDX;
07385 num_chars.fld = CN_Tbl_Idx;
07386 length.fld = ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
07387 length.idx = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
07388
07389 size_offset_binary_calc(&length, &num_chars, Div_Opr, &num_chars);
07390
07391 # if 0
07392 while (TYP_TYPE(type_idx) == Structure) {
07393
07394 attr_idx = SN_ATTR_IDX(ATT_FIRST_CPNT_IDX(TYP_IDX(type_idx)));
07395
07396 NTR_IR_TBL(ir_idx);
07397 IR_OPR(ir_idx) = Struct_Opr;
07398 IR_TYPE_IDX(ir_idx) = ATD_TYPE_IDX(attr_idx);
07399 IR_LINE_NUM(ir_idx) = line;
07400 IR_COL_NUM(ir_idx) = col;
07401 COPY_OPND(IR_OPND_L(ir_idx), (*top_opnd));
07402 OPND_FLD((*top_opnd)) = IR_Tbl_Idx;
07403 OPND_IDX((*top_opnd)) = ir_idx;
07404
07405 IR_FLD_R(ir_idx) = AT_Tbl_Idx;
07406 IR_IDX_R(ir_idx) = attr_idx;
07407 IR_LINE_NUM_R(ir_idx) = line;
07408 IR_COL_NUM_R(ir_idx) = col;
07409
07410 if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
07411 bd_idx = ATD_ARRAY_IDX(attr_idx);
07412
07413 NTR_IR_TBL(ir_idx);
07414 IR_OPR(ir_idx) = Subscript_Opr;
07415 IR_TYPE_IDX(ir_idx) = ATD_TYPE_IDX(attr_idx);
07416 IR_LINE_NUM(ir_idx) = line;
07417 IR_COL_NUM(ir_idx) = col;
07418 COPY_OPND(IR_OPND_L(ir_idx), (*top_opnd));
07419 OPND_FLD((*top_opnd)) = IR_Tbl_Idx;
07420 OPND_IDX((*top_opnd)) = ir_idx;
07421
07422 NTR_IR_LIST_TBL(list_idx);
07423 IR_FLD_R(ir_idx) = IL_Tbl_Idx;
07424 IR_IDX_R(ir_idx) = list_idx;
07425 IR_LIST_CNT_R(ir_idx) = BD_RANK(bd_idx);
07426
07427 IL_FLD(list_idx) = BD_LB_FLD(bd_idx, 1);
07428 IL_IDX(list_idx) = BD_LB_IDX(bd_idx, 1);
07429 IL_LINE_NUM(list_idx) = line;
07430 IL_COL_NUM(list_idx) = col;
07431
07432 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
07433 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
07434 }
07435
07436 for (i = 2; i <= BD_RANK(bd_idx); i++) {
07437
07438 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07439 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07440 list_idx = IL_NEXT_LIST_IDX(list_idx);
07441
07442 IL_FLD(list_idx) = BD_LB_FLD(bd_idx, i);
07443 IL_IDX(list_idx) = BD_LB_IDX(bd_idx, i);
07444 IL_LINE_NUM(list_idx) = line;
07445 IL_COL_NUM(list_idx) = col;
07446
07447 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
07448 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
07449 }
07450 }
07451 }
07452
07453 type_idx = ATD_TYPE_IDX(attr_idx);
07454 }
07455 # endif
07456
07457 NTR_IR_TBL(ir_idx);
07458 IR_OPR(ir_idx) = Substring_Opr;
07459 IR_TYPE_IDX(ir_idx) = CHARACTER_DEFAULT_TYPE;
07460 IR_LINE_NUM(ir_idx) = line;
07461 IR_COL_NUM(ir_idx) = col;
07462
07463 COPY_OPND(IR_OPND_L(ir_idx), (*top_opnd));
07464 OPND_FLD((*top_opnd)) = IR_Tbl_Idx;
07465 OPND_IDX((*top_opnd)) = ir_idx;
07466
07467 NTR_IR_LIST_TBL(list_idx);
07468 IR_FLD_R(ir_idx) = IL_Tbl_Idx;
07469 IR_IDX_R(ir_idx) = list_idx;
07470 IR_LIST_CNT_R(ir_idx) = 2;
07471 IL_FLD(list_idx) = CN_Tbl_Idx;
07472 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
07473 IL_LINE_NUM(list_idx) = line;
07474 IL_COL_NUM(list_idx) = col;
07475
07476 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07477 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07478 list_idx = IL_NEXT_LIST_IDX(list_idx);
07479
07480 if (num_chars.fld == NO_Tbl_Idx) {
07481 IL_FLD(list_idx) = CN_Tbl_Idx;
07482 IL_IDX(list_idx) = ntr_const_tbl(num_chars.type_idx,
07483 FALSE,
07484 num_chars.constant);
07485 }
07486 else {
07487 IL_FLD(list_idx) = num_chars.fld;
07488 IL_IDX(list_idx) = num_chars.idx;
07489 }
07490
07491 IL_LINE_NUM(list_idx) = line;
07492 IL_COL_NUM(list_idx) = col;
07493
07494 add_substring_length(ir_idx);
07495
07496 EXIT:
07497
07498 TRACE (Func_Exit, "transform_char_sequence_ref", NULL);
07499
07500 return;
07501
07502 }
07503
07504
07505
07506
07507
07508
07509
07510
07511
07512
07513
07514
07515
07516
07517
07518
07519
07520
07521
07522
07523 void get_concat_len(int concat_idx,
07524 opnd_type *len_opnd)
07525
07526 {
07527 int col;
07528 int line;
07529 int list_idx;
07530 opnd_type opnd;
07531 opnd_type opnd2;
07532 int plus_idx;
07533
07534
07535 TRACE (Func_Entry, "get_concat_len", NULL);
07536
07537 line = IR_LINE_NUM(concat_idx);
07538 col = IR_COL_NUM(concat_idx);
07539
07540 list_idx = IR_IDX_L(concat_idx);
07541 *len_opnd = null_opnd;
07542
07543 while (list_idx) {
07544
07545 COPY_OPND(opnd2, IL_OPND(list_idx));
07546 get_char_len(&opnd2, &opnd);
07547
07548 if (OPND_FLD((*len_opnd)) == NO_Tbl_Idx) {
07549 COPY_OPND((*len_opnd), opnd);
07550 }
07551 else {
07552 NTR_IR_TBL(plus_idx);
07553 IR_OPR(plus_idx) = Plus_Opr;
07554 IR_TYPE_IDX(plus_idx) = CG_INTEGER_DEFAULT_TYPE;
07555 IR_LINE_NUM(plus_idx) = line;
07556 IR_COL_NUM(plus_idx) = col;
07557
07558 COPY_OPND(IR_OPND_L(plus_idx), (*len_opnd));
07559 COPY_OPND(IR_OPND_R(plus_idx), opnd);
07560 OPND_FLD((*len_opnd)) = IR_Tbl_Idx;
07561 OPND_IDX((*len_opnd)) = plus_idx;
07562 }
07563
07564 list_idx = IL_NEXT_LIST_IDX(list_idx);
07565 }
07566
07567 TRACE (Func_Exit, "get_concat_len", NULL);
07568
07569 return;
07570
07571 }
07572
07573
07574
07575
07576
07577
07578
07579
07580
07581
07582
07583
07584
07585
07586
07587
07588
07589 void get_char_len(opnd_type *ref_opnd,
07590 opnd_type *length_opnd)
07591
07592 {
07593 int cn_idx;
07594 int ir_idx;
07595 int line;
07596 int col;
07597 opnd_type opnd;
07598
07599 TRACE (Func_Entry, "get_char_len", NULL);
07600
07601 find_opnd_line_and_column(ref_opnd,
07602 &line,
07603 &col);
07604
07605 switch(OPND_FLD((*ref_opnd))) {
07606 case IR_Tbl_Idx :
07607 ir_idx = OPND_IDX((*ref_opnd));
07608
07609 if (IR_OPR(ir_idx) == Substring_Opr ||
07610 IR_OPR(ir_idx) == Whole_Substring_Opr) {
07611
07612 COPY_OPND((*length_opnd), IL_OPND(IL_NEXT_LIST_IDX(
07613 IL_NEXT_LIST_IDX(IR_IDX_R(ir_idx)))));
07614 }
07615 else if (IR_OPR(ir_idx) == Stmt_Expansion_Opr ||
07616 IR_OPR(ir_idx) == Paren_Opr) {
07617 COPY_OPND(opnd, IR_OPND_L(ir_idx));
07618 get_char_len(&opnd, length_opnd);
07619 }
07620 else if (IR_TYPE_IDX(ir_idx) != NULL_IDX &&
07621 TYP_TYPE(IR_TYPE_IDX(ir_idx)) == Character) {
07622
07623 OPND_FLD((*length_opnd)) = TYP_FLD(IR_TYPE_IDX(ir_idx));
07624 OPND_IDX((*length_opnd)) = TYP_IDX(IR_TYPE_IDX(ir_idx));
07625 OPND_LINE_NUM((*length_opnd)) = line;
07626 OPND_COL_NUM((*length_opnd)) = col;
07627
07628 if (OPND_FLD((*length_opnd)) == AT_Tbl_Idx) {
07629 ADD_TMP_TO_SHARED_LIST(OPND_IDX((*length_opnd)));
07630 }
07631 }
07632 else {
07633 PRINTMSG(line, 626, Internal, col,
07634 "type idx", "get_char_len");
07635 }
07636 break;
07637
07638 case CN_Tbl_Idx :
07639
07640 cn_idx = OPND_IDX((*ref_opnd));
07641 # ifdef _DEBUG
07642 if (TYP_TYPE(CN_TYPE_IDX(cn_idx)) != Character) {
07643 PRINTMSG(line, 626, Internal, col,
07644 "CHARACTER type constant"
07645 "get_concat_len");
07646 }
07647 # endif
07648
07649 OPND_FLD((*length_opnd)) = TYP_FLD(CN_TYPE_IDX(cn_idx));
07650 OPND_IDX((*length_opnd)) = TYP_IDX(CN_TYPE_IDX(cn_idx));
07651 OPND_LINE_NUM((*length_opnd)) = line;
07652 OPND_COL_NUM((*length_opnd)) = col;
07653 break;
07654
07655 default :
07656 PRINTMSG(line, 626, Internal, col,
07657 "IR_Tbl_Idx or CN_Tbl_Idx",
07658 "get_char_len");
07659 break;
07660 }
07661
07662
07663 TRACE (Func_Exit, "get_char_len", NULL);
07664
07665 return;
07666
07667 }
07668
07669
07670
07671
07672
07673
07674
07675
07676
07677
07678
07679
07680
07681
07682
07683
07684
07685 int gen_sf_dv_whole_def(opnd_type *r_opnd,
07686 int type_idx,
07687 int bd_idx)
07688
07689 {
07690 int asg_idx;
07691 opnd_type base_opnd;
07692 int col;
07693 long_type constant;
07694 int dope_idx = NULL_IDX;
07695 int dv_attr_idx;
07696 int i;
07697 int ir_idx;
07698 int line;
07699 int list_idx;
07700 int loc_idx;
07701 int mult_idx;
07702 size_offset_type num_chars;
07703 opnd_type opnd;
07704 long rank;
07705 int rank_idx = NULL_IDX;
07706 size_offset_type result;
07707
07708
07709 TRACE (Func_Entry, "gen_sf_dv_whole_def", NULL);
07710
07711 find_opnd_line_and_column(r_opnd, &line, &col);
07712
07713 dv_attr_idx = gen_compiler_tmp(line, col, Priv, TRUE);
07714
07715 ATD_TYPE_IDX(dv_attr_idx) = type_idx;
07716 ATD_STOR_BLK_IDX(dv_attr_idx) = SCP_SB_STACK_IDX(curr_scp_idx);
07717 AT_SEMANTICS_DONE(dv_attr_idx) = TRUE;
07718
07719
07720 ATD_ARRAY_IDX(dv_attr_idx) = BD_RANK(bd_idx);
07721
07722 ATD_IM_A_DOPE(dv_attr_idx) = TRUE;
07723
07724 NTR_IR_TBL(asg_idx);
07725 IR_OPR(asg_idx) = Dv_Def_Asg_Opr;
07726 IR_TYPE_IDX(asg_idx) = CG_INTEGER_DEFAULT_TYPE;
07727 IR_LINE_NUM(asg_idx) = line;
07728 IR_COL_NUM(asg_idx) = col;
07729
07730 NTR_IR_TBL(ir_idx);
07731 IR_OPR(ir_idx) = Dv_Whole_Def_Opr;
07732 IR_TYPE_IDX(ir_idx) = CG_INTEGER_DEFAULT_TYPE;
07733 IR_LINE_NUM(ir_idx) = line;
07734 IR_COL_NUM(ir_idx) = col;
07735
07736 IR_FLD_L(asg_idx) = AT_Tbl_Idx;
07737 IR_IDX_L(asg_idx) = dv_attr_idx;
07738 IR_LINE_NUM_L(asg_idx) = line;
07739 IR_COL_NUM_L(asg_idx) = col;
07740
07741 IR_FLD_R(asg_idx) = IR_Tbl_Idx;
07742 IR_IDX_R(asg_idx) = ir_idx;
07743
07744 NTR_IR_LIST_TBL(list_idx);
07745 IR_FLD_L(ir_idx) = IL_Tbl_Idx;
07746 IR_IDX_L(ir_idx) = list_idx;
07747
07748 rank = (long) BD_RANK(bd_idx);
07749
07750 IR_LIST_CNT_L(ir_idx) = 10 + (3 * rank);
07751 IR_DV_DIM(ir_idx) = rank;
07752
07753
07754
07755
07756
07757 if (OPND_FLD((*r_opnd)) == AT_Tbl_Idx &&
07758 AT_OBJ_CLASS(OPND_IDX((*r_opnd))) == Data_Obj &&
07759 ATD_CLASS(OPND_IDX((*r_opnd))) == Compiler_Tmp &&
07760 (TYP_TYPE(ATD_TYPE_IDX(OPND_IDX((*r_opnd)))) == CRI_Ptr ||
07761 TYP_TYPE(ATD_TYPE_IDX(OPND_IDX((*r_opnd)))) == CRI_Ch_Ptr ||
07762 ATD_IM_A_DOPE(OPND_IDX((*r_opnd))))) {
07763
07764 if (ATD_IM_A_DOPE(OPND_IDX((*r_opnd)))) {
07765
07766 NTR_IR_TBL(loc_idx);
07767 IR_OPR(loc_idx) = Dv_Access_Base_Addr;
07768 IR_TYPE_IDX(loc_idx) = SA_INTEGER_DEFAULT_TYPE;
07769 IR_LINE_NUM(loc_idx) = line;
07770 IR_COL_NUM(loc_idx) = col;
07771 COPY_OPND(IR_OPND_L(loc_idx), (*r_opnd));
07772 IL_FLD(list_idx) = IR_Tbl_Idx;
07773 IL_IDX(list_idx) = loc_idx;
07774 }
07775 else {
07776 COPY_OPND(IL_OPND(list_idx), (*r_opnd));
07777 }
07778 }
07779 else {
07780 NTR_IR_TBL(loc_idx);
07781 IR_OPR(loc_idx) = Loc_Opr;
07782 IR_LINE_NUM(loc_idx) = line;
07783 IR_COL_NUM(loc_idx) = col;
07784
07785 if (TYP_TYPE(type_idx) == Character) {
07786 IR_TYPE_IDX(loc_idx) = CRI_Ch_Ptr_8;
07787 }
07788 else {
07789 IR_TYPE_IDX(loc_idx) = CRI_Ptr_8;
07790 }
07791
07792 IL_FLD(list_idx) = IR_Tbl_Idx;
07793 IL_IDX(list_idx) = loc_idx;
07794
07795 make_base_subtree(r_opnd, &base_opnd, &rank_idx, &dope_idx);
07796 COPY_OPND(IR_OPND_L(loc_idx), base_opnd);
07797
07798 # ifdef _TRANSFORM_CHAR_SEQUENCE
07799 # ifdef _TARGET_OS_UNICOS
07800 if (TYP_TYPE(type_idx) == Structure &&
07801 ATT_CHAR_SEQ(TYP_IDX(type_idx))) {
07802
07803 IR_TYPE_IDX(loc_idx) = CRI_Ch_Ptr_8;
07804 COPY_OPND(opnd, IR_OPND_L(loc_idx));
07805 transform_char_sequence_ref(&opnd, type_idx);
07806 COPY_OPND(IR_OPND_L(loc_idx), opnd);
07807 }
07808 # endif
07809 # endif
07810 }
07811
07812
07813
07814
07815
07816
07817 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07818 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07819 list_idx = IL_NEXT_LIST_IDX(list_idx);
07820
07821 if (TYP_TYPE(type_idx) == Structure) {
07822 IL_FLD(list_idx) = (fld_type) ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
07823 IL_IDX(list_idx) = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
07824 IL_LINE_NUM(list_idx) = line;
07825 IL_COL_NUM(list_idx) = col;
07826 }
07827 else if (TYP_TYPE(type_idx) == Character) {
07828
07829 if (TYP_FLD(type_idx) == CN_Tbl_Idx) {
07830
07831 if (char_len_in_bytes) {
07832
07833 IL_FLD(list_idx) = CN_Tbl_Idx;
07834 IL_IDX(list_idx) = TYP_IDX(type_idx);
07835 }
07836 else {
07837 result.idx = CN_INTEGER_CHAR_BIT_IDX;
07838 result.fld = CN_Tbl_Idx;
07839
07840 num_chars.fld = TYP_FLD(type_idx);
07841 num_chars.idx = TYP_IDX(type_idx);
07842
07843 size_offset_binary_calc(&num_chars, &result, Mult_Opr, &result);
07844
07845 if (result.fld == NO_Tbl_Idx) {
07846 IL_FLD(list_idx) = CN_Tbl_Idx;
07847 IL_IDX(list_idx) = ntr_const_tbl(result.type_idx,
07848 FALSE,
07849 result.constant);
07850 }
07851 else {
07852 IL_FLD(list_idx) = result.fld;
07853 IL_IDX(list_idx) = result.idx;
07854 }
07855 }
07856 IL_LINE_NUM(list_idx) = line;
07857 IL_COL_NUM(list_idx) = col;
07858 }
07859 else {
07860 if (char_len_in_bytes) {
07861
07862 IL_FLD(list_idx) = TYP_FLD(type_idx);
07863 IL_IDX(list_idx) = TYP_IDX(type_idx);
07864 IL_LINE_NUM(list_idx) = line;
07865 IL_COL_NUM(list_idx) = col;
07866
07867 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
07868 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
07869 }
07870 }
07871 else {
07872
07873 NTR_IR_TBL(mult_idx);
07874 IR_OPR(mult_idx) = Mult_Opr;
07875 IR_TYPE_IDX(mult_idx) = CG_INTEGER_DEFAULT_TYPE;
07876 IR_LINE_NUM(mult_idx) = line;
07877 IR_COL_NUM(mult_idx) = col;
07878 constant = 8;
07879 IR_FLD_L(mult_idx) = CN_Tbl_Idx;
07880 IR_IDX_L(mult_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 8);
07881 IR_LINE_NUM_L(mult_idx) = line;
07882 IR_COL_NUM_L(mult_idx) = col;
07883
07884 IR_FLD_R(mult_idx) = TYP_FLD(type_idx);
07885 IR_IDX_R(mult_idx) = TYP_IDX(type_idx);
07886 IR_LINE_NUM_R(mult_idx) = line;
07887 IR_COL_NUM_R(mult_idx) = col;
07888
07889 if (IR_FLD_R(mult_idx) == AT_Tbl_Idx) {
07890 ADD_TMP_TO_SHARED_LIST(IR_IDX_R(mult_idx));
07891 }
07892
07893 IL_FLD(list_idx) = IR_Tbl_Idx;
07894 IL_IDX(list_idx) = mult_idx;
07895 }
07896 }
07897 }
07898 else {
07899 constant = storage_bit_size_tbl[TYP_LINEAR(type_idx)];
07900 IL_FLD(list_idx) = CN_Tbl_Idx;
07901 IL_IDX(list_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, constant);
07902 IL_LINE_NUM(list_idx) = line;
07903 IL_COL_NUM(list_idx) = col;
07904 }
07905
07906
07907
07908
07909
07910 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07911 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07912 list_idx = IL_NEXT_LIST_IDX(list_idx);
07913
07914 IL_FLD(list_idx) = CN_Tbl_Idx;
07915 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
07916 IL_LINE_NUM(list_idx) = line;
07917 IL_COL_NUM(list_idx) = col;
07918
07919
07920
07921
07922
07923 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07924 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07925 list_idx = IL_NEXT_LIST_IDX(list_idx);
07926
07927 IL_FLD(list_idx) = CN_Tbl_Idx;
07928 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
07929 IL_LINE_NUM(list_idx) = line;
07930 IL_COL_NUM(list_idx) = col;
07931
07932
07933
07934
07935
07936
07937 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07938 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07939 list_idx = IL_NEXT_LIST_IDX(list_idx);
07940
07941 IL_FLD(list_idx) = CN_Tbl_Idx;
07942 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
07943 IL_LINE_NUM(list_idx) = line;
07944 IL_COL_NUM(list_idx) = col;
07945
07946
07947
07948
07949
07950
07951 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07952 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07953 list_idx = IL_NEXT_LIST_IDX(list_idx);
07954
07955 IL_FLD(list_idx) = CN_Tbl_Idx;
07956 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
07957 IL_LINE_NUM(list_idx) = line;
07958 IL_COL_NUM(list_idx) = col;
07959
07960
07961
07962
07963
07964 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07965 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07966 list_idx = IL_NEXT_LIST_IDX(list_idx);
07967
07968 IL_FLD(list_idx) = CN_Tbl_Idx;
07969 IL_IDX(list_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, rank);
07970 IL_LINE_NUM(list_idx) = line;
07971 IL_COL_NUM(list_idx) = col;
07972
07973
07974
07975
07976
07977
07978 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07979 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07980 list_idx = IL_NEXT_LIST_IDX(list_idx);
07981
07982 IL_FLD(list_idx) = CN_Tbl_Idx;
07983 IL_IDX(list_idx) = create_dv_type_code(dv_attr_idx);
07984 IL_LINE_NUM(list_idx) = line;
07985 IL_COL_NUM(list_idx) = col;
07986
07987
07988
07989
07990
07991 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
07992 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
07993 list_idx = IL_NEXT_LIST_IDX(list_idx);
07994
07995 IL_FLD(list_idx) = CN_Tbl_Idx;
07996 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
07997 IL_LINE_NUM(list_idx) = line;
07998 IL_COL_NUM(list_idx) = col;
07999
08000
08001
08002
08003
08004
08005 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
08006 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
08007 list_idx = IL_NEXT_LIST_IDX(list_idx);
08008
08009 IL_FLD(list_idx) = CN_Tbl_Idx;
08010 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
08011 IL_LINE_NUM(list_idx) = line;
08012 IL_COL_NUM(list_idx) = col;
08013
08014 #ifdef KEY
08015
08016
08017 list_idx = do_alloc_cpnt(line, col, list_idx, 0);
08018 #endif
08019
08020 for (i = 1; i <= rank; i++) {
08021
08022
08023
08024
08025
08026 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
08027 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
08028 list_idx = IL_NEXT_LIST_IDX(list_idx);
08029
08030 IL_FLD(list_idx) = BD_LB_FLD(bd_idx, i);
08031 IL_IDX(list_idx) = BD_LB_IDX(bd_idx, i);
08032 IL_LINE_NUM(list_idx) = line;
08033 IL_COL_NUM(list_idx) = col;
08034
08035 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
08036 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
08037 }
08038
08039
08040
08041
08042
08043 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
08044 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
08045 list_idx = IL_NEXT_LIST_IDX(list_idx);
08046
08047 IL_FLD(list_idx) = BD_XT_FLD(bd_idx, i);
08048 IL_IDX(list_idx) = BD_XT_IDX(bd_idx, i);
08049 IL_LINE_NUM(list_idx) = line;
08050 IL_COL_NUM(list_idx) = col;
08051
08052 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
08053 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
08054 }
08055
08056
08057
08058
08059
08060 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
08061 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
08062 list_idx = IL_NEXT_LIST_IDX(list_idx);
08063
08064 IL_FLD(list_idx) = BD_SM_FLD(bd_idx, i);
08065 IL_IDX(list_idx) = BD_SM_IDX(bd_idx, i);
08066 IL_LINE_NUM(list_idx) = line;
08067 IL_COL_NUM(list_idx) = col;
08068
08069 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
08070 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
08071 }
08072 }
08073
08074 gen_sh(Before, Assignment_Stmt, line, col, FALSE, FALSE, TRUE);
08075
08076 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
08077 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
08078
08079 TRACE (Func_Exit, "gen_sf_dv_whole_def", NULL);
08080
08081 return(dv_attr_idx);
08082
08083 }
08084
08085
08086
08087
08088
08089
08090
08091
08092
08093
08094
08095
08096
08097
08098
08099
08100
08101
08102
08103
08104
08105 static void compute_char_element_len(opnd_type *char_len,
08106 opnd_type *char_opnd,
08107 opnd_type *result_opnd)
08108
08109 {
08110 int col;
08111 int line;
08112 expr_arg_type loc_exp_desc;
08113 int mult_idx;
08114 cif_usage_code_type save_xref_state;
08115
08116
08117 TRACE (Func_Entry, "compute_char_element_len", NULL);
08118
08119 find_opnd_line_and_column(char_opnd, &line, &col);
08120
08121 if (OPND_FLD((*char_opnd)) == IR_Tbl_Idx &&
08122 IR_OPR(OPND_IDX((*char_opnd))) == Concat_Opr) {
08123
08124 get_concat_len(OPND_IDX((*char_opnd)), result_opnd);
08125 }
08126 else {
08127 COPY_OPND((*result_opnd), (*char_len));
08128 }
08129
08130 if (! char_len_in_bytes) {
08131
08132
08133
08134 NTR_IR_TBL(mult_idx);
08135 IR_OPR(mult_idx) = Mult_Opr;
08136 IR_TYPE_IDX(mult_idx) = CG_INTEGER_DEFAULT_TYPE;
08137 IR_LINE_NUM(mult_idx) = line;
08138 IR_COL_NUM(mult_idx) = col;
08139 IR_FLD_L(mult_idx) = CN_Tbl_Idx;
08140 IR_IDX_L(mult_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, 8);
08141 IR_LINE_NUM_L(mult_idx) = line;
08142 IR_COL_NUM_L(mult_idx) = col;
08143
08144 COPY_OPND(IR_OPND_R(mult_idx), (*result_opnd));
08145
08146 OPND_FLD((*result_opnd)) = IR_Tbl_Idx;
08147 OPND_IDX((*result_opnd)) = mult_idx;
08148 }
08149
08150
08151 loc_exp_desc.rank = 0;
08152 save_xref_state = xref_state;
08153 xref_state = CIF_No_Usage_Rec;
08154 expr_semantics(result_opnd, &loc_exp_desc);
08155 xref_state = save_xref_state;
08156
08157 TRACE (Func_Exit, "compute_char_element_len", NULL);
08158
08159 return;
08160
08161 }
08162
08163
08164
08165
08166
08167
08168
08169
08170
08171
08172
08173
08174
08175
08176
08177
08178
08179
08180
08181
08182
08183 void get_shape_from_attr(expr_arg_type *exp_desc,
08184 int attr_idx,
08185 int rank,
08186 int line,
08187 int column)
08188
08189 {
08190 int i;
08191 int ir_idx;
08192
08193
08194 TRACE (Func_Entry, "get_shape_from_attr", NULL);
08195
08196 if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
08197 for (i = 0; i < rank; i++) {
08198
08199 if (ATD_IM_A_DOPE(attr_idx)) {
08200 OPND_FLD(exp_desc->shape[i]) = IR_Tbl_Idx;
08201 NTR_IR_TBL(ir_idx);
08202 IR_OPR(ir_idx) = Dv_Access_Extent;
08203 IR_TYPE_IDX(ir_idx) = SA_INTEGER_DEFAULT_TYPE;
08204 IR_LINE_NUM(ir_idx) = line;
08205 IR_COL_NUM(ir_idx) = column;
08206 IR_DV_DIM(ir_idx) = i + 1;
08207 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
08208 IR_IDX_L(ir_idx) = attr_idx;
08209 IR_LINE_NUM_L(ir_idx) = line;
08210 IR_COL_NUM_L(ir_idx) = column;
08211 OPND_IDX(exp_desc->shape[i]) = ir_idx;
08212
08213 SHAPE_FOLDABLE(exp_desc->shape[i]) = FALSE;
08214 SHAPE_WILL_FOLD_LATER(exp_desc->shape[i]) = FALSE;
08215 }
08216 else {
08217 OPND_FLD(exp_desc->shape[i]) =
08218 BD_XT_FLD(ATD_ARRAY_IDX(attr_idx), i+1);
08219 OPND_IDX(exp_desc->shape[i]) =
08220 BD_XT_IDX(ATD_ARRAY_IDX(attr_idx), i+1);
08221 OPND_LINE_NUM(exp_desc->shape[i]) = line;
08222 OPND_COL_NUM(exp_desc->shape[i]) = column;
08223
08224 if (OPND_FLD(exp_desc->shape[i]) == AT_Tbl_Idx) {
08225 ADD_TMP_TO_SHARED_LIST(OPND_IDX(exp_desc->shape[i]));
08226 }
08227
08228 if (OPND_FLD(exp_desc->shape[i]) == CN_Tbl_Idx) {
08229 SHAPE_FOLDABLE(exp_desc->shape[i]) = TRUE;
08230 SHAPE_WILL_FOLD_LATER(exp_desc->shape[i]) = TRUE;
08231 }
08232 else if (OPND_FLD(exp_desc->shape[i]) == AT_Tbl_Idx &&
08233 AT_OBJ_CLASS(OPND_IDX(exp_desc->shape[i])) == Data_Obj &&
08234 ATD_LCV_IS_CONST(OPND_IDX(exp_desc->shape[i]))) {
08235 SHAPE_FOLDABLE(exp_desc->shape[i]) = FALSE;
08236 SHAPE_WILL_FOLD_LATER(exp_desc->shape[i]) = TRUE;
08237 }
08238 else {
08239 SHAPE_FOLDABLE(exp_desc->shape[i]) = FALSE;
08240 SHAPE_WILL_FOLD_LATER(exp_desc->shape[i]) = FALSE;
08241 }
08242 }
08243 }
08244 }
08245
08246 TRACE (Func_Exit, "get_shape_from_attr", NULL);
08247
08248 return;
08249
08250 }
08251
08252
08253
08254
08255
08256
08257
08258
08259
08260
08261
08262
08263
08264
08265
08266
08267
08268
08269
08270
08271
08272
08273
08274
08275 void insert_init_stmt_for_tmp(int tmp_idx)
08276
08277 {
08278 int asg_idx;
08279 int bd_idx;
08280 int col;
08281 int i;
08282 int line;
08283 int list_idx;
08284 int save_curr_stmt_sh_idx;
08285 int sub_idx;
08286
08287
08288 TRACE (Func_Entry, "insert_init_stmt_for_tmp", NULL);
08289
08290 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
08291 curr_stmt_sh_idx = SCP_LAST_SH_IDX(curr_scp_idx);
08292
08293 line = AT_DEF_LINE(tmp_idx);
08294 col = AT_DEF_COLUMN(tmp_idx);
08295 bd_idx = ATD_ARRAY_IDX(tmp_idx);
08296
08297 NTR_IR_TBL(asg_idx);
08298 IR_OPR(asg_idx) = Init_Opr;
08299 IR_TYPE_IDX(asg_idx) = TYPELESS_DEFAULT_TYPE;
08300 IR_LINE_NUM(asg_idx) = line;
08301 IR_COL_NUM(asg_idx) = col;
08302 IR_LINE_NUM_L(asg_idx) = line;
08303 IR_COL_NUM_L(asg_idx) = col;
08304
08305 if (ATD_FLD(tmp_idx) == IR_Tbl_Idx &&
08306 bd_idx != NULL_IDX) {
08307
08308 NTR_IR_TBL(sub_idx);
08309 IR_OPR(sub_idx) = Subscript_Opr;
08310 IR_TYPE_IDX(sub_idx) = ATD_TYPE_IDX(tmp_idx);
08311 IR_LINE_NUM(sub_idx) = line;
08312 IR_COL_NUM(sub_idx) = col;
08313 IR_FLD_L(sub_idx) = AT_Tbl_Idx;
08314 IR_IDX_L(sub_idx) = tmp_idx;
08315 IR_LINE_NUM_L(sub_idx) = line;
08316 IR_COL_NUM_L(sub_idx) = col;
08317
08318 IR_FLD_L(asg_idx) = IR_Tbl_Idx;
08319 IR_IDX_L(asg_idx) = sub_idx;
08320
08321 NTR_IR_LIST_TBL(list_idx);
08322 IR_FLD_R(sub_idx) = IL_Tbl_Idx;
08323 IR_LIST_CNT_R(sub_idx) = BD_RANK(bd_idx);
08324 IR_IDX_R(sub_idx) = list_idx;
08325
08326 IL_FLD(list_idx) = BD_LB_FLD(bd_idx, 1);
08327 IL_IDX(list_idx) = BD_LB_IDX(bd_idx, 1);
08328 IL_LINE_NUM(list_idx) = line;
08329 IL_COL_NUM(list_idx) = col;
08330
08331 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
08332 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
08333 }
08334
08335 for (i = 2; i <= BD_RANK(bd_idx); i++) {
08336 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
08337 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
08338 list_idx = IL_NEXT_LIST_IDX(list_idx);
08339
08340 IL_FLD(list_idx) = BD_LB_FLD(bd_idx, i);
08341 IL_IDX(list_idx) = BD_LB_IDX(bd_idx, i);
08342 IL_LINE_NUM(list_idx) = line;
08343 IL_COL_NUM(list_idx) = col;
08344
08345 if (IL_FLD(list_idx) == AT_Tbl_Idx) {
08346 ADD_TMP_TO_SHARED_LIST(IL_IDX(list_idx));
08347 }
08348 }
08349 }
08350 else {
08351 IR_FLD_L(asg_idx) = AT_Tbl_Idx;
08352 IR_IDX_L(asg_idx) = tmp_idx;
08353 }
08354
08355 NTR_IR_LIST_TBL(list_idx);
08356 IR_FLD_R(asg_idx) = IL_Tbl_Idx;
08357 IR_IDX_R(asg_idx) = list_idx;
08358 IR_LIST_CNT_R(asg_idx) = 3;
08359
08360 IL_FLD(list_idx) = CN_Tbl_Idx;
08361 IL_IDX(list_idx) = (ATD_FLD(tmp_idx) == CN_Tbl_Idx ? ATD_TMP_IDX(tmp_idx) :
08362 IR_IDX_R(ATD_TMP_IDX(tmp_idx)));
08363 IL_LINE_NUM(list_idx) = line;
08364 IL_COL_NUM(list_idx) = col;
08365
08366 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
08367 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
08368 list_idx = IL_NEXT_LIST_IDX(list_idx);
08369
08370 IL_FLD(list_idx) = CN_Tbl_Idx;
08371 IL_IDX(list_idx) = (ATD_FLD(tmp_idx) == CN_Tbl_Idx ? CN_INTEGER_ONE_IDX :
08372 IR_IDX_L(ATD_TMP_IDX(tmp_idx)));
08373 IL_LINE_NUM(list_idx) = line;
08374 IL_COL_NUM(list_idx) = col;
08375
08376 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
08377 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
08378 list_idx = IL_NEXT_LIST_IDX(list_idx);
08379
08380 IL_FLD(list_idx) = CN_Tbl_Idx;
08381
08382 if (ATD_FLD(tmp_idx) == CN_Tbl_Idx) {
08383 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
08384 }
08385 else {
08386 IL_IDX(list_idx) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
08387 storage_bit_size_tbl[TYP_LINEAR(CN_TYPE_IDX(
08388 IR_IDX_R(ATD_TMP_IDX(tmp_idx))))]);
08389 }
08390
08391 IL_LINE_NUM(list_idx) = line;
08392 IL_COL_NUM(list_idx) = col;
08393
08394 gen_sh(Before, Assignment_Stmt, line, col,
08395 FALSE, FALSE, TRUE);
08396 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
08397 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
08398
08399 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
08400
08401 ATD_TMP_INIT_NOT_DONE(tmp_idx) = FALSE;
08402
08403 TRACE (Func_Exit, "insert_init_stmt_for_tmp", NULL);
08404
08405 return;
08406
08407 }
08408
08409
08410
08411
08412
08413
08414
08415
08416
08417
08418
08419
08420
08421
08422
08423
08424
08425 int gen_static_integer_array_tmp(int size,
08426 int line,
08427 int col)
08428
08429 {
08430 expr_arg_type exp_desc;
08431 int tmp_idx;
08432 int type_idx;
08433
08434
08435 TRACE (Func_Entry, "gen_static_integer_array_tmp", NULL);
08436
08437 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
08438 type_idx = SA_INTEGER_DEFAULT_TYPE;
08439 # else
08440 type_idx = CG_INTEGER_DEFAULT_TYPE;
08441 # endif
08442
08443 tmp_idx = gen_compiler_tmp(line,col, Shared, TRUE);
08444 ATD_TYPE_IDX(tmp_idx) = type_idx;
08445 ATD_SAVED(tmp_idx) = TRUE;
08446 ATD_DATA_INIT(tmp_idx) = TRUE;
08447 ATD_STOR_BLK_IDX(tmp_idx) = SCP_SB_STATIC_INIT_IDX(curr_scp_idx);
08448 AT_SEMANTICS_DONE(tmp_idx)= TRUE;
08449
08450 exp_desc = init_exp_desc;
08451 exp_desc.type = Integer;
08452 exp_desc.type_idx = type_idx;
08453 exp_desc.linear_type = TYP_LINEAR(type_idx);
08454 exp_desc.rank = 1;
08455 exp_desc.shape[0].fld = CN_Tbl_Idx;
08456 exp_desc.shape[0].idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, size);
08457
08458 ATD_ARRAY_IDX(tmp_idx) = create_bd_ntry_for_const(&exp_desc,
08459 line,
08460 col);
08461
08462
08463 TRACE (Func_Exit, "gen_static_integer_array_tmp", NULL);
08464
08465 return(tmp_idx);
08466
08467 }
08468
08469
08470
08471
08472
08473
08474
08475
08476
08477
08478
08479
08480
08481
08482
08483
08484
08485 int cast_typeless_constant(int cn_idx,
08486 int type_idx,
08487 int line,
08488 int col)
08489
08490 {
08491 # if defined(_TARGET_OS_UNICOS)
08492 long_type another_constant[MAX_WORDS_FOR_NUMERIC];
08493 # endif
08494
08495 char *char_ptr;
08496 long64 i;
08497 long64 k;
08498 int l;
08499 int new_const_idx;
08500 long64 new_word_size;
08501 long64 old_word_size;
08502 boolean right_justified;
08503 long_type the_constant[MAX_WORDS_FOR_NUMERIC];
08504 boolean zero_pad;
08505
08506
08507 TRACE (Func_Entry, "cast_typeless_constant", NULL);
08508
08509 if (TYP_TYPE(type_idx) == CRI_Ptr ||
08510 TYP_TYPE(type_idx) == CRI_Parcel_Ptr ||
08511 TYP_TYPE(type_idx) == CRI_Ch_Ptr) {
08512 type_idx = TYPELESS_DEFAULT_TYPE;
08513 }
08514
08515 if (CN_HOLLERITH_TYPE(cn_idx) == H_Hollerith) {
08516 right_justified = FALSE;
08517 zero_pad = FALSE;
08518 old_word_size = TARGET_BITS_TO_WORDS(TYP_BIT_LEN(CN_TYPE_IDX(cn_idx)));
08519 }
08520 else if (CN_HOLLERITH_TYPE(cn_idx) == L_Hollerith) {
08521 right_justified = FALSE;
08522 zero_pad = TRUE;
08523 old_word_size = TARGET_BITS_TO_WORDS(TYP_BIT_LEN(CN_TYPE_IDX(cn_idx)));
08524 }
08525 else if (CN_HOLLERITH_TYPE(cn_idx) == R_Hollerith) {
08526 right_justified = TRUE;
08527 zero_pad = TRUE;
08528 old_word_size = TARGET_BITS_TO_WORDS(TYP_BIT_LEN(CN_TYPE_IDX(cn_idx)));
08529 }
08530 else if (TYP_TYPE(CN_TYPE_IDX(cn_idx)) == Character) {
08531 right_justified = FALSE;
08532 zero_pad = FALSE;
08533 old_word_size = TARGET_BYTES_TO_WORDS(
08534 CN_INT_TO_C(TYP_IDX(CN_TYPE_IDX(cn_idx))));
08535 }
08536 else {
08537
08538 right_justified = TRUE;
08539 zero_pad = TRUE;
08540 old_word_size = TARGET_BITS_TO_WORDS(TYP_BIT_LEN(CN_TYPE_IDX(cn_idx)));
08541 }
08542
08543
08544 if (TYP_TYPE(type_idx) == Typeless) {
08545 new_word_size = TARGET_BITS_TO_WORDS(TYP_BIT_LEN(type_idx));
08546 }
08547 else {
08548 new_word_size = TARGET_BITS_TO_WORDS(
08549 storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
08550 }
08551
08552 if (right_justified) {
08553 k = old_word_size - 1;
08554 for (i = new_word_size - 1; i >= 0; i--) {
08555 if (k < 0) {
08556 break;
08557 }
08558 #if defined(TARG_X8664) || defined(TARG_MIPS)
08559 the_constant[new_word_size-1-i] = CP_CONSTANT(CN_POOL_IDX(cn_idx) + k);
08560 #else
08561 the_constant[i] = CP_CONSTANT(CN_POOL_IDX(cn_idx) + k);
08562 #endif
08563 k--;
08564 }
08565
08566 while (i >= 0) {
08567
08568 if (zero_pad) {
08569 #if defined(TARG_X8664) || defined(TARG_MIPS)
08570
08571 the_constant[new_word_size-1-i] = 0;
08572 #else
08573 the_constant[i] = 0;
08574 #endif
08575 }
08576 else {
08577 char_ptr = (char *)&(the_constant[i]);
08578 for (l = 0; l < TARGET_CHARS_PER_WORD; l++) {
08579 char_ptr[l] = ' ';
08580 }
08581 }
08582
08583 i--;
08584 }
08585
08586 if (k >= 0) {
08587
08588 PRINTMSG(line, 1127, Caution, col);
08589 }
08590 }
08591 else {
08592 k = 0;
08593 for (i = 0; i < new_word_size; i++) {
08594 if (k >= old_word_size) {
08595 break;
08596 }
08597 the_constant[i] = CP_CONSTANT(CN_POOL_IDX(cn_idx) + k);
08598 k++;
08599 }
08600
08601 while (i < new_word_size) {
08602
08603 if (zero_pad) {
08604 the_constant[i] = 0;
08605 }
08606 else {
08607 char_ptr = (char *)&(the_constant[i]);
08608 for (l = 0; l < TARGET_CHARS_PER_WORD; l++) {
08609 char_ptr[l] = ' ';
08610 }
08611 }
08612
08613 i++;
08614 }
08615
08616 if (k < old_word_size) {
08617
08618 PRINTMSG(line, 1127, Caution, col);
08619 }
08620
08621 # ifdef _TARGET_OS_MAX
08622 if (TYP_LINEAR(type_idx) == Integer_1 ||
08623 TYP_LINEAR(type_idx) == Integer_2 ||
08624 TYP_LINEAR(type_idx) == Integer_4 ||
08625 TYP_LINEAR(type_idx) == Real_4 ||
08626 TYP_LINEAR(type_idx) == Logical_1 ||
08627 TYP_LINEAR(type_idx) == Logical_2 ||
08628 TYP_LINEAR(type_idx) == Logical_4) {
08629
08630 the_constant[0] = the_constant[0] >> 32;
08631 }
08632 # elif defined(_INTEGER_1_AND_2) && !defined(_TARGET_LITTLE_ENDIAN)
08633
08634 if (on_off_flags.integer_1_and_2 &&
08635 (TYP_LINEAR(type_idx) == Integer_1 ||
08636 TYP_LINEAR(type_idx) == Integer_2 ||
08637 TYP_LINEAR(type_idx) == Logical_1 ||
08638 TYP_LINEAR(type_idx) == Logical_2)) {
08639
08640 the_constant[0] = the_constant[0] >> (TARGET_BITS_PER_WORD -
08641 storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
08642 }
08643 # endif
08644 }
08645
08646 # if defined(_INTEGER_1_AND_2)
08647
08648 if (on_off_flags.integer_1_and_2) {
08649
08650 if (TYP_LINEAR(type_idx) == Integer_1 ||
08651 TYP_LINEAR(type_idx) == Logical_1) {
08652
08653 the_constant[0] = the_constant[0] & 0XFF;
08654 }
08655 else if (TYP_LINEAR(type_idx) == Integer_2 ||
08656 TYP_LINEAR(type_idx) == Logical_2) {
08657
08658 the_constant[0] = the_constant[0] & 0XFFFF;
08659 }
08660 }
08661 # endif
08662
08663 # ifdef _TARGET_OS_UNICOS
08664
08665
08666
08667
08668 if (TYP_LINEAR(type_idx) == Integer_1 ||
08669 TYP_LINEAR(type_idx) == Integer_2 ||
08670 TYP_LINEAR(type_idx) == Integer_4) {
08671
08672 if (folder_driver( (char *) the_constant,
08673 Integer_8,
08674 NULL,
08675 NULL_IDX,
08676 another_constant,
08677 &type_idx,
08678 line,
08679 col,
08680 1,
08681 Cvrt_Opr)) {
08682
08683 for (i=0; i<MAX_WORDS_FOR_INTEGER; i++) {
08684 the_constant[i] = another_constant[i];
08685 }
08686 }
08687 }
08688 # endif
08689
08690 if (TYP_TYPE(type_idx) == Typeless &&
08691 CN_BOZ_CONSTANT(cn_idx)) {
08692 new_const_idx = ntr_boz_const_tbl(type_idx,
08693 the_constant);
08694 }
08695 else if (TYP_TYPE(type_idx) == Typeless &&
08696 CN_BOOLEAN_CONSTANT(cn_idx)) {
08697 new_const_idx = ntr_boolean_const_tbl(type_idx,
08698 the_constant);
08699 }
08700 else {
08701
08702 if (TYP_TYPE(type_idx) == Real) {
08703 new_const_idx = ntr_unshared_const_tbl(type_idx,
08704 FALSE,
08705 the_constant);
08706 }
08707 else {
08708 new_const_idx = ntr_const_tbl(type_idx,
08709 FALSE,
08710 the_constant);
08711 }
08712 }
08713
08714 TRACE (Func_Exit, "cast_typeless_constant", NULL);
08715
08716 return(new_const_idx);
08717
08718 }
08719
08720
08721
08722
08723
08724
08725
08726
08727
08728
08729
08730
08731
08732
08733
08734
08735
08736
08737
08738
08739
08740
08741 void cast_to_cg_default(opnd_type *opnd,
08742 expr_arg_type *exp_desc)
08743
08744 {
08745 int col;
08746 int cvrt_idx;
08747 boolean do_cast = FALSE;
08748 long_type folded_const[MAX_WORDS_FOR_NUMERIC];
08749 int line;
08750 int type_idx;
08751
08752 TRACE (Func_Entry, "cast_to_cg_default", NULL);
08753
08754 if (exp_desc->type == Integer) {
08755
08756 if (storage_bit_size_tbl[exp_desc->linear_type] !=
08757 storage_bit_size_tbl[TYP_LINEAR(CG_INTEGER_DEFAULT_TYPE)]) {
08758
08759 do_cast = TRUE;
08760 type_idx = CG_INTEGER_DEFAULT_TYPE;
08761 }
08762 }
08763 else if (exp_desc->type == Logical) {
08764
08765 if (storage_bit_size_tbl[exp_desc->linear_type] !=
08766 storage_bit_size_tbl[TYP_LINEAR(CG_LOGICAL_DEFAULT_TYPE)]) {
08767
08768 do_cast = TRUE;
08769 type_idx = CG_LOGICAL_DEFAULT_TYPE;
08770 }
08771 }
08772
08773 if (do_cast) {
08774 find_opnd_line_and_column(opnd, &line, &col);
08775
08776 if (OPND_FLD((*opnd)) == CN_Tbl_Idx) {
08777
08778 if (folder_driver((char *)&CN_CONST(OPND_IDX((*opnd))),
08779 exp_desc->type_idx,
08780 NULL,
08781 NULL_IDX,
08782 folded_const,
08783 &type_idx,
08784 line,
08785 col,
08786 1,
08787 Cvrt_Opr)) {
08788
08789 }
08790
08791 OPND_IDX((*opnd)) = ntr_const_tbl(type_idx,
08792 FALSE,
08793 folded_const);
08794
08795 }
08796 else {
08797
08798 NTR_IR_TBL(cvrt_idx);
08799 IR_OPR(cvrt_idx) = Cvrt_Opr;
08800 IR_TYPE_IDX(cvrt_idx) = type_idx;
08801 IR_LINE_NUM(cvrt_idx) = line;
08802 IR_COL_NUM(cvrt_idx) = col;
08803
08804 IR_RANK(cvrt_idx) = exp_desc->rank;
08805
08806 COPY_OPND(IR_OPND_L(cvrt_idx), (*opnd));
08807
08808 if (exp_desc->rank > 0) {
08809 IR_ARRAY_SYNTAX(cvrt_idx) = TRUE;
08810 }
08811
08812 OPND_FLD((*opnd)) = IR_Tbl_Idx;
08813 OPND_IDX((*opnd)) = cvrt_idx;
08814
08815 exp_desc->reference = FALSE;
08816 exp_desc->tmp_reference = FALSE;
08817 }
08818
08819 exp_desc->type_idx = type_idx;
08820 exp_desc->type = TYP_TYPE(type_idx);
08821 exp_desc->linear_type = TYP_LINEAR(type_idx);
08822 }
08823
08824 TRACE (Func_Exit, "cast_to_cg_default", NULL);
08825
08826 return;
08827
08828 }
08829
08830
08831
08832
08833
08834
08835
08836
08837
08838
08839
08840
08841
08842
08843
08844
08845
08846
08847
08848 void cast_opnd_to_type_idx(opnd_type *opnd,
08849 int type_idx)
08850
08851 {
08852 int col;
08853 expr_arg_type exp_desc;
08854 int line;
08855
08856 TRACE (Func_Entry, "cast_opnd_to_type_idx", NULL);
08857
08858 exp_desc = init_exp_desc;
08859
08860 if (OPND_FLD((*opnd)) == CN_Tbl_Idx) {
08861 exp_desc.type_idx = CN_TYPE_IDX(OPND_IDX((*opnd)));
08862 }
08863 else if (OPND_FLD((*opnd)) == AT_Tbl_Idx) {
08864 exp_desc.type_idx = ATD_TYPE_IDX(OPND_IDX((*opnd)));
08865 }
08866 else if (OPND_FLD((*opnd)) == IR_Tbl_Idx) {
08867 exp_desc.type_idx = IR_TYPE_IDX(OPND_IDX((*opnd)));
08868 exp_desc.rank = IR_RANK(OPND_IDX((*opnd)));
08869 }
08870 else {
08871 # ifdef _DEBUG
08872 find_opnd_line_and_column(opnd, &line, &col);
08873 PRINTMSG(line, 626, Internal, col,
08874 "CN, AT, or IR_Tbl_Idx", "cast_opnd_to_type_idx");
08875 # endif
08876 }
08877
08878 exp_desc.linear_type = TYP_LINEAR(exp_desc.type_idx);
08879 exp_desc.type = TYP_TYPE(exp_desc.type_idx);
08880
08881 cast_to_type_idx(opnd, &exp_desc, type_idx);
08882
08883 TRACE (Func_Exit, "cast_opnd_to_type_idx", NULL);
08884
08885 return;
08886
08887 }
08888
08889
08890
08891
08892
08893
08894
08895
08896
08897
08898
08899
08900
08901
08902
08903
08904
08905
08906
08907 void cast_to_type_idx(opnd_type *opnd,
08908 expr_arg_type *exp_desc,
08909 int type_idx)
08910
08911 {
08912 char *char_ptr1;
08913 char *char_ptr2;
08914 int cn_idx;
08915 int col;
08916 int cvrt_idx;
08917 long_type folded_const[MAX_WORDS_FOR_NUMERIC];
08918 long64 i;
08919 int line;
08920
08921 TRACE (Func_Entry, "cast_to_type_idx", NULL);
08922
08923 if ((TYP_TYPE(type_idx) != Character &&
08924 TYP_LINEAR(type_idx) != exp_desc->linear_type) ||
08925 (TYP_TYPE(type_idx) == Character &&
08926 TYP_FLD(type_idx) == CN_Tbl_Idx &&
08927 TYP_FLD(exp_desc->type_idx) == CN_Tbl_Idx &&
08928 fold_relationals(TYP_IDX(type_idx),
08929 TYP_IDX(exp_desc->type_idx),
08930 Ne_Opr))) {
08931
08932 find_opnd_line_and_column(opnd, &line, &col);
08933
08934 if (exp_desc->linear_type == Short_Typeless_Const) {
08935 OPND_IDX((*opnd)) = cast_typeless_constant(OPND_IDX((*opnd)),
08936 type_idx,
08937 line,
08938 col);
08939
08940 }
08941 else if (OPND_FLD((*opnd)) == CN_Tbl_Idx) {
08942
08943 if (TYP_TYPE(type_idx) == Character) {
08944 cn_idx = ntr_const_tbl(type_idx, TRUE, NULL);
08945 char_ptr1 = (char *)&CN_CONST(OPND_IDX((*opnd)));
08946 char_ptr2 = (char *)&CN_CONST(cn_idx);
08947
08948 for (i = 0;
08949 i < CN_INT_TO_C(TYP_IDX(exp_desc->type_idx)) &&
08950 i < CN_INT_TO_C(TYP_IDX(type_idx));
08951 i++) {
08952 char_ptr2[i] = char_ptr1[i];
08953 }
08954
08955 for (; i < CN_INT_TO_C(TYP_IDX(type_idx)); i++) {
08956 char_ptr2[i] = ' ';
08957 }
08958
08959 while ((i % TARGET_CHARS_PER_WORD) != 0) {
08960 char_ptr2[i] = ' ';
08961 i++;
08962 }
08963
08964 OPND_IDX((*opnd)) = cn_idx;
08965
08966 if (compare_cn_and_value(TYP_IDX(type_idx),
08967 MAX_CHARS_IN_TYPELESS,
08968 Le_Opr)) {
08969 exp_desc->linear_type = Short_Char_Const;
08970 }
08971 else {
08972
08973 exp_desc->linear_type = Character_1;
08974 }
08975 }
08976 else {
08977 if (folder_driver((char *)&CN_CONST(OPND_IDX((*opnd))),
08978 exp_desc->type_idx,
08979 NULL,
08980 NULL_IDX,
08981 folded_const,
08982 &type_idx,
08983 line,
08984 col,
08985 1,
08986 Cvrt_Opr)) {
08987
08988 }
08989
08990 OPND_IDX((*opnd)) = ntr_const_tbl(type_idx,
08991 FALSE,
08992 folded_const);
08993 }
08994 }
08995 # if _DEBUG
08996 else if (TYP_TYPE(type_idx) == Character) {
08997 PRINTMSG(line, 626, Internal, col,
08998 "non character operand",
08999 "cast_to_type_idx");
09000 }
09001 # endif
09002 else {
09003
09004 NTR_IR_TBL(cvrt_idx);
09005 IR_OPR(cvrt_idx) = Cvrt_Opr;
09006 IR_RANK(cvrt_idx) = exp_desc->rank;
09007
09008 IR_TYPE_IDX(cvrt_idx) = type_idx;
09009 IR_LINE_NUM(cvrt_idx) = line;
09010 IR_COL_NUM(cvrt_idx) = col;
09011
09012 COPY_OPND(IR_OPND_L(cvrt_idx), (*opnd));
09013
09014 if (exp_desc->rank > 0) {
09015 IR_ARRAY_SYNTAX(cvrt_idx) = TRUE;
09016 }
09017
09018 OPND_FLD((*opnd)) = IR_Tbl_Idx;
09019 OPND_IDX((*opnd)) = cvrt_idx;
09020
09021 exp_desc->reference = FALSE;
09022 exp_desc->tmp_reference = FALSE;
09023 }
09024
09025 exp_desc->type_idx = type_idx;
09026 exp_desc->type = TYP_TYPE(type_idx);
09027 exp_desc->linear_type = TYP_LINEAR(type_idx);
09028
09029 if (exp_desc->type == Character) {
09030 OPND_FLD(exp_desc->char_len) = TYP_FLD(exp_desc->type_idx);
09031 OPND_IDX(exp_desc->char_len) = TYP_IDX(exp_desc->type_idx);
09032 }
09033 }
09034
09035 TRACE (Func_Exit, "cast_to_type_idx", NULL);
09036
09037 return;
09038
09039 }
09040
09041
09042
09043
09044
09045
09046
09047
09048
09049
09050
09051
09052
09053
09054
09055
09056
09057
09058 int set_up_logical_constant(long_type *the_constant,
09059 int type_idx,
09060 int value,
09061 boolean enter_con)
09062
09063 {
09064 int cn_idx;
09065
09066
09067 TRACE (Func_Entry, "set_up_logical_constant", NULL);
09068
09069
09070
09071 # if defined(_TARGET_OS_SOLARIS) || (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
09072 if (TYP_LINEAR(type_idx) == Logical_8) {
09073 # if defined(_HOST_LITTLE_ENDIAN) && defined(_TARGET_LITTLE_ENDIAN)
09074 *(long long *)the_constant = value;
09075 # else
09076 the_constant[0] = 0;
09077 the_constant[1] = value;
09078 # endif
09079 }
09080 else {
09081 the_constant[0] = value;
09082 }
09083 # else
09084 the_constant[0] = value;
09085 # endif
09086
09087 if (enter_con) {
09088 cn_idx = ntr_const_tbl(type_idx,
09089 FALSE,
09090 the_constant);
09091 }
09092 else {
09093 cn_idx = NULL_IDX;
09094 }
09095
09096 TRACE (Func_Exit, "set_up_logical_constant", NULL);
09097
09098 return(cn_idx);
09099
09100 }
09101
09102
09103
09104
09105
09106
09107
09108
09109
09110
09111
09112
09113
09114
09115
09116
09117
09118 boolean validate_char_len(opnd_type *result_opnd,
09119 expr_arg_type *exp_desc)
09120
09121 {
09122 int ch_asg_idx;
09123 int col;
09124 opnd_type length_opnd;
09125 int line;
09126 expr_arg_type loc_exp_desc;
09127 boolean ok = TRUE;
09128 cif_usage_code_type save_xref_state;
09129 int tmp_idx;
09130
09131 TRACE (Func_Entry, "validate_char_len", NULL);
09132
09133 if (exp_desc->type == Character &&
09134 (exp_desc->char_len.fld != TYP_FLD(exp_desc->type_idx) ||
09135 exp_desc->char_len.idx != TYP_IDX(exp_desc->type_idx) ||
09136 (OPND_FLD((*result_opnd)) == IR_Tbl_Idx &&
09137 IR_OPR(OPND_IDX((*result_opnd))) == Concat_Opr))) {
09138
09139 find_opnd_line_and_column(result_opnd, &line, &col);
09140
09141 # ifdef _DEBUG
09142 if (exp_desc->char_len.fld == NO_Tbl_Idx) {
09143 PRINTMSG(line, 1018, Internal, col);
09144 }
09145 # endif
09146
09147 loc_exp_desc.rank = 0;
09148
09149 if (OPND_FLD((*result_opnd)) == IR_Tbl_Idx &&
09150 IR_OPR(OPND_IDX((*result_opnd))) == Concat_Opr) {
09151
09152 get_concat_len(OPND_IDX((*result_opnd)), &length_opnd);
09153 }
09154 else {
09155 COPY_OPND(length_opnd, (exp_desc->char_len));
09156 }
09157
09158 save_xref_state = xref_state;
09159 xref_state = CIF_No_Usage_Rec;
09160 ok = expr_semantics(&length_opnd, &loc_exp_desc);
09161 xref_state = save_xref_state;
09162
09163 COPY_OPND((exp_desc->char_len), length_opnd);
09164
09165 if (loc_exp_desc.constant) {
09166 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
09167
09168 TYP_TYPE(TYP_WORK_IDX) = Character;
09169 TYP_LINEAR(TYP_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
09170 TYP_CHAR_CLASS(TYP_WORK_IDX) = Const_Len_Char;
09171 TYP_FLD(TYP_WORK_IDX) = CN_Tbl_Idx;
09172 TYP_IDX(TYP_WORK_IDX) = OPND_IDX(length_opnd);
09173 exp_desc->type_idx = ntr_type_tbl();
09174 exp_desc->type = Character;
09175 exp_desc->linear_type = CHARACTER_DEFAULT_TYPE;
09176 }
09177 else {
09178
09179 GEN_COMPILER_TMP_ASG(ch_asg_idx,
09180 tmp_idx,
09181 TRUE,
09182 line,
09183 col,
09184 loc_exp_desc.type_idx,
09185 Priv);
09186
09187 COPY_OPND(IR_OPND_R(ch_asg_idx), length_opnd);
09188
09189 gen_sh(Before, Assignment_Stmt, stmt_start_line,
09190 stmt_start_col, FALSE, FALSE, TRUE);
09191
09192 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ch_asg_idx;
09193 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
09194
09195 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
09196
09197 TYP_TYPE(TYP_WORK_IDX) = Character;
09198 TYP_LINEAR(TYP_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
09199 TYP_CHAR_CLASS(TYP_WORK_IDX) = Var_Len_Char;
09200 TYP_FLD(TYP_WORK_IDX) = AT_Tbl_Idx;
09201 TYP_IDX(TYP_WORK_IDX) = tmp_idx;
09202 TYP_ORIG_LEN_IDX(TYP_WORK_IDX) = tmp_idx;
09203 exp_desc->type_idx = ntr_type_tbl();
09204 exp_desc->type = Character;
09205 exp_desc->linear_type = CHARACTER_DEFAULT_TYPE;
09206 }
09207 }
09208
09209 if (OPND_FLD((*result_opnd)) == IR_Tbl_Idx &&
09210 (IR_OPR(OPND_IDX((*result_opnd))) == Substring_Opr ||
09211 IR_OPR(OPND_IDX((*result_opnd))) == Whole_Substring_Opr)) {
09212
09213 IR_TYPE_IDX(OPND_IDX((*result_opnd))) = exp_desc->type_idx;
09214 }
09215
09216
09217 TRACE (Func_Exit, "validate_char_len", NULL);
09218
09219 return(ok);
09220
09221 }
09222
09223
09224
09225
09226
09227
09228
09229
09230
09231
09232
09233
09234
09235
09236
09237
09238
09239 void gen_runtime_checks(opnd_type *top_opnd)
09240
09241 {
09242 int ir_idx;
09243 int list_idx;
09244 opnd_type opnd;
09245
09246 TRACE (Func_Entry, "gen_runtime_checks", NULL);
09247
09248 switch (OPND_FLD((*top_opnd))) {
09249 case IR_Tbl_Idx:
09250 ir_idx = OPND_IDX((*top_opnd));
09251
09252 if ((IR_OPR(ir_idx) == Subscript_Opr ||
09253 IR_OPR(ir_idx) == Section_Subscript_Opr) &&
09254 needs_bounds_check(ir_idx)) {
09255
09256 gen_runtime_bounds(ir_idx);
09257 }
09258 else if (cmd_line_flags.runtime_substring &&
09259 IR_OPR(ir_idx) == Substring_Opr &&
09260 ATD_CLASS(find_left_attr(&IR_OPND_L(ir_idx))) != Compiler_Tmp) {
09261 gen_runtime_substring(ir_idx);
09262 }
09263
09264 COPY_OPND(opnd, IR_OPND_L(ir_idx));
09265 gen_runtime_checks(&opnd);
09266
09267 COPY_OPND(opnd, IR_OPND_R(ir_idx));
09268 gen_runtime_checks(&opnd);
09269 break;
09270
09271 case IL_Tbl_Idx:
09272 list_idx = OPND_IDX((*top_opnd));
09273
09274 while (list_idx) {
09275 COPY_OPND(opnd, IL_OPND(list_idx));
09276 gen_runtime_checks(&opnd);
09277
09278 list_idx = IL_NEXT_LIST_IDX(list_idx);
09279 }
09280 break;
09281 }
09282
09283 TRACE (Func_Exit, "gen_runtime_checks", NULL);
09284
09285 return;
09286
09287 }
09288
09289
09290
09291
09292
09293
09294
09295
09296
09297
09298
09299
09300
09301
09302
09303
09304
09305 void gen_runtime_conformance(opnd_type *l_opnd,
09306 expr_arg_type *l_exp_desc,
09307 opnd_type *r_opnd,
09308 expr_arg_type *r_exp_desc)
09309
09310 {
09311 int col;
09312 int i;
09313 expr_arg_type left_exp_desc;
09314 int line;
09315 expr_arg_type right_exp_desc;
09316
09317 TRACE (Func_Entry, "gen_runtime_conformance", NULL);
09318
09319 left_exp_desc = *l_exp_desc;
09320 right_exp_desc = *r_exp_desc;
09321
09322 find_opnd_line_and_column(l_opnd, &line, &col);
09323
09324 # ifdef _DEBUG
09325 if (defer_stmt_expansion) {
09326 PRINTMSG(line, 626, Internal, col,
09327 "defer_stmt_expansion to be FALSE",
09328 "gen_runtime_conformance");
09329 }
09330 # endif
09331
09332 for (i = 0; i < left_exp_desc.rank; i++) {
09333 gen_conform_check_call(&(left_exp_desc.shape[i]),
09334 &(right_exp_desc.shape[i]),
09335 i + 1,
09336 line,
09337 col);
09338 }
09339
09340 TRACE (Func_Exit, "gen_runtime_conformance", NULL);
09341
09342 return;
09343
09344 }
09345
09346
09347
09348
09349
09350
09351
09352
09353
09354
09355
09356
09357
09358
09359
09360
09361
09362 void gen_runtime_substring(int substring_idx)
09363
09364 {
09365 int attr_idx;
09366 int list_idx;
09367 int line;
09368 int col;
09369 opnd_type size_opnd;
09370 opnd_type start_opnd;
09371 opnd_type subln_opnd;
09372
09373 TRACE (Func_Entry, "gen_runtime_substring", NULL);
09374
09375 attr_idx = find_base_attr(&IR_OPND_L(substring_idx), &line, &col);
09376
09377 # ifdef _DEBUG
09378 if (defer_stmt_expansion) {
09379 PRINTMSG(line, 626, Internal, col,
09380 "defer_stmt_expansion to be FALSE",
09381 "gen_runtime_substring");
09382 }
09383 # endif
09384
09385 list_idx = IR_IDX_R(substring_idx);
09386
09387 OPND_FLD(size_opnd) = TYP_FLD(ATD_TYPE_IDX(attr_idx));
09388 OPND_IDX(size_opnd) = TYP_IDX(ATD_TYPE_IDX(attr_idx));
09389 OPND_LINE_NUM(size_opnd) = line;
09390 OPND_COL_NUM(size_opnd) = col;
09391
09392 COPY_OPND(start_opnd, IL_OPND(list_idx));
09393 list_idx = IL_NEXT_LIST_IDX(list_idx);
09394 list_idx = IL_NEXT_LIST_IDX(list_idx);
09395
09396 # ifdef _DEBUG
09397 if (list_idx == NULL_IDX) {
09398 PRINTMSG(line, 626, Internal, col,
09399 "substring length",
09400 "gen_runtime_substring");
09401 }
09402 # endif
09403
09404 COPY_OPND(subln_opnd, IL_OPND(list_idx));
09405
09406 if (OPND_FLD(start_opnd) == CN_Tbl_Idx &&
09407 OPND_FLD(subln_opnd) == CN_Tbl_Idx &&
09408 OPND_FLD(size_opnd) == CN_Tbl_Idx) {
09409
09410 }
09411 else {
09412 gen_sbounds_check_call(AT_OBJ_NAME_PTR(attr_idx),
09413 &size_opnd,
09414 &start_opnd,
09415 &subln_opnd,
09416 line,
09417 col);
09418
09419 IR_BOUNDS_DONE(substring_idx) = TRUE;
09420 }
09421
09422
09423 TRACE (Func_Exit, "gen_runtime_substring", NULL);
09424
09425 return;
09426
09427 }
09428
09429
09430
09431
09432
09433
09434
09435
09436
09437
09438
09439
09440
09441
09442
09443
09444
09445 void gen_runtime_ptr_chk(opnd_type *dv_opnd)
09446
09447 {
09448 int attr_idx;
09449 int bd_idx;
09450 int col;
09451 int left_attr;
09452 int line;
09453
09454 TRACE (Func_Entry, "gen_runtime_ptr_chk", NULL);
09455
09456 attr_idx = find_base_attr(dv_opnd, &line, &col);
09457 left_attr = find_left_attr(dv_opnd);
09458
09459 bd_idx = ATD_ARRAY_IDX(attr_idx);
09460
09461 if (ATD_CLASS(left_attr) == Compiler_Tmp) {
09462 goto EXIT;
09463 }
09464
09465 if (ATD_POINTER(attr_idx)) {
09466 gen_ptr_chk_call(AT_OBJ_NAME_PTR(attr_idx),
09467 1,
09468 dv_opnd,
09469 line,
09470 col);
09471 }
09472 else if (ATD_ALLOCATABLE(attr_idx)) {
09473 gen_ptr_chk_call(AT_OBJ_NAME_PTR(attr_idx),
09474 2,
09475 dv_opnd,
09476 line,
09477 col);
09478 }
09479 else if (bd_idx &&
09480 BD_ARRAY_CLASS(bd_idx) == Assumed_Shape) {
09481 gen_ptr_chk_call(AT_OBJ_NAME_PTR(attr_idx),
09482 3,
09483 dv_opnd,
09484 line,
09485 col);
09486 }
09487
09488 EXIT:
09489
09490 TRACE (Func_Exit, "gen_runtime_ptr_chk", NULL);
09491
09492 return;
09493
09494 }
09495
09496
09497
09498
09499
09500
09501
09502
09503
09504
09505
09506
09507
09508
09509
09510
09511
09512 void gen_runtime_bounds(int sub_idx)
09513
09514 {
09515 int attr_idx;
09516 int bd_idx;
09517 int col;
09518 int dim;
09519 opnd_type end_opnd;
09520 opnd_type inc_opnd;
09521 int ir_idx2;
09522 opnd_type lb_opnd;
09523 int line;
09524 int list_idx;
09525 int list_idx2;
09526 int minus_idx;
09527 opnd_type opnd;
09528 opnd_type opnd2;
09529 int plus_idx;
09530 opnd_type start_opnd;
09531 opnd_type ub_opnd;
09532
09533 TRACE (Func_Entry, "gen_runtime_bounds", NULL);
09534
09535 attr_idx = find_base_attr(&IR_OPND_L(sub_idx), &line, &col);
09536
09537
09538 # ifdef _DEBUG
09539 if (defer_stmt_expansion) {
09540 PRINTMSG(line, 626, Internal, col,
09541 "defer_stmt_expansion to be FALSE",
09542 "gen_runtime_bounds");
09543 }
09544 # endif
09545
09546 bd_idx = ATD_ARRAY_IDX(attr_idx);
09547
09548 list_idx = IR_IDX_R(sub_idx);
09549 dim = 1;
09550
09551 while (list_idx != NULL_IDX) {
09552 if (BD_ARRAY_CLASS(bd_idx) == Assumed_Size &&
09553 dim == BD_RANK(bd_idx)) {
09554 break;
09555 }
09556
09557 if (IL_VECTOR_SUBSCRIPT(list_idx)) {
09558 list_idx = IL_NEXT_LIST_IDX(list_idx);
09559 dim++;
09560 continue;
09561 }
09562
09563 if (ATD_IM_A_DOPE(attr_idx)) {
09564 COPY_OPND(opnd, IR_OPND_L(sub_idx));
09565
09566 if (OPND_FLD(opnd) == IR_Tbl_Idx &&
09567 IR_OPR(OPND_IDX(opnd)) == Dv_Deref_Opr) {
09568
09569 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
09570 }
09571
09572 gen_dv_access_low_bound(&lb_opnd, &opnd, dim);
09573
09574 copy_subtree(&lb_opnd, &opnd2);
09575
09576 ir_idx2 = gen_ir(OPND_FLD(opnd), OPND_IDX(opnd),
09577 Dv_Access_Extent, SA_INTEGER_DEFAULT_TYPE,
09578 line, col,
09579 NO_Tbl_Idx, NULL_IDX);
09580 IR_DV_DIM(ir_idx2) = dim;
09581
09582 plus_idx = gen_ir(OPND_FLD(opnd2), OPND_IDX(opnd2),
09583 Plus_Opr, SA_INTEGER_DEFAULT_TYPE, line, col,
09584 IR_Tbl_Idx, ir_idx2);
09585
09586 minus_idx = gen_ir(IR_Tbl_Idx, plus_idx,
09587 Minus_Opr, SA_INTEGER_DEFAULT_TYPE, line, col,
09588 CN_Tbl_Idx, CN_INTEGER_ONE_IDX);
09589
09590 gen_opnd(&ub_opnd, minus_idx, IR_Tbl_Idx, line, col);
09591 }
09592 else {
09593 gen_opnd(&lb_opnd, BD_LB_IDX(bd_idx,dim),
09594 BD_LB_FLD(bd_idx, dim), line, col);
09595 gen_opnd(&ub_opnd, BD_UB_IDX(bd_idx,dim),
09596 BD_UB_FLD(bd_idx, dim), line, col);
09597 }
09598
09599 if (IL_FLD(list_idx) == IR_Tbl_Idx &&
09600 IR_OPR(IL_IDX(list_idx)) == Triplet_Opr) {
09601
09602 list_idx2 = IR_IDX_L(IL_IDX(list_idx));
09603 COPY_OPND(start_opnd, IL_OPND(list_idx2));
09604 copy_subtree(&start_opnd, &start_opnd);
09605
09606 list_idx2 = IL_NEXT_LIST_IDX(list_idx2);
09607 COPY_OPND(end_opnd, IL_OPND(list_idx2));
09608 copy_subtree(&end_opnd, &end_opnd);
09609
09610 list_idx2 = IL_NEXT_LIST_IDX(list_idx2);
09611 COPY_OPND(inc_opnd, IL_OPND(list_idx2));
09612 copy_subtree(&inc_opnd, &inc_opnd);
09613
09614 if (OPND_FLD(lb_opnd) != CN_Tbl_Idx ||
09615 OPND_FLD(ub_opnd) != CN_Tbl_Idx ||
09616 OPND_FLD(start_opnd) != CN_Tbl_Idx ||
09617 OPND_FLD(end_opnd) != CN_Tbl_Idx ||
09618 OPND_FLD(inc_opnd) != CN_Tbl_Idx) {
09619
09620 gen_rbounds_check_call(AT_OBJ_NAME_PTR(attr_idx),
09621 &lb_opnd,
09622 &ub_opnd,
09623 &start_opnd,
09624 &end_opnd,
09625 &inc_opnd,
09626 dim,
09627 line,
09628 col);
09629 IR_BOUNDS_DONE(sub_idx) = TRUE;
09630 }
09631 }
09632 # if 0
09633 else if (IL_VECTOR_SUBSCRIPT(list_idx)) {
09634
09635 }
09636 # endif
09637 else if (IL_FLD(list_idx) != CN_Tbl_Idx ||
09638 OPND_FLD(lb_opnd) != CN_Tbl_Idx ||
09639 OPND_FLD(ub_opnd) != CN_Tbl_Idx) {
09640
09641 COPY_OPND(start_opnd, IL_OPND(list_idx));
09642 copy_subtree(&start_opnd, &start_opnd);
09643
09644 gen_bounds_check_call(AT_OBJ_NAME_PTR(attr_idx),
09645 &lb_opnd,
09646 &ub_opnd,
09647 &start_opnd,
09648 dim,
09649 line,
09650 col);
09651
09652 IR_BOUNDS_DONE(sub_idx) = TRUE;
09653 }
09654
09655 list_idx = IL_NEXT_LIST_IDX(list_idx);
09656 dim++;
09657 }
09658
09659 TRACE (Func_Exit, "gen_runtime_bounds", NULL);
09660
09661 return;
09662
09663 }
09664
09665
09666
09667
09668
09669
09670
09671
09672
09673
09674
09675
09676
09677
09678
09679
09680
09681
09682
09683 static void gen_conform_check_call(opnd_type *l_shape, opnd_type *r_shape,
09684 int dim, int line, int col)
09685
09686 {
09687 int call_idx;
09688 opnd_type cond_opnd;
09689 int dim_idx;
09690 int end_sh_idx;
09691 expr_arg_type exp_desc;
09692 int ir_idx;
09693 int line_idx;
09694 int list_idx;
09695 int max_idx;
09696 int max_idx2;
09697 opnd_type opnd;
09698 int save_curr_stmt_sh_idx;
09699 expr_mode_type save_expr_mode;
09700 cif_usage_code_type save_xref_state;
09701 int start_sh_idx;
09702 int tmp_idx;
09703
09704
09705 TRACE (Func_Entry, "gen_conform_check_call", NULL);
09706
09707 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
09708
09709
09710
09711 start_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
09712 end_sh_idx = curr_stmt_sh_idx;
09713
09714
09715
09716 GEN_MAX_ZERO_IR(max_idx, (*l_shape), line, col);
09717
09718 GEN_MAX_ZERO_IR(max_idx2, (*r_shape), line, col);
09719
09720 ir_idx = gen_ir(IR_Tbl_Idx, max_idx,
09721 Ne_Opr, LOGICAL_DEFAULT_TYPE, line, col,
09722 IR_Tbl_Idx, max_idx2);
09723
09724 gen_opnd(&cond_opnd, ir_idx, IR_Tbl_Idx, line, col);
09725
09726 if (glb_tbl_idx[Conform_Attr_Idx] == NULL_IDX) {
09727 glb_tbl_idx[Conform_Attr_Idx] = create_lib_entry_attr(
09728 CONFORM_LIB_ENTRY,
09729 CONFORM_NAME_LEN,
09730 line,
09731 col);
09732 }
09733
09734 ADD_ATTR_TO_LOCAL_LIST(glb_tbl_idx[Conform_Attr_Idx]);
09735
09736
09737
09738 tmp_idx = gen_initialized_tmp(CN_INTEGER_ZERO_IDX, line, col);
09739
09740 line_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, line);
09741 dim_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, dim);
09742
09743 list_idx = gen_il(4, TRUE, line, col,
09744 CN_Tbl_Idx, put_file_name_in_cn(line),
09745 CN_Tbl_Idx, line_idx,
09746 CN_Tbl_Idx, dim_idx,
09747 AT_Tbl_Idx, tmp_idx);
09748
09749 call_idx = gen_ir(AT_Tbl_Idx, glb_tbl_idx[Conform_Attr_Idx],
09750 Call_Opr, TYPELESS_DEFAULT_TYPE, line, col,
09751 IL_Tbl_Idx, list_idx);
09752
09753 gen_sh(Before, Call_Stmt, line, col,
09754 FALSE, FALSE, TRUE);
09755 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
09756 SH_IR_IDX(curr_stmt_sh_idx) = call_idx;
09757 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
09758
09759 gen_opnd(&opnd, call_idx, IR_Tbl_Idx, line, col);
09760
09761 save_xref_state = xref_state;
09762 xref_state = CIF_No_Usage_Rec;
09763 save_expr_mode = expr_mode;
09764 expr_mode = Regular_Expr;
09765
09766 exp_desc = init_exp_desc;
09767 call_list_semantics(&opnd, &exp_desc, FALSE);
09768 xref_state = save_xref_state;
09769 expr_mode = save_expr_mode;
09770
09771 gen_if_stmt(&cond_opnd,
09772 SH_NEXT_IDX(start_sh_idx),
09773 SH_PREV_IDX(end_sh_idx),
09774 NULL_IDX,
09775 NULL_IDX,
09776 line,
09777 col);
09778
09779 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
09780
09781 TRACE (Func_Exit, "gen_conform_check_call", NULL);
09782
09783 return;
09784
09785 }
09786
09787
09788
09789
09790
09791
09792
09793
09794
09795
09796
09797
09798
09799
09800
09801
09802
09803
09804
09805 static void gen_bounds_check_call(char *var,
09806 opnd_type *lb_opnd,
09807 opnd_type *ub_opnd,
09808 opnd_type *subscript,
09809 int dim,
09810 int line,
09811 int col)
09812
09813 {
09814 int call_idx;
09815 opnd_type cond_opnd;
09816 int dim_idx;
09817 int end_sh_idx;
09818 expr_arg_type exp_desc;
09819 int gt_idx;
09820 int line_idx;
09821 int list_idx;
09822 int lt_idx;
09823 int or_idx;
09824 opnd_type opnd;
09825 int save_curr_stmt_sh_idx;
09826 expr_mode_type save_expr_mode;
09827 cif_usage_code_type save_xref_state;
09828 int start_sh_idx;
09829 int tmp_idx;
09830
09831
09832 TRACE (Func_Entry, "gen_bounds_check_call", NULL);
09833
09834 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
09835
09836
09837
09838 start_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
09839 end_sh_idx = curr_stmt_sh_idx;
09840
09841
09842
09843
09844
09845 lt_idx = gen_ir(OPND_FLD((*subscript)), OPND_IDX((*subscript)),
09846 Lt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
09847 OPND_FLD((*lb_opnd)), OPND_IDX((*lb_opnd)));
09848
09849
09850 gt_idx = gen_ir(OPND_FLD((*subscript)), OPND_IDX((*subscript)),
09851 Gt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
09852 OPND_FLD((*ub_opnd)), OPND_IDX((*ub_opnd)));
09853
09854 or_idx = gen_ir(IR_Tbl_Idx, lt_idx,
09855 Or_Opr, LOGICAL_DEFAULT_TYPE, line, col,
09856 IR_Tbl_Idx, gt_idx);
09857
09858
09859 gen_opnd(&cond_opnd, or_idx, IR_Tbl_Idx, line, col);
09860
09861 if (glb_tbl_idx[Bounds_Attr_Idx] == NULL_IDX) {
09862 glb_tbl_idx[Bounds_Attr_Idx] = create_lib_entry_attr(
09863 BOUNDS_LIB_ENTRY,
09864 BOUNDS_NAME_LEN,
09865 line,
09866 col);
09867 }
09868
09869 ADD_ATTR_TO_LOCAL_LIST(glb_tbl_idx[Bounds_Attr_Idx]);
09870
09871
09872
09873 tmp_idx = gen_initialized_tmp(CN_INTEGER_ZERO_IDX, line, col);
09874 line_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, line);
09875 dim_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, dim);
09876
09877 list_idx = gen_il(8, TRUE, line, col,
09878 CN_Tbl_Idx, put_file_name_in_cn(line),
09879 CN_Tbl_Idx, line_idx,
09880 CN_Tbl_Idx, put_c_str_in_cn(var),
09881 CN_Tbl_Idx, dim_idx,
09882 OPND_FLD((*lb_opnd)), OPND_IDX((*lb_opnd)),
09883 OPND_FLD((*ub_opnd)), OPND_IDX((*ub_opnd)),
09884 OPND_FLD((*subscript)), OPND_IDX((*subscript)),
09885 AT_Tbl_Idx, tmp_idx);
09886
09887 call_idx = gen_ir(AT_Tbl_Idx, glb_tbl_idx[Bounds_Attr_Idx],
09888 Call_Opr, TYPELESS_DEFAULT_TYPE, line, col,
09889 IL_Tbl_Idx, list_idx);
09890
09891 gen_sh(Before, Call_Stmt, line, col,
09892 FALSE, FALSE, TRUE);
09893 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
09894 SH_IR_IDX(curr_stmt_sh_idx) = call_idx;
09895 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
09896
09897 gen_opnd(&opnd, call_idx, IR_Tbl_Idx, line, col);
09898
09899 save_xref_state = xref_state;
09900 xref_state = CIF_No_Usage_Rec;
09901 save_expr_mode = expr_mode;
09902 expr_mode = Regular_Expr;
09903
09904 exp_desc = init_exp_desc;
09905 call_list_semantics(&opnd, &exp_desc, FALSE);
09906 xref_state = save_xref_state;
09907 expr_mode = save_expr_mode;
09908
09909 gen_if_stmt(&cond_opnd,
09910 SH_NEXT_IDX(start_sh_idx),
09911 SH_PREV_IDX(end_sh_idx),
09912 NULL_IDX,
09913 NULL_IDX,
09914 line,
09915 col);
09916
09917 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
09918
09919 TRACE (Func_Exit, "gen_bounds_check_call", NULL);
09920
09921 return;
09922
09923 }
09924
09925
09926
09927
09928
09929
09930
09931
09932
09933
09934
09935
09936
09937
09938
09939
09940
09941
09942
09943 static void gen_rbounds_check_call(char *var,
09944 opnd_type *lb_opnd,
09945 opnd_type *ub_opnd,
09946 opnd_type *start_opnd,
09947 opnd_type *end_opnd,
09948 opnd_type *inc_opnd,
09949 int dim,
09950 int line,
09951 int col)
09952
09953 {
09954 int call_idx;
09955 opnd_type cond_opnd;
09956 int dim_idx;
09957 int end_sh_idx;
09958 expr_arg_type exp_desc;
09959 int line_idx;
09960 int list_idx;
09961 opnd_type opnd;
09962 int save_curr_stmt_sh_idx;
09963 expr_mode_type save_expr_mode;
09964 cif_usage_code_type save_xref_state;
09965 int start_sh_idx;
09966 int tmp_idx;
09967
09968
09969 TRACE (Func_Entry, "gen_rbounds_check_call", NULL);
09970
09971 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
09972
09973
09974
09975 start_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
09976 end_sh_idx = curr_stmt_sh_idx;
09977
09978 gen_rbounds_condition(&cond_opnd,
09979 start_opnd,
09980 end_opnd,
09981 inc_opnd,
09982 lb_opnd,
09983 ub_opnd,
09984 line,
09985 col);
09986
09987 if (glb_tbl_idx[Rbounds_Attr_Idx] == NULL_IDX) {
09988 glb_tbl_idx[Rbounds_Attr_Idx] = create_lib_entry_attr(
09989 RBOUNDS_LIB_ENTRY,
09990 RBOUNDS_NAME_LEN,
09991 line,
09992 col);
09993 }
09994
09995 ADD_ATTR_TO_LOCAL_LIST(glb_tbl_idx[Rbounds_Attr_Idx]);
09996
09997
09998
09999 tmp_idx = gen_initialized_tmp(CN_INTEGER_ZERO_IDX, line, col);
10000 line_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, line);
10001 dim_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, dim);
10002 list_idx = gen_il(10, TRUE, line, col,
10003 CN_Tbl_Idx, put_file_name_in_cn(line),
10004 CN_Tbl_Idx, line_idx,
10005 CN_Tbl_Idx, put_c_str_in_cn(var),
10006 CN_Tbl_Idx, dim_idx,
10007 OPND_FLD((*lb_opnd)), OPND_IDX((*lb_opnd)),
10008 OPND_FLD((*ub_opnd)), OPND_IDX((*ub_opnd)),
10009 OPND_FLD((*start_opnd)), OPND_IDX((*start_opnd)),
10010 OPND_FLD((*end_opnd)), OPND_IDX((*end_opnd)),
10011 OPND_FLD((*inc_opnd)), OPND_IDX((*inc_opnd)),
10012 AT_Tbl_Idx, tmp_idx);
10013
10014 call_idx = gen_ir(AT_Tbl_Idx, glb_tbl_idx[Rbounds_Attr_Idx],
10015 Call_Opr, TYPELESS_DEFAULT_TYPE, line, col,
10016 IL_Tbl_Idx, list_idx);
10017
10018 gen_sh(Before, Call_Stmt, line, col,
10019 FALSE, FALSE, TRUE);
10020 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
10021 SH_IR_IDX(curr_stmt_sh_idx) = call_idx;
10022 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
10023
10024 gen_opnd(&opnd, call_idx, IR_Tbl_Idx, line, col);
10025
10026 save_xref_state = xref_state;
10027 xref_state = CIF_No_Usage_Rec;
10028 save_expr_mode = expr_mode;
10029 expr_mode = Regular_Expr;
10030
10031 exp_desc = init_exp_desc;
10032 call_list_semantics(&opnd, &exp_desc, FALSE);
10033 xref_state = save_xref_state;
10034 expr_mode = save_expr_mode;
10035
10036 gen_if_stmt(&cond_opnd,
10037 SH_NEXT_IDX(start_sh_idx),
10038 SH_PREV_IDX(end_sh_idx),
10039 NULL_IDX,
10040 NULL_IDX,
10041 line,
10042 col);
10043
10044 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
10045
10046 TRACE (Func_Exit, "gen_rbounds_check_call", NULL);
10047
10048 return;
10049
10050 }
10051
10052
10053
10054
10055
10056
10057
10058
10059
10060
10061
10062
10063
10064
10065
10066
10067
10068
10069
10070 static void gen_sbounds_check_call(char *var, opnd_type *size_opnd,
10071 opnd_type *start_opnd,
10072 opnd_type *subln_opnd, int line, int col)
10073
10074 {
10075 int call_idx;
10076 opnd_type cond_opnd;
10077 int end_sh_idx;
10078 expr_arg_type exp_desc;
10079 int ir_idx;
10080 int line_idx;
10081 int list_idx;
10082 int lt_idx;
10083 int minus_idx;
10084 int minus_idx2;
10085 opnd_type opnd;
10086 int plus_idx;
10087 int plus_idx2;
10088 int save_curr_stmt_sh_idx;
10089 expr_mode_type save_expr_mode;
10090 cif_usage_code_type save_xref_state;
10091 int start_sh_idx;
10092 int tmp_idx;
10093
10094
10095 TRACE (Func_Entry, "gen_sbounds_check_call", NULL);
10096
10097 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
10098
10099
10100
10101 start_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
10102 end_sh_idx = curr_stmt_sh_idx;
10103
10104
10105
10106
10107
10108
10109
10110
10111
10112
10113 plus_idx = gen_ir(CN_Tbl_Idx, CN_INTEGER_ONE_IDX,
10114 Plus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
10115 OPND_FLD((*size_opnd)), OPND_IDX((*size_opnd)));
10116
10117 plus_idx2 = gen_ir(OPND_FLD((*start_opnd)), OPND_IDX((*start_opnd)),
10118 Plus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
10119 OPND_FLD((*subln_opnd)), OPND_IDX((*subln_opnd)));
10120
10121 minus_idx = gen_ir(IR_Tbl_Idx, plus_idx,
10122 Minus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
10123 IR_Tbl_Idx, plus_idx2);
10124
10125 if (OPND_FLD((*start_opnd)) == CN_Tbl_Idx) {
10126 lt_idx = gen_ir(IR_Tbl_Idx, minus_idx,
10127 Lt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
10128 CN_Tbl_Idx, CN_INTEGER_ZERO_IDX);
10129 }
10130 else {
10131
10132 minus_idx2 = gen_ir(OPND_FLD((*start_opnd)), OPND_IDX((*start_opnd)),
10133 Minus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
10134 CN_Tbl_Idx, CN_INTEGER_ONE_IDX);
10135
10136 ir_idx = gen_ir(IR_Tbl_Idx, minus_idx2,
10137 Bor_Opr, TYPELESS_DEFAULT_TYPE, line, col,
10138 IR_Tbl_Idx, minus_idx);
10139
10140 lt_idx = gen_ir(IR_Tbl_Idx, ir_idx,
10141 Lt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
10142 CN_Tbl_Idx, CN_INTEGER_ZERO_IDX);
10143 }
10144
10145 gen_opnd(&cond_opnd, lt_idx, IR_Tbl_Idx, line, col);
10146
10147 if (glb_tbl_idx[Sbounds_Attr_Idx] == NULL_IDX) {
10148 glb_tbl_idx[Sbounds_Attr_Idx] = create_lib_entry_attr(
10149 SBOUNDS_LIB_ENTRY,
10150 SBOUNDS_NAME_LEN,
10151 line,
10152 col);
10153 }
10154
10155 ADD_ATTR_TO_LOCAL_LIST(glb_tbl_idx[Sbounds_Attr_Idx]);
10156
10157
10158
10159 tmp_idx = gen_initialized_tmp(CN_INTEGER_ZERO_IDX, line, col);
10160 line_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, line);
10161 list_idx = gen_il(7, TRUE, line, col,
10162 CN_Tbl_Idx, put_file_name_in_cn(line),
10163 CN_Tbl_Idx, line_idx,
10164 CN_Tbl_Idx, put_c_str_in_cn(var),
10165 OPND_FLD((*size_opnd)), OPND_IDX((*size_opnd)),
10166 OPND_FLD((*start_opnd)), OPND_IDX((*start_opnd)),
10167 OPND_FLD((*subln_opnd)), OPND_IDX((*subln_opnd)),
10168 AT_Tbl_Idx, tmp_idx);
10169
10170 call_idx = gen_ir(AT_Tbl_Idx, glb_tbl_idx[Sbounds_Attr_Idx],
10171 Call_Opr, TYPELESS_DEFAULT_TYPE, line, col,
10172 IL_Tbl_Idx, list_idx);
10173
10174 gen_sh(Before, Call_Stmt, line, col,
10175 FALSE, FALSE, TRUE);
10176 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
10177 SH_IR_IDX(curr_stmt_sh_idx) = call_idx;
10178 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
10179
10180 gen_opnd(&opnd, call_idx, IR_Tbl_Idx, line, col);
10181
10182 save_xref_state = xref_state;
10183 xref_state = CIF_No_Usage_Rec;
10184 save_expr_mode = expr_mode;
10185 expr_mode = Regular_Expr;
10186
10187 exp_desc = init_exp_desc;
10188 call_list_semantics(&opnd, &exp_desc, FALSE);
10189 xref_state = save_xref_state;
10190 expr_mode = save_expr_mode;
10191
10192 gen_if_stmt(&cond_opnd,
10193 SH_NEXT_IDX(start_sh_idx),
10194 SH_PREV_IDX(end_sh_idx),
10195 NULL_IDX,
10196 NULL_IDX,
10197 line,
10198 col);
10199
10200 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
10201
10202 TRACE (Func_Exit, "gen_sbounds_check_call", NULL);
10203
10204 return;
10205
10206 }
10207
10208
10209
10210
10211
10212
10213
10214
10215
10216
10217
10218
10219
10220
10221
10222
10223
10224
10225
10226 static void gen_ptr_chk_call(char *var,
10227 int dv_desc,
10228 opnd_type *dv_opnd,
10229 int line,
10230 int col)
10231
10232 {
10233 int call_idx;
10234 opnd_type cond_opnd;
10235 int dv_idx;
10236 int end_sh_idx;
10237 int eq_idx;
10238 expr_arg_type exp_desc;
10239 int ir_idx;
10240 int line_idx;
10241 int list_idx;
10242 opnd_type opnd;
10243 int save_curr_stmt_sh_idx;
10244 expr_mode_type save_expr_mode;
10245 cif_usage_code_type save_xref_state;
10246 int start_sh_idx;
10247 int tmp_idx;
10248
10249
10250 TRACE (Func_Entry, "gen_ptr_chk_call", NULL);
10251
10252 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
10253
10254
10255
10256 start_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
10257 end_sh_idx = curr_stmt_sh_idx;
10258
10259
10260
10261 ir_idx = gen_ir(OPND_FLD((*dv_opnd)), OPND_IDX((*dv_opnd)),
10262 Dv_Access_Assoc, CG_INTEGER_DEFAULT_TYPE, line, col,
10263 NO_Tbl_Idx, NULL_IDX);
10264
10265 eq_idx = gen_ir(IR_Tbl_Idx, ir_idx,
10266 Eq_Opr, LOGICAL_DEFAULT_TYPE, line, col,
10267 CN_Tbl_Idx, CN_INTEGER_ZERO_IDX);
10268
10269 gen_opnd(&cond_opnd, eq_idx, IR_Tbl_Idx, line, col);
10270
10271 if (glb_tbl_idx[Ptr_Chk_Attr_Idx] == NULL_IDX) {
10272 glb_tbl_idx[Ptr_Chk_Attr_Idx] = create_lib_entry_attr(
10273 PTR_CHK_LIB_ENTRY,
10274 PTR_CHK_NAME_LEN,
10275 line,
10276 col);
10277 }
10278
10279 ADD_ATTR_TO_LOCAL_LIST(glb_tbl_idx[Ptr_Chk_Attr_Idx]);
10280
10281
10282
10283 tmp_idx = gen_initialized_tmp(CN_INTEGER_ZERO_IDX, line, col);
10284 line_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, line);
10285 dv_idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, dv_desc);
10286
10287 list_idx = gen_il(5, TRUE, line, col,
10288 CN_Tbl_Idx, put_file_name_in_cn(line),
10289 CN_Tbl_Idx, line_idx,
10290 CN_Tbl_Idx, put_c_str_in_cn(var),
10291 CN_Tbl_Idx, dv_idx,
10292 AT_Tbl_Idx, tmp_idx);
10293
10294 call_idx = gen_ir(AT_Tbl_Idx, glb_tbl_idx[Ptr_Chk_Attr_Idx],
10295 Call_Opr, TYPELESS_DEFAULT_TYPE, line, col,
10296 IL_Tbl_Idx, list_idx);
10297
10298 gen_sh(Before, Call_Stmt, line, col,
10299 FALSE, FALSE, TRUE);
10300 curr_stmt_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
10301 SH_IR_IDX(curr_stmt_sh_idx) = call_idx;
10302 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
10303
10304 gen_opnd(&opnd, call_idx, IR_Tbl_Idx, line, col);
10305
10306 save_xref_state = xref_state;
10307 xref_state = CIF_No_Usage_Rec;
10308 save_expr_mode = expr_mode;
10309 expr_mode = Regular_Expr;
10310
10311 exp_desc = init_exp_desc;
10312 call_list_semantics(&opnd, &exp_desc, FALSE);
10313 xref_state = save_xref_state;
10314 expr_mode = save_expr_mode;
10315
10316 gen_if_stmt(&cond_opnd,
10317 SH_NEXT_IDX(start_sh_idx),
10318 SH_PREV_IDX(end_sh_idx),
10319 NULL_IDX,
10320 NULL_IDX,
10321 line,
10322 col);
10323
10324 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
10325
10326 TRACE (Func_Exit, "gen_ptr_chk_call", NULL);
10327
10328 return;
10329
10330 }
10331
10332
10333
10334
10335
10336
10337
10338
10339
10340
10341
10342
10343
10344
10345
10346
10347
10348
10349 int gen_initialized_tmp(int cn_idx,
10350 int line,
10351 int col)
10352
10353 {
10354 int asg_idx;
10355 int list_idx;
10356 int tmp_idx;
10357
10358 TRACE (Func_Entry, "gen_initialized_tmp", NULL);
10359
10360 tmp_idx = gen_compiler_tmp(line,col, Shared, TRUE);
10361 ATD_TYPE_IDX(tmp_idx) = CN_TYPE_IDX(cn_idx);
10362
10363 ATD_SAVED(tmp_idx) = TRUE;
10364 ATD_DATA_INIT(tmp_idx) = TRUE;
10365 ATD_STOR_BLK_IDX(tmp_idx) = SCP_SB_STATIC_INIT_IDX(curr_scp_idx);
10366 ATD_FLD(tmp_idx) = CN_Tbl_Idx;
10367 ATD_TMP_IDX(tmp_idx) = cn_idx;
10368 AT_SEMANTICS_DONE(tmp_idx) = TRUE;
10369
10370
10371 NTR_IR_TBL(asg_idx);
10372 IR_OPR(asg_idx) = Init_Opr;
10373 IR_TYPE_IDX(asg_idx) = TYPELESS_DEFAULT_TYPE;
10374 IR_LINE_NUM(asg_idx) = line;
10375 IR_COL_NUM(asg_idx) = col;
10376 IR_LINE_NUM_L(asg_idx) = line;
10377 IR_COL_NUM_L(asg_idx) = col;
10378 IR_FLD_L(asg_idx) = AT_Tbl_Idx;
10379 IR_IDX_L(asg_idx) = tmp_idx;
10380
10381 NTR_IR_LIST_TBL(list_idx);
10382 IR_FLD_R(asg_idx) = IL_Tbl_Idx;
10383 IR_IDX_R(asg_idx) = list_idx;
10384 IR_LIST_CNT_R(asg_idx) = 3;
10385
10386 IL_FLD(list_idx) = CN_Tbl_Idx;
10387 IL_IDX(list_idx) = cn_idx;
10388 IL_LINE_NUM(list_idx) = line;
10389 IL_COL_NUM(list_idx) = col;
10390
10391 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
10392 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
10393 list_idx = IL_NEXT_LIST_IDX(list_idx);
10394
10395 IL_FLD(list_idx) = CN_Tbl_Idx;
10396 IL_IDX(list_idx) = CN_INTEGER_ONE_IDX;
10397 IL_LINE_NUM(list_idx) = line;
10398 IL_COL_NUM(list_idx) = col;
10399
10400 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
10401 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
10402 list_idx = IL_NEXT_LIST_IDX(list_idx);
10403
10404 IL_FLD(list_idx) = CN_Tbl_Idx;
10405 IL_IDX(list_idx) = CN_INTEGER_ZERO_IDX;
10406 IL_LINE_NUM(list_idx) = line;
10407 IL_COL_NUM(list_idx) = col;
10408
10409 gen_sh(Before, Assignment_Stmt, line, col,
10410 FALSE, FALSE, TRUE);
10411 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = asg_idx;
10412 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
10413
10414 TRACE (Func_Exit, "gen_initialized_tmp", NULL);
10415
10416 return(tmp_idx);
10417
10418 }
10419
10420
10421
10422
10423
10424
10425
10426
10427
10428
10429
10430
10431
10432
10433
10434
10435
10436 static int put_file_name_in_cn(int line)
10437
10438 {
10439 int cn_idx;
10440 int idx;
10441 char name[MAX_FILE_NAME_SIZE];
10442
10443
10444 TRACE (Func_Entry, "put_file_name_in_cn", NULL);
10445
10446
10447
10448
10449
10450 strcpy(name, global_to_local_file(line));
10451
10452 for (idx = strlen(name) - 1; idx >= 0; idx--) {
10453 if (name[idx] == '/')
10454 break;
10455 }
10456
10457 idx++;
10458
10459 cn_idx = put_c_str_in_cn(&(name[idx]));
10460
10461 TRACE (Func_Exit, "put_file_name_in_cn", NULL);
10462
10463 return(cn_idx);
10464
10465 }
10466
10467
10468
10469
10470
10471
10472
10473
10474
10475
10476
10477
10478
10479
10480
10481
10482
10483 static int put_c_str_in_cn(char *ch_ptr)
10484
10485 {
10486 int cn_idx;
10487 int i;
10488 long length;
10489 long_type the_constant[(MAX_FILE_NAME_SIZE + TARGET_CHARS_PER_WORD - 1)/
10490 TARGET_CHARS_PER_WORD];
10491 int type_idx;
10492
10493 TRACE (Func_Entry, "put_c_str_in_cn", NULL);
10494
10495
10496
10497
10498
10499 for (i = 0; i < (MAX_FILE_NAME_SIZE + TARGET_CHARS_PER_WORD - 1)/
10500 TARGET_CHARS_PER_WORD; i++) {
10501 the_constant[i] = 0;
10502 }
10503
10504 length = (long) strlen(ch_ptr);
10505
10506
10507 length++;
10508
10509 strcpy((char *)the_constant, ch_ptr);
10510
10511 if (two_word_fcd) {
10512 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
10513 TYP_TYPE(TYP_WORK_IDX) = Typeless;
10514 TYP_BIT_LEN(TYP_WORK_IDX) = WORD_ALIGNED_BIT_LENGTH(length * CHAR_BIT);
10515 type_idx = ntr_type_tbl();
10516 }
10517 else {
10518 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
10519 TYP_TYPE(TYP_WORK_IDX) = Character;
10520 TYP_LINEAR(TYP_WORK_IDX) = CHARACTER_DEFAULT_TYPE;
10521 TYP_DESC(TYP_WORK_IDX) = Default_Typed;
10522 TYP_CHAR_CLASS(TYP_WORK_IDX)= Const_Len_Char;
10523 TYP_FLD(TYP_WORK_IDX) = CN_Tbl_Idx;
10524 TYP_IDX(TYP_WORK_IDX) = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, length);
10525 type_idx = ntr_type_tbl();
10526 }
10527
10528 cn_idx = ntr_const_tbl(type_idx,
10529 TRUE,
10530 the_constant);
10531
10532 TRACE (Func_Exit, "put_c_str_in_cn", NULL);
10533
10534 return(cn_idx);
10535
10536 }
10537
10538
10539
10540
10541
10542
10543
10544
10545
10546
10547
10548
10549
10550
10551
10552
10553
10554 void gen_internal_call_stmt(char *name,
10555 opnd_type *opnd,
10556 sh_position_type position)
10557
10558 {
10559
10560 int call_idx;
10561 int list_idx;
10562 int loc_idx;
10563 int lib_idx;
10564
10565 TRACE (Func_Entry, "gen_internal_call_stmt", NULL);
10566
10567 lib_idx = create_lib_entry_attr(name,
10568 strlen(name),
10569 stmt_start_line,
10570 stmt_start_col);
10571
10572 ADD_ATTR_TO_LOCAL_LIST(lib_idx);
10573
10574 NTR_IR_TBL(call_idx);
10575 IR_OPR(call_idx) = Call_Opr;
10576 IR_TYPE_IDX(call_idx) = CG_INTEGER_DEFAULT_TYPE;
10577 IR_LINE_NUM(call_idx) = stmt_start_line;
10578 IR_COL_NUM(call_idx) = stmt_start_col;
10579 IR_FLD_L(call_idx) = AT_Tbl_Idx;
10580 IR_IDX_L(call_idx) = lib_idx;
10581 IR_LINE_NUM_L(call_idx) = stmt_start_line;
10582 IR_COL_NUM_L(call_idx) = stmt_start_col;
10583
10584 NTR_IR_LIST_TBL(list_idx);
10585 IR_FLD_R(call_idx) = IL_Tbl_Idx;
10586 IR_IDX_R(call_idx) = list_idx;
10587 IR_LIST_CNT_R(call_idx) = 1;
10588
10589 NTR_IR_TBL(loc_idx);
10590
10591 if (OPND_FLD((*opnd)) == CN_Tbl_Idx) {
10592 IR_OPR(loc_idx) = Const_Tmp_Loc_Opr;
10593 IR_TYPE_IDX(loc_idx) = CN_TYPE_IDX(OPND_IDX((*opnd)));
10594 }
10595 else {
10596 IR_OPR(loc_idx) = Aloc_Opr;
10597 IR_TYPE_IDX(loc_idx) = CRI_Ptr_8;
10598 }
10599
10600 IR_LINE_NUM(loc_idx) = stmt_start_line;
10601 IR_COL_NUM(loc_idx) = stmt_start_col;
10602 IL_FLD(list_idx) = IR_Tbl_Idx;
10603 IL_IDX(list_idx) = loc_idx;
10604
10605 COPY_OPND(IR_OPND_L(loc_idx), (*opnd));
10606
10607 gen_sh(position, Call_Stmt, stmt_start_line,
10608 stmt_start_col, FALSE, FALSE, TRUE);
10609
10610 if (position == Before) {
10611 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = call_idx;
10612 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
10613 }
10614 else {
10615 SH_IR_IDX(curr_stmt_sh_idx) = call_idx;
10616 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
10617 }
10618
10619 TRACE (Func_Exit, "gen_internal_call_stmt", NULL);
10620
10621 return;
10622
10623 }
10624
10625
10626
10627
10628
10629
10630
10631
10632
10633
10634
10635
10636
10637
10638
10639
10640
10641 void gen_lb_array_ref(opnd_type *result_opnd,
10642 int attr_idx)
10643
10644 {
10645 int bd_idx;
10646 int i;
10647 int list_idx;
10648 int sub_idx;
10649
10650 TRACE (Func_Entry, "gen_lb_array_ref", NULL);
10651
10652 bd_idx = ATD_ARRAY_IDX(attr_idx);
10653
10654 NTR_IR_TBL(sub_idx);
10655 IR_OPR(sub_idx) = Subscript_Opr;
10656 IR_TYPE_IDX(sub_idx) = ATD_TYPE_IDX(attr_idx);
10657 IR_LINE_NUM(sub_idx) = stmt_start_line;
10658 IR_COL_NUM(sub_idx) = stmt_start_col;
10659 IR_FLD_L(sub_idx) = AT_Tbl_Idx;
10660 IR_IDX_L(sub_idx) = attr_idx;
10661 IR_LINE_NUM_L(sub_idx) = stmt_start_line;
10662 IR_COL_NUM_L(sub_idx) = stmt_start_col;
10663
10664 NTR_IR_LIST_TBL(list_idx);
10665 IR_FLD_R(sub_idx) = IL_Tbl_Idx;
10666 IR_LIST_CNT_R(sub_idx) = BD_RANK(bd_idx);
10667 IR_IDX_R(sub_idx) = list_idx;
10668
10669 IL_FLD(list_idx) = BD_LB_FLD(bd_idx, 1);
10670 IL_IDX(list_idx) = BD_LB_IDX(bd_idx, 1);
10671 IL_LINE_NUM(list_idx) = stmt_start_line;
10672 IL_COL_NUM(list_idx) = stmt_start_col;
10673
10674 for (i = 2; i <= BD_RANK(bd_idx); i++) {
10675 NTR_IR_LIST_TBL(IL_NEXT_LIST_IDX(list_idx));
10676 IL_PREV_LIST_IDX(IL_NEXT_LIST_IDX(list_idx)) = list_idx;
10677 list_idx = IL_NEXT_LIST_IDX(list_idx);
10678
10679 IL_FLD(list_idx) = BD_LB_FLD(bd_idx, i);
10680 IL_IDX(list_idx) = BD_LB_IDX(bd_idx, i);
10681 IL_LINE_NUM(list_idx) = stmt_start_line;
10682 IL_COL_NUM(list_idx) = stmt_start_col;
10683 }
10684
10685 OPND_FLD((*result_opnd)) = IR_Tbl_Idx;
10686 OPND_IDX((*result_opnd)) = sub_idx;
10687
10688 TRACE (Func_Exit, "gen_lb_array_ref", NULL);
10689
10690 return;
10691
10692 }
10693
10694
10695
10696
10697
10698
10699
10700
10701
10702
10703
10704
10705
10706
10707
10708
10709
10710 void set_up_exp_desc(opnd_type *top_opnd,
10711 expr_arg_type *exp_desc)
10712
10713 {
10714 int attr_idx;
10715 int col;
10716 int line;
10717
10718 TRACE (Func_Entry, "set_up_exp_desc", NULL);
10719
10720 (*exp_desc) = init_exp_desc;
10721
10722 find_opnd_line_and_column(top_opnd, &line, &col);
10723
10724 switch (OPND_FLD((*top_opnd))) {
10725 case AT_Tbl_Idx:
10726 attr_idx = OPND_IDX((*top_opnd));
10727
10728 if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
10729 exp_desc->type_idx = ATD_TYPE_IDX(attr_idx);
10730 exp_desc->type = TYP_TYPE(exp_desc->type_idx);
10731 exp_desc->linear_type = TYP_LINEAR(exp_desc->type_idx);
10732 }
10733 # ifdef _DEBUG
10734 else {
10735 PRINTMSG(line, 626, Internal, col,
10736 "Data_Obj", "set_up_exp_desc");
10737 }
10738 # endif
10739 break;
10740
10741 case IR_Tbl_Idx:
10742 exp_desc->type_idx = IR_TYPE_IDX(OPND_IDX((*top_opnd)));
10743 exp_desc->type = TYP_TYPE(exp_desc->type_idx);
10744 exp_desc->linear_type = TYP_LINEAR(exp_desc->type_idx);
10745 exp_desc->rank = IR_RANK(OPND_IDX((*top_opnd)));
10746 break;
10747
10748 case CN_Tbl_Idx:
10749 exp_desc->type_idx = CN_TYPE_IDX(OPND_IDX((*top_opnd)));
10750 exp_desc->type = TYP_TYPE(exp_desc->type_idx);
10751 exp_desc->linear_type = TYP_LINEAR(exp_desc->type_idx);
10752 break;
10753
10754 default:
10755 # ifdef _DEBUG
10756 PRINTMSG(line, 626, Internal, col,
10757 "AT_Tbl_Idx, IR_Tbl_Idx, or CN_Tbl_Idx",
10758 "set_up_exp_desc");
10759 # endif
10760 break;
10761 }
10762
10763 TRACE (Func_Exit, "set_up_exp_desc", NULL);
10764
10765 return;
10766
10767 }
10768
10769
10770
10771
10772
10773
10774
10775
10776
10777
10778
10779
10780
10781
10782
10783
10784
10785
10786 void dim_reshape_pass_driver (void)
10787
10788 {
10789 int al_idx;
10790 int attr_idx;
10791 opnd_type opnd;
10792 int save_curr_stmt_sh_idx;
10793
10794
10795 TRACE (Func_Entry, "dim_reshape_pass_driver", NULL);
10796
10797 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
10798
10799
10800
10801 al_idx = SCP_RESHAPE_ARRAY_LIST(curr_scp_idx);
10802
10803 while (al_idx) {
10804 attr_idx = AL_ATTR_IDX(al_idx);
10805
10806 # ifdef _DEBUG
10807 if (AT_OBJ_CLASS(attr_idx) != Data_Obj ||
10808 ! ATD_RESHAPE_ARRAY_OPT(attr_idx)) {
10809
10810 PRINTMSG(1, 626, Internal, 1,
10811 "ATD_RESHAPE_ARRAY_OPT flag", "dim_reshape_pass_driver");
10812 }
10813
10814 if (ATD_ARRAY_IDX(attr_idx) == NULL_IDX ||
10815 ATD_RESHAPE_ARRAY_IDX(attr_idx) == NULL_IDX) {
10816 PRINTMSG(1, 626, Internal, 1,
10817 "ATD_RESHAPE_ARRAY_IDX", "dim_reshape_pass_driver");
10818 }
10819 # endif
10820
10821 ATD_ARRAY_IDX(attr_idx) = ATD_RESHAPE_ARRAY_IDX(attr_idx);
10822 al_idx = AL_NEXT_IDX(al_idx);
10823 }
10824
10825
10826
10827 curr_stmt_sh_idx = SCP_FIRST_SH_IDX(curr_scp_idx);
10828
10829 while (curr_stmt_sh_idx != NULL_IDX) {
10830
10831 if (SH_IR_IDX(curr_stmt_sh_idx) != NULL_IDX) {
10832 OPND_FLD(opnd) = IR_Tbl_Idx;
10833 OPND_IDX(opnd) = SH_IR_IDX(curr_stmt_sh_idx);
10834
10835 reshape_reference_subscripts(&opnd);
10836
10837 SH_IR_IDX(curr_stmt_sh_idx) = OPND_IDX(opnd);
10838 }
10839
10840 curr_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
10841 }
10842
10843 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
10844
10845 PRINT_IR_TBL4;
10846
10847 TRACE (Func_Exit, "dim_reshape_pass_driver", NULL);
10848
10849 return;
10850
10851 }
10852
10853
10854
10855
10856
10857
10858
10859
10860
10861
10862
10863
10864
10865
10866
10867
10868
10869 static void reshape_reference_subscripts(opnd_type *result_opnd)
10870
10871 {
10872 int attr_idx;
10873 int col;
10874 int ir_idx;
10875 int line;
10876 int head;
10877 int list_idx;
10878 opnd_type opnd;
10879
10880
10881 TRACE (Func_Entry, "reshape_reference_subscripts", NULL);
10882
10883 switch (OPND_FLD((*result_opnd))) {
10884 case IR_Tbl_Idx:
10885 ir_idx = OPND_IDX((*result_opnd));
10886
10887 COPY_OPND(opnd, IR_OPND_L(ir_idx));
10888 reshape_reference_subscripts(&opnd);
10889 COPY_OPND(IR_OPND_L(ir_idx), opnd);
10890
10891 COPY_OPND(opnd, IR_OPND_R(ir_idx));
10892 reshape_reference_subscripts(&opnd);
10893 COPY_OPND(IR_OPND_R(ir_idx), opnd);
10894
10895 if (IR_OPR(ir_idx) == Subscript_Opr ||
10896 IR_OPR(ir_idx) == Whole_Subscript_Opr ||
10897 IR_OPR(ir_idx) == Section_Subscript_Opr) {
10898
10899 COPY_OPND(opnd, IR_OPND_L(ir_idx));
10900 attr_idx = find_base_attr(&opnd, &line, &col);
10901
10902 if (ATD_RESHAPE_ARRAY_OPT(attr_idx)) {
10903 gen_opnd(&opnd, ir_idx, IR_Tbl_Idx, IR_LINE_NUM(ir_idx),
10904 IR_COL_NUM(ir_idx));
10905 copy_subtree(&opnd, result_opnd);
10906 ir_idx = OPND_IDX((*result_opnd));
10907
10908 list_idx = IR_IDX_R(ir_idx);
10909 head = list_idx;
10910
10911 while (IL_NEXT_LIST_IDX(list_idx) != NULL_IDX) {
10912 list_idx = IL_NEXT_LIST_IDX(list_idx);
10913 }
10914 IR_IDX_R(ir_idx) = list_idx;
10915 IL_NEXT_LIST_IDX(IL_PREV_LIST_IDX(list_idx)) = NULL_IDX;
10916 IL_PREV_LIST_IDX(list_idx) = NULL_IDX;
10917 IL_NEXT_LIST_IDX(list_idx) = head;
10918 IL_PREV_LIST_IDX(head) = list_idx;
10919 }
10920 }
10921 break;
10922
10923 case IL_Tbl_Idx:
10924 list_idx = OPND_IDX((*result_opnd));
10925
10926 while (list_idx) {
10927 COPY_OPND(opnd, IL_OPND(list_idx));
10928 reshape_reference_subscripts(&opnd);
10929 COPY_OPND(IL_OPND(list_idx), opnd);
10930
10931 list_idx = IL_NEXT_LIST_IDX(list_idx);
10932 }
10933 break;
10934 }
10935
10936 TRACE (Func_Exit, "reshape_reference_subscripts", NULL);
10937
10938 return;
10939
10940 }
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950
10951
10952
10953
10954
10955
10956
10957
10958 boolean check_for_legal_define(opnd_type *top_opnd)
10959 #ifdef KEY
10960 {
10961 return check_for_legal_assignment_define(top_opnd, FALSE);
10962 }
10963
10964
10965
10966
10967
10968
10969 boolean check_for_legal_assignment_define(opnd_type *top_opnd,
10970 boolean pointer_assign)
10971 #endif
10972 {
10973 int attr_idx;
10974 int col;
10975 int line;
10976 boolean ok = TRUE;
10977 opnd_type opnd;
10978
10979 TRACE (Func_Entry, "check_for_legal_define", NULL);
10980
10981 COPY_OPND(opnd, (*top_opnd));
10982
10983 while (OPND_FLD(opnd) == IR_Tbl_Idx) {
10984 COPY_OPND(opnd, IR_OPND_L(OPND_IDX(opnd)));
10985 }
10986
10987 if (OPND_FLD(opnd) == AT_Tbl_Idx &&
10988 AT_OBJ_CLASS(OPND_IDX(opnd)) == Data_Obj) {
10989
10990 attr_idx = OPND_IDX(opnd);
10991 line = OPND_LINE_NUM(opnd);
10992 col = OPND_COL_NUM(opnd);
10993
10994 if (ATD_LIVE_DO_VAR(attr_idx)) {
10995 PRINTMSG(line, 48, Error, col);
10996 ok = FALSE;
10997 }
10998 else if (ATD_PURE(attr_idx)) {
10999 PRINTMSG(line, 1270, Error, col,
11000 AT_OBJ_NAME_PTR(attr_idx),
11001 ATP_PURE(SCP_ATTR_IDX(curr_scp_idx)) ? "pure":"elemental");
11002 ok = FALSE;
11003 }
11004 else if (ATD_CLASS(attr_idx) == Dummy_Argument &&
11005 #ifdef KEY
11006
11007 ((!ATD_POINTER(attr_idx)) || pointer_assign) &&
11008 #endif
11009 ATD_INTENT(attr_idx) == Intent_In) {
11010 PRINTMSG(line, 890, Error, col,
11011 AT_OBJ_NAME_PTR(attr_idx));
11012 ok = FALSE;
11013 }
11014 else if (ATD_FORALL_INDEX(attr_idx)) {
11015 PRINTMSG(line, 1608, Error, col,
11016 AT_OBJ_NAME_PTR(attr_idx));
11017 ok = FALSE;
11018 }
11019 else if (ATD_SYMBOLIC_CONSTANT(attr_idx) &&
11020 (ATD_CLASS(attr_idx) == Variable ||
11021 ATD_CLASS(attr_idx) == Constant)) {
11022 PRINTMSG(line, 1632, Error, col,
11023 AT_OBJ_NAME_PTR(attr_idx));
11024 ok = FALSE;
11025 }
11026 }
11027
11028
11029 TRACE (Func_Exit, "check_for_legal_define", NULL);
11030
11031 return(ok);
11032
11033 }
11034
11035
11036
11037
11038
11039
11040
11041
11042
11043
11044
11045
11046
11047
11048
11049
11050
11051
11052
11053 void check_dependence(boolean *dependant,
11054 opnd_type item,
11055 opnd_type exp)
11056
11057 {
11058 int attr_idx;
11059 int idx;
11060 int fld;
11061 int line;
11062 int col;
11063
11064 static int level;
11065 static boolean target_found;
11066 static boolean pointer_found;
11067 static boolean pointer_item;
11068 static boolean target_item;
11069
11070 TRACE (Func_Entry, "check_dependence", NULL);
11071 level = level + 1;
11072
11073
11074 attr_idx = find_base_attr(&item, &line, &col);
11075 if (ATD_POINTER(attr_idx)) pointer_item = TRUE;
11076 if (ATD_TARGET(attr_idx)) target_item = TRUE;
11077 if (ATD_CLASS(attr_idx) == CRI__Pointee) *dependant = TRUE;
11078
11079 attr_idx = find_left_attr(&item);
11080 if (ATD_EQUIV(attr_idx)) *dependant = TRUE;
11081
11082 idx = OPND_IDX(exp);
11083 fld = OPND_FLD(exp);
11084
11085 if (idx != NULL_IDX) {
11086
11087 switch(fld) {
11088 case IR_Tbl_Idx :
11089 if (IR_FLD_R(idx) != NO_Tbl_Idx) {
11090 check_dependence(dependant, item, IR_OPND_R(idx));
11091 }
11092
11093 if (IR_FLD_L(idx) != NO_Tbl_Idx) {
11094 check_dependence(dependant, item, IR_OPND_L(idx));
11095 }
11096 break;
11097
11098 case AT_Tbl_Idx :
11099 if (AT_OBJ_CLASS(idx) == Data_Obj) {
11100 if (ATD_TARGET(idx)) target_found = TRUE;
11101 if (ATD_POINTER(idx)) pointer_found = TRUE;
11102 if (idx == attr_idx) *dependant = TRUE;
11103 }
11104 break;
11105
11106 case NO_Tbl_Idx :
11107 case CN_Tbl_Idx :
11108 case SH_Tbl_Idx :
11109 break;
11110
11111 case IL_Tbl_Idx :
11112 while (idx != NULL_IDX) {
11113 if (IL_FLD(idx) != NO_Tbl_Idx) {
11114 check_dependence(dependant, item, IL_OPND(idx));
11115 }
11116 idx = IL_NEXT_LIST_IDX(idx);
11117 }
11118 break;
11119 }
11120 }
11121
11122
11123 level = level - 1;
11124 if (level == 0) {
11125 if (target_found && pointer_item) *dependant = TRUE;
11126 if (pointer_found && pointer_item) *dependant = TRUE;
11127 if (pointer_found && target_item) *dependant = TRUE;
11128 target_found = FALSE;
11129 pointer_found = FALSE;
11130 pointer_item = FALSE;
11131 target_item = FALSE;
11132 }
11133
11134 TRACE (Func_Exit, "check_dependence", NULL);
11135
11136 }
11137
11138
11139
11140
11141
11142
11143
11144
11145
11146
11147
11148
11149
11150
11151
11152
11153
11154
11155
11156
11157 void change_section_to_this_element(opnd_type *section_opnd,
11158 opnd_type *element_opnd,
11159 int which_one)
11160
11161 {
11162 int col;
11163 expr_arg_type exp_desc;
11164 int line;
11165 int list_idx;
11166 int mult_idx;
11167 opnd_type opnd1;
11168 opnd_type opnd2;
11169 int plus_idx;
11170 int rank_idx = NULL_IDX;
11171 cif_usage_code_type save_xref_state;
11172 int start_list_idx;
11173 int stride_list_idx;
11174 int trip_idx;
11175 int unused = NULL_IDX;
11176
11177 TRACE (Func_Entry, "change_section_to_this_element", NULL);
11178
11179 find_opnd_line_and_column(section_opnd, &line, &col);
11180
11181 # ifdef _DEBUG
11182 if (OPND_FLD((*section_opnd)) != IR_Tbl_Idx ||
11183 IR_RANK(OPND_IDX((*section_opnd))) != 1) {
11184 PRINTMSG(line, 626, Internal, col,
11185 "rank 1 array", "change_section_to_this_element");
11186 }
11187 # endif
11188
11189 copy_subtree(section_opnd, element_opnd);
11190
11191 just_find_dope_and_rank(element_opnd, &rank_idx, &unused);
11192
11193 # ifdef _DEBUG
11194 if (rank_idx == NULL_IDX) {
11195 PRINTMSG(line, 626, Internal, col,
11196 "section subscript", "change_section_to_this_element");
11197 }
11198 # endif
11199
11200 IR_OPR(rank_idx) = Subscript_Opr;
11201
11202 list_idx = IR_IDX_R(rank_idx);
11203
11204 while (list_idx) {
11205 if (IL_VECTOR_SUBSCRIPT(list_idx)) {
11206 COPY_OPND(opnd1, IL_OPND(list_idx));
11207 change_section_to_this_element(&opnd1, &opnd2, which_one);
11208 COPY_OPND(IL_OPND(list_idx), opnd2);
11209 break;
11210 }
11211 else if (IL_FLD(list_idx) == IR_Tbl_Idx &&
11212 IR_OPR(IL_IDX(list_idx)) == Triplet_Opr) {
11213
11214 trip_idx = IL_IDX(list_idx);
11215 start_list_idx = IR_IDX_L(trip_idx);
11216 stride_list_idx = IL_NEXT_LIST_IDX(IL_NEXT_LIST_IDX(start_list_idx));
11217 line = IR_LINE_NUM(trip_idx);
11218 col = IR_COL_NUM(trip_idx);
11219
11220
11221 mult_idx = gen_ir(CN_Tbl_Idx, C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE,
11222 (which_one - 1)),
11223 Mult_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
11224 IL_FLD(stride_list_idx), IL_IDX(stride_list_idx));
11225
11226 plus_idx = gen_ir(IL_FLD(start_list_idx), IL_IDX(start_list_idx),
11227 Plus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
11228 IR_Tbl_Idx, mult_idx);
11229
11230 gen_opnd(&opnd1, plus_idx, IR_Tbl_Idx, line, col);
11231
11232 exp_desc = init_exp_desc;
11233 exp_desc.rank = 0;
11234 save_xref_state = xref_state;
11235 xref_state = CIF_No_Usage_Rec;
11236 expr_semantics(&opnd1, &exp_desc);
11237 xref_state = save_xref_state;
11238
11239 COPY_OPND(IL_OPND(list_idx), opnd1);
11240
11241 break;
11242 }
11243
11244 list_idx = IL_NEXT_LIST_IDX(list_idx);
11245 }
11246
11247 COPY_OPND(opnd1, (*element_opnd));
11248
11249 while (OPND_FLD(opnd1) == IR_Tbl_Idx) {
11250 IR_RANK(OPND_IDX(opnd1)) = 0;
11251 COPY_OPND(opnd1, IR_OPND_L(OPND_IDX(opnd1)));
11252 }
11253
11254
11255 TRACE (Func_Exit, "change_section_to_this_element", NULL);
11256
11257 return;
11258
11259 }
11260
11261
11262
11263
11264
11265
11266
11267
11268
11269
11270
11271
11272
11273
11274
11275
11276
11277 void gen_if_stmt(opnd_type *cond_opnd,
11278 int true_start_sh_idx,
11279 int true_end_sh_idx,
11280 int false_start_sh_idx,
11281 int false_end_sh_idx,
11282 int line,
11283 int col)
11284
11285 {
11286 int else_idx;
11287 int endif_idx;
11288 int if_idx;
11289 int save_curr_stmt_sh_idx;
11290 #ifdef KEY
11291 int type_idx = 0;
11292 #else
11293 int type_idx;
11294 #endif
11295
11296 # if defined(_HIGH_LEVEL_IF_FORM)
11297 int if_sh_idx;
11298 int parent_sh_idx;
11299 # else
11300 int label1_idx;
11301 int label2_idx;
11302 # endif
11303
11304
11305 TRACE (Func_Entry, "gen_if_stmt", NULL);
11306
11307 # ifdef _DEBUG
11308 if (SH_PREV_IDX(true_start_sh_idx) == true_end_sh_idx) {
11309 PRINTMSG(line, 626, Internal, col,
11310 "proper true block", "gen_if_stmt");
11311 }
11312
11313 if (false_start_sh_idx &&
11314 SH_PREV_IDX(false_start_sh_idx) != true_end_sh_idx) {
11315 PRINTMSG(line, 626, Internal, col,
11316 "proper false block", "gen_if_stmt");
11317 }
11318
11319 if (false_start_sh_idx &&
11320 SH_PREV_IDX(false_start_sh_idx) == false_end_sh_idx) {
11321 PRINTMSG(line, 626, Internal, col,
11322 "proper false block", "gen_if_stmt");
11323 }
11324 # endif
11325
11326 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
11327
11328 switch (OPND_FLD((*cond_opnd))) {
11329 case AT_Tbl_Idx:
11330 type_idx = ATD_TYPE_IDX(OPND_IDX((*cond_opnd)));
11331 break;
11332
11333 case IR_Tbl_Idx:
11334 type_idx = IR_TYPE_IDX(OPND_IDX((*cond_opnd)));
11335 break;
11336
11337 case CN_Tbl_Idx:
11338 type_idx = CN_TYPE_IDX(OPND_IDX((*cond_opnd)));
11339 break;
11340
11341 default:
11342 # ifdef _DEBUG
11343 PRINTMSG(line, 626, Internal, col,
11344 "valid logical condition", "gen_if_stmt");
11345 # endif
11346 break;
11347 }
11348
11349 curr_stmt_sh_idx = true_start_sh_idx;
11350
11351 # if defined(_HIGH_LEVEL_IF_FORM)
11352
11353 if_idx = gen_ir(OPND_FLD((*cond_opnd)), OPND_IDX((*cond_opnd)),
11354 If_Opr, type_idx, line, col,
11355 NO_Tbl_Idx, NULL_IDX);
11356
11357 gen_sh(Before, If_Stmt, line, col, FALSE, FALSE, TRUE);
11358 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
11359 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = if_idx;
11360
11361 if_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
11362
11363 curr_stmt_sh_idx = true_end_sh_idx;
11364
11365 parent_sh_idx = if_sh_idx;
11366
11367 if (false_start_sh_idx) {
11368
11369 curr_stmt_sh_idx = false_start_sh_idx;
11370
11371 else_idx = gen_ir(OPND_FLD((*cond_opnd)), OPND_IDX((*cond_opnd)),
11372 Else_Opr, type_idx, line, col,
11373 NO_Tbl_Idx, NULL_IDX);
11374
11375 gen_sh(Before, Else_Stmt, line, col, FALSE, FALSE, TRUE);
11376 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
11377 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = else_idx;
11378 parent_sh_idx = SH_PREV_IDX(curr_stmt_sh_idx);
11379
11380 curr_stmt_sh_idx = false_end_sh_idx;
11381
11382 }
11383
11384 endif_idx = gen_ir(SH_Tbl_Idx, if_sh_idx,
11385 Endif_Opr, TYPELESS_DEFAULT_TYPE, line, col,
11386 NO_Tbl_Idx, NULL_IDX);
11387
11388 gen_sh(After, End_If_Stmt, line, col, FALSE, FALSE, TRUE);
11389 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
11390 SH_IR_IDX(curr_stmt_sh_idx) = endif_idx;
11391 SH_PARENT_BLK_IDX(curr_stmt_sh_idx) = parent_sh_idx;
11392
11393 IR_FLD_R(if_idx) = SH_Tbl_Idx;
11394 IR_IDX_R(if_idx) = curr_stmt_sh_idx;
11395 IR_LINE_NUM_R(if_idx) = line;
11396 IR_COL_NUM_R(if_idx) = col;
11397
11398 # else
11399
11400 label1_idx = gen_internal_lbl(line);
11401
11402 if_idx = gen_ir(IR_Tbl_Idx,
11403 gen_ir(OPND_FLD((*cond_opnd)),OPND_IDX((*cond_opnd)),
11404 Not_Opr, type_idx, line, col,
11405 NO_Tbl_Idx, NULL_IDX),
11406 Br_True_Opr, type_idx, line, col,
11407 AT_Tbl_Idx, label1_idx);
11408
11409 gen_sh(Before, If_Stmt, line, col, FALSE, FALSE, TRUE);
11410 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = if_idx;
11411 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
11412
11413 curr_stmt_sh_idx = true_end_sh_idx;
11414
11415 endif_idx = gen_ir(AT_Tbl_Idx, label1_idx,
11416 Label_Opr, TYPELESS_DEFAULT_TYPE, line, col,
11417 NO_Tbl_Idx, NULL_IDX);
11418
11419 gen_sh(After, Continue_Stmt, line, col, FALSE, FALSE, TRUE);
11420 SH_IR_IDX(curr_stmt_sh_idx) = endif_idx;
11421 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
11422
11423 AT_DEFINED(label1_idx) = TRUE;
11424 ATL_DEF_STMT_IDX(label1_idx) = curr_stmt_sh_idx;
11425
11426 if (false_start_sh_idx) {
11427 curr_stmt_sh_idx = true_end_sh_idx;
11428
11429 label2_idx = gen_internal_lbl(line);
11430
11431 else_idx = gen_ir(NO_Tbl_Idx, NULL_IDX,
11432 Br_Uncond_Opr, type_idx, line, col,
11433 AT_Tbl_Idx, label2_idx);
11434
11435 gen_sh(After, Goto_Stmt, line, col, FALSE, FALSE, TRUE);
11436 SH_IR_IDX(curr_stmt_sh_idx) = else_idx;
11437 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
11438
11439 curr_stmt_sh_idx = false_end_sh_idx;
11440
11441 endif_idx = gen_ir(AT_Tbl_Idx, label2_idx,
11442 Label_Opr, TYPELESS_DEFAULT_TYPE, line, col,
11443 NO_Tbl_Idx, NULL_IDX);
11444
11445 gen_sh(After, Continue_Stmt, line, col, FALSE, FALSE, TRUE);
11446 SH_IR_IDX(curr_stmt_sh_idx) = endif_idx;
11447 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
11448
11449 AT_DEFINED(label2_idx) = TRUE;
11450 ATL_DEF_STMT_IDX(label2_idx) = curr_stmt_sh_idx;
11451 }
11452
11453
11454 # endif
11455
11456
11457 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
11458
11459 TRACE (Func_Exit, "gen_if_stmt", NULL);
11460
11461 return;
11462
11463 }
11464
11465
11466
11467
11468
11469
11470
11471
11472
11473
11474
11475
11476
11477
11478
11479
11480
11481 boolean needs_bounds_check(int sub_idx)
11482
11483 {
11484 int base_attr;
11485 int bd_idx;
11486 boolean bound_chk;
11487 int col;
11488 int left_attr;
11489 int line;
11490
11491 TRACE (Func_Entry, "needs_bounds_check", NULL);
11492
11493 # ifdef _DEBUG
11494 if (IR_OPR(sub_idx) != Whole_Subscript_Opr &&
11495 IR_OPR(sub_idx) != Section_Subscript_Opr &&
11496 IR_OPR(sub_idx) != Subscript_Opr) {
11497
11498 PRINTMSG(stmt_start_line, 626, Internal, stmt_start_col,
11499 "Subscript_Opr", "needs_bounds_check");
11500 }
11501 # endif
11502
11503 base_attr = find_base_attr(&IR_OPND_L(sub_idx), &line, &col);
11504 left_attr = find_left_attr(&IR_OPND_L(sub_idx));
11505 bd_idx = ATD_ARRAY_IDX(base_attr);
11506
11507 bound_chk = (cdir_switches.bounds ||
11508 ATD_BOUNDS_CHECK(left_attr)) &&
11509 !ATD_NOBOUNDS_CHECK(left_attr);
11510
11511 bound_chk &= ! (IR_WHOLE_ARRAY(sub_idx));
11512
11513 if (IR_BOUNDS_DONE(sub_idx) ||
11514 IR_OPR(sub_idx) == Whole_Subscript_Opr ||
11515 ATD_CLASS(base_attr) == Compiler_Tmp) {
11516 bound_chk = FALSE;
11517 }
11518
11519 if (BD_RANK(bd_idx) == 1 &&
11520 BD_ARRAY_CLASS(bd_idx) == Explicit_Shape &&
11521 BD_LB_FLD(bd_idx,1) == CN_Tbl_Idx &&
11522 compare_cn_and_value(BD_LB_IDX(bd_idx,1), 1, Eq_Opr) &&
11523 BD_UB_FLD(bd_idx,1) == CN_Tbl_Idx &&
11524 compare_cn_and_value(BD_UB_IDX(bd_idx,1), 1, Eq_Opr)) {
11525
11526 bound_chk = FALSE;
11527 }
11528
11529
11530 TRACE (Func_Exit, "needs_bounds_check", NULL);
11531
11532 return(bound_chk);
11533
11534 }
11535
11536
11537
11538
11539
11540
11541
11542
11543
11544
11545
11546
11547
11548
11549
11550
11551
11552 void gen_rbounds_condition(opnd_type *cond_opnd,
11553 opnd_type *start_opnd,
11554 opnd_type *end_opnd,
11555 opnd_type *inc_opnd,
11556 opnd_type *lb_opnd,
11557 opnd_type *ub_opnd,
11558 int line,
11559 int col)
11560
11561 {
11562 int and_idx;
11563 int div_idx;
11564 expr_arg_type exp_desc;
11565 int gt_idx;
11566 int lt_idx;
11567 int minus_idx;
11568 int mult_idx;
11569 int or_idx1;
11570 int or_idx2;
11571 int or_idx3;
11572 opnd_type opnd;
11573 int plus_idx;
11574 expr_mode_type save_expr_mode;
11575 cif_usage_code_type save_xref_state;
11576 opnd_type xt_opnd;
11577
11578
11579 TRACE (Func_Entry, "gen_rbounds_condition", NULL);
11580
11581
11582
11583
11584
11585
11586
11587
11588 lt_idx = gen_ir(OPND_FLD((*start_opnd)), OPND_IDX((*start_opnd)),
11589 Lt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
11590 OPND_FLD((*lb_opnd)), OPND_IDX((*lb_opnd)));
11591
11592
11593
11594 gt_idx = gen_ir(OPND_FLD((*start_opnd)), OPND_IDX((*start_opnd)),
11595 Gt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
11596 OPND_FLD((*ub_opnd)), OPND_IDX((*ub_opnd)));
11597
11598
11599
11600 or_idx1 = gen_ir(IR_Tbl_Idx, lt_idx,
11601 Or_Opr, LOGICAL_DEFAULT_TYPE, line, col,
11602 IR_Tbl_Idx, gt_idx);
11603
11604
11605
11606
11607 minus_idx = gen_ir(OPND_FLD((*end_opnd)), OPND_IDX((*end_opnd)),
11608 Minus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
11609 OPND_FLD((*start_opnd)), OPND_IDX((*start_opnd)));
11610
11611 plus_idx = gen_ir(IR_Tbl_Idx, minus_idx,
11612 Plus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
11613 OPND_FLD((*inc_opnd)), OPND_IDX((*inc_opnd)));
11614
11615 div_idx = gen_ir(IR_Tbl_Idx, plus_idx,
11616 Div_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
11617 OPND_FLD((*inc_opnd)), OPND_IDX((*inc_opnd)));
11618
11619 gen_opnd(&xt_opnd, div_idx, IR_Tbl_Idx, line, col);
11620 copy_subtree(&xt_opnd, &xt_opnd);
11621
11622 minus_idx = gen_ir(IR_Tbl_Idx, div_idx,
11623 Minus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
11624 CN_Tbl_Idx, CN_INTEGER_ONE_IDX);
11625
11626 mult_idx = gen_ir(IR_Tbl_Idx, minus_idx,
11627 Mult_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
11628 OPND_FLD((*inc_opnd)), OPND_IDX((*inc_opnd)));
11629
11630 plus_idx = gen_ir(OPND_FLD((*start_opnd)), OPND_IDX((*start_opnd)),
11631 Plus_Opr, CG_INTEGER_DEFAULT_TYPE, line, col,
11632 IR_Tbl_Idx, mult_idx);
11633
11634 lt_idx = gen_ir(IR_Tbl_Idx, plus_idx,
11635 Lt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
11636 OPND_FLD((*lb_opnd)), OPND_IDX((*lb_opnd)));
11637
11638 gen_opnd(&opnd, plus_idx, IR_Tbl_Idx, line, col);
11639
11640 copy_subtree(&opnd, &opnd);
11641
11642 gt_idx = gen_ir(OPND_FLD(opnd), OPND_IDX(opnd),
11643 Gt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
11644 OPND_FLD((*ub_opnd)), OPND_IDX((*ub_opnd)));
11645
11646
11647
11648 or_idx2 = gen_ir(IR_Tbl_Idx, lt_idx,
11649 Or_Opr, LOGICAL_DEFAULT_TYPE, line, col,
11650 IR_Tbl_Idx, gt_idx);
11651
11652
11653 or_idx3 = gen_ir(IR_Tbl_Idx, or_idx1,
11654 Or_Opr, LOGICAL_DEFAULT_TYPE, line, col,
11655 IR_Tbl_Idx, or_idx2);
11656
11657 gt_idx = gen_ir(OPND_FLD(xt_opnd), OPND_IDX(xt_opnd),
11658 Gt_Opr, LOGICAL_DEFAULT_TYPE, line, col,
11659 CN_Tbl_Idx, CN_INTEGER_ZERO_IDX);
11660
11661 and_idx = gen_ir(IR_Tbl_Idx, or_idx3,
11662 And_Opr, LOGICAL_DEFAULT_TYPE, line, col,
11663 IR_Tbl_Idx, gt_idx);
11664
11665 gen_opnd(cond_opnd, and_idx, IR_Tbl_Idx, line, col);
11666
11667 save_xref_state = xref_state;
11668 xref_state = CIF_No_Usage_Rec;
11669 save_expr_mode = expr_mode;
11670 expr_mode = Regular_Expr;
11671
11672 exp_desc = init_exp_desc;
11673 expr_semantics(cond_opnd, &exp_desc);
11674 xref_state = save_xref_state;
11675 expr_mode = save_expr_mode;
11676
11677 TRACE (Func_Exit, "gen_rbounds_condition", NULL);
11678
11679 return;
11680
11681 }
11682
11683
11684
11685
11686
11687
11688
11689
11690
11691
11692
11693
11694
11695
11696
11697
11698
11699 void scan_for_ptr_chk(opnd_type *top_opnd)
11700
11701 {
11702 opnd_type dv_opnd;
11703 int ir_idx;
11704 int list_idx;
11705 opnd_type opnd;
11706
11707 TRACE (Func_Entry, "scan_for_ptr_chk", NULL);
11708
11709 switch (OPND_FLD((*top_opnd))) {
11710 case IR_Tbl_Idx:
11711 ir_idx = OPND_IDX((*top_opnd));
11712
11713 if (IR_OPR(ir_idx) == Dv_Deref_Opr) {
11714 COPY_OPND(dv_opnd, IR_OPND_L(ir_idx));
11715 gen_runtime_ptr_chk(&dv_opnd);
11716 }
11717
11718 COPY_OPND(opnd, IR_OPND_L(ir_idx));
11719 scan_for_ptr_chk(&opnd);
11720
11721 COPY_OPND(opnd, IR_OPND_R(ir_idx));
11722 scan_for_ptr_chk(&opnd);
11723 break;
11724
11725 case IL_Tbl_Idx:
11726 list_idx = OPND_IDX((*top_opnd));
11727
11728 while (list_idx) {
11729 COPY_OPND(opnd, IL_OPND(list_idx));
11730 scan_for_ptr_chk(&opnd);
11731 list_idx = IL_NEXT_LIST_IDX(list_idx);
11732 }
11733 break;
11734 }
11735
11736 TRACE (Func_Exit, "scan_for_ptr_chk", NULL);
11737
11738 return;
11739
11740 }
11741
11742
11743
11744
11745
11746
11747
11748
11749
11750
11751
11752
11753
11754
11755
11756
11757
11758 void runtime_ptr_chk_driver(void)
11759
11760 {
11761 opnd_type opnd;
11762 int save_curr_stmt_sh_idx;
11763
11764 TRACE (Func_Entry, "runtime_ptr_chk_driver", NULL);
11765
11766 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
11767
11768 curr_stmt_sh_idx = SCP_FIRST_SH_IDX(curr_scp_idx);
11769
11770 while (curr_stmt_sh_idx != NULL_IDX) {
11771
11772 if (SH_IR_IDX(curr_stmt_sh_idx) != NULL_IDX) {
11773 gen_opnd(&opnd, SH_IR_IDX(curr_stmt_sh_idx), IR_Tbl_Idx,
11774 SH_GLB_LINE(curr_stmt_sh_idx), SH_COL_NUM(curr_stmt_sh_idx));
11775 scan_for_ptr_chk(&opnd);
11776 }
11777
11778 curr_stmt_sh_idx = SH_NEXT_IDX(curr_stmt_sh_idx);
11779 }
11780
11781 PRINT_IR_TBL4;
11782
11783 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
11784
11785 TRACE (Func_Exit, "runtime_ptr_chk_driver", NULL);
11786
11787 return;
11788
11789 }
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807 void gen_copyin_bounds_stmt(int attr_idx)
11808
11809 {
11810 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
11811 int col;
11812 int ir_idx;
11813 int line;
11814
11815 TRACE (Func_Entry, "gen_copyin_bounds_stmt", NULL);
11816
11817 line = AT_DEF_LINE(attr_idx);
11818 col = AT_DEF_COLUMN(attr_idx);
11819
11820 ir_idx = gen_ir(AT_Tbl_Idx, attr_idx,
11821 Copyin_Bound_Opr, TYPELESS_DEFAULT_TYPE, line, col,
11822 NO_Tbl_Idx, NULL_IDX);
11823
11824 gen_sh(Before, Directive_Stmt, line, col, FALSE, FALSE, TRUE);
11825 SH_IR_IDX(SH_PREV_IDX(curr_stmt_sh_idx)) = ir_idx;
11826 SH_P2_SKIP_ME(SH_PREV_IDX(curr_stmt_sh_idx)) = TRUE;
11827
11828 TRACE (Func_Exit, "gen_copyin_bounds_stmt", NULL);
11829
11830 # endif
11831 return;
11832
11833 }
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848
11849
11850
11851 void gen_dv_access_low_bound(opnd_type *result_opnd,
11852 opnd_type *dv_opnd,
11853 int dim)
11854
11855 {
11856 int attr_idx;
11857 int bd_idx;
11858 int col;
11859 expr_arg_type exp_desc;
11860 int ir_idx;
11861 int line;
11862 cif_usage_code_type save_xref_state;
11863
11864
11865 TRACE (Func_Entry, "gen_dv_access_low_bound", NULL);
11866
11867 attr_idx = find_base_attr(dv_opnd, &line, &col);
11868
11869 # ifdef _DEBUG
11870 if (! ATD_IM_A_DOPE(attr_idx)) {
11871 PRINTMSG(line, 626, Internal, col,
11872 "dope vector" , "gen_dv_low_bound");
11873 }
11874 # endif
11875
11876 bd_idx = ATD_ARRAY_IDX(attr_idx);
11877
11878 if (bd_idx &&
11879 BD_ARRAY_CLASS(bd_idx) == Assumed_Shape) {
11880
11881 gen_opnd(result_opnd, BD_LB_IDX(bd_idx,dim), BD_LB_FLD(bd_idx,dim),
11882 line, col);
11883
11884 if (variable_size_func_expr &&
11885 OPND_FLD((*result_opnd)) == AT_Tbl_Idx &&
11886 ATD_CLASS(OPND_IDX((*result_opnd))) == Compiler_Tmp &&
11887 ATD_FLD(OPND_IDX((*result_opnd))) == IR_Tbl_Idx &&
11888 IR_OPR(ATD_TMP_IDX(OPND_IDX((*result_opnd)))) == Asg_Opr) {
11889
11890 while (OPND_FLD((*result_opnd)) == AT_Tbl_Idx &&
11891 ATD_CLASS(OPND_IDX((*result_opnd))) == Compiler_Tmp &&
11892 ATD_FLD(OPND_IDX((*result_opnd))) == IR_Tbl_Idx &&
11893 IR_OPR(ATD_TMP_IDX(OPND_IDX((*result_opnd)))) == Asg_Opr) {
11894
11895 COPY_OPND((*result_opnd),
11896 IR_OPND_R(ATD_TMP_IDX(OPND_IDX((*result_opnd)))));
11897 }
11898
11899 exp_desc.rank = 0;
11900
11901 save_xref_state = xref_state;
11902 xref_state = CIF_No_Usage_Rec;
11903 expr_semantics(result_opnd, &exp_desc);
11904 xref_state = save_xref_state;
11905 }
11906 }
11907 else {
11908 ir_idx = gen_ir(OPND_FLD((*dv_opnd)), OPND_IDX((*dv_opnd)),
11909 Dv_Access_Low_Bound, SA_INTEGER_DEFAULT_TYPE, line, col,
11910 NO_Tbl_Idx, NULL_IDX);
11911 IR_DV_DIM(ir_idx) = dim;
11912
11913 gen_opnd(result_opnd, ir_idx, IR_Tbl_Idx, line, col);
11914 }
11915
11916 TRACE (Func_Exit, "gen_dv_access_low_bound", NULL);
11917
11918 return;
11919
11920 }
11921
11922
11923
11924
11925
11926
11927
11928
11929
11930
11931
11932
11933
11934
11935
11936
11937
11938 long64 sm_unit_in_bits(int type_idx)
11939
11940 {
11941 long64 bits;
11942
11943
11944 TRACE (Func_Entry, "sm_unit_in_bits", NULL);
11945
11946 # if defined(_SM_UNIT_IS_ELEMENT)
11947
11948 switch (TYP_TYPE(type_idx)) {
11949 case Typeless:
11950 bits = TYP_BIT_LEN(type_idx);
11951 break;
11952
11953 case Integer:
11954 case Logical:
11955 case CRI_Ptr:
11956 case CRI_Ch_Ptr:
11957 case Real:
11958 case Complex:
11959 bits = storage_bit_size_tbl[TYP_LINEAR(type_idx)];
11960 break;
11961
11962 case Character:
11963
11964 # ifdef _DEBUG
11965 if (TYP_FLD(type_idx) != CN_Tbl_Idx) {
11966 PRINTMSG(stmt_start_line, 626, Internal, stmt_start_col,
11967 "constant length character", "sm_unit_in_bits");
11968 }
11969 # endif
11970 bits = CN_INT_TO_C(TYP_IDX(type_idx)) * 8;
11971 break;
11972
11973 case Structure:
11974 # ifdef _DEBUG
11975 if (ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx)) != CN_Tbl_Idx) {
11976 PRINTMSG(stmt_start_line, 626, Internal, stmt_start_col,
11977 "constant length structure", "sm_unit_in_bits");
11978 }
11979 # endif
11980 bits = CN_INT_TO_C(ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx)));
11981 break;
11982 }
11983
11984 # else
11985
11986 bits = stride_mult_unit_in_bits[TYP_LINEAR(type_idx)];
11987
11988 # endif
11989
11990 TRACE (Func_Exit, "sm_unit_in_bits", NULL);
11991
11992 return(bits);
11993
11994 }
11995
11996
11997
11998
11999
12000
12001
12002
12003
12004
12005
12006
12007
12008
12009
12010
12011
12012
12013 void gen_temp_init(int attr_idx,
12014 int cn_idx)
12015
12016 {
12017 int col;
12018 int entry_attr_idx;
12019 int entry_list_idx;
12020 int entry_sh_idx;
12021 int ir_idx;
12022 int line;
12023 opnd_type opnd;
12024 int sh_idx;
12025 int type_idx;
12026
12027 TRACE (Func_Entry, "gen_temp_init", NULL);
12028
12029 type_idx = ATD_TYPE_IDX(attr_idx);
12030 line = AT_DEF_LINE(attr_idx);
12031 col = AT_DEF_COLUMN(attr_idx);
12032
12033 if (SB_RUNTIME_INIT(ATD_STOR_BLK_IDX(attr_idx))) {
12034
12035
12036
12037
12038 ir_idx = gen_ir(AT_Tbl_Idx, attr_idx,
12039 Asg_Opr, type_idx, line, col,
12040 CN_Tbl_Idx, cn_idx);
12041
12042 gen_opnd(&opnd, ir_idx, IR_Tbl_Idx, line, col);
12043
12044 sh_idx = ntr_sh_tbl();
12045 SH_STMT_TYPE(sh_idx) = Assignment_Stmt;
12046 SH_GLB_LINE(sh_idx) = line;
12047 SH_COL_NUM(sh_idx) = col;
12048 SH_COMPILER_GEN(sh_idx) = TRUE;
12049 SH_P2_SKIP_ME(sh_idx) = TRUE;
12050
12051 SH_IR_IDX(sh_idx) = ir_idx;
12052
12053 insert_sh_chain_after_entries(sh_idx, sh_idx);
12054 }
12055 else {
12056 ir_idx = gen_ir(AT_Tbl_Idx, attr_idx,
12057 Init_Opr, TYPELESS_DEFAULT_TYPE, line, col,
12058 IL_Tbl_Idx, gen_il(3,
12059 FALSE,
12060 line,
12061 col,
12062 CN_Tbl_Idx,
12063 cn_idx,
12064 CN_Tbl_Idx,
12065 CN_INTEGER_ONE_IDX,
12066 CN_Tbl_Idx,
12067 CN_INTEGER_ZERO_IDX));
12068
12069 gen_sh(After,
12070 Type_Init_Stmt,
12071 line,
12072 col,
12073 FALSE,
12074 FALSE,
12075 TRUE);
12076
12077 SH_P2_SKIP_ME(curr_stmt_sh_idx) = TRUE;
12078 SH_IR_IDX(curr_stmt_sh_idx) = ir_idx;
12079
12080 }
12081
12082
12083 TRACE (Func_Exit, "gen_temp_init", NULL);
12084
12085 return;
12086
12087 }