|
OpenADFortTk (basic)
|
00001 // -*-Mode: C++;-*- 00002 // $Header: /m_home/m_utkej/Argonne/cvs2svn/cvs/OpenADFortTk/src/sexp2whirl/sexp2wn.i,v 1.3 2007-10-08 18:28:34 utke Exp $ 00003 #ifndef wn2sexp_i 00004 #define wn2sexp_i 00005 #include <iostream> 00006 #include <sexp.h> 00007 00008 #include "Open64IRInterface/Open64BasicTypes.h" 00009 00010 #include "sexp2whirl.i" 00011 00012 00013 // WNXlationTable: Maps WHIRL OPERATORs to functions designed to 00014 // handle the translation of that particular node. Handler functions 00015 // have the type 'Handler'. In the event that no specific handler is 00016 // registered for a particular OPERATOR, a default handler is returned. 00017 class WNXlationTable { 00018 public: 00019 00020 typedef WN* (*Handler)(sexp_t*); 00021 00022 public: 00023 WNXlationTable(); 00024 ~WNXlationTable(); 00025 00026 Handler operator[](OPERATOR opr) const { Find(opr); } 00027 Handler Find(OPERATOR opr) const { return table[opr]; } 00028 00029 void Dump(std::ostream& os = std::cerr) const; 00030 void DDump() const; 00031 00032 private: 00033 // Should not be used 00034 WNXlationTable(const WNXlationTable& x) { } 00035 WNXlationTable& operator=(const WNXlationTable& x) { return *this; } 00036 00037 struct InitEntry { 00038 OPERATOR opr; 00039 Handler fn; 00040 }; 00041 00042 private: 00043 static bool initialized; 00044 00045 // The OPERATOR -> Handler table 00046 static Handler table[]; 00047 static unsigned int tableSz; 00048 00049 // Initialization table 00050 static InitEntry initTable[]; 00051 static unsigned int initTableSz; 00052 }; 00053 00054 00055 //*************************************************************************** 00056 // Control Flow Statements 00057 //*************************************************************************** 00058 00059 namespace sexp2whirl { 00060 00061 extern WN* 00062 xlate_INTERFACE(sexp_t* sx); 00063 00064 // --------------------------------------------------------- 00065 // Structured Control Flow Statements 00066 // --------------------------------------------------------- 00067 00068 extern WN* 00069 xlate_FUNC_ENTRY(sexp_t* sx); 00070 00071 extern WN* 00072 xlate_BLOCK(sexp_t* sx); 00073 00074 extern WN* 00075 xlate_REGION(sexp_t* sx); 00076 00077 extern WN* 00078 xlate_structured_cf(sexp_t* sx); 00079 00080 // --------------------------------------------------------- 00081 // Unstructured Control Flow Statements 00082 // --------------------------------------------------------- 00083 00084 extern WN* 00085 xlate_IMPLIED_DO(sexp_t* sx); 00086 00087 extern WN* 00088 xlate_GOTOx_LABEL(sexp_t* sx); 00089 00090 extern WN* 00091 xlate_multiBR(sexp_t* sx); 00092 00093 extern WN* 00094 xlate_CASEGOTO(sexp_t* sx); 00095 00096 extern WN* 00097 xlate_AGOTO(sexp_t* sx); 00098 00099 extern WN* 00100 xlate_ALTENTRY(sexp_t* sx); 00101 00102 extern WN* 00103 xlate_condBR(sexp_t* sx); 00104 00105 extern WN* 00106 xlate_RETURNx(sexp_t* sx); 00107 00108 }; /* namespace sexp2whirl */ 00109 00110 00111 //*************************************************************************** 00112 // Calls and Other Statements 00113 //*************************************************************************** 00114 00115 namespace sexp2whirl { 00116 00117 // --------------------------------------------------------- 00118 // Calls 00119 // --------------------------------------------------------- 00120 00121 extern WN* 00122 xlate_xCALL(sexp_t* sx); 00123 00124 extern WN* 00125 xlate_IO(sexp_t* sx); 00126 00127 // --------------------------------------------------------- 00128 // Other Statements 00129 // --------------------------------------------------------- 00130 00131 extern WN* 00132 xlate_misc_stmt(sexp_t* sx); 00133 00134 extern WN* 00135 xlate_xPRAGMA(sexp_t* sx); 00136 00137 }; /* namespace sexp2whirl */ 00138 00139 00140 //*************************************************************************** 00141 // Memory Access 00142 //*************************************************************************** 00143 00144 namespace sexp2whirl { 00145 00146 // --------------------------------------------------------- 00147 // Memory Access (or assignment and variable references) 00148 // --------------------------------------------------------- 00149 00150 // Loads (variable reference) and Stores (assignment) 00151 extern WN* 00152 xlate_LDA_LDMA(sexp_t* sx); 00153 00154 extern WN* 00155 xlate_LDID_STID(sexp_t* sx); 00156 00157 extern WN* 00158 xlate_IDNAME(sexp_t* sx); 00159 00160 extern WN* 00161 xlate_xLOADx_xSTOREx(sexp_t* sx); 00162 00163 extern WN* 00164 xlate_PSTID(sexp_t* sx); 00165 00166 extern WN* 00167 xlate_PSTORE(sexp_t* sx); 00168 00169 // --------------------------------------------------------- 00170 // Memory Access (user defined structures) 00171 // --------------------------------------------------------- 00172 00173 extern WN* 00174 xlate_STRCTFLD(sexp_t* sx); 00175 00176 // --------------------------------------------------------- 00177 // Array Operators (N-ary Operations) 00178 // --------------------------------------------------------- 00179 00180 extern WN* 00181 xlate_ARRAYx(sexp_t* sx); 00182 00183 }; /* namespace sexp2whirl */ 00184 00185 00186 //*************************************************************************** 00187 // Expression Operators, Type conversion, Leaf (Other) 00188 //*************************************************************************** 00189 00190 namespace sexp2whirl { 00191 00192 // --------------------------------------------------------- 00193 // Type conversion 00194 // --------------------------------------------------------- 00195 00196 extern WN* 00197 xlate_CVT_CVTL(sexp_t* sx); 00198 00199 extern WN* 00200 xlate_TAS(sexp_t* sx); 00201 00202 // --------------------------------------------------------- 00203 // Leaf (Other) 00204 // --------------------------------------------------------- 00205 00206 extern WN* 00207 xlate_CONST(sexp_t* sx); 00208 00209 extern WN* 00210 xlate_INTCONST(sexp_t* sx); 00211 00212 // --------------------------------------------------------- 00213 // Expression Operators: Unary Operations 00214 // --------------------------------------------------------- 00215 00216 extern WN* 00217 xlate_UnaryOp(sexp_t* sx); 00218 00219 extern WN* 00220 xlate_PARM(sexp_t* sx); 00221 00222 extern WN* 00223 xlate_ALLOCA(sexp_t* sx) ; 00224 00225 // --------------------------------------------------------- 00226 // Expression Operators: Binary Operations 00227 // --------------------------------------------------------- 00228 00229 extern WN* 00230 xlate_BinaryOp(sexp_t* sx); 00231 00232 // --------------------------------------------------------- 00233 // Expression Operators: Ternary Operations 00234 // --------------------------------------------------------- 00235 00236 extern WN* 00237 xlate_TernaryOp(sexp_t* sx); 00238 00239 // --------------------------------------------------------- 00240 // Expression Operators: N-ary Operations 00241 // --------------------------------------------------------- 00242 00243 // Array expressions included in memory operations 00244 00245 extern WN* 00246 xlate_IO_ITEM(sexp_t* sx); 00247 00248 }; /* namespace sexp2whirl */ 00249 00250 //*************************************************************************** 00251 00252 namespace sexp2whirl { 00253 00254 extern WN* 00255 xlate_unknown(sexp_t* sx); 00256 00257 }; /* namespace sexp2whirl */ 00258 00259 00260 //*************************************************************************** 00261 00262 #endif /* wn2sexp_i */