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 #ifndef tree_symtab_INCLUDED
00045 #define tree_symtab_INCLUDED
00046
00047 #include <cmplrs/rcodes.h>
00048
00049 extern TY_IDX Create_TY_For_Tree (tree, TY_IDX idx = TY_IDX_ZERO);
00050 extern "C" ST* Create_ST_For_Tree (tree);
00051 #ifdef KEY
00052 extern "C" void Create_DST_For_Tree (tree, ST*);
00053 extern "C" BOOL Is_shared_mp_var (tree);
00054 #endif // KEY
00055
00056
00057
00058
00059
00060 inline TY_IDX
00061 Get_TY (tree type_tree)
00062 {
00063 if (TREE_CODE(type_tree) == ERROR_MARK)
00064 exit (RC_USER_ERROR);
00065 TY_IDX idx = TYPE_TY_IDX(type_tree);
00066 if (idx != 0) {
00067 if (TREE_CODE(type_tree) == RECORD_TYPE ||
00068 TREE_CODE(type_tree) == UNION_TYPE) {
00069 FLD_HANDLE elt_fld = TY_fld(idx);
00070 if (elt_fld.Is_Null())
00071 return Create_TY_For_Tree (type_tree, idx);
00072 else return idx;
00073 }
00074 else return idx;
00075 }
00076 return Create_TY_For_Tree (type_tree, TY_IDX_ZERO);
00077 }
00078
00079 #ifdef PATHSCALE_MERGE
00080
00081
00082 struct find_st_attr_section_name {
00083 ST_IDX st;
00084 find_st_attr_section_name (const ST *s) : st (ST_st_idx (s)) {}
00085
00086 BOOL operator () (UINT, const ST_ATTR *st_attr) const {
00087 return (ST_ATTR_kind (*st_attr) == ST_ATTR_SECTION_NAME &&
00088 ST_ATTR_st_idx (*st_attr) == st);
00089 }
00090 };
00091 #endif
00092
00093
00094
00095
00096 inline ST *
00097 Get_ST (tree decl_tree)
00098 {
00099 ST *st = DECL_ST(decl_tree);
00100 if (st != NULL) {
00101 #ifndef KEY
00102 if (TREE_CODE(decl_tree) == VAR_DECL &&
00103 ST_sclass(st) == SCLASS_EXTERN &&
00104 !ST_is_weak_symbol(st) &&
00105 !DECL_EXTERNAL(decl_tree) &&
00106 !DECL_INITIAL(decl_tree))
00107 Set_ST_sclass (st, SCLASS_UGLOBAL);
00108 #else
00109
00110
00111
00112 if (TREE_CODE(decl_tree) == VAR_DECL &&
00113 ST_sclass(st) == SCLASS_EXTERN &&
00114 !ST_is_weak_symbol(st) &&
00115 !DECL_EXTERNAL(decl_tree) &&
00116 !DECL_INITIAL(decl_tree) &&
00117 TREE_STATIC(decl_tree))
00118 {
00119 #ifdef PATHSCALE_MERGE
00120
00121 if (flag_no_common || DECL_SECTION_NAME(decl_tree)) {
00122
00123
00124
00125 if (DECL_SECTION_NAME(decl_tree)) {
00126 ST_ATTR_IDX st_attr_idx;
00127 ST_IDX idx = ST_st_idx (st);
00128
00129 st_attr_idx = For_all_until (St_Attr_Table,
00130 ST_IDX_level (idx),
00131 find_st_attr_section_name(st));
00132 if (st_attr_idx){
00133 STR_IDX str_index = ST_ATTR_section_name(St_Attr_Table(ST_IDX_level (idx), st_attr_idx));
00134
00135 if(strcmp(Index_To_Str(str_index),
00136 TREE_STRING_POINTER (DECL_SECTION_NAME (decl_tree))))
00137 Set_ST_ATTR_section_name(St_Attr_Table(ST_IDX_level (idx), st_attr_idx),
00138 Save_Str (TREE_STRING_POINTER (DECL_SECTION_NAME (decl_tree))));}
00139
00140
00141
00142 else {
00143 DevWarn ("section %s specified for %s",
00144 TREE_STRING_POINTER (DECL_SECTION_NAME (decl_tree)), ST_name (st));
00145 ST_ATTR& st_attr = New_ST_ATTR (ST_IDX_level (idx), st_attr_idx);
00146 ST_ATTR_Init (st_attr, idx, ST_ATTR_SECTION_NAME,
00147 Save_Str (TREE_STRING_POINTER (DECL_SECTION_NAME (decl_tree))));
00148 }
00149 }
00150 #endif
00151 Set_ST_sclass (st, SCLASS_UGLOBAL);
00152 }
00153 else {
00154 if (Debug_Level >= 2) {
00155
00156
00157
00158
00159 Create_DST_For_Tree(decl_tree, st);
00160 }
00161 Set_ST_sclass (st, SCLASS_COMMON);
00162 }
00163 }
00164
00165 if (TREE_CODE(decl_tree) == VAR_DECL) {
00166 TY_IDX ty_idx = Get_TY(TREE_TYPE(decl_tree));
00167 if (ty_idx &&
00168 (TY_IDX_index(ty_idx) != TY_IDX_index(ST_type(st))) ||
00169
00170 (TY_align(ty_idx) != TY_align(ST_type(st)))) {
00171 Set_ST_type(st, ty_idx);
00172 }
00173 }
00174 #endif
00175 }
00176 else
00177 st = Create_ST_For_Tree (decl_tree);
00178 if ((CURRENT_SYMTAB > GLOBAL_SYMTAB + 1) &&
00179 ((TREE_CODE(decl_tree) == VAR_DECL) ||
00180 (TREE_CODE(decl_tree) == PARM_DECL)) &&
00181 (ST_level(st) < CURRENT_SYMTAB) &&
00182 (ST_level(st) > GLOBAL_SYMTAB)) {
00183 Set_ST_has_nested_ref (st);
00184 ST *base_st = st;
00185 while (base_st != ST_base (base_st)) {
00186 base_st = ST_base (base_st);
00187 Set_ST_has_nested_ref (base_st);
00188 }
00189 }
00190 #ifdef KEY
00191 if (ST_is_thread_private(st) && CURRENT_SYMTAB != GLOBAL_SYMTAB)
00192 Set_PU_has_mp(Get_Current_PU());
00193 #endif
00194 Is_True(ST_st_idx(st) != 0, ("st_idx is 0?"));
00195 Is_True(ST_st_idx(st) != -1, ("st_idx is -1?"));
00196 Is_True(ST_IDX_level(ST_st_idx(st)) != 0, ("st_level is 0?"));
00197 Is_True(ST_IDX_index(ST_st_idx(st)) != 0, ("st_index is 0?"));
00198 return st;
00199 }
00200
00201 #endif