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 #ifndef tracing_INCLUDED 00037 #define tracing_INCLUDED 00038 00039 //#ifndef defs_INCLUDED 00041 // * seems it must be so. 00042 // */ 00043 //#define NO_MEM_POOL_WORKAROUND 00044 //#include "workaround.h" 00046 //#endif 00047 00048 #ifdef __cplusplus 00049 extern "C" { 00050 #endif 00051 00052 /* ==================================================================== 00053 * ==================================================================== 00054 * 00055 * Module: tracing.h 00056 * $Revision: 1.2 $ 00057 * $Date: 2005/12/30 03:04:50 $ 00058 * $Author: weitang $ 00059 * $Source: /depot/CVSROOT/javi/src/sw/cmplr/common/util/tracing.h,v $ 00060 * 00061 * Revision history: 00062 * 08-Sep-89 - Original Version 00063 * 24-Jan-91 - Copied for TP/Muse 00064 * 22-May-91 - Integrated additional Josie functionality 00065 * 00066 * Description: 00067 * 00068 * External interface for tracing support in the Muse compilers and 00069 * associated tools. The basic methodology assumed is the use of 00070 * fprintf to a trace file (which may be, and defaults to, stdout). 00071 * The support provided by the tracing package is primarily managing 00072 * the trace file and flags controlling the traces. 00073 * 00074 * ==================================================================== 00075 * ==================================================================== 00076 */ 00077 00078 00079 #ifdef _KEEP_RCS_ID 00080 static char *tracing_rcs_id = "$Source: /depot/CVSROOT/javi/src/sw/cmplr/common/util/tracing.h,v $ $Revision: 1.2 $"; 00081 #endif /* _KEEP_RCS_ID */ 00082 00083 /* Is_Trace */ 00084 #ifndef Is_Trace 00085 #ifdef Is_True_On 00086 #define Is_Trace(Cond, Parmlist) { if (Cond) fprintf Parmlist ; } 00087 #define Is_Trace_cmd(Cond, Cmd) { if (Cond) Cmd ; } 00088 #else 00089 #define Is_Trace(Cond, Parmlist) ((void) 1) 00090 #define Is_Trace_cmd(Cond, Cmd) ((void) 1) 00091 #endif 00092 #endif 00093 00094 /* The following strings are useful in creating trace messages: */ 00095 #ifndef SBar 00096 extern char *SBar; /* Single-dash bar w/NL, full page width */ 00097 #endif 00098 #ifndef DBar 00099 extern char *DBar; /* Double-dash bar w/NL, full page width */ 00100 #endif 00101 extern char *Sharps; /* Sharps w/NL, full page width */ 00102 00103 00104 /* ==================================================================== 00105 * 00106 * Trace Flag Literals 00107 * 00108 * This package supports several kinds of trace conditions, to allow 00109 * the programmer a great deal of control over the tracing which occurs 00110 * at runtime. (Otherwise, good tracing would be discouraged by the 00111 * sheer volume which would result, or by the difficulty of setting it 00112 * up.) The trace flag kinds supported are: 00113 * 00114 * 1) INFO flags control general information about a compilation, 00115 * e.g. timing, object code statistics, or failure tracing. 00116 * They are represented by mask bits in a single word. 00117 * 00118 * 2) DEBUG flags control options which affect the execution of the 00119 * compiler for debugging purposes, e.g. to perform extra checks 00120 * or to try alternate algorithms. They are also represented by 00121 * a word of mask bits. 00122 * 00123 * 3) IR flags control the tracing of the current IR state after 00124 * individual compiler phases. They are represented by the phase 00125 * number to which they apply. 00126 * 00127 * 4) SYMTAB flags control the tracing of the current symbol table 00128 * state after individual compiler phases. They are represented 00129 * by the phase number as well. 00130 * 00131 * 5) TN flags control the tracing of the current set of TNs after 00132 * individual compiler phases. They are represented by the phase 00133 * number as well. 00134 * 00135 * 6) Phase-specific flags control the tracing in individual compiler 00136 * components. Each such unit has available a word of mask bits 00137 * on which to base its tracing options, represented by the phase 00138 * number and mask. Note that the phase numbers used for this 00139 * purpose are the same as are used for IR and SYMTAB traces. 00140 * 00141 * ==================================================================== 00142 */ 00143 00144 /* Negative integers represent the INFO, DEBUG, IR, and SYMTAB traces, 00145 * as well as miscellaneous trace options: 00146 */ 00147 #define TKIND_INFO -1 /* Specify an information option */ 00148 #define TKIND_DEBUG -2 /* Specify a debug option */ 00149 #define TKIND_IR -3 /* Trace IR for the given pass */ 00150 #define TKIND_SYMTAB -4 /* Trace symbol table for given pass */ 00151 #define TKIND_TN -5 /* Trace TNs for given pass */ 00152 #define TKIND_BB -6 /* Specify a BB number for tracing */ 00153 #define TKIND_XPHASE -7 /* Specify final execution phase */ 00154 #define TKIND_CTRL -8 /* Specify a control option */ 00155 #define TKIND_ALLOC -9 /* Trace memory allocation */ 00156 #define TKIND_MIN -10 /* Smallest valid function number */ 00157 00158 /* Several predefined masks for TKIND_INFO cases: */ 00159 #define TINFO_TIME 1 /* Timing/resource information */ 00160 #define TINFO_CTIME 2 /* Compilation-only timing information */ 00161 #define TINFO_STATS 8 /* Code size statistics */ 00162 #define TINFO_SOURCE 32 /* Source line printing alongside IR dumps */ 00163 #define TINFO_TFLAGS 64 /* Print available trace options */ 00164 #define TINFO_PREFIXDUMP 128 /* Dump WHIRL trees in prefix order */ 00165 00166 /* Positive integers represent phase numbers for per-phase traces: 00167 * WARNING: If you change this list (adding or deleting entries), you 00168 * must change the Phases table in tracing.c. 00169 */ 00170 #define TP_MIN 1 /* Smallest valid phase number */ 00171 00172 /* Miscellaneous "phases": */ 00173 /* note: for TP_PTRACE[1|2]_flags, see below */ 00174 #define TP_PTRACE1 1 /* Performance tracing */ 00175 #define TP_PTRACE2 2 /* Performance tracing */ 00176 #define TP_MISC 3 /* Miscellaneous */ 00177 00178 /* Front end phases: */ 00179 #define TP_SEMANTICS 8 /* Semantic analyzer */ 00180 #define TP_IRB 10 /* IR (WHIRL) builder */ 00181 00182 /* Intermediate utility phases: */ 00183 #define TP_IR_READ 11 /* IR (WHIRL) reader/writer */ 00184 #define TP_WHIRL2FC 12 /* WHIRL to Fortran/C */ 00185 #define TP_WHIRLSIMP 13 /* WHIRL simplifier */ 00186 #define TP_REGION 14 /* REGION related stuff */ 00187 #define TP_ORI 15 /* Olimit Region Insertion phase */ 00188 #define TP_FEEDBACK 16 /* Decorating WHIRL/CFG with feedback */ 00189 00190 /* IPA/inlining phases: */ 00191 #define TP_INLINE 17 /* Inliner */ 00192 #define TP_IPL 18 /* IPA local (summary) phase */ 00193 #define TP_IPA 19 /* IPA main analysis phase */ 00194 #define TP_IPO 20 /* IPA main optimization phase */ 00195 #define TP_IPM 21 /* IPA miscellaneous */ 00196 00197 /* Global optimizer phases: */ 00198 #define TP_ALIAS 24 /* Alias/mod/ref analysis */ 00199 #define TP_WOPT1 25 /* Global optimization */ 00200 #define TP_WOPT2 26 /* More global optimization */ 00201 #define TP_WOPT3 27 /* Even more global optimization */ 00202 #define TP_GLOBOPT TP_WOPT1 00203 00204 /* Loop nest optimizer phases: */ 00205 #define TP_VECDD 30 /* Vector data dependency analysis */ 00206 #define TP_LNOPT 31 /* Loop Nest Optimization */ 00207 #define TP_LNOPT2 32 /* More Loop Nest Optimization */ 00208 #define TP_LNOPT3 33 /* Even more Loop Nest Optimization */ 00209 00210 #define TP_VHO_LOWER 36 /* VHO lowering */ 00211 #define TP_LOWER 37 /* WHIRL lowering */ 00212 #define TP_LOWER90 38 /* F90 Lowering */ 00213 00214 /* Code generator phases: */ 00215 #define TP_DATALAYOUT 39 /* Data layout */ 00216 #define TP_CG 40 /* Code generator miscellaneous */ 00217 #define TP_CGEXP 41 /* Code generator expansion */ 00218 #define TP_LOCALIZE 42 /* Localize TNs */ 00219 #define TP_FIND_GLOB 43 /* Find global register live ranges */ 00220 #define TP_EBO 44 /* Extended Block Optimizer */ 00221 #define TP_CGPREP 45 /* Code generator scheduling prep */ 00222 #define TP_FLOWOPT 47 /* Control flow optimization */ 00223 #define TP_GCM 48 /* Global code motion */ 00224 #define TP_CGLOOP 49 /* Code generator loop optimization */ 00225 #define TP_SWPIPE 50 /* Software pipelining */ 00226 #define TP_SRA 51 /* SWP register allocation */ 00227 #define TP_SCHED 52 /* Scheduling */ 00228 #define TP_GRA 53 /* Global register allocation */ 00229 #define TP_ALLOC 54 /* Local register allocation */ 00230 #define TP_PSGCM 55 /* Post Schedule Global code motion */ 00231 #define TP_EMIT 56 /* Code emission */ 00232 #define TP_HBF 57 /* Hyperblock formation */ 00233 #define TP_PQS 58 /* Predicate query system */ 00234 #define TP_THR 59 /* Tree-Height reduction */ 00235 00236 #define TP_TEMP 60 /* Temporary use */ 00237 #define TP_A_REGION 61 /* REGION formation */ 00238 #define TP_A_GSCHED 62 /* (ORC) global instruction scheduling */ 00239 #define TP_A_LSCHED 63 /* (ORC) local instruction */ 00240 #define TP_IPISR 64 /* Interprocedural interrupt service routine RA*/ 00241 00242 /* WARNING: TP_LAST must be at least as large as the largest phase 00243 * number above, and TP_COUNT must be at least one larger. 00244 */ 00245 #define TP_LAST 64 /* Largest valid phase number */ 00246 #define TP_COUNT 65 /* Number of valid phase numbers */ 00247 00248 /* Extract the phase number from a trace option: */ 00249 extern INT32 Get_Trace_Phase_Number ( char **cp, char *arg ); 00250 00251 /* List the trace phases to TFile: */ 00252 extern void List_Phase_Numbers ( void ); 00253 00254 /* ==================================================================== 00255 * TP_PTRACE[1|2]_flags - reserved PTRACE flags 00256 * ==================================================================== 00257 */ 00258 #define TP_PTRACE1_ALL 0x001 /* get all performance tracing */ 00259 #define TP_PTRACE1_INL 0x002 /* get INLiner performance tracing */ 00260 #define TP_PTRACE1_IPA 0x004 /* get IPA performance tracing */ 00261 #define TP_PTRACE1_LNO 0x008 /* get LNO performance tracing */ 00262 #define TP_PTRACE1_OPT 0x010 /* get OPT performance tracing */ 00263 #define TP_PTRACE1_CG 0x020 /* get CG performance tracing */ 00264 #define TP_PTRACE1_IPALNO 0x040 /* get IPA performance tracing */ 00265 #define TP_PTRACE1_IPA_CPROP 0x080 /* get IPA cprop tracing */ 00266 #define TP_PTRACE1_CALLINFO 0x100 /* get LNO call info tracing */ 00267 #define TP_PTRACE1_PARALLEL 0x200 /* get LNO parallel tracing */ 00268 #define TP_PTRACE1_NOHDR 0x400 /* suppress printing tlog header */ 00269 00270 00271 /* ==================================================================== 00272 * 00273 * Trace Flag Management 00274 * 00275 * ==================================================================== 00276 */ 00277 00278 /* Set a trace flag specified by: 00279 * Function Argument Resulting action 00280 * -------- -------- ---------------- 00281 * TKIND_INFO flag mask Enable masked traces 00282 * TKIND_DEBUG flag mask Enable masked options 00283 * TKIND_IR phase number Enable IR trace for phase 00284 * TKIND_SYMTAB phase number Enable SYMTAB trace for phase 00285 * TKIND_TN phase number Enable TN trace for phase 00286 * TKIND_BB BB number Restrict tracing to BB 00287 * TKIND_XPHASE phase number Stop execution after phase 00288 * TKIND_CNTL control number Set control option identified 00289 * TKIND_ALLOC phase number Enable mem allocation traces 00290 * phase number flag mask Enable masked per-phase traces 00291 */ 00292 extern void Set_Trace ( INT func, INT arg ); 00293 00294 /* Note a PU to be traced: */ 00295 extern void Set_Trace_Pu ( char *name ); 00296 extern void Set_Trace_Pu_Number ( INT number ); 00297 00298 /* Set current PU for pu tracing */ 00299 extern void Set_Current_PU_For_Trace ( char *name, INT number ); 00300 00301 /* Tracing for a single region */ 00302 extern void Set_Trace_Region_Number ( INT number ); 00303 extern void Set_Current_Region_For_Trace ( INT number ); 00304 00305 /* Determine whether a given trace option is enabled. 00306 */ 00307 extern BOOL Get_Trace ( INT func, INT arg ); 00308 00309 /* Determine whether a given BB (pass in it's BB_id()) is enabled for 00310 * tracing, independent of other trace options: 00311 */ 00312 extern BOOL Get_BB_Trace ( INT bb_id ); 00313 00314 /* Determine whether execution should stop after this phase: */ 00315 extern BOOL Stop_Execution ( INT phase ); 00316 00317 00318 /* ==================================================================== 00319 * 00320 * Trace File Management 00321 * 00322 * ==================================================================== 00323 */ 00324 00325 /* The trace file descriptor, to be used in fprintf tracing: */ 00326 extern FILE *Get_Trace_File_Desc ( void ); 00327 00328 /* By default, traces are sent to stdout, which of course is open on 00329 * startup. If tracing is to be directed to another file (recommended 00330 * for permanence), this routine should be called before any tracing is 00331 * done. It will close the previous trace file (if not stdout) and 00332 * open the new one, setting TFile to the new file descriptor. 00333 */ 00334 extern void Set_Trace_File ( char *filename ); 00335 00336 extern void Set_Trace_File_internal ( FILE *); 00337 00338 #define TFile Get_Trace_File_Desc() 00339 00340 /* Indent the given file according to the current execution stack 00341 * depth. This routine is useful for tracing recursive algorithms. 00342 */ 00343 extern void Nest_Indent ( FILE *file ); 00344 00345 extern INT Get_Current_Phase_Number( void ); 00346 extern void Set_Current_Phase_Number(INT); 00347 00348 #ifdef __cplusplus 00349 } 00350 #endif 00351 #endif /* tracing_INCLUDED */
1.5.6