Open64 (mfef90, whirl2f, and IR tools)
TAG: version-openad; SVN changeset: 916
|
00001 /* 00002 00003 Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved. 00004 00005 This program is free software; you can redistribute it and/or modify it 00006 under the terms of version 2 of the GNU General Public License as 00007 published by the Free Software Foundation. 00008 00009 This program is distributed in the hope that it would be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 00013 Further, this software is distributed without any warranty that it is 00014 free of the rightful claim of any third person regarding infringement 00015 or the like. Any license provided herein, whether implied or 00016 otherwise, applies only to this software file. Patent licenses, if 00017 any, provided herein do not apply to combinations of this program with 00018 other software, or any other product whatsoever. 00019 00020 You should have received a copy of the GNU General Public License along 00021 with this program; if not, write the Free Software Foundation, Inc., 59 00022 Temple Place - Suite 330, Boston MA 02111-1307, USA. 00023 00024 Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky, 00025 Mountain View, CA 94043, or: 00026 00027 http://www.sgi.com 00028 00029 For further information regarding this notice, see: 00030 00031 http://oss.sgi.com/projects/GenInfo/NoticeExplan 00032 00033 */ 00034 00035 00040 #include "opcode.h" 00041 00042 #define opcode_C "opcode.c" 00043 00044 00049 // eraxxon (2005.01): Re-implement table and routines to support b2a 00050 // and a2b conversions. 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 * OPCODE OPCODE_commutative_op(OPCODE opc) 00082 * 00083 * If opc is commutative, return the opcode for whatever operation 00084 * gives equivalent results. If the operator isn't commutative, return 0. 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 /* These ops are commutative and don't need to be altered */ 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 /* these are treated specially */ 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 /* Anything else is a null */ 00129 default: 00130 break; 00131 } 00132 00133 return (rop); 00134 }