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/sytb.c 5.25 10/27/99 16:59:36\n";
00046
00047 # include "defines.h"
00048
00049 # include "host.m"
00050 # include "host.h"
00051 # include "target.m"
00052 # include "target.h"
00053
00054 # ifdef _ARITH_H
00055 # include "arith.h"
00056 # endif
00057 #ifdef KEY
00058 #include <math.h>
00059 #endif
00060 # include "globals.m"
00061 # include "tokens.m"
00062 # include "sytb.m"
00063 # include "p_globals.m"
00064 # include "debug.m"
00065
00066 # include "globals.h"
00067 # include "tokens.h"
00068 # include "sytb.h"
00069 # include "p_globals.h"
00070
00071 # ifdef _WHIRL_HOST64_TARGET64
00072 int double_stride = 0;
00073 # endif
00074 #ifdef KEY
00075 #include "../sgi/decorate_utils.h"
00076 #endif
00077
00078
00079
00080
00081
00082 static void calculate_pad(size_offset_type *, size_offset_type *, int);
00083 static int ntr_global_bounds_tbl(int);
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 static boolean pvp_isnormal(int, long_type *);
00094
00095
00096
00097
00098
00099
00100 static int ntr_abnormal_ieee_const(int, long_type *);
00101
00102
00103
00104
00105
00106
00107
00108 static boolean is_normal(int, long_type *);
00109 static int is_normal_32(long_type *);
00110 static int is_normal_64(int, long_type *);
00111 static int is_normal_128(int, long_type *);
00112
00113
00114
00115
00116
00117
00118 static int sign_bit(int, long_type *);
00119 static int sign_bit_32(long_type *);
00120 static int sign_bit_64(long_type *);
00121 static int sign_bit_128(long_type *);
00122
00123
00124
00125
00126
00127
00128 static int fp_classify(int, long_type *);
00129 static int fp_classify_32(long_type *);
00130 static int fp_classify_64(int, long_type *);
00131 static int fp_classify_128(int, long_type *);
00132
00133
00134 static int insert_constant(int, long_type *, int);
00135 static int insert_unordered_constant(int, long_type *, int, int);
00136 static void dump_cn_tree(int, int, int);
00137
00138
00139
00140
00141
00142
00143 #define IEEE_32_EXPO_BITS 8
00144 #define IEEE_32_MANT_BITS 23
00145 #define IEEE_32_EXPONENT 0XFF
00146 #define IEEE_32_EXPO_ALLONES(X) ((X) == IEEE_32_EXPONENT)
00147
00148
00149
00150 #define IEEE_64_EXPO_BITS 11
00151 #define IEEE_64_MANTU_BITS 20
00152 #define IEEE_64_MANTL_BITS 32
00153 #define IEEE_64_EXPONENT 0X7FF
00154 #define IEEE_64_EXPO_ALLONES(X) ((X) == IEEE_64_EXPONENT)
00155
00156
00157
00158 #define IEEE_128_EXPO_BITS 15
00159 #define IEEE_128_MANTTU_BITS 16
00160 #define IEEE_128_MANTTL_BITS 32
00161 #define IEEE_128_EXPO 0X7FFF
00162 #define IEEE_128_EXPO_ALLONES(X) ((X) == IEEE_128_EXPO)
00163
00164
00165
00166
00167 #define FP_SGI_NAN 0
00168 #define FP_SGI_INFINITE 1
00169 #define FP_SGI_NORMAL 2
00170 #define FP_SGI_SUBNORMAL 3
00171 #define FP_SGI_ZERO 4
00172
00173 union ieee_real_4 {
00174 long_type integer_form;
00175 struct {
00176 # ifdef _TARGET64
00177 Uint UNUSED : 32;
00178 # endif
00179 Uint sign : 1;
00180 Uint exponent : IEEE_32_EXPO_BITS;
00181 Uint mantissa : IEEE_32_MANT_BITS;
00182 } parts;
00183 };
00184
00185 typedef union ieee_real_4 ieee_real_4_type;
00186
00187 union ieee_real_8 {
00188 long_type integer_array[MAX_WORDS_FOR_INTEGER];
00189 struct { Uint sign : 1;
00190 Uint exponent : IEEE_64_EXPO_BITS;
00191 Uint mantissa_u : IEEE_64_MANTU_BITS;
00192 Uint mantissa_l : IEEE_64_MANTL_BITS;
00193 } parts;
00194 };
00195
00196 typedef union ieee_real_8 ieee_real_8_type;
00197
00198 union ieee_real_16 {
00199 # ifdef _TARGET64
00200 long_type integer_array[2];
00201 # else
00202 long_type integer_array[4];
00203 # endif
00204 struct { Uint sign : 1;
00205 Uint exponent : IEEE_128_EXPO_BITS;
00206 Uint mantissa_u1 : IEEE_128_MANTTU_BITS;
00207 Uint mantissa_u2 : IEEE_128_MANTTL_BITS;
00208 Uint mantissa_l1 : IEEE_128_MANTTL_BITS;
00209 Uint mantissa_l2 : IEEE_128_MANTTL_BITS;
00210 } parts;
00211 };
00212
00213 typedef union ieee_real_16 ieee_real_16_type;
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237 boolean compare_value_to_cn(long_type *value,
00238 int cn_idx,
00239 int opr)
00240
00241 {
00242 long_type result[MAX_WORDS_FOR_NUMERIC];
00243 int i;
00244 boolean is_true = FALSE;
00245 boolean tested_not_equal;
00246 int type_idx;
00247 int word_len;
00248
00249
00250 TRACE (Func_Entry,"compare_value_to_cn" , NULL);
00251
00252
00253
00254
00255
00256 if (opr == Eq_Opr || opr == Ne_Opr) {
00257 tested_not_equal = FALSE;
00258
00259 word_len = TARGET_BITS_TO_WORDS(
00260 storage_bit_size_tbl[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]);
00261
00262 for (i = 0; i < word_len; i++) {
00263
00264 if (const_pool[CN_POOL_IDX(cn_idx) + i] != value[i]) {
00265 tested_not_equal = TRUE;
00266 break;
00267 }
00268 }
00269
00270 if (opr == Eq_Opr && ! tested_not_equal) {
00271 is_true = TRUE;
00272 }
00273 else if (opr == Ne_Opr && tested_not_equal) {
00274 is_true = TRUE;
00275 }
00276 }
00277 else {
00278 type_idx = CG_LOGICAL_DEFAULT_TYPE;
00279
00280 if (folder_driver( (char *) value,
00281 CN_TYPE_IDX(cn_idx),
00282 (char *) &CN_CONST(cn_idx),
00283 CN_TYPE_IDX(cn_idx),
00284 result,
00285 &type_idx,
00286 stmt_start_line,
00287 stmt_start_col,
00288 2,
00289 opr)) {
00290
00291 if (THIS_IS_TRUE(result, type_idx)) {
00292 is_true = TRUE;
00293 }
00294 }
00295 }
00296
00297 TRACE (Func_Exit, "compare_value_to_cn", NULL);
00298
00299 return(is_true);
00300
00301 }
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324 int srch_sym_tbl (char *name_str,
00325 int name_len,
00326 int *name_idx)
00327
00328 {
00329 int idx;
00330 long tst_val;
00331
00332
00333 TRACE (Func_Entry, "srch_sym_tbl", name_str);
00334
00335
00336
00337 tst_val = srch_name_tbl(name_str,
00338 name_len,
00339 &idx,
00340 loc_name_tbl,
00341 name_pool,
00342 SCP_LN_FW_IDX(curr_scp_idx),
00343 SCP_LN_LW_IDX(curr_scp_idx));
00344 *name_idx = idx;
00345
00346 if (tst_val != 0) {
00347 idx = NULL_IDX;
00348 TRACE (Func_Exit, "srch_sym_tbl", NULL);
00349 }
00350 else {
00351 TRACE (Func_Exit, "srch_sym_tbl",
00352 &name_pool[LN_NAME_IDX(*name_idx)].name_char);
00353 idx = LN_ATTR_IDX(*name_idx);
00354 }
00355 return (idx);
00356
00357 }
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383 int ntr_sym_tbl(token_type *token,
00384 int name_idx)
00385
00386 {
00387 register int attr_idx;
00388 register int i;
00389 register int np_idx;
00390 register int scp_idx;
00391
00392 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
00393 register long *name_tbl_base;
00394 # endif
00395
00396
00397 TRACE (Func_Entry, "ntr_sym_tbl", TOKEN_STR(*token));
00398
00399 # if defined(_DEBUG)
00400
00401 if (TOKEN_LEN(*token) == 0 || TOKEN_STR(*token) == NULL) {
00402 PRINTMSG(stmt_start_line, 1200, Internal, stmt_start_col);
00403 }
00404
00405 # endif
00406
00407 TBL_REALLOC_CK(loc_name_tbl, 1);
00408
00409 NTR_NAME_POOL((long *) TOKEN_STR(*token), TOKEN_LEN(*token), np_idx);
00410
00411
00412
00413 NTR_ATTR_TBL(attr_idx);
00414 AT_DEF_LINE(attr_idx) = TOKEN_LINE(*token);
00415 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(*token);
00416 AT_NAME_LEN(attr_idx) = TOKEN_LEN(*token);
00417 AT_NAME_IDX(attr_idx) = np_idx;
00418
00419 if ((loc_name_tbl_idx - 1) != SCP_LN_LW_IDX(curr_scp_idx)) {
00420
00421
00422
00423
00424
00425 for (scp_idx = 1; scp_idx <= scp_tbl_idx; scp_idx++) {
00426
00427 if (SCP_LN_FW_IDX(scp_idx) > SCP_LN_LW_IDX(curr_scp_idx)) {
00428 SCP_LN_FW_IDX(scp_idx) = SCP_LN_FW_IDX(scp_idx) + 1;
00429 SCP_LN_LW_IDX(scp_idx) = SCP_LN_LW_IDX(scp_idx) + 1;
00430 }
00431 }
00432 SCP_LN_LW_IDX(curr_scp_idx)++;
00433 }
00434 else {
00435
00436
00437
00438
00439 SCP_LN_LW_IDX(curr_scp_idx) = loc_name_tbl_idx;
00440 }
00441
00442
00443
00444 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
00445 name_tbl_base = (long *) loc_name_tbl;
00446 # endif
00447
00448 # pragma _CRI ivdep
00449 for (i = loc_name_tbl_idx; i >= name_idx; i--) {
00450 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
00451 name_tbl_base [i] = name_tbl_base [i-1];
00452 # else
00453 loc_name_tbl [i] = loc_name_tbl [i-1];
00454 # endif
00455 }
00456
00457 CLEAR_TBL_NTRY(loc_name_tbl, name_idx);
00458 LN_ATTR_IDX(name_idx) = attr_idx;
00459 LN_NAME_IDX(name_idx) = np_idx;
00460 LN_NAME_LEN(name_idx) = TOKEN_LEN(*token);
00461
00462 TRACE (Func_Exit, "ntr_sym_tbl", TOKEN_STR(*token));
00463
00464 return (attr_idx);
00465
00466 }
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490 int srch_host_sym_tbl (char *name_str,
00491 int name_len,
00492 int *name_idx,
00493 boolean search_intrin_scp)
00494
00495 {
00496
00497 int idx = NULL_IDX;
00498 int save_scp_idx;
00499 int search_range;
00500
00501 TRACE (Func_Entry, "srch_host_sym_tbl", NULL);
00502
00503
00504
00505 save_scp_idx = curr_scp_idx;
00506
00507 if (search_intrin_scp) {
00508 search_range = 0;
00509 }
00510 else {
00511 search_range = 1;
00512 }
00513
00514 if (SCP_IS_INTERFACE(curr_scp_idx)
00515 #ifdef KEY
00516
00517
00518 && ! SCP_IMPORT(curr_scp_idx)
00519 #endif
00520 ) {
00521 curr_scp_idx = 1;
00522 }
00523
00524 while (idx == NULL_IDX && curr_scp_idx != search_range) {
00525
00526
00527
00528 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
00529 idx = srch_sym_tbl (name_str, name_len, name_idx);
00530 }
00531
00532 curr_scp_idx = save_scp_idx;
00533
00534 TRACE (Func_Exit, "srch_host_sym_tbl", NULL);
00535
00536 return (idx);
00537
00538 }
00539 #ifdef KEY
00540
00541
00542 int
00543 srch_host_sym_tbl_for_import(char *name_str, int name_len, int *name_idx)
00544 {
00545 int save_scp_idx = curr_scp_idx;
00546 int idx = NULL_IDX;
00547 int dummy_name_idx;
00548 int *dummy_name_idx_p = name_idx ? name_idx : &dummy_name_idx;
00549 while (idx == NULL_IDX && curr_scp_idx != 1) {
00550 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
00551 idx = srch_sym_tbl (name_str, name_len, dummy_name_idx_p);
00552 }
00553 curr_scp_idx = save_scp_idx;
00554 return idx;
00555 }
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577 int
00578 import_from_host(char *name, int name_len, int *host_name_idx,
00579 int local_attr_idx) {
00580 int host_attr_idx = srch_host_sym_tbl_for_import(name, name_len,
00581 host_name_idx);
00582 if (host_attr_idx) {
00583 AT_ATTR_LINK(local_attr_idx) = host_attr_idx;
00584 AT_DEFINED(local_attr_idx) = AT_DEFINED(host_attr_idx);
00585 AT_LOCKED_IN(local_attr_idx) = TRUE;
00586 }
00587 return host_attr_idx;
00588 }
00589 #endif
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622 int ntr_host_in_sym_tbl(token_type *token,
00623 int name_idx,
00624 int host_attr_idx,
00625 int host_ln_idx,
00626 boolean make_new_attr_and_link)
00627
00628 {
00629 register int attr_idx;
00630 register int i;
00631 register int scp_idx;
00632
00633 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
00634 register long *name_tbl_base;
00635 # endif
00636
00637
00638 TRACE (Func_Entry, "ntr_host_in_sym_tbl", TOKEN_STR(*token));
00639
00640
00641
00642
00643 if (make_new_attr_and_link) {
00644 NTR_ATTR_TBL(attr_idx);
00645 AT_DEF_LINE(attr_idx) = TOKEN_LINE(*token);
00646 AT_DEF_COLUMN(attr_idx) = TOKEN_COLUMN(*token);
00647 AT_NAME_LEN(attr_idx) = AT_NAME_LEN(host_attr_idx);
00648 AT_NAME_IDX(attr_idx) = AT_NAME_IDX(host_attr_idx);
00649 AT_ATTR_LINK(attr_idx) = host_attr_idx;
00650 }
00651 else {
00652 attr_idx = host_attr_idx;
00653 }
00654
00655 TBL_REALLOC_CK(loc_name_tbl, 1);
00656
00657 if ((loc_name_tbl_idx - 1) != SCP_LN_LW_IDX(curr_scp_idx)) {
00658
00659
00660
00661
00662
00663 for (scp_idx = 1; scp_idx <= scp_tbl_idx; scp_idx++) {
00664
00665 if (SCP_LN_FW_IDX(scp_idx) > SCP_LN_LW_IDX(curr_scp_idx)) {
00666 SCP_LN_FW_IDX(scp_idx) = SCP_LN_FW_IDX(scp_idx) + 1;
00667 SCP_LN_LW_IDX(scp_idx) = SCP_LN_LW_IDX(scp_idx) + 1;
00668 }
00669 }
00670 SCP_LN_LW_IDX(curr_scp_idx)++;
00671 }
00672 else {
00673
00674
00675
00676
00677 SCP_LN_LW_IDX(curr_scp_idx) = loc_name_tbl_idx;
00678 }
00679
00680
00681
00682 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
00683 name_tbl_base = (long *) loc_name_tbl;
00684 # endif
00685
00686 # pragma _CRI ivdep
00687 for (i = loc_name_tbl_idx; i >= name_idx; i--) {
00688 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
00689 name_tbl_base [i] = name_tbl_base [i-1];
00690 # else
00691 loc_name_tbl [i] = loc_name_tbl [i-1];
00692 # endif
00693 }
00694
00695 CLEAR_TBL_NTRY(loc_name_tbl, name_idx);
00696 LN_ATTR_IDX(name_idx) = attr_idx;
00697 LN_NAME_IDX(name_idx) = LN_NAME_IDX(host_ln_idx);
00698 LN_NAME_LEN(name_idx) = LN_NAME_LEN(host_ln_idx);
00699
00700 TRACE (Func_Exit, "ntr_host_in_sym_tbl", TOKEN_STR(*token));
00701
00702 return (attr_idx);
00703
00704 }
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721 void remove_ln_ntry(int name_idx)
00722
00723 {
00724 register int i;
00725
00726 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
00727 register long *name_tbl_base;
00728 # endif
00729
00730
00731 TRACE (Func_Entry, "remove_ln_ntry", NULL);
00732
00733 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
00734 name_tbl_base = (long *) loc_name_tbl;
00735 # endif
00736
00737
00738
00739 # pragma _CRI ivdep
00740 for (i = name_idx; i < SCP_LN_LW_IDX(curr_scp_idx); i++) {
00741 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
00742 name_tbl_base [i] = name_tbl_base [i+1];
00743 # else
00744 loc_name_tbl [i] = loc_name_tbl [i+1];
00745 # endif
00746 }
00747
00748 if (loc_name_tbl_idx == SCP_LN_LW_IDX(curr_scp_idx)) {
00749 loc_name_tbl_idx--;
00750 }
00751
00752 SCP_LN_LW_IDX(curr_scp_idx)--;
00753
00754 TRACE (Func_Exit, "remove_ln_ntry", NULL);
00755
00756 return;
00757
00758 }
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781 int srch_kwd_name(char *name,
00782 int length,
00783 int attr_idx,
00784 int *sn_idx)
00785
00786 {
00787 register int i;
00788 register int id_char_len;
00789 register int id_wd_len;
00790 #ifdef KEY
00791 register int num_dargs = 0;
00792 #else
00793 register int num_dargs;
00794 #endif
00795 register int np_idx;
00796 register long *id;
00797 register long tst_val;
00798 register long *sn_tbl_base;
00799
00800
00801
00802 TRACE (Func_Entry, "srch_kwd_name", name);
00803
00804 if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit) {
00805 num_dargs = ATP_NUM_DARGS(attr_idx);
00806 *sn_idx = ATP_FIRST_IDX(attr_idx);
00807 }
00808 else if (AT_OBJ_CLASS(attr_idx) == Stmt_Func) {
00809 num_dargs = ATP_NUM_DARGS(attr_idx);
00810 *sn_idx = ATP_FIRST_IDX(attr_idx);
00811 }
00812 else {
00813 PRINTMSG(stmt_start_line, 136, Internal, stmt_start_col, "srch_kwd_name");
00814 }
00815
00816 id = (long *) name;
00817 id_char_len = length;
00818 id_wd_len = WORD_LEN(id_char_len);
00819
00820
00821
00822 tst_val = -1;
00823 sn_tbl_base = (long *) sec_name_tbl;
00824
00825 # if defined(_HOST_LITTLE_ENDIAN)
00826
00827 for (i = 0; i < num_dargs; i++) {
00828 np_idx = SN_NP_IDX(*sn_idx + i);
00829
00830 if (SN_LEN(*sn_idx + i) == id_char_len) {
00831 tst_val = compare_names(&id[0],
00832 id_wd_len*HOST_BYTES_PER_WORD-1,
00833 &name_pool[np_idx].name_long,
00834 id_wd_len*HOST_BYTES_PER_WORD-1);
00835 if (tst_val == 0) {
00836 break;
00837 }
00838 }
00839 }
00840
00841 # else
00842
00843 switch (id_wd_len) {
00844 case 1:
00845 # pragma _CRI ivdep
00846 for (i = 0; i < num_dargs; i++) {
00847 np_idx = SN_NP_IDX(*sn_idx + i);
00848
00849 # if 0
00850
00851 tst_val = id[0] - name_pool[np_idx].name_long;
00852 if (tst_val == 0 && SN_LEN(*sn_idx + i) == id_char_len) {
00853 break;
00854 }
00855 # endif
00856 if (SN_LEN(*sn_idx + i) == id_char_len) {
00857 tst_val = id[0] - name_pool[np_idx].name_long;
00858
00859 if (tst_val == 0) {
00860 break;
00861 }
00862 }
00863 }
00864 break;
00865
00866 case 2:
00867 # pragma _CRI ivdep
00868
00869 for (i = 0; i < num_dargs; i++) {
00870 np_idx = SN_NP_IDX(*sn_idx + i);
00871
00872 if (SN_LEN(*sn_idx + i) == id_char_len) {
00873 tst_val = (id[0] - name_pool[np_idx ].name_long) |
00874 (id[1] - name_pool[np_idx + 1].name_long);
00875
00876 if (tst_val == 0) {
00877 break;
00878 }
00879 }
00880 }
00881 break;
00882
00883 case 3:
00884 # pragma _CRI ivdep
00885
00886 for (i = 0; i < num_dargs; i++) {
00887 np_idx = SN_NP_IDX(*sn_idx + i);
00888
00889 if (SN_LEN(*sn_idx + i) == id_char_len) {
00890 tst_val = (id[0] - name_pool[np_idx ].name_long) |
00891 (id[1] - name_pool[np_idx + 1].name_long) |
00892 (id[2] - name_pool[np_idx + 2].name_long);
00893
00894 if (tst_val == 0) {
00895 break;
00896 }
00897 }
00898 }
00899 break;
00900
00901 case 4:
00902 # pragma _CRI ivdep
00903 for (i = 0; i < num_dargs; i++) {
00904 np_idx = SN_NP_IDX(*sn_idx + i);
00905 if (SN_LEN(*sn_idx + i) == id_char_len) {
00906 tst_val = (id[0] - name_pool[np_idx ].name_long) |
00907 (id[1] - name_pool[np_idx + 1].name_long) |
00908 (id[2] - name_pool[np_idx + 2].name_long) |
00909 (id[3] - name_pool[np_idx + 3].name_long);
00910 if (tst_val == 0) {
00911 break;
00912 }
00913 }
00914 }
00915 break;
00916
00917 # ifdef _HOST32
00918 case 5:
00919 for (i = 0; i < num_dargs; i++) {
00920 np_idx = SN_NP_IDX(*sn_idx + i);
00921 if (SN_LEN(*sn_idx + i) == id_char_len) {
00922 tst_val = (id[0] - name_pool[np_idx ].name_long) |
00923 (id[1] - name_pool[np_idx + 1].name_long) |
00924 (id[2] - name_pool[np_idx + 2].name_long) |
00925 (id[3] - name_pool[np_idx + 3].name_long) |
00926 (id[4] - name_pool[np_idx + 4].name_long);
00927 if (tst_val == 0) {
00928 break;
00929 }
00930 }
00931 }
00932 break;
00933
00934 case 6:
00935 for (i = 0; i < num_dargs; i++) {
00936 np_idx = SN_NP_IDX(*sn_idx + i);
00937 if (SN_LEN(*sn_idx + i) == id_char_len) {
00938 tst_val = (id[0] - name_pool[np_idx ].name_long) |
00939 (id[1] - name_pool[np_idx + 1].name_long) |
00940 (id[2] - name_pool[np_idx + 2].name_long) |
00941 (id[3] - name_pool[np_idx + 3].name_long) |
00942 (id[4] - name_pool[np_idx + 4].name_long) |
00943 (id[5] - name_pool[np_idx + 5].name_long);
00944 if (tst_val == 0) {
00945 break;
00946 }
00947 }
00948 }
00949 break;
00950
00951 case 7:
00952 for (i = 0; i < num_dargs; i++) {
00953 np_idx = SN_NP_IDX(*sn_idx + i);
00954 if (SN_LEN(*sn_idx + i) == id_char_len) {
00955 tst_val = (id[0] - name_pool[np_idx ].name_long) |
00956 (id[1] - name_pool[np_idx + 1].name_long) |
00957 (id[2] - name_pool[np_idx + 2].name_long) |
00958 (id[3] - name_pool[np_idx + 3].name_long) |
00959 (id[4] - name_pool[np_idx + 4].name_long) |
00960 (id[5] - name_pool[np_idx + 5].name_long) |
00961 (id[6] - name_pool[np_idx + 6].name_long);
00962 if (tst_val == 0) {
00963 break;
00964 }
00965 }
00966 }
00967 break;
00968
00969 case 8:
00970 for (i = 0; i < num_dargs; i++) {
00971 np_idx = SN_NP_IDX(*sn_idx + i);
00972 if (SN_LEN(*sn_idx + i) == id_char_len) {
00973 tst_val = (id[0] - name_pool[np_idx ].name_long) |
00974 (id[1] - name_pool[np_idx + 1].name_long) |
00975 (id[2] - name_pool[np_idx + 2].name_long) |
00976 (id[3] - name_pool[np_idx + 3].name_long) |
00977 (id[4] - name_pool[np_idx + 4].name_long) |
00978 (id[5] - name_pool[np_idx + 5].name_long) |
00979 (id[6] - name_pool[np_idx + 6].name_long) |
00980 (id[7] - name_pool[np_idx + 7].name_long);
00981 if (tst_val == 0) {
00982 break;
00983 }
00984 }
00985 }
00986 break;
00987
00988 # endif
00989
00990 default:
00991 PRINTMSG(stmt_start_line, 196, Internal, stmt_start_col,
00992 "srch_kwd_name",
00993 NUM_ID_WDS * TARGET_CHARS_PER_WORD);
00994 break;
00995 }
00996
00997 # endif
00998
00999 if (tst_val == 0) {
01000 TRACE (Func_Exit, "srch_kwd_name", name);
01001 *sn_idx = *sn_idx + i;
01002 i = SN_ATTR_IDX(*sn_idx);
01003 }
01004 else {
01005 TRACE (Func_Exit, "srch_kwd_name", NULL);
01006 i = NULL_IDX;
01007 }
01008
01009 return (i);
01010
01011 }
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031 int srch_stor_blk_tbl (char *name_str,
01032 int name_len,
01033 int scp_idx)
01034
01035 {
01036 register int i;
01037 register long *id;
01038 register int id_char_len;
01039 register int id_wd_len;
01040 register int j;
01041 register int np_idx;
01042 register long tst_val;
01043
01044
01045 TRACE (Func_Entry, "srch_stor_blk_tbl", name_str);
01046
01047 id = (long *) name_str;
01048 id_char_len = name_len;
01049 id_wd_len = WORD_LEN(id_char_len);
01050 tst_val = -1;
01051
01052 # if defined(_HOST_LITTLE_ENDIAN)
01053
01054 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01055 np_idx = SB_NAME_IDX(i);
01056
01057 if (SB_NAME_LEN(i) == id_char_len &&
01058 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01059
01060 tst_val = compare_names(&id[0],
01061 id_wd_len*HOST_BYTES_PER_WORD-1,
01062 &name_pool[np_idx].name_long,
01063 id_wd_len*HOST_BYTES_PER_WORD-1);
01064
01065 if (tst_val == 0) {
01066 break;
01067 }
01068 }
01069 }
01070 # else
01071
01072 switch (id_wd_len) {
01073 case 1:
01074 # pragma _CRI ivdep
01075 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01076 np_idx = SB_NAME_IDX(i);
01077
01078 if (SB_NAME_LEN(i) == id_char_len &&
01079 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01080
01081 tst_val = id[0] - name_pool[np_idx].name_long;
01082
01083 if (tst_val == 0) {
01084 break;
01085 }
01086 }
01087 }
01088 break;
01089
01090 case 2:
01091 # pragma _CRI ivdep
01092 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01093 np_idx = SB_NAME_IDX(i);
01094
01095 if (SB_NAME_LEN(i) == id_char_len &&
01096 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01097
01098 tst_val = (id[0] - name_pool[np_idx ].name_long) |
01099 (id[1] - name_pool[np_idx + 1].name_long);
01100
01101 if (tst_val == 0) {
01102 break;
01103 }
01104 }
01105 }
01106 break;
01107
01108 case 3:
01109 # pragma _CRI ivdep
01110 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01111 np_idx = SB_NAME_IDX(i);
01112
01113 if (SB_NAME_LEN(i) == id_char_len &&
01114 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01115
01116 tst_val = (id[0] - name_pool[np_idx ].name_long) |
01117 (id[1] - name_pool[np_idx + 1].name_long) |
01118 (id[2] - name_pool[np_idx + 2].name_long);
01119
01120 if (tst_val == 0) {
01121 break;
01122 }
01123 }
01124 }
01125 break;
01126
01127 case 4:
01128 # pragma _CRI ivdep
01129 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01130 np_idx = SB_NAME_IDX(i);
01131
01132 if (SB_NAME_LEN(i) == id_char_len &&
01133 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01134
01135 tst_val = (id[0] - name_pool[np_idx ].name_long) |
01136 (id[1] - name_pool[np_idx + 1].name_long) |
01137 (id[2] - name_pool[np_idx + 2].name_long) |
01138 (id[3] - name_pool[np_idx + 3].name_long);
01139
01140 if (tst_val == 0) {
01141 break;
01142 }
01143 }
01144 }
01145 break;
01146
01147 # ifdef _HOST32
01148 case 5:
01149 # pragma _CRI ivdep
01150 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01151 np_idx = SB_NAME_IDX(i);
01152
01153 if (SB_NAME_LEN(i) == id_char_len &&
01154 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01155
01156 tst_val = (id[0] - name_pool[np_idx ].name_long) |
01157 (id[1] - name_pool[np_idx + 1].name_long) |
01158 (id[2] - name_pool[np_idx + 2].name_long) |
01159 (id[3] - name_pool[np_idx + 3].name_long) |
01160 (id[4] - name_pool[np_idx + 4].name_long);
01161
01162 if (tst_val == 0) {
01163 break;
01164 }
01165 }
01166 }
01167 break;
01168 case 6:
01169 # pragma _CRI ivdep
01170 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01171 np_idx = SB_NAME_IDX(i);
01172
01173 if (SB_NAME_LEN(i) == id_char_len &&
01174 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01175
01176 tst_val = (id[0] - name_pool[np_idx ].name_long) |
01177 (id[1] - name_pool[np_idx + 1].name_long) |
01178 (id[2] - name_pool[np_idx + 2].name_long) |
01179 (id[3] - name_pool[np_idx + 3].name_long) |
01180 (id[4] - name_pool[np_idx + 4].name_long) |
01181 (id[5] - name_pool[np_idx + 5].name_long);
01182
01183 if (tst_val == 0) {
01184 break;
01185 }
01186 }
01187 }
01188 break;
01189 case 7:
01190 # pragma _CRI ivdep
01191 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01192 np_idx = SB_NAME_IDX(i);
01193
01194 if (SB_NAME_LEN(i) == id_char_len &&
01195 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01196
01197 tst_val = (id[0] - name_pool[np_idx ].name_long) |
01198 (id[1] - name_pool[np_idx + 1].name_long) |
01199 (id[2] - name_pool[np_idx + 2].name_long) |
01200 (id[3] - name_pool[np_idx + 3].name_long) |
01201 (id[4] - name_pool[np_idx + 4].name_long) |
01202 (id[5] - name_pool[np_idx + 5].name_long) |
01203 (id[6] - name_pool[np_idx + 6].name_long);
01204
01205 if (tst_val == 0) {
01206 break;
01207 }
01208 }
01209 }
01210 break;
01211 case 8:
01212 # pragma _CRI ivdep
01213 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01214 np_idx = SB_NAME_IDX(i);
01215
01216 if (SB_NAME_LEN(i) == id_char_len &&
01217 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01218
01219 tst_val = (id[0] - name_pool[np_idx ].name_long) |
01220 (id[1] - name_pool[np_idx + 1].name_long) |
01221 (id[2] - name_pool[np_idx + 2].name_long) |
01222 (id[3] - name_pool[np_idx + 3].name_long) |
01223 (id[4] - name_pool[np_idx + 4].name_long) |
01224 (id[5] - name_pool[np_idx + 5].name_long) |
01225 (id[6] - name_pool[np_idx + 6].name_long) |
01226 (id[7] - name_pool[np_idx + 7].name_long);
01227
01228 if (tst_val == 0) {
01229 break;
01230 }
01231 }
01232 }
01233 break;
01234 # endif
01235
01236 default:
01237
01238 for (i = 1; i <= stor_blk_tbl_idx; i++) {
01239 np_idx = SB_NAME_IDX(i);
01240
01241 if (SB_NAME_LEN(i) == id_char_len &&
01242 SB_SCP_IDX(i) == scp_idx && !SB_HIDDEN(i)) {
01243 tst_val = 0;
01244
01245 # pragma _CRI ivdep
01246 for (j = 0; j < id_wd_len; j++) {
01247 tst_val = tst_val | (id[j] - name_pool[np_idx+j].name_long);
01248 }
01249
01250 if (tst_val == 0) {
01251 break;
01252 }
01253 }
01254 }
01255 break;
01256 }
01257
01258 # endif
01259
01260 if (tst_val != 0) {
01261 i = NULL_IDX;
01262 }
01263
01264 TRACE (Func_Exit, "srch_stor_blk_tbl", NULL);
01265
01266 return (i);
01267
01268 }
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292 int ntr_stor_blk_tbl (char *name_str,
01293 int name_len,
01294 int def_line,
01295 int def_column,
01296 int blk_type)
01297
01298 {
01299 register int np_idx;
01300
01301
01302 TRACE (Func_Entry, "ntr_stor_blk_tbl", name_str);
01303
01304 NTR_NAME_POOL((long *) name_str, name_len, np_idx);
01305
01306 TBL_REALLOC_CK(stor_blk_tbl, 1);
01307
01308 CLEAR_TBL_NTRY(stor_blk_tbl, stor_blk_tbl_idx);
01309
01310 SB_NAME_LEN(stor_blk_tbl_idx) = name_len;
01311 SB_NAME_IDX(stor_blk_tbl_idx) = np_idx;
01312 SB_DEF_LINE(stor_blk_tbl_idx) = def_line;
01313 SB_DEF_COLUMN(stor_blk_tbl_idx) = def_column;
01314 SB_SCP_IDX(stor_blk_tbl_idx) = curr_scp_idx;
01315 SB_ORIG_SCP_IDX(stor_blk_tbl_idx) = curr_scp_idx;
01316 #ifdef KEY
01317
01318
01319
01320
01321 if (Common == (sb_type_type) blk_type) {
01322 SB_LEN_IDX(stor_blk_tbl_idx) = C_INT_TO_CN(Integer_8, 0);
01323 } else
01324 #endif
01325 SB_LEN_IDX(stor_blk_tbl_idx) = CN_INTEGER_ZERO_IDX;
01326 SB_LEN_FLD(stor_blk_tbl_idx) = CN_Tbl_Idx;
01327 SB_BLK_TYPE(stor_blk_tbl_idx) = (sb_type_type) blk_type;
01328
01329 switch (blk_type) {
01330 case Common:
01331 case Task_Common:
01332 case Threadprivate:
01333 SB_IS_COMMON(stor_blk_tbl_idx) = TRUE;
01334 SB_RUNTIME_INIT(stor_blk_tbl_idx) = FALSE;
01335 break;
01336
01337 case Coment:
01338 case Static:
01339 case Static_Named:
01340 case Static_Local:
01341 SB_RUNTIME_INIT(stor_blk_tbl_idx) = FALSE;
01342 break;
01343
01344 case Stack:
01345 case Formal:
01346 case Based:
01347 case Equivalenced:
01348 case Non_Local_Stack:
01349 case Non_Local_Formal:
01350 case Hosted_Stack:
01351 case Auxiliary:
01352 SB_RUNTIME_INIT(stor_blk_tbl_idx) = TRUE;
01353 break;
01354
01355 # if defined(_DEBUG)
01356 case Unknown_Seg:
01357 case Extern:
01358 case Exported:
01359 case Soft_External:
01360 case Global_Breg:
01361 case Global_Treg:
01362 case Restricted:
01363 case Distributed:
01364 case LM_Static:
01365 case LM_Common:
01366 case LM_Extern:
01367
01368
01369
01370 default:
01371 PRINTMSG(def_line, 1592, Internal, def_column);
01372 break;
01373 # endif
01374 }
01375
01376 TRACE (Func_Exit, "ntr_stor_blk_tbl", NULL);
01377
01378 return (stor_blk_tbl_idx);
01379
01380 }
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399 int ntr_array_in_bd_tbl(int bd_idx)
01400
01401 {
01402 int free_idx;
01403 int free_size;
01404 int size;
01405
01406
01407 TRACE (Func_Entry, "ntr_array_in_bd_tbl", NULL);
01408
01409
01410
01411
01412
01413
01414
01415 if (BD_ARRAY_CLASS(bd_idx) == Deferred_Shape) {
01416
01417 if (!BD_DCL_ERR(bd_idx)) {
01418 BD_LINE_NUM(BD_RANK(bd_idx)) = BD_LINE_NUM(bd_idx);
01419 BD_COLUMN_NUM(BD_RANK(bd_idx)) = BD_COLUMN_NUM(bd_idx);
01420 free_idx = bd_idx;
01421 free_size = BD_NTRY_SIZE(bd_idx);
01422 bd_idx = BD_RANK(bd_idx);
01423 }
01424 else {
01425 free_size = BD_NTRY_SIZE(bd_idx) - 1;
01426 free_idx = bd_idx + 1;
01427 BD_USED_NTRY(bd_idx) = TRUE;
01428 BD_NTRY_SIZE(bd_idx) = 1;
01429 }
01430 }
01431 else {
01432 size = BD_RANK(bd_idx) + 1;
01433 free_size = BD_NTRY_SIZE(bd_idx) - size;
01434 free_idx = bd_idx + size;
01435 BD_USED_NTRY(bd_idx) = TRUE;
01436 BD_NTRY_SIZE(bd_idx) = size;
01437 }
01438
01439 if (free_size > 0) {
01440
01441 if ((free_idx + free_size - 1) == bounds_tbl_idx) {
01442 bounds_tbl_idx -= free_size;
01443 }
01444 else {
01445 BD_NEXT_FREE_NTRY(free_idx) = BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX);
01446 BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX) = free_idx;
01447 BD_NTRY_SIZE(free_idx) = free_size;
01448 BD_USED_NTRY(free_idx) = FALSE;
01449 }
01450 }
01451
01452 TRACE (Func_Exit, "ntr_array_in_bd_tbl", NULL);
01453
01454 return(bd_idx);
01455
01456 }
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476 int reserve_array_ntry (int rank)
01477
01478 {
01479 int bd_idx;
01480 int i;
01481 int size;
01482 long *tbl_idx;
01483
01484
01485 TRACE (Func_Entry, "reserve_array_ntry", NULL);
01486
01487 size = ++rank;
01488 bd_idx = BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX);
01489
01490 while (bd_idx != NULL_IDX && size > BD_NTRY_SIZE(bd_idx)) {
01491 bd_idx = BD_NEXT_FREE_NTRY(bd_idx);
01492 }
01493
01494 if (bd_idx == NULL_IDX) {
01495 bd_idx = bounds_tbl_idx + 1;
01496 TBL_REALLOC_CK(bounds_tbl, size);
01497 }
01498 else if (BD_NTRY_SIZE(bd_idx) > size) {
01499 BD_NTRY_SIZE(bd_idx) = BD_NTRY_SIZE(bd_idx) - size;
01500 bd_idx = size + bd_idx;
01501 }
01502 else {
01503 BD_NEXT_FREE_NTRY(BD_FREE_LIST_IDX) = BD_NEXT_FREE_NTRY(bd_idx);
01504 }
01505
01506 tbl_idx = ((long *) (&bounds_tbl[bd_idx]));
01507
01508 for (i = 0; i < NUM_BD_WDS * size; i++) {
01509 *(tbl_idx) = 0;
01510 tbl_idx++;
01511 }
01512
01513 BD_NTRY_SIZE(bd_idx) = size;
01514 BD_USED_NTRY(bd_idx) = TRUE;
01515
01516 TRACE (Func_Exit, "reserve_array_ntry", NULL);
01517
01518 return(bd_idx);
01519
01520 }
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539 void init_sytb()
01540
01541 {
01542
01543 TRACE (Func_Entry, "init_sytb", NULL);
01544
01545
01546
01547 # ifdef _DEBUG
01548 if (sizeof(attr_list_tbl_type) != (NUM_AL_WDS * HOST_BYTES_PER_WORD)) {
01549 PRINTMSG(1, 138, Internal, 0, "Attribute list table");
01550 }
01551
01552 if (sizeof(attr_tbl_type) != (NUM_AT_WDS * HOST_BYTES_PER_WORD)) {
01553 PRINTMSG(1, 138, Internal, 0, "Attribute table");
01554 }
01555
01556 if (sizeof(bounds_tbl_type) != (NUM_BD_WDS * HOST_BYTES_PER_WORD)) {
01557 PRINTMSG(1, 138, Internal, 0, "Bounds table");
01558 }
01559
01560 if (sizeof(file_path_tbl_type) != (NUM_FP_WDS * HOST_BYTES_PER_WORD)) {
01561 PRINTMSG(1, 138, Internal, 0, "File path table");
01562 }
01563
01564 if (sizeof(loc_name_tbl_type) != (NUM_LN_WDS * HOST_BYTES_PER_WORD)) {
01565 PRINTMSG(1, 138, Internal, 0, "Local name table");
01566 }
01567
01568 if (sizeof(mod_link_tbl_type) != (NUM_ML_WDS * HOST_BYTES_PER_WORD)) {
01569 PRINTMSG(1, 138, Internal, 0, "Module link table");
01570 }
01571
01572 # if 0
01573 if (sizeof(mod_tbl_type) != (NUM_MD_WDS * HOST_BYTES_PER_WORD)) {
01574 PRINTMSG(1, 138, Internal, 0, "Module table");
01575 }
01576 # endif
01577
01578 if (sizeof(scp_tbl_type) != (NUM_SCP_WDS * HOST_BYTES_PER_WORD)) {
01579 PRINTMSG(1, 138, Internal, 0, "Scope table");
01580 }
01581
01582 if (sizeof(pdg_link_tbl_type) != (NUM_PDG_WDS * HOST_BYTES_PER_WORD)) {
01583 PRINTMSG(1, 138, Internal, 0, "Pdg link table");
01584 }
01585
01586 if (sizeof(stor_blk_tbl_type) != (NUM_SB_WDS * HOST_BYTES_PER_WORD)) {
01587 PRINTMSG(1, 138, Internal, 0, "Storage block table");
01588 }
01589
01590 if (sizeof(sec_name_tbl_type) != (NUM_SN_WDS * HOST_BYTES_PER_WORD)) {
01591 PRINTMSG(1, 138, Internal, 0, "Secondary name table");
01592 }
01593
01594 if (sizeof(ir_tbl_type) != (NUM_IR_WDS * HOST_BYTES_PER_WORD)) {
01595 PRINTMSG(1, 138, Internal, 0, "IR table");
01596 }
01597
01598 if (sizeof(ir_list_tbl_type) != (NUM_IL_WDS * HOST_BYTES_PER_WORD)) {
01599 PRINTMSG(1, 138, Internal, 0, "IR list table");
01600 }
01601
01602 if (sizeof(sh_tbl_type) != (NUM_SH_WDS * HOST_BYTES_PER_WORD)) {
01603 PRINTMSG(1, 138, Internal, 0, "statement header table");
01604 }
01605
01606 if (sizeof(rename_only_tbl_type) != (NUM_RO_WDS * HOST_BYTES_PER_WORD)) {
01607 PRINTMSG(1, 138, Internal, 0, "rename only table");
01608 }
01609
01610 if (sizeof(type_tbl_type) != (NUM_TYP_WDS * HOST_BYTES_PER_WORD)) {
01611 PRINTMSG(1, 138, Internal, 0, "type table");
01612 }
01613
01614 if (sizeof(global_line_tbl_type) != (NUM_GL_WDS * HOST_BYTES_PER_WORD)) {
01615 PRINTMSG(1, 138, Internal, 0, "global line table");
01616 }
01617
01618 if (sizeof(global_name_tbl_type) != (NUM_GN_WDS * HOST_BYTES_PER_WORD)) {
01619 PRINTMSG(1, 138, Internal, 0, "global name table");
01620 }
01621 # endif
01622
01623
01624
01625
01626
01627
01628
01629 CREATE_ID(TOKEN_ID(main_token),
01630 UNNAMED_PROGRAM_NAME,
01631 UNNAMED_PROGRAM_NAME_LEN);
01632
01633 TOKEN_LEN(main_token) = UNNAMED_PROGRAM_NAME_LEN;
01634 TOKEN_LINE(main_token) = 1;
01635 TOKEN_COLUMN(main_token) = 1;
01636 TOKEN_VALUE(main_token) = Tok_Id;
01637 TOKEN_KIND_STR(main_token)[0] = EOS;
01638 TOKEN_KIND_LEN(main_token) = 0;
01639
01640
01641
01642 stmt_start_line = 1;
01643 stmt_start_col = 1;
01644
01645 TRACE (Func_Exit, "init_sytb", NULL);
01646
01647 return;
01648
01649 }
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672 int ntr_const_tbl (int type_idx,
01673 boolean extra_zero_word,
01674 long_type *constant)
01675
01676 {
01677 register int const_idx;
01678 #ifdef KEY
01679 long64 const_word_len = 0;
01680 register int i;
01681 long64 input_word_len = 0;
01682 #else
01683 long64 const_word_len;
01684 register int i;
01685 long64 input_word_len;
01686 #endif
01687 size_offset_type length;
01688 register int pool_idx;
01689 int num_long_types;
01690
01691
01692
01693
01694
01695
01696
01697 #if (defined(_HOST_OS_UNICOS) && defined(_TARGET_OS_UNICOS)) || \
01698 (defined(_HOST_OS_MAX) && defined(_TARGET_OS_MAX)) || \
01699 (defined(_HOST_OS_SOLARIS) && defined(_TARGET_OS_SOLARIS)) || \
01700 ((defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX) || defined(_HOST_OS_DARWIN)) && (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN)))
01701
01702
01703
01704
01705
01706
01707 union integer_and_real { long integer_form;
01708
01709 #ifdef _TARGET_OS_MAX
01710 double real_form;
01711 #else
01712 float real_form;
01713 #endif
01714 };
01715
01716 union integer_and_real value;
01717 union integer_and_real high_cn;
01718 union integer_and_real low_cn;
01719 union integer_and_real mid_cn;
01720
01721 #endif
01722
01723
01724 TRACE (Func_Entry, "ntr_const_tbl", NULL);
01725
01726 switch(TYP_TYPE(type_idx)) {
01727
01728 case Typeless:
01729
01730 input_word_len = STORAGE_WORD_SIZE(TYP_BIT_LEN(type_idx));
01731
01732 if (extra_zero_word || (input_word_len == 0)) {
01733 const_word_len = input_word_len + 1;
01734 extra_zero_word = TRUE;
01735 }
01736 else {
01737 const_word_len = input_word_len;
01738 }
01739 break;
01740
01741
01742 case Character:
01743
01744 input_word_len = TARGET_BYTES_TO_WORDS(((long)
01745 CN_INT_TO_C(TYP_IDX(type_idx))));
01746
01747 if (extra_zero_word || (input_word_len == 0)) {
01748 const_word_len = input_word_len + 1;
01749 extra_zero_word = TRUE;
01750 }
01751 else {
01752 const_word_len = input_word_len;
01753 }
01754 break;
01755
01756
01757 case Integer:
01758 case Real:
01759 case Logical:
01760
01761 const_word_len =
01762 TARGET_BITS_TO_WORDS(storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
01763 input_word_len = const_word_len;
01764 break;
01765
01766
01767 case Complex:
01768
01769 const_word_len =
01770 TARGET_BITS_TO_WORDS(storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
01771
01772 # if defined(_TARGET_OS_MAX) || defined(_WHIRL_HOST64_TARGET64)
01773
01774 if (TYP_LINEAR(type_idx) == Complex_4) {
01775 const_word_len = 2;
01776 }
01777
01778 # endif
01779
01780 input_word_len = const_word_len;
01781 break;
01782
01783
01784
01785
01786 case Structure:
01787
01788 length.fld = ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));;
01789 length.idx = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));;
01790
01791 BITS_TO_WORDS(length, TARGET_BITS_PER_WORD);
01792
01793
01794
01795 const_word_len = F_INT_TO_C(length.constant, TYP_LINEAR(length.type_idx));
01796
01797 if (length.fld == CN_Tbl_Idx) {
01798 const_word_len = CN_INT_TO_C(length.idx);
01799
01800 if (const_word_len == 0) {
01801 const_word_len = 1;
01802 extra_zero_word = TRUE;
01803 }
01804 }
01805 else {
01806 PRINTMSG(AT_DEF_LINE(TYP_IDX(type_idx)), 1201, Internal,
01807 AT_DEF_COLUMN(TYP_IDX(type_idx)),
01808 AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
01809 }
01810
01811 input_word_len = const_word_len;
01812 break;
01813 }
01814
01815
01816 if (constant != NULL_IDX) {
01817
01818 if (TYP_TYPE(type_idx) == Integer || TYP_TYPE(type_idx) == Real) {
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829 num_long_types = num_host_wds[TYP_LINEAR(type_idx)];
01830
01831
01832
01833
01834 if (sizeof(long_type) == sizeof(long long) &&
01835 num_long_types != 1) {
01836 num_long_types = 0;
01837 }
01838
01839 if (TYP_TYPE(type_idx) == Real &&
01840 num_long_types != 1 &&
01841 num_long_types != 2) {
01842
01843 if (target_ieee) {
01844
01845 if (! is_normal(type_idx, constant)) {
01846 const_idx = ntr_abnormal_ieee_const(type_idx,
01847 constant);
01848 goto FOUND;
01849 }
01850 }
01851 else {
01852
01853 if (! pvp_isnormal(type_idx, constant)) {
01854 const_idx = ntr_unshared_const_tbl(type_idx,
01855 FALSE,
01856 constant);
01857 goto FOUND;
01858 }
01859 }
01860 }
01861
01862 # ifdef _DEBUG
01863 if (dump_flags.constant_bits) {
01864 long neg_one = -1;
01865 write(1,constant,
01866 sizeof(long_type)*num_host_wds[TYP_LINEAR(type_idx)]);
01867 write(1,&neg_one, 4);
01868 }
01869 # endif
01870 const_idx = insert_constant(type_idx,
01871 constant,
01872 num_long_types);
01873
01874 if (CN_POOL_IDX(const_idx) != NULL_IDX) {
01875 goto FOUND;
01876 }
01877 else {
01878 goto ATTACH_POOL_IDX;
01879 }
01880 }
01881 else {
01882 const_idx = insert_unordered_constant(type_idx,
01883 constant,
01884 input_word_len,
01885 const_word_len);
01886
01887 if (CN_POOL_IDX(const_idx) != NULL_IDX) {
01888 goto FOUND;
01889 }
01890 else {
01891 goto ATTACH_POOL_IDX;
01892 }
01893 }
01894 }
01895
01896
01897
01898
01899
01900
01901 TBL_REALLOC_CK(const_tbl, 1);
01902 CLEAR_TBL_NTRY(const_tbl, const_tbl_idx);
01903 const_idx = const_tbl_idx;
01904
01905 ATTACH_POOL_IDX:
01906
01907 pool_idx = const_pool_idx + 1;
01908
01909 #if defined(_HOST32)
01910
01911 if (DALIGN_TEST_CONDITION(type_idx)) {
01912
01913 while ((((long)&const_pool[pool_idx]) % 8) != 0) {
01914 pool_idx++;
01915 const_pool_idx++;
01916 }
01917 }
01918
01919 #endif
01920
01921
01922 CN_POOL_IDX(const_idx) = pool_idx;
01923
01924 if ((const_pool_idx += const_word_len) >= const_pool_size) {
01925 const_pool_size = const_pool_size +
01926 ( ( ( (const_pool_idx - const_pool_size + 1) /
01927 const_pool_inc) + 1) * const_pool_inc);
01928 MEM_REALLOC (const_pool, const_pool_type, const_pool_size);
01929 }
01930
01931 CN_TYPE_IDX(const_idx) = type_idx;
01932 CN_EXTRA_ZERO_WORD(const_idx) = extra_zero_word;
01933
01934
01935
01936
01937
01938 if (const_word_len == 0) {
01939
01940
01941
01942
01943 }
01944 else if (constant != NULL_IDX) {
01945 const_pool[const_pool_idx] = 0L;
01946
01947 if (TYP_TYPE(type_idx) == Character) {
01948
01949 if (extra_zero_word) {
01950 const_pool[const_pool_idx - 1] = 0L;
01951 }
01952
01953 strncpy((char *) &CN_CONST(const_idx),
01954 (char *) constant,
01955 (long) CN_INT_TO_C(TYP_IDX(type_idx)));
01956 }
01957 else {
01958 for (i = 0; i < input_word_len; i++) {
01959 const_pool[pool_idx + i] = constant[i];
01960 }
01961 }
01962 }
01963 else {
01964
01965 for (i = pool_idx; i <= const_pool_idx; i++) {
01966 const_pool[i] = 0L;
01967 }
01968 }
01969
01970
01971 FOUND:
01972
01973 # if 0
01974 printf("************************************************************\n");
01975 dump_cn_tree(cn_root_idx[TYP_LINEAR(type_idx)],
01976 type_idx,
01977 0);
01978 # endif
01979
01980
01981 TRACE (Func_Exit, "ntr_const_tbl", NULL);
01982
01983 return (const_idx);
01984
01985 }
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003 static int insert_constant(int type_idx,
02004 long_type *constant,
02005 int num_long_types)
02006
02007 {
02008
02009 int balance_factor;
02010 int cn_idx = NULL_IDX;
02011 int idx = NULL_IDX;
02012 int idx_B;
02013 int idx_C;
02014 int last_unbalanced_idx;
02015 int unbalanced_parent_idx = NULL_IDX;
02016 int previous_idx = NULL_IDX;
02017 int root;
02018 int matched_cn_idx = NULL_IDX;
02019
02020 TRACE (Func_Entry, "insert_constant", NULL);
02021
02022 root = cn_root_idx[TYP_LINEAR(type_idx)];
02023
02024 if (root == NULL_IDX) {
02025
02026
02027 TBL_REALLOC_CK(const_tbl, 1);
02028 CLEAR_TBL_NTRY(const_tbl, const_tbl_idx);
02029 cn_idx = const_tbl_idx;
02030
02031 cn_root_idx[TYP_LINEAR(type_idx)] = cn_idx;
02032 goto EXIT;
02033 }
02034
02035 last_unbalanced_idx = root;
02036 idx = root;
02037
02038 switch (num_long_types) {
02039 case 1:
02040 while (idx) {
02041 if (CN_BALANCE_FACTOR(idx) != 0) {
02042 last_unbalanced_idx = idx;
02043 unbalanced_parent_idx = previous_idx;
02044 }
02045
02046 if (*constant < CN_CONST(idx)) {
02047 previous_idx = idx;
02048 idx = CN_LEFT_CHILD(idx);
02049 }
02050 else if (*constant > CN_CONST(idx)) {
02051 previous_idx = idx;
02052 idx = CN_RIGHT_CHILD(idx);
02053 }
02054 else if (type_idx < CN_TYPE_IDX(idx)) {
02055
02056 matched_cn_idx = idx;
02057 previous_idx = idx;
02058 idx = CN_LEFT_CHILD(idx);
02059 }
02060 else if (type_idx > CN_TYPE_IDX(idx)) {
02061
02062 matched_cn_idx = idx;
02063 previous_idx = idx;
02064 idx = CN_RIGHT_CHILD(idx);
02065 }
02066 else {
02067
02068 cn_idx = idx;
02069 goto EXIT;
02070 }
02071 }
02072 break;
02073
02074 case 2:
02075 while (idx) {
02076 if (CN_BALANCE_FACTOR(idx) != 0) {
02077 last_unbalanced_idx = idx;
02078 unbalanced_parent_idx = previous_idx;
02079 }
02080
02081 if (*(long long *)constant < *(long long *)&CN_CONST(idx)) {
02082 previous_idx = idx;
02083 idx = CN_LEFT_CHILD(idx);
02084 }
02085 else if (*(long long *)constant > *(long long *)&CN_CONST(idx)) {
02086 previous_idx = idx;
02087 idx = CN_RIGHT_CHILD(idx);
02088 }
02089 else if (type_idx < CN_TYPE_IDX(idx)) {
02090
02091 matched_cn_idx = idx;
02092 previous_idx = idx;
02093 idx = CN_LEFT_CHILD(idx);
02094 }
02095 else if (type_idx > CN_TYPE_IDX(idx)) {
02096
02097 matched_cn_idx = idx;
02098 previous_idx = idx;
02099 idx = CN_RIGHT_CHILD(idx);
02100 }
02101 else {
02102
02103 cn_idx = idx;
02104 goto EXIT;
02105 }
02106 }
02107 break;
02108
02109 default:
02110 while (idx) {
02111 if (CN_BALANCE_FACTOR(idx) != 0) {
02112 last_unbalanced_idx = idx;
02113 unbalanced_parent_idx = previous_idx;
02114 }
02115
02116 if (compare_value_to_cn(constant, idx, Lt_Opr)) {
02117 previous_idx = idx;
02118 idx = CN_LEFT_CHILD(idx);
02119 }
02120 else if (compare_value_to_cn(constant, idx, Gt_Opr)) {
02121 previous_idx = idx;
02122 idx = CN_RIGHT_CHILD(idx);
02123 }
02124 else if (type_idx < CN_TYPE_IDX(idx)) {
02125
02126 matched_cn_idx = idx;
02127 previous_idx = idx;
02128 idx = CN_LEFT_CHILD(idx);
02129 }
02130 else if (type_idx > CN_TYPE_IDX(idx)) {
02131
02132 matched_cn_idx = idx;
02133 previous_idx = idx;
02134 idx = CN_RIGHT_CHILD(idx);
02135 }
02136 else {
02137
02138 cn_idx = idx;
02139 goto EXIT;
02140 }
02141 }
02142 break;
02143 }
02144
02145
02146 TBL_REALLOC_CK(const_tbl, 1);
02147 CLEAR_TBL_NTRY(const_tbl, const_tbl_idx);
02148 cn_idx = const_tbl_idx;
02149
02150 if (matched_cn_idx != NULL_IDX) {
02151 COPY_TBL_NTRY(const_tbl, cn_idx, matched_cn_idx);
02152 CN_LEFT_CHILD(cn_idx) = NULL_IDX;
02153 CN_RIGHT_CHILD(cn_idx) = NULL_IDX;
02154 CN_TYPE_IDX(cn_idx) = type_idx;
02155 }
02156
02157 switch (num_long_types) {
02158 case 1:
02159 if (*constant > CN_CONST(previous_idx)) {
02160
02161 CN_RIGHT_CHILD(previous_idx) = cn_idx;
02162 }
02163 else if (*constant < CN_CONST(previous_idx)) {
02164
02165 CN_LEFT_CHILD(previous_idx) = cn_idx;
02166 }
02167 else if (type_idx > CN_TYPE_IDX(previous_idx)) {
02168
02169 CN_RIGHT_CHILD(previous_idx) = cn_idx;
02170 }
02171 else {
02172
02173 CN_LEFT_CHILD(previous_idx) = cn_idx;
02174 }
02175
02176 if (*constant > CN_CONST(last_unbalanced_idx)) {
02177 idx = CN_RIGHT_CHILD(last_unbalanced_idx);
02178 idx_B = idx;
02179 balance_factor = -1;
02180 }
02181 else if (*constant < CN_CONST(last_unbalanced_idx)) {
02182 idx = CN_LEFT_CHILD(last_unbalanced_idx);
02183 idx_B = idx;
02184 balance_factor = 1;
02185 }
02186 else if (type_idx > CN_TYPE_IDX(last_unbalanced_idx)) {
02187 idx = CN_RIGHT_CHILD(last_unbalanced_idx);
02188 idx_B = idx;
02189 balance_factor = -1;
02190 }
02191 else {
02192 idx = CN_LEFT_CHILD(last_unbalanced_idx);
02193 idx_B = idx;
02194 balance_factor = 1;
02195 }
02196
02197 while (idx != cn_idx) {
02198 if (*constant > CN_CONST(idx)) {
02199 CN_BALANCE_FACTOR(idx) = -1;
02200 idx = CN_RIGHT_CHILD(idx);
02201 }
02202 else if (*constant < CN_CONST(idx)) {
02203 CN_BALANCE_FACTOR(idx) = 1;
02204 idx = CN_LEFT_CHILD(idx);
02205 }
02206 else if (type_idx > CN_TYPE_IDX(idx)) {
02207 CN_BALANCE_FACTOR(idx) = -1;
02208 idx = CN_RIGHT_CHILD(idx);
02209 }
02210 else {
02211 CN_BALANCE_FACTOR(idx) = 1;
02212 idx = CN_LEFT_CHILD(idx);
02213 }
02214 }
02215 break;
02216
02217 case 2:
02218 if (*(long long *)constant > *(long long *)&CN_CONST(previous_idx)) {
02219
02220 CN_RIGHT_CHILD(previous_idx) = cn_idx;
02221 }
02222 else if (*(long long *)constant <
02223 *(long long *)&CN_CONST(previous_idx)) {
02224
02225 CN_LEFT_CHILD(previous_idx) = cn_idx;
02226 }
02227 else if (type_idx > CN_TYPE_IDX(previous_idx)) {
02228
02229 CN_RIGHT_CHILD(previous_idx) = cn_idx;
02230 }
02231 else {
02232
02233 CN_LEFT_CHILD(previous_idx) = cn_idx;
02234 }
02235
02236 if (*(long long *)constant >
02237 *(long long *)&CN_CONST(last_unbalanced_idx)) {
02238 idx = CN_RIGHT_CHILD(last_unbalanced_idx);
02239 idx_B = idx;
02240 balance_factor = -1;
02241 }
02242 else if (*(long long *)constant <
02243 *(long long *)&CN_CONST(last_unbalanced_idx)) {
02244 idx = CN_LEFT_CHILD(last_unbalanced_idx);
02245 idx_B = idx;
02246 balance_factor = 1;
02247 }
02248 else if (type_idx > CN_TYPE_IDX(last_unbalanced_idx)) {
02249 idx = CN_RIGHT_CHILD(last_unbalanced_idx);
02250 idx_B = idx;
02251 balance_factor = -1;
02252 }
02253 else {
02254 idx = CN_LEFT_CHILD(last_unbalanced_idx);
02255 idx_B = idx;
02256 balance_factor = 1;
02257 }
02258
02259 while (idx != cn_idx) {
02260 if (*(long long *)constant > *(long long *)&CN_CONST(idx)) {
02261 CN_BALANCE_FACTOR(idx) = -1;
02262 idx = CN_RIGHT_CHILD(idx);
02263 }
02264 else if (*(long long *)constant < *(long long *)&CN_CONST(idx)) {
02265 CN_BALANCE_FACTOR(idx) = 1;
02266 idx = CN_LEFT_CHILD(idx);
02267 }
02268 else if (type_idx > CN_TYPE_IDX(idx)) {
02269 CN_BALANCE_FACTOR(idx) = -1;
02270 idx = CN_RIGHT_CHILD(idx);
02271 }
02272 else {
02273 CN_BALANCE_FACTOR(idx) = 1;
02274 idx = CN_LEFT_CHILD(idx);
02275 }
02276 }
02277 break;
02278
02279 default:
02280 if (compare_value_to_cn(constant, previous_idx, Gt_Opr)) {
02281
02282 CN_RIGHT_CHILD(previous_idx) = cn_idx;
02283 }
02284 else if (compare_value_to_cn(constant, previous_idx, Lt_Opr)) {
02285
02286 CN_LEFT_CHILD(previous_idx) = cn_idx;
02287 }
02288 else if (type_idx > CN_TYPE_IDX(previous_idx)) {
02289
02290 CN_RIGHT_CHILD(previous_idx) = cn_idx;
02291 }
02292 else {
02293
02294 CN_LEFT_CHILD(previous_idx) = cn_idx;
02295 }
02296
02297
02298 if (compare_value_to_cn(constant, last_unbalanced_idx, Gt_Opr)) {
02299 idx = CN_RIGHT_CHILD(last_unbalanced_idx);
02300 idx_B = idx;
02301 balance_factor = -1;
02302 }
02303 else if (compare_value_to_cn(constant, last_unbalanced_idx, Lt_Opr)) {
02304 idx = CN_LEFT_CHILD(last_unbalanced_idx);
02305 idx_B = idx;
02306 balance_factor = 1;
02307 }
02308 else if (type_idx > CN_TYPE_IDX(last_unbalanced_idx)) {
02309 idx = CN_RIGHT_CHILD(last_unbalanced_idx);
02310 idx_B = idx;
02311 balance_factor = -1;
02312 }
02313 else {
02314 idx = CN_LEFT_CHILD(last_unbalanced_idx);
02315 idx_B = idx;
02316 balance_factor = 1;
02317 }
02318
02319 while (idx != cn_idx) {
02320 if (compare_value_to_cn(constant, idx, Gt_Opr)) {
02321 CN_BALANCE_FACTOR(idx) = -1;
02322 idx = CN_RIGHT_CHILD(idx);
02323 }
02324 else if (compare_value_to_cn(constant, idx, Lt_Opr)) {
02325 CN_BALANCE_FACTOR(idx) = 1;
02326 idx = CN_LEFT_CHILD(idx);
02327 }
02328 else if (type_idx > CN_TYPE_IDX(idx)) {
02329 CN_BALANCE_FACTOR(idx) = -1;
02330 idx = CN_RIGHT_CHILD(idx);
02331 }
02332 else {
02333 CN_BALANCE_FACTOR(idx) = 1;
02334 idx = CN_LEFT_CHILD(idx);
02335 }
02336 }
02337 break;
02338 }
02339
02340 if (CN_BALANCE_FACTOR(last_unbalanced_idx) == 0) {
02341 CN_BALANCE_FACTOR(last_unbalanced_idx) = balance_factor;
02342 goto EXIT;
02343 }
02344
02345 if (CN_BALANCE_FACTOR(last_unbalanced_idx) + balance_factor == 0) {
02346 CN_BALANCE_FACTOR(last_unbalanced_idx) = 0;
02347 goto EXIT;
02348 }
02349
02350
02351
02352 if (balance_factor == 1) {
02353
02354 if (CN_BALANCE_FACTOR(idx_B) == 1) {
02355
02356 CN_LEFT_CHILD(last_unbalanced_idx) = CN_RIGHT_CHILD(idx_B);
02357 CN_RIGHT_CHILD(idx_B) = last_unbalanced_idx;
02358 CN_BALANCE_FACTOR(last_unbalanced_idx) = 0;
02359 CN_BALANCE_FACTOR(idx_B) = 0;
02360 }
02361 else {
02362
02363 idx_C = CN_RIGHT_CHILD(idx_B);
02364 CN_RIGHT_CHILD(idx_B) = CN_LEFT_CHILD(idx_C);
02365 CN_LEFT_CHILD(last_unbalanced_idx) = CN_RIGHT_CHILD(idx_C);
02366 CN_LEFT_CHILD(idx_C) = idx_B;
02367 CN_RIGHT_CHILD(idx_C) = last_unbalanced_idx;
02368
02369 if (CN_BALANCE_FACTOR(idx_C) == 1) {
02370
02371 CN_BALANCE_FACTOR(last_unbalanced_idx) = -1;
02372 CN_BALANCE_FACTOR(idx_B) = 0;
02373 }
02374 else if (CN_BALANCE_FACTOR(idx_C) == -1) {
02375
02376 CN_BALANCE_FACTOR(idx_B) = 1;
02377 CN_BALANCE_FACTOR(last_unbalanced_idx) = 0;
02378 }
02379 else {
02380
02381 CN_BALANCE_FACTOR(idx_B) = 0;
02382 CN_BALANCE_FACTOR(last_unbalanced_idx) = 0;
02383 }
02384
02385 CN_BALANCE_FACTOR(idx_C) = 0;
02386 idx_B = idx_C;
02387 }
02388 }
02389 else {
02390
02391 if (CN_BALANCE_FACTOR(idx_B) == -1) {
02392
02393 CN_RIGHT_CHILD(last_unbalanced_idx) = CN_LEFT_CHILD(idx_B);
02394 CN_LEFT_CHILD(idx_B) = last_unbalanced_idx;
02395 CN_BALANCE_FACTOR(last_unbalanced_idx) = 0;
02396 CN_BALANCE_FACTOR(idx_B) = 0;
02397 }
02398 else {
02399
02400 idx_C = CN_LEFT_CHILD(idx_B);
02401 CN_LEFT_CHILD(idx_B) = CN_RIGHT_CHILD(idx_C);
02402 CN_RIGHT_CHILD(last_unbalanced_idx) = CN_LEFT_CHILD(idx_C);
02403 CN_RIGHT_CHILD(idx_C) = idx_B;
02404 CN_LEFT_CHILD(idx_C) = last_unbalanced_idx;
02405
02406 if (CN_BALANCE_FACTOR(idx_C) == -1) {
02407
02408 CN_BALANCE_FACTOR(last_unbalanced_idx) = 1;
02409 CN_BALANCE_FACTOR(idx_B) = 0;
02410 }
02411 else if (CN_BALANCE_FACTOR(idx_C) == 1) {
02412
02413 CN_BALANCE_FACTOR(idx_B) = -1;
02414 CN_BALANCE_FACTOR(last_unbalanced_idx) = 0;
02415 }
02416 else {
02417
02418 CN_BALANCE_FACTOR(idx_B) = 0;
02419 CN_BALANCE_FACTOR(last_unbalanced_idx) = 0;
02420 }
02421
02422 CN_BALANCE_FACTOR(idx_C) = 0;
02423 idx_B = idx_C;
02424 }
02425 }
02426
02427 if (unbalanced_parent_idx == 0) {
02428 cn_root_idx[TYP_LINEAR(type_idx)] = idx_B;
02429 }
02430 else if (last_unbalanced_idx == CN_LEFT_CHILD(unbalanced_parent_idx)) {
02431 CN_LEFT_CHILD(unbalanced_parent_idx) = idx_B;
02432 }
02433 else if (last_unbalanced_idx == CN_RIGHT_CHILD(unbalanced_parent_idx)) {
02434 CN_RIGHT_CHILD(unbalanced_parent_idx) = idx_B;
02435 }
02436
02437 EXIT:
02438
02439 TRACE (Func_Exit, "insert_constant", NULL);
02440
02441 return(cn_idx);
02442
02443 }
02444
02445
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461 static int insert_unordered_constant(int type_idx,
02462 long_type *constant,
02463 int input_word_len,
02464 int const_word_len)
02465
02466 {
02467 #ifdef KEY
02468 int cn_idx = 0;
02469 #else
02470 int cn_idx;
02471 #endif
02472 int i;
02473 int idx;
02474 int pool_idx;
02475 int prev_idx;
02476 int root;
02477
02478 TRACE (Func_Entry, "insert_unordered_constant", NULL);
02479
02480 root = cn_root_idx[TYP_LINEAR(type_idx)];
02481
02482 if (root == NULL_IDX) {
02483
02484
02485 TBL_REALLOC_CK(const_tbl, 1);
02486 CLEAR_TBL_NTRY(const_tbl, const_tbl_idx);
02487 cn_idx = const_tbl_idx;
02488
02489 cn_root_idx[TYP_LINEAR(type_idx)] = cn_idx;
02490 goto EXIT;
02491 }
02492
02493 prev_idx = 0;
02494 idx = root;
02495
02496 if (TYP_TYPE(type_idx) == Typeless) {
02497 while (idx) {
02498 if (type_idx == CN_TYPE_IDX(idx)) {
02499 if (CN_BOZ_CONSTANT(idx) ||
02500 CN_BOOLEAN_CONSTANT(idx) ||
02501 CN_HOLLERITH_TYPE(idx) != Not_Hollerith) {
02502 continue;
02503 }
02504 pool_idx = CN_POOL_IDX(idx);
02505 for (i = 0; i < input_word_len; i++) {
02506 if (const_pool[pool_idx + i] != constant[i]) {
02507 break;
02508 }
02509 }
02510 if (i == input_word_len &&
02511 (input_word_len == const_word_len ||
02512 const_pool[pool_idx + i] == 0)) {
02513 cn_idx = idx;
02514 goto EXIT;
02515 }
02516 }
02517
02518 prev_idx = idx;
02519 idx = CN_LEFT_CHILD(idx);
02520 }
02521 }
02522 else {
02523 while (idx) {
02524 if (type_idx == CN_TYPE_IDX(idx)) {
02525 pool_idx = CN_POOL_IDX(idx);
02526
02527 for (i = 0; i < input_word_len; i++) {
02528
02529 if (const_pool[pool_idx + i] != constant[i]) {
02530 break;
02531 }
02532 }
02533
02534 if (i == input_word_len &&
02535 (input_word_len == const_word_len ||
02536 const_pool[pool_idx + i] == 0)) {
02537 cn_idx = idx;
02538 goto EXIT;
02539 }
02540 }
02541
02542 prev_idx = idx;
02543 idx = CN_LEFT_CHILD(idx);
02544 }
02545 }
02546
02547 if (idx == NULL_IDX) {
02548 TBL_REALLOC_CK(const_tbl, 1);
02549 CLEAR_TBL_NTRY(const_tbl, const_tbl_idx);
02550 cn_idx = const_tbl_idx;
02551 CN_LEFT_CHILD(prev_idx) = cn_idx;
02552 }
02553
02554 EXIT:
02555
02556 TRACE (Func_Exit, "insert_unordered_constant", NULL);
02557
02558 return(cn_idx);
02559
02560 }
02561
02562
02563
02564
02565
02566
02567
02568
02569
02570
02571
02572
02573
02574
02575
02576
02577
02578 static void dump_cn_tree(int root,
02579 int type_idx,
02580 int indent)
02581
02582 {
02583 int i;
02584 char shift[80];
02585 char str[80];
02586
02587 TRACE (Func_Entry, "dump_cn_tree", NULL);
02588
02589 if (root != NULL_IDX) {
02590 for (i = 0; i < 3 * indent; i++) {
02591 shift[i] = ' ';
02592 if (i == 79)
02593 break;
02594 }
02595 shift[i] = '\0';
02596
02597 printf("%s%s %c\n", shift, convert_to_string(&CN_CONST(root),
02598 type_idx,
02599 str),
02600 TYP_DESC(CN_TYPE_IDX(root)) == Default_Typed ?
02601 'D' : 'K');
02602
02603 if (CN_LEFT_CHILD(root) != NULL_IDX ||
02604 CN_RIGHT_CHILD(root) != NULL_IDX) {
02605 dump_cn_tree(CN_LEFT_CHILD(root), type_idx, indent+1);
02606 dump_cn_tree(CN_RIGHT_CHILD(root), type_idx, indent+1);
02607 }
02608 }
02609 else {
02610 printf("\n");
02611 }
02612
02613 TRACE (Func_Exit, "dump_cn_tree", NULL);
02614
02615 return;
02616
02617 }
02618
02619
02620
02621
02622
02623
02624
02625
02626
02627
02628
02629
02630
02631
02632
02633
02634
02635
02636
02637 int ntr_boz_const_tbl(int type_idx,
02638 long_type *constant)
02639
02640 {
02641 register int const_idx;
02642 register int i;
02643 register int pool_idx;
02644 register int word_len;
02645
02646
02647 TRACE (Func_Entry, "ntr_boz_const_tbl", NULL);
02648
02649 word_len = STORAGE_WORD_SIZE(TYP_BIT_LEN(type_idx));
02650
02651 for (const_idx = 1; const_idx <= const_tbl_idx; const_idx++) {
02652
02653 if (CN_BOZ_CONSTANT(const_idx) &&
02654 CN_TYPE_IDX(const_idx) == type_idx) {
02655
02656 pool_idx = CN_POOL_IDX(const_idx);
02657
02658 for (i = 0; i < word_len; i++) {
02659
02660 if (const_pool[pool_idx + i] != constant[i]) {
02661 break;
02662 }
02663 }
02664
02665 if (i == word_len) {
02666 goto FOUND;
02667 }
02668 }
02669 }
02670
02671 TBL_REALLOC_CK(const_tbl, 1);
02672 CLEAR_TBL_NTRY(const_tbl, const_tbl_idx);
02673 pool_idx = const_pool_idx + 1;
02674
02675 CN_POOL_IDX(const_tbl_idx) = pool_idx;
02676
02677 if ((const_pool_idx += word_len) >= const_pool_size) {
02678 const_pool_size = const_pool_size +
02679 ( ( ( (const_pool_idx - const_pool_size + 1) /
02680 const_pool_inc) + 1) * const_pool_inc);
02681 MEM_REALLOC (const_pool, const_pool_type, const_pool_size);
02682 }
02683
02684 const_idx = const_tbl_idx;
02685 CN_TYPE_IDX(const_idx) = type_idx;
02686 CN_BOZ_CONSTANT(const_idx) = TRUE;
02687
02688 for (i = 0; i < word_len; i++) {
02689 const_pool[pool_idx + i] = constant[i];
02690 }
02691
02692 FOUND:
02693
02694 TRACE (Func_Exit, "ntr_boz_const_tbl", NULL);
02695
02696 return (const_idx);
02697
02698 }
02699
02700
02701
02702
02703
02704
02705
02706
02707
02708
02709
02710
02711
02712
02713
02714
02715
02716
02717 int ntr_boolean_const_tbl(int type_idx,
02718 long_type *constant)
02719
02720 {
02721 register int const_idx;
02722 register int i;
02723 register int pool_idx;
02724 register int word_len;
02725
02726
02727 TRACE (Func_Entry, "ntr_boolean_const_tbl", NULL);
02728
02729 word_len = STORAGE_WORD_SIZE(TYP_BIT_LEN(type_idx));
02730
02731 for (const_idx = 1; const_idx <= const_tbl_idx; const_idx++) {
02732
02733 if (CN_BOOLEAN_CONSTANT(const_idx) &&
02734 CN_TYPE_IDX(const_idx) == type_idx) {
02735
02736 pool_idx = CN_POOL_IDX(const_idx);
02737
02738 for (i = 0; i < word_len; i++) {
02739
02740 if (const_pool[pool_idx + i] != constant[i]) {
02741 break;
02742 }
02743 }
02744
02745 if (i == word_len) {
02746 goto FOUND;
02747 }
02748 }
02749 }
02750
02751 TBL_REALLOC_CK(const_tbl, 1);
02752 CLEAR_TBL_NTRY(const_tbl, const_tbl_idx);
02753 pool_idx = const_pool_idx + 1;
02754
02755 CN_POOL_IDX(const_tbl_idx) = pool_idx;
02756
02757 if ((const_pool_idx += word_len) >= const_pool_size) {
02758 const_pool_size = const_pool_size +
02759 ( ( ( (const_pool_idx - const_pool_size + 1) /
02760 const_pool_inc) + 1) * const_pool_inc);
02761 MEM_REALLOC (const_pool, const_pool_type, const_pool_size);
02762 }
02763
02764 const_idx = const_tbl_idx;
02765 CN_TYPE_IDX(const_idx) = type_idx;
02766 CN_BOOLEAN_CONSTANT(const_idx) = TRUE;
02767
02768 for (i = 0; i < word_len; i++) {
02769 const_pool[pool_idx + i] = constant[i];
02770 }
02771
02772 FOUND:
02773
02774 TRACE (Func_Exit, "ntr_boolean_const_tbl", NULL);
02775
02776 return (const_idx);
02777
02778 }
02779
02780
02781
02782
02783
02784
02785
02786
02787
02788
02789
02790
02791
02792
02793
02794
02795
02796
02797
02798
02799
02800
02801
02802
02803
02804 int ntr_unshared_const_tbl (int type_idx,
02805 boolean extra_zero_word,
02806 long_type *constant)
02807
02808 {
02809 register int const_idx;
02810 #ifdef KEY
02811 long64 const_word_len = 0;
02812 register int i;
02813 long64 input_word_len = 0;
02814 #else
02815 long64 const_word_len;
02816 register int i;
02817 long64 input_word_len;
02818 #endif
02819 size_offset_type length;
02820 register int pool_idx;
02821
02822
02823 TRACE (Func_Entry, "ntr_unshared_const_tbl", NULL);
02824
02825 switch(TYP_TYPE(type_idx)) {
02826
02827 case Typeless:
02828
02829 input_word_len = STORAGE_WORD_SIZE(TYP_BIT_LEN(type_idx));
02830 const_word_len =
02831 (extra_zero_word) ? input_word_len + 1 : input_word_len;
02832 break;
02833
02834
02835 case Character:
02836
02837 input_word_len = TARGET_BYTES_TO_WORDS(CN_INT_TO_C(TYP_IDX(type_idx)));
02838 const_word_len =
02839 (extra_zero_word) ? input_word_len + 1 : input_word_len;
02840 break;
02841
02842
02843 case Integer:
02844 case Real:
02845 case Logical:
02846
02847 const_word_len =
02848 TARGET_BITS_TO_WORDS(storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
02849 input_word_len = const_word_len;
02850 break;
02851
02852
02853 case Complex:
02854
02855 const_word_len =
02856 TARGET_BITS_TO_WORDS(storage_bit_size_tbl[TYP_LINEAR(type_idx)]);
02857
02858 #if defined(_TARGET_OS_MAX) || defined(_WHIRL_HOST64_TARGET64)
02859
02860 if (TYP_LINEAR(type_idx) == Complex_4) {
02861 const_word_len = 2;
02862 }
02863
02864 #endif
02865 input_word_len = const_word_len;
02866 break;
02867
02868
02869 case Structure:
02870
02871
02872
02873
02874 length.fld = ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));;
02875 length.idx = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));;
02876
02877 BITS_TO_WORDS(length, TARGET_BITS_PER_WORD);
02878
02879 if (length.fld == CN_Tbl_Idx) {
02880 const_word_len = CN_INT_TO_C(length.idx);
02881 }
02882 else {
02883 PRINTMSG(AT_DEF_LINE(TYP_IDX(type_idx)), 1201, Internal,
02884 AT_DEF_COLUMN(TYP_IDX(type_idx)),
02885 AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
02886 }
02887
02888 input_word_len = const_word_len;
02889 break;
02890 }
02891
02892
02893 TBL_REALLOC_CK(const_tbl, 1);
02894 CLEAR_TBL_NTRY(const_tbl, const_tbl_idx);
02895 pool_idx = const_pool_idx + 1;
02896
02897
02898 #if defined(_HOST32)
02899
02900 if (DALIGN_TEST_CONDITION(type_idx)) {
02901
02902 while ((((long)&const_pool[pool_idx]) % 8) != 0) {
02903 pool_idx++;
02904 const_pool_idx++;
02905 }
02906 }
02907
02908 #endif
02909
02910
02911 CN_POOL_IDX(const_tbl_idx) = pool_idx;
02912
02913 if ((const_pool_idx += const_word_len) >= const_pool_size) {
02914 const_pool_size = const_pool_size +
02915 ( ( ( (const_pool_idx - const_pool_size + 1) /
02916 const_pool_inc) + 1) * const_pool_inc);
02917 MEM_REALLOC (const_pool, const_pool_type, const_pool_size);
02918 }
02919
02920 const_idx = const_tbl_idx;
02921 CN_TYPE_IDX(const_idx) = type_idx;
02922 CN_EXTRA_ZERO_WORD(const_idx) = extra_zero_word;
02923
02924
02925
02926
02927
02928 if (const_word_len == 0) {
02929
02930
02931
02932
02933 }
02934 else if (constant != NULL_IDX) {
02935 const_pool[const_pool_idx] = 0L;
02936
02937 if (TYP_TYPE(type_idx) == Character) {
02938
02939 if (extra_zero_word) {
02940 const_pool[const_pool_idx - 1] = 0L;
02941 }
02942 strncpy((char *) &CN_CONST(const_idx),
02943 (char *) constant,
02944 (long) CN_INT_TO_C(TYP_IDX(type_idx)));
02945 }
02946 else {
02947
02948 for (i = 0; i < input_word_len; i++) {
02949 const_pool[pool_idx + i] = constant[i];
02950 }
02951 }
02952 }
02953 else {
02954
02955 for (i = pool_idx; i <= const_pool_idx; i++) {
02956 const_pool[i] = 0L;
02957 }
02958 }
02959
02960 TRACE (Func_Exit, "ntr_unshared_const_tbl", NULL);
02961
02962 return (const_idx);
02963
02964 }
02965
02966
02967
02968
02969
02970
02971
02972
02973
02974
02975
02976
02977
02978
02979
02980
02981
02982
02983
02984
02985
02986 static int ntr_abnormal_ieee_const(int type_idx,
02987 long_type *constant)
02988
02989 {
02990 int const_idx;
02991 #ifdef KEY
02992 int idx = 0;
02993 #else
02994 int idx;
02995 #endif
02996
02997 enum abnormal_value { Real_4_Nan,
02998 Real_8_Nan,
02999 Real_16_Nan,
03000 Real_4_Pos_Inf,
03001 Real_8_Pos_Inf,
03002 Real_16_Pos_Inf,
03003 Real_4_Neg_Inf,
03004 Real_8_Neg_Inf,
03005 Real_16_Neg_Inf,
03006 Real_4_Subnormal,
03007 Real_8_Subnormal,
03008 Real_16_Subnormal,
03009 Real_4_Pos_Zero,
03010 Real_8_Pos_Zero,
03011 Real_16_Pos_Zero,
03012 Real_4_Neg_Zero,
03013 Real_8_Neg_Zero,
03014 Real_16_Neg_Zero
03015 };
03016
03017
03018 TRACE (Func_Entry, "ntr_abnormal_ieee_const", NULL);
03019
03020
03021 switch (TYP_LINEAR(type_idx)) {
03022
03023 case Real_4:
03024
03025 switch (fp_classify(type_idx, constant)) {
03026
03027 case FP_SGI_NAN:
03028 idx = (int) Real_4_Nan;
03029 break;
03030
03031 case FP_SGI_INFINITE:
03032 idx = (sign_bit(type_idx, constant) == 0) ?
03033 (int) Real_4_Pos_Inf : (int) Real_4_Neg_Inf;
03034 break;
03035
03036 case FP_SGI_SUBNORMAL:
03037 idx = (int) Real_4_Subnormal;
03038 break;
03039
03040 case FP_SGI_ZERO:
03041 idx = (sign_bit(type_idx, constant) == 0) ?
03042 (int) Real_4_Pos_Zero : (int) Real_4_Neg_Zero;
03043 break;
03044
03045 default:
03046 PRINTMSG(stmt_start_line, 179, Internal, stmt_start_col,
03047 "ntr_abnormal_ieee_const");
03048 }
03049
03050 break;
03051
03052
03053 case Real_8:
03054
03055 switch (fp_classify(type_idx, constant)) {
03056
03057 case FP_SGI_NAN:
03058 idx = (int) Real_8_Nan;
03059 break;
03060
03061 case FP_SGI_INFINITE:
03062 idx = (sign_bit(type_idx, constant) == 0) ?
03063 (int) Real_8_Pos_Inf : (int) Real_8_Neg_Inf;
03064 break;
03065
03066 case FP_SGI_SUBNORMAL:
03067 idx = (int) Real_8_Subnormal;
03068 break;
03069
03070 case FP_SGI_ZERO:
03071 idx = (sign_bit(type_idx, constant) == 0) ?
03072 (int) Real_8_Pos_Zero : (int) Real_8_Neg_Zero;
03073 break;
03074
03075 default:
03076 PRINTMSG(stmt_start_line, 179, Internal, stmt_start_col,
03077 "ntr_abnormal_ieee_const");
03078 }
03079
03080 break;
03081
03082
03083 case Real_16:
03084
03085 switch (fp_classify(type_idx, constant)) {
03086
03087 case FP_SGI_NAN:
03088 idx = (int) Real_16_Nan;
03089 break;
03090
03091 case FP_SGI_INFINITE:
03092 idx = (sign_bit(type_idx, constant) == 0) ?
03093 (int) Real_16_Pos_Inf : (int) Real_16_Neg_Inf;
03094 break;
03095
03096 case FP_SGI_SUBNORMAL:
03097 idx = (int) Real_16_Subnormal;
03098 break;
03099
03100 case FP_SGI_ZERO:
03101 idx = (sign_bit(type_idx, constant) == 0) ?
03102 (int) Real_16_Pos_Zero : (int) Real_16_Neg_Zero;
03103 break;
03104
03105 default:
03106 PRINTMSG(stmt_start_line, 179, Internal, stmt_start_col,
03107 "ntr_abnormal_ieee_const");
03108 }
03109 }
03110
03111 if (ieee_const_tbl_idx[idx] == NULL_IDX) {
03112 const_idx = ntr_unshared_const_tbl(type_idx, FALSE, constant);
03113 ieee_const_tbl_idx[idx] = const_idx;
03114 }
03115 else {
03116 const_idx = ieee_const_tbl_idx[idx];
03117 }
03118
03119 TRACE (Func_Exit, "ntr_abnormal_ieee_const", NULL);
03120
03121 return(const_idx);
03122
03123 }
03124
03125
03126
03127
03128
03129
03130
03131
03132
03133
03134
03135
03136
03137
03138
03139
03140
03141
03142
03143
03144
03145 int srch_host_stor_blk_tbl (token_type *token)
03146
03147 {
03148
03149 int idx = NULL_IDX;
03150 token_type nme_token;
03151 int save_scp_idx;
03152
03153 TRACE (Func_Entry, "srch_host_stor_blk_tbl", NULL);
03154
03155
03156
03157 if (SCP_IS_INTERFACE(curr_scp_idx)) {
03158 return (NULL_IDX);
03159 }
03160
03161 save_scp_idx = curr_scp_idx;
03162
03163 while (idx == NULL_IDX && SCP_PARENT_IDX(curr_scp_idx) != NULL_IDX) {
03164
03165
03166
03167 curr_scp_idx = SCP_PARENT_IDX(curr_scp_idx);
03168
03169 nme_token = *token;
03170 idx = srch_stor_blk_tbl(TOKEN_STR(nme_token),
03171 TOKEN_LEN(nme_token),
03172 curr_scp_idx);
03173 }
03174
03175 curr_scp_idx = save_scp_idx;
03176
03177 TRACE (Func_Exit, "srch_host_stor_blk_tbl", NULL);
03178
03179 return (idx);
03180
03181 }
03182
03183
03184
03185
03186
03187
03188
03189
03190
03191
03192
03193
03194
03195
03196
03197
03198
03199 boolean compare_derived_types(int dt_idx1,
03200 int dt_idx2)
03201
03202 {
03203 int at_idx1;
03204 int at_idx2;
03205 int bit_idx1;
03206 #ifdef KEY
03207 int bit_idx2 = 0;
03208 #else
03209 int bit_idx2;
03210 #endif
03211 boolean check;
03212 int entry_idx1;
03213 #ifdef KEY
03214 int entry_idx2 = 0;
03215 #else
03216 int entry_idx2;
03217 #endif
03218 int id1;
03219 int id2;
03220 int idx;
03221 boolean keep_compare;
03222 int len1;
03223 int len2;
03224 int mod_idx1;
03225 int mod_idx2;
03226 long *name1;
03227 long *name2;
03228 int s_idx1;
03229 int s_idx2;
03230 boolean same;
03231
03232 static long dt_cmp_tbl_size;
03233 static int entry_size;
03234 static long num_of_entries;
03235 static long unique_dt_number;
03236
03237
03238
03239
03240
03241
03242
03243
03244
03245
03246
03247 TRACE (Func_Entry, "compare_derived_types", NULL);
03248
03249
03250
03251 dt_idx1 = TYP_IDX(dt_idx1);
03252 dt_idx2 = TYP_IDX(dt_idx2);
03253
03254 while (AT_ATTR_LINK(dt_idx1) != NULL_IDX) {
03255 dt_idx1 = AT_ATTR_LINK(dt_idx1);
03256 }
03257
03258 while (AT_ATTR_LINK(dt_idx2) != NULL_IDX) {
03259 dt_idx2 = AT_ATTR_LINK(dt_idx2);
03260 }
03261
03262 if (dt_idx1 == dt_idx2) {
03263 same = TRUE;
03264 return(TRUE);
03265 }
03266
03267
03268
03269
03270
03271
03272
03273
03274
03275
03276
03277
03278
03279
03280
03281
03282
03283
03284
03285
03286
03287
03288
03289
03290
03291 if (dt_cmp_tbl == NULL) {
03292
03293 if (comp_phase >= Decl_Semantics) {
03294 num_of_entries = num_of_derived_types;
03295 }
03296 else {
03297 num_of_entries = (num_of_derived_types > 500) ? num_of_derived_types :
03298 500;
03299 }
03300
03301 entry_size = ((num_of_entries-1) / HOST_BITS_PER_WORD) + 1;
03302 dt_cmp_tbl_size = (1 + num_of_entries) * entry_size;
03303 unique_dt_number = 0;
03304
03305
03306
03307 MEM_ALLOC(dt_cmp_tbl, long, dt_cmp_tbl_size);
03308
03309 for (idx = 0; idx < dt_cmp_tbl_size; idx++) dt_cmp_tbl[idx] = 0;
03310 }
03311 id1 = ATT_UNIQUE_ID(dt_idx1);
03312 id2 = ATT_UNIQUE_ID(dt_idx2);
03313
03314 if (id1 == 0) {
03315 id1 = ++unique_dt_number;
03316 ATT_UNIQUE_ID(dt_idx1) = id1;
03317 }
03318
03319 if (id2 == 0) {
03320 id2 = ++unique_dt_number;
03321 ATT_UNIQUE_ID(dt_idx2) = id2;
03322 }
03323
03324
03325 if (id1 > num_of_entries || id2 > num_of_entries) {
03326
03327
03328
03329 keep_compare = FALSE;
03330 }
03331 else {
03332 keep_compare = TRUE;
03333
03334
03335
03336 if (id2 < id1) {
03337 entry_idx1 = id2;
03338 id2 = id1;
03339 id1 = entry_idx1;
03340 }
03341
03342 entry_idx1 = ((id1-1)*entry_size) + ((id2-1) / HOST_BITS_PER_WORD);
03343 entry_idx2 = ((id2-1)*entry_size) + ((id1-1) / HOST_BITS_PER_WORD);
03344 bit_idx1 = ((id2-1) % HOST_BITS_PER_WORD);
03345 bit_idx2 = ((id1-1) % HOST_BITS_PER_WORD);
03346
03347 check = (1L << bit_idx1) & dt_cmp_tbl[entry_idx1];
03348
03349 if (check) {
03350 same = (1L << bit_idx2) & dt_cmp_tbl[entry_idx2];
03351 goto DONE;
03352 }
03353
03354
03355
03356
03357
03358 dt_cmp_tbl[entry_idx1] |= (1L << bit_idx1);
03359 dt_cmp_tbl[entry_idx2] |= (1L << bit_idx2);
03360
03361 }
03362
03363 if (AT_USE_ASSOCIATED(dt_idx1)) {
03364 name1 = AT_ORIG_NAME_LONG(dt_idx1);
03365 len1 = AT_ORIG_NAME_LEN(dt_idx1);
03366 mod_idx1 = AT_MODULE_IDX(dt_idx1);
03367 }
03368 else {
03369 name1 = AT_OBJ_NAME_LONG(dt_idx1);
03370 len1 = AT_NAME_LEN(dt_idx1);
03371 mod_idx1 = NULL_IDX;
03372 }
03373
03374 if (AT_USE_ASSOCIATED(dt_idx2)) {
03375 name2 = AT_ORIG_NAME_LONG(dt_idx2);
03376 len2 = AT_ORIG_NAME_LEN(dt_idx2);
03377 mod_idx2 = AT_MODULE_IDX(dt_idx2);
03378 }
03379 else {
03380 name2 = AT_OBJ_NAME_LONG(dt_idx2);
03381 len2 = AT_NAME_LEN(dt_idx2);
03382 mod_idx2 = NULL_IDX;
03383 }
03384
03385 if (compare_names(name1, len1, name2, len2) != 0) {
03386 same = FALSE;
03387 goto DONE;
03388 }
03389
03390 if (mod_idx1 != NULL_IDX && mod_idx2 != NULL_IDX &&
03391 compare_names(AT_OBJ_NAME_LONG(mod_idx1),
03392 AT_NAME_LEN(mod_idx1),
03393 AT_OBJ_NAME_LONG(mod_idx2),
03394 AT_NAME_LEN(mod_idx2)) == 0) {
03395 same = TRUE;
03396 goto DONE;
03397 }
03398
03399 same = (!ATT_PRIVATE_CPNT(dt_idx1) &&
03400 !ATT_PRIVATE_CPNT(dt_idx2) &&
03401 (!AT_PRIVATE(dt_idx1) || AT_USE_ASSOCIATED(dt_idx1)) &&
03402 (!AT_PRIVATE(dt_idx2) || AT_USE_ASSOCIATED(dt_idx1)) &&
03403 #ifdef KEY
03404 ((ATT_SEQUENCE_SET(dt_idx1) && ATT_SEQUENCE_SET(dt_idx2)) ||
03405 (AT_BIND_ATTR(dt_idx1) && AT_BIND_ATTR(dt_idx2))) &&
03406 #else
03407 ATT_SEQUENCE_SET(dt_idx1) &&
03408 ATT_SEQUENCE_SET(dt_idx2) &&
03409 #endif
03410 ATT_NUM_CPNTS(dt_idx1) == ATT_NUM_CPNTS(dt_idx2));
03411
03412 if (!same) {
03413 goto DONE;
03414 }
03415
03416 s_idx1 = ATT_FIRST_CPNT_IDX(dt_idx1);
03417 s_idx2 = ATT_FIRST_CPNT_IDX(dt_idx2);
03418
03419 while (s_idx1 != NULL_IDX) {
03420 at_idx1 = SN_ATTR_IDX(s_idx1);
03421 at_idx2 = SN_ATTR_IDX(s_idx2);
03422
03423 same = same &&
03424 ATD_POINTER(at_idx1) == ATD_POINTER(at_idx2) &&
03425 TYP_TYPE(ATD_TYPE_IDX(at_idx1)) ==
03426 TYP_TYPE(ATD_TYPE_IDX(at_idx2)) &&
03427 compare_array_entries(ATD_ARRAY_IDX(at_idx1),
03428 ATD_ARRAY_IDX(at_idx2)) &&
03429 (compare_names(AT_OBJ_NAME_LONG(at_idx1),
03430 AT_NAME_LEN(at_idx1),
03431 AT_OBJ_NAME_LONG(at_idx2),
03432 AT_NAME_LEN(at_idx2)) == 0);
03433
03434
03435
03436 if (TYP_TYPE(ATD_TYPE_IDX(at_idx1)) == Character) {
03437 same = same && fold_relationals(TYP_IDX(ATD_TYPE_IDX(at_idx1)),
03438 TYP_IDX(ATD_TYPE_IDX(at_idx2)),
03439 Eq_Opr);
03440 }
03441 else if (TYP_TYPE(ATD_TYPE_IDX(at_idx1)) == Structure) {
03442
03443 if (TYP_IDX(ATD_TYPE_IDX(at_idx1)) == dt_idx1 &&
03444 TYP_IDX(ATD_TYPE_IDX(at_idx2)) == dt_idx2) {
03445
03446
03447 }
03448 else if (TYP_IDX(ATD_TYPE_IDX(at_idx1)) == dt_idx1 &&
03449 TYP_IDX(ATD_TYPE_IDX(at_idx2)) != dt_idx2) {
03450 same = FALSE;
03451 goto DONE;
03452 }
03453 else if (TYP_IDX(ATD_TYPE_IDX(at_idx1)) != dt_idx1 &&
03454 TYP_IDX(ATD_TYPE_IDX(at_idx2)) == dt_idx2) {
03455 same = FALSE;
03456 goto DONE;
03457 }
03458 else {
03459 same=same && compare_derived_types(ATD_TYPE_IDX(at_idx1),
03460 ATD_TYPE_IDX(at_idx2));
03461 }
03462 }
03463 else {
03464 same = same && TYP_LINEAR(ATD_TYPE_IDX(at_idx1)) ==
03465 TYP_LINEAR(ATD_TYPE_IDX(at_idx2));
03466 }
03467
03468 s_idx1 = SN_SIBLING_LINK(s_idx1);
03469 s_idx2 = SN_SIBLING_LINK(s_idx2);
03470 }
03471
03472 DONE:
03473
03474 if (keep_compare) {
03475
03476 if (same) {
03477 dt_cmp_tbl[entry_idx2] |= (1L << bit_idx2);
03478 }
03479 else {
03480 dt_cmp_tbl[entry_idx2] &= ~(1L << bit_idx2);
03481 }
03482 }
03483
03484 TRACE (Func_Exit, "compare_derived_types", NULL);
03485
03486 return(same);
03487
03488 }
03489
03490
03491
03492
03493
03494
03495
03496
03497
03498
03499
03500
03501
03502
03503
03504
03505
03506 boolean compare_array_entries(int bd_idx1,
03507 int bd_idx2)
03508 {
03509 long_type folded_const[MAX_WORDS_FOR_NUMERIC];
03510 int i;
03511 boolean same;
03512 int type_idx;
03513
03514
03515 TRACE (Func_Entry, "compare_array_entries", NULL);
03516
03517 if (bd_idx1 == bd_idx2) {
03518 same = TRUE;
03519 }
03520 else if (bd_idx1 == NULL_IDX || bd_idx2 == NULL_IDX) {
03521 same = FALSE;
03522 }
03523 else {
03524
03525 same = (BD_RANK(bd_idx1) == BD_RANK(bd_idx2)) &&
03526 (BD_ARRAY_SIZE(bd_idx1) == BD_ARRAY_SIZE(bd_idx2)) &&
03527 (BD_ARRAY_CLASS(bd_idx1) == BD_ARRAY_CLASS(bd_idx2));
03528
03529 if (same && BD_ARRAY_CLASS(bd_idx1) != Deferred_Shape) {
03530 type_idx = CG_LOGICAL_DEFAULT_TYPE;
03531
03532 for (i = 1; i <= BD_RANK(bd_idx1); i++) {
03533
03534 if (BD_LB_FLD(bd_idx1, i) == CN_Tbl_Idx &&
03535 BD_LB_FLD(bd_idx2, i) == CN_Tbl_Idx) {
03536
03537 if (folder_driver((char *)&CN_CONST(BD_LB_IDX(bd_idx1, i)),
03538 CN_TYPE_IDX(BD_LB_IDX(bd_idx1, i)),
03539 (char *)&CN_CONST(BD_LB_IDX(bd_idx2, i)),
03540 CN_TYPE_IDX(BD_LB_IDX(bd_idx2, i)),
03541 folded_const,
03542 &type_idx,
03543 BD_LINE_NUM(bd_idx1),
03544 BD_COLUMN_NUM(bd_idx1),
03545 2,
03546 Ne_Opr)) {
03547 }
03548
03549 if (THIS_IS_TRUE(folded_const, type_idx)) {
03550 same = FALSE;
03551 }
03552 }
03553
03554 if (BD_UB_FLD(bd_idx1, i) == CN_Tbl_Idx &&
03555 BD_UB_FLD(bd_idx2, i) == CN_Tbl_Idx) {
03556
03557 if (folder_driver((char *)&CN_CONST(BD_UB_IDX(bd_idx1, i)),
03558 CN_TYPE_IDX(BD_UB_IDX(bd_idx1, i)),
03559 (char *)&CN_CONST(BD_UB_IDX(bd_idx2, i)),
03560 CN_TYPE_IDX(BD_UB_IDX(bd_idx2, i)),
03561 folded_const,
03562 &type_idx,
03563 BD_LINE_NUM(bd_idx1),
03564 BD_COLUMN_NUM(bd_idx1),
03565 2,
03566 Ne_Opr)) {
03567 }
03568
03569 if (THIS_IS_TRUE(folded_const, type_idx)) {
03570 same = FALSE;
03571 }
03572 }
03573 }
03574 }
03575 }
03576
03577 TRACE (Func_Exit, "compare_array_entries", NULL);
03578
03579 return(same);
03580
03581 }
03582
03583
03584
03585
03586
03587
03588
03589
03590
03591
03592
03593
03594
03595
03596
03597
03598
03599
03600
03601 void init_name_and_stor_tbls(int scp_idx,
03602 boolean create_full_scp)
03603 {
03604 int ln_idx;
03605 id_str_type name;
03606 int new_idx;
03607
03608
03609 TRACE (Func_Entry, "init_name_and_stor_tbls", NULL);
03610
03611 ln_idx = loc_name_tbl_idx + 1;
03612
03613 TBL_REALLOC_CK(loc_name_tbl, 2);
03614 CLEAR_TBL_NTRY(loc_name_tbl, ln_idx);
03615 LN_NAME_IDX(ln_idx) = NAME_POOL_ZERO_IDX;
03616 LN_NAME_LEN(ln_idx) = HOST_BYTES_PER_WORD;
03617 SCP_LN_FW_IDX(scp_idx) = ln_idx;
03618
03619 CLEAR_TBL_NTRY(loc_name_tbl, loc_name_tbl_idx);
03620 LN_NAME_IDX(loc_name_tbl_idx) = NAME_POOL_ONES_IDX;
03621 LN_NAME_LEN(loc_name_tbl_idx) = HOST_BYTES_PER_WORD;
03622 SCP_LN_LW_IDX(scp_idx) = loc_name_tbl_idx;
03623
03624 if (create_full_scp) {
03625
03626 create_hidden_name_tbl(scp_idx);
03627
03628
03629
03630
03631
03632
03633 CREATE_ID(name, sb_name[Data_Blk], sb_len[Data_Blk]);
03634 new_idx = ntr_stor_blk_tbl(name.string,
03635 sb_len[Data_Blk],
03636 stmt_start_line,
03637 stmt_start_col,
03638 Static_Local);
03639 SCP_SB_STATIC_IDX(scp_idx) = new_idx;
03640 SB_PAD_BLK(new_idx) = cmd_line_flags.pad;
03641
03642 # if defined(_SPLIT_STATIC_STORAGE_2) || defined(_SPLIT_STATIC_STORAGE_3)
03643
03644
03645
03646 CREATE_ID(name, sb_name[Data_Init_Blk], sb_len[Data_Init_Blk]);
03647 new_idx = ntr_stor_blk_tbl(name.string,
03648 sb_len[Data_Init_Blk],
03649 stmt_start_line,
03650 stmt_start_col,
03651 Static_Named);
03652 SCP_SB_STATIC_INIT_IDX(scp_idx) = new_idx;
03653 SB_PAD_BLK(new_idx) = cmd_line_flags.pad;
03654
03655 # if defined(_SPLIT_STATIC_STORAGE_3)
03656 CREATE_ID(name, sb_name[Data_Uninit_Blk], sb_len[Data_Uninit_Blk]);
03657 new_idx = ntr_stor_blk_tbl(name.string,
03658 sb_len[Data_Uninit_Blk],
03659 stmt_start_line,
03660 stmt_start_col,
03661 Static_Named);
03662 SCP_SB_STATIC_UNINIT_IDX(scp_idx) = new_idx;
03663 SB_PAD_BLK(new_idx) = cmd_line_flags.pad;
03664 # endif
03665
03666 # else
03667 SCP_SB_STATIC_INIT_IDX(scp_idx) = SCP_SB_STATIC_IDX(scp_idx);
03668 SCP_SB_STATIC_UNINIT_IDX(scp_idx) = SCP_SB_STATIC_IDX(scp_idx);
03669 # endif
03670
03671 if (cmd_line_flags.pad_amount != 0) {
03672
03673 # if defined(_SPLIT_STATIC_STORAGE_3)
03674 SB_PAD_AMOUNT(SCP_SB_STATIC_UNINIT_IDX(scp_idx)) =
03675 cmd_line_flags.pad_amount;
03676 SB_PAD_AMOUNT_SET(SCP_SB_STATIC_UNINIT_IDX(scp_idx)) = TRUE;
03677 # endif
03678
03679 # if defined(_SPLIT_STATIC_STORAGE_2)
03680
03681 SB_PAD_AMOUNT(SCP_SB_STATIC_INIT_IDX(scp_idx)) =
03682 cmd_line_flags.pad_amount;
03683 SB_PAD_AMOUNT_SET(SCP_SB_STATIC_INIT_IDX(scp_idx)) = TRUE;
03684 # endif
03685 SB_PAD_AMOUNT(SCP_SB_STATIC_IDX(scp_idx))= cmd_line_flags.pad_amount;
03686 SB_PAD_AMOUNT_SET(SCP_SB_STATIC_IDX(scp_idx)) = TRUE;
03687 }
03688
03689
03690
03691 CREATE_ID(name, sb_name[Stack_Blk], sb_len[Stack_Blk]);
03692 new_idx = ntr_stor_blk_tbl(name.string,
03693 sb_len[Stack_Blk],
03694 stmt_start_line,
03695 stmt_start_col,
03696 Stack);
03697 SCP_SB_STACK_IDX(scp_idx) = new_idx;
03698
03699
03700
03701 CREATE_ID(name, sb_name[Dargs_Blk], sb_len[Dargs_Blk]);
03702 new_idx = ntr_stor_blk_tbl(name.string,
03703 sb_len[Dargs_Blk],
03704 stmt_start_line,
03705 stmt_start_col,
03706 Formal);
03707 SCP_SB_DARG_IDX(scp_idx) = new_idx;
03708
03709 CREATE_ID(name, sb_name[Based_Blk], sb_len[Based_Blk]);
03710 new_idx = ntr_stor_blk_tbl(name.string,
03711 sb_len[Based_Blk],
03712 stmt_start_line,
03713 stmt_start_col,
03714 Based);
03715 SCP_SB_BASED_IDX(scp_idx) = new_idx;
03716 }
03717
03718 TRACE (Func_Exit, "init_name_and_stor_tbls", NULL);
03719
03720 return;
03721
03722 }
03723
03724 # ifdef _DEBUG
03725
03726
03727
03728
03729
03730
03731
03732
03733
03734
03735
03736
03737
03738
03739
03740
03741
03742
03743
03744
03745 attr_tbl_type *sytb_var_error(char *err_str,
03746 int attr_idx)
03747 {
03748 static int been_here_before;
03749
03750 if (been_here_before == 0) {
03751 been_here_before = 1;
03752 print_at_all(attr_idx);
03753 PRINTMSG(stmt_start_line, 42, Internal,stmt_start_col, attr_idx, err_str);
03754 }
03755 return(attr_tbl);
03756 }
03757 # endif
03758
03759
03760 # ifdef _DEBUG
03761
03762
03763
03764
03765
03766
03767
03768
03769
03770
03771
03772
03773
03774
03775
03776
03777
03778
03779
03780 attr_aux_tbl_type *attr_aux_var_error(char *err_str,
03781 int attr_idx)
03782 {
03783 static int been_here_before;
03784
03785 if (been_here_before == 0) {
03786 been_here_before = 1;
03787 print_at_all(attr_idx);
03788 PRINTMSG(stmt_start_line, 42, Internal,stmt_start_col, attr_idx, err_str);
03789 }
03790 return(attr_aux_tbl);
03791 }
03792 # endif
03793
03794 # ifdef _DEBUG
03795
03796
03797
03798
03799
03800
03801
03802
03803
03804
03805
03806
03807
03808
03809
03810
03811
03812
03813
03814 bounds_tbl_type *bd_var_error(char *err_str,
03815 int bd_idx)
03816 {
03817 static int been_here_before;
03818
03819 if (been_here_before == 0) {
03820 been_here_before = 1;
03821 print_bd(bd_idx);
03822 PRINTMSG(stmt_start_line, 1367, Internal,stmt_start_col, bd_idx, err_str);
03823 }
03824 return(bounds_tbl);
03825 }
03826 # endif
03827
03828 # ifdef _DEBUG
03829
03830
03831
03832
03833
03834
03835
03836
03837
03838
03839
03840
03841
03842
03843
03844
03845
03846
03847
03848 ir_list_tbl_type *ir_list_var_error(char *err_str,
03849 int il_idx)
03850 {
03851 static int been_here_before;
03852
03853 if (been_here_before == 0) {
03854 been_here_before = 1;
03855 print_il(il_idx);
03856 PRINTMSG(stmt_start_line, 782, Internal,stmt_start_col, il_idx, err_str);
03857 }
03858 return(ir_list_tbl);
03859 }
03860 # endif
03861
03862 # ifdef _DEBUG
03863
03864
03865
03866
03867
03868
03869
03870
03871
03872
03873
03874
03875
03876
03877
03878
03879
03880
03881
03882
03883
03884 global_attr_tbl_type *ga_var_error(char *err_str,
03885 int ga_idx)
03886 {
03887 static int been_here_before;
03888
03889 if (been_here_before == 0) {
03890 been_here_before = 1;
03891 print_ga(ga_idx);
03892 PRINTMSG(stmt_start_line, 42, Internal,stmt_start_col, ga_idx, err_str);
03893 }
03894 return(global_attr_tbl);
03895 }
03896 # endif
03897
03898
03899
03900
03901
03902
03903
03904
03905
03906
03907
03908
03909
03910
03911
03912
03913
03914
03915
03916
03917
03918 int gen_internal_lbl (int label_line)
03919
03920 {
03921 int attr_idx;
03922 int length;
03923 id_str_type name;
03924
03925
03926 TRACE (Func_Entry, "gen_internal_lbl", NULL);
03927
03928 curr_internal_lbl++;
03929
03930 CREATE_ID(name, " ", 1);
03931
03932 # if defined(_NO_AT_SIGN_IN_NAMES)
03933 length = (int) sprintf(name.string, "l.%05d", curr_internal_lbl);
03934 # else
03935 length = (int) sprintf(name.string, "l@%05d", curr_internal_lbl);
03936 # endif
03937
03938 # ifdef _HOST32
03939 length = strlen(name.string);
03940 # endif
03941
03942
03943 # ifdef _DEBUG
03944 if (curr_internal_lbl > MAX_GENERATED_LABELS) {
03945 PRINTMSG(label_line, 364, Limit, 0, MAX_GENERATED_LABELS);
03946 }
03947 # endif
03948
03949 attr_idx = ntr_local_attr_list(name.string,
03950 length,
03951 label_line,
03952 0);
03953 AT_OBJ_CLASS(attr_idx) = Label;
03954 AT_COMPILER_GEND(attr_idx) = TRUE;
03955 AT_REFERENCED(attr_idx) = Referenced;
03956 ATL_CLASS(attr_idx) = Lbl_Internal;
03957
03958 if (! cdir_switches.vector) {
03959 ATL_NOVECTOR(attr_idx) = TRUE;
03960 }
03961
03962
03963
03964 TRACE (Func_Exit, "gen_internal_lbl", NULL);
03965
03966 return (attr_idx);
03967
03968 }
03969
03970
03971
03972
03973
03974
03975
03976
03977
03978
03979
03980
03981
03982
03983
03984
03985
03986
03987
03988
03989
03990
03991
03992
03993
03994
03995
03996 size_offset_type stor_bit_size_of(int attr_idx,
03997 boolean all_elements,
03998 boolean check_array_size)
03999 {
04000 int bd_idx;
04001 size_offset_type constant;
04002 boolean issue_msg;
04003 size_offset_type length;
04004 size_offset_type max_storage_size;
04005 long num;
04006 size_offset_type num_chars;
04007 size_offset_type result;
04008 int type_idx;
04009
04010 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
04011 long64 max_size;
04012 # endif
04013
04014
04015 TRACE (Func_Entry, "stor_bit_size_of", NULL);
04016
04017 #ifdef KEY
04018
04019
04020 constant.type_idx = Integer_8;
04021 #else
04022 constant.type_idx = CG_INTEGER_DEFAULT_TYPE;
04023 #endif
04024 constant.fld = NO_Tbl_Idx;
04025 C_TO_F_INT(constant.constant, 0, CG_INTEGER_DEFAULT_TYPE);
04026
04027 if (AT_OBJ_CLASS(attr_idx) == Data_Obj) {
04028
04029 if (ATD_IM_A_DOPE(attr_idx)) {
04030 #ifdef KEY
04031 boolean is_array = (ATD_ARRAY_IDX(attr_idx) != NULL_IDX);
04032 num = DV_HD_WORD_SIZE;
04033 if (is_array) {
04034 int n_allocatable_cpnt = do_count_allocatable_cpnt(attr_idx,
04035 is_array);
04036 num +=
04037 (DV_DIM_WORD_SIZE * (long) BD_RANK(ATD_ARRAY_IDX(attr_idx))) +
04038 (n_allocatable_cpnt ?
04039 ((n_allocatable_cpnt + 1) * DV_ALLOC_CPNT_OFFSET_WORD_SIZE) :
04040 0);
04041 }
04042
04043 num *= DV_BITS_PER_WORD;
04044 #else
04045 num = (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) ?
04046 (TARGET_BITS_PER_WORD * (DV_HD_WORD_SIZE +
04047 (DV_DIM_WORD_SIZE *
04048 (long) BD_RANK(ATD_ARRAY_IDX(attr_idx))))) :
04049 (DV_HD_WORD_SIZE * TARGET_BITS_PER_WORD);
04050 #endif
04051 C_TO_F_INT(constant.constant, num, CG_INTEGER_DEFAULT_TYPE);
04052 }
04053 else {
04054
04055 type_idx = ATD_TYPE_IDX(attr_idx);
04056
04057 switch (TYP_TYPE(type_idx)) {
04058 case Character:
04059
04060 if (TYP_FLD(type_idx) == CN_Tbl_Idx) {
04061 constant.fld = CN_Tbl_Idx;
04062 constant.idx = CN_INTEGER_CHAR_BIT_IDX;
04063 num_chars.fld = TYP_FLD(type_idx);
04064 num_chars.idx = TYP_IDX(type_idx);
04065
04066
04067
04068
04069 size_offset_binary_calc(&num_chars,
04070 &constant,
04071 Mult_Opr,
04072 &constant);
04073 }
04074
04075 break;
04076
04077 case Structure:
04078
04079 constant.fld = ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
04080 constant.idx = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
04081 break;
04082
04083 case Typeless :
04084 C_TO_F_INT(constant.constant, TYP_BIT_LEN(type_idx), Integer_8);
04085 constant.type_idx = Integer_8;
04086
04087 align_bit_length(&constant, TARGET_BITS_PER_WORD);
04088 break;
04089
04090 default:
04091
04092 # ifdef _DEBUG
04093 if (TYP_LINEAR(type_idx) == Err_Res) {
04094 PRINTMSG(AT_DEF_LINE(attr_idx), 810, Internal,
04095 AT_DEF_COLUMN(attr_idx),
04096 AT_OBJ_NAME_PTR(attr_idx));
04097 }
04098 # endif
04099 C_TO_F_INT(constant.constant,
04100 storage_bit_size_tbl[TYP_LINEAR(type_idx)],
04101 CG_INTEGER_DEFAULT_TYPE);
04102 }
04103
04104 bd_idx = ATD_ARRAY_IDX(attr_idx);
04105
04106 if (all_elements) {
04107
04108 if (bd_idx != NULL_IDX) {
04109
04110
04111
04112
04113 if (BD_ARRAY_SIZE(bd_idx) == Constant_Size ||
04114 BD_ARRAY_SIZE(bd_idx) == Symbolic_Constant_Size) {
04115 length.fld = BD_LEN_FLD(bd_idx);
04116 length.idx = BD_LEN_IDX(bd_idx);
04117 #ifdef KEY
04118
04119
04120
04121
04122
04123
04124 length.type_idx = (length.fld == CN_Tbl_Idx) ?
04125 CN_TYPE_IDX(length.idx) :
04126 CG_INTEGER_DEFAULT_TYPE;
04127 #endif
04128
04129 if (!size_offset_binary_calc(&length,
04130 &constant,
04131 Mult_Opr,
04132 &constant)) {
04133
04134 AT_DCL_ERR(attr_idx) = TRUE;
04135 }
04136 }
04137 else {
04138 constant.fld = CN_Tbl_Idx;
04139 constant.idx = CN_INTEGER_ZERO_IDX;
04140 }
04141 }
04142
04143 # if defined(_CHECK_MAX_MEMORY)
04144
04145 if (!ATD_AUXILIARY(attr_idx) &&
04146 constant.fld == NO_Tbl_Idx &&
04147 (check_array_size ||
04148 bd_idx == NULL_IDX ||
04149 BD_ARRAY_CLASS(bd_idx) != Explicit_Shape ||
04150 BD_ARRAY_SIZE(bd_idx) != Constant_Size)) {
04151
04152
04153
04154
04155
04156 issue_msg = FALSE;
04157 max_storage_size.fld = NO_Tbl_Idx;
04158
04159 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
04160 max_storage_size.type_idx = Integer_8;
04161
04162 if (cmd_line_flags.s_pointer8) {
04163 max_size = 0400000000000000000LL;
04164 C_TO_F_INT(max_storage_size.constant,
04165 max_size,
04166 Integer_8);
04167
04168 }
04169 else {
04170 C_TO_F_INT(max_storage_size.constant, pow(2,32),Integer_8);
04171 }
04172
04173 # else
04174 max_storage_size.type_idx = Integer_8;
04175
04176 # if defined(_TARGET32)
04177 C_TO_F_INT(max_storage_size.constant,
04178 2147483616,
04179 Integer_8);
04180 # else
04181 C_TO_F_INT(max_storage_size.constant,
04182 (MAX_STORAGE_SIZE_IN_WORDS*TARGET_BITS_PER_WORD),
04183 Integer_8);
04184 # endif
04185 # endif
04186
04187 size_offset_logical_calc(&constant,
04188 &max_storage_size,
04189 Gt_Opr,
04190 &result);
04191
04192 issue_msg = THIS_IS_TRUE(result.constant, result.type_idx);
04193
04194 if (issue_msg) {
04195
04196 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
04197
04198 if (cmd_line_flags.s_pointer8) {
04199 constant = max_storage_size;
04200
04201 if (!AT_DCL_ERR(attr_idx)) {
04202 AT_DCL_ERR(attr_idx) = TRUE;
04203
04204 if (AT_COMPILER_GEND(attr_idx)) {
04205 ISSUE_EXPR_SIZE_EXCEEDED_MSG(AT_DEF_LINE(attr_idx),
04206 AT_DEF_COLUMN(attr_idx),
04207 Error);
04208 }
04209 else {
04210 ISSUE_STORAGE_SIZE_EXCEEDED_MSG(attr_idx, Error);
04211 }
04212 }
04213 }
04214 else {
04215 ATD_TOO_BIG_FOR_DV(attr_idx) = TRUE;
04216 }
04217 # else
04218
04219 if (target_t3e) {
04220
04221 if (AT_COMPILER_GEND(attr_idx)) {
04222 ISSUE_EXPR_SIZE_EXCEEDED_MSG(AT_DEF_LINE(attr_idx),
04223 AT_DEF_COLUMN(attr_idx),
04224 Warning);
04225 }
04226 else {
04227 ISSUE_STORAGE_SIZE_EXCEEDED_MSG(attr_idx, Warning);
04228 }
04229 }
04230 else {
04231 constant = max_storage_size;
04232
04233 if (!AT_DCL_ERR(attr_idx)) {
04234 AT_DCL_ERR(attr_idx) = TRUE;
04235
04236 if (AT_COMPILER_GEND(attr_idx)) {
04237 ISSUE_EXPR_SIZE_EXCEEDED_MSG(AT_DEF_LINE(attr_idx),
04238 AT_DEF_COLUMN(attr_idx),
04239 Error);
04240 }
04241 else {
04242 ISSUE_STORAGE_SIZE_EXCEEDED_MSG(attr_idx, Error);
04243 }
04244 }
04245 }
04246 # endif
04247 }
04248 }
04249 # endif
04250 }
04251 }
04252 }
04253
04254 TRACE (Func_Exit, "stor_bit_size_of", NULL);
04255
04256 return(constant);
04257
04258 }
04259
04260
04261
04262
04263
04264
04265
04266
04267
04268
04269
04270
04271
04272
04273
04274
04275
04276
04277
04278
04279
04280
04281
04282
04283
04284
04285
04286
04287
04288 int gen_compiler_tmp (int tmp_line,
04289 int tmp_column,
04290 task_scope_type scope,
04291 boolean add_to_attr_list)
04292
04293 {
04294 int attr_idx;
04295 int length;
04296 static int curr_tmp = 0;
04297 id_str_type name;
04298 int np_idx;
04299
04300
04301 TRACE (Func_Entry, "gen_compiler_tmp", NULL);
04302
04303 curr_tmp++;
04304
04305 CREATE_ID(name, " ", 1);
04306
04307 # if defined(_HOST_OS_UNICOS) || defined(_HOST_OS_MAX)
04308 length = sprintf(name.string, "t$%d", curr_tmp);
04309 # else
04310 sprintf(name.string, "t$%d", curr_tmp);
04311 length = strlen(name.string);
04312 # endif
04313
04314 if (add_to_attr_list) {
04315 attr_idx = ntr_local_attr_list(name.string,
04316 length,
04317 tmp_line,
04318 tmp_column);
04319 }
04320 else {
04321 NTR_NAME_POOL(&(name.words[0]), length, np_idx);
04322
04323 NTR_ATTR_TBL(attr_idx);
04324 AT_DEF_LINE(attr_idx) = tmp_line;
04325 AT_DEF_COLUMN(attr_idx) = tmp_column;
04326 AT_NAME_LEN(attr_idx) = length;
04327 AT_NAME_IDX(attr_idx) = np_idx;
04328 }
04329
04330 ATD_CLASS(attr_idx) = Compiler_Tmp;
04331 AT_REFERENCED(attr_idx) = Referenced;
04332 AT_COMPILER_GEND(attr_idx) = TRUE;
04333 AT_TYPED(attr_idx) = TRUE;
04334
04335 if (scope == Priv) {
04336 ADD_TMP_TO_PRIVATE_LIST(attr_idx);
04337 }
04338 else {
04339 ADD_TMP_TO_SHARED_LIST(attr_idx);
04340 }
04341
04342 TRACE (Func_Exit, "gen_compiler_tmp", NULL);
04343
04344 return (attr_idx);
04345
04346 }
04347
04348
04349
04350
04351
04352
04353
04354
04355
04356
04357
04358
04359
04360
04361
04362
04363
04364
04365
04366
04367
04368
04369
04370
04371
04372
04373
04374
04375
04376
04377 void chg_data_obj_to_pgm_unit(int attr_idx,
04378 pgm_unit_type pgm_unit,
04379 atp_proc_type proc_type)
04380
04381 {
04382 #ifdef KEY
04383 int new_at_idx = 0;
04384 #else
04385 int new_at_idx;
04386 #endif
04387
04388
04389 TRACE (Func_Entry, "chg_data_obj_to_pgm_unit", NULL);
04390
04391
04392
04393
04394
04395
04396
04397 if (ATD_CLASS(attr_idx) == Dummy_Argument) {
04398 proc_type = Dummy_Proc;
04399 }
04400
04401
04402
04403 if (pgm_unit == Function ||
04404 (pgm_unit == Pgm_Unknown && (AT_TYPED(attr_idx) ||
04405 ATD_TARGET(attr_idx) ||
04406 ATD_POINTER(attr_idx) ||
04407 ATD_ARRAY_IDX(attr_idx) != NULL_IDX))) {
04408
04409 NTR_ATTR_TBL(new_at_idx);
04410 COPY_ATTR_NTRY(new_at_idx, attr_idx);
04411 AT_CIF_SYMBOL_ID(new_at_idx) = 0;
04412 ATD_CLASS(new_at_idx) = Function_Result;
04413 ATD_FUNC_IDX(new_at_idx) = attr_idx;
04414 pgm_unit = Function;
04415 }
04416
04417 CLEAR_VARIANT_ATTR_INFO(attr_idx, Pgm_Unit);
04418 ATP_PGM_UNIT(attr_idx) = pgm_unit;
04419 MAKE_EXTERNAL_NAME(attr_idx, AT_NAME_IDX(attr_idx), AT_NAME_LEN(attr_idx));
04420 ATP_PROC(attr_idx) = proc_type;
04421
04422
04423
04424
04425
04426 ATP_SCP_IDX(attr_idx) = curr_scp_idx;
04427
04428 if (pgm_unit == Function) {
04429 ATP_RSLT_IDX(attr_idx) = new_at_idx;
04430 }
04431
04432 TRACE (Func_Exit, "chg_data_obj_to_pgm_unit", NULL);
04433
04434 return;
04435
04436 }
04437
04438
04439
04440
04441
04442
04443
04444
04445
04446
04447
04448
04449
04450
04451
04452
04453
04454
04455
04456
04457
04458 char *get_basic_type_str(int type_idx)
04459 {
04460 char *str;
04461 static char str1[45];
04462
04463 #ifdef KEY
04464 static char *type_strings[Num_Linear_Types] = {
04465 "[Internal Error0]",
04466 "CHARACTER",
04467 "BOOLEAN",
04468 "TYPELESS/HOLLERITH",
04469 "TYPELESS/HOLLERITH",
04470 "BOOLEAN",
04471 "BOOLEAN",
04472 "TYPELESS/HOLLERITH",
04473 "INTEGER(KIND=1)",
04474 "INTEGER(KIND=2)",
04475 "INTEGER(KIND=4)",
04476 "INTEGER(KIND=8)",
04477 "REAL(KIND=4)",
04478 "REAL(KIND=8)",
04479 "REAL(KIND=16)",
04480 "COMPLEX(KIND=4)",
04481 "COMPLEX(KIND=8)",
04482 "COMPLEX(KIND=16)",
04483 "Cray pointer",
04484 "LOGICAL(KIND=1)",
04485 "LOGICAL(KIND=2)",
04486 "LOGICAL(KIND=4)",
04487 "LOGICAL(KIND=8)",
04488 "CHARACTER",
04489 "CHARACTER",
04490 "CHARACTER",
04491 "Cray character pointer",
04492 "[Internal Error1]",
04493 "Cray parcel pointer"
04494 };
04495 # ifdef _DEBUG
04496
04497 if (0 == type_strings[Num_Linear_Types - 1]) { abort(); }
04498 # endif
04499 #endif
04500
04501 TRACE (Func_Entry, "get_basic_type_str", NULL);
04502
04503 switch (TYP_TYPE(type_idx)) {
04504
04505 #ifdef KEY
04506 #else
04507 case Typeless:
04508 if (TYP_LINEAR(type_idx) == Typeless_4 ||
04509 TYP_LINEAR(type_idx) == Typeless_8 ||
04510 TYP_LINEAR(type_idx) == Short_Typeless_Const) {
04511 str = "BOOLEAN";
04512 }
04513 else {
04514 str = "TYPELESS";
04515 }
04516 break;
04517
04518 case Integer:
04519 str = "INTEGER";
04520 break;
04521
04522 case Logical:
04523 str = "LOGICAL";
04524 break;
04525
04526 case Real:
04527 str = (TYP_LINEAR(type_idx) <= REAL_DEFAULT_TYPE) ? "REAL" :
04528 "DOUBLE PRECISION";
04529 break;
04530
04531 case Complex:
04532 str = (TYP_LINEAR(type_idx) <= COMPLEX_DEFAULT_TYPE) ? "COMPLEX":
04533 "DOUBLE COMPLEX";
04534 break;
04535
04536 case Character:
04537 str = "CHARACTER";
04538 break;
04539 #endif
04540
04541 case Structure:
04542 str1[0] = '\0';
04543 strcat(str1, "type(");
04544 strcat(str1, AT_OBJ_NAME_PTR(TYP_IDX(type_idx)));
04545 strcat(str1, ")");
04546 str = str1;
04547 break;
04548
04549 #ifdef KEY
04550 default:
04551 str = type_strings[TYP_LINEAR(type_idx)];
04552 break;
04553 #else
04554 case CRI_Ptr:
04555 str = "Cray pointer";
04556 break;
04557
04558 case CRI_Ch_Ptr:
04559 str = "Cray character pointer";
04560 break;
04561
04562 case CRI_Parcel_Ptr:
04563 str = "Cray parcel pointer";
04564 break;
04565 #endif
04566
04567 }
04568
04569 TRACE (Func_Exit, "get_basic_type_str", NULL);
04570
04571 return(str);
04572
04573 }
04574
04575
04576
04577
04578
04579
04580
04581
04582
04583
04584
04585
04586
04587
04588
04589
04590
04591
04592
04593
04594
04595
04596
04597 boolean kind_to_linear_type(opnd_type *opnd,
04598 int attr_idx,
04599 boolean kind0seen,
04600 boolean kind0E0seen,
04601 boolean kind0D0seen,
04602 boolean kindconstseen)
04603
04604
04605 {
04606 int column;
04607 boolean error = FALSE;
04608 long kind;
04609 int line;
04610 linear_type_type linear_type = Err_Res;
04611 basic_type_type type;
04612 int type_idx;
04613
04614
04615 TRACE (Func_Entry, "kind_to_linear_type", NULL);
04616
04617 type = TYP_TYPE(ATD_TYPE_IDX(attr_idx));
04618
04619 if (OPND_FLD((*opnd)) != CN_Tbl_Idx ||
04620 TYP_TYPE(CN_TYPE_IDX(OPND_IDX((*opnd)))) != Integer) {
04621
04622 find_opnd_line_and_column(opnd, &line, &column);
04623 PRINTMSG(line, 770, Error, column);
04624 error = TRUE;
04625
04626
04627
04628 switch (type) {
04629 case Integer:
04630 type_idx = INTEGER_DEFAULT_TYPE;
04631 break;
04632
04633 case Logical:
04634 type_idx = LOGICAL_DEFAULT_TYPE;
04635 break;
04636
04637 case Real:
04638 type_idx = REAL_DEFAULT_TYPE;
04639 break;
04640
04641 case Complex:
04642 type_idx = COMPLEX_DEFAULT_TYPE;
04643 break;
04644
04645 default:
04646 type_idx = ATD_TYPE_IDX(attr_idx);
04647 break;
04648 }
04649 }
04650 else {
04651 kind = (long) CN_INT_TO_C(OPND_IDX((*opnd)));
04652
04653 error = validate_kind(type,
04654 OPND_LINE_NUM((*opnd)),
04655 OPND_COL_NUM((*opnd)),
04656 &kind,
04657 &linear_type);
04658
04659 if (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Character) {
04660 type_tbl[TYP_WORK_IDX] = type_tbl[ATD_TYPE_IDX(attr_idx)];
04661 }
04662 else {
04663 CLEAR_TBL_NTRY(type_tbl, TYP_WORK_IDX);
04664 TYP_TYPE(TYP_WORK_IDX) = type;
04665 TYP_LINEAR(TYP_WORK_IDX) = linear_type;
04666 }
04667
04668 TYP_DCL_VALUE(TYP_WORK_IDX) = kind;
04669 TYP_DESC(TYP_WORK_IDX) = Kind_Typed;
04670
04671 if ((kind0seen &&
04672 (TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Logical ||
04673 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Integer)) ||
04674 (kind0E0seen && TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Real)) {
04675
04676
04677
04678 TYP_DESC(TYP_WORK_IDX) = Default_Typed;
04679 }
04680 else if (kind0D0seen && TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Real) {
04681 TYP_KIND_DOUBLE(TYP_WORK_IDX) = TRUE;
04682 }
04683 else if (kindconstseen) {
04684 TYP_KIND_CONST(TYP_WORK_IDX) = TRUE;
04685 }
04686
04687 type_idx = ntr_type_tbl();
04688 }
04689
04690 ATD_TYPE_IDX(attr_idx) = type_idx;
04691
04692 TRACE (Func_Exit, "kind_to_linear_type", NULL);
04693
04694 return(error);
04695
04696 }
04697
04698
04699
04700
04701
04702
04703
04704
04705
04706
04707
04708
04709
04710
04711
04712
04713
04714
04715
04716
04717
04718
04719 int gen_debug_lbl_stmt(int stmt_idx,
04720 atl_debug_class_type label_type,
04721 int attr_idx)
04722
04723 {
04724 int ir_idx;
04725 int length;
04726 id_str_type name;
04727 int save_curr_stmt_sh_idx;
04728
04729 # if defined(_NO_AT_SIGN_IN_NAMES)
04730 char label_name[7] = "z.%05d";
04731 # else
04732 char label_name[7] = "z@%05d";
04733 # endif
04734
04735
04736 TRACE (Func_Entry, "gen_debug_lbl_stmt", NULL);
04737
04738 if (attr_idx == NULL_IDX) {
04739 curr_debug_lbl++;
04740
04741 CREATE_ID(name, " ", 1);
04742
04743 # if defined(_HOST_OS_UNICOS) || defined(_HOST_OS_MAX)
04744 length = sprintf (name.string, label_name, curr_debug_lbl);
04745 # else
04746 sprintf(name.string, label_name, curr_debug_lbl);
04747 length = strlen(name.string);
04748 # endif
04749
04750 # ifdef _DEBUG
04751
04752
04753 if (curr_debug_lbl > MAX_GENERATED_LABELS) {
04754 PRINTMSG(SH_GLB_LINE(stmt_idx), 364, Limit, 0, MAX_GENERATED_LABELS);
04755 }
04756 # endif
04757
04758 attr_idx = ntr_local_attr_list(name.string,
04759 length,
04760 SH_GLB_LINE(stmt_idx),
04761 0);
04762
04763 AT_OBJ_CLASS(attr_idx) = Label;
04764 AT_COMPILER_GEND(attr_idx) = TRUE;
04765 ATL_CLASS(attr_idx) = Lbl_Debug;
04766 ATL_DEBUG_CLASS(attr_idx) = label_type;
04767 AT_DEFINED(attr_idx) = TRUE;
04768 ATL_DEF_STMT_IDX(attr_idx) = curr_stmt_sh_idx;
04769 }
04770
04771 save_curr_stmt_sh_idx = curr_stmt_sh_idx;
04772
04773 if (SH_LABELED(stmt_idx)) {
04774 stmt_idx = SH_PREV_IDX(stmt_idx);
04775 }
04776
04777 curr_stmt_sh_idx = stmt_idx;
04778
04779 gen_sh(Before,
04780 Continue_Stmt,
04781 SH_GLB_LINE(stmt_idx),
04782 SH_COL_NUM(stmt_idx),
04783 FALSE,
04784 TRUE,
04785 TRUE);
04786
04787 stmt_idx = SH_PREV_IDX(curr_stmt_sh_idx);
04788 curr_stmt_sh_idx = save_curr_stmt_sh_idx;
04789 SH_P2_SKIP_ME(stmt_idx) = TRUE;
04790
04791 NTR_IR_TBL(ir_idx);
04792 SH_IR_IDX(stmt_idx) = ir_idx;
04793 IR_OPR(ir_idx) = Label_Opr;
04794 IR_TYPE_IDX(ir_idx) = TYPELESS_DEFAULT_TYPE;
04795 IR_LINE_NUM(ir_idx) = SH_GLB_LINE(stmt_idx);
04796 IR_COL_NUM(ir_idx) = SH_COL_NUM(stmt_idx);
04797 IR_LINE_NUM_L(ir_idx) = SH_GLB_LINE(stmt_idx);
04798 IR_COL_NUM_L(ir_idx) = SH_COL_NUM(stmt_idx);
04799 IR_FLD_L(ir_idx) = AT_Tbl_Idx;
04800 IR_IDX_L(ir_idx) = attr_idx;
04801
04802 TRACE (Func_Exit, "gen_debug_lbl_stmt", NULL);
04803
04804 return(stmt_idx);
04805
04806 }
04807
04808
04809
04810
04811
04812
04813
04814
04815
04816
04817
04818
04819
04820
04821
04822
04823
04824
04825
04826 int make_in_parent_string(int name_str_idx,
04827 int name_str_len,
04828 int scp_idx,
04829 int *name_len)
04830 {
04831 int idx;
04832 int length;
04833 int new_name_idx;
04834
04835
04836 TRACE (Func_Entry, "make_in_parent_string", NULL);
04837
04838 new_name_idx = name_pool_idx + 1;
04839 length = name_str_len;
04840
04841 TBL_REALLOC_CK(name_pool, HOST_BYTES_TO_WORDS(MAX_EXTERNAL_ID_LEN));
04842
04843 for (idx = new_name_idx; idx <= name_pool_idx; idx++) {
04844 name_pool[idx].name_long = 0;
04845 }
04846
04847 # if 0
04848 name_pool[new_name_idx].name_char[idx] =
04849 tolower(name_pool[name_str_idx].name_char[idx]);
04850 # endif
04851
04852 strcat(&name_pool[new_name_idx].name_char,
04853 &name_pool[name_str_idx].name_char);
04854
04855 while (scp_idx != NULL_IDX) {
04856 strcat(&name_pool[new_name_idx].name_char, UNIQUE_PROC_CONNECTOR);
04857 #ifdef KEY
04858 int attr_idx = SCP_ATTR_IDX(scp_idx);
04859 char *appendage;
04860 int appendage_len;
04861
04862
04863
04864
04865
04866
04867
04868
04869
04870
04871
04872
04873
04874 if (AT_IS_INTRIN(attr_idx) &&
04875 Pgm_Unit == AT_OBJ_CLASS(attr_idx) &&
04876 Module == ATP_PGM_UNIT(attr_idx)) {
04877 appendage = ATP_EXT_NAME_PTR(attr_idx);
04878 appendage_len = ATP_EXT_NAME_LEN(attr_idx);
04879 } else {
04880 appendage = AT_OBJ_NAME_PTR(attr_idx);
04881 appendage_len = AT_NAME_LEN(attr_idx);
04882 }
04883 strcat(&name_pool[new_name_idx].name_char, appendage);
04884 length += appendage_len + UNIQUE_PROC_LEN;
04885 #else
04886 strcat(&name_pool[new_name_idx].name_char,
04887 AT_OBJ_NAME_PTR(SCP_ATTR_IDX(scp_idx)));
04888
04889 length = length + AT_NAME_LEN(SCP_ATTR_IDX(scp_idx)) + UNIQUE_PROC_LEN;
04890 #endif
04891 scp_idx = SCP_PARENT_IDX(scp_idx);
04892 }
04893
04894 name_pool_idx = name_pool_idx - (HOST_BYTES_TO_WORDS(MAX_EXTERNAL_ID_LEN) -
04895 WORD_LEN(length));
04896 *name_len = length;
04897
04898 TRACE (Func_Exit, "make_in_parent_string", NULL);
04899
04900 return(new_name_idx);
04901
04902 }
04903
04904
04905
04906
04907
04908
04909
04910
04911
04912
04913
04914
04915
04916
04917
04918 int compare_names(long *id1,
04919 int id1_len,
04920 long *id2,
04921 int id2_len)
04922
04923 {
04924 int i;
04925 long matched = -1;
04926
04927
04928 TRACE (Func_Entry, "compare_names", NULL);
04929
04930 # if !(defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX) || defined(_HOST_OS_DARWIN))
04931 # pragma _CRI shortloop
04932 # endif
04933
04934 for (i = 0; i < WORD_LEN((id1_len > id2_len) ? id1_len : id2_len); i++) {
04935 matched = id1[i] - id2[i];
04936
04937 if (matched != 0) {
04938 break;
04939 }
04940 }
04941
04942 # if defined(_HOST_LITTLE_ENDIAN)
04943
04944
04945 if (matched) {
04946
04947
04948
04949
04950
04951
04952
04953
04954
04955 unsigned char* i1 = (unsigned char *) &id1[i];
04956 unsigned char* i2 = (unsigned char *) &id2[i];
04957
04958 # ifdef _HOST64
04959 # ifdef _WHIRL_HOST64_TARGET64
04960 signed long t, t1, t2;
04961
04962
04963
04964
04965
04966
04967
04968
04969
04970
04971
04972
04973
04974
04975
04976
04977
04978 t1 = 0;
04979 t2 = 0;
04980 t = i1[0]; t = t << 56; t1 += t;
04981 t = i1[1]; t = t << 48; t1 += t;
04982 t = i1[2]; t = t << 40; t1 += t;
04983 t = i1[3]; t = t << 32; t1 += t;
04984 t = i1[4]; t = t << 24; t1 += t;
04985 t = i1[5]; t = t << 16; t1 += t;
04986 t = i1[6]; t = t << 8; t1 += t;
04987 t = i1[7]; t1 += t;
04988 t = i2[0]; t = t << 56; t2 += t;
04989 t = i2[1]; t = t << 48; t2 += t;
04990 t = i2[2]; t = t << 40; t2 += t;
04991 t = i2[3]; t = t << 32; t2 += t;
04992 t = i2[4]; t = t << 24; t2 += t;
04993 t = i2[5]; t = t << 16; t2 += t;
04994 t = i2[6]; t = t << 8; t2 += t;
04995 t = i2[7]; t2 += t;
04996 matched = t1 - t2;
04997
04998
04999
05000
05001 #else
05002 matched = (signed long) (i1[0]<<56 | i1[1]<<48 | i1[2]<<40| i1[3]<<32
05003 | i1[4]<<24 | i1[5]<<16 | i1[6]<<8 | i1[7] )
05004 -
05005 (signed long) (i2[0]<<56 | i2[1]<<48 | i2[2]<<40| i2[3]<<32
05006 | i2[4]<<24 | i2[5]<<16 | i2[6]<<8 | i2[7] );
05007 #endif
05008 #else
05009 matched = (signed long) (i1[0]<<24 | i1[1]<<16 | i1[2]<<8 | i1[3] )
05010 -
05011 (signed long) (i2[0]<<24 | i2[1]<<16 | i2[2]<<8 | i2[3] );
05012
05013 #endif
05014 }
05015 #endif
05016
05017
05018 TRACE (Func_Exit, "compare_names", NULL);
05019
05020 # ifdef _HOST64
05021 # ifdef _WHIRL_HOST64_TARGET64
05022 if (matched)
05023 matched = matched > 0 ? 1 : -1;
05024 #endif
05025 #endif
05026
05027 return(matched);
05028
05029 }
05030
05031
05032
05033
05034
05035
05036
05037
05038
05039
05040
05041
05042
05043
05044
05045
05046
05047 int ntr_local_attr_list(char *name_str,
05048 int name_len,
05049 int def_line,
05050 int def_column)
05051
05052 {
05053 int attr_idx;
05054 long *id;
05055 int np_idx;
05056
05057
05058 TRACE (Func_Entry, "ntr_local_attr_list", NULL);
05059
05060 id = (long *) name_str;
05061
05062 NTR_NAME_POOL(id, name_len, np_idx);
05063
05064 NTR_ATTR_TBL(attr_idx);
05065 AT_DEF_LINE(attr_idx) = def_line;
05066 AT_DEF_COLUMN(attr_idx) = def_column;
05067 AT_NAME_LEN(attr_idx) = name_len;
05068 AT_NAME_IDX(attr_idx) = np_idx;
05069
05070 ADD_ATTR_TO_LOCAL_LIST(attr_idx);
05071
05072 TRACE (Func_Exit, "ntr_local_attr_list", NULL);
05073
05074 return(attr_idx);
05075
05076 }
05077
05078
05079
05080
05081
05082
05083
05084
05085
05086
05087
05088
05089
05090
05091 int create_lib_entry_attr(char *name_str,
05092 int name_len,
05093 int def_line,
05094 int def_column)
05095
05096 {
05097 int attr_idx;
05098 id_str_type name;
05099 int np_idx;
05100
05101
05102 TRACE (Func_Entry, "create_lib_entry_attr", NULL);
05103
05104 CREATE_ID(name, name_str, name_len);
05105 NTR_NAME_POOL(&(name.words[0]), name_len, np_idx);
05106 NTR_ATTR_TBL(attr_idx);
05107 AT_OBJ_CLASS(attr_idx) = Pgm_Unit;
05108 AT_REFERENCED(attr_idx) = Referenced;
05109 AT_COMPILER_GEND(attr_idx) = TRUE;
05110 ATP_PGM_UNIT(attr_idx) = Subroutine;
05111 ATP_SCP_IDX(attr_idx) = curr_scp_idx;
05112 ATP_PROC(attr_idx) = Extern_Proc;
05113 AT_NAME_IDX(attr_idx) = np_idx;
05114 AT_NAME_LEN(attr_idx) = name_len;
05115 ATP_EXT_NAME_IDX(attr_idx) = np_idx;
05116 ATP_EXT_NAME_LEN(attr_idx) = name_len;
05117 AT_DEF_LINE(attr_idx) = def_line;
05118 AT_DEF_COLUMN(attr_idx) = def_column;
05119
05120 TRACE (Func_Exit, "create_lib_entry_attr", NULL);
05121
05122 return(attr_idx);
05123
05124 }
05125
05126
05127
05128
05129
05130
05131
05132
05133
05134
05135
05136
05137
05138
05139
05140
05141 void set_stride_for_first_dim(int type_idx,
05142 size_offset_type *stride)
05143 {
05144 long64 length;
05145 size_offset_type result;
05146
05147
05148 TRACE (Func_Entry, "set_stride_for_first_dim", NULL);
05149
05150 # ifdef _SM_UNIT_IS_ELEMENT
05151
05152 (*stride).fld = CN_Tbl_Idx;
05153 (*stride).idx = CN_INTEGER_ONE_IDX;
05154
05155 # else
05156
05157 switch (TYP_TYPE(type_idx)) {
05158
05159 case Typeless:
05160 length = STORAGE_WORD_SIZE(TYP_BIT_LEN(type_idx));
05161 (*stride).fld = CN_Tbl_Idx;
05162 (*stride).idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, length);
05163 break;
05164
05165 case Integer:
05166 case Logical:
05167 case CRI_Ptr:
05168 case CRI_Ch_Ptr:
05169 case Real:
05170 case Complex:
05171
05172 length = BITS_TO_INTEGER_DEFAULT_WORDS(
05173 storage_bit_size_tbl[TYP_LINEAR(type_idx)],
05174 storage_bit_size_tbl[CG_INTEGER_DEFAULT_TYPE] );
05175
05176 # if 0
05177 # if defined(_TARGET64) && defined(_WHIRL_HOST64_TARGET64)
05178 if (double_stride && (storage_bit_size_tbl[TYP_LINEAR(type_idx)] > 32))
05179 length *= 2;
05180 # endif
05181 # endif
05182 (*stride).fld = CN_Tbl_Idx;
05183 (*stride).idx = C_INT_TO_CN(CG_INTEGER_DEFAULT_TYPE, length);
05184 break;
05185
05186 case Character:
05187 # if defined(_EXTENDED_CRI_CHAR_POINTER)
05188 if (TYP_FLD(type_idx) == AT_Tbl_Idx &&
05189 AT_OBJ_CLASS(TYP_IDX(type_idx)) == Data_Obj &&
05190 (TYP_TYPE(ATD_TYPE_IDX(TYP_IDX(type_idx))) == CRI_Ch_Ptr ||
05191 TYP_TYPE(ATD_TYPE_IDX(TYP_IDX(type_idx))) == CRI_Ptr)) {
05192
05193
05194
05195
05196 (*stride).fld = CN_Tbl_Idx;
05197 (*stride).idx = CN_INTEGER_ONE_IDX;
05198 }
05199 else {
05200 (*stride).fld = TYP_FLD(type_idx);
05201 (*stride).idx = TYP_IDX(type_idx);
05202 }
05203 # else
05204 (*stride).fld = TYP_FLD(type_idx);
05205 (*stride).idx = TYP_IDX(type_idx);
05206 # endif
05207 break;
05208
05209 case Structure:
05210
05211 if (ATT_CHAR_SEQ(TYP_IDX(type_idx))) {
05212
05213
05214
05215 result.idx = CN_INTEGER_THREE_IDX;
05216 result.fld = CN_Tbl_Idx;
05217 (*stride).fld = ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
05218 (*stride).idx = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
05219
05220 if (!size_offset_binary_calc(&(*stride),
05221 &result,
05222 Shiftr_Opr,
05223 &(*stride))) {
05224
05225 (*stride).fld = ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
05226 (*stride).idx = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
05227 }
05228 }
05229 else {
05230 (*stride).fld = ATT_STRUCT_BIT_LEN_FLD(TYP_IDX(type_idx));
05231 (*stride).idx = ATT_STRUCT_BIT_LEN_IDX(TYP_IDX(type_idx));
05232
05233 # if defined(_TARGET64) && defined(_WHIRL_HOST64_TARGET64)
05234 BITS_TO_WORDS((*stride), TARGET_BITS_PER_WORD/2);
05235 # else
05236 BITS_TO_WORDS((*stride), TARGET_BITS_PER_WORD);
05237 # endif
05238 }
05239
05240 if ((*stride).fld == NO_Tbl_Idx) {
05241 (*stride).fld = CN_Tbl_Idx;
05242 (*stride).idx = ntr_const_tbl((*stride).type_idx,
05243 FALSE,
05244 (*stride).constant);
05245 }
05246
05247 break;
05248
05249 }
05250 # endif
05251
05252 TRACE (Func_Exit, "set_stride_for_first_dim", 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 int ntr_type_tbl(void)
05276
05277 {
05278 boolean found;
05279 int i;
05280 int new_type_idx;
05281 long *null_base;
05282 long *type_tbl_base;
05283
05284
05285 TRACE (Func_Entry, "ntr_type_tbl", NULL);
05286
05287 switch (TYP_TYPE(TYP_WORK_IDX)) {
05288 case Integer:
05289 case Logical:
05290 case Real:
05291 case Complex:
05292
05293 if (TYP_DESC(TYP_WORK_IDX) == Default_Typed &&
05294 TYP_LINEAR(TYP_WORK_IDX) != Err_Res) {
05295 new_type_idx = TYP_LINEAR(TYP_WORK_IDX);
05296 goto EXIT;
05297 }
05298 break;
05299
05300 case CRI_Ptr:
05301
05302 if (TYP_PTR_INCREMENT(TYP_WORK_IDX) != 0 &&
05303 TYP_PTR_INCREMENT(TYP_WORK_IDX) != TARGET_BITS_PER_WORD) {
05304 break;
05305 }
05306
05307 case CRI_Parcel_Ptr:
05308 case CRI_Ch_Ptr:
05309 new_type_idx = TYP_LINEAR(TYP_WORK_IDX);
05310 goto EXIT;
05311
05312 case Typeless:
05313
05314 if (TYP_LINEAR(TYP_WORK_IDX) == Err_Res) {
05315
05316 switch (TYP_BIT_LEN(TYP_WORK_IDX)) {
05317 case 32:
05318 TYP_LINEAR(TYP_WORK_IDX) = Typeless_4;
05319 break;
05320
05321 case 64:
05322 TYP_LINEAR(TYP_WORK_IDX) = Typeless_8;
05323 break;
05324
05325 default:
05326 TYP_LINEAR(TYP_WORK_IDX) = Long_Typeless;
05327 break;
05328 }
05329 }
05330 break;
05331
05332 case Character:
05333 TYP_LINEAR(TYP_WORK_IDX) = (TYP_LINEAR(TYP_WORK_IDX) == Err_Res)?
05334 CHARACTER_DEFAULT_TYPE :
05335 TYP_LINEAR(TYP_WORK_IDX);
05336 break;
05337
05338 case Structure:
05339 break;
05340 }
05341
05342 null_base = (long *) type_tbl;
05343
05344 for (new_type_idx = 1; new_type_idx <= type_tbl_idx; new_type_idx++) {
05345 found = TRUE;
05346 type_tbl_base = (long *) &(type_tbl[new_type_idx]);
05347
05348 for (i = 0; i < NUM_TYP_WDS; i++) {
05349
05350 if (null_base[i] != type_tbl_base[i]) {
05351 found = FALSE;
05352 }
05353 }
05354
05355 if (found) {
05356 goto EXIT;
05357 }
05358 }
05359
05360 TBL_REALLOC_CK(type_tbl, 1);
05361 new_type_idx = type_tbl_idx;
05362 type_tbl[new_type_idx] = type_tbl[TYP_WORK_IDX];
05363
05364 EXIT:
05365
05366 TRACE (Func_Exit, "ntr_type_tbl", NULL);
05367
05368 return(new_type_idx);
05369
05370 }
05371
05372
05373
05374
05375
05376
05377
05378
05379
05380
05381
05382
05383
05384
05385
05386
05387
05388
05389
05390 int srch_linked_sn(char *name,
05391 int length,
05392 int *sn_idx)
05393
05394 {
05395 int attr_idx;
05396 register int i;
05397 register int id_wd_len;
05398 register long *id;
05399 register long *id1;
05400 register long matched;
05401
05402
05403 TRACE (Func_Entry, "srch_linked_sn", name);
05404
05405 id = (long *) name;
05406 id_wd_len = WORD_LEN(length);
05407 matched = -1;
05408 attr_idx = NULL_IDX;
05409
05410 while (*sn_idx != NULL_IDX) {
05411
05412 if (SN_NAME_LEN(*sn_idx) == length) {
05413 id1 = (long *) &(name_pool[SN_NAME_IDX(*sn_idx)]);
05414
05415 # if !(defined(_HOST_OS_IRIX) || defined(_HOST_OS_LINUX) || defined(_HOST_OS_DARWIN))
05416 # pragma _CRI shortloop
05417 # endif
05418
05419 for (i = 0; i < id_wd_len; i++) {
05420 matched = id[i] - id1[i];
05421
05422 if (matched != 0) {
05423 break;
05424 }
05425 }
05426
05427 if (matched == 0) {
05428 attr_idx = SN_ATTR_IDX(*sn_idx);
05429 break;
05430 }
05431 }
05432
05433 *sn_idx = SN_SIBLING_LINK(*sn_idx);
05434 }
05435
05436 TRACE (Func_Exit, "srch_linked_sn", NULL);
05437
05438 return (attr_idx);
05439
05440 }
05441
05442
05443
05444
05445
05446
05447
05448
05449
05450
05451
05452
05453
05454
05455
05456
05457
05458 void free_tables()
05459
05460 {
05461 TRACE (Func_Entry, "free_tables", NULL);
05462
05463
05464
05465
05466
05467
05468 strncpy(program_unit_name,
05469 AT_OBJ_NAME_PTR(SCP_ATTR_IDX(curr_scp_idx)),
05470 AT_NAME_LEN(SCP_ATTR_IDX(curr_scp_idx))+1);
05471
05472
05473
05474 curr_stmt_sh_idx = NULL_IDX;
05475 curr_scp_idx = NULL_IDX;
05476 expanded_intrinsic_list = NULL_IDX;
05477
05478 TBL_FREE (pdg_link_tbl);
05479 TBL_FREE (attr_list_tbl);
05480 TBL_FREE (attr_tbl);
05481 TBL_FREE (attr_aux_tbl);
05482 TBL_FREE (bounds_tbl);
05483 TBL_FREE (const_tbl);
05484 TBL_FREE (const_pool);
05485 TBL_FREE (sec_name_tbl);
05486 TBL_FREE (stor_blk_tbl);
05487 TBL_FREE (loc_name_tbl);
05488 TBL_FREE (name_pool);
05489 TBL_FREE (scp_tbl);
05490 TBL_FREE (type_tbl);
05491 TBL_FREE (ir_tbl);
05492 TBL_FREE (sh_tbl);
05493 TBL_FREE (ir_list_tbl);
05494 TBL_FREE (hidden_name_tbl);
05495
05496 TRACE (Func_Exit, "free_tables", NULL);
05497
05498 return;
05499
05500 }
05501
05502
05503
05504
05505
05506
05507
05508
05509
05510
05511
05512
05513
05514
05515
05516
05517
05518
05519
05520 boolean validate_kind(basic_type_type type,
05521 int line,
05522 int column,
05523 long *kind,
05524 linear_type_type *linear_type)
05525
05526 {
05527 boolean ok = TRUE;
05528 char kind_str[32];
05529
05530
05531 TRACE (Func_Entry, "validate_kind", NULL);
05532
05533 switch (type) {
05534
05535 case Integer:
05536
05537 switch(*kind) {
05538 case 1:
05539 *linear_type = Integer_1;
05540 break;
05541
05542 case 2:
05543 *linear_type = Integer_2;
05544 break;
05545
05546 case 4:
05547 *linear_type = Integer_4;
05548 break;
05549
05550 case 8:
05551 *linear_type = Integer_8;
05552 break;
05553
05554 default:
05555 *linear_type = INTEGER_DEFAULT_TYPE;
05556 ok = FALSE;
05557 break;
05558 }
05559 break;
05560
05561
05562 case Logical:
05563
05564 switch(*kind) {
05565 case 1:
05566 *linear_type = Logical_1;
05567 break;
05568
05569 case 2:
05570 *linear_type = Logical_2;
05571 break;
05572
05573 case 4:
05574 *linear_type = Logical_4;
05575 break;
05576
05577 case 8:
05578 *linear_type = Logical_8;
05579 break;
05580
05581 default:
05582 *linear_type = LOGICAL_DEFAULT_TYPE;
05583 ok = FALSE;
05584 break;
05585 }
05586 break;
05587
05588
05589 case Real:
05590
05591 switch(*kind) {
05592 case 4:
05593 *linear_type = Real_4;
05594 break;
05595
05596 case 8:
05597 *linear_type = Real_8;
05598 break;
05599
05600 case 16:
05601 *linear_type = Real_16;
05602
05603 # if defined(_TARGET_OS_MAX)
05604 PRINTMSG(line, 543, Warning, column, 16, 8);
05605 *linear_type = Real_8;
05606 # elif defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN)
05607 PRINTMSG(line, 541, Error, column);
05608 # endif
05609 break;
05610
05611 default:
05612 ok = FALSE;
05613 break;
05614 }
05615 break;
05616
05617
05618 case Complex:
05619
05620 switch(*kind) {
05621 case 4:
05622 *linear_type = Complex_4;
05623 break;
05624
05625 case 8:
05626 *linear_type = Complex_8;
05627 break;
05628
05629 case 16:
05630 *linear_type = Complex_16;
05631
05632 # if defined(_TARGET_OS_MAX)
05633 PRINTMSG(line, 543, Warning, column, 16, 8);
05634 *linear_type = Complex_8;
05635 # elif defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN)
05636 PRINTMSG(line, 541, Error, column);
05637 # endif
05638 break;
05639
05640 default:
05641 *linear_type = COMPLEX_DEFAULT_TYPE;
05642 ok = FALSE;
05643 break;
05644 }
05645 break;
05646
05647
05648 case Character:
05649
05650 switch(*kind) {
05651 case 1:
05652 *linear_type = Character_1;
05653 break;
05654
05655 default:
05656 *linear_type = CHARACTER_DEFAULT_TYPE;
05657 ok = FALSE;
05658 break;
05659 }
05660 break;
05661
05662
05663 default:
05664 *linear_type = Err_Res;
05665 ok = FALSE;
05666 break;
05667
05668 }
05669
05670 if (!ok) {
05671 sprintf(kind_str,"%ld", *kind);
05672 PRINTMSG(line, 130, Error, column,
05673 kind_str,
05674 basic_type_str[type]);
05675 *kind = 0;
05676 }
05677
05678 TRACE (Func_Exit, "validate_kind", NULL);
05679
05680 return(ok);
05681
05682 }
05683
05684
05685
05686
05687
05688
05689
05690
05691
05692
05693
05694
05695
05696
05697
05698
05699
05700
05701
05702
05703
05704
05705
05706
05707
05708
05709
05710
05711
05712
05713
05714
05715
05716
05717
05718
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
05744
05745
05746
05747
05748
05749
05750
05751 void assign_offset(int attr_idx)
05752
05753 {
05754 size_offset_type offset;
05755 boolean pack;
05756 size_offset_type pad;
05757 size_offset_type storage_size;
05758 int type_idx;
05759
05760 # if defined(_TARGET_DOUBLE_ALIGN)
05761 size_offset_type result;
05762 # endif
05763
05764
05765 TRACE (Func_Entry, "assign_offset", NULL);
05766
05767 if (ATD_SYMBOLIC_CONSTANT(attr_idx)) {
05768
05769
05770
05771 ATD_OFFSET_ASSIGNED(attr_idx) = TRUE;
05772 ATD_OFFSET_IDX(attr_idx) = CN_INTEGER_ZERO_IDX;
05773 ATD_OFFSET_FLD(attr_idx) = CN_Tbl_Idx;
05774 return;
05775 }
05776
05777 if (ATD_CLASS(attr_idx) == Struct_Component) {
05778 offset.fld = ATT_STRUCT_BIT_LEN_FLD(CURR_BLK_NAME);
05779 offset.idx = ATT_STRUCT_BIT_LEN_IDX(CURR_BLK_NAME);
05780 pack = TRUE;
05781 }
05782 else {
05783 offset.fld = SB_LEN_FLD(ATD_STOR_BLK_IDX(attr_idx));
05784 offset.idx = SB_LEN_IDX(ATD_STOR_BLK_IDX(attr_idx));
05785 pack = SB_IS_COMMON(ATD_STOR_BLK_IDX(attr_idx));
05786 }
05787
05788 storage_size = stor_bit_size_of(attr_idx,
05789 TRUE,
05790 FALSE);
05791
05792 type_idx = ATD_TYPE_IDX(attr_idx);
05793
05794 if (ATD_IM_A_DOPE(attr_idx)) {
05795
05796 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
05797 align_bit_length(&offset, storage_bit_size_tbl[CRI_Ptr_8]);
05798
05799 if (ATD_CLASS(attr_idx) == Struct_Component) {
05800
05801 if (cmd_line_flags.s_pointer8 && !cmd_line_flags.align32) {
05802 ATT_DALIGN_ME(CURR_BLK_NAME) = TRUE;
05803 ATD_ALIGNMENT(attr_idx) = Align_64;
05804 }
05805 }
05806 # else
05807 align_bit_length(&offset, TARGET_BITS_PER_WORD);
05808 ATD_ALIGNMENT(attr_idx) = WORD_ALIGN;
05809 # endif
05810
05811 if (offset.fld == NO_Tbl_Idx) {
05812 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
05813 offset.fld = CN_Tbl_Idx;
05814 }
05815 }
05816 else if (pack &&
05817 (TYP_TYPE(type_idx) == Character ||
05818 (TYP_TYPE(type_idx) == Structure &&
05819 ATT_CHAR_SEQ(TYP_IDX(type_idx))))) {
05820
05821
05822
05823 if (TYP_TYPE(type_idx) == Character) {
05824
05825 # if defined(_CHAR_IS_ALIGN_8)
05826 ATD_ALIGNMENT(attr_idx) = Align_8;
05827 # else
05828 ATD_ALIGNMENT(attr_idx) = Align_Bit;
05829 # endif
05830 }
05831 else {
05832 ATD_ALIGNMENT(attr_idx) = Align_Bit;
05833 }
05834 }
05835
05836 # if defined(_TARGET_PACK_HALF_WORD_TYPES)
05837
05838
05839
05840
05841 else if (PACK_HALF_WORD_TEST_CONDITION(type_idx)) {
05842
05843
05844
05845
05846
05847
05848
05849 align_bit_length(&offset, TARGET_BITS_PER_WORD / 2);
05850 ATD_ALIGNMENT(attr_idx) = Align_32;
05851
05852 if (offset.fld == NO_Tbl_Idx) {
05853 offset.fld = CN_Tbl_Idx;
05854 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
05855 }
05856 }
05857 # endif
05858
05859 # if defined(_INTEGER_1_AND_2)
05860
05861 else if (on_off_flags.integer_1_and_2 &&
05862 PACK_8_BIT_TEST_CONDITION(type_idx)) {
05863 align_bit_length(&offset, 8);
05864 ATD_ALIGNMENT(attr_idx) = Align_8;
05865
05866 if (offset.fld == NO_Tbl_Idx) {
05867 offset.fld = CN_Tbl_Idx;
05868 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
05869 }
05870 }
05871 else if (on_off_flags.integer_1_and_2 &&
05872 PACK_16_BIT_TEST_CONDITION(type_idx)){
05873 align_bit_length(&offset, 16);
05874 ATD_ALIGNMENT(attr_idx) = Align_16;
05875
05876 if (offset.fld == NO_Tbl_Idx) {
05877 offset.fld = CN_Tbl_Idx;
05878 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
05879 }
05880 }
05881
05882 # endif
05883
05884 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
05885
05886 # if 0
05887 else if (cmd_line_flags.align8) {
05888 align_bit_length(&offset, 8);
05889 ATD_ALIGNMENT(attr_idx) = Align_8;
05890
05891 if (offset.fld == NO_Tbl_Idx) {
05892 offset.fld = CN_Tbl_Idx;
05893 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
05894 }
05895 }
05896 else if (cmd_line_flags.align16) {
05897 align_bit_length(&offset, 16);
05898 ATD_ALIGNMENT(attr_idx) = Align_16;
05899
05900 if (offset.fld == NO_Tbl_Idx) {
05901 offset.fld = CN_Tbl_Idx;
05902 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
05903 }
05904 }
05905 # endif
05906 else if (cmd_line_flags.align32) {
05907 align_bit_length(&offset, 32);
05908 ATD_ALIGNMENT(attr_idx) = Align_32;
05909
05910 if (offset.fld == NO_Tbl_Idx) {
05911 offset.fld = CN_Tbl_Idx;
05912 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
05913 }
05914 }
05915 # endif
05916
05917 # if defined(_ALIGN_REAL16_TO_16_BYTES)
05918
05919 else if (TYP_LINEAR(type_idx) == Complex_16 ||
05920 TYP_LINEAR(type_idx) == Real_16) {
05921 #if defined(_TARGET64) && defined(_WHIRL_HOST64_TARGET64)
05922 align_bit_length(&offset, TARGET_BITS_PER_WORD*2);
05923 #else
05924 align_bit_length(&offset, TARGET_BITS_PER_WORD*4);
05925 #endif
05926 ATD_ALIGNMENT(attr_idx) = Align_128;
05927
05928 if (offset.fld == NO_Tbl_Idx) {
05929 offset.fld = CN_Tbl_Idx;
05930 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
05931 }
05932 }
05933 # endif
05934
05935 # if defined(_TARGET_DOUBLE_ALIGN)
05936
05937 else if (DALIGN_TEST_CONDITION(type_idx)) {
05938
05939
05940
05941 if (cmd_line_flags.dalign) {
05942
05943 if (ATD_STOR_BLK_IDX(attr_idx) != NULL_IDX &&
05944 SB_IS_COMMON(ATD_STOR_BLK_IDX(attr_idx)) ) {
05945
05946 align_bit_length(&offset, TARGET_BITS_PER_WORD);
05947
05948 if (offset.fld == NO_Tbl_Idx) {
05949 offset.fld = CN_Tbl_Idx;
05950 offset.idx = ntr_const_tbl(offset.type_idx,
05951 FALSE,
05952 offset.constant);
05953 }
05954
05955 C_TO_F_INT(result.constant,
05956 TARGET_BITS_PER_WORD * 2,
05957 CG_INTEGER_DEFAULT_TYPE);
05958 result.type_idx = CG_INTEGER_DEFAULT_TYPE;
05959 result.fld = NO_Tbl_Idx;
05960
05961 if (!size_offset_binary_calc(&offset, &result, Mod_Opr, &result)) {
05962 AT_DCL_ERR(attr_idx) = TRUE;
05963 }
05964
05965 if (result.fld == NO_Tbl_Idx) {
05966 result.fld = CN_Tbl_Idx;
05967 result.idx = ntr_const_tbl(result.type_idx,
05968 FALSE,
05969 result.constant);
05970 }
05971
05972 # if ! (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
05973
05974
05975
05976
05977
05978
05979 if (fold_relationals(result.idx,
05980 CN_INTEGER_ZERO_IDX,
05981 Ne_Opr)) {
05982 PRINTMSG(AT_DEF_LINE(attr_idx), 1013, Warning,
05983 AT_DEF_COLUMN(attr_idx),
05984 AT_OBJ_NAME_PTR(attr_idx),
05985 SB_BLANK_COMMON(ATD_STOR_BLK_IDX(attr_idx)) ?
05986 "" : SB_NAME_PTR(ATD_STOR_BLK_IDX(attr_idx)));
05987 }
05988 # endif
05989 }
05990 else if (ATD_CLASS(attr_idx) == Struct_Component) {
05991 ATT_DALIGN_ME(CURR_BLK_NAME) = TRUE;
05992 }
05993
05994 align_bit_length(&offset, TARGET_BITS_PER_WORD * 2);
05995 ATD_ALIGNMENT(attr_idx) = Align_64;
05996
05997 if (offset.fld == NO_Tbl_Idx) {
05998 offset.fld = CN_Tbl_Idx;
05999 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
06000 }
06001 }
06002 else if (ATD_CLASS(attr_idx) == Struct_Component &&
06003 !ATT_DCL_NUMERIC_SEQ(CURR_BLK_NAME)) {
06004
06005
06006
06007 align_bit_length(&offset, TARGET_BITS_PER_WORD * 2);
06008
06009 if (offset.fld == NO_Tbl_Idx) {
06010 offset.fld = CN_Tbl_Idx;
06011 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
06012 }
06013
06014 ATT_DALIGN_ME(CURR_BLK_NAME) = TRUE;
06015 ATD_ALIGNMENT(attr_idx) = Align_64;
06016 }
06017 else if (ATD_STOR_BLK_IDX(attr_idx) != NULL_IDX) {
06018
06019 if (SB_IS_COMMON(ATD_STOR_BLK_IDX(attr_idx))) {
06020
06021 align_bit_length(&offset, TARGET_BITS_PER_WORD);
06022 ATD_ALIGNMENT(attr_idx) = WORD_ALIGN;
06023
06024 if (offset.fld == NO_Tbl_Idx) {
06025 offset.fld = CN_Tbl_Idx;
06026 offset.idx = ntr_const_tbl(offset.type_idx,
06027 FALSE,
06028 offset.constant);
06029 }
06030
06031 C_TO_F_INT(result.constant,
06032 TARGET_BITS_PER_WORD * 2,
06033 CG_INTEGER_DEFAULT_TYPE);
06034 result.type_idx = CG_INTEGER_DEFAULT_TYPE;
06035 result.fld = NO_Tbl_Idx;
06036
06037 if (!size_offset_binary_calc(&offset, &result, Mod_Opr, &result)) {
06038 AT_DCL_ERR(attr_idx) = TRUE;
06039 }
06040
06041
06042
06043 if (result.fld == NO_Tbl_Idx) {
06044 result.fld = CN_Tbl_Idx;
06045 result.idx = ntr_const_tbl(result.type_idx,
06046 FALSE,
06047 result.constant);
06048 }
06049
06050 if (fold_relationals(result.idx,
06051 CN_INTEGER_ZERO_IDX,
06052 Ne_Opr)) {
06053
06054
06055
06056
06057
06058 PRINTMSG(AT_DEF_LINE(attr_idx), 1161, Caution,
06059 AT_DEF_COLUMN(attr_idx),
06060 AT_OBJ_NAME_PTR(attr_idx),
06061 SB_BLANK_COMMON(ATD_STOR_BLK_IDX(attr_idx)) ?
06062 "" : SB_NAME_PTR(ATD_STOR_BLK_IDX(attr_idx)));
06063 }
06064 }
06065 else {
06066
06067 align_bit_length(&offset, TARGET_BITS_PER_WORD * 2);
06068 ATD_ALIGNMENT(attr_idx) = Align_64;
06069
06070 if (offset.fld == NO_Tbl_Idx) {
06071 offset.fld = CN_Tbl_Idx;
06072 offset.idx = ntr_const_tbl(offset.type_idx,
06073 FALSE,
06074 offset.constant);
06075 }
06076 }
06077 }
06078 else {
06079 align_bit_length(&offset, TARGET_BITS_PER_WORD);
06080 ATD_ALIGNMENT(attr_idx) = WORD_ALIGN;
06081
06082 if (offset.fld == NO_Tbl_Idx) {
06083 offset.fld = CN_Tbl_Idx;
06084 offset.idx = ntr_const_tbl(offset.type_idx,
06085 FALSE,
06086 offset.constant);
06087 }
06088
06089 if (ATD_CLASS(attr_idx) == Struct_Component) {
06090 C_TO_F_INT(result.constant,
06091 TARGET_BITS_PER_WORD * 2,
06092 CG_INTEGER_DEFAULT_TYPE);
06093 result.fld = NO_Tbl_Idx;
06094 result.type_idx = CG_INTEGER_DEFAULT_TYPE;
06095
06096 if (!size_offset_binary_calc(&offset, &result, Mod_Opr, &result)) {
06097 AT_DCL_ERR(attr_idx) = TRUE;
06098 }
06099
06100 if (result.fld == NO_Tbl_Idx) {
06101 result.fld = CN_Tbl_Idx;
06102 result.idx = ntr_const_tbl(result.type_idx,
06103 FALSE,
06104 result.constant);
06105 }
06106
06107
06108
06109 if (fold_relationals(result.idx,
06110 CN_INTEGER_ZERO_IDX,
06111 Ne_Opr)) {
06112
06113
06114
06115
06116 PRINTMSG(AT_DEF_LINE(attr_idx), 1198, Caution,
06117 AT_DEF_COLUMN(attr_idx),
06118 AT_OBJ_NAME_PTR(attr_idx),
06119 AT_OBJ_NAME_PTR(CURR_BLK_NAME));
06120 }
06121 }
06122 }
06123 }
06124
06125 # endif
06126
06127 # if (defined(_TARGET_OS_IRIX) || defined(_TARGET_OS_LINUX) || defined(_TARGET_OS_DARWIN))
06128
06129 else if (TYP_TYPE(type_idx) == Structure &&
06130 ATT_ALIGNMENT(TYP_IDX(type_idx)) > WORD_ALIGN) {
06131
06132 switch (ATT_ALIGNMENT(TYP_IDX(type_idx))) {
06133 case Align_Double:
06134 case Align_128:
06135 align_bit_length(&offset, 128);
06136 ATD_ALIGNMENT(attr_idx) = ATT_ALIGNMENT(TYP_IDX(type_idx));
06137 break;
06138 }
06139
06140 if (offset.fld == NO_Tbl_Idx) {
06141 offset.fld = CN_Tbl_Idx;
06142 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
06143 }
06144 }
06145 # endif
06146 else {
06147 align_bit_length(&offset, TARGET_BITS_PER_WORD);
06148 ATD_ALIGNMENT(attr_idx) = WORD_ALIGN;
06149
06150 if (offset.fld == NO_Tbl_Idx) {
06151 offset.fld = CN_Tbl_Idx;
06152 offset.idx = ntr_const_tbl(offset.type_idx, FALSE, offset.constant);
06153 }
06154 }
06155
06156 if (ATD_CLASS(attr_idx) == Struct_Component) {
06157 ATD_OFFSET_FLD(attr_idx) = offset.fld;
06158 ATD_CPNT_OFFSET_IDX(attr_idx) = offset.idx;
06159
06160 if (!size_offset_binary_calc(&offset,
06161 &storage_size,
06162 Plus_Opr,
06163 &storage_size)) {
06164 AT_DCL_ERR(attr_idx) = TRUE;
06165 }
06166
06167 if (storage_size.fld == NO_Tbl_Idx) {
06168 ATT_STRUCT_BIT_LEN_FLD(CURR_BLK_NAME) = CN_Tbl_Idx;
06169 ATT_STRUCT_BIT_LEN_IDX(CURR_BLK_NAME) = ntr_const_tbl(
06170 storage_size.type_idx,
06171 FALSE,
06172 storage_size.constant);
06173 }
06174 else {
06175 ATT_STRUCT_BIT_LEN_FLD(CURR_BLK_NAME) = storage_size.fld;
06176 ATT_STRUCT_BIT_LEN_IDX(CURR_BLK_NAME) = storage_size.idx;
06177 }
06178 }
06179 else {
06180
06181
06182
06183
06184 ATD_OFFSET_IDX(attr_idx) = offset.idx;
06185 ATD_OFFSET_FLD(attr_idx) = offset.fld;
06186
06187 if (SB_PAD_BLK(ATD_STOR_BLK_IDX(attr_idx))) {
06188 calculate_pad(&pad, &storage_size, attr_idx);
06189
06190 if (!size_offset_binary_calc(&offset,
06191 &storage_size,
06192 Plus_Opr,
06193 &storage_size)) {
06194 AT_DCL_ERR(attr_idx) = TRUE;
06195 }
06196
06197 if (!size_offset_binary_calc(&pad,
06198 &storage_size,
06199 Plus_Opr,
06200 &storage_size)) {
06201 AT_DCL_ERR(attr_idx) = TRUE;
06202 }
06203 }
06204 else {
06205
06206 if (!size_offset_binary_calc(&offset,
06207 &storage_size,
06208 Plus_Opr,
06209 &storage_size)) {
06210 AT_DCL_ERR(attr_idx) = TRUE;
06211 }
06212 }
06213
06214 if (storage_size.fld == NO_Tbl_Idx) {
06215 storage_size.fld = CN_Tbl_Idx;
06216 storage_size.idx = ntr_const_tbl(storage_size.type_idx,
06217 FALSE,
06218 storage_size.constant);
06219 }
06220
06221 SB_LEN_FLD(ATD_STOR_BLK_IDX(attr_idx)) = storage_size.fld;
06222 SB_LEN_IDX(ATD_STOR_BLK_IDX(attr_idx)) = storage_size.idx;
06223 }
06224
06225 TRACE (Func_Exit, "assign_offset", NULL);
06226
06227 return;
06228
06229 }
06230 #ifdef KEY
06231
06232
06233
06234
06235
06236
06237
06238 void
06239 assign_bind_c_offset(int attr_idx, boolean bind_c) {
06240 boolean save_align32 = cmd_line_flags.align32;
06241 boolean save_align64 = cmd_line_flags.align64;
06242 if (is_x8664_n32() && bind_c) {
06243
06244 cmd_line_flags.align32 = TRUE;
06245 cmd_line_flags.align64 = FALSE;
06246 }
06247 assign_offset(attr_idx);
06248 cmd_line_flags.align32 = save_align32;
06249 cmd_line_flags.align64 = save_align64;
06250 }
06251 #endif
06252
06253
06254
06255
06256
06257
06258
06259
06260
06261
06262
06263
06264
06265
06266
06267
06268
06269
06270 static void calculate_pad(size_offset_type *pad,
06271 size_offset_type *storage_size,
06272 int attr_idx)
06273
06274 {
06275 size_offset_type constant;
06276 size_offset_type min_result;
06277 int sb_idx;
06278 size_offset_type temp_1;
06279 size_offset_type temp_2;
06280 size_offset_type wd_storage_size;
06281
06282
06283 TRACE (Func_Entry, "calculate_pad", NULL);
06284
06285 sb_idx = ATD_STOR_BLK_IDX(attr_idx);
06286
06287 if (! SB_PAD_AMOUNT_SET(sb_idx)) {
06288
06289
06290
06291 wd_storage_size = (*storage_size);
06292
06293 BITS_TO_WORDS(wd_storage_size, TARGET_BITS_PER_WORD);
06294
06295
06296
06297
06298
06299
06300
06301
06302
06303
06304 constant.fld = NO_Tbl_Idx;
06305 constant.type_idx = CG_INTEGER_DEFAULT_TYPE;
06306
06307 C_TO_F_INT(constant.constant, 1024, CG_INTEGER_DEFAULT_TYPE);
06308
06309 if (! size_offset_binary_calc(&wd_storage_size,
06310 &constant,
06311 Div_Opr,
06312 &temp_1)) {
06313 goto ERROR;
06314 }
06315
06316
06317
06318
06319 C_TO_F_INT(constant.constant, 1, CG_INTEGER_DEFAULT_TYPE);
06320
06321 if (! size_offset_min_max_calc(&constant,
06322 &temp_1,
06323 Min_Opr,
06324 &min_result)) {
06325 goto ERROR;
06326 }
06327
06328
06329
06330
06331 C_TO_F_INT(constant.constant, 256, CG_INTEGER_DEFAULT_TYPE);
06332
06333 if (! size_offset_binary_calc(&wd_storage_size,
06334 &constant,
06335 Mult_Opr,
06336 &temp_1)) {
06337 goto ERROR;
06338 }
06339
06340
06341
06342
06343 C_TO_F_INT(constant.constant, 4096, CG_INTEGER_DEFAULT_TYPE);
06344
06345 if (! size_offset_binary_calc(&temp_1, &constant, Div_Opr, &temp_2)) {
06346 goto ERROR;
06347 }
06348
06349
06350
06351
06352 C_TO_F_INT(constant.constant, 7, CG_INTEGER_DEFAULT_TYPE);
06353
06354 if (! size_offset_binary_calc(&temp_2, &constant, Plus_Opr, &temp_1)) {
06355 goto ERROR;
06356 }
06357
06358
06359
06360
06361 C_TO_F_INT(constant.constant, 8, CG_INTEGER_DEFAULT_TYPE);
06362
06363 if (! size_offset_binary_calc(&temp_1, &constant, Div_Opr, &temp_2)) {
06364 goto ERROR;
06365 }
06366
06367
06368
06369
06370 if (! size_offset_binary_calc(&temp_2, &constant, Mult_Opr, &temp_1)) {
06371 goto ERROR;
06372 }
06373
06374
06375
06376
06377 if (!size_offset_binary_calc(&min_result, &temp_1, Mult_Opr, &temp_2)) {
06378 goto ERROR;
06379 }
06380
06381
06382
06383
06384 C_TO_F_INT(constant.constant, 256, CG_INTEGER_DEFAULT_TYPE);
06385
06386 if (! size_offset_min_max_calc(&constant, &temp_2, Min_Opr, pad)) {
06387
06388
06389
06390 goto ERROR;
06391 }
06392
06393
06394
06395
06396 C_TO_F_INT(constant.constant, 128, CG_INTEGER_DEFAULT_TYPE);
06397
06398 if (! size_offset_binary_calc(&wd_storage_size,
06399 &constant,
06400 Div_Opr,
06401 &temp_1)) {
06402 goto ERROR;
06403 }
06404
06405
06406
06407
06408 C_TO_F_INT(constant.constant, 1, CG_INTEGER_DEFAULT_TYPE);
06409
06410 if (! size_offset_min_max_calc(&constant,
06411 &temp_1,
06412 Min_Opr,
06413 &min_result)) {
06414 goto ERROR;
06415 }
06416
06417
06418
06419
06420 C_TO_F_INT(constant.constant, 8, CG_INTEGER_DEFAULT_TYPE);
06421
06422 if (! size_offset_binary_calc(&min_result,
06423 &constant,
06424 Mult_Opr,
06425 &temp_1)) {
06426 goto ERROR;
06427 }
06428
06429
06430
06431
06432 if (! size_offset_binary_calc(pad, &temp_1, Plus_Opr, pad)) {
06433 goto ERROR;
06434 }
06435
06436
06437
06438
06439 C_TO_F_INT(constant.constant, 8, CG_INTEGER_DEFAULT_TYPE);
06440
06441 if (! size_offset_binary_calc(&wd_storage_size,
06442 &constant,
06443 Mod_Opr,
06444 &temp_1)) {
06445 goto ERROR;
06446 }
06447
06448
06449
06450
06451 if (! size_offset_binary_calc(&constant, &temp_1, Minus_Opr, &temp_2)) {
06452 goto ERROR;
06453 }
06454
06455
06456
06457
06458 if (! size_offset_binary_calc(&temp_2, &constant, Mod_Opr, &temp_1)) {
06459 goto ERROR;
06460 }
06461
06462
06463
06464
06465 if (! size_offset_binary_calc(pad, &temp_1, Plus_Opr, pad)) {
06466 goto ERROR;
06467 }
06468 }
06469 else {
06470 (*pad).fld = NO_Tbl_Idx;
06471 (*pad).type_idx = CG_INTEGER_DEFAULT_TYPE;
06472 C_TO_F_INT((*pad).constant,
06473 SB_PAD_AMOUNT(sb_idx),
06474 CG_INTEGER_DEFAULT_TYPE);
06475 }
06476
06477 constant.fld = NO_Tbl_Idx;
06478 constant.type_idx = CG_INTEGER_DEFAULT_TYPE;
06479 C_TO_F_INT(constant.constant, TARGET_BITS_PER_WORD, CG_INTEGER_DEFAULT_TYPE);
06480
06481 if (!size_offset_binary_calc(pad, &constant, Mult_Opr, pad)) {
06482 goto ERROR;
06483 }
06484
06485 goto DONE;
06486
06487 ERROR:
06488 (*pad).fld = CN_Tbl_Idx;
06489 (*pad).idx = CN_INTEGER_ZERO_IDX;
06490
06491 DONE:
06492
06493 TRACE (Func_Exit, "calculate_pad", NULL);
06494
06495 return;
06496
06497 }
06498
06499
06500
06501
06502
06503
06504
06505
06506
06507
06508
06509
06510
06511
06512
06513
06514 boolean srch_global_name_tbl(char *name_str,
06515 int name_len,
06516 int *name_idx)
06517
06518 {
06519 boolean found;
06520 int idx;
06521 long tst_val;
06522
06523
06524 TRACE (Func_Entry, "srch_global_name_tbl", name_str);
06525
06526 tst_val = srch_name_tbl(name_str,
06527 name_len,
06528 &idx,
06529 global_name_tbl,
06530 str_pool,
06531 1,
06532 global_name_tbl_idx);
06533 *name_idx = idx;
06534
06535 if (tst_val != 0) {
06536 found = FALSE;
06537 TRACE (Func_Exit, "srch_global_name_tbl", NULL);
06538 }
06539 else {
06540 found = TRUE;
06541 TRACE (Func_Exit, "srch_global_name_tbl",
06542 &str_pool[GN_NAME_IDX(idx)].name_char);
06543 }
06544 return (found);
06545
06546 }
06547
06548
06549
06550
06551
06552
06553
06554
06555
06556
06557
06558
06559
06560
06561
06562
06563
06564
06565
06566
06567
06568
06569 void ntr_global_name_tbl(int attr_idx,
06570 int sb_idx,
06571 int name_idx)
06572
06573
06574 {
06575 int ga_idx;
06576 register int i;
06577 register long *id;
06578 register int length;
06579
06580 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
06581 register long *global_tbl_base;
06582 # endif
06583
06584
06585 TRACE (Func_Entry, "ntr_global_name_tbl", NULL);
06586
06587 TBL_REALLOC_CK(global_name_tbl, 1);
06588
06589 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
06590 global_tbl_base = (long *) global_name_tbl;
06591
06592 # pragma _CRI ivdep
06593 for (i = global_name_tbl_idx; i >= name_idx; i--) {
06594 global_tbl_base[i] = global_tbl_base[i-1];
06595 }
06596
06597 # else
06598 for (i = global_name_tbl_idx; i >= name_idx; i--) {
06599 global_name_tbl[i] = global_name_tbl[i-1];
06600 }
06601 # endif
06602
06603 CLEAR_TBL_NTRY(global_name_tbl, name_idx);
06604
06605 if (sb_idx != NULL_IDX) {
06606 id = SB_NAME_LONG(sb_idx);
06607 length = SB_NAME_LEN(sb_idx);
06608 GN_NAME_IDX(name_idx) = str_pool_idx + 1;
06609 GN_NAME_LEN(name_idx) = length;
06610 length = WORD_LEN(length);
06611
06612
06613
06614 TBL_REALLOC_CK (str_pool, length);
06615
06616 for (i = 0; i < length; i++) {
06617 str_pool[GN_NAME_IDX(name_idx) + i].name_long = id[i];
06618 }
06619
06620 ga_idx = ntr_common_in_global_attr_tbl(sb_idx, name_idx);
06621
06622 GN_ATTR_IDX(name_idx) = ga_idx;
06623 }
06624 else if (attr_idx != NULL_IDX) {
06625 ga_idx = ntr_global_attr_tbl(attr_idx, NULL_IDX);
06626 GN_ATTR_IDX(name_idx) = ga_idx;
06627 GN_NAME_IDX(name_idx) = GA_NAME_IDX(ga_idx);
06628 GN_NAME_LEN(name_idx) = GA_NAME_LEN(ga_idx);
06629
06630 fill_in_global_attr_ntry(ga_idx, attr_idx, NULL_IDX);
06631
06632 }
06633
06634 TRACE (Func_Exit, "ntr_global_name_tbl", NULL);
06635
06636 return;
06637
06638 }
06639
06640 #ifdef KEY
06641
06642
06643
06644
06645
06646
06647 char *
06648 file_and_line(int def_line) {
06649 int gl_idx;
06650 uint act_file_line;
06651 GLOBAL_LINE_TO_FILE_LINE(def_line, gl_idx, act_file_line);
06652 const char *file_name = GL_FILE_NAME_PTR(gl_idx);
06653 char *alloc_str = malloc(strlen(file_name) + 32);
06654 sprintf(alloc_str, "%d (%s)", act_file_line, file_name);
06655 return alloc_str;
06656 }
06657
06658
06659
06660
06661
06662
06663
06664
06665 static void
06666 make_ga_binding_label(int ga_idx, const char *name, int name_len) {
06667 if (GA_BIND_ATTR(ga_idx)) {
06668 char *result = memcpy(malloc(name_len + 1), name, name_len);
06669 result[name_len] = 0;
06670 GA_BINDING_LABEL(ga_idx) = result;
06671 }
06672 else {
06673 GA_BINDING_LABEL(ga_idx) = 0;
06674 }
06675 }
06676 #endif
06677
06678
06679
06680
06681
06682
06683
06684
06685
06686
06687
06688
06689
06690
06691
06692
06693
06694
06695
06696
06697
06698
06699
06700
06701
06702
06703
06704
06705 void fill_in_global_attr_ntry(int ga_idx,
06706 int attr_idx,
06707 int ga_pgm_idx)
06708
06709 {
06710 int cn_idx;
06711 int first_sn_idx;
06712 int ga_darg_idx;
06713 int i;
06714 int module_idx;
06715 int name_idx;
06716 int new_idx;
06717 int num_dargs;
06718 int rslt_idx;
06719 int sn_idx;
06720
06721
06722 TRACE (Func_Entry, "fill_in_global_attr_ntry", NULL);
06723
06724 module_idx = AT_MODULE_IDX(attr_idx);
06725
06726 if (module_idx != NULL_IDX) {
06727
06728 if (srch_global_name_tbl(AT_OBJ_NAME_PTR(module_idx),
06729 AT_NAME_LEN(module_idx),
06730 &name_idx)) {
06731
06732
06733
06734
06735
06736 if (GA_OBJ_CLASS(GN_ATTR_IDX(name_idx)) == Common_Block) {
06737 GA_MODULE_IDX(ga_idx) = GAC_PGM_UNIT_IDX(GN_ATTR_IDX(name_idx));
06738 }
06739 else {
06740 GA_MODULE_IDX(ga_idx) = GN_ATTR_IDX(name_idx);
06741 }
06742 }
06743 else {
06744 ntr_global_name_tbl(module_idx, NULL_IDX, name_idx);
06745 GA_MODULE_IDX(ga_idx) = GN_ATTR_IDX(name_idx);
06746 }
06747 }
06748
06749 switch (AT_OBJ_CLASS(attr_idx)) {
06750 case Data_Obj:
06751
06752 GAD_CLASS(ga_idx) = ATD_CLASS(attr_idx);
06753 GAD_POINTER(ga_idx) = ATD_POINTER(attr_idx);
06754 #ifdef KEY
06755 GAD_VOLATILE(ga_idx) = ATD_VOLATILE(attr_idx);
06756 #endif
06757 GAD_TARGET(ga_idx) = ATD_TARGET(attr_idx);
06758
06759 if (ATD_ARRAY_IDX(attr_idx) != NULL_IDX) {
06760
06761
06762
06763
06764
06765 if (ATD_CLASS(attr_idx) == Struct_Component ||
06766 ATD_IN_COMMON(attr_idx)) {
06767 new_idx = ntr_global_bounds_tbl(ATD_ARRAY_IDX(attr_idx));
06768 GAD_ARRAY_IDX(ga_idx) = new_idx;
06769 }
06770 GAD_RANK(ga_idx) = BD_RANK(ATD_ARRAY_IDX(attr_idx));
06771 GAD_ASSUMED_SHAPE_ARRAY(ga_idx) =
06772 (BD_ARRAY_CLASS(ATD_ARRAY_IDX(attr_idx)) == Assumed_Shape);
06773 }
06774
06775 switch (ATD_CLASS(attr_idx)) {
06776 case Dummy_Argument:
06777 GAD_INTENT(ga_idx) = ATD_INTENT(attr_idx);
06778 new_idx = ntr_global_type_tbl(ATD_TYPE_IDX(attr_idx));
06779 GAD_TYPE_IDX(ga_idx) = new_idx;
06780
06781 if (GAD_ASSUMED_SHAPE_ARRAY(ga_idx) ||
06782 GA_OPTIONAL(ga_idx) ||
06783 GAD_POINTER(ga_idx) ||
06784 #ifdef KEY
06785 GAD_VOLATILE(ga_idx) ||
06786 #endif
06787 GAD_TARGET(ga_idx)) {
06788 GAP_NEEDS_EXPL_ITRFC(ga_pgm_idx) = TRUE;
06789 }
06790 break;
06791
06792 case Function_Result:
06793 new_idx = ntr_global_type_tbl(ATD_TYPE_IDX(attr_idx));
06794 GAD_TYPE_IDX(ga_idx) = new_idx;
06795
06796 if (GAD_RANK(ga_idx) != 0 ||
06797 GAD_POINTER(ga_idx) ||
06798 #ifdef KEY
06799
06800
06801
06802 #endif
06803 (GT_TYPE(GAD_TYPE_IDX(ga_idx)) == Character &&
06804 GT_CHAR_CLASS(GAD_TYPE_IDX(ga_idx)) == Var_Len_Char)) {
06805 GAP_NEEDS_EXPL_ITRFC(ga_pgm_idx) = TRUE;
06806 }
06807 break;
06808
06809 case CRI__Pointee:
06810 new_idx = ntr_global_type_tbl(ATD_TYPE_IDX(attr_idx));
06811 GAD_TYPE_IDX(ga_idx) = new_idx;
06812 break;
06813
06814 case Struct_Component:
06815
06816 if (ATD_POINTER(attr_idx) &&
06817 TYP_TYPE(ATD_TYPE_IDX(attr_idx)) == Derived_Type &&
06818 attr_idx == TYP_IDX(ATD_TYPE_IDX(attr_idx))) {
06819
06820
06821
06822 GAD_TYPE_IDX(ga_idx) = ATT_GLOBAL_TYPE_IDX(attr_idx);
06823 }
06824 else {
06825 new_idx = ntr_global_type_tbl(ATD_TYPE_IDX(attr_idx));
06826 GAD_TYPE_IDX(ga_idx) = new_idx;
06827 }
06828 break;
06829
06830 case Variable:
06831 new_idx = ntr_global_type_tbl(ATD_TYPE_IDX(attr_idx));
06832 GAD_TYPE_IDX(ga_idx) = new_idx;
06833 break;
06834
06835 default:
06836 new_idx = ntr_global_type_tbl(ATD_TYPE_IDX(attr_idx));
06837 GAD_TYPE_IDX(ga_idx) = new_idx;
06838 break;
06839 }
06840 break;
06841
06842 case Pgm_Unit:
06843
06844 GAP_PGM_UNIT(ga_idx) = ATP_PGM_UNIT(attr_idx);
06845 GAP_ELEMENTAL(ga_idx) = ATP_ELEMENTAL(attr_idx);
06846 GAP_NOSIDE_EFFECTS(ga_idx) = ATP_NOSIDE_EFFECTS(attr_idx);
06847 GAP_PURE(ga_idx) = ATP_PURE(attr_idx);
06848 GAP_RECURSIVE(ga_idx) = ATP_RECURSIVE(attr_idx);
06849 GAP_VFUNCTION(ga_idx) = ATP_VFUNCTION(attr_idx);
06850 ATP_GLOBAL_ATTR_IDX(attr_idx) = ga_idx;
06851 #ifdef KEY
06852 GA_BIND_ATTR(ga_idx) = AT_BIND_ATTR(attr_idx);
06853 if (GA_BIND_ATTR(ga_idx)) {
06854 GAP_NEEDS_EXPL_ITRFC(ga_idx) = TRUE;
06855 }
06856 make_ga_binding_label(ga_idx, ATP_EXT_NAME_PTR(attr_idx),
06857 ATP_EXT_NAME_LEN(attr_idx));
06858 #endif
06859
06860 if (GAP_ELEMENTAL(ga_idx)) {
06861 GAP_NEEDS_EXPL_ITRFC(ga_idx) = TRUE;
06862 }
06863
06864 # if 0
06865 if (attr_idx == SCP_ATTR_IDX(curr_scp_idx) ||
06866 (ATP_ALT_ENTRY(attr_idx) && ATP_SCP_ALIVE(attr_idx))) {
06867 }
06868 # endif
06869 if (ATP_EXPL_ITRFC(attr_idx)) {
06870 GA_DEFINED(ga_idx) = TRUE;
06871
06872 if (SCP_IS_INTERFACE(curr_scp_idx)) {
06873 GAP_IN_INTERFACE_BLK(ga_idx) = TRUE;
06874 }
06875 else {
06876 GAP_PGM_UNIT_DEFINED(ga_idx) = TRUE;
06877 }
06878 }
06879 else if (AT_REFERENCED(attr_idx) > Not_Referenced) {
06880 GA_REFERENCED(ga_idx) = TRUE;
06881 }
06882 else {
06883 }
06884
06885 if (ATP_PGM_UNIT(attr_idx) == Function ||
06886 ATP_PGM_UNIT(attr_idx) == Subroutine) {
06887
06888
06889
06890
06891
06892 if (ATP_EXTRA_DARG(attr_idx) && ATP_EXPL_ITRFC(attr_idx)) {
06893 first_sn_idx = ATP_FIRST_IDX(attr_idx) + 1;
06894 num_dargs = ATP_NUM_DARGS(attr_idx) - 1;
06895 }
06896 else {
06897 first_sn_idx = ATP_FIRST_IDX(attr_idx);
06898 num_dargs = ATP_NUM_DARGS(attr_idx);
06899 }
06900
06901 GAP_NUM_DARGS(ga_idx) = num_dargs;
06902
06903 if (num_dargs > 0) {
06904 ga_darg_idx = global_attr_tbl_idx + 1;
06905 GAP_FIRST_IDX(ga_idx) = ga_darg_idx;
06906 sn_idx = first_sn_idx;
06907
06908
06909
06910
06911 for (i = 0; i < num_dargs; i++ ) {
06912 ntr_global_attr_tbl(SN_ATTR_IDX(sn_idx), NULL_IDX);
06913 sn_idx++;
06914 }
06915
06916 sn_idx = first_sn_idx;
06917
06918 for (i = 0; i < num_dargs; i++) {
06919 fill_in_global_attr_ntry(ga_darg_idx,
06920 SN_ATTR_IDX(sn_idx),
06921 ga_idx);
06922 if (SN_LINE_NUM(sn_idx) != 0) {
06923 GA_DEF_LINE(ga_darg_idx) = SN_LINE_NUM(sn_idx);
06924 GA_DEF_COLUMN(ga_darg_idx) = SN_COLUMN_NUM(sn_idx);
06925 }
06926 ga_darg_idx++;
06927 sn_idx++;
06928 }
06929 }
06930
06931 if (ATP_RSLT_IDX(attr_idx) != NULL_IDX) {
06932 rslt_idx = ntr_global_attr_tbl(ATP_RSLT_IDX(attr_idx), NULL_IDX);
06933 fill_in_global_attr_ntry(rslt_idx, ATP_RSLT_IDX(attr_idx), ga_idx);
06934 GAP_RSLT_IDX(ga_idx) = rslt_idx;
06935 }
06936
06937 }
06938 break;
06939
06940 case Derived_Type:
06941 GAT_NUM_CPNTS(ga_idx) = ATT_NUM_CPNTS(attr_idx);
06942 GAT_PRIVATE_CPNT(ga_idx) = ATT_PRIVATE_CPNT(attr_idx);
06943 GAT_SEQUENCE_SET(ga_idx) = ATT_SEQUENCE_SET(attr_idx);
06944 cn_idx = ATT_STRUCT_BIT_LEN_IDX(attr_idx);
06945 GAT_STRUCT_LIN_TYPE(ga_idx) = TYP_LINEAR(CN_TYPE_IDX(cn_idx));
06946
06947 for (i = 0; i < num_host_wds[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]; i++) {
06948 GAT_STRUCT_BIT_LEN(ga_idx)[i] = CP_CONSTANT(CN_POOL_IDX(cn_idx) + i);
06949 }
06950
06951 break;
06952 }
06953
06954 TRACE (Func_Exit, "fill_in_global_attr_ntry", NULL);
06955
06956 return;
06957
06958 }
06959
06960
06961
06962
06963
06964
06965
06966
06967
06968
06969
06970
06971
06972
06973
06974
06975
06976
06977
06978 int ntr_global_attr_tbl(int attr_idx,
06979 int name_idx)
06980
06981 {
06982 int ga_idx;
06983 int i;
06984 long *id;
06985 int length;
06986
06987
06988 TRACE (Func_Entry, "ntr_global_attr_tbl", NULL);
06989
06990 TBL_REALLOC_CK(global_attr_tbl, 1);
06991 CLEAR_TBL_NTRY(global_attr_tbl, global_attr_tbl_idx);
06992 ga_idx = global_attr_tbl_idx;
06993
06994 #ifdef KEY
06995
06996 GA_DEF_LINE(ga_idx) = AT_DEF_LINE(attr_idx);
06997 GA_DEF_COLUMN(ga_idx) = AT_DEF_COLUMN(attr_idx);
06998 #endif
06999
07000 if (name_idx == NULL_IDX) {
07001
07002 if (AT_OBJ_CLASS(attr_idx) == Pgm_Unit &&
07003 ATP_PGM_UNIT(attr_idx) == Module &&
07004 ATP_MODULE_STR_IDX(attr_idx) != NULL_IDX) {
07005 GN_NAME_IDX(ga_idx) = ATP_MODULE_STR_IDX(attr_idx);
07006 GA_NAME_LEN(ga_idx) = AT_NAME_LEN(attr_idx);
07007 }
07008 else {
07009 id = AT_OBJ_NAME_LONG(attr_idx);
07010 length = AT_NAME_LEN(attr_idx);
07011 GA_NAME_IDX(ga_idx) = str_pool_idx + 1;
07012 GA_NAME_LEN(ga_idx) = length;
07013 length = WORD_LEN(length);
07014
07015
07016
07017 TBL_REALLOC_CK (str_pool, length);
07018
07019 for (i = 0; i < length; i++) {
07020 str_pool[GA_NAME_IDX(ga_idx) + i].name_long = id[i];
07021 }
07022 }
07023 }
07024 else {
07025 GA_NAME_IDX(ga_idx) = GN_NAME_IDX(name_idx);
07026 GA_NAME_LEN(ga_idx) = GN_NAME_LEN(name_idx);;
07027 }
07028
07029 if (AT_ORIG_NAME_IDX(attr_idx) == AT_NAME_IDX(attr_idx)) {
07030 GA_ORIG_NAME_IDX(ga_idx) = GA_NAME_IDX(ga_idx);
07031 GA_ORIG_NAME_LEN(ga_idx) = GA_NAME_LEN(ga_idx);
07032 }
07033 else if (AT_ORIG_NAME_IDX(attr_idx) != NULL_IDX) {
07034 id = AT_ORIG_NAME_LONG(attr_idx);
07035 length = AT_ORIG_NAME_LEN(attr_idx);
07036 GA_ORIG_NAME_IDX(ga_idx) = str_pool_idx + 1;
07037 GA_ORIG_NAME_LEN(ga_idx) = length;
07038 length = WORD_LEN(length);
07039
07040
07041
07042 TBL_REALLOC_CK (str_pool, length);
07043
07044 for (i = 0; i < length; i++) {
07045 str_pool[GA_ORIG_NAME_IDX(ga_idx) + i].name_long = id[i];
07046 }
07047 }
07048
07049 #if ! defined(KEY)
07050 GA_DEF_LINE(ga_idx) = AT_DEF_LINE(attr_idx);
07051 GA_DEF_COLUMN(ga_idx) = AT_DEF_COLUMN(attr_idx);
07052 #endif
07053 GA_OBJ_CLASS(ga_idx) = AT_OBJ_CLASS(attr_idx);
07054 GA_OPTIONAL(ga_idx) = AT_OPTIONAL(attr_idx);
07055 GA_COMPILER_GEND(ga_idx) = AT_COMPILER_GEND(attr_idx);
07056 GA_USE_ASSOCIATED(ga_idx) = AT_USE_ASSOCIATED(attr_idx);
07057
07058 TRACE (Func_Exit, "ntr_global_attr_tbl", NULL);
07059
07060 return(ga_idx);
07061
07062 }
07063
07064
07065
07066
07067
07068
07069
07070
07071
07072
07073
07074
07075
07076
07077
07078 int ntr_common_in_global_attr_tbl(int sb_idx,
07079 int name_idx)
07080
07081 {
07082 int attr_idx;
07083 int ga_idx;
07084 int new_idx;
07085 int prev_idx;
07086
07087
07088 TRACE (Func_Entry, "ntr_common_in_global_attr_tbl", NULL);
07089
07090 TBL_REALLOC_CK(global_attr_tbl, 1);
07091 CLEAR_TBL_NTRY(global_attr_tbl, global_attr_tbl_idx);
07092 ga_idx = global_attr_tbl_idx;
07093 GA_NAME_IDX(ga_idx) = GN_NAME_IDX(name_idx);
07094 GA_NAME_LEN(ga_idx) = GN_NAME_LEN(name_idx);
07095 GA_DEF_LINE(ga_idx) = SB_DEF_LINE(sb_idx);
07096 GA_DEF_COLUMN(ga_idx) = SB_DEF_COLUMN(sb_idx);
07097 GA_OBJ_CLASS(ga_idx) = Common_Block;
07098 GA_USE_ASSOCIATED(ga_idx) = SB_USE_ASSOCIATED(sb_idx);
07099 GAC_AUXILIARY(ga_idx) = SB_AUXILIARY(sb_idx);
07100 GAC_TASK_COMMON(ga_idx) = SB_BLK_TYPE(sb_idx) == Task_Common;
07101 GAC_EQUIVALENCED(ga_idx) = SB_EQUIVALENCED(sb_idx);
07102 GAC_ALIGN_SYMBOL(ga_idx) = SB_ALIGN_SYMBOL(sb_idx);
07103 GAC_FILL_SYMBOL(ga_idx) = SB_FILL_SYMBOL(sb_idx);
07104 GAC_SECTION_GP(ga_idx) = SB_SECTION_GP(sb_idx);
07105 GAC_SECTION_NON_GP(ga_idx) = SB_SECTION_NON_GP(sb_idx);
07106 GAC_CACHE_ALIGN(ga_idx) = SB_CACHE_ALIGN(sb_idx);
07107 #ifdef KEY
07108 GA_BIND_ATTR(ga_idx) = SB_BIND_ATTR(sb_idx);
07109 make_ga_binding_label(ga_idx, SB_EXT_NAME_PTR(sb_idx),
07110 SB_EXT_NAME_LEN(sb_idx));
07111 #endif
07112
07113
07114
07115 attr_idx = SB_FIRST_ATTR_IDX(sb_idx);
07116 prev_idx = NULL_IDX;
07117
07118 while (attr_idx != NULL_IDX) {
07119 new_idx = ntr_global_attr_tbl(attr_idx, NULL_IDX);
07120 fill_in_global_attr_ntry(new_idx, attr_idx, NULL_IDX);
07121
07122 if (prev_idx != NULL_IDX) {
07123 GAD_NEXT_IDX(prev_idx) = new_idx;
07124 }
07125 else {
07126 GAC_FIRST_MEMBER_IDX(ga_idx) = new_idx;
07127 }
07128 prev_idx = new_idx;
07129 attr_idx = ATD_NEXT_MEMBER_IDX(attr_idx);
07130 }
07131
07132 if (SB_MODULE_IDX(sb_idx) != NULL_IDX) {
07133
07134 if (srch_global_name_tbl(AT_OBJ_NAME_PTR(SB_MODULE_IDX(sb_idx)),
07135 AT_NAME_LEN(SB_MODULE_IDX(sb_idx)),
07136 &name_idx)) {
07137
07138
07139
07140
07141
07142 if (GA_OBJ_CLASS(GN_ATTR_IDX(name_idx)) == Common_Block) {
07143 GA_MODULE_IDX(ga_idx) = GAC_PGM_UNIT_IDX(GN_ATTR_IDX(name_idx));
07144 }
07145 else {
07146 GA_MODULE_IDX(ga_idx) = GN_ATTR_IDX(name_idx);
07147 }
07148 }
07149 else {
07150 ntr_global_name_tbl(SB_MODULE_IDX(sb_idx), NULL_IDX, name_idx);
07151 GA_MODULE_IDX(ga_idx) = GN_ATTR_IDX(name_idx);
07152 }
07153 }
07154
07155 TRACE (Func_Exit, "ntr_common_in_global_attr_tbl", NULL);
07156
07157 return(ga_idx);
07158
07159 }
07160
07161
07162
07163
07164
07165
07166
07167
07168
07169
07170
07171
07172
07173
07174
07175
07176
07177
07178 int ntr_global_type_tbl(int type_idx)
07179
07180 {
07181 int attr_idx;
07182 int cn_idx;
07183 boolean found;
07184 int ga_idx;
07185 int ga_cpnt_idx;
07186 int i;
07187 int new_type_idx;
07188 long *null_base;
07189 int sn_idx;
07190 long *type_tbl_base;
07191
07192
07193 TRACE (Func_Entry, "ntr_global_type_tbl", NULL);
07194
07195 if (TYP_TYPE(type_idx) == Character) {
07196 GT_TYPE(TYP_WORK_IDX) = TYP_TYPE(type_idx);
07197 GT_DCL_VALUE(TYP_WORK_IDX) = TYP_DCL_VALUE(type_idx);
07198 GT_DESC(TYP_WORK_IDX) = TYP_DESC(type_idx);
07199 GT_LINEAR_TYPE(TYP_WORK_IDX) = TYP_LINEAR(type_idx);
07200 GT_CHAR_CLASS(TYP_WORK_IDX) = TYP_CHAR_CLASS(type_idx);
07201 GT_STRUCT_IDX(TYP_WORK_IDX) = TYP_IDX(type_idx);
07202
07203 if (GT_CHAR_CLASS(TYP_WORK_IDX) == Const_Len_Char) {
07204 cn_idx = GT_STRUCT_IDX(TYP_WORK_IDX);
07205 GT_LENGTH_LIN_TYPE(TYP_WORK_IDX) = TYP_LINEAR(CN_TYPE_IDX(cn_idx));
07206
07207 for (i = 0; i < num_host_wds[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]; i++) {
07208 GT_LENGTH(TYP_WORK_IDX)[i] = CP_CONSTANT(CN_POOL_IDX(cn_idx) + i);
07209 }
07210 }
07211 GT_STRUCT_IDX(TYP_WORK_IDX) = NULL_IDX;
07212 }
07213 else if (TYP_TYPE(type_idx) == Structure) {
07214
07215 if (ATT_GLOBAL_TYPE_IDX(TYP_IDX(type_idx)) != NULL_IDX) {
07216
07217
07218
07219 new_type_idx = ATT_GLOBAL_TYPE_IDX(TYP_IDX(type_idx));
07220 goto EXIT;
07221 }
07222
07223 GT_TYPE(TYP_WORK_IDX) = TYP_TYPE(type_idx);
07224 GT_DCL_VALUE(TYP_WORK_IDX) = TYP_DCL_VALUE(type_idx);
07225 GT_DESC(TYP_WORK_IDX) = TYP_DESC(type_idx);
07226 GT_LINEAR_TYPE(TYP_WORK_IDX) = TYP_LINEAR(type_idx);
07227 GT_CHAR_CLASS(TYP_WORK_IDX) = TYP_CHAR_CLASS(type_idx);
07228 GT_STRUCT_IDX(TYP_WORK_IDX) = TYP_IDX(type_idx);
07229
07230 attr_idx = GT_STRUCT_IDX(TYP_WORK_IDX);
07231 ga_idx = ntr_global_attr_tbl(attr_idx, NULL_IDX);
07232
07233 TBL_REALLOC_CK(global_type_tbl, 1);
07234 new_type_idx = global_type_tbl_idx;
07235 global_type_tbl[new_type_idx] = global_type_tbl[TYP_WORK_IDX];
07236 GT_STRUCT_IDX(new_type_idx) = ga_idx;
07237 ATT_GLOBAL_TYPE_IDX(attr_idx) = new_type_idx;
07238
07239 fill_in_global_attr_ntry(ga_idx, attr_idx, NULL_IDX);
07240
07241 ga_cpnt_idx = global_attr_tbl_idx + 1;
07242 GAT_FIRST_CPNT_IDX(ga_idx) = ga_cpnt_idx;
07243
07244 sn_idx = ATT_FIRST_CPNT_IDX(attr_idx);
07245
07246
07247
07248
07249 for (i = 0; i < ATT_NUM_CPNTS(attr_idx); i++ ) {
07250 ntr_global_attr_tbl(SN_ATTR_IDX(sn_idx), NULL_IDX);
07251 sn_idx = SN_SIBLING_LINK(sn_idx);
07252 }
07253
07254 sn_idx = ATT_FIRST_CPNT_IDX(attr_idx);
07255
07256 for (i = 0; i < ATT_NUM_CPNTS(attr_idx); i++ ) {
07257 fill_in_global_attr_ntry(ga_cpnt_idx, SN_ATTR_IDX(sn_idx), NULL_IDX);
07258 sn_idx = SN_SIBLING_LINK(sn_idx);
07259 ga_cpnt_idx++;
07260 }
07261
07262 goto EXIT;
07263 }
07264 else {
07265 GT_TYPE(TYP_WORK_IDX) = TYP_TYPE(type_idx);
07266 GT_DCL_VALUE(TYP_WORK_IDX) = TYP_DCL_VALUE(type_idx);
07267 GT_DESC(TYP_WORK_IDX) = TYP_DESC(type_idx);
07268 GT_LINEAR_TYPE(TYP_WORK_IDX) = TYP_LINEAR(type_idx);
07269 GT_CHAR_CLASS(TYP_WORK_IDX) = TYP_CHAR_CLASS(type_idx);
07270 GT_STRUCT_IDX(TYP_WORK_IDX) = TYP_IDX(type_idx);
07271 }
07272
07273 null_base = (long *) global_type_tbl;
07274
07275 for (new_type_idx = 1; new_type_idx <= global_type_tbl_idx; new_type_idx++){
07276 found = TRUE;
07277 type_tbl_base = (long *) &(global_type_tbl[new_type_idx]);
07278
07279 for (i = 0; i < NUM_TYP_WDS; i++) {
07280
07281 if (null_base[i] != type_tbl_base[i]) {
07282 found = FALSE;
07283 }
07284 }
07285
07286 if (found) {
07287 goto EXIT;
07288 }
07289 }
07290
07291 TBL_REALLOC_CK(global_type_tbl, 1);
07292 new_type_idx = global_type_tbl_idx;
07293 global_type_tbl[new_type_idx] = global_type_tbl[TYP_WORK_IDX];
07294
07295 EXIT:
07296
07297 TRACE (Func_Exit, "ntr_global_type_tbl", NULL);
07298
07299 return(new_type_idx);
07300
07301 }
07302
07303
07304
07305
07306
07307
07308
07309
07310
07311
07312
07313
07314
07315
07316
07317
07318
07319 static int ntr_global_bounds_tbl(int bd_idx)
07320
07321 {
07322 int cn_idx;
07323 int dim;
07324 boolean found;
07325 int gb_idx;
07326 long *gb_tbl_base;
07327 int i;
07328 long *new_base;
07329 int new_gb_idx;
07330 int size;
07331 int type_idx;
07332
07333
07334 TRACE (Func_Entry, "ntr_global_bounds_tbl", NULL);
07335
07336 if (BD_GLOBAL_IDX(bd_idx) != NULL_IDX) {
07337 return(BD_GLOBAL_IDX(bd_idx));
07338 }
07339
07340
07341
07342 size = (BD_ARRAY_CLASS(bd_idx) != Explicit_Shape ||
07343 BD_ARRAY_SIZE(bd_idx) != Constant_Size) ? 1 : 1+(BD_RANK(bd_idx)*3);
07344
07345 gb_idx = global_bounds_tbl_idx + 1;
07346
07347 TBL_REALLOC_CK(global_bounds_tbl, size);
07348
07349 GB_RANK(gb_idx) = BD_RANK(bd_idx);
07350 GB_ARRAY_SIZE(gb_idx) = BD_ARRAY_SIZE(bd_idx);
07351 GB_ARRAY_CLASS(gb_idx) = BD_ARRAY_CLASS(bd_idx);
07352
07353 if (size > 1) {
07354
07355 for (dim = 1; dim <= BD_RANK(bd_idx); dim++) {
07356
07357 if (BD_LB_FLD(bd_idx,dim) == CN_Tbl_Idx) {
07358 cn_idx = BD_LB_IDX(bd_idx, dim);
07359
07360 for (i = 0; i < num_host_wds[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]; i++){
07361 GB_LOWER_BOUND(gb_idx, dim)[i] =
07362 CP_CONSTANT(CN_POOL_IDX(cn_idx) + i);
07363 }
07364 type_idx = ntr_global_type_tbl(CN_TYPE_IDX(cn_idx));
07365 GB_LB_TYPE(gb_idx, dim) = type_idx;
07366 }
07367
07368 if (BD_UB_FLD(bd_idx,dim) == CN_Tbl_Idx) {
07369 cn_idx = BD_UB_IDX(bd_idx, dim);
07370
07371 for (i = 0; i < num_host_wds[TYP_LINEAR(CN_TYPE_IDX(cn_idx))]; i++){
07372 GB_UPPER_BOUND(gb_idx, dim)[i] =
07373 CP_CONSTANT(CN_POOL_IDX(cn_idx) + i);
07374 }
07375 type_idx = ntr_global_type_tbl(CN_TYPE_IDX(cn_idx));
07376 GB_UB_TYPE(gb_idx, dim) = type_idx;
07377 }
07378 }
07379 }
07380
07381 new_base = (long *) &(global_bounds_tbl[gb_idx]);
07382 new_gb_idx = 1;
07383
07384 while (new_gb_idx <= (gb_idx - 1)) {
07385 found = TRUE;
07386 gb_tbl_base = (long *) &(global_bounds_tbl[new_gb_idx]);
07387
07388
07389
07390 for (i = 0; i < NUM_GB_WDS; i++) {
07391
07392 if (new_base[i] != gb_tbl_base[i]) {
07393 found = FALSE;
07394 }
07395 }
07396
07397 if (found && (size > 1)) {
07398
07399 for (i = 0; i < (GB_RANK(gb_idx) * 3); i++) {
07400
07401 if (new_base[i] != gb_tbl_base[i]) {
07402 found = FALSE;
07403 }
07404 }
07405 }
07406
07407 if (found) {
07408 global_bounds_tbl_idx = gb_idx - 1;
07409 gb_idx = new_gb_idx;
07410 goto EXIT;
07411 }
07412 new_gb_idx += NUM_GB_WDS;
07413
07414 if (GB_ARRAY_SIZE(new_gb_idx) == Constant_Size &&
07415 GB_ARRAY_CLASS(new_gb_idx) == Explicit_Shape) {
07416 new_gb_idx += (3 * GB_RANK(new_gb_idx));
07417 }
07418 }
07419
07420 EXIT:
07421 BD_GLOBAL_IDX(bd_idx) = gb_idx;
07422
07423 TRACE (Func_Exit, "ntr_global_bounds_tbl", NULL);
07424
07425 return(gb_idx);
07426
07427 }
07428
07429
07430
07431
07432
07433
07434
07435
07436
07437
07438
07439
07440
07441
07442
07443 int ntr_ir_tbl(void)
07444
07445 {
07446 int ir_idx;
07447
07448
07449 TRACE (Func_Entry, "ntr_ir_tbl", NULL);
07450
07451 if (IR_NEXT_IDX(NULL_IDX) != NULL_IDX) {
07452 ir_idx = IR_NEXT_IDX(NULL_IDX);
07453 IR_NEXT_IDX(NULL_IDX) = IR_NEXT_IDX(ir_idx);
07454 }
07455 else {
07456 TBL_REALLOC_CK(ir_tbl,1);
07457 ir_idx = ir_tbl_idx;
07458 }
07459
07460 CLEAR_TBL_NTRY(ir_tbl, ir_idx);
07461
07462 TRACE (Func_Exit, "ntr_ir_tbl", NULL);
07463
07464 return(ir_idx);
07465
07466 }
07467
07468
07469
07470
07471
07472
07473
07474
07475
07476
07477
07478
07479
07480
07481
07482 int ntr_ir_list_tbl(void)
07483
07484 {
07485 int il_idx;
07486
07487
07488 TRACE (Func_Entry, "ntr_ir_list_tbl", NULL);
07489
07490 if (IL_NEXT_LIST_IDX(NULL_IDX) != NULL_IDX) {
07491 il_idx = IL_NEXT_LIST_IDX(NULL_IDX);
07492 IL_NEXT_LIST_IDX(NULL_IDX) = IL_NEXT_LIST_IDX(il_idx);
07493 }
07494 else {
07495 TBL_REALLOC_CK (ir_list_tbl,1);
07496 il_idx = ir_list_tbl_idx;
07497 }
07498
07499 CLEAR_TBL_NTRY(ir_list_tbl, il_idx);
07500
07501 TRACE (Func_Exit, "ntr_ir_list_tbl", NULL);
07502
07503 return(il_idx);
07504
07505 }
07506
07507
07508
07509
07510
07511
07512
07513
07514
07515
07516
07517
07518
07519
07520
07521 int ntr_gl_ir_tbl(void)
07522
07523 {
07524 int ir_idx;
07525
07526
07527 TRACE (Func_Entry, "ntr_gl_ir_tbl", NULL);
07528
07529 TBL_REALLOC_CK(global_ir_tbl,1);
07530 ir_idx = global_ir_tbl_idx;
07531
07532 CLEAR_TBL_NTRY(global_ir_tbl, ir_idx);
07533
07534 TRACE (Func_Exit, "ntr_gl_ir_tbl", NULL);
07535
07536 return(ir_idx);
07537
07538 }
07539
07540
07541
07542
07543
07544
07545
07546
07547
07548
07549
07550
07551
07552
07553
07554 int ntr_gl_ir_list_tbl(void)
07555
07556 {
07557 int il_idx;
07558
07559
07560 TRACE (Func_Entry, "ntr_gl_ir_list_tbl", NULL);
07561
07562 TBL_REALLOC_CK (global_ir_list_tbl,1);
07563 il_idx = global_ir_list_tbl_idx;
07564
07565 CLEAR_TBL_NTRY(global_ir_list_tbl, il_idx);
07566
07567 TRACE (Func_Exit, "ntr_gl_ir_list_tbl", NULL);
07568
07569 return(il_idx);
07570
07571 }
07572
07573
07574
07575
07576
07577
07578
07579
07580
07581
07582
07583
07584
07585
07586
07587 int ntr_gl_sh_tbl(void)
07588
07589 {
07590 int sh_idx;
07591
07592
07593 TRACE (Func_Entry, "ntr_gl_sh_tbl", NULL);
07594
07595 TBL_REALLOC_CK(global_sh_tbl,1);
07596 sh_idx = global_sh_tbl_idx;
07597
07598 CLEAR_TBL_NTRY(global_sh_tbl, sh_idx);
07599
07600 TRACE (Func_Exit, "ntr_gl_sh_tbl", NULL);
07601
07602 return(sh_idx);
07603
07604 }
07605
07606
07607
07608
07609
07610
07611
07612
07613
07614
07615
07616
07617
07618
07619
07620 void add_attr_to_local_list(int attr_idx)
07621
07622 {
07623 int al_idx;
07624
07625
07626 TRACE (Func_Entry, "add_attr_to_local_list", NULL);
07627
07628 NTR_ATTR_LIST_TBL(al_idx);
07629 AL_ATTR_IDX(al_idx) = attr_idx;
07630
07631 if (SCP_ATTR_LIST(curr_scp_idx) == NULL_IDX) {
07632 SCP_ATTR_LIST(curr_scp_idx) = al_idx;
07633 }
07634 else {
07635 AL_NEXT_IDX(SCP_ATTR_LIST_END(curr_scp_idx)) = al_idx;
07636 }
07637
07638 SCP_ATTR_LIST_END(curr_scp_idx) = al_idx;
07639
07640 TRACE (Func_Exit, "add_attr_to_local_list", NULL);
07641
07642 return;
07643
07644 }
07645
07646
07647
07648
07649
07650
07651
07652
07653
07654
07655
07656
07657
07658
07659
07660 int ntr_sh_tbl(void)
07661
07662 {
07663 int sh_idx;
07664
07665
07666 TRACE (Func_Entry, "ntr_sh_tbl", NULL);
07667
07668 if (SH_NEXT_IDX(NULL_IDX) != NULL_IDX) {
07669 sh_idx = SH_NEXT_IDX(NULL_IDX);
07670 SH_NEXT_IDX(NULL_IDX) = SH_NEXT_IDX(sh_idx);
07671 }
07672 else {
07673 TBL_REALLOC_CK(sh_tbl,1);
07674 sh_idx = sh_tbl_idx;
07675 }
07676
07677 CLEAR_TBL_NTRY(sh_tbl, sh_idx);
07678
07679 TRACE (Func_Exit, "ntr_sh_tbl", NULL);
07680
07681 return(sh_idx);
07682
07683 }
07684
07685
07686
07687
07688
07689
07690
07691
07692
07693
07694
07695
07696
07697
07698
07699 void find_opnd_line_and_column(opnd_type *opnd,
07700 int *line,
07701 int *column)
07702
07703 {
07704 opnd_type tmp_opnd;
07705
07706 TRACE (Func_Entry, "find_opnd_line_and_column", NULL);
07707
07708 switch (OPND_FLD((*opnd))) {
07709 case CN_Tbl_Idx:
07710 case AT_Tbl_Idx:
07711 case SB_Tbl_Idx:
07712 *line = OPND_LINE_NUM((*opnd));
07713 *column = OPND_COL_NUM((*opnd));
07714 break;
07715
07716 case IR_Tbl_Idx:
07717 *line = IR_LINE_NUM(OPND_IDX((*opnd)));
07718 *column = IR_COL_NUM(OPND_IDX((*opnd)));
07719 break;
07720
07721 case IL_Tbl_Idx:
07722 COPY_OPND(tmp_opnd, IL_OPND(OPND_IDX((*opnd))));
07723 find_opnd_line_and_column(&tmp_opnd, line, column);
07724 break;
07725
07726 case SH_Tbl_Idx:
07727 *line = SH_GLB_LINE(OPND_IDX((*opnd)));
07728 *column = SH_COL_NUM(OPND_IDX((*opnd)));
07729 break;
07730
07731 default:
07732 *line = 0;
07733 *column = 0;
07734 break;
07735 }
07736
07737 TRACE (Func_Exit, "find_opnd_line_and_column", NULL);
07738
07739 return;
07740
07741 }
07742
07743
07744
07745
07746
07747
07748
07749
07750
07751
07752
07753
07754
07755
07756
07757
07758
07759
07760
07761
07762
07763
07764 int srch_hidden_name_tbl(char *name_str,
07765 int name_len,
07766 int attr_idx,
07767 int *np_idx,
07768 int *name_idx)
07769
07770 {
07771 int first;
07772 int idx;
07773 long tst_val;
07774
07775
07776 TRACE (Func_Entry, "srch_hidden_name_tbl", name_str);
07777
07778 first = SCP_HN_FW_IDX(curr_scp_idx);
07779
07780 tst_val = srch_name_tbl(name_str,
07781 name_len,
07782 &idx,
07783 hidden_name_tbl,
07784 name_pool,
07785 first,
07786 SCP_HN_LW_IDX(curr_scp_idx));
07787
07788
07789 *name_idx = idx;
07790
07791 if (tst_val != 0) {
07792 idx = NULL_IDX;
07793 *np_idx = NULL_IDX;
07794 }
07795 else {
07796
07797
07798
07799 while (HN_NAME_IDX(*name_idx) == HN_NAME_IDX((*name_idx) - 1)) {
07800 (*name_idx)--;
07801 }
07802
07803 *np_idx = HN_NAME_IDX(*name_idx);
07804
07805 if (attr_idx != NULL_IDX) {
07806 first = *name_idx;
07807
07808 while (HN_ATTR_IDX(*name_idx) != attr_idx) {
07809
07810 if (HN_NAME_IDX((*name_idx)++) != *np_idx) {
07811 *name_idx = first;
07812 break;
07813 }
07814 }
07815 }
07816 idx = HN_ATTR_IDX(*name_idx);
07817 }
07818
07819 TRACE (Func_Exit, "srch_hidden_name_tbl", NULL);
07820
07821 return (idx);
07822
07823 }
07824
07825
07826
07827
07828
07829
07830
07831
07832
07833
07834
07835
07836
07837
07838
07839
07840
07841
07842
07843
07844
07845
07846
07847
07848
07849 void ntr_hidden_name_tbl(int attr_idx,
07850 int np_idx,
07851 int name_idx)
07852
07853 {
07854 register int i;
07855 register int scp_idx;
07856
07857 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
07858 register long *name_tbl_base;
07859 # endif
07860
07861
07862 TRACE (Func_Entry, "ntr_hidden_name_tbl", NULL);
07863
07864 if (np_idx == NULL_IDX) {
07865 np_idx = AT_ORIG_NAME_IDX(attr_idx);
07866
07867 if (np_idx == NULL_IDX) {
07868 np_idx = AT_NAME_IDX(attr_idx);
07869 }
07870 }
07871
07872 TBL_REALLOC_CK(hidden_name_tbl, 1);
07873
07874 if ((hidden_name_tbl_idx - 1) != SCP_HN_LW_IDX(curr_scp_idx)) {
07875
07876
07877
07878
07879
07880 for (scp_idx = 1; scp_idx <= scp_tbl_idx; scp_idx++) {
07881
07882 if (SCP_HN_FW_IDX(scp_idx) > SCP_HN_LW_IDX(curr_scp_idx)) {
07883 SCP_HN_FW_IDX(scp_idx) = SCP_HN_FW_IDX(scp_idx) + 1;
07884 SCP_HN_LW_IDX(scp_idx) = SCP_HN_LW_IDX(scp_idx) + 1;
07885 }
07886 }
07887 SCP_HN_LW_IDX(curr_scp_idx)++;
07888 }
07889 else {
07890
07891
07892
07893
07894 SCP_HN_LW_IDX(curr_scp_idx) = hidden_name_tbl_idx;
07895 }
07896
07897
07898
07899 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
07900 name_tbl_base = (long *) hidden_name_tbl;
07901 # endif
07902
07903 # pragma _CRI ivdep
07904 for (i = hidden_name_tbl_idx; i >= name_idx; i--) {
07905 # if defined(_HOST64) && !defined(_WHIRL_HOST64_TARGET64)
07906 name_tbl_base [i] = name_tbl_base [i-1];
07907 # else
07908 hidden_name_tbl [i] = hidden_name_tbl [i-1];
07909 # endif
07910 }
07911
07912 CLEAR_TBL_NTRY(hidden_name_tbl, name_idx);
07913 HN_ATTR_IDX(name_idx) = attr_idx;
07914