00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 static const char *source_file = __FILE__;
00079
00080 #ifdef _KEEP_RCS_ID
00081 static char *rcs_id = "$Source: ../../../crayf90/sgi/SCCS/s.cwh_stab.cxx $ $Revision: 1.10 $";
00082 #endif
00083
00084
00085
00086
00087 #include "defs.h"
00088 #include "glob.h"
00089 #include "stab.h"
00090 #include "strtab.h"
00091 #include "errors.h"
00092 #include "targ_const.h"
00093 #include "config_targ.h"
00094 #include "const.h"
00095 #include "wn.h"
00096 #include "wn_util.h"
00097 #include "dwarf_DST_producer.h"
00098 #include "cxx_memory.h"
00099 #include <stdio.h>
00100
00101
00102
00103 #include "i_cvrt.h"
00104
00105
00106
00107 #include "cwh_defines.h"
00108 #include "cwh_types.h"
00109 #include "cwh_addr.h"
00110 #include "cwh_expr.h"
00111 #include "cwh_block.h"
00112 #include "cwh_stmt.h"
00113 #include "cwh_preg.h"
00114 #include "cwh_auxst.h"
00115 #include "cwh_stab.h"
00116 #include "cwh_stab.i"
00117 #include "cwh_dst.h"
00118 #ifdef KEY
00119 #include "cwh_directive.h"
00120 #endif
00121 #include "cwh_mkdepend.h"
00122 #include "sgi_cmd_line.h"
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141 extern INTPTR
00142 fei_next_func_idx(INT32 Pu_arg,
00143 INT32 Proc_arg,
00144 INT32 altentry_idx)
00145 {
00146
00147 STB_pkt *p ;
00148 static INT32 i = 0 ;
00149 PROC_CLASS proc ;
00150
00151 proc = (PROC_CLASS) Proc_arg;
00152
00153 if (altentry_idx == 0) {
00154
00155
00156 if (NOT_IN_PU) {
00157
00158 New_Scope (HOST_LEVEL, FE_Mempool, TRUE );
00159 cwh_auxst_register_table();
00160 Host_Top = -1;
00161 Has_nested_proc = FALSE ;
00162 Hosted_Equivalences = NULL;
00163 Alttemp_ST = NULL;
00164 Altbase_ST = NULL;
00165 Altaddress_ST = NULL;
00166
00167 }
00168
00169 if (proc == PDGCS_Proc_Intern) {
00170
00171 New_Scope (INTERNAL_LEVEL, FE_Mempool, TRUE);
00172 cwh_auxst_register_table();
00173 }
00174
00175 Equivalences = NULL;
00176 entry_point_count = 0 ;
00177 STB_list = NULL ;
00178 }
00179
00180 i++;
00181 p = cwh_stab_packet(cast_to_void((INTPTR)i), is_CONST);
00182 return(cast_to_long(p));
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196 INTPTR
00197 fei_proc(char *name_string,
00198 INT32 lineno,
00199 INT32 Sym_class_arg,
00200 INT32 Class_arg,
00201 INT32 num_dum_args,
00202 INT32 parent_stx,
00203 INT32 first_st_idx,
00204 INT32 alt_entry_idx,
00205 TYPE result_type,
00206 INT32 proc_idx,
00207 INT64 flags )
00208 {
00209 #ifdef KEY
00210 INTPTR p = 0;
00211 #else
00212 INTPTR p;
00213 #endif
00214
00215 if (test_flag(flags, FEI_PROC_DEFINITION)) {
00216 p = fei_proc_def(name_string,
00217 lineno,
00218 Sym_class_arg,
00219 Class_arg,
00220 0,
00221 0,
00222 num_dum_args,
00223 parent_stx,
00224 first_st_idx,
00225 alt_entry_idx,
00226 result_type,
00227 0,
00228 proc_idx,
00229 flags);
00230 }
00231
00232 if (test_flag(flags, FEI_PROC_PARENT)) {
00233 p = fei_proc_parent(name_string,
00234 lineno,
00235 Sym_class_arg,
00236 0,
00237 num_dum_args,
00238 parent_stx,
00239 first_st_idx,
00240 alt_entry_idx,
00241 result_type,
00242 proc_idx,
00243 flags);
00244 }
00245
00246 if (test_flag(flags, FEI_PROC_IMPORTED)) {
00247 p = fei_proc_imp(lineno,
00248 name_string,
00249 0,
00250 0,
00251 Sym_class_arg,
00252 Class_arg,
00253 result_type,
00254 flags);
00255 }
00256
00257 return(p);
00258 }
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281 INTPTR
00282 fei_proc_def(char *name_string,
00283 INT32 lineno,
00284 INT32 Sym_class_arg,
00285 INT32 Class_arg,
00286 INT32 unused1,
00287 INT32 unused2,
00288 INT32 num_dum_args,
00289 INT32 parent_stx,
00290 INT32 first_st_idx,
00291 INT32 alt_entry_idx,
00292 TYPE result_type,
00293 INT32 cmcs_node,
00294 INT32 proc_idx,
00295 INT64 flags )
00296 {
00297 ST * st ;
00298 TY_IDX ty ;
00299 STB_pkt *p ;
00300 FUNCTION_SYM sym_class;
00301 PROC_CLASS Class;
00302 BOOL is_inline_func = FALSE;
00303 ST_EXPORT eclass;
00304 TY_IDX ret_ty;
00305
00306 still_in_preamble = TRUE;
00307
00308 sym_class = (FUNCTION_SYM) Sym_class_arg;
00309 Class = (PROC_CLASS) Class_arg;
00310
00311
00312
00313 ret_ty = cast_to_TY(t_TY(result_type)) ;
00314 ty = cwh_types_mk_procedure_TY(ret_ty,num_dum_args,TRUE,FALSE);
00315
00316 if (Class == PDGCS_Proc_Intern) {
00317
00318 eclass = EXPORT_LOCAL_INTERNAL;
00319 is_inline_func = TRUE;
00320 Has_nested_proc = TRUE;
00321
00322 } else {
00323
00324 eclass = EXPORT_PREEMPTIBLE;
00325 if (test_flag(flags,FEI_PROC_OPTIONAL_DIR))
00326 eclass = EXPORT_OPTIONAL;
00327
00328 }
00329
00330
00331
00332 st = cwh_auxst_find_item(Top_Text,name_string);
00333
00334 if (st == NULL) {
00335
00336 PU_IDX idx = cwh_stab_mk_pu(ty, CURRENT_SYMTAB);
00337
00338 st = New_ST(GLOBAL_SYMTAB);
00339 cwh_auxst_clear(st);
00340 ST_Init (st, Save_Str(name_string), CLASS_FUNC, SCLASS_TEXT, eclass, (TY_IDX) idx);
00341 Set_ST_ofst(st,0);
00342 cwh_auxst_add_to_list(&Top_Text,st,FALSE);
00343
00344 } else {
00345 Set_ST_sclass(st, SCLASS_TEXT);
00346 Set_ST_export(st, eclass);
00347 }
00348
00349
00350
00351
00352 PU_IDX pu_idx = ST_pu(st);
00353 PU& pu = Pu_Table[pu_idx];
00354
00355 Set_PU_prototype (pu, ty);
00356 Set_PU_f90_lang (pu);
00357
00358 #ifdef TARG_X8664
00359 if (Check_FF2C_Script(name_string, 1))
00360 Set_PU_ff2c_abi(pu);
00361 #endif
00362
00363 if (is_inline_func)
00364 Set_PU_is_inline_function(pu);
00365
00366 cwh_stab_set_linenum(st,lineno);
00367
00368
00369
00370
00371 if (sym_class == Main_Pgm) {
00372
00373 INTPTR midx;
00374 Set_PU_is_mainpu(pu);
00375 Set_PU_no_inline(pu);
00376
00377 Main_ST = NULL;
00378
00379 if (strcmp(crayf90_def_main,ST_name(st)) != 0) {
00380
00381 midx = fei_proc_imp(lineno,
00382 def_main,
00383 0,
00384 0,
00385 Main_Pgm,
00386 PDGCS_Proc_Imported,
00387 result_type,
00388 0);
00389
00390 Main_ST = cast_to_ST(cast_to_STB(midx)->item);
00391 Set_ST_pu(Main_ST, pu_idx);
00392 cwh_stab_set_linenum(Main_ST,lineno);
00393 }
00394 }
00395
00396 #if 0
00397 if (sym_class == Fort_Blockdata)
00398 DevWarn(("TODO_NEW_SYMTAB: blockdata"));
00399 #endif
00400
00401 if (sym_class == F90_Module) {
00402 cwh_add_to_module_files_table(name_string);
00403 }
00404
00405 if (Class == PDGCS_Proc_Intern)
00406 Set_PU_is_nested_func(pu);
00407
00408 if (Class == PDGCS_Proc_Extern)
00409 if (Has_nested_proc)
00410 Set_PU_uplevel(pu);
00411
00412 if (test_flag(flags, FEI_PROC_RECURSE))
00413 Set_PU_recursive(pu);
00414
00415 cwh_auxst_alloc_proc_entry(st,num_dum_args, ret_ty);
00416
00417 if (test_flag(flags, FEI_PROC_HASRSLT))
00418 Set_ST_auxst_has_rslt_tmp(st,TRUE);
00419
00420 if (test_flag(flags, FEI_PROC_ELEMENTAL))
00421 Set_ST_auxst_is_elemental(st,TRUE);
00422
00423 if (test_flag(flags, FEI_PROC_ENTRY)) {
00424
00425 Set_ST_auxst_is_altentry(st,TRUE);
00426 cwh_auxst_add_item(Procedure_ST,st,l_ALTENTRY);
00427
00428 } else {
00429
00430 Scope_tab [Current_scope].st = st;
00431 Procedure_ST = st ;
00432 cwh_stab_pu_has_globals = FALSE;
00433 cwh_block_init_pu();
00434
00435 if (test_flag(flags, FEI_PROC_HAS_ALT_ENTRY))
00436 Set_PU_has_altentry(pu);
00437 }
00438
00439 if ((Class == PDGCS_Proc_Extern) ||
00440 (Class == PDGCS_Proc_Intern))
00441 cwh_stab_adjust_name(st);
00442
00443 st_for_distribute_temp=NULL;
00444 preg_for_distribute.preg=-1;
00445
00446 entry_point_count++ ;
00447
00448 p = cwh_stab_packet(st, is_ST);
00449 return(cast_to_long(p));
00450 }
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468 INTPTR
00469 fei_proc_imp(INT32 lineno,
00470 const char *name_string,
00471 INT32 unused1,
00472 INT32 unused2,
00473 INT32 Sclass_arg,
00474 INT32 Class_arg,
00475 TYPE result_type,
00476 INT64 flags)
00477 {
00478 ST * st ;
00479 STB_pkt *p ;
00480 PROC_CLASS Class;
00481 FUNCTION_SYM sym_class;
00482
00483
00484 sym_class = (FUNCTION_SYM) Sclass_arg;
00485 Class = (PROC_CLASS) Class_arg;
00486
00487 st = NULL ;
00488 switch (Class) {
00489 case PDGCS_Proc_Imported:
00490 case PDGCS_Proc_Intern_Ref:
00491
00492 st = cwh_auxst_find_item(Top_Text,name_string);
00493
00494 if ( st == NULL ) {
00495
00496 ST_EXPORT eclass = EXPORT_PREEMPTIBLE;
00497
00498 if (test_flag(flags,FEI_PROC_OPTIONAL_DIR))
00499 eclass = EXPORT_OPTIONAL;
00500
00501
00502
00503
00504
00505 INT32 level = HOST_LEVEL ;
00506 if (Class == PDGCS_Proc_Intern_Ref){
00507
00508 level = INTERNAL_LEVEL;
00509 eclass = EXPORT_LOCAL_INTERNAL;
00510 }
00511
00512 st = cwh_stab_mk_fn_0args(name_string,
00513 eclass,
00514 level,
00515 cast_to_TY(t_TY(result_type)));
00516
00517 cwh_auxst_add_to_list(&Top_Text,st,FALSE);
00518 }
00519 break;
00520
00521 default:
00522 break;
00523 }
00524
00525 if (sym_class == F90_Module)
00526 Set_ST_emit_symbol(st);
00527
00528 if (test_flag(flags, FEI_PROC_HASRSLT))
00529 Set_ST_auxst_has_rslt_tmp(st,TRUE) ;
00530
00531 if (test_flag(flags, FEI_PROC_ELEMENTAL))
00532 Set_ST_auxst_is_elemental(st,TRUE);
00533
00534 p = cwh_stab_packet(st, is_ST);
00535 return(cast_to_long(p));
00536 }
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547 extern INTPTR
00548 fei_arith_con(TYPE type, SLONG *start)
00549 {
00550 WN * wn;
00551 ST * st;
00552 TY_IDX ty;
00553 TYPE_ID bt;
00554 TCON tcon;
00555 QUAD_TYPE q,q1 ;
00556 float *f;
00557 double *d;
00558 #ifdef KEY
00559 STB_pkt * r = 0;
00560 #else
00561 STB_pkt * r ;
00562 #endif
00563 INT64 iconst;
00564
00565 ty = cast_to_TY(t_TY(type));
00566 bt = TY_mtype(ty) ;
00567
00568 if (MTYPE_is_integral(bt)) {
00569
00570
00571 if (bt == MTYPE_I8 || bt == MTYPE_U8) {
00572 iconst = *(INT64 *) start;
00573 } else {
00574 iconst = (INT64) * start;
00575 }
00576 if (bt == MTYPE_I1) {
00577 iconst = (iconst << 56) >> 56;
00578 } else if (bt == MTYPE_I2) {
00579 iconst = (iconst << 48) >> 48;
00580 } else if (bt == MTYPE_I4) {
00581 iconst = (iconst << 32) >> 32;
00582 }
00583
00584 wn = WN_CreateIntconst(Intconst_Opcode [op_form [bt]],
00585 iconst) ;
00586
00587 r = cwh_stab_packet(wn,is_WN);
00588
00589 } else if (MTYPE_is_void(bt)) {
00590
00591 wn = WN_CreateIntconst(OPC_U8INTCONST,(INT64) * (UINT32 *)start) ;
00592 r = cwh_stab_packet(wn,is_WN);
00593
00594 } else if (MTYPE_is_float(bt)) {
00595
00596 switch (bt) {
00597 case MTYPE_F4 :
00598 tcon = Host_To_Targ_Float_4(bt,(float) * (float *) start);
00599 break ;
00600
00601 case MTYPE_F8 :
00602 tcon = Host_To_Targ_Float(bt,(double) * (double *) start);
00603 break ;
00604
00605 case MTYPE_FQ:
00606
00607 memcpy(&q,start,sizeof (QUAD_TYPE));
00608 tcon = Host_To_Targ_Quad(q);
00609 break ;
00610
00611 case MTYPE_C4 :
00612 f = (float *)start;
00613 tcon = Host_To_Targ_Complex_4 ( bt, *f, *(f+1) );
00614 break ;
00615
00616 case MTYPE_C8 :
00617 d = (double *) start;
00618 tcon = Host_To_Targ_Complex( bt, *d, *(d+1) );
00619 break ;
00620
00621 case MTYPE_CQ :
00622 memcpy(&q,start,sizeof (QUAD_TYPE));
00623 memcpy(&q1,start+4,sizeof (QUAD_TYPE));
00624 tcon = Host_To_Targ_Complex_Quad (q,q1);
00625 break ;
00626
00627 default:
00628 DevAssert((0),("Odd float constant"));
00629 }
00630
00631 st = New_Const_Sym(Enter_tcon (tcon), ty);
00632 r = cwh_stab_packet(st,is_ST);
00633
00634 } else
00635 DevAssert((0),("Unimplemented constant"));
00636
00637 return (cast_to_long(r)) ;
00638
00639 }
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651 extern INTPTR
00652 fei_pattern_con(TYPE type,char *start,INT64 bitsize)
00653 {
00654 TY_IDX ty ;
00655 ST * st ;
00656
00657 TCON tc;
00658
00659 ty = cast_to_TY(t_TY(type));
00660 tc = Host_To_Targ_String (MTYPE_STRING,start,TY_size(ty));
00661 st = Gen_String_Sym (&tc,ty,FALSE);
00662
00663 return(cast_to_long(st));
00664
00665 }
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683 INTPTR
00684 fei_proc_parent( char *name_string,
00685 INT32 lineno,
00686 INT32 Sym_class_arg,
00687 INT32 unused,
00688 INT32 num_dum_args,
00689 INT32 parent_stx,
00690 INT32 first_st_idx,
00691 INT32 aux_idx,
00692 TYPE result_type,
00693 INTPTR st_idx,
00694 INT64 flags )
00695 {
00696 INT32 level;
00697 FUNCTION_SYM sym_class;
00698
00699 sym_class = (FUNCTION_SYM) Sym_class_arg;
00700
00701 st_idx = fei_proc_imp(lineno,
00702 name_string,
00703 0,
00704 0,
00705 sym_class,
00706 PDGCS_Proc_Imported,
00707 result_type,
00708 flags);
00709
00710 level = PU_lexical_level(Get_Current_PU()) - 1;
00711
00712 if (level != GLOBAL_SYMTAB) {
00713 STB_pkt * p ;
00714
00715 Current_scope = level;
00716
00717
00718
00719
00720
00721 p = cast_to_STB(st_idx);
00722 Scope_tab[level].st = cast_to_ST(p->item);
00723 }
00724
00725 if (test_flag(flags, FEI_PROC_HAS_ALT_ENTRY))
00726 Set_PU_has_altentry(Get_Current_PU ());
00727
00728 return(st_idx);
00729 }
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754 INTPTR
00755 fei_object(char * name_string,
00756 TYPE type,
00757 INT64 flag_bits,
00758 INT32 Sym_class_arg,
00759 INTPTR storage_idx,
00760 INT32 arg_num,
00761 INTPTR ptr_st_idx,
00762 INT64 offset,
00763 INT32 arg_intent,
00764 INT64 size,
00765 INT32 type_aux,
00766 INT32 alignment,
00767 INT32 distr_idx,
00768 INT32 node_1,
00769 INT32 node_2,
00770 INT32 lineno)
00771 {
00772 TY_IDX ty ;
00773 ST * st ;
00774 ST * base_st ;
00775
00776 BOOL hosted ;
00777 BOOL eq ;
00778 BOOL in_common ;
00779 INT64 off ;
00780 SYMTAB_IDX st_level;
00781
00782 STB_pkt *p;
00783 STB_pkt *o;
00784 STB_pkt *b;
00785
00786 OBJECT_SYM sym_class;
00787
00788 sym_class = (OBJECT_SYM) Sym_class_arg;
00789
00790 ty = cast_to_TY(t_TY(type));
00791 p = cast_to_STB(storage_idx);
00792
00793 hosted = (sym_class == Hosted_Dummy_Procedure) ||
00794 (sym_class == Hosted_Dummy_Arg ) ||
00795 (sym_class == Hosted_Compiler_Temp) ||
00796 (sym_class == Hosted_User_Variable ) ||
00797 (sym_class == CRI_Pointee &&
00798 (test_flag(flag_bits,FEI_OBJECT_INNER_REF) ||
00799 test_flag(flag_bits,FEI_OBJECT_INNER_DEF))) ;
00800
00801
00802
00803
00804
00805
00806
00807
00808 if (hosted &&
00809 sym_class != Hosted_Compiler_Temp &&
00810 !test_flag(flag_bits,FEI_OBJECT_INNER_REF) &&
00811 !test_flag(flag_bits,FEI_OBJECT_INNER_DEF) &&
00812 !test_flag(flag_bits,FEI_OBJECT_NAMELIST_ITEM))
00813 return (0);
00814
00815
00816
00817 if (test_flag(flag_bits,FEI_OBJECT_SF_DARG))
00818 return(0);
00819
00820
00821
00822
00823
00824 if ((test_flag(flag_bits,FEI_OBJECT_INNER_REF)) ||
00825 (test_flag(flag_bits,FEI_OBJECT_INNER_DEF)) ||
00826 (sym_class == Hosted_Compiler_Temp)) {
00827
00828 ST * sl = cwh_stab_earlier_hosted(name_string);
00829 if (sl != NULL) {
00830
00831 cwh_stab_adjust_base_name(sl);
00832
00833
00834
00835
00836
00837
00838 if (sym_class == Dummy_Arg || sym_class == Dummy_Procedure) {
00839
00840 if (ST_is_return_var(sl) && TY_kind(ST_type(sl)) != KIND_POINTER)
00841 cwh_auxst_patch_proc(ST_type(sl));
00842
00843 else {
00844
00845 BOOL rtmp = test_flag(flag_bits,FEI_OBJECT_RESULT_TEMP);
00846 ST * dmst = sl;
00847
00848
00849
00850 if (rtmp && Altaddress_ST != NULL)
00851 dmst = Altaddress_ST ;
00852
00853 cwh_auxst_add_dummy(dmst,rtmp);
00854 }
00855 }
00856
00857 o = cwh_stab_packet(sl,is_ST);
00858 return(cast_to_long(o));
00859 }
00860 }
00861
00862
00863
00864
00865
00866 off = 0 ;
00867 if (test_flag(flag_bits,FEI_OBJECT_OFF_ASSIGNED)) {
00868
00869 off = bit_to_byte(offset);
00870
00871 if (p->form == is_SCLASS)
00872 if ((cast_to_SCLASS(p->item) != SCLASS_COMMON) &&
00873 (cast_to_SCLASS(p->item) != SCLASS_DGLOBAL))
00874 off = 0 ;
00875 }
00876
00877
00878
00879
00880 in_common = ((p->form == is_ST) && (IS_COMMON(cast_to_ST(p->item)))) ||
00881 ((sym_class == CRI_Pointee) && IS_COMMON(cast_to_ST((cast_to_STB(ptr_st_idx))->item)));
00882
00883
00884 if (in_common) {
00885
00886
00887
00888
00889 if (sym_class == CRI_Pointee) {
00890
00891 STB_pkt *bb = cast_to_STB(ptr_st_idx);
00892 DevAssert((bb->form == is_ST),("odd pointer base"));
00893
00894 ST * ptr = cast_to_ST(bb->item);
00895 DevAssert((ptr),("odd pointee"));
00896
00897 st = cwh_auxst_cri_pointee(ST_base(ptr),0);
00898 } else {
00899 st = cwh_stab_seen_common_element(cast_to_ST(p->item),off,name_string);
00900 #ifdef KEY
00901
00902
00903
00904
00905
00906 if (st) {
00907 cwh_auxst_add_item(ST_base(st),st,l_PU_COMLIST) ;
00908 }
00909 #endif
00910 }
00911
00912 if (st) {
00913 if (test_flag(flag_bits,FEI_OBJECT_NOT_PT_TO_UNIQUE_MEM)) {
00914 Clear_ST_pt_to_unique_mem(st);
00915 }
00916 o = cwh_stab_packet(st,is_ST);
00917
00918 if (decl_distribute_pragmas)
00919 cwh_stab_distrib_pragmas(st) ;
00920 return(cast_to_long(o));
00921 }
00922 }
00923
00924
00925
00926
00927 if (in_common || (sym_class == Name)) {
00928
00929 st_level = GLOBAL_SYMTAB ;
00930
00931 } else {
00932
00933 st_level = CURRENT_SYMTAB;
00934 if (hosted && IN_NESTED_PU)
00935 st_level = HOST_LEVEL ;
00936 }
00937
00938 st = New_ST(st_level);
00939 cwh_auxst_clear(st);
00940
00941 ST_Init(st,
00942 Save_Str(name_string),
00943 object_map[sym_class],
00944 cast_to_SCLASS(p->item),
00945 EXPORT_LOCAL,
00946 ty);
00947
00948 if (sym_class == Name) {
00949 Set_ST_is_not_used (st);
00950 }
00951
00952 Set_ST_base(st,st);
00953 Set_ST_ofst(st, off);
00954
00955 cwh_stab_set_linenum(st,lineno);
00956
00957
00958
00959
00960
00961
00962 if ((sym_class == Dummy_Procedure) ||
00963 #ifdef KEY
00964 test_flag(flag_bits, FEI_OBJECT_PASS_BY_VALUE) ||
00965 #endif
00966 (sym_class == Hosted_Dummy_Procedure)) {
00967
00968 Set_ST_is_value_parm(st);
00969 ty = cwh_types_mk_procedure_TY (ty,0,TRUE,hosted);
00970
00971 Set_ST_type(st, cwh_types_mk_pointer_TY(ty,hosted));
00972 }
00973
00974
00975
00976
00977
00978 if ((sym_class == Compiler_Temp) ||
00979 (sym_class == Hosted_Compiler_Temp)) {
00980 Set_ST_auxst_is_tmp(st,TRUE);
00981
00982 if (ST_sclass(st) == SCLASS_AUTO ||
00983 ST_sclass(st) == SCLASS_FORMAL ||
00984 ST_sclass(st) == SCLASS_FORMAL_REF)
00985 Set_ST_is_temp_var(st);
00986 }
00987
00988
00989
00990
00991 if (test_flag(flag_bits,FEI_OBJECT_ASSUMD_SHAPE) ||
00992 test_flag(flag_bits,FEI_OBJECT_DV_IS_PTR)) {
00993 Set_ST_auxst_is_non_contiguous(st, TRUE);
00994 }
00995
00996 if (test_flag(flag_bits,FEI_OBJECT_READ_ONLY)) {
00997 Set_ST_is_const_var(st);
00998 }
00999
01000
01001
01002
01003
01004 #ifdef KEY
01005 ST *original_st = 0;
01006 #endif
01007 if (ST_sclass(st) == SCLASS_FORMAL) {
01008 BOOL formal = TRUE;
01009
01010 if (test_flag(flag_bits,FEI_OBJECT_RESULT_TEMP)) {
01011
01012
01013
01014 if (STRUCT_BY_VALUE(ty)) {
01015
01016 Set_ST_sclass(st, SCLASS_AUTO);
01017
01018
01019
01020 if (! hosted)
01021 cwh_auxst_patch_proc(ty);
01022
01023 formal = FALSE;
01024 sym_class = Function_Rslt ;
01025 p->form = is_UNDEF ;
01026
01027 } else
01028 Set_ST_auxst_is_rslt_tmp(st, TRUE);
01029
01030
01031 if (TY_kind(ty) != KIND_STRUCT) {
01032
01033
01034
01035
01036 Set_ST_type(st, cwh_types_mk_pointer_TY(ty,hosted));
01037 Set_ST_is_value_parm(st);
01038 }
01039
01040 if (TY_kind(ty) != KIND_SCALAR) {
01041
01042
01043
01044
01045
01046
01047 if (ST_level(st) == HOST_LEVEL) {
01048 if (Alttemp_ST != NULL) {
01049 #ifdef KEY
01050 original_st = st;
01051 #endif
01052 st = Alttemp_ST ;
01053 }
01054
01055 Alttemp_ST = st ;
01056 }
01057
01058 } else if (TY_mtype(ty) == MTYPE_CQ) {
01059
01060
01061
01062
01063
01064 if (PU_has_altentry(Get_Current_PU())) {
01065
01066 ST * rt = st ;
01067
01068
01069
01070
01071 st = cwh_stab_altentry_temp(ST_name(st),hosted);
01072
01073 Set_ST_name(rt, Save_Str(".resaddr."));
01074
01075 if (Altaddress_ST == NULL)
01076 Altaddress_ST = rt ;
01077
01078 if (hosted)
01079 Set_ST_has_nested_ref(Altaddress_ST);
01080 else
01081 cwh_auxst_add_dummy(Altaddress_ST,TRUE);
01082
01083
01084 cwh_auxst_add_item(ST_base(st),st,l_EQVLIST);
01085 Set_ST_is_equivalenced(st);
01086
01087 sym_class = Function_Rslt ;
01088 p->form = is_UNDEF ;
01089 formal = FALSE;
01090 }
01091 }
01092 }
01093 if (formal)
01094 cwh_stab_formal_ref(st,hosted);
01095 }
01096
01097
01098
01099 if (test_flag(flag_bits,FEI_OBJECT_OPTIONAL)) {
01100 Set_ST_is_optional_argument(st);
01101 }
01102
01103
01104
01105
01106 if (test_flag(flag_bits,FEI_OBJECT_ALLOCATE) ||
01107 test_flag(flag_bits,FEI_OBJECT_ASSUMD_SHAPE)) {
01108
01109 if (!test_flag(flag_bits,FEI_OBJECT_TARGET) &&
01110 !test_flag(flag_bits,FEI_OBJECT_NOT_PT_TO_UNIQUE_MEM)) {
01111 Set_ST_pt_to_unique_mem(st);
01112 }
01113 }
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123 if (p->form == is_SCLASS && (cast_to_SCLASS(p->item) == SCLASS_BASED)) {
01124
01125 if (sym_class == CRI_Pointee) {
01126 b = cast_to_STB(ptr_st_idx);
01127 base_st = cast_to_ST(b->item);
01128 cwh_auxst_cri_pointee(base_st, st);
01129
01130 } else {
01131 b = cast_to_STB((UINTPS) offset);
01132 base_st = cast_to_ST(b->item);
01133 }
01134
01135 Set_ST_base(st, base_st);
01136 Set_ST_ofst(st, 0);
01137 Set_ST_sclass(st, ST_sclass(base_st));
01138
01139 Set_ST_auxst_is_auto_or_cpointer(st, TRUE);
01140
01141 if (test_flag(flag_bits, FEI_OBJECT_TARGET))
01142 Set_ST_is_f90_target(base_st) ;
01143 else if (sym_class != CRI_Pointee &&
01144 !test_flag(flag_bits,FEI_OBJECT_NOT_PT_TO_UNIQUE_MEM))
01145 Set_ST_pt_to_unique_mem(base_st);
01146
01147 Set_ST_type(base_st, cwh_types_mk_pointer_TY(ty,hosted));
01148
01149
01150
01151 if (!hosted)
01152 cwh_stab_adjust_base_name(st);
01153 }
01154
01155
01156
01157
01158
01159 eq = test_flag(flag_bits,FEI_OBJECT_EQUIV) ;
01160
01161 if (p->form == is_ST) {
01162 Set_ST_sclass(st, ST_sclass(cast_to_ST(p->item)));
01163 Set_ST_base(st, cast_to_ST(p->item));
01164
01165
01166
01167
01168 if (ST_sclass(st) == SCLASS_DGLOBAL)
01169 Set_ST_is_initialized(st);
01170
01171 if (eq)
01172 Set_ST_is_equivalenced(st);
01173 }
01174
01175
01176
01177 if (hosted) {
01178 cwh_stab_enter_hosted(st);
01179
01180 if (IS_AUTO_OR_FORMAL(st))
01181 Set_ST_has_nested_ref(st);
01182
01183 }
01184
01185
01186
01187
01188
01189 if ((sym_class == Function_Rslt) ||
01190 (hosted && test_flag(flag_bits,FEI_OBJECT_RESULT_TEMP))) {
01191
01192 if (Has_Base_Block(st)) {
01193
01194 TY_IDX temp_ty_idx = ST_type (ST_base(st));
01195 Set_TY_align (temp_ty_idx, 8);
01196 Set_ST_type (ST_base(st), temp_ty_idx);
01197 Set_ST_is_return_var(ST_base(st));
01198 cwh_stab_altres_offset(st,hosted);
01199
01200 } else if (ST_sclass(st) != SCLASS_FORMAL_REF)
01201 Set_ST_is_return_var(st);
01202 }
01203
01204
01205
01206
01207
01208 if (IS_FORMAL(st)) {
01209 if (! hosted )
01210 cwh_auxst_add_dummy(st,test_flag(flag_bits,FEI_OBJECT_RESULT_TEMP));
01211 }
01212
01213
01214
01215 if (Has_Base_Block(st)) {
01216
01217 if (IS_COMMON(ST_base(st))) {
01218 if (sym_class != CRI_Pointee)
01219 cwh_auxst_add_item(ST_base(st),st,l_COMLIST) ;
01220 #ifdef KEY
01221
01222
01223
01224
01225 cwh_auxst_add_item(ST_base(st),st,l_PU_COMLIST) ;
01226 #endif
01227
01228 } else if (eq) {
01229 cwh_auxst_add_item(ST_base(st),st,l_EQVLIST);
01230 }
01231 }
01232
01233
01234
01235 if (test_flag(flag_bits, FEI_OBJECT_DV_IS_PTR)) {
01236 Set_ST_auxst_is_f90_pointer(st, TRUE);
01237 if (ST_sclass(st) == SCLASS_FORMAL) {
01238 DevAssert(TY_is_f90_pointer(TY_pointed(ST_type(st))),(" missing pf90p"));
01239 } else {
01240 DevAssert(TY_is_f90_pointer(ST_type(st)),(" missing f90p"));
01241 }
01242 }
01243
01244 if (test_flag(flag_bits, FEI_OBJECT_ALLOCATE))
01245 Set_ST_auxst_is_allocatable(st, TRUE) ;
01246
01247 if (test_flag(flag_bits, FEI_OBJECT_ASSUMD_SHAPE))
01248 Set_ST_auxst_is_assumed_shape(st, TRUE) ;
01249
01250 if (test_flag(flag_bits, FEI_OBJECT_ASSUMED_SIZE))
01251 Set_ST_auxst_is_assumed_size(st, TRUE) ;
01252
01253 if (test_flag(flag_bits, FEI_OBJECT_TARGET))
01254 Set_ST_is_f90_target(st) ;
01255
01256 if (test_flag(flag_bits, FEI_OBJECT_ACTUAL_ARG))
01257 cwh_expr_set_flags(st,f_T_PASSED);
01258
01259
01260
01261
01262 if (decl_distribute_pragmas)
01263 cwh_stab_distrib_pragmas(st) ;
01264
01265 if (!Has_Base_Block(st))
01266 DevAssert((ST_ofst(st) == 0),("Offset?"));
01267
01268 o = cwh_stab_packet(st,is_ST);
01269 #ifdef KEY
01270
01271
01272
01273 if (original_st && ST_sclass(st) == SCLASS_FORMAL_REF) {
01274 STR_IDX save_name_idx = original_st->u1.name_idx;
01275 ST_IDX save_st_idx = original_st->st_idx;
01276 *original_st = *st;
01277 original_st->u1.name_idx = save_name_idx;
01278 original_st->st_idx = save_st_idx;
01279 }
01280 #endif
01281 return(cast_to_long(o));
01282 }
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305 INTPTR
01306 fei_seg (char * name_string,
01307 INT32 Seg_type_arg,
01308 INT32 owner,
01309 INT32 parent,
01310 INT32 aux_index,
01311 INT32 flag_bits,
01312 INT32 nest_level,
01313 INT64 block_length )
01314 {
01315 INT32 rt ;
01316 ST *st ;
01317 STB_pkt *p ;
01318 SEGMENT_TYPE seg_type;
01319 TY_IDX ty;
01320
01321 seg_type = (SEGMENT_TYPE) Seg_type_arg;
01322
01323 if (seg_type == Seg_Common) {
01324
01325 BOOL is_duplicate = test_flag(flag_bits,FEI_SEG_DUPLICATE);
01326 st = cwh_stab_earlier_common(name_string,is_duplicate);
01327
01328 if (st == NULL) {
01329
01330 st = cwh_stab_common_ST(name_string, block_length,0);
01331
01332 if (test_flag(flag_bits,FEI_SEG_THREADPRIVATE)) {
01333 Set_ST_is_thread_private(st);
01334 Set_ST_not_gprel(st);
01335
01336 #ifdef KEY
01337 cwh_directive_set_PU_flags(FALSE);
01338 #endif
01339 }
01340
01341 if (test_flag(flag_bits,FEI_SEG_MODULE))
01342 Set_ST_auxst_is_module_data(st,TRUE);
01343
01344 cwh_auxst_add_to_list(&Commons_Already_Seen,st,FALSE);
01345
01346 ty = ST_type(st);
01347
01348 if (test_flag(flag_bits,FEI_SEG_VOLATILE))
01349 Set_TY_is_volatile(ty);
01350
01351 } else {
01352
01353 if (test_flag(flag_bits,FEI_SEG_THREADPRIVATE)) {
01354 Set_ST_is_thread_private(st);
01355 Set_ST_not_gprel(st);
01356
01357 #ifdef KEY
01358 cwh_directive_set_PU_flags(FALSE);
01359 #endif
01360 }
01361 #ifdef KEY
01362
01363
01364
01365 cwh_clear_PU_common_list(st);
01366 #endif
01367 }
01368
01369
01370
01371 cwh_auxst_add_item(Procedure_ST,st,l_DST_COMLIST);
01372
01373 p = cwh_stab_packet(st,is_ST);
01374
01375 } else if (test_flag(flag_bits,FEI_SEG_EQUIVALENCED)) {
01376
01377
01378
01379 st = cwh_stab_earlier_hosted(name_string);
01380
01381 if (st == NULL) {
01382
01383 SYMTAB_IDX level = CURRENT_SYMTAB;
01384
01385 if (seg_type == Seg_Non_Local_Stack)
01386 level = HOST_LEVEL ;
01387
01388 st = New_ST(level);
01389 cwh_auxst_clear(st);
01390 ST_Init(st, Save_Str(name_string), CLASS_VAR, SCLASS_AUTO, EXPORT_LOCAL,0);
01391 Set_ST_base(st, st);
01392 Set_ST_ofst(st, 0);
01393
01394 if (test_flag(flag_bits,FEI_SEG_SAVED) || (seg_type == Seg_Static_Local))
01395 Set_ST_sclass(st, SCLASS_PSTATIC);
01396 else
01397 Set_ST_is_temp_var(st);
01398
01399 if (seg_type == Seg_Non_Local_Stack) {
01400
01401 cwh_stab_enter_hosted(st);
01402 Set_ST_has_nested_ref(st);
01403 }
01404
01405 Set_ST_type(st, cwh_types_mk_equiv_TY(block_length));
01406 cwh_stab_to_list_of_equivs(st,seg_type == Seg_Non_Local_Stack);
01407 }
01408
01409 p = cwh_stab_packet(st,is_ST);
01410
01411 } else {
01412
01413 rt = cast_to_int(segment_map[seg_type]);
01414 p = cwh_stab_packet(cast_to_void((INTPTR)rt),is_SCLASS);
01415 }
01416
01417 return (cast_to_long(p));
01418 }
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438 INTPTR
01439 fei_name (char *name_string,
01440 INT32 st_grp,
01441 INTPTR st_idx,
01442 INT32 prev_idx,
01443 INT32 idx )
01444 {
01445 ST * st;
01446 STB_pkt *p;
01447 STB_pkt *r;
01448
01449 r = NULL ;
01450
01451 switch ((SYM_GROUP)st_grp) {
01452 case Sym_Namelist:
01453
01454 if (prev_idx == 0)
01455 Namelist = NULL;
01456
01457 p = cast_to_STB(st_idx);
01458 DevAssert((p->form == is_ST),(" name item??"));
01459
01460 st = cast_to_ST(p->item);
01461 (void) cwh_auxst_add_to_list(&Namelist,st,FALSE) ;
01462 r = cwh_stab_packet(cast_to_void(Namelist),is_LIST);
01463 break ;
01464
01465 case Sym_Object:
01466
01467 if (st_idx != 0){
01468
01469 if (entry_point_count > 1 ) {
01470
01471 p = cast_to_STB(st_idx);
01472
01473 if (p->form == is_ST) {
01474 st = cast_to_ST(p->item) ;
01475
01476 if (IS_FORMAL(st)) {
01477 if (!cwh_auxst_find_dummy(st))
01478 cwh_auxst_add_dummy(st,FALSE);
01479 }
01480 }
01481 }
01482 } else {
01483
01484 cwh_mkdepend_add_name(idx, name_string);
01485 }
01486
01487 case Sym_Null:
01488 cwh_mkdepend_add_name(idx, name_string);
01489 break;
01490
01491 default:
01492 break ;
01493 }
01494 return(cast_to_long(r));
01495 }
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509 INTPTR
01510 fei_namelist(char * name_string,
01511 INT32 nitems,
01512 INTPTR idx )
01513 {
01514 ST * st;
01515 TY_IDX ty;
01516 STB_pkt *p;
01517 STB_pkt *l;
01518
01519 ty = cwh_types_mk_namelist_TY(nitems);
01520
01521 st = New_ST(CURRENT_SYMTAB);
01522 cwh_auxst_clear(st);
01523 ST_Init(st, Save_Str(name_string), CLASS_VAR, SCLASS_AUTO, EXPORT_LOCAL, ty);
01524 Set_ST_is_temp_var(st);
01525 #ifdef KEY
01526 Set_ST_is_namelist(st);
01527 #endif
01528 Set_ST_ofst(st, 0);
01529
01530 p = cwh_stab_packet(cast_to_void(st),is_ST) ;
01531
01532 l = cast_to_STB(idx);
01533 DevAssert((l->form == is_LIST),("Nm list??"));
01534 cwh_auxst_add_list(st, (LIST *) l->item, l_NAMELIST);
01535
01536 return (cast_to_long(p));
01537 }
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554 INT32
01555 fei_label(char *name_string,
01556 INT32 flags,
01557 INT32 Class,
01558 char *fmt_string,
01559 INT32 debug)
01560 {
01561 LABEL_IDX l_idx;
01562
01563 switch ((LABEL_SYM)Class) {
01564
01565 case PDGCS_Lbl_User :
01566 case PDGCS_Lbl_Format:
01567 {
01568 LABEL& lbl = New_LABEL (CURRENT_SYMTAB, l_idx);
01569 LABEL_Init(lbl, Save_Str(name_string), LKIND_DEFAULT);
01570 }
01571 break ;
01572
01573 case PDGCS_Lbl_Internal:
01574 {
01575 LABEL& int_lbl = New_LABEL (CURRENT_SYMTAB, l_idx);
01576 LABEL_Init(int_lbl, 0, LKIND_DEFAULT);
01577 }
01578 break ;
01579
01580 default:
01581 DevAssert((0),(" Unexpected Label"));
01582
01583 }
01584 return(cast_to_int(l_idx));
01585 }
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601 extern void
01602 cwh_stab_set_symtab(ST *st)
01603 {
01604 Current_scope = PU_lexical_level(st);
01605 }
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615 extern ST *
01616 cwh_stab_const_ST(WN *wn)
01617 {
01618 TCON tcon;
01619 #ifdef KEY
01620 ST *st = 0 ;
01621 #else
01622 ST *st ;
01623 #endif
01624
01625 if (WNOPR(wn) == OPR_CONST)
01626 st = WN_st(wn);
01627
01628 else if (WNOPR(wn) == OPR_INTCONST) {
01629 tcon = Host_To_Targ (WNRTY(wn),WN_const_val(wn));
01630 st = New_Const_Sym(Enter_tcon (tcon), Be_Type_Tbl(WNRTY(wn)));
01631
01632 } else {
01633 DevAssert((0),("unexpected WN"));
01634 }
01635 return st;
01636 }
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646 extern WN *
01647 cwh_stab_const(ST *st)
01648 {
01649 WN *wn ;
01650 TYPE_ID bt;
01651
01652 bt = TY_mtype(ST_type(st));
01653 wn = WN_CreateConst (Const_Opcode [bt],st);
01654
01655 return(wn);
01656 }
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672 extern ST *
01673 cwh_stab_address_temp_ST(const char * name, TY_IDX ty , BOOL uniq)
01674 {
01675 ST * st ;
01676
01677 st = New_ST(CURRENT_SYMTAB);
01678 cwh_auxst_clear(st);
01679 ST_Init (st,
01680 Save_Str(cwh_types_mk_anon_name(name)),
01681 CLASS_VAR,
01682 SCLASS_AUTO,
01683 EXPORT_LOCAL,
01684 ty);
01685
01686 Set_ST_is_temp_var(st);
01687
01688 if (uniq)
01689 Set_ST_pt_to_unique_mem(st);
01690
01691 cwh_expr_temp_set_pragma(st);
01692 return st ;
01693 }
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703 extern ST *
01704 cwh_stab_temp_ST(TY_IDX ty, const char * name)
01705 {
01706 ST * st;
01707
01708 st = Gen_Temp_Symbol(ty,name);
01709 cwh_auxst_clear(st);
01710 cwh_expr_temp_set_pragma(st) ;
01711
01712 return st;
01713 }
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729 extern void
01730 cwh_stab_add_pragma(ST *st, WN_PRAGMA_ACCESSED_FLAGS flag )
01731 {
01732 WN * wn ;
01733 enum site block = block_ca ;
01734
01735 wn = cwh_auxst_pragma(st);
01736
01737 if (wn == NULL) {
01738
01739 wn = WN_CreatePragma (WN_PRAGMA_ACCESSED_ID,st,0,flag);
01740
01741 if (cwh_stmt_add_to_preamble(wn, block))
01742 (void) cwh_auxst_pragma(st,wn);
01743 else
01744 WN_DELETE_Tree(wn);
01745
01746 } else
01747 WN_pragma_arg2(wn) = WN_pragma_arg2(wn) | flag ;
01748 }
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760 extern STB_pkt *
01761 cwh_stab_packet(void * thing, enum is_form fm)
01762 {
01763 STB_pkt *p ;
01764
01765 p = cwh_stab_packet_typed(thing,fm, 0) ;
01766 return (p) ;
01767 }
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780 extern STB_pkt *
01781 cwh_stab_packet_typed(void * thing, enum is_form fm, TY_IDX ty)
01782 {
01783 STB_pkt *p ;
01784
01785 p = (STB_pkt *) malloc(sizeof(STB_pkt)) ;
01786
01787 p->item = thing ;
01788 p->form = fm ;
01789 p->ty = ty ;
01790 p->next = STB_list;
01791
01792 STB_list = p ;
01793
01794 return (p) ;
01795 }
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805 static void
01806 cwh_stab_free_packet(void)
01807 {
01808
01809 STB_pkt *p ;
01810 STB_pkt *q ;
01811
01812 p = STB_list ;
01813
01814 while (p != NULL) {
01815 q = p->next ;
01816 free(p);
01817 p = q ;
01818 }
01819
01820 STB_list = NULL ;
01821
01822 }
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835 extern void
01836 cwh_stab_end_procs(void)
01837 {
01838 cwh_stab_free_packet();
01839 cwh_auxst_free() ;
01840
01841 if (! IN_NESTED_PU)
01842 Has_nested_proc = FALSE ;
01843
01844 cwh_auxst_un_register_table() ;
01845 Delete_Scope(CURRENT_SYMTAB);
01846
01847 Current_scope -= 1;
01848 cwh_auxst_clear_per_PU();
01849 entry_point_count = 0 ;
01850 }
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867 static ST *
01868 cwh_stab_earlier_hosted(const char * name)
01869 {
01870 ST * sl ;
01871 INT32 i ;
01872
01873 for(i = 0 ; i <= Host_Top ; i ++) {
01874 sl = Host_STs[i];
01875 if (ST_class(sl) == CLASS_VAR)
01876 if (strcmp(name,ST_name(sl)) == 0)
01877 return (sl);
01878 }
01879 return (NULL);
01880 }
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893 static void
01894 cwh_stab_enter_hosted(ST * st)
01895 {
01896 Host_Top ++ ;
01897
01898 if (Host_Top >= Host_Current_Size) {
01899 Host_Current_Size += HOST_ST_SIZE_CHANGE;
01900 Host_STs = (ST **) realloc(Host_STs,sizeof(ST *)*Host_Current_Size);
01901 }
01902
01903 Host_STs[Host_Top] = st;
01904 }
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926 static void
01927 cwh_stab_adjust_name(ST * st)
01928 {
01929 char *p;
01930 const char *s;
01931 char c;
01932 INT32 n;
01933
01934 s = ST_name(st);
01935
01936 PU& pu = Pu_Table[ST_pu(st)];
01937 if (PU_is_mainpu(pu)) {
01938
01939 Set_ST_name(st, Save_Str(def_main_u));
01940
01941 if (!strcmp(crayf90_def_main,s))
01942 s = def_main ;
01943
01944 n = strlen(s);
01945 p = (char *) malloc(n+1);
01946 (void) cwh_auxst_stem_name(st,strcpy(p,s));
01947 p[n-1] = '\0';
01948
01949 } else {
01950
01951 c = '.' ;
01952 p = strchr(s,c);
01953
01954 if (p != NULL) {
01955
01956 n = p-s+1;
01957 p = (char *) malloc(n);
01958 p = strncpy(p,s,n-1);
01959 p[n-1] = '\0';
01960
01961 cwh_auxst_stem_name(st,p);
01962 }
01963 }
01964 }
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982 static void
01983 cwh_stab_adjust_base_name(ST * st)
01984 {
01985
01986 if (Has_Base_Block(st)) {
01987 ST * base = ST_base(st);
01988 if (ST_is_temp_var(base))
01989 if (ST_sclass(base) == SCLASS_AUTO)
01990 if (!ST_is_return_var(base))
01991 if (!ST_has_nested_ref(st) ||
01992 (ST_has_nested_ref(st) && CURRENT_SYMTAB == HOST_LEVEL))
01993 Set_ST_name(base,Save_Str2("p_",ST_name(st)));
01994 }
01995 }
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006 extern ST *
02007 cwh_stab_main_ST(void)
02008 {
02009 return Main_ST;
02010 }
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021 extern void
02022 cwh_stab_set_linenum(ST *st, INT32 lineno)
02023 {
02024 USRCPOS *pos;
02025 char *file_name;
02026 static char *last_file_name = NULL;
02027 static INT32 last_file_num = 0 ;
02028 INT32 local_line_num;
02029
02030 pos = cwh_auxst_srcpos_addr(st);
02031 file_name = global_to_local_file(lineno);
02032 local_line_num = global_to_local_line_number(lineno);
02033 if (last_file_name != file_name)
02034 last_file_num = cwh_dst_enter_path(file_name);
02035
02036 USRCPOS_filenum(*pos) = last_file_num ;
02037 USRCPOS_linenum(*pos) = local_line_num;
02038
02039 last_file_name = file_name ;
02040 }
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052 static void
02053 cwh_stab_formal_ref(ST * st, BOOL host)
02054 {
02055
02056 TY_IDX ty ;
02057
02058 if (!ST_is_value_parm(st)) {
02059
02060 ty = ST_type(st);
02061
02062 if (TY_kind(ty) == KIND_SCALAR || TY_kind(ty) == KIND_STRUCT)
02063 Set_ST_sclass(st, SCLASS_FORMAL_REF);
02064 else
02065 Set_ST_type(st, cwh_types_mk_pointer_TY(ty, host));
02066 }
02067 }
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083 static void
02084 cwh_stab_full_split(ST *c, enum list_name list)
02085 {
02086 ITEM * el;
02087 INT32 nf;
02088 INT32 i;
02089 LIST *l;
02090 FIELDS fp_table ;
02091
02092 l = cwh_auxst_get_list(c,l_COMLIST);
02093 if ( l == NULL)
02094 return;
02095
02096 nf = L_num(l);
02097 if (nf == 0)
02098 return ;
02099
02100 if (ST_is_initialized(c) || TY_is_volatile(ST_type(c))) {
02101 cwh_stab_mk_flds(c,list);
02102 return ;
02103 }
02104
02105 fp_table = (FIELDS) malloc ( sizeof(FIELD_ITEM) * nf) ;
02106
02107 i = 0 ;
02108 el = NULL ;
02109
02110 while ((el = cwh_auxst_next_element(c,el,list)) != NULL ) {
02111
02112 ST *st = I_element(el);
02113 FIELDS_fp(i) = st;
02114 FIELDS_first_offset(i) = ST_ofst(st);
02115 FIELDS_last_offset(i) = ST_ofst(st) + TY_size(ST_type(st)) - 1;
02116 i ++ ;
02117 }
02118
02119 DevAssert((i==nf),(" cant count"));
02120
02121
02122
02123 cwh_stab_find_overlaps(fp_table,nf);
02124
02125
02126
02127
02128
02129
02130 if (cwh_stab_split_common(c,fp_table,nf)) {
02131
02132 el = NULL ;
02133 while ((el = cwh_auxst_next_element(c,el,l_SPLITLIST)) != NULL ) {
02134
02135 cwh_stab_mk_flds(I_element(el),l_COMLIST);
02136 }
02137
02138 cwh_stab_mk_flds(c,l_SPLITLIST);
02139
02140 L_num(l) = 0 ;
02141 L_first(l) = NULL ;
02142 L_last(l) = NULL ;
02143
02144 } else
02145 cwh_stab_mk_flds(c,list);
02146
02147 free(fp_table);
02148
02149 }
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163 static void
02164 cwh_stab_find_overlaps(FIELDS fp_table, INT32 nf)
02165 {
02166 INT32 i,j,first;
02167 INT64 last_offset;
02168 INT64 first_offset;
02169
02170 first = 0;
02171 first_offset = FIELDS_first_offset(0);
02172 last_offset = FIELDS_last_offset(0);
02173
02174 for ( i = 1; i < nf; i++ ) {
02175
02176 if ( FIELDS_first_offset(i) > last_offset ) {
02177
02178 for ( j = first; j < i; j++ ) {
02179
02180 FIELDS_first_offset(j) = first_offset;
02181 FIELDS_last_offset(j) = last_offset;
02182 }
02183
02184 first = i;
02185 first_offset = FIELDS_first_offset(i);
02186 last_offset = FIELDS_last_offset(i);
02187
02188 } else if ( FIELDS_last_offset(i) > last_offset )
02189 last_offset = FIELDS_last_offset(i);
02190 }
02191
02192 for ( j = first; j < i; j++ ) {
02193
02194 FIELDS_first_offset(j) = first_offset;
02195 FIELDS_last_offset(j) = last_offset;
02196 }
02197 }
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217 static BOOL
02218 cwh_stab_split_common(ST * c, FIELDS fp_table, INT32 nf)
02219 {
02220 ST * e ;
02221 ST * nc ;
02222 TY_IDX ty ;
02223 TY_IDX tc ;
02224
02225 INT32 i,j,k ;
02226 INT32 first ;
02227 INT32 full_split_last_array = -1;
02228 INT64 first_offset;
02229 INT64 last_offset;
02230 BOOL seen_a_split = FALSE ;
02231
02232
02233 tc = ST_type(c);
02234 first = 0;
02235 first_offset = FIELDS_first_offset(0);
02236 last_offset = FIELDS_last_offset(0);
02237 full_split_last_array = -1;
02238
02239
02240 for ( i = 1; i < nf; i++ ) {
02241
02242 if ( FIELDS_last_offset(i) > last_offset ) {
02243
02244 e = FIELDS_fp(i);
02245 ty = ST_type(e);
02246
02247 if ((TY_kind(ty) == KIND_ARRAY) &&
02248 (FIELDS_first_offset(i) % TY_align(tc) == 0)) {
02249
02250 if ( TY_size(ty) >= FE_Full_Split_Array_Limit ) {
02251
02252 BOOL split = FALSE;
02253
02254 for ( j = 0; j < FE_Full_Split_Limits_Count; j++ ) {
02255
02256 if ( FIELDS_first_offset(i) - first_offset
02257 < FE_Full_Split_Limits [j].rel_offset
02258 - FE_Full_Split_Limits [j].delta )
02259 break;
02260
02261 if ( need_to_split ( FIELDS_first_offset(i),
02262 first_offset,
02263 FE_Full_Split_Limits [j].rel_offset,
02264 FE_Full_Split_Limits [j].delta ) ) {
02265 split = TRUE;
02266 seen_a_split = TRUE;
02267 break;
02268 }
02269
02270 for (k = full_split_last_array;
02271 k >= 0;
02272 k = FIELDS_prev_array_index(k) ) {
02273
02274 if ( need_to_split (FIELDS_first_offset(i),
02275 FIELDS_first_offset(k),
02276 FE_Full_Split_Limits [j].rel_offset,
02277 FE_Full_Split_Limits [j].delta ) ) {
02278 split = TRUE;
02279 seen_a_split = TRUE;
02280 break;
02281 }
02282 }
02283 if ( split )
02284 break;
02285 }
02286
02287 if ( split ) {
02288
02289 nc = cwh_stab_split_ST(c,
02290 FIELDS_first_offset(first),
02291 FIELDS_last_offset(i-1));
02292 cwh_stab_emit_split(nc,fp_table,first, i-1);
02293 cwh_auxst_add_item(c,nc, l_SPLITLIST);
02294 if (ST_is_thread_private(c)){
02295 Set_ST_is_thread_private(nc);
02296
02297 #ifdef KEY
02298 cwh_directive_set_PU_flags(FALSE);
02299 #endif
02300 }
02301 first = i;
02302 first_offset = FIELDS_first_offset(i);
02303 full_split_last_array = -1;
02304 }
02305
02306 FIELDS_prev_array_index(i) = full_split_last_array;
02307 full_split_last_array = i;
02308 }
02309 }
02310 last_offset = FIELDS_last_offset(i);
02311 }
02312 }
02313
02314 if (seen_a_split) {
02315 nc = cwh_stab_split_ST(c,
02316 FIELDS_first_offset(first),
02317 FIELDS_last_offset(i-1));
02318 cwh_stab_emit_split(nc,fp_table,first, i-1);
02319 cwh_auxst_add_item(c,nc, l_SPLITLIST);
02320 }
02321
02322 return seen_a_split ;
02323 }
02324
02325
02326
02327
02328
02329
02330
02331
02332
02333
02334
02335 static BOOL
02336 need_to_split (INT64 cur_offset,
02337 INT64 base_offset,
02338 INT64 rel_offset,
02339 int delta )
02340 {
02341 BOOL split;
02342 INT64 offset;
02343
02344 offset = cur_offset - base_offset;
02345 offset = offset % rel_offset;
02346
02347 split = ( offset < delta ) || ( offset > ( rel_offset - delta ) );
02348
02349 return split;
02350 }
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361 static void
02362 cwh_stab_dump_FIELDS(FIELDS fp_table, INT32 from, INT32 to)
02363 {
02364 ST *st;
02365 INT32 i ;
02366
02367 for ( i = from; i <= to; i++ ) {
02368
02369 st = FIELDS_fp(i);
02370
02371 printf (" %d - ",i);
02372
02373 printf (" f_off: %16llx, l_off: %16llx, prev %4d,",
02374 FIELDS_first_offset(i),
02375 FIELDS_last_offset(i),
02376 FIELDS_prev_array_index(i));
02377 if (st)
02378 printf (" ST: %p (%s)\n",st,ST_name(st));
02379 else
02380 printf (" ST: <none>\n");
02381
02382 }
02383 }
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396
02397
02398 static void
02399 cwh_stab_emit_split(ST * c, FIELDS fp_table, INT32 from, INT32 to)
02400 {
02401
02402 INT32 i ;
02403 ST * e ;
02404 INT64 off;
02405
02406 off = FIELDS_first_offset(from);
02407
02408 for (i = from ; i <= to; i ++) {
02409 e = FIELDS_fp(i);
02410 Set_ST_ofst(e, (ST_ofst(e) - off));
02411 Set_ST_base(e, c);
02412 cwh_auxst_add_item(c,e,l_COMLIST) ;
02413 }
02414 }
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428 static ST *
02429 cwh_stab_split_ST(ST * c, INT64 low_off, INT64 high_off)
02430 {
02431 INT32 l ;
02432 INT64 off;
02433 char *name;
02434 ST * st;
02435
02436 l = strlen(ST_name(c));
02437
02438 name = (char *) malloc(l + 128);
02439
02440 name[0] = '_';
02441 name[1] = '_';
02442
02443 (void) strcpy(&name[2],ST_name(c));
02444 sprintf(&name[l+2], ".%lld", low_off );
02445
02446 off = high_off-low_off+1;
02447 st = cwh_stab_common_ST(name,byte_to_bit(off),TY_align(ST_type(c)));
02448
02449 Set_ST_ofst(st, 0);
02450 Set_ST_base(st, c);
02451
02452 Set_ST_is_split_common(st) ;
02453
02454 if (ST_is_thread_private(c)) {
02455 Set_ST_is_thread_private(st);
02456
02457 #ifdef KEY
02458 cwh_directive_set_PU_flags(FALSE);
02459 #endif
02460 }
02461
02462 Set_TY_split(Ty_Table[ST_type(st)]);
02463
02464 free (name);
02465 return st ;
02466 }
02467
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477 static ST *
02478 cwh_stab_common_ST(char *name,INT64 size, mUINT16 al)
02479 {
02480
02481 ST * st ;
02482
02483 st = New_ST(GLOBAL_SYMTAB);
02484 cwh_auxst_clear(st);
02485 ST_Init(st, Save_Str(name), CLASS_VAR, SCLASS_COMMON, EXPORT_PREEMPTIBLE,
02486 cwh_types_mk_common_TY(size,al));
02487
02488 Set_ST_base(st, st);
02489 Set_ST_ofst(st, 0);
02490
02491 if (CURRENT_SYMTAB != GLOBAL_SYMTAB) {
02492 cwh_stab_pu_has_globals = TRUE;
02493 }
02494
02495 return st;
02496 }
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517 static void
02518 cwh_stab_altres_offset(ST *st, BOOL hosted)
02519 {
02520 ITEM * et;
02521
02522 BOOL change ;
02523 BOOL same ;
02524 BOOL allF4C4 ;
02525 BOOL isF8 ;
02526 BOOL isC4 ;
02527 TY_IDX ty ;
02528
02529 if (ST_has_nested_ref(st) && ! hosted)
02530 return;
02531
02532 ty = ST_type(st);
02533
02534 if (TY_kind(ty) == KIND_STRUCT)
02535 return ;
02536
02537 DevAssert((TY_kind(ty) == KIND_SCALAR),("Only scalars"));
02538
02539
02540
02541
02542 if (Altbase_ST == NULL)
02543 Altbase_ST = ST_base(st);
02544 else if (Altbase_ST != ST_base(st))
02545 Set_ST_base(st, Altbase_ST);
02546
02547
02548
02549
02550 allF4C4 = (TY_mtype(ty) == MTYPE_C4) ||
02551 (TY_mtype(ty) == MTYPE_F4) ;
02552
02553 isF8 = (TY_mtype(ty) == MTYPE_F8);
02554 isC4 = (TY_mtype(ty) == MTYPE_C4);
02555
02556
02557
02558
02559
02560 et = NULL;
02561 same = TRUE ;
02562
02563 while ((et = cwh_auxst_next_element(ST_base(st),et,l_RETURN_TEMPS)) != NULL ) {
02564
02565 TY_IDX tyi = ST_type(I_element(et));
02566
02567 allF4C4 = allF4C4 &&
02568 ((TY_mtype(tyi) == MTYPE_C4) ||
02569 (TY_mtype(tyi) == MTYPE_F4)) ;
02570
02571 isF8 = isF8 ||
02572 (TY_mtype(tyi) == MTYPE_F8) ;
02573
02574 isC4 = isC4 ||
02575 (TY_mtype(tyi) == MTYPE_C4) ;
02576
02577 same = same && (ty == tyi);
02578 }
02579
02580 Set_ST_auxst_altentry_shareTY(ST_base(st),same);
02581
02582
02583
02584
02585 change = FALSE ;
02586
02587 TYPE_ID bt = TY_mtype(ty);
02588 TY_IDX tb = ST_type(ST_base(st));
02589 TY& t = Ty_Table[tb];
02590
02591 if (MTYPE_is_integral(bt)) {
02592 if (TY_size(tb) < TY_size(Be_Type_Tbl(MTYPE_I8))) {
02593
02594 Set_TY_size(t, TY_size(Be_Type_Tbl(MTYPE_I8)));
02595 change = TRUE;
02596 }
02597
02598 } else if (!same) {
02599 if (!allF4C4) {
02600 if (isC4 && isF8) {
02601 if (TY_size(tb) < TY_size(Be_Type_Tbl(MTYPE_C8))) {
02602
02603 Set_TY_size(t, TY_size(Be_Type_Tbl(MTYPE_C8)));
02604 change = TRUE;
02605 }
02606 }
02607 }
02608 }
02609
02610
02611
02612 if (TY_size(tb) <= TY_size(ty)) {
02613
02614 Set_TY_size(t, TY_size(ty));
02615 change = TRUE;
02616 }
02617
02618 cwh_stab_altres_offset_comp(st,allF4C4);
02619 cwh_auxst_add_item(ST_base(st),st,l_RETURN_TEMPS);
02620
02621
02622
02623 if (change) {
02624
02625 et = NULL ;
02626 while ((et = cwh_auxst_next_element(ST_base(st),et,l_RETURN_TEMPS)) != NULL ) {
02627 cwh_stab_altres_offset_comp(I_element(et),allF4C4);
02628 }
02629 }
02630 }
02631
02632
02633
02634
02635
02636
02637
02638
02639
02640
02641
02642
02643
02644
02645 static void
02646 cwh_stab_altres_offset_comp(ST *st, BOOL allF4C4)
02647 {
02648 TY_IDX ty;
02649 TY_IDX tb;
02650 TYPE_ID bt ;
02651
02652 ty = ST_type(st);
02653 bt = TY_mtype(ty);
02654 tb = ST_type(ST_base(st));
02655
02656 if (MTYPE_is_complex(bt)) {
02657 if (bt == MTYPE_C4)
02658 if (TY_size(tb) > 8)
02659 Set_ST_ofst(st, 8);
02660
02661 } else if (MTYPE_is_float(bt)) {
02662 if (bt == MTYPE_F4)
02663 if (TY_size(tb) > 4 && !allF4C4)
02664 Set_ST_ofst(st, 4);
02665
02666 } else
02667 Set_ST_ofst(st, TY_size(Be_Type_Tbl(MTYPE_I8)) - TY_size(ty));
02668 }
02669
02670
02671
02672
02673
02674
02675
02676
02677
02678
02679
02680
02681
02682
02683
02684
02685
02686
02687
02688
02689
02690
02691
02692
02693 extern TY_IDX
02694 cwh_stab_altentry_TY(ST *st, BOOL expr)
02695 {
02696 TY_IDX tr;
02697 TY_IDX ty;
02698 TY_IDX base;
02699
02700 TYPE_ID max;
02701 TYPE_ID bt ;
02702
02703 ty = ST_type(st);
02704
02705 DevAssert((TY_kind(ty) == KIND_SCALAR),("Only scalars"));
02706
02707 base = ST_type(ST_base(st));
02708 bt = TY_mtype(ty);
02709 max = bt ;
02710
02711 if (MTYPE_is_complex(bt)) {
02712 if (!expr) {
02713 if (TY_size(base) == 8)
02714 max = MTYPE_C4;
02715 else
02716 max = MTYPE_FQ;
02717 }
02718
02719 } else if (MTYPE_is_float(bt)) {
02720 if (TY_size(base) == 4)
02721 max = MTYPE_F4;
02722 else if (TY_size(base) == 8) {
02723 max = MTYPE_F8;
02724 if (ST_ofst(st) == 0 && bt == MTYPE_F4)
02725 max = MTYPE_C4;
02726 } else
02727 max = MTYPE_FQ;
02728 } else
02729 max = MTYPE_I8;
02730
02731 tr = Be_Type_Tbl(max);
02732
02733 return tr;
02734 }
02735
02736
02737
02738
02739
02740
02741
02742
02743
02744
02745
02746
02747
02748 static void
02749 cwh_stab_distrib_pragmas(ST *st)
02750 {
02751 TY_IDX ty;
02752 WN_ITER *stmt_iter;
02753 WN *stmt, *wn;
02754 PREG_det preg;
02755
02756 ty = ST_type(st);
02757
02758 if (ST_sclass(st) == SCLASS_FORMAL)
02759 ty = TY_pointed(ty);
02760
02761 DevAssert((TY_kind(ty)==KIND_ARRAY),("distribute of non-array"));
02762
02763 stmt_iter = WN_WALK_StmtIter(decl_distribute_pragmas);
02764 while(stmt_iter != NULL) {
02765 stmt_iter = WN_WALK_StmtNext(stmt_iter);
02766 if (stmt_iter) {
02767 stmt= WN_ITER_wn(stmt_iter);
02768 if (stmt!=NULL) {
02769 switch(WN_opcode(stmt)) {
02770 case OPC_XPRAGMA:
02771 case OPC_PRAGMA:
02772 WN_st_idx(stmt) = ST_st_idx(st);
02773 if (WN_pragma(stmt)==WN_PRAGMA_DISTRIBUTE_RESHAPE)
02774 Set_ST_is_reshaped(st);
02775 break;
02776 default:
02777 DevAssert((0),("unexpected distribute pragma"));
02778 }
02779 }
02780 }
02781 }
02782
02783
02784
02785 cwh_block_append_given_id(decl_distribute_pragmas,First_Block,FALSE);
02786 decl_distribute_pragmas = NULL;
02787
02788
02789
02790 preg = cwh_auxst_distr_preg(st);
02791 wn = cwh_load_distribute_temp();
02792 wn = WN_CreateStid( OPC_I4STID, preg.preg, preg.preg_st, preg.preg_ty, wn);
02793 cwh_block_append_given_id(wn,First_Block,FALSE);
02794
02795
02796
02797 if (preg_for_distribute.preg==-1) {
02798 preg_for_distribute=cwh_preg_next_preg(MTYPE_I4, NULL, NULL);
02799 }
02800 wn = cwh_load_distribute_temp();
02801 wn = WN_CreateStid( OPC_I4STID, preg_for_distribute.preg,
02802 preg_for_distribute.preg_st, preg_for_distribute.preg_ty, wn);
02803 cwh_block_append_given_id(wn,First_Block,FALSE);
02804
02805
02806
02807 Set_PU_mp_needs_lno (Get_Current_PU ());
02808 Set_FILE_INFO_needs_lno (File_info);
02809 }
02810
02811
02812
02813
02814
02815
02816
02817
02818
02819 extern WN *
02820 cwh_load_distribute_temp(void)
02821 {
02822 TY_IDX ty;
02823 WN *rtrn;
02824
02825 ty = Be_Type_Tbl(MTYPE_I4);
02826
02827 if (st_for_distribute_temp == NULL) {
02828 st_for_distribute_temp = Gen_Temp_Symbol(ty,TY_name(ty));
02829 cwh_auxst_clear(st_for_distribute_temp);
02830 }
02831 rtrn = WN_CreateLdid(OPC_I4I4LDID, 0, st_for_distribute_temp, ty);
02832 return rtrn;
02833 }
02834
02835
02836
02837
02838
02839
02840
02841
02842
02843
02844
02845
02846
02847
02848 static ST *
02849 cwh_stab_altentry_temp(char * name, BOOL hosted)
02850 {
02851 ST * st;
02852 TY_IDX ty;
02853
02854 TYPE t ;
02855 INT32 size ;
02856
02857 size = byte_to_bit(TY_size(Be_Type_Tbl(MTYPE_CQ)));
02858
02859 if (Altbase_ST == NULL) {
02860
02861 ty = cwh_types_mk_equiv_TY(size);
02862 st = cwh_stab_address_temp_ST(".cq_base.",ty , FALSE);
02863 Set_ST_base(st, st);
02864 cwh_stab_to_list_of_equivs(st, hosted) ;
02865 Altbase_ST = st;
02866 }
02867
02868 t = fei_descriptor(0,Basic,size,C_omplex,0,0);
02869 st = New_ST(CURRENT_SYMTAB);
02870 cwh_auxst_clear(st);
02871 ST_Init (st, Save_Str(name), CLASS_VAR, SCLASS_AUTO, EXPORT_LOCAL, cast_to_TY(t_TY(t)));
02872 Set_ST_base(st, Altbase_ST);
02873 Set_ST_ofst(st, 0);
02874
02875 return st;
02876 }
02877
02878
02879
02880
02881
02882
02883
02884
02885
02886
02887 static void
02888 cwh_stab_to_list_of_equivs(ST *st, BOOL hosted)
02889 {
02890 LIST ** l = &Equivalences ;
02891
02892 if (hosted)
02893 l = &Hosted_Equivalences ;
02894
02895 cwh_auxst_add_to_list(l,st,FALSE);
02896 }
02897
02898
02899
02900
02901
02902
02903
02904
02905
02906
02907 void
02908 cwh_stab_set_tylist_for_entries(ST *proc)
02909 {
02910
02911 ITEM *en = NULL;
02912
02913 cwh_auxst_set_tylist(proc);
02914 while ((en = cwh_auxst_next_element(proc,en,l_ALTENTRY)) != NULL) {
02915 cwh_auxst_set_tylist(I_element(en));
02916 }
02917
02918 }
02919
02920
02921
02922
02923
02924
02925
02926
02927
02928
02929
02930
02931
02932 extern void
02933 cwh_stab_emit_commons_and_equivalences(SYMTAB_IDX level)
02934 {
02935
02936 void (*fp) (ST *, enum list_name) = &cwh_stab_mk_flds;
02937
02938 if (FE_Full_Split)
02939 fp = &cwh_stab_full_split ;
02940
02941 if (level == GLOBAL_SYMTAB)
02942 cwh_stab_emit_list(&Commons_Already_Seen,l_COMLIST,fp);
02943
02944 else {
02945
02946 cwh_stab_emit_list(&Equivalences,l_EQVLIST,&cwh_stab_mk_flds);
02947
02948
02949
02950
02951
02952
02953 if (level == HOST_LEVEL)
02954 cwh_stab_emit_list(&Hosted_Equivalences,l_EQVLIST,&cwh_stab_mk_flds);
02955
02956 }
02957 }
02958
02959
02960
02961
02962
02963
02964
02965
02966
02967
02968
02969 static void
02970 cwh_stab_emit_list(LIST ** lp, enum list_name list, void (*fp) (ST *, enum list_name))
02971 {
02972 ITEM * i;
02973
02974 if (*lp != NULL ) {
02975 i = L_first(*lp);
02976
02977 while (i != NULL) {
02978 fp (I_element(i),list) ;
02979 i = I_next(i);
02980 }
02981
02982 #ifdef KEY
02983
02984
02985
02986 #endif
02987 cwh_auxst_free_list(lp);
02988 }
02989 }
02990
02991
02992
02993
02994
02995
02996
02997
02998
02999
03000 static void
03001 cwh_stab_mk_flds(ST * blk, enum list_name list)
03002 {
03003 ITEM * el;
03004 INT32 nf;
03005 INT32 i;
03006 LIST *l;
03007
03008 l = cwh_auxst_get_list(blk, list);
03009 if (l == NULL)
03010 return ;
03011
03012 nf = L_num(l);
03013
03014 if (nf == 0)
03015 return ;
03016
03017
03018
03019 i = 0 ;
03020 el = NULL ;
03021
03022 while ((el = cwh_auxst_next_element(blk,el,list)) != NULL ) {
03023 cwh_types_mk_element(blk,I_element(el));
03024 i ++ ;
03025 }
03026 #ifdef KEY
03027
03028
03029
03030
03031
03032
03033
03034
03035
03036
03037
03038
03039
03040
03041
03042 if (list == l_COMLIST) {
03043 TY_IDX ty = ST_type(blk);
03044 Set_TY_align(ty, 16);
03045 Set_ST_type(blk, ty);
03046 }
03047 #endif
03048
03049 DevAssert((i == nf), (" can't count"));
03050 }
03051
03052
03053
03054
03055
03056
03057
03058
03059
03060
03061
03062
03063
03064
03065 static ST*
03066 cwh_stab_earlier_common(char *name_string, BOOL is_duplicate)
03067 {
03068 ITEM * i;
03069
03070 if (Commons_Already_Seen!= NULL ) {
03071 i = L_first(Commons_Already_Seen);
03072
03073 while (i != NULL) {
03074 ST *st = I_element(i) ;
03075 if (ST_auxst_is_module_data(st) || is_duplicate)
03076 if (strcmp(ST_name(st),name_string) == 0) {
03077 return st ;
03078 }
03079 i = I_next(i);
03080 }
03081 }
03082
03083 return NULL;
03084 }
03085
03086
03087
03088
03089
03090
03091
03092
03093
03094
03095
03096
03097
03098
03099 static ST *
03100 cwh_stab_seen_common_element(ST *c, INT64 offset, char* name)
03101 {
03102 ITEM * el = NULL;
03103 ST * st ;
03104
03105 while ((el = cwh_auxst_next_element(c,el,l_COMLIST)) != NULL ) {
03106 st = I_element(el);
03107 if (ST_ofst(st) == offset)
03108 if (strcmp(ST_name(st),name) == 0)
03109 return st ;
03110
03111 }
03112 return NULL ;
03113 }
03114
03115
03116
03117
03118
03119
03120
03121
03122
03123
03124
03125
03126 extern ST *
03127 cwh_stab_mk_fn_0args(const char *name, ST_EXPORT eclass,SYMTAB_IDX level,TY_IDX rty)
03128 {
03129 ST * st ;
03130 PU_IDX pu ;
03131 TY_IDX ty ;
03132
03133 ty = cwh_types_mk_procedure_TY(rty,
03134 0,
03135 TRUE,
03136 FALSE);
03137
03138 pu = cwh_stab_mk_pu(ty, level);
03139 st = New_ST(GLOBAL_SYMTAB);
03140 cwh_auxst_clear(st);
03141
03142 ST_Init (st,
03143 Save_Str(name),
03144 CLASS_FUNC,
03145 SCLASS_EXTERN,
03146 eclass,
03147 (TY_IDX)pu);
03148
03149 Set_ST_ofst(st, 0);
03150
03151 #ifdef TARG_X8664
03152 PU_IDX pu_idx = ST_pu(st);
03153 PU& pu_rec = Pu_Table[pu_idx];
03154 if (Check_FF2C_Script(name, 1))
03155 Set_PU_ff2c_abi(pu_rec);
03156 #endif
03157 return(st);
03158 }
03159
03160
03161
03162
03163
03164
03165
03166
03167
03168
03169 static PU_IDX
03170 cwh_stab_mk_pu(TY_IDX pty, SYMTAB_IDX level)
03171 {
03172 PU_IDX pu_idx;
03173 PU& pu = New_PU (pu_idx);
03174
03175 PU_Init(pu, pty, level);
03176
03177 return (pu_idx);
03178 }
03179
03180
03181
03182
03183
03184
03185
03186
03187
03188
03189
03190
03191
03192
03193 INTPTR
03194 fei_smt_parameter(char * name_string,
03195 TYPE type,
03196 INTPTR con_idx,
03197 INT32 Class,
03198 INT32 lineno)
03199
03200 {
03201 INT32 len;
03202 char * name;
03203 char * name1;
03204 STB_pkt *p;
03205 #ifdef KEY
03206 ST * st = 0;
03207 #else
03208 ST * st;
03209 #endif
03210 TY_IDX ty;
03211 WN * wn;
03212
03213
03214 ty = cast_to_TY(t_TY(type));
03215
03216 if (TY_is_character(ty)) {
03217 st = cast_to_ST(con_idx);
03218 }
03219 else {
03220 p = cast_to_STB(con_idx);
03221
03222 if (p->form == is_ST) {
03223 st = cast_to_ST(p->item);
03224 }
03225 else if (p->form == is_WN) {
03226 wn = cast_to_WN(p->item);
03227 st = cwh_stab_const_ST(wn);
03228 }
03229 }
03230
03231
03232
03233
03234
03235
03236
03237
03238
03239 name = NULL;
03240 name = cwh_auxst_stem_name(st, name);
03241
03242 if (name == NULL) {
03243 len = strlen(name_string);
03244 name1 = (char *) malloc(len+1);
03245 strcpy(name1, name_string);
03246 cwh_auxst_stem_name(st, name1);
03247 cwh_auxst_add_item(Procedure_ST,st,l_DST_PARMLIST);
03248 }
03249 else {
03250 len = strlen(name_string);
03251 len += strlen(name);
03252 ++len;
03253 name1 = (char *) malloc(len+1);
03254 strcpy(name1, name_string);
03255 strcat(name1, " ");
03256 strcat(name1, name);
03257 free(name);
03258 cwh_auxst_stem_name(st, name1);
03259 }
03260 cwh_stab_set_linenum(st,lineno);
03261
03262 return(cast_to_long(st));
03263 }