|
OpenADFortTk (basic)
|
00001 // -*-Mode: C++;-*- 00002 // $Header: /Volumes/cvsrep/developer/OpenADFortTk/src/whirl2sexp/wn2sexp.cxx,v 1.16 2006/07/06 18:38:41 utke Exp $ 00003 00004 #include <stdlib.h> 00005 00006 #include "Open64IRInterface/Open64BasicTypes.h" 00007 00008 #include "SexpTags.h" 00009 #include "Diagnostics.h" 00010 00011 #include "wn2sexp.i" 00012 #include "wn2sexp.h" 00013 00014 00015 //************************** Forward Declarations *************************** 00016 00017 using namespace whirl2sexp; 00018 using namespace sexp; // for sexp::ostream, etc 00019 00020 00021 //*************************************************************************** 00022 // Translate any WN 00023 //*************************************************************************** 00024 00025 // TranslateWN: see header. 00026 whirl2sexp::status 00027 whirl2sexp::TranslateWN(sexp::ostream& sos, WN* wn) 00028 { 00029 // The task of translation is dispatched to the appropriate handler 00030 // registered in the handler table. 00031 static WNXlationTable handlerTable; 00032 00033 if (!wn) { 00034 sos << BegList << EndList; 00035 return whirl2sexp::good; 00036 } 00037 00038 OPERATOR opr = WN_operator(wn); 00039 FORTTK_DEVMSG(3, "Translating " << OPERATOR_name(opr)); 00040 00041 // Dispatch to the appropriate handler for this construct. 00042 return handlerTable[opr](sos, wn); 00043 } 00044 00045 00046 // TranslateWNChildren: see header. 00047 whirl2sexp::status 00048 whirl2sexp::TranslateWNChildren(sexp::ostream& sos, WN* wn) 00049 { 00050 FORTTK_ASSERT(wn, fortTkSupport::Diagnostics::UnexpectedInput); 00051 00052 INT nkids = WN_kid_count(wn); 00053 for (INT kidno = 0; kidno < nkids; ++kidno) { 00054 WN* kidwn = WN_kid(wn, kidno); 00055 TranslateWN(sos, kidwn); 00056 if (kidno < nkids - 1) { 00057 sos << EndLine; // do not output after last call 00058 } 00059 } 00060 00061 return whirl2sexp::good; 00062 } 00063 00064 00065 //*************************************************************************** 00066 // S-expressions sexp::ostream operators 00067 //*************************************************************************** 00068 00069 // Cf. GenSexpSym 00070 sexp::ostream& 00071 operator<<(std::ostream& os, const GenSexpSymInfo_& x) 00072 { 00073 sexp::ostream& sos = dynamic_cast<sexp::ostream&>(os); 00074 00075 ST_IDX st_idx = x.val; 00076 UINT lvl = (UINT)ST_IDX_level(st_idx); 00077 UINT idx = (UINT)ST_IDX_index(st_idx); 00078 00079 sos << BegList << Atom(SexpTags::ST) << Atom(lvl) << Atom(idx) << EndList; 00080 00081 return sos; 00082 } 00083 00084 00085 // Cf. GenSexpTy 00086 sexp::ostream& 00087 operator<<(std::ostream& os, const GenSexpTyInfo_& x) 00088 { 00089 sexp::ostream& sos = dynamic_cast<sexp::ostream&>(os); 00090 00091 TY_IDX ty_idx = x.val; 00092 const char* nm = TY_name(ty_idx); 00093 UINT32 idx = TY_id(ty_idx); 00094 UINT32 algn = TY_align(ty_idx); 00095 00096 using namespace sexp::IOFlags; 00097 sos << BegList 00098 << Atom(SexpTags::TY) << Atom(A_DQUOTE, nm) << Atom(idx) << Atom(algn) 00099 << EndList; 00100 00101 return sos; 00102 } 00103 00104 00105 // Cf. GenSexpWNOpr 00106 sexp::ostream& 00107 operator<<(std::ostream& os, const GenSexpWNOprInfo_& x) 00108 { 00109 sexp::ostream& sos = dynamic_cast<sexp::ostream&>(os); 00110 00111 WN* wn = x.val; 00112 OPCODE opc = WN_opcode(wn); 00113 00114 OPERATOR opr = OPCODE_operator(opc); 00115 TYPE_ID rty = OPCODE_rtype(opc); 00116 TYPE_ID dty = OPCODE_desc(opc); 00117 00118 const char* oprNm = OPERATOR_name(opr) + 4; // skip "OPR_" 00119 const char* rtyNm = Mtype_Name(rty); 00120 const char* dtyNm = Mtype_Name(dty); 00121 00122 sos << Atom(oprNm) << Atom(rtyNm) << Atom(dtyNm); 00123 00124 return sos; 00125 } 00126 00127 00128 // Cf. GenSexpSymRef 00129 sexp::ostream& 00130 operator<<(std::ostream& os, const GenSexpSymRefInfo_& x) 00131 { 00132 sexp::ostream& sos = dynamic_cast<sexp::ostream&>(os); 00133 00134 ST_IDX st_idx = x.val; 00135 ST* st = (st_idx != 0) ? &St_Table[st_idx] : NULL; 00136 00137 UINT lvl = 0; 00138 UINT idx = 0; 00139 if (st) { 00140 lvl = (UINT)ST_level(st); 00141 idx = (UINT)ST_index(st); 00142 } 00143 00144 sos << BegList << Atom(SexpTags::ST) << GenSexpSymNm(st) 00145 << Atom(lvl) << Atom(idx) << EndList; 00146 00147 return sos; 00148 } 00149 00150 00151 // Cf. GenSexpSymNm 00152 sexp::ostream& 00153 operator<<(std::ostream& os, const GenSexpSymNmInfo_& x) 00154 { 00155 sexp::ostream& sos = dynamic_cast<sexp::ostream&>(os); 00156 00157 ST* st = x.val; 00158 00159 const char* nm = NULL; 00160 if (st) { 00161 if (ST_class(st) == CLASS_CONST) { 00162 TCON& tcon = STC_val(st); 00163 if (TCON_ty(tcon) == MTYPE_STR) { 00164 STR_IDX idx = TCON_str_idx(tcon); 00165 nm = Index_to_char_array(idx); 00166 } 00167 else { 00168 nm = Targ_Print(NULL, tcon); 00169 } 00170 } 00171 else { 00172 nm = ST_name(st); 00173 } 00174 } 00175 00176 using namespace sexp::IOFlags; 00177 sos << Atom(A_DQUOTE, nm); 00178 00179 return sos; 00180 } 00181 00182 00183 // Cf. GenSexpTyUse 00184 sexp::ostream& 00185 operator<<(std::ostream& os, const GenSexpTyUseInfo_& x) 00186 { 00187 sexp::ostream& sos = dynamic_cast<sexp::ostream&>(os); 00188 00189 TY_IDX ty_idx = x.val; 00190 TY* ty = (ty_idx != 0) ? &Ty_Table[ty_idx] : NULL; 00191 00192 const char* nm = NULL; 00193 UINT32 idx = 0; 00194 UINT32 algn = 0; 00195 if (ty) { 00196 nm = TY_name(ty_idx); 00197 idx = TY_id(ty_idx); 00198 algn = TY_align(ty_idx); 00199 } 00200 00201 using namespace sexp::IOFlags; 00202 sos << BegList 00203 << Atom(SexpTags::TY) << Atom(A_DQUOTE, nm) << Atom(idx) << Atom(algn) 00204 << EndList; 00205 00206 return sos; 00207 } 00208 00209 00210 // Cf. GenSexpFlg 00211 sexp::ostream& 00212 operator<<(std::ostream& os, const GenSexpFlgInfo_& x) 00213 { 00214 sexp::ostream& sos = dynamic_cast<sexp::ostream&>(os); 00215 00216 const char* val = x.val; 00217 00218 using namespace sexp::IOFlags; 00219 sos << BegList << Atom(SexpTags::FLG) << Atom(A_DQUOTE, val) << EndList; 00220 00221 return sos; 00222 } 00223 00224 00225 // Cf. GenSexpOpaqueFlg 00226 sexp::ostream& 00227 operator<<(std::ostream& os, const GenSexpOpaqueFlgInfo_& x) 00228 { 00229 sexp::ostream& sos = dynamic_cast<sexp::ostream&>(os); 00230 00231 UINT64 val = x.val; 00232 00233 using namespace sexp::IOFlags; 00234 sos << BegList << Atom(SexpTags::OFLG) << Atom(A_HEX, val) << EndList; 00235 00236 return sos; 00237 } 00238 00239 00240 //*************************************************************************** 00241 // Structured Control Flow Statements: translation of these is 00242 // superceded by construction of the control flow graph. 00243 //*************************************************************************** 00244 00245 whirl2sexp::status 00246 whirl2sexp::xlate_FUNC_ENTRY(sexp::ostream& sos, WN* wn) 00247 { 00248 FORTTK_ASSERT(WN_operator(wn) == OPR_FUNC_ENTRY, fortTkSupport::Diagnostics::UnexpectedInput); 00249 00250 // For a routine definition, the following is true (but there are 00251 // exceptions, e.g., in INTERFACE node) 00252 // kid 0..n-4: formals 00253 // kid n-3: WN_func_pragmas(wn) 00254 // kid n-2: WN_func_varrefs(wn) 00255 // kid n-1: WN_func_body(wn) 00256 00257 ST_IDX st_idx = WN_entry_name(wn); 00258 00259 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00260 sos << BegList << GenSexpSymRef(st_idx) << EndList; // WN_ATTRS 00261 if (WN_kid_count(wn) > 0) { 00262 sos << EndLine; 00263 } 00264 TranslateWNChildren(sos, wn); // KIDs 00265 sos << EndList; 00266 00267 return whirl2sexp::good; 00268 } 00269 00270 00271 whirl2sexp::status 00272 whirl2sexp::xlate_BLOCK(sexp::ostream& sos, WN* wn) 00273 { 00274 FORTTK_ASSERT(WN_operator(wn) == OPR_BLOCK, fortTkSupport::Diagnostics::UnexpectedInput); 00275 00276 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00277 sos << BegList << EndList; // WN_ATTRS 00278 if (WN_first(wn)) { 00279 // Generate a new line only if something is to follow. BLOCKS are 00280 // special in that the attribute list is followed by 0 or more 00281 // WHIRL_ASTs, not it's own list. 00282 sos << EndLine; 00283 } 00284 00285 for (WN* x = WN_first(wn); x != NULL; x = WN_next(x)) { // KIDs 00286 TranslateWN(sos, x); 00287 if (WN_next(x)) { 00288 sos << EndLine; // do not output after last call 00289 } 00290 } 00291 sos << EndList; 00292 00293 return whirl2sexp::good; 00294 } 00295 00296 00297 whirl2sexp::status 00298 whirl2sexp::xlate_REGION(sexp::ostream& sos, WN* wn) 00299 { 00300 FORTTK_ASSERT(WN_operator(wn) == OPR_REGION, fortTkSupport::Diagnostics::UnexpectedInput); 00301 00302 FORTTK_DIE(fortTkSupport::Diagnostics::Unimplemented); 00303 return whirl2sexp::good; 00304 } 00305 00306 00307 whirl2sexp::status 00308 whirl2sexp::xlate_structured_cf(sexp::ostream& sos, WN* wn) 00309 { 00310 OPERATOR opr = WN_operator(wn); 00311 FORTTK_ASSERT(opr == OPR_DO_LOOP || opr == OPR_DO_WHILE || 00312 opr == OPR_WHILE_DO || opr == OPR_IF, 00313 fortTkSupport::Diagnostics::UnexpectedInput); 00314 00315 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00316 sos << BegList; // WN_ATTRS 00317 if (opr == OPR_IF) { 00318 UINT32 flg = WN_if_flag(wn); 00319 sos << GenSexpOpaqueFlg(flg); 00320 } 00321 sos << EndList << EndLine; 00322 TranslateWNChildren(sos, wn); // KIDs 00323 sos << EndList; 00324 00325 00326 return whirl2sexp::good; 00327 } 00328 00329 00330 //*************************************************************************** 00331 // Unstructured Control Flow Statements 00332 //*************************************************************************** 00333 00334 whirl2sexp::status 00335 whirl2sexp::xlate_IMPLIED_DO(sexp::ostream& sos, WN* wn) 00336 { 00337 FORTTK_ASSERT(WN_operator(wn) == OPR_IMPLIED_DO, fortTkSupport::Diagnostics::UnexpectedInput); 00338 FORTTK_DIE(fortTkSupport::Diagnostics::Unimplemented); 00339 return whirl2sexp::good; 00340 } 00341 00342 00343 whirl2sexp::status 00344 whirl2sexp::xlate_GOTOx_LABEL(sexp::ostream& sos, WN* wn) 00345 { 00346 OPERATOR opr = WN_operator(wn); 00347 FORTTK_ASSERT(opr == OPR_GOTO || opr == OPR_GOTO_OUTER_BLOCK || 00348 opr == OPR_REGION_EXIT || opr == OPR_LABEL, 00349 fortTkSupport::Diagnostics::UnexpectedInput); 00350 00351 INT32 lbl = WN_label_number(wn); 00352 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00353 sos << BegList << Atom(lbl); // WN_ATTRS 00354 if (opr == OPR_GOTO_OUTER_BLOCK) { 00355 UINT32 lbl_lvl = WN_label_level(wn); 00356 sos << Atom(lbl_lvl) << EndList; 00357 } 00358 else if (opr == OPR_LABEL) { 00359 UINT32 flg = WN_label_flag(wn); 00360 sos << GenSexpOpaqueFlg(flg); 00361 } 00362 sos << EndList; 00363 if (opr == OPR_LABEL) { // KID 0 00364 sos << EndLine; 00365 TranslateWN(sos, WN_kid0(wn)); 00366 } 00367 sos << EndList; 00368 00369 return whirl2sexp::good; 00370 } 00371 00372 00373 whirl2sexp::status 00374 whirl2sexp::xlate_multiBR(sexp::ostream& sos, WN* wn) 00375 { 00376 OPERATOR opr = WN_operator(wn); 00377 FORTTK_ASSERT(opr == OPR_SWITCH || opr == OPR_COMPGOTO, 00378 fortTkSupport::Diagnostics::UnexpectedInput); 00379 00380 INT32 nentries = WN_num_entries(wn); 00381 INT32 llbl = WN_last_label(wn); 00382 00383 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00384 sos << BegList << Atom(nentries) << Atom(llbl) << EndList // WN_ATTRS 00385 << EndLine; 00386 TranslateWNChildren(sos, wn); // KIDs 00387 sos << EndList; 00388 00389 return whirl2sexp::good; 00390 } 00391 00392 00393 whirl2sexp::status 00394 whirl2sexp::xlate_CASEGOTO(sexp::ostream& sos, WN* wn) 00395 { 00396 FORTTK_ASSERT(WN_operator(wn) == OPR_CASEGOTO, fortTkSupport::Diagnostics::UnexpectedInput); 00397 00398 INT64 cval = WN_const_val(wn); 00399 INT32 lbl = WN_label_number(wn); 00400 00401 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00402 sos << BegList << Atom(cval) << Atom(lbl) << EndList; // WN_ATTRS 00403 sos << EndList; 00404 00405 return whirl2sexp::good; 00406 } 00407 00408 00409 whirl2sexp::status 00410 whirl2sexp::xlate_AGOTO(sexp::ostream& sos, WN* wn) 00411 { 00412 FORTTK_ASSERT(WN_operator(wn) == OPR_AGOTO, fortTkSupport::Diagnostics::UnexpectedInput); 00413 00414 // XGOTO: number_entries st_idx kid0 kid1 00415 // AGOTO: kid0 00416 FORTTK_DIE(fortTkSupport::Diagnostics::Unimplemented); 00417 return whirl2sexp::good; 00418 } 00419 00420 00421 whirl2sexp::status 00422 whirl2sexp::xlate_ALTENTRY(sexp::ostream& sos, WN* wn) 00423 { 00424 FORTTK_ASSERT(WN_operator(wn) == OPR_ALTENTRY, fortTkSupport::Diagnostics::UnexpectedInput); 00425 00426 FORTTK_DIE(fortTkSupport::Diagnostics::Unimplemented); 00427 return whirl2sexp::good; 00428 } 00429 00430 00431 whirl2sexp::status 00432 whirl2sexp::xlate_condBR(sexp::ostream& sos, WN* wn) 00433 { 00434 OPERATOR opr = WN_operator(wn); 00435 FORTTK_ASSERT(opr == OPR_TRUEBR || opr == OPR_FALSEBR, 00436 fortTkSupport::Diagnostics::UnexpectedInput); 00437 00438 INT32 lbl = WN_label_number(wn); 00439 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00440 sos << BegList << Atom(lbl) << EndList << EndLine; // WN_ATTRS 00441 TranslateWN(sos, WN_kid0(wn)); // KID 0 00442 sos << EndList; 00443 00444 return whirl2sexp::good; 00445 } 00446 00447 00448 whirl2sexp::status 00449 whirl2sexp::xlate_RETURNx(sexp::ostream& sos, WN* wn) 00450 { 00451 OPERATOR opr = WN_operator(wn); 00452 FORTTK_ASSERT(opr == OPR_RETURN || opr == OPR_RETURN_VAL, 00453 fortTkSupport::Diagnostics::UnexpectedInput); 00454 00455 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00456 sos << BegList << EndList; // WN_ATTRS 00457 if (opr == OPR_RETURN_VAL) { // KID 0 00458 sos << EndLine; 00459 TranslateWN(sos, WN_kid0(wn)); 00460 } 00461 sos << EndList; 00462 00463 return whirl2sexp::good; 00464 } 00465 00466 00467 //*************************************************************************** 00468 // Calls 00469 //*************************************************************************** 00470 00471 whirl2sexp::status 00472 whirl2sexp::xlate_xCALL(sexp::ostream& sos, WN* wn) 00473 { 00474 OPERATOR opr = WN_operator(wn); 00475 FORTTK_ASSERT(opr == OPR_CALL || opr == OPR_ICALL || 00476 opr == OPR_VFCALL || opr == OPR_PICCALL || 00477 opr == OPR_INTRINSIC_CALL || opr == OPR_INTRINSIC_OP, 00478 fortTkSupport::Diagnostics::UnexpectedInput); 00479 00480 UINT32 flg = 0; 00481 if (opr != OPR_VFCALL) { 00482 flg = WN_call_flag(wn); // VFCALL doesn't have a flags field... 00483 } 00484 00485 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00486 00487 sos << BegList; // WN_ATTRS 00488 if (opr == OPR_CALL || opr == OPR_PICCALL) { 00489 ST_IDX st_idx = WN_st_idx(wn); 00490 sos << GenSexpSymRef(st_idx); 00491 } 00492 else if (opr == OPR_ICALL || opr == OPR_VFCALL) { 00493 TY_IDX ty_idx = WN_ty(wn); 00494 sos << GenSexpTyUse(ty_idx); 00495 } 00496 else { 00497 INTRINSIC intrn = WN_intrinsic(wn); 00498 const char* nm = INTRINSIC_name(intrn); 00499 sos << Atom(nm); 00500 } 00501 if (opr != OPR_VFCALL) { 00502 sos << GenSexpOpaqueFlg(flg); 00503 } 00504 sos << EndList; 00505 if (WN_kid_count(wn) > 0) { 00506 sos << EndLine; 00507 } 00508 00509 TranslateWNChildren(sos, wn); // KIDs 00510 sos << EndList; 00511 00512 return whirl2sexp::good; 00513 } 00514 00515 00516 whirl2sexp::status 00517 whirl2sexp::xlate_IO(sexp::ostream& sos, WN* wn) 00518 { 00519 FORTTK_ASSERT(WN_operator(wn) == OPR_IO, fortTkSupport::Diagnostics::UnexpectedInput); 00520 00521 IOSTATEMENT ios = WN_io_statement(wn); 00522 UINT32 flg = WN_io_flag(wn); 00523 const char* nm = IOSTATEMENT_name(ios); 00524 00525 using namespace sexp::IOFlags; 00526 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00527 sos << BegList // WN_ATTRS 00528 << Atom(nm) << GenSexpOpaqueFlg(flg) 00529 << EndList << EndLine; 00530 TranslateWNChildren(sos, wn); // KIDs 00531 sos << EndList; 00532 00533 return whirl2sexp::good; 00534 } 00535 00536 00537 whirl2sexp::status 00538 whirl2sexp::xlate_IO_ITEM(sexp::ostream& sos, WN* wn) 00539 { 00540 FORTTK_ASSERT(WN_operator(wn) == OPR_IO_ITEM, fortTkSupport::Diagnostics::UnexpectedInput); 00541 00542 IOITEM ioi = WN_io_item(wn); 00543 TY_IDX ty_idx = WN_ty(wn); 00544 const char* nm = IOITEM_name(ioi); 00545 00546 using namespace sexp::IOFlags; 00547 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00548 sos << BegList // WN_ATTRS 00549 << Atom(nm) << GenSexpTyUse(ty_idx) 00550 << EndList; 00551 if (WN_kid_count(wn) > 0) { 00552 sos << EndLine; 00553 } 00554 TranslateWNChildren(sos, wn); // KIDs 00555 sos << EndList; 00556 00557 return whirl2sexp::good; 00558 } 00559 00560 00561 //*************************************************************************** 00562 // Other Statements 00563 //*************************************************************************** 00564 00565 whirl2sexp::status 00566 whirl2sexp::xlate_misc_stmt(sexp::ostream& sos, WN* wn) 00567 { 00568 OPERATOR opr = WN_operator(wn); 00569 FORTTK_ASSERT(opr == OPR_EVAL || 00570 opr == OPR_PREFETCH || opr == OPR_PREFETCHX || 00571 opr == OPR_COMMENT || 00572 opr == OPR_TRAP || opr == OPR_ASSERT || opr == OPR_AFFIRM || 00573 opr == OPR_FORWARD_BARRIER || opr == OPR_BACKWARD_BARRIER || 00574 opr == OPR_DEALLOCA || 00575 opr == OPR_USE || opr == OPR_NAMELIST || 00576 opr == OPR_IMPLICIT_BND || opr == OPR_NULLIFY || 00577 opr == OPR_INTERFACE || opr == OPR_ARRAY_CONSTRUCT, 00578 fortTkSupport::Diagnostics::UnexpectedInput); 00579 00580 // misc. statements 00581 // EVAL: kid0 00582 // PREFETCH: flag, kids 00583 // PREFETCHX: flag, kids 00584 // COMMENT: stidx 00585 // TRAP: ofst, kids 00586 // ASSERT: ofst, kids 00587 // AFFIRM: kids 00588 // FBARRIER: kids 00589 // BBARRIER: kids 00590 // DEALLOCA: kids 00591 // USE: stidx, kids 00592 // NAMELIST: stidx, kids 00593 // IMPLICIT_BND: 00594 // NULLIFY: kids 00595 // INTERFACE: stidx, kids 00596 // ACONSTRUCT: kids 00597 00598 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00599 00600 sos << BegList; // WN_ATTRS 00601 if (OPERATOR_has_sym(opr)) { 00602 ST_IDX st_idx = WN_st_idx(wn); 00603 sos << GenSexpSymRef(st_idx); 00604 } 00605 if (OPERATOR_has_offset(opr)) { 00606 WN_OFFSET ofst = WN_offset(wn); 00607 sos << Atom(ofst); 00608 } 00609 if (OPERATOR_has_flags(opr)) { 00610 UINT32 flg = WN_flag(wn); 00611 sos << GenSexpOpaqueFlg(flg); 00612 } 00613 sos << EndList; 00614 00615 if (WN_kid_count(wn) > 0) { 00616 sos << EndLine; 00617 } 00618 TranslateWNChildren(sos, wn); // KIDs 00619 sos << EndList; 00620 00621 return whirl2sexp::good; 00622 } 00623 00624 00625 whirl2sexp::status 00626 whirl2sexp::xlate_xPRAGMA(sexp::ostream& sos, WN* wn) 00627 { 00628 OPERATOR opr = WN_operator(wn); 00629 FORTTK_ASSERT(opr == OPR_PRAGMA || opr == OPR_XPRAGMA, 00630 fortTkSupport::Diagnostics::UnexpectedInput); 00631 00632 WN_PRAGMA_ID prag = (WN_PRAGMA_ID)WN_pragma(wn); 00633 UINT16 flg = WN_pragma_flags(wn); 00634 ST_IDX st_idx = WN_st_idx(wn); 00635 00636 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00637 sos << BegList << Atom(prag) << GenSexpSymRef(st_idx) // WN_ATTRS 00638 << GenSexpOpaqueFlg(flg); 00639 00640 if (opr == OPR_PRAGMA) { 00641 INT64 cval = WN_const_val(wn); 00642 sos << Atom(cval) << EndList; // end WN_ATTRS 00643 } 00644 else { 00645 sos << EndList; // end WN_ATTRS 00646 sos << EndLine; 00647 TranslateWN(sos, WN_kid0(wn)); // KID 0 00648 } 00649 00650 sos << EndList; 00651 return whirl2sexp::good; 00652 } 00653 00654 00655 //*************************************************************************** 00656 // Loads (In WHIRL, loads are expressions.) 00657 // Stores (In WHIRL, stores are statements.) 00658 //*************************************************************************** 00659 00660 whirl2sexp::status 00661 whirl2sexp::xlate_LDA_LDMA(sexp::ostream& sos, WN* wn) 00662 { 00663 OPERATOR opr = WN_operator(wn); 00664 FORTTK_ASSERT(opr == OPR_LDA || opr == OPR_LDMA, fortTkSupport::Diagnostics::UnexpectedInput); 00665 00666 ST_IDX st_idx = WN_st_idx(wn); 00667 WN_OFFSET ofst = WN_load_offset(wn); 00668 TY_IDX ty_idx = WN_ty(wn); 00669 UINT fldid = WN_field_id(wn); 00670 00671 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00672 sos << BegList << GenSexpSymRef(st_idx) << Atom(ofst) 00673 << GenSexpTyUse(ty_idx) << Atom(fldid) << EndList; // WN_ATTRS 00674 sos << EndList; 00675 00676 return whirl2sexp::good; 00677 } 00678 00679 00680 whirl2sexp::status 00681 whirl2sexp::xlate_LDID_STID(sexp::ostream& sos, WN* wn) 00682 { 00683 OPERATOR opr = WN_operator(wn); 00684 FORTTK_ASSERT(opr == OPR_LDID 00685 || 00686 opr == OPR_STID 00687 || 00688 opr == OPR_PSTID, 00689 fortTkSupport::Diagnostics::UnexpectedInput); 00690 00691 ST_IDX st_idx = WN_st_idx(wn); 00692 WN_OFFSET ofst = WN_offset(wn); // WN_load_offset, WN_store_offset 00693 TY_IDX ty_idx = WN_ty(wn); 00694 UINT fldid = WN_field_id(wn); 00695 00696 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00697 sos << BegList << GenSexpSymRef(st_idx) << Atom(ofst) 00698 << GenSexpTyUse(ty_idx) << Atom(fldid) << EndList; // WN_ATTRS 00699 if (opr == OPR_STID || opr == OPR_PSTID) { 00700 sos << EndLine; 00701 TranslateWN(sos, WN_kid0(wn)); // KID 0 00702 } 00703 sos << EndList; 00704 00705 return whirl2sexp::good; 00706 } 00707 00708 00709 whirl2sexp::status 00710 whirl2sexp::xlate_IDNAME(sexp::ostream& sos, WN* wn) 00711 { 00712 OPERATOR opr = WN_operator(wn); 00713 FORTTK_ASSERT(opr == OPR_IDNAME, fortTkSupport::Diagnostics::UnexpectedInput); 00714 00715 ST_IDX st_idx = WN_st_idx(wn); 00716 WN_OFFSET ofst = WN_idname_offset(wn); 00717 00718 sos << BegList << GenSexpWNOpr(wn) // WN_OPR 00719 << BegList << GenSexpSymRef(st_idx) << Atom(ofst) << EndList // WN_ATTRS 00720 << EndList; 00721 return whirl2sexp::good; 00722 } 00723 00724 00725 whirl2sexp::status 00726 whirl2sexp::xlate_xLOADx_xSTOREx(sexp::ostream& sos, WN* wn) 00727 { 00728 OPERATOR opr = WN_operator(wn); 00729 FORTTK_ASSERT(opr == OPR_ILOAD || opr == OPR_MLOAD || opr == OPR_ILOADX || 00730 opr == OPR_ISTORE || opr == OPR_MSTORE || opr == OPR_ISTOREX || 00731 opr == OPR_PSTORE, 00732 fortTkSupport::Diagnostics::UnexpectedInput); 00733 00734 // ILOAD: ofst field_id ty_idx1 ty_idx2 kid0 00735 // MLOAD: ofst field_id ty_idx kid0 kid1 00736 // ISTORE: ofst field_id ty_idx kid0 kid1 00737 // PSTORE: ofst field_id ty_idx kid0 kid1 00738 // MSTORE: ofst field_id ty_idx kid0 kid1 kid2 00739 // ILOADX: ty_idx1 ty_idx2 kid0 kid1 00740 // ISTOREX: ty_idx kid0 kid1 kid2 00741 00742 TY_IDX ty_idx1 = WN_ty(wn); 00743 00744 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00745 00746 sos << BegList; // WN_ATTRS 00747 if (opr == OPR_ILOAD || opr == OPR_MLOAD || 00748 opr == OPR_ISTORE || opr == OPR_MSTORE || 00749 opr == OPR_PSTORE) { 00750 WN_OFFSET ofst = WN_load_offset(wn); 00751 UINT fldid = WN_field_id(wn); 00752 sos << Atom(ofst) << Atom(fldid); 00753 } 00754 sos << GenSexpTyUse(ty_idx1); 00755 if (opr == OPR_ILOAD || opr == OPR_ILOADX) { 00756 TY_IDX ty_idx2 = WN_load_addr_ty(wn); 00757 sos << GenSexpTyUse(ty_idx2); 00758 } 00759 sos << EndList << EndLine; 00760 00761 TranslateWNChildren(sos, wn); // KIDs 00762 sos << EndList; 00763 00764 return whirl2sexp::good; 00765 } 00766 00767 //*************************************************************************** 00768 // Array Operators (N-ary Operations) 00769 //*************************************************************************** 00770 00771 whirl2sexp::status 00772 whirl2sexp::xlate_ARRAYx(sexp::ostream& sos, WN* wn) 00773 { 00774 OPERATOR opr = WN_operator(wn); 00775 FORTTK_ASSERT(opr == OPR_ARRAY || opr == OPR_ARRAYEXP || 00776 opr == OPR_ARRSECTION, fortTkSupport::Diagnostics::UnexpectedInput); 00777 00778 // N.B.: WHIRL indices are 0-based and memory layout is row-major 00779 // (right-most index represents contiguous elements). 00780 // In contrast, Fortran indices are 1-based and memory layout is 00781 // column-major (left-most index represents contiguous elements). 00782 // To convert WHIRL indices into a Fortran index expression, reverse 00783 // their order and denormalize to base 1. 00784 00785 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00786 sos << BegList; // WN_ATTRS 00787 if (opr == OPR_ARRAY || opr == OPR_ARRSECTION) { 00788 WN_ESIZE sz = WN_element_size(wn); 00789 sos << Atom(sz); 00790 } 00791 sos << EndList << EndLine; 00792 TranslateWNChildren(sos, wn); // KIDs 00793 sos << EndList; 00794 00795 return whirl2sexp::good; 00796 } 00797 00798 00799 //*************************************************************************** 00800 // Type Conversion 00801 //*************************************************************************** 00802 00803 whirl2sexp::status 00804 whirl2sexp::xlate_CVT_CVTL(sexp::ostream& sos, WN* wn) 00805 { 00806 OPERATOR opr = WN_operator(wn); 00807 FORTTK_ASSERT(opr == OPR_CVT || opr == OPR_CVTL, fortTkSupport::Diagnostics::UnexpectedInput); 00808 00809 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00810 sos << BegList; // WN_ATTRS 00811 if (opr == OPR_CVTL) { 00812 INT16 cvtlbits = WN_cvtl_bits(wn); 00813 sos << Atom(cvtlbits); 00814 } 00815 sos << EndList << EndLine; 00816 TranslateWN(sos, WN_kid0(wn)); 00817 sos << EndList; 00818 00819 return whirl2sexp::good; 00820 } 00821 00822 00823 whirl2sexp::status 00824 whirl2sexp::xlate_TAS(sexp::ostream& sos, WN* wn) 00825 { 00826 FORTTK_ASSERT(WN_operator(wn) == OPR_TAS, fortTkSupport::Diagnostics::UnexpectedInput); 00827 00828 TY_IDX ty_idx = WN_ty(wn); 00829 00830 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00831 sos << BegList << GenSexpTyUse(ty_idx) << EndList; // WN_ATTRS 00832 TranslateWN(sos, WN_kid0(wn)); 00833 sos << EndList; 00834 00835 return whirl2sexp::good; 00836 } 00837 00838 00839 //*************************************************************************** 00840 // Leaf (Other) 00841 //*************************************************************************** 00842 00843 whirl2sexp::status 00844 whirl2sexp::xlate_INTCONST(sexp::ostream& sos, WN* wn) 00845 { 00846 FORTTK_ASSERT(WN_operator(wn) == OPR_INTCONST, fortTkSupport::Diagnostics::UnexpectedInput); 00847 00848 INT64 val = WN_const_val(wn); 00849 00850 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00851 sos << BegList << Atom(val) << EndList; // WN_ATTRS 00852 sos << EndList; 00853 00854 return whirl2sexp::good; 00855 } 00856 00857 00858 whirl2sexp::status 00859 whirl2sexp::xlate_CONST(sexp::ostream& sos, WN* wn) 00860 { 00861 FORTTK_ASSERT(WN_operator(wn) == OPR_CONST, fortTkSupport::Diagnostics::UnexpectedInput); 00862 00863 ST_IDX st_idx = WN_st_idx(wn); 00864 00865 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00866 sos << BegList << GenSexpSymRef(st_idx) << EndList; // WN_ATTRS 00867 sos << EndList; 00868 00869 return whirl2sexp::good; 00870 } 00871 00872 00873 //*************************************************************************** 00874 // Expression Operators: Unary Operations 00875 //*************************************************************************** 00876 00877 whirl2sexp::status 00878 whirl2sexp::xlate_UnaryOp(sexp::ostream& sos, WN* wn) 00879 { 00880 OPERATOR opr = WN_operator(wn); 00881 FORTTK_ASSERT(WN_kid_count(wn) == 1, 00882 fortTkSupport::Diagnostics::UnexpectedInput << OPERATOR_name(opr)); 00883 00884 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00885 sos << BegList << EndList << EndLine; // WN_ATTRS 00886 TranslateWN(sos, WN_kid0(wn)); // KID 0 00887 sos << EndList; 00888 00889 return whirl2sexp::good; 00890 } 00891 00892 //*************************************************************************** 00893 // structure field access 00894 //*************************************************************************** 00895 00896 whirl2sexp::status 00897 whirl2sexp::xlate_STRCTFLD(sexp::ostream& sos, WN* wn) 00898 { 00899 OPERATOR opr = WN_operator(wn); 00900 FORTTK_ASSERT(opr == OPR_STRCTFLD, 00901 fortTkSupport::Diagnostics::UnexpectedInput); 00902 00903 FORTTK_ASSERT(WN_kid_count(wn) == 1, 00904 fortTkSupport::Diagnostics::UnexpectedInput << OPERATOR_name(opr)); 00905 00906 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00907 { 00908 // get the attributes 00909 TY_IDX ty_idx1 = WN_load_addr_ty(wn); // the type of the structure 00910 TY_IDX ty_idx2 = WN_ty(wn); // the type of the field being accessed 00911 UINT fldid = WN_field_id(wn); // the field_id of the field 00912 // put them in the list 00913 sos << BegList; 00914 sos << GenSexpTyUse(ty_idx1); 00915 sos << GenSexpTyUse(ty_idx2); 00916 sos << Atom(fldid); 00917 sos << EndList << EndLine; 00918 TranslateWNChildren(sos, wn); 00919 } 00920 sos << EndList; 00921 return whirl2sexp::good; 00922 } 00923 00924 whirl2sexp::status 00925 whirl2sexp::xlate_PARM(sexp::ostream& sos, WN* wn) 00926 { 00927 FORTTK_ASSERT(WN_operator(wn) == OPR_PARM, fortTkSupport::Diagnostics::UnexpectedInput); 00928 00929 UINT32 flg = WN_parm_flag(wn); 00930 TY_IDX ty_idx = WN_ty(wn); 00931 00932 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00933 sos << BegList // WN_ATTRS 00934 << GenSexpOpaqueFlg(flg) << GenSexpTyUse(ty_idx); 00935 if (wn->u3.ty_fields.ty) { // hack for keyword call 00936 sos << GenSexpSymRef(wn->u3.ty_fields.ty); 00937 } 00938 sos << EndList << EndLine; 00939 TranslateWN(sos, WN_kid0(wn)); // KID 0 00940 sos << EndList; 00941 00942 return whirl2sexp::good; 00943 } 00944 00945 00946 whirl2sexp::status 00947 whirl2sexp::xlate_ALLOCA(sexp::ostream& sos, WN* wn) 00948 { 00949 FORTTK_ASSERT(WN_operator(wn) == OPR_ALLOCA, fortTkSupport::Diagnostics::UnexpectedInput); 00950 FORTTK_DIE(fortTkSupport::Diagnostics::Unimplemented); 00951 return whirl2sexp::good; 00952 } 00953 00954 00955 //*************************************************************************** 00956 // Expression Operators: Binary Operations 00957 //*************************************************************************** 00958 00959 whirl2sexp::status 00960 whirl2sexp::xlate_BinaryOp(sexp::ostream& sos, WN* wn) 00961 { 00962 OPERATOR opr = WN_operator(wn); 00963 FORTTK_ASSERT(WN_kid_count(wn) == 2, 00964 fortTkSupport::Diagnostics::UnexpectedInput << OPERATOR_name(opr)); 00965 00966 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00967 sos << BegList << EndList << EndLine; // WN_ATTRS 00968 TranslateWNChildren(sos, wn); // KIDs 00969 sos << EndList; 00970 00971 return whirl2sexp::good; 00972 } 00973 00974 00975 //*************************************************************************** 00976 // Expression Operators: Ternary Operations; N-ary Operations 00977 //*************************************************************************** 00978 00979 whirl2sexp::status 00980 whirl2sexp::xlate_TernaryOp(sexp::ostream& sos, WN* wn) 00981 { 00982 OPERATOR opr = WN_operator(wn); 00983 FORTTK_ASSERT(WN_kid_count(wn) == 3, 00984 fortTkSupport::Diagnostics::UnexpectedInput << OPERATOR_name(opr)); 00985 00986 sos << BegList << GenSexpWNOpr(wn); // WN_OPR 00987 sos << BegList << EndList << EndLine; // WN_ATTRS 00988 TranslateWNChildren(sos, wn); // KIDs 00989 sos << EndList; 00990 00991 return whirl2sexp::good; 00992 } 00993 00994 00995 //*************************************************************************** 00996 // WNXlationTable 00997 //*************************************************************************** 00998 00999 whirl2sexp::status 01000 whirl2sexp::xlate_unknown(sexp::ostream& sos, WN* wn) 01001 { 01002 // Warn about opcodes we cannot translate, but keep translating. 01003 OPERATOR opr = WN_operator(wn); 01004 01005 FORTTK_DEVMSG(0, fortTkSupport::Diagnostics::UnexpectedOpr << OPERATOR_name(opr)); 01006 sos << BegComment << "*** Unknown WHIRL operator: " << OPERATOR_name(opr) 01007 << " ***" << EndComment; 01008 01009 return whirl2sexp::good; 01010 } 01011 01012 01013 #define TABLE_SZ (OPERATOR_LAST + 1) 01014 #define INIT_TABLE_SZ \ 01015 (sizeof(WNXlationTable::initTable) / sizeof(WNXlationTable::InitEntry)) 01016 01017 01018 bool WNXlationTable::initialized = false; 01019 01020 WNXlationTable::Handler WNXlationTable::table[TABLE_SZ]; 01021 unsigned int WNXlationTable::tableSz = TABLE_SZ; 01022 01023 WNXlationTable::InitEntry WNXlationTable::initTable[] = { 01024 01025 // Note: Organization generally corresponds to that in 01026 // Open64/documentation/whirl.tex 01027 01028 // Structured control flow 01029 { OPR_FUNC_ENTRY, &xlate_FUNC_ENTRY }, 01030 { OPR_BLOCK, &xlate_BLOCK }, 01031 { OPR_REGION, &xlate_REGION }, 01032 { OPR_DO_LOOP, &xlate_structured_cf }, 01033 { OPR_DO_WHILE, &xlate_structured_cf }, 01034 { OPR_WHILE_DO, &xlate_structured_cf }, 01035 { OPR_IF, &xlate_structured_cf }, 01036 01037 // Other control flow 01038 { OPR_IMPLIED_DO, &xlate_IMPLIED_DO }, 01039 { OPR_GOTO, &xlate_GOTOx_LABEL }, 01040 { OPR_GOTO_OUTER_BLOCK, &xlate_GOTOx_LABEL }, 01041 { OPR_SWITCH, &xlate_multiBR }, 01042 { OPR_CASEGOTO, &xlate_CASEGOTO }, 01043 { OPR_COMPGOTO, &xlate_multiBR }, 01044 { OPR_AGOTO, &xlate_AGOTO }, 01045 { OPR_REGION_EXIT, &xlate_GOTOx_LABEL }, 01046 { OPR_ALTENTRY, &xlate_ALTENTRY }, 01047 { OPR_TRUEBR, &xlate_condBR }, 01048 { OPR_FALSEBR, &xlate_condBR }, 01049 { OPR_RETURN, &xlate_RETURNx }, 01050 { OPR_RETURN_VAL, &xlate_RETURNx }, 01051 { OPR_LABEL, &xlate_GOTOx_LABEL }, 01052 01053 // Statements: Calls 01054 { OPR_CALL, &xlate_xCALL }, 01055 { OPR_ICALL, &xlate_xCALL }, 01056 { OPR_VFCALL, &xlate_xCALL }, 01057 { OPR_PICCALL, &xlate_xCALL }, 01058 { OPR_INTRINSIC_CALL, &xlate_xCALL }, 01059 { OPR_IO, &xlate_IO }, 01060 01061 // Statements: Other 01062 { OPR_EVAL, &xlate_misc_stmt }, 01063 { OPR_PRAGMA, &xlate_xPRAGMA }, 01064 { OPR_XPRAGMA, &xlate_xPRAGMA }, 01065 { OPR_PREFETCH, &xlate_misc_stmt }, 01066 { OPR_PREFETCHX, &xlate_misc_stmt }, 01067 { OPR_COMMENT, &xlate_misc_stmt }, 01068 { OPR_TRAP, &xlate_misc_stmt }, 01069 { OPR_ASSERT, &xlate_misc_stmt }, 01070 { OPR_AFFIRM, &xlate_misc_stmt }, 01071 { OPR_FORWARD_BARRIER, &xlate_misc_stmt }, 01072 { OPR_BACKWARD_BARRIER, &xlate_misc_stmt }, 01073 { OPR_DEALLOCA, &xlate_misc_stmt }, 01074 01075 { OPR_USE, &xlate_misc_stmt }, 01076 { OPR_NAMELIST, &xlate_misc_stmt }, 01077 { OPR_IMPLICIT_BND, &xlate_misc_stmt }, 01078 { OPR_NULLIFY, &xlate_misc_stmt }, 01079 { OPR_INTERFACE, &xlate_misc_stmt }, 01080 { OPR_ARRAY_CONSTRUCT, &xlate_misc_stmt }, 01081 01082 // Memory Access (or assignment and variable references) 01083 { OPR_LDA, &xlate_LDA_LDMA }, // Leaf 01084 { OPR_LDMA, &xlate_LDA_LDMA }, // Leaf 01085 { OPR_IDNAME, &xlate_IDNAME }, // Leaf; like a mem-ref 01086 { OPR_LDID, &xlate_LDID_STID }, 01087 { OPR_STID, &xlate_LDID_STID }, 01088 { OPR_ILOAD, &xlate_xLOADx_xSTOREx }, 01089 { OPR_ILOADX, &xlate_xLOADx_xSTOREx }, 01090 { OPR_MLOAD, &xlate_xLOADx_xSTOREx }, 01091 01092 { OPR_ISTORE, &xlate_xLOADx_xSTOREx }, 01093 { OPR_ISTOREX, &xlate_xLOADx_xSTOREx }, 01094 { OPR_MSTORE, &xlate_xLOADx_xSTOREx }, 01095 01096 { OPR_PSTID, &xlate_LDID_STID }, // pointer version of STID 01097 { OPR_PSTORE, &xlate_xLOADx_xSTOREx },// pointer version of STORE 01098 01099 // Type conversion 01100 { OPR_CVT, &xlate_CVT_CVTL }, 01101 { OPR_CVTL, &xlate_CVT_CVTL }, 01102 { OPR_TAS, &xlate_TAS }, 01103 01104 // Expressions: Unary operations 01105 { OPR_INTCONST, &xlate_INTCONST }, // Leaf 01106 { OPR_CONST, &xlate_CONST }, // Leaf 01107 01108 { OPR_NEG, &xlate_UnaryOp }, 01109 { OPR_ABS, &xlate_UnaryOp }, 01110 { OPR_SQRT, &xlate_UnaryOp }, 01111 { OPR_RSQRT, &xlate_UnaryOp }, 01112 { OPR_RECIP, &xlate_UnaryOp }, 01113 { OPR_REALPART, &xlate_UnaryOp }, // OPR_FIRSTPART 01114 { OPR_IMAGPART, &xlate_UnaryOp }, // OPR_SECONDPART 01115 { OPR_PAREN, &xlate_UnaryOp }, 01116 { OPR_RND, &xlate_UnaryOp }, 01117 { OPR_TRUNC, &xlate_UnaryOp }, 01118 { OPR_CEIL, &xlate_UnaryOp }, 01119 { OPR_FLOOR, &xlate_UnaryOp }, 01120 { OPR_BNOT, &xlate_UnaryOp }, 01121 { OPR_LNOT, &xlate_UnaryOp }, 01122 // FIXME: LOWPART, HIGHPART, MINPART, MAXPART, ILDA, EXTRACT_BITS 01123 // structure field access: 01124 { OPR_STRCTFLD, &xlate_STRCTFLD }, 01125 // parameter: 01126 { OPR_PARM, &xlate_PARM }, 01127 // FIXME: ASM_INPUT 01128 { OPR_ALLOCA, &xlate_ALLOCA }, 01129 01130 // Expressions: Binary operations 01131 { OPR_COMPLEX, &xlate_BinaryOp }, // OPR_PAIR 01132 { OPR_ADD, &xlate_BinaryOp }, 01133 { OPR_SUB, &xlate_BinaryOp }, 01134 { OPR_MPY, &xlate_BinaryOp }, 01135 // FIXME: HIGHMPY, XMPY 01136 { OPR_DIV, &xlate_BinaryOp }, 01137 { OPR_MOD, &xlate_BinaryOp }, 01138 { OPR_REM, &xlate_BinaryOp }, 01139 // FIXME: DIVREM 01140 { OPR_MAX, &xlate_BinaryOp }, 01141 { OPR_MIN, &xlate_BinaryOp }, 01142 // FIXME: MINMAX 01143 { OPR_EQ, &xlate_BinaryOp }, 01144 { OPR_NE, &xlate_BinaryOp }, 01145 { OPR_GE, &xlate_BinaryOp }, 01146 { OPR_GT, &xlate_BinaryOp }, 01147 { OPR_LE, &xlate_BinaryOp }, 01148 { OPR_LT, &xlate_BinaryOp }, 01149 { OPR_BAND, &xlate_BinaryOp }, 01150 { OPR_BIOR, &xlate_BinaryOp }, 01151 { OPR_BNOR, &xlate_BinaryOp }, 01152 { OPR_BXOR, &xlate_BinaryOp }, 01153 { OPR_LAND, &xlate_BinaryOp }, 01154 { OPR_LIOR, &xlate_BinaryOp }, 01155 { OPR_CAND, &xlate_BinaryOp }, 01156 { OPR_CIOR, &xlate_BinaryOp }, 01157 { OPR_SHL, &xlate_BinaryOp }, 01158 { OPR_ASHR, &xlate_BinaryOp }, 01159 { OPR_LSHR, &xlate_BinaryOp }, 01160 // FIXME: COMPOSE_BITS, RROTATE, COMMA, RCOMMA 01161 01162 // Expressions: Ternary operations 01163 { OPR_SELECT, &xlate_TernaryOp }, 01164 // FIXME: CSELECT 01165 { OPR_MADD, &xlate_TernaryOp }, 01166 { OPR_MSUB, &xlate_TernaryOp }, 01167 { OPR_NMADD, &xlate_TernaryOp }, 01168 { OPR_NMSUB, &xlate_TernaryOp }, 01169 01170 // Expressions: N-ary operations 01171 { OPR_ARRAY, &xlate_ARRAYx }, 01172 { OPR_INTRINSIC_OP, &xlate_xCALL }, 01173 { OPR_IO_ITEM, &xlate_IO_ITEM }, 01174 { OPR_TRIPLET, &xlate_TernaryOp }, 01175 { OPR_SRCTRIPLET, &xlate_TernaryOp }, 01176 { OPR_ARRAYEXP, &xlate_ARRAYx }, 01177 { OPR_ARRSECTION, &xlate_ARRAYx }, 01178 { OPR_WHERE, &xlate_TernaryOp }, 01179 01180 01181 { OPERATOR_UNKNOWN, &xlate_unknown } // just for convenience 01182 }; 01183 01184 unsigned int WNXlationTable::initTableSz = INIT_TABLE_SZ; 01185 01186 #undef TABLE_SZ 01187 #undef INIT_TABLE_SZ 01188 01189 01190 WNXlationTable::WNXlationTable() 01191 { 01192 // Initialize table with default handler 01193 for (int i = 0; i < tableSz; ++i) { 01194 table[i] = &xlate_unknown; 01195 } 01196 01197 // Initialize the table using 'initTable' 01198 for (int i = 0; i < initTableSz; ++i) { 01199 table[initTable[i].opr] = initTable[i].fn; 01200 } 01201 01202 initialized = true; // could use to this initialize on demand 01203 } 01204 01205 WNXlationTable::~WNXlationTable() 01206 { 01207 } 01208