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