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 #ifndef anl_varlist_INCLUDED 00038 #define anl_varlist_INCLUDED 00039 00040 // ============================================================== 00041 // ============================================================== 00042 // 00043 // 00044 // Description: 00045 // 00046 // An object to represent the attributes we accumulate for 00047 // variable references, and an object to represent a set of 00048 // such variables with their attributes (sorted on ST_idx()s). 00049 // 00050 // ============================================================== 00051 // ============================================================== 00052 00053 #include "array_set.h" // For ARRAY_SET 00054 00055 class ANL_FUNC_ENTRY; // Defined in "anl_func_entry.h" 00056 00057 #define ANL_VAR_READ 0x00000001 00058 #define ANL_VAR_WRITTEN 0x00000002 00059 00060 00061 class ANL_VAR 00062 { 00063 private: 00064 ST *_st; 00065 ANL_VAR *_alias; // A circular list of name aliases 00066 UINT32 _status; 00067 00068 public: 00069 00070 // ============== Constructors & Destructors ============== 00071 00072 ANL_VAR(): _st(NULL), _alias(this), _status(0) {} 00073 ANL_VAR(ST *st): _st(st), _alias(this), _status(0) {} 00074 00075 00076 // =================== Inquiries =================== 00077 00078 INT32 Id() const {return (_st==NULL? 0 : ST_st_idx(_st));} 00079 BOOL operator==(const ANL_VAR &v) const {return Id() == v.Id();} 00080 BOOL operator!=(const ANL_VAR &v) const {return Id() != v.Id();} 00081 BOOL operator<(const ANL_VAR &v) const {return Id() < v.Id();} 00082 BOOL operator<=(const ANL_VAR &v) const {return Id() <= v.Id();} 00083 BOOL operator>(const ANL_VAR &v) const {return Id() > v.Id();} 00084 BOOL operator>=(const ANL_VAR &v) const {return Id() >= v.Id();} 00085 00086 BOOL Is_Read() {return ((_status & ANL_VAR_READ) != 0);} 00087 BOOL Is_Written() {return ((_status & ANL_VAR_WRITTEN) != 0);} 00088 00089 00090 // =================== Modification ================== 00091 00092 ANL_VAR &operator=(const ANL_VAR &v) 00093 { 00094 _st = v._st; 00095 _status = v._status; 00096 return *this; 00097 } 00098 00099 void Set_Name_Alias(ANL_VAR *var); 00100 00101 void Set_Read() {_status = (_status | ANL_VAR_READ);} 00102 void Set_Written() {_status = (_status | ANL_VAR_WRITTEN);} 00103 00104 void Reset_References(); // For this and all aliases 00105 00106 00107 // ================ Printing Variable Info =============== 00108 00109 void Write(ANL_CBUF *cbuf, ANL_FUNC_ENTRY *_func_entry); // this and aliases 00110 00111 }; // class ANL_VAR 00112 00113 00114 class ANL_VARLIST 00115 { 00116 private: 00117 00118 ARRAY_SET<ANL_VAR*> _vlist; // List of ANL_VARs sorted by ST_idx()s. 00119 ANL_FUNC_ENTRY *_func_entry; 00120 MEM_POOL *_pool; 00121 00122 mUINT32 _Binary_Search(INT32 id, mUINT32 from, mUINT32 till); 00123 00124 UINT32 _Get_Io_Item_Lda_Access_Status(WN *io_item); 00125 00126 UINT32 _Get_Lda_Access_Status(WN *lda); 00127 00128 public: 00129 00130 // ============== Constructors & Destructors ============== 00131 00132 ANL_VARLIST(MEM_POOL *pool, ANL_FUNC_ENTRY *func_entry): 00133 _vlist(pool), 00134 _pool(pool), 00135 _func_entry(func_entry) 00136 {} 00137 00138 ~ANL_VARLIST() 00139 { 00140 for (INT i = 0; i < _vlist.Size(); i++) 00141 CXX_DELETE(_vlist.Indexed_Get(i), _pool); 00142 } 00143 00144 00145 // =================== Search =================== 00146 00147 ANL_VAR *Find(ST *st); // NULL if not found 00148 ANL_VAR *Find_or_Insert(ST *st); // Never NULL 00149 00150 00151 // =================== Initialization =================== 00152 00153 void Insert_Var_Refs(WN *subtree); 00154 00155 00156 // ============== Printing Variable-list Info ============= 00157 00158 void Write(ANL_CBUF *cbuf, INT64 construct_id); 00159 00160 00161 }; // class ANL_VARLIST 00162 00163 #endif /* anl_varlist_INCLUDED */