This machine mirrors various open-source projects.
20 Gbit/s uplink.
If there are any issues or you want another project mirrored, please contact
mirror-service -=AT=- netcologne DOT de !
00001 //===-- basic/PrimitiveOps.h ---------------------------------- -*- C++ -*-===// 00002 // 00003 // This file is distributed under the MIT license. See LICENSE.txt for details. 00004 // 00005 // Copyright (C) 2009-2010, Stephen Wilson 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 #ifndef COMMA_BASIC_PRIMITIVEOPS_HDR_GUARD 00010 #define COMMA_BASIC_PRIMITIVEOPS_HDR_GUARD 00011 00012 #include "llvm/ADT/StringRef.h" 00013 00014 namespace comma { 00015 00016 class IdentifierInfo; 00017 00018 namespace primitive_ops { 00019 00020 enum PrimitiveID { 00021 00022 NotPrimitive, 00023 00024 // 00025 // Binary arithmetic operators. 00026 // 00027 ADD_op, 00028 SUB_op, 00029 MUL_op, 00030 DIV_op, 00031 MOD_op, 00032 REM_op, 00033 POW_op, 00034 00035 // 00036 // Binary predicates. 00037 // 00038 EQ_op, 00039 NE_op, 00040 LT_op, 00041 GT_op, 00042 LE_op, 00043 GE_op, 00044 LOR_op, 00045 LAND_op, 00046 LXOR_op, 00047 00048 // 00049 // Unary predicates. 00050 // 00051 LNOT_op, 00052 00053 // 00054 // Unary arithmetic operators. 00055 POS_op, 00056 NEG_op, 00057 00058 // 00059 // Miscellaneous operators. 00060 // 00061 ENUM_op, 00062 00063 // Tags for fast matching of primitive ID's. 00064 FIRST_PREDICATE_OP = EQ_op, 00065 LAST_PREDICATE_OP = LNOT_op, 00066 00067 FIRST_PRIMITIVE_OP = ADD_op, 00068 LAST_PRIMITIVE_OP = ENUM_op, 00069 00070 FIRST_BINARY_OP = ADD_op, 00071 LAST_BINARY_OP = LXOR_op, 00072 00073 FIRST_UNARY_OP = LNOT_op, 00074 LAST_UNARY_OP = NEG_op 00075 }; 00076 00078 inline bool denotesOperator(PrimitiveID ID) { 00079 return (FIRST_PRIMITIVE_OP <= ID) && (ID <= LAST_PRIMITIVE_OP); 00080 } 00081 00083 inline bool denotesPredicateOp(PrimitiveID ID) { 00084 return (FIRST_PREDICATE_OP <= ID) && (ID <= LAST_PREDICATE_OP); 00085 } 00086 00088 inline bool denotesUnaryOp(PrimitiveID ID) { 00089 return (FIRST_UNARY_OP <= ID) && (ID <= LAST_UNARY_OP); 00090 } 00091 00093 inline bool denotesBinaryOp(PrimitiveID ID) { 00094 return (FIRST_BINARY_OP <= ID) && (ID <= LAST_BINARY_OP); 00095 } 00096 00098 bool denotesBinaryOp(const llvm::StringRef &string); 00099 00101 bool denotesUnaryOp(const llvm::StringRef &string); 00102 00104 bool denotesOperator(const llvm::StringRef &string); 00105 00107 bool denotesBinaryOp(const comma::IdentifierInfo *idInfo); 00108 00110 bool denotesUnaryOp(const comma::IdentifierInfo *idInfo); 00111 00113 bool denotesOperator(const comma::IdentifierInfo *idInfo); 00114 00116 inline const char *getOpName(PrimitiveID ID) { 00117 switch (ID) { 00118 default: 00119 assert(false && "Not a primitive operator!"); 00120 return 0; 00121 case EQ_op: return "="; 00122 case NE_op: return "/="; 00123 case LT_op: return "<"; 00124 case GT_op: return ">"; 00125 case LE_op: return "<="; 00126 case GE_op: return ">="; 00127 case ADD_op: return "+"; 00128 case SUB_op: return "-"; 00129 case MUL_op: return "*"; 00130 case DIV_op: return "/"; 00131 case MOD_op: return "mod"; 00132 case REM_op: return "rem"; 00133 case POW_op: return "**"; 00134 case POS_op: return "+"; 00135 case NEG_op: return "-"; 00136 case LOR_op: return "or"; 00137 case LAND_op: return "and"; 00138 case LNOT_op: return "not"; 00139 case LXOR_op: return "xor"; 00140 } 00141 } 00142 00143 } // end primitive_ops namespace. 00144 00145 namespace PO = primitive_ops; 00146 00147 } // end comma namespace. 00148 00149 #endif