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 #ifndef symtab_idx_INCLUDED
00043 #define symtab_idx_INCLUDED
00044
00045 #ifndef ERRORS_INCLUDED
00046 #include "errors.h"
00047 #endif
00048
00049
00050
00051 typedef mUINT32 ST_IDX;
00052 typedef mUINT32 TY_IDX;
00053 typedef mUINT32 FLD_IDX;
00054 typedef mUINT32 ARB_IDX;
00055 typedef mUINT32 TYLIST_IDX;
00056 typedef mUINT32 PU_IDX;
00057 typedef mUINT32 TARGET_INFO_IDX;
00058 typedef mUINT32 TCON_IDX;
00059 typedef mUINT32 LABEL_IDX;
00060 typedef mUINT32 PREG_IDX;
00061 typedef mUINT32 ST_ATTR_IDX;
00062 typedef mUINT32 BLK_IDX;
00063 typedef mUINT32 INITO_IDX;
00064 typedef mUINT32 INITV_IDX;
00065 typedef mUINT64 STR_IDX;
00066 typedef mUINT8 SYMTAB_IDX;
00067
00068
00069
00070 static const ST_IDX ST_IDX_ZERO = 0;
00071 static const TY_IDX TY_IDX_ZERO = 0;
00072 static const FLD_IDX FLD_IDX_ZERO = 0;
00073 static const ARB_IDX ARB_IDX_ZERO = 0;
00074 static const TYLIST_IDX TYLIST_IDX_ZERO = 0;
00075 static const PU_IDX PU_IDX_ZERO = 0;
00076 static const TARGET_INFO_IDX TARGET_INFO_IDX_ZERO = 0;
00077 static const TCON_IDX TCON_IDX_ZERO = 0;
00078 static const LABEL_IDX LABEL_IDX_ZERO = 0;
00079 static const PREG_IDX PREG_IDX_ZERO = 0;
00080 static const ST_ATTR_IDX ST_ATTR_IDX_ZERO = 0;
00081 static const BLK_IDX BLK_IDX_ZERO = 0;
00082 static const INITO_IDX INITO_IDX_ZERO = 0;
00083 static const INITV_IDX INITV_IDX_ZERO = 0;
00084 static const STR_IDX STR_IDX_ZERO = 0;
00085 static const SYMTAB_IDX SYMTAB_IDX_ZERO = 0;
00086
00087
00088
00089 struct ST;
00090 struct TY;
00091 struct FLD;
00092 struct ARB;
00093 struct PU;
00094 struct TCON;
00095 struct LABEL;
00096 struct PREG;
00097 struct ST_ATTR;
00098 struct INITO;
00099 struct INITV;
00100 struct SCOPE;
00101 struct FILE_INFO;
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 template<class INDEX_TYPE, class LEVEL_INDEX_TYPE>
00116 inline LEVEL_INDEX_TYPE Extract_level8(INDEX_TYPE idx, LEVEL_INDEX_TYPE *)
00117 {
00118 return idx & 0xff;
00119 }
00120
00121 template<class INDEX_TYPE>
00122 inline UINT32 Extract_index24(INDEX_TYPE idx) { return idx >> 8; }
00123
00124 inline SYMTAB_IDX
00125 ST_IDX_level (ST_IDX st_idx)
00126 {
00127 return Extract_level8(st_idx, (SYMTAB_IDX *) 0);
00128 }
00129
00130 inline UINT32
00131 ST_IDX_index (ST_IDX st_idx) { return Extract_index24(st_idx); }
00132
00133 inline ST_IDX
00134 make_ST_IDX (UINT index, SYMTAB_IDX level) {
00135 return (ST_IDX)((index << 8)|level);
00136 }
00137
00138
00139 inline SYMTAB_IDX
00140 INITO_IDX_level (INITO_IDX inito_idx)
00141 {
00142 return Extract_level8(inito_idx, (SYMTAB_IDX *) 0);
00143 }
00144
00145 inline UINT32
00146 INITO_IDX_index (INITO_IDX inito_idx) { return Extract_index24(inito_idx); }
00147
00148 inline INITO_IDX
00149 make_INITO_IDX (UINT index, SYMTAB_IDX level) {
00150 return (INITO_IDX) ((index << 8)|level);
00151 }
00152
00153
00154 inline SYMTAB_IDX
00155 LABEL_IDX_level (LABEL_IDX label_idx)
00156 {
00157 return Extract_level8(label_idx, (SYMTAB_IDX *) 0);
00158 }
00159
00160 inline UINT32
00161 LABEL_IDX_index (LABEL_IDX label_idx) { return Extract_index24(label_idx); }
00162
00163 inline LABEL_IDX
00164 make_LABEL_IDX (UINT index, SYMTAB_IDX level) {
00165 return (LABEL_IDX) ((index << 8)|level);
00166 }
00167
00168 template<class ENTRY_TYPE,
00169 class INDEX_TYPE,
00170 class LEVEL_INDEX_TYPE,
00171 class LEVEL_CONTAINER_TYPE,
00172 LEVEL_CONTAINER_TYPE *level_container_ptr,
00173 class LEVEL_MEMBER_ACCESSOR>
00174 struct TABLE_INDEXED_BY_LEVEL8_AND_INDEX24 {
00175 ENTRY_TYPE &operator[](INDEX_TYPE idx)
00176 {
00177 LEVEL_INDEX_TYPE level = Extract_level8(idx, (LEVEL_INDEX_TYPE *) 0);
00178 UINT32 index = Extract_index24(idx);
00179 return LEVEL_MEMBER_ACCESSOR()(level_container_ptr, level)->Entry(index);
00180 }
00181
00182 ENTRY_TYPE &operator()(LEVEL_CONTAINER_TYPE *lev_container_ptr,
00183 INDEX_TYPE idx)
00184 {
00185 LEVEL_INDEX_TYPE level = Extract_level8(idx, (LEVEL_INDEX_TYPE *) 0);
00186 UINT32 index = Extract_index24(idx);
00187 return LEVEL_MEMBER_ACCESSOR()(lev_container_ptr, level)->Entry(index);
00188 }
00189
00190 ENTRY_TYPE &operator()(LEVEL_INDEX_TYPE level, UINT32 index)
00191 {
00192 #ifndef __GNU_BUG_WORKAROUND
00193 Is_True(LEVEL_MEMBER_ACCESSOR()(level_container_ptr, level) != NULL,
00194 ("Uninitialized ST_IDX-indexed table"));
00195 #endif
00196 return LEVEL_MEMBER_ACCESSOR()(level_container_ptr, level)->Entry(index);
00197 }
00198
00199 ENTRY_TYPE &operator()(LEVEL_CONTAINER_TYPE *lev_container_ptr,
00200 LEVEL_INDEX_TYPE level, UINT32 index)
00201 {
00202 #ifndef __GNU_BUG_WORKAROUND
00203 Is_True(LEVEL_MEMBER_ACCESSOR()(lev_container_ptr, level) != NULL,
00204 ("Uninitialized ST_IDX-indexed table"));
00205 #endif
00206 return LEVEL_MEMBER_ACCESSOR()(lev_container_ptr, level)->Entry(index);
00207 }
00208 };
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 const UINT32 TY_RESTRICT = 0x00000080;
00226 const UINT32 TY_VOLATILE = 0x00000040;
00227 const UINT32 TY_CONST = 0x00000020;
00228 const UINT32 TY_ALIGN = 0x0000001f;
00229
00230 inline UINT32 TY_IDX_index (TY_IDX ty_idx) { return ty_idx >> 8; }
00231 inline void Set_TY_IDX_index (TY_IDX &ty_idx, UINT32 index)
00232 {
00233 ty_idx = (ty_idx & 0xff) | (index << 8);
00234 }
00235
00236 inline TY_IDX
00237 make_TY_IDX (UINT32 index) { return index << 8; }
00238
00239 inline BOOL TY_is_const (TY_IDX ty_idx) { return ty_idx & TY_CONST; }
00240 inline void Set_TY_is_const (TY_IDX &ty_idx) { ty_idx |= TY_CONST; }
00241 inline void Clear_TY_is_const (TY_IDX &ty_idx) { ty_idx &= ~TY_CONST; }
00242
00243 inline BOOL TY_is_volatile (TY_IDX ty_idx) { return ty_idx & TY_VOLATILE;}
00244 inline void Set_TY_is_volatile (TY_IDX &ty_idx) { ty_idx |= TY_VOLATILE; }
00245 inline void Clear_TY_is_volatile (TY_IDX &ty_idx){ ty_idx &= ~TY_VOLATILE; }
00246
00247 inline BOOL TY_is_restrict (TY_IDX ty_idx) { return ty_idx & TY_RESTRICT;}
00248 inline void Set_TY_is_restrict (TY_IDX &ty_idx) { ty_idx |= TY_RESTRICT; }
00249 inline void Clear_TY_is_restrict (TY_IDX &ty_idx){ ty_idx &= ~TY_RESTRICT; }
00250
00251
00252
00253 inline UINT TY_align_exp (TY_IDX ty_idx) { return ty_idx & TY_ALIGN; }
00254 inline void Set_TY_align_exp (TY_IDX &ty_idx, UINT exp) {
00255 ty_idx = (ty_idx & ~TY_ALIGN) | (exp & TY_ALIGN);
00256 }
00257
00258 inline UINT TY_align (TY_IDX ty_idx) { return 1 << (ty_idx & TY_ALIGN); }
00259 inline void Set_TY_align (TY_IDX &ty_idx, UINT32 align) {
00260 extern UINT32 TY_log_base2 (UINT32 align);
00261
00262 if (align & 0x3f)
00263 Set_TY_align_exp (ty_idx,
00264 (align & 0x7) ? (align >> 1) : 3 + (align >> 4));
00265 else
00266 Set_TY_align_exp (ty_idx, TY_log_base2 (align));
00267 }
00268
00269
00270 #endif
00271
00272