10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_OPTO_MATHEXACTNODE_HPP
26 #define SHARE_VM_OPTO_MATHEXACTNODE_HPP
27
28 #include "opto/multnode.hpp"
29 #include "opto/node.hpp"
30 #include "opto/subnode.hpp"
31 #include "opto/type.hpp"
32
33 class BoolNode;
34 class IfNode;
35 class Node;
36
37 class PhaseGVN;
38 class PhaseTransform;
39
40 class MathExactNode : public MultiNode {
41 public:
42 MathExactNode(Node* ctrl, Node* in1);
43 MathExactNode(Node* ctrl, Node* in1, Node* in2);
44 enum {
45 result_proj_node = 0,
46 flags_proj_node = 1
47 };
48 virtual int Opcode() const;
49 virtual Node* Identity(PhaseTransform* phase) { return this; }
50 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape) { return NULL; }
51 virtual const Type* Value(PhaseTransform* phase) const { return bottom_type(); }
52 virtual uint hash() const { return NO_HASH; }
53 virtual bool is_CFG() const { return false; }
54 virtual uint ideal_reg() const { return NotAMachineReg; }
55
56 ProjNode* result_node() const { return proj_out(result_proj_node); }
57 ProjNode* flags_node() const { return proj_out(flags_proj_node); }
58 Node* control_node() const;
59 Node* non_throwing_branch() const;
60 protected:
61 IfNode* if_node() const;
62 BoolNode* bool_node() const;
63 Node* no_overflow(PhaseGVN *phase, Node* new_result);
64 };
65
66 class MathExactINode : public MathExactNode {
67 public:
68 MathExactINode(Node* ctrl, Node* in1) : MathExactNode(ctrl, in1) {}
69 MathExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {}
70 virtual int Opcode() const;
71 virtual Node* match(const ProjNode* proj, const Matcher* m);
72 virtual const Type* bottom_type() const { return TypeTuple::INT_CC_PAIR; }
73 };
74
75 class MathExactLNode : public MathExactNode {
76 public:
77 MathExactLNode(Node* ctrl, Node* in1) : MathExactNode(ctrl, in1) {}
78 MathExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {}
79 virtual int Opcode() const;
80 virtual Node* match(const ProjNode* proj, const Matcher* m);
81 virtual const Type* bottom_type() const { return TypeTuple::LONG_CC_PAIR; }
82 };
83
84 class AddExactINode : public MathExactINode {
85 public:
86 AddExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {}
87 virtual int Opcode() const;
88 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
89 };
90
91 class AddExactLNode : public MathExactLNode {
92 public:
93 AddExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {}
94 virtual int Opcode() const;
95 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
96 };
97
98 class SubExactINode : public MathExactINode {
99 public:
100 SubExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {}
101 virtual int Opcode() const;
102 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
103 };
104
105 class SubExactLNode : public MathExactLNode {
106 public:
107 SubExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {}
108 virtual int Opcode() const;
109 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
110 };
111
112 class NegExactINode : public MathExactINode {
113 public:
114 NegExactINode(Node* ctrl, Node* in1) : MathExactINode(ctrl, in1) {}
115 virtual int Opcode() const;
116 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
117 };
118
119 class NegExactLNode : public MathExactLNode {
120 public:
121 NegExactLNode(Node* ctrl, Node* in1) : MathExactLNode(ctrl, in1) {}
122 virtual int Opcode() const;
123 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
124 };
125
126 class MulExactINode : public MathExactINode {
127 public:
128 MulExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {}
129 virtual int Opcode() const;
130 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
131 };
132
133 class MulExactLNode : public MathExactLNode {
134 public:
135 MulExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {}
136 virtual int Opcode() const;
137 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
138 };
139
140 class FlagsProjNode : public ProjNode {
141 public:
142 FlagsProjNode(Node* src, uint con) : ProjNode(src, con) {
143 init_class_id(Class_FlagsProj);
144 }
145
146 virtual int Opcode() const;
147 virtual bool is_CFG() const { return false; }
148 virtual const Type* bottom_type() const { return TypeInt::CC; }
149 virtual uint ideal_reg() const { return Op_RegFlags; }
150 };
151
152
153 #endif
154
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_OPTO_MATHEXACTNODE_HPP
26 #define SHARE_VM_OPTO_MATHEXACTNODE_HPP
27
28 #include "opto/multnode.hpp"
29 #include "opto/node.hpp"
30 #include "opto/addnode.hpp"
31 #include "opto/subnode.hpp"
32 #include "opto/type.hpp"
33
34 class PhaseGVN;
35 class PhaseTransform;
36
37 class OverflowNode : public CmpNode {
38 public:
39 OverflowNode(Node* in1);
40 OverflowNode(Node* in1, Node* in2);
41 virtual uint ideal_reg() const { return Op_RegFlags; }
42
43 template <typename OverflowOp>
44 class AddHelper {
45 public:
46 typedef typename OverflowOp::ConstantType ConstantType;
47 typedef typename OverflowOp::TypeClass TypeClass;
48 static bool will_overflow(ConstantType value1, ConstantType value2);
49 static bool can_overflow(const Type* type1, const Type* type2);
50 };
51 template <typename OverflowOp>
52 class SubHelper {
53 public:
54 typedef typename OverflowOp::ConstantType ConstantType;
55 typedef typename OverflowOp::TypeClass TypeClass;
56 static bool will_overflow(ConstantType value1, ConstantType value2);
57 static bool can_overflow(const Type* type1, const Type* type2);
58 };
59
60 template <typename OverflowOp>
61 class MulHelper {
62 public:
63 typedef typename OverflowOp::ConstantType ConstantType;
64 typedef typename OverflowOp::TypeClass TypeClass;
65 static bool can_overflow(const Type* type1, const Type* type2);
66 };
67 };
68
69 class OverflowINode : public OverflowNode {
70 public:
71 enum {
72 IsLong = false
73 };
74 typedef jint ConstantType;
75 typedef TypeInt TypeClass;
76
77 OverflowINode(Node* in1) : OverflowNode(in1) {}
78 OverflowINode(Node* in1, Node* in2) : OverflowNode(in1, in2) {}
79 Node* Ideal(PhaseGVN* phase, bool can_reshape);
80 const Type* Value(PhaseTransform* phase) const;
81 const Type* sub(const Type* t1, const Type* t2) const;
82
83 virtual bool will_overflow(jint v1, jint v2) const;
84 virtual bool can_overflow(const Type* t1, const Type* t2) const;
85 };
86
87
88 class OverflowLNode : public OverflowNode {
89 public:
90 enum {
91 IsLong = true
92 };
93 typedef jlong ConstantType;
94 typedef TypeLong TypeClass;
95
96 OverflowLNode(Node* in1) : OverflowNode(in1) {}
97 OverflowLNode(Node* in1, Node* in2) : OverflowNode(in1, in2) {}
98 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
99 const Type* sub(const Type* t1, const Type* t2) const;
100 const Type* Value(PhaseTransform* phase) const;
101
102 virtual bool will_overflow(jlong v1, jlong v2) const;
103 virtual bool can_overflow(const Type* t1, const Type* t2) const;
104 };
105
106 class OverflowAddINode : public OverflowINode {
107 public:
108 typedef AddINode MathOp;
109 typedef OverflowNode::AddHelper<OverflowINode> OverflowHelper;
110
111 OverflowAddINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {}
112 virtual int Opcode() const;
113
114 virtual bool will_overflow(jint v1, jint v2) const;
115 virtual bool can_overflow(const Type* t1, const Type* t2) const;
116 };
117
118 class OverflowSubINode : public OverflowINode {
119 public:
120 typedef SubINode MathOp;
121 typedef OverflowNode::SubHelper<OverflowINode> OverflowHelper;
122
123 OverflowSubINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {}
124 virtual int Opcode() const;
125
126 virtual bool will_overflow(jint v1, jint v2) const;
127 virtual bool can_overflow(const Type* t1, const Type* t2) const;
128 };
129
130 class OverflowMulINode : public OverflowINode {
131 public:
132 typedef MulINode MathOp;
133 typedef OverflowNode::MulHelper<OverflowINode> OverflowHelper;
134
135 OverflowMulINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {}
136 virtual int Opcode() const;
137
138 virtual bool will_overflow(jint v1, jint v2) const;
139 virtual bool can_overflow(const Type* t1, const Type* t2) const;
140 };
141
142 class OverflowAddLNode : public OverflowLNode {
143 public:
144 typedef AddLNode MathOp;
145 typedef OverflowNode::AddHelper<OverflowLNode> OverflowHelper;
146
147 OverflowAddLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {}
148 virtual int Opcode() const;
149
150 virtual bool will_overflow(jlong v1, jlong v2) const;
151 virtual bool can_overflow(const Type* t1, const Type* t2) const;
152 };
153
154 class OverflowSubLNode : public OverflowLNode {
155 public:
156 typedef SubLNode MathOp;
157 typedef OverflowNode::SubHelper<OverflowLNode> OverflowHelper;
158
159 OverflowSubLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {}
160 virtual int Opcode() const;
161
162 virtual bool will_overflow(jlong v1, jlong v2) const;
163 virtual bool can_overflow(const Type* t1, const Type* t2) const;
164 };
165
166 class OverflowMulLNode : public OverflowLNode {
167 public:
168 typedef MulLNode MathOp;
169 typedef OverflowNode::MulHelper<OverflowLNode> OverflowHelper;
170
171 OverflowMulLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {}
172 virtual int Opcode() const;
173
174 virtual bool will_overflow(jlong v1, jlong v2) const;
175 virtual bool can_overflow(const Type* t1, const Type* t2) const;
176 };
177
178 #endif
179
|