00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifdef USE_PCH
00036 #include "be_com_pch.h"
00037 #endif
00038 #pragma hdrstop
00039
00040 #include "whirl2src.h"
00041
00042 #ifndef SHARED_BUILD
00043 #define load_so(a,b,c)
00044 #else
00045 #include "dso.h"
00046 #endif
00047
00048 #include "w2c_weak.h"
00049 #include "w2f_weak.h"
00050
00051 extern BOOL Show_Progress;
00052
00053 static BOOL init_whirl2c = FALSE;
00054 static BOOL init_whirl2f = FALSE;
00055 static WN* w2src_func_nd = NULL;
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 extern void
00067 Whirl2C_Init (WN* func_nd)
00068 {
00069 w2src_func_nd = func_nd;
00070 if (!init_whirl2c) {
00071 #ifndef BUILD_SKIP_WHIRL2C
00072 if (W2C_Process_Command_Line == NULL) {
00073
00074 extern char *W2C_Path;
00075 const char* const str = "";
00076 load_so("whirl2c.so", W2C_Path, Show_Progress);
00077 W2C_Process_Command_Line(0, &str, 0, &str);
00078 W2C_Init ();
00079 }
00080 #endif
00081 init_whirl2c = TRUE;
00082 }
00083 }
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 extern void
00095 Whirl2F_Init (WN* func_nd)
00096 {
00097 w2src_func_nd = func_nd;
00098 if (!init_whirl2f) {
00099 #ifndef BUILD_SKIP_WHIRL2F
00100 if (W2F_Process_Command_Line == NULL) {
00101
00102 extern char *W2F_Path;
00103 const char* str;
00104 str = "";
00105 load_so("whirl2f.so", W2F_Path, Show_Progress);
00106 W2F_Process_Command_Line(0, &str, 0, &str);
00107 W2F_Init ();
00108 }
00109 #endif
00110 init_whirl2f = TRUE;
00111 }
00112 }
00113
00114
00115
00116
00117
00118
00119
00120 extern void
00121 Whirl2Src_Init (WN* func_nd)
00122 {
00123 switch (PU_src_lang(Get_Current_PU())) {
00124 case PU_C_LANG:
00125 case PU_CXX_LANG:
00126 Whirl2C_Init (func_nd);
00127 break;
00128 case PU_F90_LANG:
00129 case PU_F77_LANG:
00130 Whirl2F_Init (func_nd);
00131 break;
00132 default:
00133 FmtAssert (FALSE, ("Unknown source language type"));
00134 break;
00135 }
00136 }
00137
00138
00139
00140
00141
00142
00143 extern void
00144 Whirl2C_Emit (FILE* fp, WN* wn)
00145 {
00146 if (!init_whirl2c) {
00147 Is_True (FALSE, ("Whirl2C_Emit: whirl2c not initialized\n"));
00148 return;
00149 }
00150 W2C_Push_PU (w2src_func_nd, wn);
00151 W2C_Translate_Wn(fp, wn);
00152 W2C_Pop_PU();
00153 return;
00154 }
00155
00156
00157
00158
00159
00160
00161 extern void
00162 Whirl2F_Emit (FILE* fp, WN* wn)
00163 {
00164 if (!init_whirl2f) {
00165 Is_True (FALSE, ("Whirl2F_Emit: whirl2f not initialized\n"));
00166 return;
00167 }
00168 W2F_Push_PU (w2src_func_nd, wn);
00169 W2F_Translate_Wn(fp, wn);
00170 W2F_Pop_PU();
00171 return;
00172 }
00173
00174
00175
00176
00177
00178
00179 extern void
00180 Whirl2Src_Emit (FILE* fp, WN* wn)
00181 {
00182 switch (PU_src_lang(Get_Current_PU())) {
00183 case PU_C_LANG:
00184 case PU_CXX_LANG:
00185 Whirl2C_Emit (fp, wn);
00186 break;
00187 case PU_F90_LANG:
00188 case PU_F77_LANG:
00189 Whirl2F_Emit (fp, wn);
00190 break;
00191 default:
00192 FmtAssert (FALSE, ("Unknown source language type"));
00193 break;
00194 }
00195 }
00196
00197 #ifndef BUILD_SKIP_PROMPF
00198 #if ! (defined(__linux__) || defined(BUILD_OS_DARWIN))
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210 static void
00211 dummy ()
00212 {
00213 W2C_Translate_Istore_Lhs ((char*) NULL, (UINT) 0, (WN*) NULL, (WN_OFFSET) 0,
00214 (TY_IDX) NULL, (TYPE_ID) 0);
00215 W2F_Translate_Istore_Lhs ((char*) NULL, (UINT) 0, (WN*) NULL, (WN_OFFSET) 0,
00216 (TY_IDX) NULL, (TYPE_ID) 0);
00217 W2C_Translate_Wn_Str ((char*) NULL, (UINT) 0, (WN*) NULL);
00218 W2F_Translate_Wn_Str ((char*) NULL, (UINT) 0, (WN*) NULL);
00219 }
00220
00221 extern void
00222 Whirl2Src_Translate_Iload_Str(char *str_buf,
00223 UINT buf_size,
00224 WN* iload)
00225 {
00226 INT i;
00227 for (i=0; i<buf_size; i++) str_buf[i]='\0';
00228 switch (PU_src_lang(Get_Current_PU())) {
00229 case PU_C_LANG:
00230 case PU_CXX_LANG:
00231 W2C_Push_PU (w2src_func_nd, iload);
00232 W2C_Translate_Wn_Str(str_buf, buf_size, iload);
00233 W2C_Pop_PU ();
00234 break;
00235 case PU_F90_LANG:
00236 case PU_F77_LANG:
00237 W2F_Push_PU (w2src_func_nd, iload);
00238 W2F_Translate_Wn_Str(str_buf, buf_size, iload);
00239 W2F_Pop_PU ();
00240 break;
00241 default:
00242 FmtAssert (FALSE, ("Unknown source language type"));
00243 }
00244 }
00245
00246 extern void
00247 Whirl2Src_Translate_Istore_Str(char *str_buf,
00248 UINT buf_size,
00249 WN* istore)
00250 {
00251 INT i;
00252 for (i=0; i<buf_size; i++) str_buf[i]='\0';
00253 switch (PU_src_lang(Get_Current_PU())) {
00254 case PU_C_LANG:
00255 case PU_CXX_LANG:
00256 W2C_Push_PU (w2src_func_nd, istore);
00257 W2C_Translate_Istore_Lhs(str_buf, buf_size, WN_kid1(istore),
00258 WN_offset(istore), WN_ty(istore),
00259 WN_desc(istore));
00260 W2C_Pop_PU ();
00261 break;
00262 case PU_F90_LANG:
00263 case PU_F77_LANG:
00264 W2F_Push_PU (w2src_func_nd, istore);
00265 W2F_Translate_Istore_Lhs(str_buf, buf_size, WN_kid1(istore),
00266 WN_offset(istore), WN_ty(istore),
00267 WN_desc(istore));
00268 W2F_Pop_PU ();
00269 break;
00270 default:
00271 FmtAssert (FALSE, ("Unknown source language type"));
00272 }
00273 }
00274
00275 #endif // __linux__
00276 #endif // BUILD_PROMPF