Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00036 /* -*-Mode: c++;-*- (Tell emacs to use c++ mode) */ 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 /* targ_sim_INCLUDED */ 00056 00057 typedef mUINT32 BE_ST_IDX; 00058 00059 // Definitions for BE_ST::flags 00060 00061 const UINT32 BE_ST_ADDR_USED_LOCALLY = 0x00000001; // Address of item is taken somewhere 00062 const UINT32 BE_ST_ADDR_PASSED = 0x00000002; // Address of item is passed by ref 00063 const UINT32 BE_ST_W2FC_REFERENCED = 0x00000004; // whirl2{f,c} sees reference to ST 00064 const UINT32 BE_ST_UNKNOWN_CONST = 0x00000008; // Const, with unknown value 00065 // (Generated by LNO) 00066 // BE_ST_ADDR_ADDR_* bits are valid only if this is set 00067 const UINT32 BE_ST_PU_HAS_VALID_ADDR_FLAGS = 0x00000010; 00068 00069 // ST_ADDR_* bits are no longer valid and need to be recomputed 00070 const UINT32 BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST = 0x00000020; 00071 00072 00073 // Back-end-specific information about each symtab entry 00074 00075 class BE_ST { 00076 mUINT32 flags; 00077 void *io_auxst; 00078 00079 public: 00080 BE_ST(void) : flags(0),io_auxst(NULL) { } 00081 BOOL Is_set(UINT32 f) const { return flags & f; } 00082 void Set_flag(UINT32 f) { flags |= f; } 00083 void Clear_flag(UINT32 f) { flags &= ~f; } 00084 void Set_io_auxst(void *v) { io_auxst = v; } 00085 void * Io_auxst(void) { return io_auxst; } 00086 }; 00087 00088 typedef RELATED_SEGMENTED_ARRAY<BE_ST> BE_ST_TAB; 00089 00090 struct BE_SCOPE { 00091 BE_ST_TAB *be_st_tab; 00092 }; 00093 00094 struct BE_SCOPE_TAB_BE_ST_TAB_ACCESS { 00095 BE_SCOPE_TAB_BE_ST_TAB_ACCESS(void) { } 00096 00097 BE_ST_TAB *operator()(BE_SCOPE **be_scope_tab, SYMTAB_IDX level) 00098 { return (*be_scope_tab)[level].be_st_tab; } 00099 }; 00100 00101 extern BE_SCOPE *Be_scope_tab; 00102 00103 typedef TABLE_INDEXED_BY_LEVEL8_AND_INDEX24<BE_ST, ST_IDX, SYMTAB_IDX, 00104 BE_SCOPE *, &Be_scope_tab, 00105 BE_SCOPE_TAB_BE_ST_TAB_ACCESS> 00106 BE_SYMBOL_TABLE; 00107 00108 extern BE_SYMBOL_TABLE Be_symbol_table; 00109 00110 inline BOOL 00111 BE_ST_addr_used_locally(const ST_IDX idx) 00112 { 00113 return Be_symbol_table[idx].Is_set(BE_ST_ADDR_USED_LOCALLY); 00114 } 00115 00116 inline BOOL 00117 BE_ST_addr_used_locally(const BE_ST *const be_st) 00118 { 00119 return be_st->Is_set(BE_ST_ADDR_USED_LOCALLY); 00120 } 00121 00122 inline BOOL 00123 BE_ST_addr_used_locally(const ST *const st) 00124 { 00125 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_ADDR_USED_LOCALLY); 00126 } 00127 00128 inline void 00129 Set_BE_ST_addr_used_locally(const ST_IDX idx) 00130 { 00131 Be_symbol_table[idx].Set_flag(BE_ST_ADDR_USED_LOCALLY); 00132 } 00133 00134 inline void 00135 Set_BE_ST_addr_used_locally(BE_ST *const be_st) 00136 { 00137 be_st->Set_flag(BE_ST_ADDR_USED_LOCALLY); 00138 } 00139 00140 inline void 00141 Set_BE_ST_addr_used_locally(const ST *const st) 00142 { 00143 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_ADDR_USED_LOCALLY); 00144 } 00145 00146 inline void 00147 Clear_BE_ST_addr_used_locally(const ST_IDX idx) 00148 { 00149 Be_symbol_table[idx].Clear_flag(BE_ST_ADDR_USED_LOCALLY); 00150 } 00151 00152 inline void 00153 Clear_BE_ST_addr_used_locally(BE_ST *const be_st) 00154 { 00155 be_st->Clear_flag(BE_ST_ADDR_USED_LOCALLY); 00156 } 00157 00158 inline void 00159 Clear_BE_ST_addr_used_locally(const ST *const st) 00160 { 00161 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_ADDR_USED_LOCALLY); 00162 } 00163 00164 inline void 00165 BE_ST_set_io_auxst(const ST_IDX idx, void *v) 00166 { 00167 Be_symbol_table[idx].Set_io_auxst(v); 00168 } 00169 00170 inline void * 00171 BE_ST_io_auxst(const ST_IDX idx) 00172 { 00173 return Be_symbol_table[idx].Io_auxst(); 00174 } 00175 00176 00177 inline BOOL 00178 BE_ST_addr_passed(const ST_IDX idx) 00179 { 00180 return Be_symbol_table[idx].Is_set(BE_ST_ADDR_PASSED); 00181 } 00182 00183 inline BOOL 00184 BE_ST_addr_passed(const BE_ST *const be_st) 00185 { 00186 return be_st->Is_set(BE_ST_ADDR_PASSED); 00187 } 00188 00189 inline BOOL 00190 BE_ST_addr_passed(const ST *const st) 00191 { 00192 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_ADDR_PASSED); 00193 } 00194 00195 inline void 00196 Set_BE_ST_addr_passed(const ST_IDX idx) 00197 { 00198 Be_symbol_table[idx].Set_flag(BE_ST_ADDR_PASSED); 00199 } 00200 00201 inline void 00202 Set_BE_ST_addr_passed(BE_ST *const be_st) 00203 { 00204 be_st->Set_flag(BE_ST_ADDR_PASSED); 00205 } 00206 00207 inline void 00208 Set_BE_ST_addr_passed(const ST *const st) 00209 { 00210 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_ADDR_PASSED); 00211 } 00212 00213 inline void 00214 Clear_BE_ST_addr_passed(const ST_IDX idx) 00215 { 00216 Be_symbol_table[idx].Clear_flag(BE_ST_ADDR_PASSED); 00217 } 00218 00219 inline void 00220 Clear_BE_ST_addr_passed(BE_ST *const be_st) 00221 { 00222 be_st->Clear_flag(BE_ST_ADDR_PASSED); 00223 } 00224 00225 inline void 00226 Clear_BE_ST_addr_passed(const ST *const st) 00227 { 00228 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_ADDR_PASSED); 00229 } 00230 00231 00232 inline BOOL 00233 BE_ST_w2fc_referenced(const ST_IDX idx) 00234 { 00235 return Be_symbol_table[idx].Is_set(BE_ST_W2FC_REFERENCED); 00236 } 00237 00238 inline BOOL 00239 BE_ST_w2fc_referenced(const BE_ST *const be_st) 00240 { 00241 return be_st->Is_set(BE_ST_W2FC_REFERENCED); 00242 } 00243 00244 inline BOOL 00245 BE_ST_w2fc_referenced(const ST *const st) 00246 { 00247 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_W2FC_REFERENCED); 00248 } 00249 00250 inline void 00251 Set_BE_ST_w2fc_referenced(const ST_IDX idx) 00252 { 00253 Be_symbol_table[idx].Set_flag(BE_ST_W2FC_REFERENCED); 00254 } 00255 00256 inline void 00257 Set_BE_ST_w2fc_referenced(BE_ST *const be_st) 00258 { 00259 be_st->Set_flag(BE_ST_W2FC_REFERENCED); 00260 } 00261 00262 inline void 00263 Set_BE_ST_w2fc_referenced(const ST *const st) 00264 { 00265 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_W2FC_REFERENCED); 00266 } 00267 00268 inline void 00269 Clear_BE_ST_w2fc_referenced(BE_ST *const be_st) 00270 { 00271 be_st->Clear_flag(BE_ST_W2FC_REFERENCED); 00272 } 00273 00274 inline void 00275 Clear_BE_ST_w2fc_referenced(const ST *const st) 00276 { 00277 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_W2FC_REFERENCED); 00278 } 00279 00280 inline void 00281 Clear_BE_ST_w2fc_referenced(const ST_IDX idx) 00282 { 00283 Be_symbol_table[idx].Clear_flag(BE_ST_W2FC_REFERENCED); 00284 } 00285 00286 00287 inline BOOL 00288 BE_ST_unknown_const(const ST_IDX idx) 00289 { 00290 return Be_symbol_table[idx].Is_set(BE_ST_UNKNOWN_CONST); 00291 } 00292 00293 inline BOOL 00294 BE_ST_unknown_const(const BE_ST *const be_st) 00295 { 00296 return be_st->Is_set(BE_ST_UNKNOWN_CONST); 00297 } 00298 00299 inline BOOL 00300 BE_ST_unknown_const(const ST *const st) 00301 { 00302 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_UNKNOWN_CONST); 00303 } 00304 00305 inline void 00306 Set_BE_ST_unknown_const(const ST_IDX idx) 00307 { 00308 Be_symbol_table[idx].Set_flag(BE_ST_UNKNOWN_CONST); 00309 } 00310 00311 inline void 00312 Set_BE_ST_unknown_const(BE_ST *const be_st) 00313 { 00314 be_st->Set_flag(BE_ST_UNKNOWN_CONST); 00315 } 00316 00317 inline void 00318 Set_BE_ST_unknown_const(const ST *const st) 00319 { 00320 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_UNKNOWN_CONST); 00321 } 00322 00323 inline void 00324 Clear_BE_ST_unknown_const(BE_ST *const be_st) 00325 { 00326 be_st->Clear_flag(BE_ST_UNKNOWN_CONST); 00327 } 00328 00329 inline void 00330 Clear_BE_ST_unknown_const(const ST *const st) 00331 { 00332 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_UNKNOWN_CONST); 00333 } 00334 00335 inline void 00336 Clear_BE_ST_unknown_const(const ST_IDX idx) 00337 { 00338 Be_symbol_table[idx].Clear_flag(BE_ST_UNKNOWN_CONST); 00339 } 00340 00341 00342 inline BOOL 00343 BE_ST_pu_has_valid_addr_flags(const ST_IDX idx) 00344 { 00345 return Be_symbol_table[idx].Is_set(BE_ST_PU_HAS_VALID_ADDR_FLAGS); 00346 } 00347 00348 inline BOOL 00349 BE_ST_pu_has_valid_addr_flags(const BE_ST *const be_st) 00350 { 00351 return be_st->Is_set(BE_ST_PU_HAS_VALID_ADDR_FLAGS); 00352 } 00353 00354 inline BOOL 00355 BE_ST_pu_has_valid_addr_flags(const ST *const st) 00356 { 00357 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_PU_HAS_VALID_ADDR_FLAGS); 00358 } 00359 00360 inline void 00361 Set_BE_ST_pu_has_valid_addr_flags(const ST_IDX idx) 00362 { 00363 Be_symbol_table[idx].Set_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS); 00364 } 00365 00366 inline void 00367 Set_BE_ST_pu_has_valid_addr_flags(BE_ST *const be_st) 00368 { 00369 be_st->Set_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS); 00370 } 00371 00372 inline void 00373 Set_BE_ST_pu_has_valid_addr_flags(const ST *const st) 00374 { 00375 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS); 00376 } 00377 00378 inline void 00379 Clear_BE_ST_pu_has_valid_addr_flags(BE_ST *const be_st) 00380 { 00381 be_st->Clear_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS); 00382 } 00383 00384 inline void 00385 Clear_BE_ST_pu_has_valid_addr_flags(const ST *const st) 00386 { 00387 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS); 00388 } 00389 00390 inline void 00391 Clear_BE_ST_pu_has_valid_addr_flags(const ST_IDX idx) 00392 { 00393 Be_symbol_table[idx].Clear_flag(BE_ST_PU_HAS_VALID_ADDR_FLAGS); 00394 } 00395 00396 00397 inline BOOL 00398 BE_ST_pu_needs_addr_flag_adjust(const ST_IDX idx) 00399 { 00400 return Be_symbol_table[idx].Is_set(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST); 00401 } 00402 00403 inline BOOL 00404 BE_ST_pu_needs_addr_flag_adjust(const BE_ST *const be_st) 00405 { 00406 return be_st->Is_set(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST); 00407 } 00408 00409 inline BOOL 00410 BE_ST_pu_needs_addr_flag_adjust(const ST *const st) 00411 { 00412 return Be_symbol_table[ST_st_idx(st)].Is_set(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST); 00413 } 00414 00415 inline void 00416 Set_BE_ST_pu_needs_addr_flag_adjust(const ST_IDX idx) 00417 { 00418 Be_symbol_table[idx].Set_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST); 00419 } 00420 00421 inline void 00422 Set_BE_ST_pu_needs_addr_flag_adjust(BE_ST *const be_st) 00423 { 00424 be_st->Set_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST); 00425 } 00426 00427 inline void 00428 Set_BE_ST_pu_needs_addr_flag_adjust(const ST *const st) 00429 { 00430 Be_symbol_table[ST_st_idx(st)].Set_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST); 00431 } 00432 00433 inline void 00434 Clear_BE_ST_pu_needs_addr_flag_adjust(BE_ST *const be_st) 00435 { 00436 be_st->Clear_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST); 00437 } 00438 00439 inline void 00440 Clear_BE_ST_pu_needs_addr_flag_adjust(const ST *const st) 00441 { 00442 Be_symbol_table[ST_st_idx(st)].Clear_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST); 00443 } 00444 00445 inline void 00446 Clear_BE_ST_pu_needs_addr_flag_adjust(const ST_IDX idx) 00447 { 00448 Be_symbol_table[idx].Clear_flag(BE_ST_PU_NEEDS_ADDR_FLAG_ADJUST); 00449 } 00450 00451 00452 00453 00454 // 00455 // BE-ST related utilities 00456 // 00457 00458 // Return TRUE iff the ST is known to be a constant initialized to 00459 // some value. 00460 extern BOOL 00461 ST_is_const_initialized(const ST *); 00462 00463 // Return TRUE iff the ST is known to be a constant scalar initialized 00464 // to a value we can determine at compile time and return in the 00465 // argument tcon_copy. 00466 extern BOOL 00467 ST_is_const_initialized_scalar(const ST *, TCON &tcon_copy); 00468 00469 // Return the INITV_IDX of the value of the ST if the ST is a const 00470 // initialized scalar and we can find the INITV. 00471 extern INITV_IDX 00472 ST_is_const_and_has_initv(const ST *); 00473 00474 // Return the INITV_IDX of the value of the ST if st is a 00475 // initialized scalar and we can find the INITV. 00476 extern INITV_IDX 00477 ST_has_initv(const ST *); 00478 00479 00480 // Back-end-specific information about each PU 00481 00482 class BE_PU { 00483 private: 00484 mUINT16 last_label; 00485 public: 00486 INT16 Last_label(void) const { return last_label; } 00487 }; 00488 00489 class BE_PREG { 00490 private: 00491 WN *home_location; 00492 public: 00493 BE_PREG(void) : home_location(NULL) { } 00494 void Set_home_location(WN *wn) { home_location = wn; } 00495 WN *Home_location(void) const { return home_location; } 00496 }; 00497 00498 typedef RELATED_SEGMENTED_ARRAY<BE_PREG> BE_PREG_TAB; 00499 00500 extern BE_PREG_TAB Be_preg_tab; 00501 00502 // Create_Preg for back end components that want to associate a 00503 // home location with each register. 00504 00505 static inline PREG_NUM 00506 Create_Preg(TYPE_ID mtype, char *name, WN *home) 00507 { 00508 PREG_NUM retval = Create_Preg(mtype, name); 00509 Be_preg_tab[retval - Last_Dedicated_Preg_Offset].Set_home_location(home); 00510 return retval; 00511 } 00512 00513 static inline WN * 00514 Preg_Home(PREG_NUM preg) 00515 { 00516 const UINT idx = preg - Last_Dedicated_Preg_Offset; 00517 return (idx < Be_preg_tab.Size()) ? Be_preg_tab[idx].Home_location() : NULL; 00518 } 00519 00520 extern void BE_symtab_initialize_be_scopes(void); 00521 extern void BE_symtab_free_be_scopes(void); 00522 extern void BE_symtab_alloc_scope_level(const SYMTAB_IDX); 00523 00524 00525 #endif // be_symtab_INCLUDED