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 #ifndef spin_symtab_INCLUDED
00049 #define spin_symtab_INCLUDED
00050
00051 extern TY_IDX Create_TY_For_Tree (gs_t, TY_IDX idx = TY_IDX_ZERO);
00052 extern "C" ST* Create_ST_For_Tree (gs_t);
00053 extern "C" void Create_DST_For_Tree (gs_t, ST*);
00054
00055 TY_IDX& TYPE_TY_IDX(gs_t);
00056 extern "C" void add_duplicates (gs_t, gs_t);
00057 extern "C" void erase_duplicates (gs_t);
00058 void set_DECL_ST(gs_t, ST*);
00059 ST*& get_DECL_ST(gs_t);
00060 BOOL& expanded_decl(gs_t);
00061 BOOL& func_PU_uplevel(gs_t);
00062 #define DECL_ST(x) get_DECL_ST(x)
00063 SYMTAB_IDX& DECL_SYMTAB_IDX(gs_t);
00064 LABEL_IDX& DECL_LABEL_IDX(gs_t);
00065 ST*& TREE_STRING_ST(gs_t);
00066 BOOL& DECL_LABEL_DEFINED(gs_t);
00067 INT32& DECL_FIELD_ID(gs_t);
00068 INT32& TYPE_FIELD_IDS_USED(gs_t);
00069 INT32& SCOPE_NUMBER(gs_t);
00070 gs_t& LABEL_SCOPE(gs_t);
00071 DST_INFO_IDX& DECL_DST_IDX(gs_t);
00072 DST_INFO_IDX& DECL_DST_FIELD_IDX(gs_t);
00073 DST_INFO_IDX& TYPE_DST_IDX(gs_t);
00074 DST_INFO_IDX& DECL_DST_SPECIFICATION_IDX(gs_t);
00075 DST_INFO_IDX& DECL_DST_ABSTRACT_ROOT_IDX(gs_t);
00076 LABEL_IDX& HANDLER_LABEL(gs_t);
00077 #ifdef KEY
00078 gs_t& PARENT_SCOPE(gs_t);
00079 INT32& WEAK_WORKAROUND(ST*);
00080 #endif
00081 ST* & DECL_ST2(gs_t);
00082
00083 extern BOOL flag_no_common;
00084
00085 #ifdef KEY
00086
00087
00088 #define WEAK_WORKAROUND_unknown 0
00089 #define WEAK_WORKAROUND_dont_make_weak 1
00090 #define WEAK_WORKAROUND_made_weak 2
00091
00092 extern BOOL expanding_function_definition;
00093 #endif
00094
00095
00096
00097
00098
00099 inline TY_IDX
00100 Get_TY (gs_t type_tree)
00101 {
00102 #ifdef KEY
00103
00104
00105
00106
00107 if (gs_type_context(type_tree) &&
00108 (gs_tree_code(type_tree) == GS_RECORD_TYPE ||
00109 gs_tree_code(type_tree) == GS_UNION_TYPE) &&
00110 (gs_tree_code(gs_type_context(type_tree)) == GS_RECORD_TYPE ||
00111 gs_tree_code(gs_type_context(type_tree)) == GS_UNION_TYPE) &&
00112 !TYPE_TY_IDX(gs_type_context(type_tree))) {
00113 Get_TY(gs_type_context(type_tree));
00114 }
00115 #endif
00116 TY_IDX idx = TYPE_TY_IDX(type_tree);
00117 if (idx > 1) {
00118 if (gs_tree_code(type_tree) == GS_RECORD_TYPE ||
00119 gs_tree_code(type_tree) == GS_UNION_TYPE) {
00120 FLD_HANDLE elt_fld = TY_fld(idx);
00121 if (elt_fld.Is_Null() && TY_content_seen(idx) == 0)
00122 return Create_TY_For_Tree (type_tree, idx);
00123 else return idx;
00124 }
00125 #ifdef KEY
00126 else if (expanding_function_definition &&
00127 (TY_is_incomplete(idx) ||
00128 (TY_kind(idx)==KIND_POINTER &&
00129 TY_is_incomplete(TY_pointed(idx)))))
00130 return Create_TY_For_Tree (type_tree, idx);
00131 #endif
00132 else return idx;
00133 }
00134 return Create_TY_For_Tree (type_tree, TY_IDX_ZERO);
00135 }
00136
00137
00138
00139 struct find_st_attr_section_name {
00140 ST_IDX st;
00141 find_st_attr_section_name (const ST *s) : st (ST_st_idx (s)) {}
00142 BOOL operator () (UINT, const ST_ATTR *st_attr) const {
00143 return (ST_ATTR_kind (*st_attr) == ST_ATTR_SECTION_NAME &&
00144 ST_ATTR_st_idx (*st_attr) == st);
00145 }
00146 };
00147
00148
00149
00150
00151
00152 inline ST *
00153 Get_ST (gs_t decl_tree)
00154 {
00155 ST *st = DECL_ST(decl_tree);
00156
00157
00158
00159
00160 if (st == NULL)
00161 st = Create_ST_For_Tree (decl_tree);
00162
00163 if (st != NULL) {
00164 if (gs_tree_code(decl_tree) == GS_VAR_DECL &&
00165 ST_sclass(st) == SCLASS_EXTERN &&
00166 !ST_is_weak_symbol(st) &&
00167 !gs_decl_external(decl_tree) &&
00168 !gs_decl_initial(decl_tree)
00169 #if 1
00170 &&
00171 gs_tree_static(decl_tree)
00172 #endif
00173 )
00174 {
00175 if (flag_no_common || gs_decl_section_name(decl_tree))
00176 Set_ST_sclass (st, SCLASS_UGLOBAL);
00177 else {
00178 if (Debug_Level >= 2) {
00179
00180
00181
00182
00183 Create_DST_For_Tree(decl_tree, st);
00184 }
00185 Set_ST_sclass (st, SCLASS_COMMON);
00186 }
00187 }
00188 #ifdef KEY // the earlier definition may not have the complete type
00189 if (gs_tree_code(decl_tree) == GS_VAR_DECL) {
00190 TY_IDX ty_idx = Get_TY(gs_tree_type(decl_tree));
00191 if (ty_idx && TY_IDX_index(ty_idx) != TY_IDX_index(st->u2.type)) {
00192
00193 if (TY_is_volatile(ST_type(st)))
00194 Set_TY_is_volatile(ty_idx);
00195 st->u2.type = ty_idx;
00196 }
00197 }
00198
00199
00200
00201
00202
00203 if (gs_tree_code(decl_tree) == GS_VAR_DECL &&
00204 ( ST_sclass(st) == SCLASS_EXTERN ||
00205 ST_sclass(st) == SCLASS_FSTATIC ||
00206 ST_sclass(st) == SCLASS_COMMON ||
00207 ST_sclass(st) == SCLASS_UGLOBAL ||
00208 ST_sclass(st) == SCLASS_DGLOBAL) &&
00209 !ST_is_weak_symbol(st) &&
00210 !gs_decl_external(decl_tree) &&
00211 gs_tree_static(decl_tree) &&
00212 gs_decl_section_name(decl_tree)) {
00213 ST_ATTR_IDX st_attr_idx;
00214 ST_IDX idx = ST_st_idx (st);
00215
00216 st_attr_idx = For_all_until (St_Attr_Table,
00217 ST_IDX_level (idx),
00218 find_st_attr_section_name(st));
00219
00220 st_attr_idx = For_all_until (St_Attr_Table,ST_IDX_level (idx),
00221 find_st_attr_section_name(st));
00222 if (st_attr_idx){
00223 STR_IDX str_index = ST_ATTR_section_name(St_Attr_Table(ST_IDX_level (idx), st_attr_idx));
00224
00225 if(strcmp(Index_To_Str(str_index),
00226 gs_tree_string_pointer(gs_decl_section_name (decl_tree))))
00227 Set_ST_ATTR_section_name(St_Attr_Table(ST_IDX_level (idx), st_attr_idx),
00228 Save_Str (gs_tree_string_pointer(gs_decl_section_name (decl_tree))));}
00229
00230
00231
00232 else {
00233 DevWarn ("section %s specified for %s",
00234 gs_tree_string_pointer(gs_decl_section_name (decl_tree)), ST_name (st));
00235 ST_ATTR& st_attr = New_ST_ATTR (ST_IDX_level (idx), st_attr_idx);
00236 ST_ATTR_Init (st_attr, idx, ST_ATTR_SECTION_NAME,
00237 Save_Str (gs_tree_string_pointer(gs_decl_section_name (decl_tree))));
00238 }
00239
00240 if (!gs_decl_initial(decl_tree))
00241 Set_ST_sclass (st, SCLASS_UGLOBAL);
00242 }
00243 #endif
00244 }
00245 else st = Create_ST_For_Tree (decl_tree);
00246 if ((CURRENT_SYMTAB > GLOBAL_SYMTAB + 1) &&
00247 ((gs_tree_code(decl_tree) == GS_VAR_DECL) ||
00248 (gs_tree_code(decl_tree) == GS_PARM_DECL)) &&
00249 (ST_level(st) < CURRENT_SYMTAB) &&
00250 (ST_level(st) > GLOBAL_SYMTAB)) {
00251 Set_ST_has_nested_ref (st);
00252 ST *base_st = st;
00253 while (base_st != ST_base (base_st)) {
00254 base_st = ST_base (base_st);
00255 Set_ST_has_nested_ref (base_st);
00256 }
00257 }
00258 #ifdef KEY
00259 if (ST_is_thread_private(st) && CURRENT_SYMTAB != GLOBAL_SYMTAB)
00260 Set_PU_has_mp(Get_Current_PU());
00261 #endif
00262 return st;
00263 }
00264
00265 bool is_empty_base_class (gs_t type_tree);
00266 gs_t next_real_field (gs_t type_tree, gs_t field);
00267 gs_t get_first_real_or_virtual_field (gs_t);
00268 size_t Roundup (size_t offset, int alignment);
00269 size_t Type_Size_Without_Vbases (gs_t type_tree);
00270
00271 #endif