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 be_symtab_INCLUDED
00039 #define be_symtab_INCLUDED
00040
00041 #ifndef cmplr_segmented_array_INCLUDED
00042 #include "cmplr_segmented_array.h"
00043 #endif // cmplr_segmented_array_INCLUDED
00044
00045 #ifndef symtab_INCLUDED
00046 #include "symtab.h"
00047 #endif // symtab_INCLUDED
00048
00049 #ifndef wn_INCLUDED
00050 #include "wn.h"
00051 #endif // wn_INCLUDED
00052
00053 #ifndef targ_sim_INCLUDED
00054 #include "targ_sim.h"
00055 #endif
00056
00057 typedef mUINT32 BE_ST_IDX;
00058
00059
00060
00061 const UINT32 BE_ST_ADDR_USED_LOCALLY = 0x00000001;
00062 const UINT32 BE_ST_ADDR_PASSED = 0x00000002;
00063 const UINT32 BE_ST_W2FC_REFERENCED = 0x00000004;
00064 const UINT32 BE_ST_UNKNOWN_CONST = 0x00000008;
00065
00066
00067 const UINT32 BE_ST_PU_HAS_VALID_ADDR_FLAGS = 0x00000010;
00068
00069
00070 const UINT32 BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST = 0x00000020;
00071
00072 const UINT32 BE_ST_REFERENCED = 0x00000040;
00073
00074
00075
00076 class BE_ST {
00077 mUINT32 flags;
00078 void *io_auxst;
00079
00080 public:
00081 BE_ST(void) : flags(0),io_auxst(NULL) { }
00082 BOOL Is_set(UINT32 f) const { return flags & f; }
00083 void Set_flag(UINT32 f) { flags |= f; }
00084 void Clear_flag(UINT32 f) { flags &= ~f; }
00085 void Set_io_auxst(void *v) { io_auxst = v; }
00086 void * Io_auxst(void) { return io_auxst; }
00087 };
00088
00089 typedef RELATED_SEGMENTED_ARRAY<BE_ST> BE_ST_TAB;
00090
00091 struct BE_SCOPE {
00092 BE_ST_TAB *be_st_tab;
00093 };
00094
00095 struct BE_SCOPE_TAB_BE_ST_TAB_ACCESS {
00096 BE_SCOPE_TAB_BE_ST_TAB_ACCESS(void) { }
00097
00098 BE_ST_TAB *operator()(BE_SCOPE **be_scope_tab, SYMTAB_IDX level)
00099 { return (*be_scope_tab)[level].be_st_tab; }
00100 };
00101
00102 extern BE_SCOPE *Be_scope_tab;
00103
00104 typedef TABLE_INDEXED_BY_LEVEL8_AND_INDEX24<BE_ST, ST_IDX, SYMTAB_IDX,
00105 BE_SCOPE *, &Be_scope_tab,
00106 BE_SCOPE_TAB_BE_ST_TAB_ACCESS>
00107 BE_SYMBOL_TABLE;
00108
00109 extern BE_SYMBOL_TABLE Be_symbol_table;
00110
00111 inline BOOL
00112 BE_ST_addr_used_locally(const ST_IDX idx)
00113 {
00114 return Be_symbol_table[idx].Is_set(BE_ST_ADDR_USED_LOCALLY);
00115 }
00116
00117 inline BOOL
00118 BE_ST_addr_used_locally(const BE_ST *const be_st)
00119 {
00120 return be_st->Is_set(BE_ST_ADDR_USED_LOCALLY);
00121 }
00122
00123 inline BOOL
00124 BE_ST_addr_used_locally(const ST *const st)
00125 {
00126 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_ADDR_USED_LOCALLY);
00127 }
00128
00129 inline void
00130 Set_BE_ST_addr_used_locally(const ST_IDX idx)
00131 {
00132 Be_symbol_table[idx].Set_flag(BE_ST_ADDR_USED_LOCALLY);
00133 }
00134
00135 inline void
00136 Set_BE_ST_addr_used_locally(BE_ST *const be_st)
00137 {
00138 be_st->Set_flag(BE_ST_ADDR_USED_LOCALLY);
00139 }
00140
00141 inline void
00142 Set_BE_ST_addr_used_locally(const ST *const st)
00143 {
00144 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_ADDR_USED_LOCALLY);
00145 }
00146
00147 inline void
00148 Clear_BE_ST_addr_used_locally(const ST_IDX idx)
00149 {
00150 Be_symbol_table[idx].Clear_flag(BE_ST_ADDR_USED_LOCALLY);
00151 }
00152
00153 inline void
00154 Clear_BE_ST_addr_used_locally(BE_ST *const be_st)
00155 {
00156 be_st->Clear_flag(BE_ST_ADDR_USED_LOCALLY);
00157 }
00158
00159 inline void
00160 Clear_BE_ST_addr_used_locally(const ST *const st)
00161 {
00162 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_ADDR_USED_LOCALLY);
00163 }
00164
00165 inline void
00166 BE_ST_set_io_auxst(const ST_IDX idx, void *v)
00167 {
00168 Be_symbol_table[idx].Set_io_auxst(v);
00169 }
00170
00171 inline void *
00172 BE_ST_io_auxst(const ST_IDX idx)
00173 {
00174 return Be_symbol_table[idx].Io_auxst();
00175 }
00176
00177
00178 inline BOOL
00179 BE_ST_addr_passed(const ST_IDX idx)
00180 {
00181 return Be_symbol_table[idx].Is_set(BE_ST_ADDR_PASSED);
00182 }
00183
00184 inline BOOL
00185 BE_ST_addr_passed(const BE_ST *const be_st)
00186 {
00187 return be_st->Is_set(BE_ST_ADDR_PASSED);
00188 }
00189
00190 inline BOOL
00191 BE_ST_addr_passed(const ST *const st)
00192 {
00193 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_ADDR_PASSED);
00194 }
00195
00196 inline void
00197 Set_BE_ST_addr_passed(const ST_IDX idx)
00198 {
00199 Be_symbol_table[idx].Set_flag(BE_ST_ADDR_PASSED);
00200 }
00201
00202 inline void
00203 Set_BE_ST_addr_passed(BE_ST *const be_st)
00204 {
00205 be_st->Set_flag(BE_ST_ADDR_PASSED);
00206 }
00207
00208 inline void
00209 Set_BE_ST_addr_passed(const ST *const st)
00210 {
00211 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_ADDR_PASSED);
00212 }
00213
00214 inline void
00215 Clear_BE_ST_addr_passed(const ST_IDX idx)
00216 {
00217 Be_symbol_table[idx].Clear_flag(BE_ST_ADDR_PASSED);
00218 }
00219
00220 inline void
00221 Clear_BE_ST_addr_passed(BE_ST *const be_st)
00222 {
00223 be_st->Clear_flag(BE_ST_ADDR_PASSED);
00224 }
00225
00226 inline void
00227 Clear_BE_ST_addr_passed(const ST *const st)
00228 {
00229 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_ADDR_PASSED);
00230 }
00231
00232
00233 inline BOOL
00234 BE_ST_w2fc_referenced(const ST_IDX idx)
00235 {
00236 return Be_symbol_table[idx].Is_set(BE_ST_W2FC_REFERENCED);
00237 }
00238
00239 inline BOOL
00240 BE_ST_w2fc_referenced(const BE_ST *const be_st)
00241 {
00242 return be_st->Is_set(BE_ST_W2FC_REFERENCED);
00243 }
00244
00245 inline BOOL
00246 BE_ST_w2fc_referenced(const ST *const st)
00247 {
00248 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_W2FC_REFERENCED);
00249 }
00250
00251 inline void
00252 Set_BE_ST_w2fc_referenced(const ST_IDX idx)
00253 {
00254 Be_symbol_table[idx].Set_flag(BE_ST_W2FC_REFERENCED);
00255 }
00256
00257 inline void
00258 Set_BE_ST_w2fc_referenced(BE_ST *const be_st)
00259 {
00260 be_st->Set_flag(BE_ST_W2FC_REFERENCED);
00261 }
00262
00263 inline void
00264 Set_BE_ST_w2fc_referenced(const ST *const st)
00265 {
00266 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_W2FC_REFERENCED);
00267 }
00268
00269 inline void
00270 Clear_BE_ST_w2fc_referenced(BE_ST *const be_st)
00271 {
00272 be_st->Clear_flag(BE_ST_W2FC_REFERENCED);
00273 }
00274
00275 inline void
00276 Clear_BE_ST_w2fc_referenced(const ST *const st)
00277 {
00278 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_W2FC_REFERENCED);
00279 }
00280
00281 inline void
00282 Clear_BE_ST_w2fc_referenced(const ST_IDX idx)
00283 {
00284 Be_symbol_table[idx].Clear_flag(BE_ST_W2FC_REFERENCED);
00285 }
00286
00287
00288 inline BOOL
00289 BE_ST_unknown_const(const ST_IDX idx)
00290 {
00291 return Be_symbol_table[idx].Is_set(BE_ST_UNKNOWN_CONST);
00292 }
00293
00294 inline BOOL
00295 BE_ST_unknown_const(const BE_ST *const be_st)
00296 {
00297 return be_st->Is_set(BE_ST_UNKNOWN_CONST);
00298 }
00299
00300 inline BOOL
00301 BE_ST_unknown_const(const ST *const st)
00302 {
00303 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_UNKNOWN_CONST);
00304 }
00305
00306 inline void
00307 Set_BE_ST_unknown_const(const ST_IDX idx)
00308 {
00309 Be_symbol_table[idx].Set_flag(BE_ST_UNKNOWN_CONST);
00310 }
00311
00312 inline void
00313 Set_BE_ST_unknown_const(BE_ST *const be_st)
00314 {
00315 be_st->Set_flag(BE_ST_UNKNOWN_CONST);
00316 }
00317
00318 inline void
00319 Set_BE_ST_unknown_const(const ST *const st)
00320 {
00321 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_UNKNOWN_CONST);
00322 }
00323
00324 inline void
00325 Clear_BE_ST_unknown_const(BE_ST *const be_st)
00326 {
00327 be_st->Clear_flag(BE_ST_UNKNOWN_CONST);
00328 }
00329
00330 inline void
00331 Clear_BE_ST_unknown_const(const ST *const st)
00332 {
00333 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_UNKNOWN_CONST);
00334 }
00335
00336 inline void
00337 Clear_BE_ST_unknown_const(const ST_IDX idx)
00338 {
00339 Be_symbol_table[idx].Clear_flag(BE_ST_UNKNOWN_CONST);
00340 }
00341
00342
00343 inline BOOL
00344 BE_ST_pu_has_valid_addr_flags(const ST_IDX idx)
00345 {
00346 return Be_symbol_table[idx].Is_set(BE_ST_PU_HAS_VALID_ADDR_FLAGS);
00347 }
00348
00349 inline BOOL
00350 BE_ST_pu_has_valid_addr_flags(const BE_ST *const be_st)
00351 {
00352 return be_st->Is_set(BE_ST_PU_HAS_VALID_ADDR_FLAGS);
00353 }
00354
00355 inline BOOL
00356 BE_ST_pu_has_valid_addr_flags(const ST *const st)
00357 {
00358 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_PU_HAS_VALID_ADDR_FLAGS);
00359 }
00360
00361 inline void
00362 Set_BE_ST_pu_has_valid_addr_flags(const ST_IDX idx)
00363 {
00364 Be_symbol_table[idx].Set_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS);
00365 }
00366
00367 inline void
00368 Set_BE_ST_pu_has_valid_addr_flags(BE_ST *const be_st)
00369 {
00370 be_st->Set_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS);
00371 }
00372
00373 inline void
00374 Set_BE_ST_pu_has_valid_addr_flags(const ST *const st)
00375 {
00376 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS);
00377 }
00378
00379 inline void
00380 Clear_BE_ST_pu_has_valid_addr_flags(BE_ST *const be_st)
00381 {
00382 be_st->Clear_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS);
00383 }
00384
00385 inline void
00386 Clear_BE_ST_pu_has_valid_addr_flags(const ST *const st)
00387 {
00388 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS);
00389 }
00390
00391 inline void
00392 Clear_BE_ST_pu_has_valid_addr_flags(const ST_IDX idx)
00393 {
00394 Be_symbol_table[idx].Clear_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS);
00395 }
00396
00397
00398 inline BOOL
00399 BE_ST_pu_needs_addr_flag_adjust(const ST_IDX idx)
00400 {
00401 return Be_symbol_table[idx].Is_set(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST);
00402 }
00403
00404 inline BOOL
00405 BE_ST_pu_needs_addr_flag_adjust(const BE_ST *const be_st)
00406 {
00407 return be_st->Is_set(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST);
00408 }
00409
00410 inline BOOL
00411 BE_ST_pu_needs_addr_flag_adjust(const ST *const st)
00412 {
00413 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST);
00414 }
00415
00416 inline void
00417 Set_BE_ST_pu_needs_addr_flag_adjust(const ST_IDX idx)
00418 {
00419 Be_symbol_table[idx].Set_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST);
00420 }
00421
00422 inline void
00423 Set_BE_ST_pu_needs_addr_flag_adjust(BE_ST *const be_st)
00424 {
00425 be_st->Set_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST);
00426 }
00427
00428 inline void
00429 Set_BE_ST_pu_needs_addr_flag_adjust(const ST *const st)
00430 {
00431 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST);
00432 }
00433
00434 inline void
00435 Clear_BE_ST_pu_needs_addr_flag_adjust(BE_ST *const be_st)
00436 {
00437 be_st->Clear_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST);
00438 }
00439
00440 inline void
00441 Clear_BE_ST_pu_needs_addr_flag_adjust(const ST *const st)
00442 {
00443 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST);
00444 }
00445
00446 inline void
00447 Clear_BE_ST_pu_needs_addr_flag_adjust(const ST_IDX idx)
00448 {
00449 Be_symbol_table[idx].Clear_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST);
00450 }
00451
00452 inline BOOL
00453 BE_ST_referenced (const ST *const st)
00454 {
00455 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_REFERENCED);
00456 }
00457 inline void
00458 Set_BE_ST_referenced(const ST *const st)
00459 {
00460 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_REFERENCED);
00461 }
00462 inline void
00463 Clear_BE_ST_referenced (const ST *const st)
00464 {
00465 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_REFERENCED);
00466 }
00467
00468
00469
00470
00471
00472
00473
00474
00475 extern BOOL
00476 ST_is_const_initialized(const ST *);
00477
00478
00479
00480
00481 extern BOOL
00482 ST_is_const_initialized_scalar(const ST *, INT64 offset, TCON &tcon_copy);
00483
00484
00485
00486 extern INITV_IDX
00487 ST_is_const_and_has_initv(const ST *);
00488
00489
00490
00491 extern INITV_IDX
00492 ST_has_initv(const ST *);
00493
00494
00495
00496
00497 class BE_PU {
00498 private:
00499 mUINT16 last_label;
00500 public:
00501 INT16 Last_label(void) const { return last_label; }
00502 };
00503
00504 class BE_PREG {
00505 private:
00506 WN *home_location;
00507 #ifdef TARG_NVISA
00508 WN *lda;
00509 #endif
00510 public:
00511 #ifdef TARG_NVISA
00512 BE_PREG(void) : home_location(NULL), lda(NULL) { }
00513 #else
00514 BE_PREG(void) : home_location(NULL) { }
00515 #endif
00516 void Set_home_location(WN *wn) { home_location = wn; }
00517 WN *Home_location(void) const { return home_location; }
00518 #ifdef TARG_NVISA
00519 void Set_lda(WN *wn) { lda = wn; }
00520 WN *Lda(void) const { return lda; }
00521 #endif
00522 };
00523
00524 typedef RELATED_SEGMENTED_ARRAY<BE_PREG> BE_PREG_TAB;
00525
00526 extern BE_PREG_TAB Be_preg_tab;
00527
00528
00529
00530
00531 static inline PREG_NUM
00532 Create_Preg(TYPE_ID mtype,const char *name, WN *home)
00533 {
00534 PREG_NUM retval = Create_Preg(mtype, name);
00535 Be_preg_tab[retval - Last_Dedicated_Preg_Offset].Set_home_location(home);
00536 return retval;
00537 }
00538
00539 static inline WN *
00540 Preg_Home(PREG_NUM preg)
00541 {
00542 const UINT idx = preg - Last_Dedicated_Preg_Offset;
00543 return (idx < Be_preg_tab.Size()) ? Be_preg_tab[idx].Home_location() : NULL;
00544 }
00545
00546 #ifdef TARG_NVISA
00547 static inline WN*
00548 Preg_Lda(PREG_NUM preg)
00549 {
00550 const UINT idx = preg - Last_Dedicated_Preg_Offset;
00551 return (idx < Be_preg_tab.Size()) ? Be_preg_tab[idx].Lda() : NULL;
00552 }
00553
00554 static inline void
00555 Set_Preg_Lda(PREG_NUM preg, WN *wn)
00556 {
00557 Be_preg_tab[preg - Last_Dedicated_Preg_Offset].Set_lda(wn);
00558 }
00559
00560
00561
00562
00563 extern WN* Find_Lda (WN *tree);
00564 #endif
00565
00566 extern void BE_symtab_initialize_be_scopes(void);
00567 extern void BE_symtab_free_be_scopes(void);
00568 extern void BE_symtab_alloc_scope_level(SYMTAB_IDX);
00569 #endif // be_symtab_INCLUDED