00001 /* 00002 * Copyright 2004, 2005, 2006 PathScale, Inc. All Rights Reserved. 00003 */ 00004 00005 /* 00006 00007 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00008 00009 This program is free software; you can redistribute it and/or modify it 00010 under the terms of version 2 of the GNU General Public License as 00011 published by the Free Software Foundation. 00012 00013 This program is distributed in the hope that it would be useful, but 00014 WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00016 00017 Further, this software is distributed without any warranty that it is 00018 free of the rightful claim of any third person regarding infringement 00019 or the like. Any license provided herein, whether implied or 00020 otherwise, applies only to this software file. Patent licenses, if 00021 any, provided herein do not apply to combinations of this program with 00022 other software, or any other product whatsoever. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with this program; if not, write the Free Software Foundation, Inc., 59 00026 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00027 00028 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00029 Mountain View, CA 94043, or: 00030 00031 http://www.sgi.com 00032 00033 For further information regarding this notice, see: 00034 00035 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00036 00037 */ 00038 00039 00041 // 00042 // Find interesting regions of the control flow graph that will 00043 // make good candidates for forming hyperblocks. Loops bodies, 00044 // of course, are always good candidates. We also attempt to 00045 // find other control flow structures that will also make good 00046 // candidates (e.g. if-then-else constructs). 00047 // 00048 // When choosing candidate regions, we must make sure that we 00049 // do not present too large of a graph for consideration by the 00050 // block selection algorithm. The reason for this is two fold. 00051 // First, we do not wish to form a region that is so large that 00052 // we cannot possibly if convert a large portion of it profitably. 00053 // Second, compile time is an issue for the path enumeration algorithm, 00054 // so we must keep the number of nodes that it sees to a reasonably 00055 // small number. See the osprey design web page for hyperblocks for 00056 // more details on this algorithm. 00057 // 00058 // Exported types: 00059 // 00060 // HB_CAND_TREE 00061 // candidate - hyperblock structure representing the candidate region. 00062 // parent - ancestor in tree, i.e. immediately containing region. 00063 // kids - list of fully contained candidate regions. 00064 // 00065 // External routines: 00066 // 00067 // HB_CAND_TREE_Alloc(MEM_POOL* pool) 00068 // allocate and initialize a new structure 00069 // 00070 // inline HB* HB_CAND_TREE_Candidate(HB_CAND_TREE* hct) 00071 // inline void HB_CAND_TREE_Candidate_Set(HB_CAND_TREE* hct, 00072 // HB* candidate) 00073 // inline HB_CAND_TREE* HB_CAND_TREE_Parent(HB_CAND_TREE* hct) 00074 // inline void HB_CAND_TREE_Parent_Set(HB_CAND_TREE* hct, 00075 // HB_CAND_TREE* parent) 00076 // inline list<HB_CAND_TREE*> HB_CAND_TREE_Kids(HB_CAND_TREE* hct) 00077 // Routines for accessing/setting members. 00078 // 00079 // void HB_Identify_Hammock_Candidates(list<HB_CAND_TREE*> candidates, 00080 // BB_MAP hct_entry_map); 00081 // Identifies "hammock" regions from the control flow graph. These 00082 // can be nested. 00083 // 00084 // void HB_Identify_General_Candidates(list<HB_CAND_TREE*> candidates, 00085 // BB_MAP hct_entry_map, 00086 // INT pass) 00087 // Identifies high priority connected regions in the control flow 00088 // graph that are single entry, multiple exit that are good candidates 00089 // for hyperblock formation. 00090 // 00091 // void HB_Identify_Candidates_Init() 00092 // Initialize data required by candidate region identification 00093 // algorithms. 00094 // 00095 // INT HB_CAND_TREE_Flags(HB_CAND_TREE* hct) 00096 // void HB_CAND_TREE_Flags_Reset_All(HB_CAND_TREE* hct) 00097 // BOOL HB_CAND_TREE_Check_Flag(HB_CAND_TREE* hct, INT flag) 00098 // void HB_CAND_TREE_Reset_Flag(HB_CAND_TREE* hct, INT flag) 00099 // Routines to maniplate tree node flags. 00100 // 00102 00103 #ifndef HB_ID_CANDIDATES_H_INCLUDED 00104 #define HB_ID_CANDIDATES_H_INCLUDED 00105 00106 #include <list> 00107 #include "cxx_memory.h" 00108 00109 struct HB_CAND_TREE { 00110 HB* candidate; 00111 HB_CAND_TREE* parent; 00112 std::list<HB_CAND_TREE*> kids; 00113 INT flags; 00114 }; 00115 00116 // 00117 // Flags (properties) 00118 // 00119 #define HCT_FULLY_CONVERTED 0x00000001 00120 #define HCT_SINGLE_BLOCK 0x00000002 00121 #define HCT_SHARED_ENTRY 0x00000004 00122 #define HCT_SHARED_EXIT 0x00000008 00123 #define HCT_UNPROCESSED 0x00000010 00124 #define HCT_ERASE 0x00000020 00125 #define HCT_GENERAL 0x00000040 00126 00127 // Flags (miscellaneous) 00128 #define HCT_VISITED 0x00000080 00129 #define HCT_CVISITED 0x00000100 00130 00131 00133 inline HB* 00134 HB_CAND_TREE_Candidate(HB_CAND_TREE* hct) 00136 // See interface description. 00138 { 00139 return hct->candidate; 00140 } 00141 00143 inline void 00144 HB_CAND_TREE_Candidate_Set(HB_CAND_TREE* hct, HB* candidate) 00146 // See interface description. 00148 { 00149 hct->candidate = candidate; 00150 } 00151 00153 inline HB_CAND_TREE* 00154 HB_CAND_TREE_Parent(HB_CAND_TREE* hct) 00156 // See interface description. 00158 { 00159 return hct->parent; 00160 } 00161 00163 inline void 00164 HB_CAND_TREE_Parent_Set(HB_CAND_TREE* hct, HB_CAND_TREE* parent) 00166 // See interface description. 00168 { 00169 hct->parent = parent; 00170 } 00171 00173 inline std::list<HB_CAND_TREE*>& 00174 HB_CAND_TREE_Kids(HB_CAND_TREE* hct) 00176 // See interface description. 00178 { 00179 return hct->kids; 00180 } 00181 00183 inline INT HB_CAND_TREE_Flags(HB_CAND_TREE* hct) 00185 // See interface description. 00187 { 00188 return hct->flags; 00189 } 00190 00192 inline void HB_CAND_TREE_Flags_Reset_All(HB_CAND_TREE* hct) 00194 // See interface description. 00196 { 00197 hct->flags = 0; 00198 } 00199 00201 inline BOOL HB_CAND_TREE_Check_Flag(HB_CAND_TREE* hct, INT flag) 00203 // See interface description. 00205 { 00206 return hct->flags & flag; 00207 } 00208 00210 inline void HB_CAND_TREE_Reset_Flag(HB_CAND_TREE* hct, INT flag) 00212 // See interface description. 00214 { 00215 hct->flags &= ~flag; 00216 } 00217 00219 inline void HB_CAND_TREE_Set_Flag(HB_CAND_TREE* hct, INT flag) 00221 // See interface description. 00223 { 00224 hct->flags |= flag; 00225 } 00226 00227 inline HB_CAND_TREE* HB_CAND_TREE_Alloc(MEM_POOL* pool) 00229 // See interface description. 00231 { 00232 HB_CAND_TREE* hct = CXX_NEW(HB_CAND_TREE, pool); 00233 HB_CAND_TREE_Candidate_Set(hct, NULL); 00234 HB_CAND_TREE_Parent_Set(hct, NULL); 00235 HB_CAND_TREE_Flags_Reset_All(hct); 00236 return hct; 00237 } 00238 00239 extern void HB_Identify_Hammock_Candidates(std::list<HB_CAND_TREE*>& candidates, 00240 BB_MAP hct_entry_map); 00241 extern void HB_Identify_General_Candidates(std::list<HB_CAND_TREE*>& candidates, 00242 BB_MAP hct_entry_map, 00243 INT pass); 00244 extern void HB_Identify_Candidates_Init(); 00245 extern BOOL Check_BB_For_HB_Suitability(BB* bb, BB* bb_entry); 00246 extern BOOL Check_HB_For_PQS_Suitability(BB_SET *selected_hb, BB *entry); 00247 00248 #endif 00249 00250 00251
1.5.6