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 * Module: freq.h 00040 * $Revision: 1.2 $ 00041 * $Date: 02/11/07 23:41:24-00:00 $ 00042 * $Author: fchow@keyresearch.com $ 00043 * $Source: /scratch/mee/2.4-65/kpro64-pending/be/cg/SCCS/s.freq.h $ 00044 * 00045 * Description: 00046 * 00047 * Utilities for determining execution frequencies of BBs and edges. 00048 * 00049 * Utilities: 00050 * 00051 * void FREQ_Compute_BB_Frequencies(void) 00052 * Determine the block and edge frequency for all BBs in the control flow 00053 * graph. This is done using several heuristics to predict the direction 00054 * of conditional branches and/or feedback if available. This routine 00055 * also sets the BB_freq field of each basic block. 00056 * 00057 * void FREQ_Incorporate_Feedback(cosnt WN* entry) 00058 * Incorporate feedback (from the WHIRL) into the CG CFG; entry is the 00059 * entry whirl node of the tree 00060 * 00061 * void FREQ_Print_BB_Note(BB *bb, FILE *file) 00062 * Print a note to 'file' which indicates the block and successor 00063 * edge frequencies for 'bb'. 00064 * 00065 * void FREQ_Region_Initialize(void) 00066 * Must be called at the start of processing for each region. 00067 * 00068 * BOOL FREQ_Frequencies_Computed(void) 00069 * Returns TRUE if block and edge frequencies have been computed; 00070 * i.e. FREQ_Compute_BB_Frequencies was called and -CG:enable_freq 00071 * was TRUE. 00072 * 00073 * BOOL WN_Is_Pointer(WN *wn) 00074 * Returns TRUE if whirl node 'wn' is a pointer. 00075 * 00076 * BOOL FREQ_Match(float f1, float f2) 00077 * Return TRUE if BB_freqs <f1> and <f2> are "close enough" (used in 00078 * sanity checks of frequency info). 00079 * 00080 * BOOL FREQ_Check_Consistency(const char *caller) 00081 * Perform a consistency check over the BBs in the region. 00082 * DevWarn if a problem is found. <caller> is an ascii string 00083 * to identify the caller in error messages. Return TRUE iff 00084 * check detects no errors. 00085 * 00086 * BB_SET *FREQ_Find_Never_BBs(MEM_POOL *pool) 00087 * Return the set of BBs that can be inferred are never executed 00088 * as a result of NEVER frequency hint pragmas. The returned set 00089 * is allocated from <pool>. If there are no NEVER BBs, then 00090 * NULL is returned instead of an empty set. 00091 * 00092 * void FREQ_View_CFG(const char *status) 00093 * Use DaVinci to view a feedback/frequency annotated CFG. 00094 * <status> is an informational string used to label the graph. 00095 * 00096 * BOOL FREQ_Verify(const char *caller) 00097 * Prints the block frequencies and edge probabilites of the 00098 * current region into the trace file. Also prints a "FAIL" 00099 * message to the trace file if a consistency problem is found. 00100 * <caller> is an ascii string to identify the caller. 00101 * Return TRUE iff no errors are detected. 00102 * 00103 * ==================================================================== 00104 * ==================================================================== 00105 */ 00106 00107 #ifndef FREQ_INCLUDED 00108 #define FREQ_INCLUDED 00109 00110 #include "bb_set.h" 00111 00112 extern void FREQ_Compute_BB_Frequencies(void); 00113 00114 extern void FREQ_Print_BB_Note( 00115 BB *bb, 00116 FILE *file 00117 ); 00118 00119 extern void FREQ_Region_Initialize(void); 00120 00121 inline BOOL FREQ_Frequencies_Computed(void) 00122 { 00123 extern BOOL FREQ_freqs_computed; 00124 return FREQ_freqs_computed; 00125 } 00126 00127 extern BOOL WN_Is_Pointer(WN *wn); 00128 00129 inline BOOL FREQ_Match(float f1, float f2) 00130 { 00131 float ratio; 00132 00133 if (f1 == f2) return TRUE; 00134 00135 /* Tolerance is 0.1% of (f1+f2). When (f1+f2) is zero, we'll 00136 * always return FALSE, but that's desirable since negative 00137 * freqs don't make sense. 00138 */ 00139 ratio = (f1-f2)/(f1+f2); 00140 return ratio <= 0.001 && ratio >= -0.001; 00141 } 00142 00143 extern BOOL FREQ_Check_Consistency(const char *caller); 00144 00145 extern BB_SET *FREQ_Find_Never_BBs(MEM_POOL *pool); 00146 00147 extern void FREQ_Incorporate_Feedback(const WN* entry); 00148 00149 extern void FREQ_View_CFG(const char *status); 00150 00151 extern BOOL FREQ_Verify(const char *caller); 00152 00153 #endif /* FREQ_INCLUDED */
1.5.6