OpenADFortTk (including Open64 and OpenAnalysis references)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
opcode.cxx
Go to the documentation of this file.
1 /*
2 
3  Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved.
4 
5  This program is free software; you can redistribute it and/or modify it
6  under the terms of version 2 of the GNU General Public License as
7  published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it would be useful, but
10  WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13  Further, this software is distributed without any warranty that it is
14  free of the rightful claim of any third person regarding infringement
15  or the like. Any license provided herein, whether implied or
16  otherwise, applies only to this software file. Patent licenses, if
17  any, provided herein do not apply to combinations of this program with
18  other software, or any other product whatsoever.
19 
20  You should have received a copy of the GNU General Public License along
21  with this program; if not, write the Free Software Foundation, Inc., 59
22  Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 
24  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
25  Mountain View, CA 94043, or:
26 
27  http://www.sgi.com
28 
29  For further information regarding this notice, see:
30 
31  http://oss.sgi.com/projects/GenInfo/NoticeExplan
32 
33 */
34 
35 
40 #include "opcode.h"
41 
42 #define opcode_C "opcode.c"
43 
44 
49 // eraxxon (2005.01): Re-implement table and routines to support b2a
50 // and a2b conversions.
51 
52 const char *OPERATOR_name(OPERATOR opr)
53 {
54  using namespace ir_a2b;
56  OPERATOR_LAST+1>("OPERATOR_info", (INT)opr);
57 }
58 
59 OPERATOR Name_To_OPERATOR(const char* nm)
60 {
61  using namespace ir_a2b;
63  OPERATOR_LAST+1>("OPERATOR_info", nm);
64 }
65 
66 
74 {
76 }
77 
78 
79 /* ====================================================================
80  *
81  * OPCODE OPCODE_commutative_op(OPCODE opc)
82  *
83  * If opc is commutative, return the opcode for whatever operation
84  * gives equivalent results. If the operator isn't commutative, return 0.
85  *
86  * ====================================================================
87  */
88 
90 {
91 
92  OPCODE rop = (OPCODE) 0;
93  OPERATOR opr = OPCODE_operator(opc);
94  TYPE_ID rtype = OPCODE_rtype(opc);
95  TYPE_ID desc = OPCODE_desc(opc);
96 
97  switch (opr) {
98  /* These ops are commutative and don't need to be altered */
99  case OPR_ADD:
100  case OPR_MPY:
101  case OPR_MAX:
102  case OPR_MIN:
103  case OPR_BAND:
104  case OPR_BIOR:
105  case OPR_BNOR:
106  case OPR_BXOR:
107  case OPR_LAND:
108  case OPR_LIOR:
109  case OPR_EQ:
110  case OPR_NE:
111  rop = opc;
112  break;
113 
114  /* these are treated specially */
115  case OPR_GT:
116  rop = OPCODE_make_op(OPR_LT, rtype, desc);
117  break;
118  case OPR_GE:
119  rop = OPCODE_make_op(OPR_LE, rtype, desc);
120  break;
121  case OPR_LT:
122  rop = OPCODE_make_op(OPR_GT, rtype, desc);
123  break;
124  case OPR_LE:
125  rop = OPCODE_make_op(OPR_GE, rtype, desc);
126  break;
127 
128  /* Anything else is a null */
129  default:
130  break;
131  }
132 
133  return (rop);
134 }