Open64 (mfef90, whirl2f, and IR tools)  TAG: version-openad; SVN changeset: 916
opt_alias_mgr.h
Go to the documentation of this file.
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_mgr_INCLUDED
00050 #define opt_alias_mgr_INCLUDED  "opt_alias_mgr.h"
00051 #ifdef _KEEP_RCS_ID
00052 #endif /* _KEEP_RCS_ID */
00053 
00054 /***********************************************************************
00055 *
00056 *  ALIAS MANAGER IMPLEMENTATION
00057 *
00058 *  See opt_alias_interface.h also.
00059 *
00060 * 
00061 *  The manager also consists of a alias mapping.  It maps WN nodes
00062 *  to alias_ids.  During WHIRL emit time, each WN memory operation is 
00063 *  allocated an alias_id.  Identical memory operation should have the same 
00064 *  alias_id.  The alias_id is used to index into a dynamic array of
00065 *  POINTS_TO * to obtain the alias information of the WN node.
00066 * 
00067 *  In order to conserve space, an optimization is done for PREGs and 
00068 *  scalars that have no aliases except itself.  As usual, they are
00069 *  assigned alias_ids, but given a NULL POINTS_TO information because
00070 *  their alias information are easily derived from the WN node.
00071 *  
00072 ************************************************************************
00073 */
00074 
00075 #ifndef cxx_template_INCLUDED
00076 #include "cxx_template.h"
00077 #endif
00078 #include "opt_alias_interface.h"
00079 #include "opt_points_to.h"
00080 #include "mempool.h"
00081 #include "tracing.h"                    // for TFile
00082 
00083 class ALIAS_CLASSIFICATION;
00084 
00085 class ALIAS_MANAGER {
00086 
00087 private:
00088   MEM_POOL              _mem_pool;
00089   BOOL                  _trace;
00090   WN_MAP                _map;
00091   WN_MAP                _homing_map;
00092   IDTYPE                _last_alias_id;
00093   DYN_ARRAY<POINTS_TO*> *_vec;
00094   static const IDTYPE   _preg_id = 1;
00095   IDTYPE                _no_alias_info_id;
00096   ALIAS_CONTEXT         _pu_context;      // bitset of accepted alias rule
00097   ALIAS_RULE            *_rule;
00098 
00099   ALIAS_MANAGER(const ALIAS_MANAGER&);
00100   ALIAS_MANAGER& operator = (const ALIAS_MANAGER&);
00101 
00102   DYN_ARRAY<POINTS_TO*> *Vec(void) const { return _vec; }
00103   vector<IDTYPE, mempool_allocator<IDTYPE> > *_invalid_ip_alias_classes;
00104 
00105 public:
00106   ALIAS_MANAGER(void);
00107   ~ALIAS_MANAGER(void);
00108 
00109   IDTYPE     Id(const WN *wn) const;
00110   IDTYPE     Preg_id(void) const             { return _preg_id; }
00111   IDTYPE     No_alias_info_id(void) const    { return _no_alias_info_id; }
00112   POINTS_TO  *Pt(IDTYPE id) const            { return (*_vec)[id]; }
00113   ALIAS_CONTEXT Pu_context(void) const       { return _pu_context; }
00114   ALIAS_RULE *Rule(void)   const             { return _rule; }
00115   WN_MAP     Map(void) const                 { return _map; }
00116   WN_MAP     Homing_map(void) const          { return _homing_map; }
00117   inline void       Set_id(WN *wn, IDTYPE id) const;
00118   inline void       Set_pu_context(ALIAS_CONTEXT ct){ _pu_context = ct; }
00119   inline void       Set_context(ALIAS_CONTEXT c);
00120   inline IDTYPE     New_alias_id(void);   
00121   inline POINTS_TO *New_points_to(WN *wn);  // also assign new id
00122 
00123   // Cross-DSO out-of-line versions of member functions required by wopt.so.
00124   IDTYPE     Cross_dso_new_alias_id(void);   
00125   void       Cross_dso_set_id(WN *wn, IDTYPE id) const;
00126 
00127   // setup alias information for EMIT
00128   void              Gen_alias_id(WN *, POINTS_TO *);
00129   void              Gen_alias_id_list(WN *, POINTS_TO_LIST *);
00130   void              Gen_black_box_alias(WN *);
00131   // duplicate the alias id for an entire WN tree for EMIT
00132   void              Dup_tree_alias_id( const WN *old_wn, WN *new_wn );
00133   void              Print( const WN *wn, FILE *fp = TFile ) const;
00134 
00135   void              Forget_alias_class_info(void);
00136   void              Transfer_alias_class_to_alias_manager(const ALIAS_CLASSIFICATION &,
00137                                                                 WN                   *);
00138 
00139   // Support to fix 707179
00140   inline BOOL May_refer_to_alloca_mem(const WN *) const;
00141   BOOL              Safe_to_speculate(const WN *) const;
00142 
00143   void Note_invalid_ip_alias_class(const WN *);
00144   void Erase_ip_alias_class_if_invalid(WN *);
00145 
00146   // support homing
00147   BOOL Homing_load( const WN *load_wn ) const
00148                 { return WN_MAP32_Get(Homing_map(),load_wn); }
00149   void Set_homing_load( WN *load_wn, BOOL b ) const
00150                 { WN_MAP32_Set(Homing_map(),load_wn,b); }
00151 
00152   BOOL Homing_store( const WN *store_wn ) const
00153                 { return WN_MAP32_Get(Homing_map(),store_wn); }
00154   void Set_homing_store( WN *store_wn, BOOL b ) const
00155                 { WN_MAP32_Set(Homing_map(),store_wn,b); }
00156 
00157   ALIAS_RESULT Aliased(WN *wn, const POINTS_TO *pt);
00158   ALIAS_RESULT Aliased(const POINTS_TO *pt, WN *wn);
00159   ALIAS_RESULT Aliased(const POINTS_TO *pt1, const POINTS_TO *pt2);
00160 };
00161 
00162 #endif /* opt_alias_mgr.h include */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines