1 /*
2 * Copyright (c) 1997, 2025, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
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_OPTO_SUBNODE_HPP
26 #define SHARE_OPTO_SUBNODE_HPP
27
28 #include "opto/node.hpp"
29 #include "opto/opcodes.hpp"
30 #include "opto/type.hpp"
31
32 // Portions of code courtesy of Clifford Click
33
34 //------------------------------SUBNode----------------------------------------
35 // Class SUBTRACTION functionality. This covers all the usual 'subtract'
36 // behaviors. Subtract-integer, -float, -double, binary xor, compare-integer,
37 // -float, and -double are all inherited from this class. The compare
38 // functions behave like subtract functions, except that all negative answers
39 // are compressed into -1, and all positive answers compressed to 1.
40 class SubNode : public Node {
41 public:
42 SubNode( Node *in1, Node *in2 ) : Node(nullptr,in1,in2) {
43 init_class_id(Class_Sub);
44 }
45
46 // Handle algebraic identities here. If we have an identity, return the Node
47 // we are equivalent to. We look for "add of zero" as an identity.
48 virtual Node* Identity(PhaseGVN* phase);
49
50 // Compute a new Type for this node. Basically we just do the pre-check,
51 // then call the virtual add() to set the type.
52 virtual const Type* Value(PhaseGVN* phase) const;
53 const Type* Value_common(PhaseValues* phase) const;
54
55 // Supplied function returns the subtractend of the inputs.
56 // This also type-checks the inputs for sanity. Guaranteed never to
57 // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
58 virtual const Type *sub( const Type *, const Type * ) const = 0;
59
60 // Supplied function to return the additive identity type.
61 // This is returned whenever the subtracts inputs are the same.
62 virtual const Type *add_id() const = 0;
63
64 static SubNode* make(Node* in1, Node* in2, BasicType bt);
65 };
66
67
68 // NOTE: SubINode should be taken away and replaced by add and negate
69 //------------------------------SubINode---------------------------------------
70 // Subtract 2 integers
71 class SubINode : public SubNode {
72 public:
73 SubINode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
74 virtual int Opcode() const;
75 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
76 virtual const Type *sub( const Type *, const Type * ) const;
77 const Type *add_id() const { return TypeInt::ZERO; }
78 const Type *bottom_type() const { return TypeInt::INT; }
79 virtual uint ideal_reg() const { return Op_RegI; }
80 };
81
82 //------------------------------SubLNode---------------------------------------
83 // Subtract 2 integers
84 class SubLNode : public SubNode {
85 public:
86 SubLNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
87 virtual int Opcode() const;
88 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
89 virtual const Type *sub( const Type *, const Type * ) const;
90 const Type *add_id() const { return TypeLong::ZERO; }
91 const Type *bottom_type() const { return TypeLong::LONG; }
92 virtual uint ideal_reg() const { return Op_RegL; }
93 };
94
95 // NOTE: SubFPNode should be taken away and replaced by add and negate
96 //------------------------------SubFPNode--------------------------------------
97 // Subtract 2 floats or doubles
98 class SubFPNode : public SubNode {
99 protected:
100 SubFPNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {}
101 public:
102 const Type* Value(PhaseGVN* phase) const;
103 };
104
105 // NOTE: SubFNode should be taken away and replaced by add and negate
106 //------------------------------SubFNode---------------------------------------
107 // Subtract 2 doubles
108 class SubFNode : public SubFPNode {
109 public:
110 SubFNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {}
111 virtual int Opcode() const;
112 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
113 virtual const Type *sub( const Type *, const Type * ) const;
114 const Type *add_id() const { return TypeF::ZERO; }
115 const Type *bottom_type() const { return Type::FLOAT; }
116 virtual uint ideal_reg() const { return Op_RegF; }
117 };
118
119 // NOTE: SubDNode should be taken away and replaced by add and negate
120 //------------------------------SubDNode---------------------------------------
121 // Subtract 2 doubles
122 class SubDNode : public SubFPNode {
123 public:
124 SubDNode( Node *in1, Node *in2 ) : SubFPNode(in1,in2) {}
125 virtual int Opcode() const;
126 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
127 virtual const Type *sub( const Type *, const Type * ) const;
128 const Type *add_id() const { return TypeD::ZERO; }
129 const Type *bottom_type() const { return Type::DOUBLE; }
130 virtual uint ideal_reg() const { return Op_RegD; }
131 };
132
133 //------------------------------SubHFNode--------------------------------------
134 // Subtract 2 half floats
135 class SubHFNode : public SubFPNode {
136 public:
137 SubHFNode(Node* in1, Node* in2) : SubFPNode(in1, in2) {}
138 virtual int Opcode() const;
139 virtual const Type* sub(const Type*, const Type*) const;
140 const Type* add_id() const { return TypeH::ZERO; }
141 const Type* bottom_type() const { return Type::HALF_FLOAT; }
142 virtual uint ideal_reg() const { return Op_RegF; }
143 };
144
145 //------------------------------CmpNode---------------------------------------
146 // Compare 2 values, returning condition codes (-1, 0 or 1).
147 class CmpNode : public SubNode {
148 public:
149 CmpNode( Node *in1, Node *in2 ) : SubNode(in1,in2) {
150 init_class_id(Class_Cmp);
151 }
152 virtual Node* Identity(PhaseGVN* phase);
153 const Type *add_id() const { return TypeInt::ZERO; }
154 const Type *bottom_type() const { return TypeInt::CC; }
155 virtual uint ideal_reg() const { return Op_RegFlags; }
156
157 static CmpNode *make(Node *in1, Node *in2, BasicType bt, bool unsigned_comp = false);
158 };
159
160 //------------------------------CmpINode---------------------------------------
161 // Compare 2 signed values, returning condition codes (-1, 0 or 1).
162 class CmpINode : public CmpNode {
163 public:
164 CmpINode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
165 virtual int Opcode() const;
166 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
167 virtual const Type *sub( const Type *, const Type * ) const;
168 virtual const Type* Value(PhaseGVN* phase) const;
169 };
170
171 //------------------------------CmpUNode---------------------------------------
172 // Compare 2 unsigned values (integer or pointer), returning condition codes (-1, 0 or 1).
173 class CmpUNode : public CmpNode {
174 public:
175 CmpUNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
176 virtual int Opcode() const;
177 virtual const Type *sub( const Type *, const Type * ) const;
178 const Type* Value(PhaseGVN* phase) const;
179 bool is_index_range_check() const;
180 };
181
182 //------------------------------CmpU3Node--------------------------------------
183 // Compare 2 unsigned values, returning integer value (-1, 0 or 1).
184 class CmpU3Node : public CmpUNode {
185 public:
186 CmpU3Node( Node *in1, Node *in2 ) : CmpUNode(in1,in2) {
187 // Since it is not consumed by Bools, it is not really a Cmp.
188 init_class_id(Class_Sub);
189 }
190 virtual int Opcode() const;
191 virtual uint ideal_reg() const { return Op_RegI; }
192 };
193
194 //------------------------------CmpPNode---------------------------------------
195 // Compare 2 pointer values, returning condition codes (-1, 0 or 1).
196 class CmpPNode : public CmpNode {
197 public:
198 CmpPNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
199 virtual int Opcode() const;
200 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
201 virtual const Type *sub( const Type *, const Type * ) const;
202 };
203
204 //------------------------------CmpNNode--------------------------------------
205 // Compare 2 narrow oop values, returning condition codes (-1, 0 or 1).
206 class CmpNNode : public CmpNode {
207 public:
208 CmpNNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
209 virtual int Opcode() const;
210 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
211 virtual const Type *sub( const Type *, const Type * ) const;
212 };
213
214 //------------------------------CmpLNode---------------------------------------
215 // Compare 2 long values, returning condition codes (-1, 0 or 1).
216 class CmpLNode : public CmpNode {
217 public:
218 CmpLNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
219 virtual int Opcode() const;
220 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
221 virtual const Type *sub( const Type *, const Type * ) const;
222 };
223
224 //------------------------------CmpULNode---------------------------------------
225 // Compare 2 unsigned long values, returning condition codes (-1, 0 or 1).
226 class CmpULNode : public CmpNode {
227 public:
228 CmpULNode(Node* in1, Node* in2) : CmpNode(in1, in2) { }
229 virtual int Opcode() const;
230 virtual const Type* sub(const Type*, const Type*) const;
231 };
232
233 //------------------------------CmpL3Node--------------------------------------
234 // Compare 2 long values, returning integer value (-1, 0 or 1).
235 class CmpL3Node : public CmpLNode {
236 public:
237 CmpL3Node( Node *in1, Node *in2 ) : CmpLNode(in1,in2) {
238 // Since it is not consumed by Bools, it is not really a Cmp.
239 init_class_id(Class_Sub);
240 }
241 virtual int Opcode() const;
242 virtual uint ideal_reg() const { return Op_RegI; }
243 };
244
245 //------------------------------CmpUL3Node-------------------------------------
246 // Compare 2 unsigned long values, returning integer value (-1, 0 or 1).
247 class CmpUL3Node : public CmpULNode {
248 public:
249 CmpUL3Node( Node *in1, Node *in2 ) : CmpULNode(in1,in2) {
250 // Since it is not consumed by Bools, it is not really a Cmp.
251 init_class_id(Class_Sub);
252 }
253 virtual int Opcode() const;
254 virtual uint ideal_reg() const { return Op_RegI; }
255 };
256
257 //------------------------------CmpFNode---------------------------------------
258 // Compare 2 float values, returning condition codes (-1, 0 or 1).
259 // This implements the Java bytecode fcmpl, so unordered returns -1.
260 // Operands may not commute.
261 class CmpFNode : public CmpNode {
262 public:
263 CmpFNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
264 virtual int Opcode() const;
265 virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return nullptr; }
266 const Type* Value(PhaseGVN* phase) const;
267 };
268
269 //------------------------------CmpF3Node--------------------------------------
270 // Compare 2 float values, returning integer value (-1, 0 or 1).
271 // This implements the Java bytecode fcmpl, so unordered returns -1.
272 // Operands may not commute.
273 class CmpF3Node : public CmpFNode {
274 public:
275 CmpF3Node( Node *in1, Node *in2 ) : CmpFNode(in1,in2) {
276 // Since it is not consumed by Bools, it is not really a Cmp.
277 init_class_id(Class_Sub);
278 }
279 virtual int Opcode() const;
280 // Since it is not consumed by Bools, it is not really a Cmp.
281 virtual uint ideal_reg() const { return Op_RegI; }
282 };
283
284
285 //------------------------------CmpDNode---------------------------------------
286 // Compare 2 double values, returning condition codes (-1, 0 or 1).
287 // This implements the Java bytecode dcmpl, so unordered returns -1.
288 // Operands may not commute.
289 class CmpDNode : public CmpNode {
290 public:
291 CmpDNode( Node *in1, Node *in2 ) : CmpNode(in1,in2) {}
292 virtual int Opcode() const;
293 virtual const Type *sub( const Type *, const Type * ) const { ShouldNotReachHere(); return nullptr; }
294 const Type* Value(PhaseGVN* phase) const;
295 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
296 };
297
298 //------------------------------CmpD3Node--------------------------------------
299 // Compare 2 double values, returning integer value (-1, 0 or 1).
300 // This implements the Java bytecode dcmpl, so unordered returns -1.
301 // Operands may not commute.
302 class CmpD3Node : public CmpDNode {
303 public:
304 CmpD3Node( Node *in1, Node *in2 ) : CmpDNode(in1,in2) {
305 // Since it is not consumed by Bools, it is not really a Cmp.
306 init_class_id(Class_Sub);
307 }
308 virtual int Opcode() const;
309 virtual uint ideal_reg() const { return Op_RegI; }
310 };
311
312
313 //------------------------------BoolTest---------------------------------------
314 // Convert condition codes to a boolean test value (0 or -1).
315 // We pick the values as 3 bits; the low order 2 bits we compare against the
316 // condition codes, the high bit flips the sense of the result.
317 // For vector compares, additionally, the 4th bit indicates if the compare is unsigned
318 struct BoolTest {
319 enum mask { eq = 0, ne = 4, le = 5, ge = 7, lt = 3, gt = 1, overflow = 2, no_overflow = 6, never = 8, illegal = 9,
320 // The following values are used with vector compares
321 // A BoolTest value should not be constructed for such values
322 unsigned_compare = 16,
323 ule = unsigned_compare | le, uge = unsigned_compare | ge, ult = unsigned_compare | lt, ugt = unsigned_compare | gt };
324 mask _test;
325 BoolTest( mask btm ) : _test(btm) { assert((btm & unsigned_compare) == 0, "unsupported");}
326 const Type *cc2logical( const Type *CC ) const;
327 // Commute the test. I use a small table lookup. The table is created as
328 // a simple char array where each element is the ASCII version of a 'mask'
329 // enum from above.
330 mask commute( ) const { return mask("032147658"[_test]-'0'); }
331 mask negate( ) const { return mask(_test^4); }
332 bool is_canonical( ) const { return (_test == BoolTest::ne || _test == BoolTest::lt || _test == BoolTest::le || _test == BoolTest::overflow); }
333 bool is_less( ) const { return _test == BoolTest::lt || _test == BoolTest::le; }
334 bool is_greater( ) const { return _test == BoolTest::gt || _test == BoolTest::ge; }
335 void dump_on(outputStream *st) const;
336 mask merge(BoolTest other) const;
337 };
338
339 //------------------------------BoolNode---------------------------------------
340 // A Node to convert a Condition Codes to a Logical result.
341 class BoolNode : public Node {
342 virtual uint hash() const;
343 virtual bool cmp( const Node &n ) const;
344 virtual uint size_of() const;
345
346 // Try to optimize signed integer comparison
347 Node* fold_cmpI(PhaseGVN* phase, SubNode* cmp, Node* cmp1, int cmp_op,
348 int cmp1_op, const TypeInt* cmp2_type);
349 public:
350 const BoolTest _test;
351 BoolNode(Node *cc, BoolTest::mask t): Node(nullptr,cc), _test(t) {
352 init_class_id(Class_Bool);
353 }
354 // Convert an arbitrary int value to a Bool or other suitable predicate.
355 static Node* make_predicate(Node* test_value, PhaseGVN* phase);
356 // Convert self back to an integer value.
357 Node* as_int_value(PhaseGVN* phase);
358 // Invert sense of self, returning new Bool.
359 BoolNode* negate(PhaseGVN* phase);
360 virtual int Opcode() const;
361 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
362 const Type* Value_cmpu_and_mask(PhaseValues* phase) const;
363 virtual const Type* Value(PhaseGVN* phase) const;
364 virtual const Type *bottom_type() const { return TypeInt::BOOL; }
365 uint match_edge(uint idx) const { return 0; }
366 virtual uint ideal_reg() const { return Op_RegI; }
367
368 bool is_counted_loop_exit_test();
369 #ifndef PRODUCT
370 virtual void dump_spec(outputStream *st) const;
371 #endif
372 };
373
374 //------------------------------AbsNode----------------------------------------
375 // Abstract class for absolute value. Mostly used to get a handy wrapper
376 // for finding this pattern in the graph.
377 class AbsNode : public Node {
378 public:
379 AbsNode( Node *value ) : Node(nullptr,value) {}
380 virtual Node* Identity(PhaseGVN* phase);
381 virtual Node* Ideal(PhaseGVN* phase, bool can_reshape);
382 virtual const Type* Value(PhaseGVN* phase) const;
383 };
384
385 //------------------------------AbsINode---------------------------------------
386 // Absolute value an integer. Since a naive graph involves control flow, we
387 // "match" it in the ideal world (so the control flow can be removed).
388 class AbsINode : public AbsNode {
389 public:
390 AbsINode( Node *in1 ) : AbsNode(in1) {}
391 virtual int Opcode() const;
392 const Type *bottom_type() const { return TypeInt::INT; }
393 virtual uint ideal_reg() const { return Op_RegI; }
394 };
395
396 //------------------------------AbsLNode---------------------------------------
397 // Absolute value a long. Since a naive graph involves control flow, we
398 // "match" it in the ideal world (so the control flow can be removed).
399 class AbsLNode : public AbsNode {
400 public:
401 AbsLNode( Node *in1 ) : AbsNode(in1) {}
402 virtual int Opcode() const;
403 const Type *bottom_type() const { return TypeLong::LONG; }
404 virtual uint ideal_reg() const { return Op_RegL; }
405 };
406
407 //------------------------------AbsFNode---------------------------------------
408 // Absolute value a float, a common float-point idiom with a cheap hardware
409 // implementation on most chips. Since a naive graph involves control flow, we
410 // "match" it in the ideal world (so the control flow can be removed).
411 class AbsFNode : public AbsNode {
412 public:
413 AbsFNode( Node *in1 ) : AbsNode(in1) {}
414 virtual int Opcode() const;
415 const Type *bottom_type() const { return Type::FLOAT; }
416 virtual uint ideal_reg() const { return Op_RegF; }
417 };
418
419 //------------------------------AbsDNode---------------------------------------
420 // Absolute value a double, a common float-point idiom with a cheap hardware
421 // implementation on most chips. Since a naive graph involves control flow, we
422 // "match" it in the ideal world (so the control flow can be removed).
423 class AbsDNode : public AbsNode {
424 public:
425 AbsDNode( Node *in1 ) : AbsNode(in1) {}
426 virtual int Opcode() const;
427 const Type *bottom_type() const { return Type::DOUBLE; }
428 virtual uint ideal_reg() const { return Op_RegD; }
429 };
430
431
432 //------------------------------CmpLTMaskNode----------------------------------
433 // If p < q, return -1 else return 0. Nice for flow-free idioms.
434 class CmpLTMaskNode : public Node {
435 public:
436 CmpLTMaskNode( Node *p, Node *q ) : Node(nullptr, p, q) {}
437 virtual int Opcode() const;
438 const Type *bottom_type() const { return TypeInt::INT; }
439 virtual uint ideal_reg() const { return Op_RegI; }
440 };
441
442 //------------------------------InvolutionNode----------------------------------
443 // Represents a self-inverse operation, i.e., op(op(x)) = x for any x
444 class InvolutionNode : public Node {
445 public:
446 InvolutionNode(Node* in) : Node(nullptr, in) {}
447 virtual Node* Identity(PhaseGVN* phase);
448 };
449
450 //------------------------------NegNode----------------------------------------
451 class NegNode : public InvolutionNode {
452 public:
453 NegNode(Node* in1) : InvolutionNode(in1) {
454 init_class_id(Class_Neg);
455 }
456 };
457
458 //------------------------------NegINode---------------------------------------
459 // Negate value an int. For int values, negation is the same as subtraction
460 // from zero
461 class NegINode : public NegNode {
462 public:
463 NegINode(Node *in1) : NegNode(in1) {}
464 virtual int Opcode() const;
465 const Type *bottom_type() const { return TypeInt::INT; }
466 virtual uint ideal_reg() const { return Op_RegI; }
467 };
468
469 //------------------------------NegLNode---------------------------------------
470 // Negate value an int. For int values, negation is the same as subtraction
471 // from zero
472 class NegLNode : public NegNode {
473 public:
474 NegLNode(Node *in1) : NegNode(in1) {}
475 virtual int Opcode() const;
476 const Type *bottom_type() const { return TypeLong::LONG; }
477 virtual uint ideal_reg() const { return Op_RegL; }
478 };
479
480 //------------------------------NegFNode---------------------------------------
481 // Negate value a float. Negating 0.0 returns -0.0, but subtracting from
482 // zero returns +0.0 (per JVM spec on 'fneg' bytecode). As subtraction
483 // cannot be used to replace negation we have to implement negation as ideal
484 // node; note that negation and addition can replace subtraction.
485 class NegFNode : public NegNode {
486 public:
487 NegFNode( Node *in1 ) : NegNode(in1) {}
488 virtual int Opcode() const;
489 const Type *bottom_type() const { return Type::FLOAT; }
490 virtual uint ideal_reg() const { return Op_RegF; }
491 };
492
493 //------------------------------NegDNode---------------------------------------
494 // Negate value a double. Negating 0.0 returns -0.0, but subtracting from
495 // zero returns +0.0 (per JVM spec on 'dneg' bytecode). As subtraction
496 // cannot be used to replace negation we have to implement negation as ideal
497 // node; note that negation and addition can replace subtraction.
498 class NegDNode : public NegNode {
499 public:
500 NegDNode( Node *in1 ) : NegNode(in1) {}
501 virtual int Opcode() const;
502 const Type *bottom_type() const { return Type::DOUBLE; }
503 virtual uint ideal_reg() const { return Op_RegD; }
504 };
505
506 //------------------------------AtanDNode--------------------------------------
507 // arcus tangens of a double
508 class AtanDNode : public Node {
509 public:
510 AtanDNode(Node *c, Node *in1, Node *in2 ) : Node(c, in1, in2) {}
511 virtual int Opcode() const;
512 const Type *bottom_type() const { return Type::DOUBLE; }
513 virtual uint ideal_reg() const { return Op_RegD; }
514 };
515
516
517 //------------------------------SqrtDNode--------------------------------------
518 // square root a double
519 class SqrtDNode : public Node {
520 public:
521 SqrtDNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
522 init_flags(Flag_is_expensive);
523 C->add_expensive_node(this);
524 }
525 virtual int Opcode() const;
526 const Type *bottom_type() const { return Type::DOUBLE; }
527 virtual uint ideal_reg() const { return Op_RegD; }
528 virtual const Type* Value(PhaseGVN* phase) const;
529 };
530
531 //------------------------------SqrtFNode--------------------------------------
532 // square root a float
533 class SqrtFNode : public Node {
534 public:
535 SqrtFNode(Compile* C, Node *c, Node *in1) : Node(c, in1) {
536 init_flags(Flag_is_expensive);
537 if (c != nullptr) {
538 // Treat node only as expensive if a control input is set because it might
539 // be created from a SqrtDNode in ConvD2FNode::Ideal() that was found to
540 // be unique and therefore has no control input.
541 C->add_expensive_node(this);
542 }
543 }
544 virtual int Opcode() const;
545 const Type *bottom_type() const { return Type::FLOAT; }
546 virtual uint ideal_reg() const { return Op_RegF; }
547 virtual const Type* Value(PhaseGVN* phase) const;
548 };
549
550 //------------------------------SqrtHFNode-------------------------------------
551 // square root of a half-precision float
552 class SqrtHFNode : public Node {
553 public:
554 SqrtHFNode(Compile* C, Node* c, Node* in1) : Node(c, in1) {
555 init_flags(Flag_is_expensive);
556 C->add_expensive_node(this);
557 }
558 virtual int Opcode() const;
559 const Type* bottom_type() const { return Type::HALF_FLOAT; }
560 virtual uint ideal_reg() const { return Op_RegF; }
561 virtual const Type* Value(PhaseGVN* phase) const;
562 };
563
564 //-------------------------------ReverseBytesINode--------------------------------
565 // reverse bytes of an integer
566 class ReverseBytesINode : public InvolutionNode {
567 public:
568 ReverseBytesINode(Node* in) : InvolutionNode(in) {}
569 virtual int Opcode() const;
570 const Type* bottom_type() const { return TypeInt::INT; }
571 virtual uint ideal_reg() const { return Op_RegI; }
572 };
573
574 //-------------------------------ReverseBytesLNode--------------------------------
575 // reverse bytes of a long
576 class ReverseBytesLNode : public InvolutionNode {
577 public:
578 ReverseBytesLNode(Node* in) : InvolutionNode(in) {}
579 virtual int Opcode() const;
580 const Type* bottom_type() const { return TypeLong::LONG; }
581 virtual uint ideal_reg() const { return Op_RegL; }
582 };
583
584 //-------------------------------ReverseBytesUSNode--------------------------------
585 // reverse bytes of an unsigned short / char
586 class ReverseBytesUSNode : public InvolutionNode {
587 public:
588 ReverseBytesUSNode(Node* in1) : InvolutionNode(in1) {}
589 virtual int Opcode() const;
590 const Type* bottom_type() const { return TypeInt::CHAR; }
591 virtual uint ideal_reg() const { return Op_RegI; }
592 };
593
594 //-------------------------------ReverseBytesSNode--------------------------------
595 // reverse bytes of a short
596 class ReverseBytesSNode : public InvolutionNode {
597 public:
598 ReverseBytesSNode(Node* in) : InvolutionNode(in) {}
599 virtual int Opcode() const;
600 const Type* bottom_type() const { return TypeInt::SHORT; }
601 virtual uint ideal_reg() const { return Op_RegI; }
602 };
603
604 //-------------------------------ReverseINode--------------------------------
605 // reverse bits of an int
606 class ReverseINode : public InvolutionNode {
607 public:
608 ReverseINode(Node* in) : InvolutionNode(in) {}
609 virtual int Opcode() const;
610 const Type* bottom_type() const { return TypeInt::INT; }
611 virtual uint ideal_reg() const { return Op_RegI; }
612 virtual const Type* Value(PhaseGVN* phase) const;
613 };
614
615 //-------------------------------ReverseLNode--------------------------------
616 // reverse bits of a long
617 class ReverseLNode : public InvolutionNode {
618 public:
619 ReverseLNode(Node* in) : InvolutionNode(in) {}
620 virtual int Opcode() const;
621 const Type* bottom_type() const { return TypeLong::LONG; }
622 virtual uint ideal_reg() const { return Op_RegL; }
623 virtual const Type* Value(PhaseGVN* phase) const;
624 };
625
626 #endif // SHARE_OPTO_SUBNODE_HPP
--- EOF ---