IntrinsicXlationTable.cxx

Go to the documentation of this file.
00001 // -*-Mode: C++;-*-
00002 // $Header: /Volumes/cvsrep/developer/OpenADFortTk/src/lib/support/IntrinsicXlationTable.cxx,v 1.28 2006/05/12 16:12:22 utke Exp $
00003 
00004 #include <stdlib.h>  
00005 #include <algorithm> 
00006 
00007 
00008 #include "IntrinsicXlationTable.h"
00009 #include "Open64IRInterface/wn_attr.h"
00010 #include "Diagnostics.h"
00011 
00012 namespace fortTkSupport { 
00013 
00014   IntrinsicXlationTable::Entry IntrinsicXlationTable::ourTable[] = {
00015 
00016     // -------------------------------------------------------
00017     // WHIRL calls, expressions and intrinsics that correspond to XAIF
00018     // Intrinsics.  
00019     //
00020     // For OPR_INTRINSIC_OP, the WHIRL string is the INTRINSIC_basename()
00021     // (cf. wintrinsic.h, wutil.cxx)
00022     // -------------------------------------------------------
00023 
00024     // Common mathematical functions
00025     { { WNExpr,     OPR_NEG,          NULL,      1, 0 }, { XAIFIntrin, "minus_scal",                NULL,            1 } },
00026     { { WNExpr,     OPR_ADD,          NULL,      2, 0 }, { XAIFIntrin, "add_scal_scal",             NULL,            2 } },
00027     { { WNExpr,     OPR_SUB,          NULL,      2, 0 }, { XAIFIntrin, "sub_scal_scal",             NULL,            2 } },
00028     { { WNExpr,     OPR_MPY,          NULL,      2, 0 }, { XAIFIntrin, "mul_scal_scal",             NULL,            2 } },
00029     { { WNExpr,     OPR_DIV,          NULL,      2, 0 }, { XAIFIntrin, "div_scal_scal",             NULL,            2 } }, 
00030     { { WNCall,     OPR_CALL,         "SQRT",    1, 0 }, { XAIFIntrin, "sqrt_scal",                 "0_SQRT",        1 } },
00031     { { WNCall,     OPR_CALL,         "DSQRT",   1, 0 }, { XAIFIntrin, "sqrt_scal",                 "1_DSQRT",       1 } },
00032     { { WNExpr,     OPR_SQRT,         NULL,      1, 0 }, { XAIFIntrin, "sqrt_scal",                 "2_SQRT",        1 } }, 
00033     { { WNCall,     OPR_CALL,         "SUM",     1, 0 }, { XAIFIntrin, "sum_arr",                   NULL,            1 } }, 
00034     // modulo/remainder
00035     { { WNExpr,     OPR_MOD,          NULL,      2, 0 }, { XAIFIntrin, "bogus_modulo_scal_scal",    "0_MODULO",      2 } }, 
00036     { { WNCall,     OPR_CALL,         "MODULO",  2, 0 }, { XAIFIntrin, "bogus_modulo_scal_scal",    "1_MODULO",      2 } }, 
00037     { { WNExpr,     OPR_REM,          NULL,      2, 0 }, { XAIFIntrin, "mod_scal_scal",             "0_MOD",         2 } },
00038     { { WNIntrinOp, OPR_INTRINSIC_OP, "AMOD",    2, 0 }, { XAIFIntrin, "mod_scal_scal",             "1_AMOD",        2 } },
00039     { { WNIntrinOp, OPR_INTRINSIC_OP, "DMOD",    2, 0 }, { XAIFIntrin, "mod_scal_scal",             "2_DMOD",        2 } }, 
00040     { { WNCall,     OPR_CALL,         "MOD",     2, 0 }, { XAIFIntrin, "mod_scal_scal",             "3_MOD",         2 } }, 
00041     // trigonometric
00042     { { WNCall,     OPR_CALL,         "SIN",     1, 0 }, { XAIFIntrin, "sin_scal",                  "0_SIN",         1 } },
00043     { { WNCall,     OPR_CALL,         "DSIN",    1, 0 }, { XAIFIntrin, "sin_scal",                  "1_DSIN",        1 } },
00044     { { WNCall,     OPR_CALL,         "COS",     1, 0 }, { XAIFIntrin, "cos_scal",                  "0_COS",         1 } },
00045     { { WNCall,     OPR_CALL,         "DCOS",    1, 0 }, { XAIFIntrin, "cos_scal",                  "1_DCOS",        1 } },
00046     { { WNCall,     OPR_CALL,         "TAN",     1, 0 }, { XAIFIntrin, "tan_scal",                  "0_TAN",         1 } },
00047     { { WNCall,     OPR_CALL,         "OAD_TAN", 1, 0 }, { XAIFIntrin, "oad_tan_scal",              "0_TAN",         1 } },
00048     { { WNCall,     OPR_CALL,         "DTAN",    1, 0 }, { XAIFIntrin, "tan_scal",                  "1_DTAN",        1 } }, 
00049     { { WNCall,     OPR_CALL,         "ASIN",    1, 0 }, { XAIFIntrin, "arcsin_scal",               "0_ASIN",        1 } },
00050     { { WNCall,     OPR_CALL,         "ACOS",    1, 0 }, { XAIFIntrin, "arccos_scal",               "0_ACOS",        1 } },
00051     { { WNCall,     OPR_CALL,         "ATAN",    1, 0 }, { XAIFIntrin, "arctan_scal",               "0_ATAN",        1 } }, 
00052     { { WNCall,     OPR_CALL,         "SINH",    1, 0 }, { XAIFIntrin, "sinh_scal",                 "0_SINH",        1 } },
00053     { { WNCall,     OPR_CALL,         "DSINH",   1, 0 }, { XAIFIntrin, "sinh_scal",                 "1_DSINH",       1 } },
00054     { { WNCall,     OPR_CALL,         "COSH",    1, 0 }, { XAIFIntrin, "cosh_scal",                 "0_COSH",        1 } },
00055     { { WNCall,     OPR_CALL,         "DCOSH",   1, 0 }, { XAIFIntrin, "cosh_scal",                 "1_DCOSH",       1 } },
00056     { { WNCall,     OPR_CALL,         "TANH",    1, 0 }, { XAIFIntrin, "tanh_scal",                 "0_TANH",        1 } },
00057     { { WNCall,     OPR_CALL,         "DTANH",   1, 0 }, { XAIFIntrin, "tanh_scal",                 "1_DTANH",       1 } },
00058     // exp/log
00059     { { WNCall,     OPR_CALL,         "EXP",     1, 0 }, { XAIFIntrin, "exp_scal",                  "0_EXP",         1 } },
00060     { { WNCall,     OPR_CALL,         "DEXP",    1, 0 }, { XAIFIntrin, "exp_scal",                  "1_DEXP",        1 } },
00061     { { WNCall,     OPR_CALL,         "LOG",     1, 0 }, { XAIFIntrin, "ln_scal",                   "0_LOG",         1 } },
00062     { { WNCall,     OPR_CALL,         "DLOG",    1, 0 }, { XAIFIntrin, "ln_scal",                   "1_DLOG",        1 } }, 
00063     { { WNCall,     OPR_CALL,         "ALOG",    1, 0 }, { XAIFIntrin, "ln_scal",                   "2_ALOG",        1 } }, 
00064     { { WNCall,     OPR_CALL,         "LOG10",   1, 0 }, { XAIFIntrin, "log10",                     NULL,            1 } }, 
00065     { { WNIntrinOp, OPR_INTRINSIC_OP, "EXPEXPR", 2, 0 }, { XAIFIntrin, "pow_scal_scal",             NULL,            2 } },
00066     // string operations
00067     { { WNIntrinOp, OPR_INTRINSIC_OP, "CEQEXPR", 2, 0 }, { XAIFIntrin, "string_eq_scal_scal",       NULL,            2 } },
00068     { { WNIntrinOp, OPR_INTRINSIC_OP, "CNEEXPR", 2, 0 }, { XAIFIntrin, "bogus_string_ne_scal_scal", NULL,            2 } },
00069     { { WNIntrinOp, OPR_INTRINSIC_OP, "CGEEXPR", 2, 0 }, { XAIFIntrin, "bogus_string_ge_scal_scal", NULL,            2 } },
00070     { { WNIntrinOp, OPR_INTRINSIC_OP, "CGTEXPR", 2, 0 }, { XAIFIntrin, "bogus_string_gt_scal_scal", NULL,            2 } },
00071     { { WNIntrinOp, OPR_INTRINSIC_OP, "CLEEXPR", 2, 0 }, { XAIFIntrin, "bogus_string_le_scal_scal", NULL,            2 } },
00072     { { WNIntrinOp, OPR_INTRINSIC_OP, "CLTEXPR", 2, 0 }, { XAIFIntrin, "bogus_string_lt_scal_scal", NULL,            2 } },
00073     { { WNIntrinOp, OPR_INTRINSIC_OP, "LEN",     1, 0 }, { XAIFIntrin, "len",                       "0_LEN_OP",      1 } },
00074     { { WNCall,     OPR_CALL,         "LEN",     1, 0 }, { XAIFIntrin, "len",                       "1_LEN_CALL",    1 } },
00075     { { WNCall,     OPR_CALL,         "TRIM",    1, 0 }, { XAIFIntrin, "trim",                      NULL,            1 } },
00076     // Rounding, conversion
00077     { { WNExpr,     OPR_ABS,          NULL,      1, 0 }, { XAIFIntrin, "abs_scal",                  "0_ABS",         1 } },
00078     { { WNCall,     OPR_CALL,         "ABS",     1, 0 }, { XAIFIntrin, "abs_scal",                  "1_ABS",         1 } },
00079     { { WNCall,     OPR_CALL,         "DABS",    1, 0 }, { XAIFIntrin, "abs_scal",                  "2_DABS",        1 } },
00080     { { WNCall,     OPR_CALL,         "IABS",    1, 0 }, { XAIFIntrin, "iabs_scal",                 "0_IABS",        1 } }, 
00081     { { WNCall,     OPR_CALL,         "SIGN",    2, 0 }, { XAIFIntrin, "sign_scal_scal",            "0_SIGN",        2 } }, 
00082     { { WNCall,     OPR_CALL,         "DSIGN",   2, 0 }, { XAIFIntrin, "sign_scal_scal",            "1_SIGN",        2 } }, 
00083     { { WNExpr,     OPR_RND,          NULL,      1, 0 }, { XAIFIntrin, "bogus_round_scal",          NULL,            1 } },
00084     { { WNExpr,     OPR_TRUNC,        NULL,      1, 0 }, { XAIFIntrin, "int_scal",                  "0_INT",         1 } },
00085     { { WNCall,     OPR_CALL,         "INT",     1, 0 }, { XAIFIntrin, "int_scal",                  "1_INT",         1 } },
00086     { { WNCall,     OPR_CALL,         "NINT",    1, 0 }, { XAIFIntrin, "nint_scal",                 NULL,            1 } },
00087     { { WNExpr,     OPR_CEIL,         NULL,      1, 0 }, { XAIFIntrin, "bogus_ceil_scal",           NULL,            1 } },
00088     { { WNExpr,     OPR_FLOOR,        NULL,      1, 0 }, { XAIFIntrin, "bogus_floor_scal",          NULL,            1 } }, 
00089     { { WNCall,     OPR_CALL,         "REAL",    1, 0 }, { XAIFIntrin, "real_scal",                 "0_REAL",        1 } },
00090     { { WNCall,     OPR_CALL,         "FLOAT",   1, 0 }, { XAIFIntrin, "real_scal",                 "1_REAL",        1 } },
00091     { { WNCall,     OPR_CALL,         "DBLE",    1, 0 }, { XAIFIntrin, "real_scal",                 "2_REAL",        1 } }, 
00092     { { WNCall,     OPR_CALL,         "AIMAG",   1, 0 }, { XAIFIntrin, "imag_scal",                 NULL,            1 } }, 
00093     { { WNCall,     OPR_CALL,         "TRANS",   1, 0 }, { XAIFIntrin, "trans_arr",                 NULL,            1 } }, 
00094     { { WNExpr,     OPR_COMPLEX,      NULL,      2, 0 }, { XAIFIntrin, "complex_scal",              NULL,            2 } }, 
00095     // Logical (and bitwise logical) operations 
00096     { { WNExpr,     OPR_BNOT,         NULL,      1, 0 }, { XAIFBoolOp, "b_not",                     NULL,            1 } },
00097     { { WNExpr,     OPR_BAND,         NULL,      2, 0 }, { XAIFBoolOp, "b_and",                     NULL,            2 } },
00098     { { WNExpr,     OPR_BIOR,         NULL,      2, 0 }, { XAIFBoolOp, "b_or",                      NULL,            2 } },
00099     { { WNExpr,     OPR_BXOR,         NULL,      2, 0 }, { XAIFBoolOp, "b_xor",                     NULL,            2 } }, 
00100     { { WNExpr,     OPR_LNOT,         NULL,      1, 0 }, { XAIFBoolOp, "not",                       NULL,            1 } },
00101     { { WNExpr,     OPR_LAND,         NULL,      2, 0 }, { XAIFBoolOp, "and",                       NULL,            2 } },
00102     { { WNExpr,     OPR_LIOR,         NULL,      2, 0 }, { XAIFBoolOp, "or",                        NULL,            2 } },
00103     { { WNExpr,     OPR_CAND,         NULL,      2, 0 }, { XAIFBoolOp, "bogus_cand_scal_scal",      NULL,            2 } },
00104     { { WNExpr,     OPR_CIOR,         NULL,      2, 0 }, { XAIFBoolOp, "bogus_cor_scal_scal",       NULL,            2 } }, 
00105     { { WNExpr,     OPR_EQ,           NULL,      2, 0 }, { XAIFBoolOp, "equal",                     NULL,            2 } },
00106     { { WNExpr,     OPR_NE,           NULL,      2, 0 }, { XAIFBoolOp, "not_equal",                 NULL,            2 } },
00107     { { WNExpr,     OPR_GT,           NULL,      2, 0 }, { XAIFBoolOp, "greater_than",              NULL,            2 } },
00108     { { WNExpr,     OPR_GE,           NULL,      2, 0 }, { XAIFBoolOp, "greater_or_equal",          NULL,            2 } },
00109     { { WNExpr,     OPR_LT,           NULL,      2, 0 }, { XAIFBoolOp, "less_than",                 NULL,            2 } },
00110     { { WNExpr,     OPR_LE,           NULL,      2, 0 }, { XAIFBoolOp, "less_or_equal",             NULL,            2 } }, 
00111     // Misc.
00112     { { WNCall,     OPR_CALL,         "MAXVAL",  1, 0 }, { XAIFIntrin, "maxval",                    NULL,            1 } },
00113     { { WNCall,     OPR_CALL,         "LBOUND",  2, 0 }, { XAIFIntrin, "lbound",                    NULL,            2 } },
00114     { { WNCall,     OPR_CALL,         "UBOUND",  2, 0 }, { XAIFIntrin, "ubound",                    NULL,            2 } },
00115     { { WNCall,     OPR_CALL,         "SIZE",    2, 1 }, { XAIFIntrin, "size",                      NULL,            2 } },
00116     { { WNIntrinOp, OPR_INTRINSIC_OP, "F90INDEX",2, 0 }, { XAIFIntrin, "index",                     NULL,            2 } },
00117     { { WNExpr,     OPR_SHL,           NULL,     2, 0 }, { XAIFIntrin, "bogus_shl_scal_scal",       NULL,            2 } },
00118     { { WNExpr,     OPR_ASHR,          NULL,     2, 0 }, { XAIFIntrin, "bogus_ashr_scal_scal",      NULL,            2 } }, 
00119     { { WNCall,     OPR_CALL,         "PRESENT", 1, 0 }, { XAIFIntrin, "present",                   NULL,            1 } },
00120     { { WNCall,     OPR_CALL,         "ASSOCIATED", 1, 0 }, { XAIFIntrin, "associated",             NULL,            1 } },
00121     { { WNCall,     OPR_CALL,         "ALLOCATED", 1, 0 }, { XAIFIntrin, "allocated",               NULL,            1 } },
00122     // max/min are turned into special subroutine calls by the canonicalizer 
00123     { { WNExpr,     OPR_MAX,           NULL,     2, 0 }, { XAIFIntrin, "bogus_max_scal_scal",       NULL,            2 } },
00124     { { WNExpr,     OPR_MIN,           NULL,     2, 0 }, { XAIFIntrin, "bogus_min_scal_scal",       NULL,            2 } }
00125   
00126   };
00127 
00128   unsigned int IntrinsicXlationTable::ourTableSize = 
00129     (sizeof(IntrinsicXlationTable::ourTable) / sizeof(IntrinsicXlationTable::Entry));
00130 
00131   const std::string IntrinsicXlationTable::toString(const WNOprClass& oprcl) {
00132     std::string retStr;
00133     switch (oprcl) {
00134     case WNCall:     
00135       retStr="WNCall";
00136       break;
00137     case WNIntrinCall:      
00138       retStr="WNIntrinCall";
00139       break;
00140     case WNIntrinOp:      
00141       retStr="WNIntrinOp";
00142       break;
00143     case WNExpr:     
00144       retStr="WNExpr";
00145       break;
00146     default:
00147       FORTTK_DIE("IntrinsicXlationTable::toString: unknown WNOprClass " << (int)oprcl);
00148       break;
00149     }
00150     return retStr; // should never reach
00151   }
00152 
00153   const std::string IntrinsicXlationTable::toString(const XAIFOpr& opr) {
00154     std::string retStr;
00155     switch (opr) {
00156     case XAIFSubCall:        
00157       retStr="XAIFSubCall";
00158       break;
00159     case XAIFFuncCall:          
00160       retStr="XAIFFuncCall";
00161       break;
00162     case XAIFIntrin:            
00163       retStr="XAIFIntrinsic";
00164       break;
00165     case XAIFBoolOp:            
00166       retStr="XAIFBoolOp";
00167       break;
00168     default:
00169       FORTTK_DIE("IntrinsicXlationTable::toString: unknown XAIFOpr "<< (int)opr);
00170       break;
00171     }
00172     return retStr; 
00173   }
00174 
00175   void IntrinsicXlationTable::WHIRLInfo::dump(std::ostream& os) const {
00176     os << "{ " 
00177        << toString(oprcl).c_str() << ", " 
00178        << OPERATOR_name(opr)      << ", "
00179        << ((name) ? name : "<null>") << ", "
00180        << numop 
00181        << " }";
00182   }
00183 
00184   void IntrinsicXlationTable::WHIRLInfo::ddump() const {
00185     dump(std::cerr);
00186   }
00187 
00188   void IntrinsicXlationTable::XAIFInfo::dump(std::ostream& os) const {
00189     os << "{ " 
00190        << toString(opr).c_str() << ", " 
00191        << ((name) ? name : "<null>") << ", " 
00192        << ((key) ? key : "<null>") << ", " 
00193        << numop 
00194        << " }";
00195   }
00196 
00197   void IntrinsicXlationTable::XAIFInfo::ddump() const {
00198     dump(std::cerr);
00199   }
00200 
00201   IntrinsicXlationTable::LtSortedTable::LtSortedTable(TableType aTableType, bool ignoreXaifKey) : 
00202     myTableType(aTableType), 
00203     myIgnoreXaifKeyFlag(ignoreXaifKey) { 
00204   }
00205 
00206   IntrinsicXlationTable::LtSortedTable::~LtSortedTable() { 
00207   }
00208 
00209   bool IntrinsicXlationTable::LtSortedTable:: operator()(const Entry* e1, 
00210                                                          const Entry* e2) const {
00211     if (myTableType == W2X) {
00212       // 1. whirl_info.opr is the primary sorting key
00213       if (e1->whirl_info.opr == e2->whirl_info.opr) {
00214       
00215         // Either 1) both whirl_info.oprcl will be equal or 2) one will
00216         // be 'WNOprClass_UNKNOWN' (the search item)
00217         WNOprClass cl = (e1->whirl_info.oprcl == WNOprClass_UNKNOWN) ? 
00218           e2->whirl_info.oprcl : e1->whirl_info.oprcl;
00219 
00220         switch (cl) {
00221         case WNCall:
00222         case WNIntrinCall:
00223         case WNIntrinOp:
00224           // 2. whirl_info.name is the secondary sorting key
00225           return (strcmp(e1->whirl_info.name, e2->whirl_info.name) < 0);
00226         case WNExpr:
00227           // 2. There is no secondary sorting key
00228           return false; // e1 and e2 are equal
00229         default:
00230           FORTTK_DIE("Internal IntrinsicXlationTable error: Unknown WNOprClass: "
00231                      << cl);
00232         }
00233       } 
00234       else {
00235         return (e1->whirl_info.opr < e2->whirl_info.opr);
00236       }
00237     } 
00238     else if (myTableType == X2W) {
00239       // 1. xaif_info.opr is the primary sorting key
00240       if (e1->xaif_info.opr == e2->xaif_info.opr) {
00241         // 2. xaif_info.name is the secondary sorting key
00242         int cmp = (strcmp(e1->xaif_info.name, e2->xaif_info.name));
00243         if (!myIgnoreXaifKeyFlag && cmp == 0) {
00244           // 3. xaif_info.key, if available, is the tertiary sorting key
00245           if (e1->xaif_info.key && e2->xaif_info.key) {
00246             return (strcmp(e1->xaif_info.key, e2->xaif_info.key) < 0);
00247           }
00248           else if (e1->xaif_info.key) /* && !e2->xaif_info.key */ {
00249             return false; // e1 > e2
00250           }
00251           else if (e2->xaif_info.key) /* && !e1->xaif_info.key */ {
00252             return true; // e1 < e2
00253           }
00254           // fall-through
00255         } 
00256         return (cmp < 0);
00257       } 
00258       else {
00259         return (e1->xaif_info.opr < e2->xaif_info.opr);
00260       }
00261     } 
00262     else {
00263       FORTTK_DIE("Internal IntrinsicXlationTable error: Unknown TableType: " 
00264                  << myTableType);
00265     }
00266   }
00267 
00268   IntrinsicXlationTable::IntrinsicXlationTable(const TableType& aTableType) : 
00269     myTableType(aTableType), 
00270     mySortedTable(SortedTable(ourTableSize)) {
00271     // Initialize it
00272     for (unsigned int i = 0; i < ourTableSize; ++i) {
00273       Entry* e = &ourTable[i];
00274       mySortedTable[i] = e;
00275     }
00276     // Sort it ascendingly
00277     std::sort(mySortedTable.begin(), 
00278               mySortedTable.end(), 
00279               LtSortedTable(myTableType));
00280   }
00281 
00282   IntrinsicXlationTable::~IntrinsicXlationTable() 
00283   { 
00284   }
00285 
00286   IntrinsicXlationTable::XAIFInfoPair::XAIFInfoPair(bool aBoolean,
00287                                                     const IntrinsicXlationTable::XAIFInfo& anXAIFInfo) :
00288     first(aBoolean),
00289     second(anXAIFInfo) { 
00290   }
00291 
00292   IntrinsicXlationTable::XAIFInfoPair IntrinsicXlationTable::findXAIFInfo(OPERATOR opr, 
00293                                                                           const char* name,
00294                                                                           bool mustFind) {
00295     if (myTableType != W2X) 
00296       FORTTK_DIE("IntrinsicXlationTable::findXAIFInfo: wrong TableType"); 
00297     static Entry toFind;
00298     toFind.whirl_info.oprcl = WNOprClass_UNKNOWN;
00299     toFind.whirl_info.opr = opr;
00300     toFind.whirl_info.name = name;
00301     LtSortedTable lt(myTableType);
00302     SortedTableIt it = std::lower_bound(mySortedTable.begin(), 
00303                                         mySortedTable.end(),
00304                                         toFind, lt);
00305     if (it != mySortedTable.end() && !lt(*it, toFind) && !lt(toFind, *it)) {
00306       return XAIFInfoPair(true,const_cast<const XAIFInfo&>((*it)->xaif_info));
00307     } 
00308     if (mustFind)
00309       FORTTK_DIE("IntrinsicXlationTable::findXAIFInfo: unknown opr="
00310                  << OPERATOR_name(opr)
00311                  << ",name="
00312                  << name);
00313     return XAIFInfoPair(false,toFind.xaif_info);
00314   }
00315 
00316   IntrinsicXlationTable::WHIRLInfo* 
00317   IntrinsicXlationTable::findWHIRLInfo(XAIFOpr opr, 
00318                                        const char* name, 
00319                                        const char* key) {
00320     if (myTableType != X2W)
00321       FORTTK_DIE("IntrinsicXlationTable::findWHIRLInfo: wrong TableType"); 
00322     static Entry toFind;  
00323     toFind.xaif_info.opr = opr;
00324     toFind.xaif_info.name = name;
00325     toFind.xaif_info.key = (key && key[0] == '\0') ? NULL : key;
00326     bool ignoreKey = (toFind.xaif_info.key == NULL);
00327     LtSortedTable lt(myTableType, ignoreKey);
00328     SortedTableIt it = std::lower_bound(mySortedTable.begin(), 
00329                                         mySortedTable.end(), 
00330                                         toFind, 
00331                                         lt);
00332     if (it != mySortedTable.end() && !lt(*it, toFind) && !lt(toFind, *it)) {
00333       Entry* foundItem = *it; // may be multiple matches if key is NULL
00334       return &(foundItem->whirl_info);
00335     } 
00336     FORTTK_DIE("IntrinsicXlationTable::findWHIRLInfo: unknown opr="
00337                << toString(opr).c_str()
00338                << ",name="
00339                << name
00340                << ",key="
00341                << key);
00342     return NULL;
00343   }
00344 
00345   class PrintEntry : public std::unary_function<IntrinsicXlationTable::Entry*, void> {
00346   public:
00347     PrintEntry(std::ostream& anOstream, IntrinsicXlationTable::TableType aTableType) : 
00348       myOstream(anOstream), 
00349       myTableType(aTableType) { 
00350     }
00351     ~PrintEntry() { 
00352     }
00353     void operator() (IntrinsicXlationTable::Entry* anEntry) {
00354       if (myTableType == IntrinsicXlationTable::W2X) {
00355         anEntry->whirl_info.dump(myOstream); 
00356         myOstream << " ";
00357         anEntry->xaif_info.dump(myOstream);  
00358         myOstream << std::endl;
00359       } 
00360       else if (myTableType == IntrinsicXlationTable::X2W) {
00361         anEntry->xaif_info.dump(myOstream);  
00362         myOstream << " ";
00363         anEntry->whirl_info.dump(myOstream); 
00364         myOstream << std::endl;
00365       } 
00366       else {
00367         FORTTK_DIE("Internal IntrinsicXlationTable error: Unknown TableType: " 
00368                    << myTableType);
00369       }
00370     }
00371   private:
00372     std::ostream& myOstream;
00373     IntrinsicXlationTable::TableType myTableType;
00374   };
00375 
00376   void IntrinsicXlationTable::dump(std::ostream& os) const {
00377     os << "Begin Intrinsic Table\n";
00378     std::for_each(mySortedTable.begin(), 
00379                   mySortedTable.end(), 
00380                   PrintEntry(os, 
00381                              myTableType));
00382     os << "End Intrinsic Table" << std::endl;
00383   }
00384 
00385   void IntrinsicXlationTable::ddump() const {
00386     dump(std::cerr);
00387   }
00388 
00389 }

Generated on Fri Jul 24 04:29:02 2009 for OpenADFortTk (extended to Open64) by  doxygen 1.5.7.1