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