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 00046 #include "opcode.h" 00047 00048 #define opcode_C "opcode.c" 00049 00050 00055 const char *OPERATOR_name(OPERATOR opr) 00056 { 00057 Is_True(opr >= OPERATOR_FIRST && opr <= OPERATOR_LAST, 00058 ("Bad OPERATOR %d", opr)); 00059 00060 return (const char *) OPERATOR_info[opr]._name; 00061 } 00062 00068 BOOL Operator_To_Opcode_Table_Inited = FALSE; 00069 void Init_Operator_To_Opcode_Table(void) 00070 { 00071 Operator_To_Opcode_Table_Inited = TRUE; 00072 } 00073 00074 00075 /* ==================================================================== 00076 * 00077 * OPCODE OPCODE_commutative_op(OPCODE opc) 00078 * 00079 * If opc is commutative, return the opcode for whatever operation 00080 * gives equivalent results. If the operator isn't commutative, return 0. 00081 * 00082 * ==================================================================== 00083 */ 00084 00085 OPCODE OPCODE_commutative_op( OPCODE opc ) 00086 { 00087 00088 OPCODE rop = (OPCODE) 0; 00089 OPERATOR opr = OPCODE_operator(opc); 00090 TYPE_ID rtype = OPCODE_rtype(opc); 00091 TYPE_ID desc = OPCODE_desc(opc); 00092 00093 switch (opr) { 00094 /* These ops are commutative and don't need to be altered */ 00095 case OPR_ADD: 00096 case OPR_MPY: 00097 case OPR_MAX: 00098 case OPR_MIN: 00099 case OPR_BAND: 00100 case OPR_BIOR: 00101 case OPR_BNOR: 00102 case OPR_BXOR: 00103 case OPR_LAND: 00104 case OPR_LIOR: 00105 case OPR_EQ: 00106 case OPR_NE: 00107 rop = opc; 00108 break; 00109 00110 /* these are treated specially */ 00111 case OPR_GT: 00112 rop = OPCODE_make_op(OPR_LT, rtype, desc); 00113 break; 00114 case OPR_GE: 00115 rop = OPCODE_make_op(OPR_LE, rtype, desc); 00116 break; 00117 case OPR_LT: 00118 rop = OPCODE_make_op(OPR_GT, rtype, desc); 00119 break; 00120 case OPR_LE: 00121 rop = OPCODE_make_op(OPR_GE, rtype, desc); 00122 break; 00123 00124 /* Anything else is a null */ 00125 default: 00126 break; 00127 } 00128 00129 return (rop); 00130 }
1.5.6