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 w2c_driver_INCLUDED 00037 #define w2c_driver_INCLUDED 00038 extern "C" { 00039 /* ==================================================================== 00040 * ==================================================================== 00041 * 00042 * 00043 * Description: 00044 * 00045 * W2C_Should_Emit_Nested_PUs() 00046 * Returns TRUE when we should translate nested PUs. 00047 * 00048 * W2C_Process_Command_Line() 00049 * Process the command line arguments. Evaluate flags pertaining 00050 * solely to w2c, assuming these are in the phase_argv list, 00051 * ignoring all others (assuming non-w2c options are processed 00052 * and checked for correctness elsewhere). argv[0] is assumed to 00053 * hold the name of the current program invocation ("whirl2c") 00054 * or NULL if there is no such name. Also, set up the file-names 00055 * (W2C_File) such that these are all non-NULL. The naming of 00056 * files is based partially on the command-line options, and 00057 * partially on Src_File_Name and Irb_File_Name. The only 00058 * W2C_File which may be NULL after this call is the W2C_LOC_FILE. 00059 * 00060 * W2C_Init() 00061 * Basic Initialization of W2C, assuming the command-line has 00062 * already been processed and the global symbol-table, string- 00063 * table, and initialization table already have been read in with 00064 * Read_Global_Info(). This initiates all translation modules, 00065 * but opens no output files and does no preliminary translation. 00066 * 00067 * W2C_Push_PU() 00068 * Must be called before translating an expression within 00069 * a PU (i.e. a FUNC_ENTRY). The new symbol table for the 00070 * given PU will be pushed onto the stack. After this call, the 00071 * locally defined symbol names can be accessed by means of the 00072 * W2CF_Symtab_Nameof_() routines. Note that any lowering of 00073 * Fortran intrinsics and IO statements must already have 00074 * occurred in the context that calls this routine. 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 W2C_Translate_Wn() or 00078 * W2C_Translate_Wn_Str(). 00079 * 00080 * W2C_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 whirl2c 00083 * symbol table stack. 00084 * 00085 * W2C_Mark_Loads() 00086 * Inserts positional placeholder for translated ILOAD/LDID. 00087 * 00088 * W2C_Nomark_Loads() 00089 * Regular translation of loads (ILOAD/LDID). This is the default 00090 * mode. 00091 * 00092 * W2C_Set_Prompf_Emission() 00093 * Pass in a mapping from WN nodes to construct identifiers, and 00094 * notify whirl2c to emit its output in a form suitable for ProMPF. 00095 * Call this one time only, before any translation takes place! 00096 * 00097 * W2C_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 * -CLIST option. 00102 * 00103 * W2C_Get_Transformed_Src_Path() 00104 * Returns the name of the .c file emitted by whirl2c. Must be 00105 * called after W2C_Init(). 00106 * 00107 * W2C_Set_Purple_Emission() 00108 * W2C_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 * W2C_Translate_Global_Types() 00114 * Translate all structured types declared at file-level, such 00115 * that multiple redeclarations of these will not occcur for 00116 * definitions based on these types in local scopes. At most 00117 * one call to this routine should be made between Init and Fini. 00118 * 00119 * W2C_Translate_Global_Defs() 00120 * Translate the file-level definitions based on references 00121 * encountered thus far. All file-level variables and functions 00122 * referenced thus far will be declared. At most one call to 00123 * this routine should be made between Init and Fini. 00124 * 00125 * W2C_Object_Name() 00126 * Returns the name of the given ST. 00127 * 00128 * W2C_Translate_Stid_Lhs() 00129 * Given the attributes for an OPR_STID (or similar attributes 00130 * derived from other kinds of nodes, such as an OPR_LDID), put an 00131 * expression suitable as an assignment lhs in the given string 00132 * buffer. 00133 * 00134 * W2C_Translate_Istore_Lhs() 00135 * Same as W2C_Translate_Stid_Lhs(), but based on the attributes 00136 * for an OPR_ISTORE instead of the attributes of an OPR_STID. 00137 * 00138 * W2C_Translate_Wn() 00139 * Translation of an arbitrary WN tree into C, assuming the 00140 * current PU scope has been pushed onto the whirl2c symbol- 00141 * table stack. The output will be appended to the given file. 00142 * If the expression is a FUNC_ENTRY node, then the local symbol 00143 * table will be pushed and popped, and the effect is similar 00144 * to W2C_Outfile_Translate_Pu(). The file must be open with 00145 * write permission. 00146 * 00147 * W2C_Translate_Wn_Str() 00148 * Same as W2C_Translate_Wn(), but the output is put into the 00149 * given string buffer instead of being appended to a file. 00150 * 00151 * W2C_Translate_Purple_Main() 00152 * Given an arbitrary FUNC_ENTRY node, we translate it into a 00153 * purple main program, where the parameters are declared as 00154 * local variables, placeholders are inserted for initialization 00155 * and final checking, and a call is made to the purple region 00156 * routine. 00157 * 00158 * W2C_Fini() 00159 * Finalization of W2C. This will terminate all translation 00160 * modules and free up their state information (such as symol- 00161 * tables, etc). 00162 * 00163 * EXPORTED OUTPUT-FILE INTERFACE 00164 * ------------------------------ 00165 * 00166 * This is the easiest interface for using whirl2c, and it 00167 * maintains output file status and produces a uniform output 00168 * format based on the -CLIST options. There are strict rules 00169 * as to how this interface interacts with the lower-level 00170 * interface described above. 00171 * 00172 * W2C_Outfile_Init() 00173 * Initializes the output-files for whirl2c, based on the 00174 * command-line options. Will call W2C_Init() is this has 00175 * not already been done. Optionally, the file-level 00176 * declarations may be emitted to the generated header file. 00177 * 00178 * W2C_Outfile_Translate_Pu() 00179 * Translates a PU, presupposing W2C_Outfile_Init() has been 00180 * called. The PU will be lowered (for Fortran) and the 00181 * output C code will be appended to the output files. 00182 * 00183 * W2C_Output_Fini() 00184 * Finalizes a W2C translation by closing the output-files, and 00185 * calling W2C_Fini(). Optionally, this may cause common blocks 00186 * (for Fortran-to-C translation) to be appended to the generated 00187 * header-file. Call this before the Irb file is closed! 00188 * 00189 * INTERACTION BETWEEN OUTPUT-FILE AND LOW-LEVEL INTERFACE 00190 * ------------------------------------------------------- 00191 * 00192 * 1) There is no ordering constraint between the Init routines. 00193 * A redundant call to an init routine is simply ignored. 00194 * 00195 * 2) All "Outfile" routines require a W2C_Outfile_Init() call. 00196 * 00197 * 3) All "low-level" routines require a W2C_Init() or a 00198 * W2C_Outfile_Init() call. 00199 * 00200 * 4) A call to W2C_Push_PU() may be followed by a call to 00201 * W2C_Outfile_Translate_Pu(), in which case the scope will 00202 * not be pushed again and will not be popped before 00203 * W2C_Outfile_Translate_Pu() returns. However, this is 00204 * only valid when the push is with the intent to translate 00205 * the complete function body! 00206 * 00207 * 5) W2C_Fini() has no effect if W2C_Outfile_Init() was called, 00208 * since finalization must then be done with a call to 00209 * W2C_Output_Fini(). 00210 * 00211 * 6) Initialization may again occur after a finalization for 00212 * a second whirl2c translation. Two whirl2c translation 00213 * tasks cannot be active simultaneously within the same process, 00214 * but the same WHIRL tree may be translated multiple times 00215 * in a given sequential sequence by the same translation 00216 * process. 00217 * 00218 * ==================================================================== 00219 * ==================================================================== 00220 */ 00221 00222 /* Flags set by W2C_Process_Command_Line() */ 00223 /*-----------------------------------------*/ 00224 00225 extern BOOL W2C_Verbose; /* Show translation information */ 00226 extern BOOL W2C_No_Pragmas; /* Do not emit pragmas */ 00227 extern BOOL W2C_Emit_Adims; /* Emit comments for array dimensions */ 00228 extern BOOL W2C_Emit_Prefetch; /* Emit comments for prefetches */ 00229 extern BOOL W2C_Emit_All_Regions;/* Emit cmplr-generated regions */ 00230 extern BOOL W2C_Emit_Linedirs; /* Emit preprocessing line-directives */ 00231 extern BOOL W2C_Emit_Frequency; /* Emit feedback frequency information */ 00232 extern BOOL W2C_Emit_Cgtag; /* Emit codegen tags for loop */ 00233 extern BOOL W2C_Lower_Fortran; /* Lower Fortran intrinsics and io */ 00234 extern BOOL W2F_Emit_Omp; /* Force OMP pragmas wherever possible */ 00235 00236 00237 /* External data set through the API or otherwise */ 00238 /*------------------------------------------------*/ 00239 00240 extern BOOL W2C_Only_Mark_Loads; /* Only mark, do not xlate loads */ 00241 extern BOOL W2C_Purple_Emission; /* Emitting purple extracted srcs */ 00242 extern BOOL W2C_Prompf_Emission; /* Emitting prompf xformed sources */ 00243 extern const WN_MAP *W2C_Construct_Map; /* Construct id mapping for prompf */ 00244 extern WN_MAP W2C_Frequency_Map; /* Frequency mapping */ 00245 extern BOOL W2C_Cplus_Initializer;/* Whether to call C++ init */ 00246 00247 00248 /* Files */ 00249 /*-------*/ 00250 00251 typedef enum W2C_File_Kind 00252 { 00253 W2C_ORIG_FILE, /* Original source file (input file) */ 00254 W2C_DOTH_FILE, /* W2C generated .h file */ 00255 W2C_DOTC_FILE, /* W2C generated .c file */ 00256 W2C_LOC_FILE, /* W2C generated source-to-source location mapping file */ 00257 W2C_DATA_FILE, /* Initailization file for shared and TLD variables */ 00258 W2C_NUM_FILES /* Number of elements in this enumeration */ 00259 } W2C_FILE_KIND; 00260 00261 extern FILE *W2C_File[W2C_NUM_FILES]; 00262 00263 00264 /* Exported Functions */ 00265 /*--------------------*/ 00266 00267 /* Note that we also export some utilities from W2CF_symtab.h */ 00268 00269 extern BOOL W2C_Should_Emit_Nested_PUs(void); 00270 extern void W2C_Process_Command_Line(INT phase_argc, char * const phase_argv[], 00271 INT argc, char * const argv[]); 00272 extern void W2C_Init(void); 00273 extern void W2C_Fini(void); 00274 extern void W2C_Push_PU(const WN *pu, WN *body_part_of_interest); 00275 extern void W2C_Pop_PU(void); 00276 00277 extern void W2C_Mark_Loads(void); 00278 extern void W2C_Nomark_Loads(void); 00279 00280 extern void W2C_Set_Prompf_Emission(const WN_MAP *construct_map); 00281 extern void W2C_Set_Frequency_Map(WN_MAP frequency_map); 00282 00283 extern const char *W2C_Get_Transformed_Src_Path(void); 00284 00285 extern void W2C_Set_Purple_Emission(void); 00286 extern void W2C_Reset_Purple_Emission(void); 00287 00288 extern void W2C_Translate_Global_Types(FILE *outfile); 00289 extern void W2C_Translate_Global_Defs(FILE *outfile); 00290 00291 extern const char *W2C_Object_Name(const ST *func_st); 00292 00293 extern void W2C_Translate_Stid_Lhs(char *strbuf, 00294 UINT bufsize, 00295 const ST *stid_st, 00296 mINT64 stid_ofst, 00297 TY_IDX stid_ty, 00298 TYPE_ID stid_mtype); 00299 extern void W2C_Translate_Istore_Lhs(char *strbuf, 00300 UINT bufsize, 00301 const WN *lhs, 00302 mINT64 istore_ofst, 00303 TY_IDX istore_addr_ty, 00304 TYPE_ID istore_mtype); 00305 00306 extern void W2C_Translate_Wn(FILE *outfile, const WN *wn); 00307 extern void W2C_Translate_Wn_Str(char *strbuf, UINT bufsize, const WN *wn); 00308 00309 extern void 00310 W2C_Translate_Purple_Main(FILE *outfile, const WN *pu, const char *region_name); 00311 00312 extern void W2C_Outfile_Init(BOOL emit_global_decls); 00313 extern void W2C_Outfile_Translate_Pu(WN *pu, BOOL emit_global_decls); 00314 extern void W2C_Outfile_Fini(BOOL emit_global_decls); 00315 00316 extern void W2C_Cleanup(void); 00317 00318 } 00319 #endif /* w2c_driver_INCLUDED */