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 /* c-or-c++ */ 00037 00038 #ifndef _whirl2src_h_included 00039 #define _whirl2src_h_included 00040 00041 /*********************************************************************** 00042 * 00043 * This set of routines is an interface to whirl2c/whirl2f, 00044 * and can be used to print whirl in source form. 00045 * 00046 * The interface comes in two flavors: 00047 * In the common case you would like to reproduce the WHIRL in 00048 * the same language as the original source (either C, C++, or Fortran). 00049 * To do so, you need to do the following: 00050 * Whirl2Src_Init (func_nd); // once in the beginning 00051 * // func_nd is the current PU. 00052 * // Must be called for each PU 00053 * // (multiple calls are harmless) 00054 * 00055 * Whirl2Src_Emit (fp, wn) // emit wn in src form into FILE* fp 00056 * ... 00057 * Whirl2Src_Emit (fp, wn) // ditto, as many Emits as you like 00058 * 00059 * 00060 * If, rather than generating the original source language you 00061 * specifically wish one of whirl2c/whirl2f, you use exactly 00062 * the same interface as above, except the names of the routines change 00063 * to the following: 00064 * Whirl2C_Init (func_nd) 00065 * Whirl2C_Emit (fp, wn) 00066 * and 00067 * Whirl2F_Init (func_nd) 00068 * Whirl2F_Emit (fp, wn) 00069 * 00070 * Some requirements and restrictions are: 00071 * 00072 * The whirl2c/f .so are loaded only if you actually call one of these 00073 * routines. In that case there must be a whirl2c/f .so in your 00074 * LD_LIBRARY_PATH. 00075 * 00076 * Although whirl2c and whirl2f allow printing to either a FILE* 00077 * or to a char* buffer, the interface here currently allows printing 00078 * to a FILE* only. 00079 * 00080 * There are restrictions on what can and cannot be printed. If you 00081 * need to do something fancier, then you can use specific routines 00082 * within whirl2c/whirl2f. Some of those routines which are used by 00083 * prefetching with the -ls option are included below. 00084 * 00085 * 00086 * Exported functions: 00087 * ------------------- 00088 * 00089 * void Whirl2Src_Init (WN* func_nd); 00090 * Based on the source language of the current PU (supplied in 00091 * func_nd) (a) load the appropriate DSO (whirl2c/whirl2f) if 00092 * not already loaded, and (b) initialize it to process nodes 00093 * from the supplie PU (func_nd). 00094 * 00095 * extern void Whirl2Src_Emit (FILE* fp, WN* wn); 00096 * Emit the supplied whirl (wn) in appropriate source form 00097 * into the supplied FILE*. 00098 * 00099 * extern void Whirl2C_Init (WN* func_nd); 00100 * Same as Whirl2Src_Init, except use C as the target language. 00101 * 00102 * extern void Whirl2C_Emit (FILE* fp, WN* wn); 00103 * Emit WHIRL as C code into FILE*. 00104 * 00105 * extern void Whirl2F_Init (WN* func_nd); 00106 * Same as Whirl2Src_Init, except use Fortran as the target language. 00107 * 00108 * extern void Whirl2F_Emit (FILE* fp, WN* wn); 00109 * Emit WHIRL as Fortran code into FILE*. 00110 * 00111 * 00112 * 00113 ***********************************************************************/ 00114 00115 #include "defs.h" 00116 #include "wn.h" 00117 00118 #ifdef __cplusplus 00119 extern "C" { 00120 #endif 00121 00122 /* Whirl2C functions */ 00123 extern void W2C_Cleanup(void); 00124 extern void W2C_Init(void); 00125 extern void W2C_Outfile_Fini(BOOL emit_global_decls); 00126 extern void W2C_Outfile_Init(BOOL emit_global_decls); 00127 extern void W2C_Outfile_Translate_Pu(WN *pu, BOOL emit_global_decls); 00128 extern void W2C_Pop_PU(void); 00129 extern void W2C_Process_Command_Line(INT phase_argc, 00130 char * const phase_argv[], 00131 INT argc, 00132 char * const argv[]); 00133 extern void W2C_Push_PU(const WN *pu, WN *body_part_of_interest); 00134 extern void W2C_Set_Frequency_Map(WN_MAP frequency_map); 00135 extern void W2C_Set_Prompf_Emission(const WN_MAP *construct_map); 00136 extern BOOL W2C_Should_Emit_Nested_PUs(void); 00137 extern void W2C_Translate_Istore_Lhs(char *strbuf, 00138 UINT bufsize, 00139 const WN* lhs, 00140 mINT64 istore_ofst, 00141 TY_IDX istore_addr_ty, 00142 TYPE_ID istore_mtype); 00143 extern void W2C_Translate_Wn(FILE *outfile, const WN *wn); 00144 extern void W2C_Translate_Wn_Str(char *strbuf, UINT bufsize, const WN *wn); 00145 00146 /* Whirl2F functions */ 00147 extern void W2F_Cleanup(void); 00148 extern void W2F_Init(void); 00149 extern void W2F_Outfile_Fini(void); 00150 extern void W2F_Outfile_Init(void); 00151 extern void W2F_Outfile_Translate_Pu(WN *pu); 00152 extern void W2F_Pop_PU(void); 00153 extern void W2F_Process_Command_Line(INT phase_argc, 00154 char *phase_argv[], 00155 INT argc, 00156 char *argv[]); 00157 extern void W2F_Push_PU(WN *pu, WN *body_part_of_interest); 00158 extern void W2F_Set_Frequency_Map(WN_MAP frequency_map); 00159 extern void W2F_Set_Prompf_Emission(WN_MAP *construct_map); 00160 extern BOOL W2F_Should_Emit_Nested_PUs(void); 00161 extern void W2F_Translate_Istore_Lhs(char *strbuf, 00162 UINT bufsize, 00163 WN* lhs, 00164 mINT64 istore_ofst, 00165 TY_IDX istore_addr_ty, 00166 TYPE_ID istore_mtype); 00167 extern void W2F_Translate_Wn(FILE *outfile, WN *wn); 00168 extern void W2F_Translate_Wn_Str(char *strbuf, UINT bufsize, WN *wn); 00169 00170 /* Interface functions for LNO */ 00171 extern void Whirl2Src_Init (WN* func_nd); 00172 extern void Whirl2Src_Emit (FILE* fp, WN* wn); 00173 00174 extern void Whirl2C_Init (WN* func_nd); 00175 extern void Whirl2C_Emit (FILE* fp, WN* wn); 00176 00177 extern void Whirl2F_Init (WN* func_nd); 00178 extern void Whirl2F_Emit (FILE* fp, WN* wn); 00179 00180 #ifdef __cplusplus 00181 } 00182 #endif 00183 00184 #endif /* _whirl2src_h_included */