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 w2f_driver_INCLUDED 00037 #define w2f_driver_INCLUDED 00038 #ifdef __cplusplus 00039 extern "C" { 00040 #endif 00041 /* ==================================================================== 00042 * ==================================================================== 00043 * 00044 * 00045 * Description: 00046 * 00047 * W2F_Should_Emit_Nested_PUs() 00048 * Returns TRUE when we should translate nested PUs. 00049 * 00050 * W2F_Process_Command_Line() 00051 * Process the command line arguments. Evaluate flags pertaining 00052 * solely to w2f, assuming these are in the phase_argv list, 00053 * ignoring all others (assuming non-w2f options are processed 00054 * and checked for correctness elsewhere). argv[0] is assumed to 00055 * hold the name of the current program invocation ("whirl2f") 00056 * or NULL if there is no such name. Also, set up the file-names 00057 * (W2F_File) such that these are all non-NULL. The naming of 00058 * files is based partially on the command-line options, and 00059 * partially on Src_File_Name and Irb_File_Name. The only 00060 * W2F_File which may be NULL after this call is the W2F_LOC_FILE. 00061 * 00062 * W2F_Init() 00063 * Basic Initialization of W2F, assuming the command-line has 00064 * already been processed and the global symbol-table, string- 00065 * table, and initialization table already have been read in with 00066 * Read_Global_Info(). This initiates all translation modules, 00067 * but opens no output files and does no preliminary translation. 00068 * 00069 * W2F_Push_PU() 00070 * Must be called before translating an expression within 00071 * a PU (i.e. a FUNC_ENTRY). The new symbol table for the 00072 * given PU will be pushed onto the stack. After this call, the 00073 * locally defined symbol names can be accessed by means of the 00074 * W2CF_Symtab_Nameof_() routines. This call 00075 * also specifies the subtree within the body of the pu, which 00076 * we are interested in translating, which *must* exactly match 00077 * the subtree passed in a call to W2F_Translate_Wn() or 00078 * W2F_Translate_Wn_Str(). 00079 * 00080 * W2F_Pop_PU() 00081 * This must be called after a PU is done with, and the symbol 00082 * table-section for the PU will be popped off the whirl2f 00083 * symbol table stack. 00084 * 00085 * W2F_Mark_Loads() 00086 * Inserts positional placeholder for translated ILOAD/LDID. 00087 * 00088 * W2F_Nomark_Loads() 00089 * Regular translation of loads (ILOAD/LDID). This is the default 00090 * mode. 00091 * 00092 * W2F_Set_Prompf_Emission() 00093 * Pass in a mapping from WN nodes to construct identifiers, and 00094 * notify whirl2f to emit its output in a form suitable for ProMPF. 00095 * Call this one time only, before any translation takes place! 00096 * 00097 * W2F_Set_Frequency_Map() 00098 * Pass in a mapping from WN nodes to feedback frequency information. 00099 * Call this for each PU that has such a map. The actual emission 00100 * of this info (in comments) is controlled by the "emit_frequency" 00101 * -FLIST option. 00102 * 00103 * W2F_Get_Transformed_Src_Path() 00104 * Returns the name of the .f file emitted by whirl2f. Must be 00105 * called after W2F_Init(). 00106 * 00107 * W2F_Set_Purple_Emission() 00108 * W2F_Reset_Purple_Emission() 00109 * Instruct the code-emitter to translate WHIRL in a manner 00110 * specific to the needs of purple. Actived by the "Set" 00111 * routine; deactivated by the "Reset" routine. 00112 * 00113 * W2F_Def_ST() 00114 * Appends a definition for the given symbol to the given 00115 * file. The file must be open with write permission. 00116 * 00117 * W2F_Object_Name() 00118 * Returns the name of the given function. 00119 * 00120 * W2F_Translate_Stid_Lhs() 00121 * Given the attributes for an OPR_STID (or similar attributes 00122 * derived from other kinds of nodes, such as an OPR_LDID), put an 00123 * expression suitable as an assignment lhs in the given string 00124 * buffer. 00125 * 00126 * W2F_Translate_Istore_Lhs() 00127 * Same as W2F_Translate_Stid_Lhs(), but based on the attributes 00128 * for an OPR_ISTORE instead of the attributes of an OPR_STID. 00129 * 00130 * W2F_Translate_Wn() 00131 * Translation of an arbitrary WN tree into Fortran, assuming the 00132 * current PU scope has been pushed onto the whirl2f symbol- 00133 * table stack. The output will be appended to the given file. 00134 * If the expression is a FUNC_ENTRY node, then the local symbol 00135 * table will be pushed and popped, and the effect is similar 00136 * to W2F_Outfile_Translate_Pu(). The file must be open with 00137 * write permission. 00138 * 00139 * W2F_Translate_Wn_Str() 00140 * Same as W2F_Translate_Wn(), but the output is put into the 00141 * given string buffer instead of being appended to a file. 00142 * 00143 * W2F_Translate_Purple_Main() 00144 * Given an arbitrary FUNC_ENTRY node, we translate it into a 00145 * purple main program, where the parameters are declared as 00146 * local variables, placeholders are inserted for initialization 00147 * and final checking, and a call is made to the purple region 00148 * routine. 00149 * 00150 * W2F_Fini() 00151 * Finalization of W2F. This will terminate all translation 00152 * modules and free up their state information (such as symol- 00153 * tables, etc). 00154 * 00155 * EXPORTED OUTPUT-FILE INTERFACE 00156 * ------------------------------ 00157 * 00158 * This is the easiest interface for using whirl2f, and it 00159 * maintains output file status and produces a uniform output 00160 * format based on the -FLIST options. There are strict rules 00161 * as to how this interface interacts with the lower-level 00162 * interface described above. 00163 * 00164 * W2F_Outfile_Init() 00165 * Initializes the output-files for whirl2f, based on the 00166 * command-line options. Will call W2F_Init() is this has 00167 * not already been done. Optionally, the file-level 00168 * declarations may be emitted to the generated header file. 00169 * 00170 * W2F_Outfile_Translate_Pu() 00171 * Translates a PU, presupposing W2F_Outfile_Init() has been 00172 * called. The PU will be lowered (for Fortran) and the 00173 * output Fortran code will be appended to the output files. 00174 * 00175 * W2C_Output_Fini() 00176 * Finalizes a W2F translation by closing the output-files, and 00177 * calling W2F_Fini(). Call this before the Irb file is closed! 00178 * 00179 * INTERACTION BETWEEN OUTPUT-FILE AND LOW-LEVEL INTERFACE 00180 * ------------------------------------------------------- 00181 * 00182 * 1) There is no ordering constraint between the Init routines. 00183 * A redundant call to an init routine is simply ignored. 00184 * 00185 * 2) All "Outfile" routines require a W2F_Outfile_Init() call. 00186 * 00187 * 3) All "low-level" routines require a W2F_Init() or a 00188 * W2F_Outfile_Init() call. 00189 * 00190 * 4) A call to W2F_Push_PU() may be followed by a call to 00191 * W2F_Outfile_Translate_Pu(), in which case the scope will 00192 * not be pushed again and will not be popped when 00193 * W2F_Outfile_Translate_Pu() returns. 00194 * 00195 * 5) W2F_Fini() has no effect if W2F_Outfile_Init() was called, 00196 * since finalization must then be done with a call to 00197 * W2F_Output_Fini(). 00198 * 00199 * 6) Initialization may again occur after a finalization for 00200 * a another whirl2f translation. Two whirl2f translation 00201 * tasks cannot be active simultaneously within the same process, 00202 * but the same WHIRL tree may be translated multiple times 00203 * in a given sequential sequence by the same translation 00204 * process. 00205 * 00206 * ==================================================================== 00207 * ==================================================================== 00208 */ 00209 00210 /* Flags set by W2F_Process_Command_Line() */ 00211 /*-----------------------------------------*/ 00212 00213 extern BOOL W2F_Verbose; /* Show translation information */ 00214 extern BOOL W2F_Old_F77; /* Use macros for new intrinsics */ 00215 extern BOOL W2F_Ansi_Format; /* Line-formatting to f77 standard */ 00216 extern BOOL W2F_No_Pragmas; /* Do not emit pragmas */ 00217 extern BOOL W2F_Emit_Prefetch; /* Emit comments for prefetches */ 00218 extern BOOL W2F_Emit_All_Regions;/* Emit cmplr-generated regions */ 00219 extern BOOL W2F_Emit_Linedirs; /* Emit preprocessing line-directives */ 00220 extern BOOL W2F_Emit_Frequency; /* Emit feedback frequency information */ 00221 extern BOOL W2F_Purple_Emission; /* Emitting purple extracted sources */ 00222 extern BOOL W2F_Emit_Pcf; /* Emitting PCF spellings of pragmas */ 00223 extern BOOL W2F_Emit_Omp; /* Emitting OMP spellings of pragmas */ 00224 00225 extern BOOL W2F_OpenAD; /* Special OpenAD mode */ 00226 #define W2F_ACTIVE_TYPE_LEN 28 00227 extern char W2F_activeType[W2F_ACTIVE_TYPE_LEN]; /* active type for OpenAD */ 00228 00229 00230 /* Files */ 00231 /*-------*/ 00232 00233 typedef enum W2F_File_Kind 00234 { 00235 W2F_ORIG_FILE, /* Fortran input file */ 00236 W2F_FTN_FILE, /* Fortran output file */ 00237 W2F_LOC_FILE, /* W2F generated source-to-source location mapping file */ 00238 W2F_NUM_FILES /* Number of elements in this enumeration */ 00239 } W2F_FILE_KIND; 00240 00241 extern FILE *W2F_File[W2F_NUM_FILES]; 00242 00243 00244 /* Exported Functions */ 00245 /*--------------------*/ 00246 00247 /* Note that we also export some utilities from W2CF_symtab.h */ 00248 extern BOOL W2F_Should_Emit_Nested_PUs(void); 00249 extern void W2F_Process_Command_Line(INT phase_argc, char *phase_argv[], 00250 INT argc, char *argv[]); 00251 extern void W2F_Init(void); 00252 extern void W2F_Fini(void); 00253 extern void W2F_Push_PU(WN *pu, WN *body_part_of_interest); 00254 extern void W2F_Pop_PU(void); 00255 00256 extern void W2F_Mark_Loads(void); 00257 extern void W2F_Nomark_Loads(void); 00258 00259 extern void W2F_Set_Prompf_Emission(WN_MAP *construct_map); 00260 extern void W2F_Set_Frequency_Map(WN_MAP frequency_map); 00261 00262 extern const char * W2F_Get_Transformed_Src_Path(void); 00263 00264 extern void W2F_Set_Purple_Emission(void); 00265 extern void W2F_Reset_Purple_Emission(void); 00266 00267 extern void W2F_Def_ST(FILE *outfile, ST *st); 00268 00269 extern const char * W2F_Object_Name(ST *func_st); 00270 00271 extern void W2F_Translate_Stid_Lhs(char *strbuf, 00272 UINT bufsize, 00273 ST *stid_st, 00274 mINT64 stid_ofst, 00275 TY_IDX stid_ty, 00276 TYPE_ID stid_mtype); 00277 extern void W2F_Translate_Istore_Lhs(char *strbuf, 00278 UINT bufsize, 00279 WN *lhs, 00280 mINT64 istore_ofst, 00281 TY_IDX istore_addr_ty, 00282 TYPE_ID istore_mtype); 00283 00284 extern void W2F_Translate_Wn(FILE *outfile, WN *wn); 00285 extern void W2F_Translate_Wn_Str(char *strbuf, UINT bufsize, WN *wn); 00286 00287 extern void 00288 W2F_Translate_Purple_Main(FILE *outfile, WN *pu, const char *region_name); 00289 00290 extern void W2F_Outfile_Init(void); 00291 extern void W2F_Outfile_Translate_Pu(WN *pu); 00292 extern void W2F_Outfile_Fini(void); 00293 00294 extern void W2F_Cleanup(void); 00295 00296 typedef map<TY_IDX, ST_IDX> TyIdxToStIdxMap; 00297 extern TyIdxToStIdxMap tyidx_modidx; 00298 00299 #ifdef __cplusplus 00300 } 00301 #endif 00302 #endif /* w2f_driver_INCLUDED */