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