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