| [51587aa] | 1 | // | 
|---|
|  | 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo | 
|---|
|  | 3 | // | 
|---|
|  | 4 | // The contents of this file are covered under the licence agreement in the | 
|---|
|  | 5 | // file "LICENCE" distributed with Cforall. | 
|---|
|  | 6 | // | 
|---|
|  | 7 | // OperatorTable.cc -- | 
|---|
|  | 8 | // | 
|---|
|  | 9 | // Author           : Richard C. Bilson | 
|---|
|  | 10 | // Created On       : Mon May 18 07:44:20 2015 | 
|---|
|  | 11 | // Last Modified By : Peter A. Buhr | 
|---|
| [de62360d] | 12 | // Last Modified On : Tue Jun 23 17:41:14 2015 | 
|---|
|  | 13 | // Update Count     : 5 | 
|---|
| [51587aa] | 14 | // | 
|---|
| [51b73452] | 15 |  | 
|---|
|  | 16 | #include <map> | 
|---|
|  | 17 | #include "OperatorTable.h" | 
|---|
|  | 18 |  | 
|---|
|  | 19 | namespace CodeGen { | 
|---|
| [51587aa] | 20 | namespace { | 
|---|
|  | 21 | const OperatorInfo tableValues[] = { | 
|---|
| [de62360d] | 22 | {       "?[?]",         "",             "_operator_index",                              OT_INDEX                        }, | 
|---|
|  | 23 | {       "?()",          "",             "_operator_call",                               OT_CALL                         }, | 
|---|
|  | 24 | {       "?++",          "++",   "_operator_postincr",                   OT_POSTFIXASSIGN        }, | 
|---|
|  | 25 | {       "?--",          "--",   "_operator_postdecr",                   OT_POSTFIXASSIGN        }, | 
|---|
|  | 26 | {       "*?",           "*",    "_operator_deref",                              OT_PREFIX                       }, | 
|---|
|  | 27 | {       "+?",           "+",    "_operator_unaryplus",                  OT_PREFIX                       }, | 
|---|
|  | 28 | {       "-?",           "-",    "_operator_unaryminus",                 OT_PREFIX                       }, | 
|---|
|  | 29 | {       "~?",           "~",    "_operator_bitnot",                             OT_PREFIX                       }, | 
|---|
|  | 30 | {       "!?",           "!",    "_operator_lognot",                             OT_PREFIX                       }, | 
|---|
|  | 31 | {       "++?",          "++",   "_operator_preincr",                    OT_PREFIXASSIGN         }, | 
|---|
|  | 32 | {       "--?",          "--",   "_operator_predecr",                    OT_PREFIXASSIGN         }, | 
|---|
|  | 33 | {       "?*?",          "*",    "_operator_multiply",                   OT_INFIX                        }, | 
|---|
|  | 34 | {       "?/?",          "/",    "_operator_divide",                             OT_INFIX                        }, | 
|---|
|  | 35 | {       "?%?",          "%",    "_operator_modulus",                    OT_INFIX                        }, | 
|---|
|  | 36 | {       "?+?",          "+",    "_operator_add",                                OT_INFIX                        }, | 
|---|
|  | 37 | {       "?-?",          "-",    "_operator_subtract",                   OT_INFIX                        }, | 
|---|
|  | 38 | {       "?<<?",         "<<",   "_operator_shiftleft",                  OT_INFIX                        }, | 
|---|
|  | 39 | {       "?>>?",         ">>",   "_operator_shiftright",                 OT_INFIX                        }, | 
|---|
|  | 40 | {       "?<?",          "<",    "_operator_less",                               OT_INFIX                        }, | 
|---|
|  | 41 | {       "?>?",          ">",    "_operator_greater",                    OT_INFIX                        }, | 
|---|
|  | 42 | {       "?<=?",         "<=",   "_operator_lessequal",                  OT_INFIX                        }, | 
|---|
|  | 43 | {       "?>=?",         ">=",   "_operator_greaterequal",               OT_INFIX                        }, | 
|---|
|  | 44 | {       "?==?",         "==",   "_operator_equal",                              OT_INFIX                        }, | 
|---|
|  | 45 | {       "?!=?",         "!=",   "_operator_notequal",                   OT_INFIX                        }, | 
|---|
|  | 46 | {       "?&?",          "&",    "_operator_bitand",                             OT_INFIX                        }, | 
|---|
|  | 47 | {       "?^?",          "^",    "_operator_bitxor",                             OT_INFIX                        }, | 
|---|
|  | 48 | {       "?|?",          "|",    "_operator_bitor",                              OT_INFIX                        }, | 
|---|
|  | 49 | {       "?=?",          "=",    "_operator_assign",                             OT_INFIXASSIGN          }, | 
|---|
|  | 50 | {       "?*=?",         "*=",   "_operator_multassign",                 OT_INFIXASSIGN          }, | 
|---|
|  | 51 | {       "?/=?",         "/=",   "_operator_divassign",                  OT_INFIXASSIGN          }, | 
|---|
|  | 52 | {       "?%=?",         "%=",   "_operator_modassign",                  OT_INFIXASSIGN          }, | 
|---|
|  | 53 | {       "?+=?",         "+=",   "_operator_addassign",                  OT_INFIXASSIGN          }, | 
|---|
|  | 54 | {       "?-=?",         "-=",   "_operator_subassign",                  OT_INFIXASSIGN          }, | 
|---|
| [51587aa] | 55 | {       "?<<=?",        "<<=",  "_operator_shiftleftassign",    OT_INFIXASSIGN          }, | 
|---|
|  | 56 | {       "?>>=?",        ">>=",  "_operator_shiftrightassign",   OT_INFIXASSIGN          }, | 
|---|
| [de62360d] | 57 | {       "?&=?",         "&=",   "_operator_bitandassign",               OT_INFIXASSIGN          }, | 
|---|
|  | 58 | {       "?^=?",         "^=",   "_operator_bitxorassign",               OT_INFIXASSIGN          }, | 
|---|
|  | 59 | {       "?|=?",         "|=",   "_operator_bitorassign",                OT_INFIXASSIGN          }, | 
|---|
|  | 60 | {       "&&",           "&&",   "&&",                                                   OT_LABELADDRESS         }, | 
|---|
|  | 61 | {       "0",            "0",    "_constant_zero",                               OT_CONSTANT                     }, | 
|---|
|  | 62 | {       "1",            "1",    "_constant_one",                                OT_CONSTANT                     } | 
|---|
| [51587aa] | 63 | }; | 
|---|
| [51b73452] | 64 |  | 
|---|
| [51587aa] | 65 | const int numOps = sizeof( tableValues ) / sizeof( OperatorInfo ); | 
|---|
| [51b73452] | 66 |  | 
|---|
| [51587aa] | 67 | std::map< std::string, OperatorInfo > table; | 
|---|
| [51b73452] | 68 |  | 
|---|
| [51587aa] | 69 | void initialize() { | 
|---|
|  | 70 | for ( int i = 0; i < numOps; ++i ) { | 
|---|
|  | 71 | table[ tableValues[i].inputName ] = tableValues[i]; | 
|---|
|  | 72 | } // for | 
|---|
|  | 73 | } | 
|---|
|  | 74 | } // namespace | 
|---|
| [51b73452] | 75 |  | 
|---|
| [51587aa] | 76 | bool operatorLookup( std::string funcName, OperatorInfo &info ) { | 
|---|
|  | 77 | static bool init = false; | 
|---|
|  | 78 | if ( ! init ) { | 
|---|
|  | 79 | initialize(); | 
|---|
|  | 80 | } // if | 
|---|
|  | 81 | std::map< std::string, OperatorInfo >::const_iterator i = table.find( funcName ); | 
|---|
|  | 82 | if ( i == table.end() ) { | 
|---|
|  | 83 | return false; | 
|---|
|  | 84 | } else { | 
|---|
|  | 85 | info = i->second; | 
|---|
|  | 86 | return true; | 
|---|
|  | 87 | } // if | 
|---|
|  | 88 | } | 
|---|
| [51b73452] | 89 | } // namespace CodeGen | 
|---|
| [51587aa] | 90 |  | 
|---|
|  | 91 | // Local Variables: // | 
|---|
|  | 92 | // tab-width: 4 // | 
|---|
|  | 93 | // mode: c++ // | 
|---|
|  | 94 | // compile-command: "make install" // | 
|---|
|  | 95 | // End: // | 
|---|