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