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 /* ==================================================================== 00037 * ==================================================================== 00038 * 00039 * 00040 * Revision history: 00041 * 07-APR-95 lo - spilt from opt_alias.h 00042 * 00043 * Description: 00044 * 00045 * ==================================================================== 00046 * ==================================================================== 00047 */ 00048 00049 #ifndef opt_alias_interface_INCLUDED 00050 #define opt_alias_interface_INCLUDED "opt_alias_interface.h" 00051 #ifdef _KEEP_RCS_ID 00052 #endif /* _KEEP_RCS_ID */ 00053 00054 00055 /* ======================================================================== 00056 * 00057 * ALIAS ANALYSIS INTERFACE 00058 * ------------------------ 00059 * 00060 * The alias information is generated in the preopt/wopt phase. 00061 * The consumers are IPA, LNO, and CG. The information is passed in memory 00062 * for IPA and LNO. The information is emitted into the WHIRL IR 00063 * and passed through .B file to CG. 00064 * [ The previous sentence is a lie. The information is passed in 00065 * memory to CG as well. -- RK 981106 ] 00066 * 00067 * 00068 * ALIAS_MANAGER 00069 * ------------- 00070 * All the alias data is managed by the ALIAS_MANAGER. 00071 * The alias context is used to identify the alias rule set to 00072 * be applied. See opt_alias_rule.h for details about 00073 * ALIAS_CONTEXT. 00074 * 00075 * struct ALIAS_MANAGER *Create_Alias_Manager(void) 00076 * Create an alias manager. The alias manager will have its 00077 * own memory pool and manage the memory used by the alias information 00078 * itself. 00079 * 00080 * void Delete_Alias_Manager(struct ALIAS_MANAGER *) 00081 * Destroy the alias manager. Free the MEM_POOL used. 00082 * 00083 * ALIAS_CONTEXT Get_Default_Alias_Context(struct ALIAS_MANAGER *) 00084 * Obtain the current alias context. 00085 * 00086 * void Set_Alias_Context(struct ALIAS_MANAGER *, ALIAS_CONTEXT); 00087 * Set up the current alias context. 00088 * 00089 * void Reset_Alias_Context(struct ALIAS_MANAGER *); 00090 * Revert to the default alias context. 00091 * 00092 * 00093 * Alias analysis functions 00094 * ------------------------ 00095 * 00096 * The alias analysis function return ALIAS_RESULT (one of the following 00097 * three values). 00098 * 00099 * NOT_ALIASED: two memory operations are not aliased. 00100 * POSSIBLY_ALIASED: we can't prove the memory operations are not aliased. 00101 * SAME_LOCATION: two memory operations are aliased and access exactly 00102 * the same memory locations. the size of memory accessed 00103 * must be the same too. 00104 * 00105 * WARNING: Alias analyis ALWAYS RETURN conservatively answers. 00106 * Even though two memory operations are not aliased, the analysis may not be 00107 * powerful enough to determine that. It is correct to return POSSILBY_ALIASED. 00108 * Similarly, for two memory operations that access the same location, it is 00109 * correct for the alias analyzer to return POSSIBLY_ALIASED. 00110 * 00111 * ALIAS_RESULT Aliased(const struct ALIAS_MANAGER *, const WN *wn1, const WN *wn2) 00112 * Check whether the memory accessed by wn1 and wn2 overlaps. 00113 * 00114 * ALIAS_RESULT Overlapped_base(const struct ALIAS_MANAGER *, const WN *wn1, const WN *wm2) 00115 * Ignore the context-sensitive offset information from wn1 and wn2. 00116 * Check whether the memory accessed by wn1 and wn2 overlaps. 00117 * 00118 * Example: 00119 * do i 00120 * a[i] 00121 * a[i+1] 00122 * 00123 * Aliased(manager, "a[i]", "a[i+1]") return NOT_ALIASED because 00124 * context-sensitive analysis MAY determine that a[i] and a[i+1] are both 00125 * based on &a[i]. By applying the Offset rule, a[i] and a[i+1] are said 00126 * to be not aliased. 00127 * 00128 * Notice that this is only true for a particular iteration. The a[i+1] 00129 * is aliased to the *p of the following iteration. LNO requested to 00130 * return POSSIBLY_ALIASED for a[i] and a[i+1] because they really care 00131 * about the dependence across all iterations. 00132 * 00133 * The function Overlapped_base() is written to provide this functionality. 00134 * It always return ALIASED if the base is not a constant address. 00135 * It ignores the offset information derived from context-sensitive analysis. 00136 * Therefore, for both a[i] and a[i+1], the offset is undetermined. 00137 * However, for a[1] or a[2], the offset is determined becuase it can be derived 00138 * from the tree underneath the load/store operation. 00139 * 00140 * 00141 * ALIAS_RESULT Aliased_with_region(const struct ALIAS_MANAGER *, 00142 * WN *call_or_region, WN *wn, READ_WRITE); 00143 * Check if the wn operations has dependence with a REGION. 00144 * CALL is regarded a simple region. READ_WRITE specifies 00145 * the dependence checked (READ dependence, WRITE dependence, or both). 00146 * FORWARD_BARRIER/BACKWARD_BARRIER/DEALLOCA are another form or REGION. 00147 * 00148 * 00149 * BOOL Homing_Load( const struct ALIAS_MANAGER *, const WN *load_wn ) 00150 * void Set_Homing_Load( struct ALIAS_MANAGER *, WN *load_wn ) 00151 * void Reset_Homing_Load( struct ALIAS_MANAGER *, WN *load_wn ) 00152 * 00153 * Determine if the load is from a variable's home location to be stored 00154 * into that var's preg. 00155 * 00156 * BOOL Homing_Store( const struct ALIAS_MANAGER *, const WN *store_wn ) 00157 * void Set_Homing_Store( struct ALIAS_MANAGER *, WN *store_wn ) 00158 * void Reset_Homing_Store( struct ALIAS_MANAGER *, WN *store_wn ) 00159 * 00160 * Determine if the store is to a variable's home location and the value 00161 * being stored is that var's preg. 00162 * 00163 * Lowering and Unrolling Support 00164 * ------------------------------ 00165 * 00166 * The alias package provides basic support for the update of 00167 * alias information as new memory operations are created during 00168 * lowering and unrolling. The support is minimal so that correct 00169 * alias analysis is possible. However, re-analyze the unrolled memop 00170 * is needed to provide a better solution. 00171 * In fact, the Aliased_Memop() in cgprep.c of Ragnarok handle this situation 00172 * by examining the INS. 00173 * 00174 * void Copy_alias_info(const struct ALIAS_MANAGER *, WN *wn1, WN *wn2) 00175 * The alias information of wn1 is transfered to wn2. This will be used 00176 * by lowering. For example, LDID a ---> ILOAD (LDA a). 00177 * An iload is created and it should have identical alias behavior as the 00178 * LDID. 00179 * 00180 * void Duplicate_alias_info(struct ALIAS_MANAGER *, 00181 * const WN *wn1, WN *wn2) 00182 * The alias information of wn1 is duplicated to wn2, and some updating 00183 * both wn1 and wn1 to reduce the strength of alias analysis. 00184 * 00185 * void Create_vector_alias(struct ALIAS_MANAGER *, WN *wn1, WN *wn2) 00186 * The alias information of wn1 (accessing an element) is 00187 * copied to wn2 (accessing the entire array). 00188 * 00189 * BOOL Valid_alias(const struct ALIAS_MANAGER *am, WN *wn); 00190 * Return true if the wn has a valid alias mapping 00191 * 00192 * Duplicate_alias_info() is used by unrolling. As CG unrolls a loop, 00193 * it duplicates the memops. The duplicated memops should have similar, but 00194 * not idential alias behavior as the original because 00195 * the alias information does not apply across iterations. 00196 * 00197 * Notice that If the address of the memory operation is a loop invariant, then 00198 * the unroller should use Copy_alias_info() to transfer the alias information 00199 * in order to preserve all the useful alias information. 00200 * 00201 * LNO & Lowerer Support 00202 * --------------------- 00203 * 00204 * This routines update the alias information associated with newly created WHIRL nodes. 00205 * 00206 * void Create_alias(struct ALIAS_MANAGER *, WN *wn) 00207 * Create a new alias id corresponding to WHIRL load/store. 00208 * 00209 * void Create_local_alias(struct ALIAS_MANAGER *, WN *wn) 00210 * Create a new alias id corresponding to the ST in the WHIRL node. 00211 * Assume the ST is a local var, and not address taken. 00212 * 00213 * void Create_global_alias(struct ALIAS_MANAGER *, ST *, WN *ldid, WN *iload) 00214 * The ST is a global variable. 00215 * Create a new alias id corresponding to LDID ST to the ldid WHIRL node. 00216 * Create a new alias id corresponding to ILOAD (LDID ST) to the iload WHIRL node. 00217 * 00218 * void Create_formal_alias(struct ALIAS_MANAGER *, ST *, WN *formal_addr, WN *formal) 00219 * The ST in formal_addr must be SCLASS_FORMAL. 00220 * Assume FORTRAN alias rule: formals are not aliased with other variables. 00221 * Create alias ids for both the variable containing the formal and the formal. 00222 * 00223 * void Create_unique_pointer_alias(struct ALIAS_MANAGER *, ST *, WN *ldid, WN *iload) 00224 * ST is the symbol that points to this chunk memory exclusively. 00225 * ST must have the PT_TO_UNIQUE_MEM bit set. 00226 * Create a new alias id corresponding to LDID ST to the ldid WHIRL node. 00227 * Create a new alias id corresponding to ILOAD (LDID ST) to the iload WHIRL node. 00228 * 00229 * void Create_lda_array_alias(struct ALIAS_MANAGER *am, WN *lda, WN *iload) 00230 * Create a new alias id corresponding to the array access. 00231 * 00232 * void Erase_Restricted_Mapping(WN *wn) 00233 * Erase the restricted pointer stored in the 'restrict map'. 00234 * Should be called when an array is localized. 00235 * 00236 * void Note_Invalid_Based_Symbol(const ST *st) 00237 * Mark the symbol "st" as an invalid based_sym in the restricted 00238 * map. This should be called when an array is distribute/reshaped 00239 * by LNO because memory operations based on the symbol are now 00240 * based on another symbol introduced during the distribute/reshape 00241 * operation. 00242 * 00243 * void Note_Invalid_IP_Alias_Class(const WN *wn) 00244 * Mark the interprocedural alias class of "wn" as invalid. This 00245 * should be called when an array accessed by "wn" is equivalenced 00246 * by LNO during Equivalence_arrays, because the alias behavior of 00247 * the array as seen by IPA is no longer valid. 00248 * 00249 * void Invalidate_Persistent_Alias_Info(ALIAS_MANAGER *, WN *); 00250 * Removes those items marked as invalid by 00251 * Note_Invalid_Based_Symbol and Note_Invalid_IP_Alias_Class. This 00252 * should be called at the end of LNO, after Copy_Restricted_Map is 00253 * used to move the restricted map entries to the new WHIRL tree 00254 * from the alias manager. 00255 * 00256 * ALIAS_RESULT ALIAS_MANAGER::Aliased(WN *wn, const POINTS_TO *pt); 00257 * ALIAS_RESULT ALIAS_MANAGER::Aliased(const POINTS_TO *pt, WN *wn); 00258 * Determine if a WHIRL load/store is aliased with a POINTS_TO. 00259 * 00260 * ALIAS_RESULT ALIAS_MANAGER::Aliased(const POINTS_TO *pt1, const POINTS_TO *pt2); 00261 * Determine if two POINTS_TO are aliased. 00262 * 00263 * POINTS_TO(ST *st, BOOL indirect = FALSE) 00264 * POINTS_TO(ST *st, INT64 ofst, INT64 size, BOOL indirect = FALSE) 00265 * The ALIAS_MANAGER::Aliased() routine takes POINTS_TO. The POINTS_TO 00266 * can be constructed using these constructors. Set indirect to 00267 * FALSE for regular variables. Set indirect to TRUE when the ST is 00268 * a pointer and you want to construct a POINTS_TO for the object the pointer 00269 * points to. 00270 * 00271 * 00272 * Misc 00273 * ---- 00274 * 00275 * void Dump_alias_mgr(const struct ALIAS_MANAGER *, const WN *, FILE *) 00276 * Prints out the WHIRL tree with their alias id. 00277 * Prints out the alias arcs. 00278 * 00279 * void Print_alias_info(char *buf, const struct ALIAS_MANAGER *, WN *wn) 00280 * Prints out some of the alias information. 00281 * 00282 * BOOL ALIAS_MANAGER::Safe_to_speculate(const WN *) 00283 * Returns TRUE if the object accessed by the WN node will be 00284 * allocated, and therefore safe to be speculatively accessed. 00285 * This function returns TRUE under two situations: 00286 * 1) the WN node accesses a PREG; 00287 * 2) the POINTS_TO of the WHIRL node satisfies the following conditions: 00288 * a) the POINTS_TO represents an address expr; 00289 * b) the base ST is valid and non-NULL; 00290 * c) the offset is valid and size is non-zero. 00291 * d) the POINTS_TO have the Safe_to_speculate attribute set 00292 * Condition (2c) is used to suppress the motion of array expr 00293 * if the size of the array is unknown. 00294 * Condition (2d) is used to prevent speculation of weak symbol, 00295 * optional parameters, ... 00296 * 00297 * ======================================================================== 00298 */ 00299 00300 #include "defs.h" 00301 #include "mempool.h" 00302 #include "wn.h" 00303 00304 #ifdef __cplusplus 00305 extern "C" { 00306 #endif 00307 00308 struct ALIAS_MANAGER; 00309 struct POINTS_TO; 00310 struct PU; 00311 00312 typedef enum { 00313 NOT_ALIASED = 0, 00314 POSSIBLY_ALIASED = 1, 00315 SAME_LOCATION = 2 00316 } ALIAS_RESULT; 00317 00318 /* Be careful when redefining the enum. READ and WRITE are bit masks. */ 00319 typedef enum { 00320 NO_READ_NO_WRITE = 0, 00321 READ = 0x1, 00322 WRITE = 0x2, 00323 READ_AND_WRITE =0x3 00324 } READ_WRITE; 00325 00326 typedef UINT32 ALIAS_CONTEXT; 00327 00328 struct ALIAS_MANAGER *Create_Alias_Manager(MEM_POOL *); 00329 00330 void Delete_Alias_Manager(struct ALIAS_MANAGER *, MEM_POOL *); 00331 00332 void Create_Restricted_Map(MEM_POOL *); 00333 00334 void Copy_Restricted_Map(WN *, struct ALIAS_MANAGER *); 00335 00336 void Delete_Restricted_Map(void); 00337 00338 void Erase_Restricted_Mapping(WN *); 00339 00340 void Verify_Restricted_Map(const WN * const, const POINTS_TO * const); 00341 00342 BOOL Update_From_Restricted_Map(WN * const, POINTS_TO * const); 00343 00344 void Note_Invalid_Based_Symbol(const ST *); 00345 00346 struct ALIAS_RULE *Alias_Rule(struct ALIAS_MANAGER *); 00347 00348 ALIAS_CONTEXT Get_Default_Alias_Context(struct ALIAS_MANAGER *); 00349 00350 void Set_Alias_Context(struct ALIAS_MANAGER *, ALIAS_CONTEXT); 00351 00352 void Reset_Alias_Context(struct ALIAS_MANAGER *); 00353 00354 /* to be deleted */ void Assign_preg_alias_id(struct ALIAS_MANAGER *, WN *); 00355 00356 BOOL No_alias(const struct ALIAS_MANAGER *am, WN *wn); 00357 00358 BOOL Valid_alias(const struct ALIAS_MANAGER *am, WN *wn); 00359 00360 ALIAS_RESULT Aliased(const struct ALIAS_MANAGER *, WN *, WN *); 00361 00362 ALIAS_RESULT Overlapped_base(const struct ALIAS_MANAGER *, const WN *, const WN *); 00363 00364 ALIAS_RESULT Aliased_with_region(const struct ALIAS_MANAGER *, const WN *, const WN *, READ_WRITE); 00365 00366 ALIAS_RESULT Aliased_with_intr_op(const struct ALIAS_MANAGER *, const WN *, const WN *); 00367 00368 void Note_Invalid_IP_Alias_Class(ALIAS_MANAGER *, const WN *); 00369 00370 void Invalidate_Persistent_Alias_Info(ALIAS_MANAGER *, WN *); 00371 00372 BOOL Homing_Load( const struct ALIAS_MANAGER *, const WN *load_wn ); 00373 void Set_Homing_Load( struct ALIAS_MANAGER *, WN *load_wn ); 00374 void Reset_Homing_Load( struct ALIAS_MANAGER *, WN *load_wn ); 00375 00376 BOOL Homing_Store( const struct ALIAS_MANAGER *, const WN *store_wn ); 00377 void Set_Homing_Store( struct ALIAS_MANAGER *, WN *store_wn ); 00378 void Reset_Homing_Store( struct ALIAS_MANAGER *, WN *store_wn ); 00379 00380 void Copy_alias_info(const struct ALIAS_MANAGER *, WN *, WN *); 00381 00382 void Duplicate_alias_info(struct ALIAS_MANAGER *, WN *, WN *); 00383 00384 BOOL Verify_alias(struct ALIAS_MANAGER *, WN *); /* opt_verify.cxx */ 00385 00386 void Assign_alias_id(struct ALIAS_MANAGER *, WN *); 00387 00388 void Create_alias(struct ALIAS_MANAGER *, WN *); 00389 00390 void Create_local_alias(struct ALIAS_MANAGER *, WN *); 00391 00392 void Create_global_alias(struct ALIAS_MANAGER *, ST *, WN *, WN *); 00393 00394 void Create_formal_alias(struct ALIAS_MANAGER *, ST *, WN *, WN *); 00395 00396 void Create_vector_alias(struct ALIAS_MANAGER *, WN *, WN *); 00397 00398 void Create_unique_pointer_alias(struct ALIAS_MANAGER *, ST *, WN *, WN *); 00399 00400 void Create_lda_array_alias(struct ALIAS_MANAGER *, WN *, WN *); 00401 00402 void Print_alias_info(char *, const struct ALIAS_MANAGER *, const WN *); 00403 00404 BOOL May_refer_to_alloca_mem(const struct ALIAS_MANAGER *, const WN *); 00405 00406 BOOL Safe_to_speculate(const struct ALIAS_MANAGER *, const WN *); 00407 00408 void Dump_alias_mgr(const struct ALIAS_MANAGER *, const WN *, FILE *fp); 00409 00410 #ifdef __cplusplus 00411 } /* end extern "C" */ 00412 #endif 00413 00414 extern void PU_adjust_addr_flags(ST*, WN*); 00415 00416 #endif /* opt_alias_interface.h include */