Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00040 #include "opcode.h"
00041
00042 #define opcode_C "opcode.c"
00043
00044
00049
00050
00051
00052 const char *OPERATOR_name(OPERATOR opr)
00053 {
00054 using namespace ir_a2b;
00055 return MapEnumToStr<OPERATOR_info_struct, OPERATOR_info,
00056 OPERATOR_LAST+1>("OPERATOR_info", (INT)opr);
00057 }
00058
00059 OPERATOR Name_To_OPERATOR(const char* nm)
00060 {
00061 using namespace ir_a2b;
00062 return (OPERATOR)MapStrToEnum<OPERATOR_info_struct, OPERATOR_info,
00063 OPERATOR_LAST+1>("OPERATOR_info", nm);
00064 }
00065
00066
00072 BOOL Operator_To_Opcode_Table_Inited = FALSE;
00073 void Init_Operator_To_Opcode_Table(void)
00074 {
00075 Operator_To_Opcode_Table_Inited = TRUE;
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 OPCODE OPCODE_commutative_op( OPCODE opc )
00090 {
00091
00092 OPCODE rop = (OPCODE) 0;
00093 OPERATOR opr = OPCODE_operator(opc);
00094 TYPE_ID rtype = OPCODE_rtype(opc);
00095 TYPE_ID desc = OPCODE_desc(opc);
00096
00097 switch (opr) {
00098
00099 case OPR_ADD:
00100 case OPR_MPY:
00101 case OPR_MAX:
00102 case OPR_MIN:
00103 case OPR_BAND:
00104 case OPR_BIOR:
00105 case OPR_BNOR:
00106 case OPR_BXOR:
00107 case OPR_LAND:
00108 case OPR_LIOR:
00109 case OPR_EQ:
00110 case OPR_NE:
00111 rop = opc;
00112 break;
00113
00114
00115 case OPR_GT:
00116 rop = OPCODE_make_op(OPR_LT, rtype, desc);
00117 break;
00118 case OPR_GE:
00119 rop = OPCODE_make_op(OPR_LE, rtype, desc);
00120 break;
00121 case OPR_LT:
00122 rop = OPCODE_make_op(OPR_GT, rtype, desc);
00123 break;
00124 case OPR_LE:
00125 rop = OPCODE_make_op(OPR_GE, rtype, desc);
00126 break;
00127
00128
00129 default:
00130 break;
00131 }
00132
00133 return (rop);
00134 }