Wed, 27 Jan 2016 09:02:51 +0100
6675699: need comprehensive fix for unconstrained ConvI2L with narrowed type
Summary: Emit CastII to make narrow ConvI2L dependent on the corresponding range check.
Reviewed-by: kvn, roland
1 /*
2 * Copyright (c) 1997, 2012, 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 */
25 #ifndef SHARE_VM_OPTO_CONNODE_HPP
26 #define SHARE_VM_OPTO_CONNODE_HPP
28 #include "opto/node.hpp"
29 #include "opto/opcodes.hpp"
30 #include "opto/type.hpp"
32 class PhaseTransform;
33 class MachNode;
35 //------------------------------ConNode----------------------------------------
36 // Simple constants
37 class ConNode : public TypeNode {
38 public:
39 ConNode( const Type *t ) : TypeNode(t->remove_speculative(),1) {
40 init_req(0, (Node*)Compile::current()->root());
41 init_flags(Flag_is_Con);
42 }
43 virtual int Opcode() const;
44 virtual uint hash() const;
45 virtual const RegMask &out_RegMask() const { return RegMask::Empty; }
46 virtual const RegMask &in_RegMask(uint) const { return RegMask::Empty; }
48 // Polymorphic factory method:
49 static ConNode* make( Compile* C, const Type *t );
50 };
52 //------------------------------ConINode---------------------------------------
53 // Simple integer constants
54 class ConINode : public ConNode {
55 public:
56 ConINode( const TypeInt *t ) : ConNode(t) {}
57 virtual int Opcode() const;
59 // Factory method:
60 static ConINode* make( Compile* C, int con ) {
61 return new (C) ConINode( TypeInt::make(con) );
62 }
64 };
66 //------------------------------ConPNode---------------------------------------
67 // Simple pointer constants
68 class ConPNode : public ConNode {
69 public:
70 ConPNode( const TypePtr *t ) : ConNode(t) {}
71 virtual int Opcode() const;
73 // Factory methods:
74 static ConPNode* make( Compile *C ,address con ) {
75 if (con == NULL)
76 return new (C) ConPNode( TypePtr::NULL_PTR ) ;
77 else
78 return new (C) ConPNode( TypeRawPtr::make(con) );
79 }
80 };
83 //------------------------------ConNNode--------------------------------------
84 // Simple narrow oop constants
85 class ConNNode : public ConNode {
86 public:
87 ConNNode( const TypeNarrowOop *t ) : ConNode(t) {}
88 virtual int Opcode() const;
89 };
91 //------------------------------ConNKlassNode---------------------------------
92 // Simple narrow klass constants
93 class ConNKlassNode : public ConNode {
94 public:
95 ConNKlassNode( const TypeNarrowKlass *t ) : ConNode(t) {}
96 virtual int Opcode() const;
97 };
100 //------------------------------ConLNode---------------------------------------
101 // Simple long constants
102 class ConLNode : public ConNode {
103 public:
104 ConLNode( const TypeLong *t ) : ConNode(t) {}
105 virtual int Opcode() const;
107 // Factory method:
108 static ConLNode* make( Compile *C ,jlong con ) {
109 return new (C) ConLNode( TypeLong::make(con) );
110 }
112 };
114 //------------------------------ConFNode---------------------------------------
115 // Simple float constants
116 class ConFNode : public ConNode {
117 public:
118 ConFNode( const TypeF *t ) : ConNode(t) {}
119 virtual int Opcode() const;
121 // Factory method:
122 static ConFNode* make( Compile *C, float con ) {
123 return new (C) ConFNode( TypeF::make(con) );
124 }
126 };
128 //------------------------------ConDNode---------------------------------------
129 // Simple double constants
130 class ConDNode : public ConNode {
131 public:
132 ConDNode( const TypeD *t ) : ConNode(t) {}
133 virtual int Opcode() const;
135 // Factory method:
136 static ConDNode* make( Compile *C, double con ) {
137 return new (C) ConDNode( TypeD::make(con) );
138 }
140 };
142 //------------------------------BinaryNode-------------------------------------
143 // Place holder for the 2 conditional inputs to a CMove. CMove needs 4
144 // inputs: the Bool (for the lt/gt/eq/ne bits), the flags (result of some
145 // compare), and the 2 values to select between. The Matcher requires a
146 // binary tree so we break it down like this:
147 // (CMove (Binary bol cmp) (Binary src1 src2))
148 class BinaryNode : public Node {
149 public:
150 BinaryNode( Node *n1, Node *n2 ) : Node(0,n1,n2) { }
151 virtual int Opcode() const;
152 virtual uint ideal_reg() const { return 0; }
153 };
155 //------------------------------CMoveNode--------------------------------------
156 // Conditional move
157 class CMoveNode : public TypeNode {
158 public:
159 enum { Control, // When is it safe to do this cmove?
160 Condition, // Condition controlling the cmove
161 IfFalse, // Value if condition is false
162 IfTrue }; // Value if condition is true
163 CMoveNode( Node *bol, Node *left, Node *right, const Type *t ) : TypeNode(t,4)
164 {
165 init_class_id(Class_CMove);
166 // all inputs are nullified in Node::Node(int)
167 // init_req(Control,NULL);
168 init_req(Condition,bol);
169 init_req(IfFalse,left);
170 init_req(IfTrue,right);
171 }
172 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
173 virtual const Type *Value( PhaseTransform *phase ) const;
174 virtual Node *Identity( PhaseTransform *phase );
175 static CMoveNode *make( Compile *C, Node *c, Node *bol, Node *left, Node *right, const Type *t );
176 // Helper function to spot cmove graph shapes
177 static Node *is_cmove_id( PhaseTransform *phase, Node *cmp, Node *t, Node *f, BoolNode *b );
178 };
180 //------------------------------CMoveDNode-------------------------------------
181 class CMoveDNode : public CMoveNode {
182 public:
183 CMoveDNode( Node *bol, Node *left, Node *right, const Type* t) : CMoveNode(bol,left,right,t){}
184 virtual int Opcode() const;
185 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
186 };
188 //------------------------------CMoveFNode-------------------------------------
189 class CMoveFNode : public CMoveNode {
190 public:
191 CMoveFNode( Node *bol, Node *left, Node *right, const Type* t ) : CMoveNode(bol,left,right,t) {}
192 virtual int Opcode() const;
193 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
194 };
196 //------------------------------CMoveINode-------------------------------------
197 class CMoveINode : public CMoveNode {
198 public:
199 CMoveINode( Node *bol, Node *left, Node *right, const TypeInt *ti ) : CMoveNode(bol,left,right,ti){}
200 virtual int Opcode() const;
201 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
202 };
204 //------------------------------CMoveLNode-------------------------------------
205 class CMoveLNode : public CMoveNode {
206 public:
207 CMoveLNode(Node *bol, Node *left, Node *right, const TypeLong *tl ) : CMoveNode(bol,left,right,tl){}
208 virtual int Opcode() const;
209 };
211 //------------------------------CMovePNode-------------------------------------
212 class CMovePNode : public CMoveNode {
213 public:
214 CMovePNode( Node *c, Node *bol, Node *left, Node *right, const TypePtr* t ) : CMoveNode(bol,left,right,t) { init_req(Control,c); }
215 virtual int Opcode() const;
216 };
218 //------------------------------CMoveNNode-------------------------------------
219 class CMoveNNode : public CMoveNode {
220 public:
221 CMoveNNode( Node *c, Node *bol, Node *left, Node *right, const Type* t ) : CMoveNode(bol,left,right,t) { init_req(Control,c); }
222 virtual int Opcode() const;
223 };
225 //------------------------------ConstraintCastNode-----------------------------
226 // cast to a different range
227 class ConstraintCastNode: public TypeNode {
228 public:
229 ConstraintCastNode (Node *n, const Type *t ): TypeNode(t,2) {
230 init_class_id(Class_ConstraintCast);
231 init_req(1, n);
232 }
233 virtual Node *Identity( PhaseTransform *phase );
234 virtual const Type *Value( PhaseTransform *phase ) const;
235 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
236 virtual int Opcode() const;
237 virtual uint ideal_reg() const = 0;
238 virtual Node *Ideal_DU_postCCP( PhaseCCP * );
239 };
241 //------------------------------CastIINode-------------------------------------
242 // cast integer to integer (different range)
243 class CastIINode: public ConstraintCastNode {
244 private:
245 // Can this node be removed post CCP or does it carry a required dependency?
246 const bool _carry_dependency;
247 // Is this node dependent on a range check?
248 const bool _range_check_dependency;
250 protected:
251 virtual uint cmp( const Node &n ) const;
252 virtual uint size_of() const;
254 public:
255 CastIINode(Node *n, const Type *t, bool carry_dependency = false, bool range_check_dependency = false)
256 : ConstraintCastNode(n,t), _carry_dependency(carry_dependency), _range_check_dependency(range_check_dependency) {
257 init_class_id(Class_CastII);
258 }
259 virtual int Opcode() const;
260 virtual uint ideal_reg() const { return Op_RegI; }
261 virtual Node *Identity( PhaseTransform *phase );
262 virtual const Type *Value( PhaseTransform *phase ) const;
263 virtual Node *Ideal_DU_postCCP( PhaseCCP * );
264 const bool has_range_check() {
265 #ifdef _LP64
266 return _range_check_dependency;
267 #else
268 assert(!_range_check_dependency, "Should not have range check dependency");
269 return false;
270 #endif
271 }
272 #ifndef PRODUCT
273 virtual void dump_spec(outputStream *st) const;
274 #endif
275 };
277 //------------------------------CastPPNode-------------------------------------
278 // cast pointer to pointer (different type)
279 class CastPPNode: public ConstraintCastNode {
280 public:
281 CastPPNode (Node *n, const Type *t ): ConstraintCastNode(n, t) {}
282 virtual int Opcode() const;
283 virtual uint ideal_reg() const { return Op_RegP; }
284 virtual Node *Ideal_DU_postCCP( PhaseCCP * );
285 };
287 //------------------------------CheckCastPPNode--------------------------------
288 // for _checkcast, cast pointer to pointer (different type), without JOIN,
289 class CheckCastPPNode: public TypeNode {
290 public:
291 CheckCastPPNode( Node *c, Node *n, const Type *t ) : TypeNode(t,2) {
292 init_class_id(Class_CheckCastPP);
293 init_req(0, c);
294 init_req(1, n);
295 }
297 virtual Node *Identity( PhaseTransform *phase );
298 virtual const Type *Value( PhaseTransform *phase ) const;
299 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
300 virtual int Opcode() const;
301 virtual uint ideal_reg() const { return Op_RegP; }
302 // No longer remove CheckCast after CCP as it gives me a place to hang
303 // the proper address type - which is required to compute anti-deps.
304 //virtual Node *Ideal_DU_postCCP( PhaseCCP * );
305 };
308 //------------------------------EncodeNarrowPtr--------------------------------
309 class EncodeNarrowPtrNode : public TypeNode {
310 protected:
311 EncodeNarrowPtrNode(Node* value, const Type* type):
312 TypeNode(type, 2) {
313 init_class_id(Class_EncodeNarrowPtr);
314 init_req(0, NULL);
315 init_req(1, value);
316 }
317 public:
318 virtual uint ideal_reg() const { return Op_RegN; }
319 virtual Node *Ideal_DU_postCCP( PhaseCCP *ccp );
320 };
322 //------------------------------EncodeP--------------------------------
323 // Encodes an oop pointers into its compressed form
324 // Takes an extra argument which is the real heap base as a long which
325 // may be useful for code generation in the backend.
326 class EncodePNode : public EncodeNarrowPtrNode {
327 public:
328 EncodePNode(Node* value, const Type* type):
329 EncodeNarrowPtrNode(value, type) {
330 init_class_id(Class_EncodeP);
331 }
332 virtual int Opcode() const;
333 virtual Node *Identity( PhaseTransform *phase );
334 virtual const Type *Value( PhaseTransform *phase ) const;
335 };
337 //------------------------------EncodePKlass--------------------------------
338 // Encodes a klass pointer into its compressed form
339 // Takes an extra argument which is the real heap base as a long which
340 // may be useful for code generation in the backend.
341 class EncodePKlassNode : public EncodeNarrowPtrNode {
342 public:
343 EncodePKlassNode(Node* value, const Type* type):
344 EncodeNarrowPtrNode(value, type) {
345 init_class_id(Class_EncodePKlass);
346 }
347 virtual int Opcode() const;
348 virtual Node *Identity( PhaseTransform *phase );
349 virtual const Type *Value( PhaseTransform *phase ) const;
350 };
352 //------------------------------DecodeNarrowPtr--------------------------------
353 class DecodeNarrowPtrNode : public TypeNode {
354 protected:
355 DecodeNarrowPtrNode(Node* value, const Type* type):
356 TypeNode(type, 2) {
357 init_class_id(Class_DecodeNarrowPtr);
358 init_req(0, NULL);
359 init_req(1, value);
360 }
361 public:
362 virtual uint ideal_reg() const { return Op_RegP; }
363 };
365 //------------------------------DecodeN--------------------------------
366 // Converts a narrow oop into a real oop ptr.
367 // Takes an extra argument which is the real heap base as a long which
368 // may be useful for code generation in the backend.
369 class DecodeNNode : public DecodeNarrowPtrNode {
370 public:
371 DecodeNNode(Node* value, const Type* type):
372 DecodeNarrowPtrNode(value, type) {
373 init_class_id(Class_DecodeN);
374 }
375 virtual int Opcode() const;
376 virtual const Type *Value( PhaseTransform *phase ) const;
377 virtual Node *Identity( PhaseTransform *phase );
378 };
380 //------------------------------DecodeNKlass--------------------------------
381 // Converts a narrow klass pointer into a real klass ptr.
382 // Takes an extra argument which is the real heap base as a long which
383 // may be useful for code generation in the backend.
384 class DecodeNKlassNode : public DecodeNarrowPtrNode {
385 public:
386 DecodeNKlassNode(Node* value, const Type* type):
387 DecodeNarrowPtrNode(value, type) {
388 init_class_id(Class_DecodeNKlass);
389 }
390 virtual int Opcode() const;
391 virtual const Type *Value( PhaseTransform *phase ) const;
392 virtual Node *Identity( PhaseTransform *phase );
393 };
395 //------------------------------Conv2BNode-------------------------------------
396 // Convert int/pointer to a Boolean. Map zero to zero, all else to 1.
397 class Conv2BNode : public Node {
398 public:
399 Conv2BNode( Node *i ) : Node(0,i) {}
400 virtual int Opcode() const;
401 virtual const Type *bottom_type() const { return TypeInt::BOOL; }
402 virtual Node *Identity( PhaseTransform *phase );
403 virtual const Type *Value( PhaseTransform *phase ) const;
404 virtual uint ideal_reg() const { return Op_RegI; }
405 };
407 // The conversions operations are all Alpha sorted. Please keep it that way!
408 //------------------------------ConvD2FNode------------------------------------
409 // Convert double to float
410 class ConvD2FNode : public Node {
411 public:
412 ConvD2FNode( Node *in1 ) : Node(0,in1) {}
413 virtual int Opcode() const;
414 virtual const Type *bottom_type() const { return Type::FLOAT; }
415 virtual const Type *Value( PhaseTransform *phase ) const;
416 virtual Node *Identity( PhaseTransform *phase );
417 virtual uint ideal_reg() const { return Op_RegF; }
418 };
420 //------------------------------ConvD2INode------------------------------------
421 // Convert Double to Integer
422 class ConvD2INode : public Node {
423 public:
424 ConvD2INode( Node *in1 ) : Node(0,in1) {}
425 virtual int Opcode() const;
426 virtual const Type *bottom_type() const { return TypeInt::INT; }
427 virtual const Type *Value( PhaseTransform *phase ) const;
428 virtual Node *Identity( PhaseTransform *phase );
429 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
430 virtual uint ideal_reg() const { return Op_RegI; }
431 };
433 //------------------------------ConvD2LNode------------------------------------
434 // Convert Double to Long
435 class ConvD2LNode : public Node {
436 public:
437 ConvD2LNode( Node *dbl ) : Node(0,dbl) {}
438 virtual int Opcode() const;
439 virtual const Type *bottom_type() const { return TypeLong::LONG; }
440 virtual const Type *Value( PhaseTransform *phase ) const;
441 virtual Node *Identity( PhaseTransform *phase );
442 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
443 virtual uint ideal_reg() const { return Op_RegL; }
444 };
446 //------------------------------ConvF2DNode------------------------------------
447 // Convert Float to a Double.
448 class ConvF2DNode : public Node {
449 public:
450 ConvF2DNode( Node *in1 ) : Node(0,in1) {}
451 virtual int Opcode() const;
452 virtual const Type *bottom_type() const { return Type::DOUBLE; }
453 virtual const Type *Value( PhaseTransform *phase ) const;
454 virtual uint ideal_reg() const { return Op_RegD; }
455 };
457 //------------------------------ConvF2INode------------------------------------
458 // Convert float to integer
459 class ConvF2INode : public Node {
460 public:
461 ConvF2INode( Node *in1 ) : Node(0,in1) {}
462 virtual int Opcode() const;
463 virtual const Type *bottom_type() const { return TypeInt::INT; }
464 virtual const Type *Value( PhaseTransform *phase ) const;
465 virtual Node *Identity( PhaseTransform *phase );
466 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
467 virtual uint ideal_reg() const { return Op_RegI; }
468 };
470 //------------------------------ConvF2LNode------------------------------------
471 // Convert float to long
472 class ConvF2LNode : public Node {
473 public:
474 ConvF2LNode( Node *in1 ) : Node(0,in1) {}
475 virtual int Opcode() const;
476 virtual const Type *bottom_type() const { return TypeLong::LONG; }
477 virtual const Type *Value( PhaseTransform *phase ) const;
478 virtual Node *Identity( PhaseTransform *phase );
479 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
480 virtual uint ideal_reg() const { return Op_RegL; }
481 };
483 //------------------------------ConvI2DNode------------------------------------
484 // Convert Integer to Double
485 class ConvI2DNode : public Node {
486 public:
487 ConvI2DNode( Node *in1 ) : Node(0,in1) {}
488 virtual int Opcode() const;
489 virtual const Type *bottom_type() const { return Type::DOUBLE; }
490 virtual const Type *Value( PhaseTransform *phase ) const;
491 virtual uint ideal_reg() const { return Op_RegD; }
492 };
494 //------------------------------ConvI2FNode------------------------------------
495 // Convert Integer to Float
496 class ConvI2FNode : public Node {
497 public:
498 ConvI2FNode( Node *in1 ) : Node(0,in1) {}
499 virtual int Opcode() const;
500 virtual const Type *bottom_type() const { return Type::FLOAT; }
501 virtual const Type *Value( PhaseTransform *phase ) const;
502 virtual Node *Identity( PhaseTransform *phase );
503 virtual uint ideal_reg() const { return Op_RegF; }
504 };
506 //------------------------------ConvI2LNode------------------------------------
507 // Convert integer to long
508 class ConvI2LNode : public TypeNode {
509 public:
510 ConvI2LNode(Node *in1, const TypeLong* t = TypeLong::INT)
511 : TypeNode(t, 2)
512 { init_req(1, in1); }
513 virtual int Opcode() const;
514 virtual const Type *Value( PhaseTransform *phase ) const;
515 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
516 virtual uint ideal_reg() const { return Op_RegL; }
517 };
519 //------------------------------ConvL2DNode------------------------------------
520 // Convert Long to Double
521 class ConvL2DNode : public Node {
522 public:
523 ConvL2DNode( Node *in1 ) : Node(0,in1) {}
524 virtual int Opcode() const;
525 virtual const Type *bottom_type() const { return Type::DOUBLE; }
526 virtual const Type *Value( PhaseTransform *phase ) const;
527 virtual uint ideal_reg() const { return Op_RegD; }
528 };
530 //------------------------------ConvL2FNode------------------------------------
531 // Convert Long to Float
532 class ConvL2FNode : public Node {
533 public:
534 ConvL2FNode( Node *in1 ) : Node(0,in1) {}
535 virtual int Opcode() const;
536 virtual const Type *bottom_type() const { return Type::FLOAT; }
537 virtual const Type *Value( PhaseTransform *phase ) const;
538 virtual uint ideal_reg() const { return Op_RegF; }
539 };
541 //------------------------------ConvL2INode------------------------------------
542 // Convert long to integer
543 class ConvL2INode : public Node {
544 public:
545 ConvL2INode( Node *in1 ) : Node(0,in1) {}
546 virtual int Opcode() const;
547 virtual const Type *bottom_type() const { return TypeInt::INT; }
548 virtual Node *Identity( PhaseTransform *phase );
549 virtual const Type *Value( PhaseTransform *phase ) const;
550 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
551 virtual uint ideal_reg() const { return Op_RegI; }
552 };
554 //------------------------------CastX2PNode-------------------------------------
555 // convert a machine-pointer-sized integer to a raw pointer
556 class CastX2PNode : public Node {
557 public:
558 CastX2PNode( Node *n ) : Node(NULL, n) {}
559 virtual int Opcode() const;
560 virtual const Type *Value( PhaseTransform *phase ) const;
561 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
562 virtual Node *Identity( PhaseTransform *phase );
563 virtual uint ideal_reg() const { return Op_RegP; }
564 virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; }
565 };
567 //------------------------------CastP2XNode-------------------------------------
568 // Used in both 32-bit and 64-bit land.
569 // Used for card-marks and unsafe pointer math.
570 class CastP2XNode : public Node {
571 public:
572 CastP2XNode( Node *ctrl, Node *n ) : Node(ctrl, n) {}
573 virtual int Opcode() const;
574 virtual const Type *Value( PhaseTransform *phase ) const;
575 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
576 virtual Node *Identity( PhaseTransform *phase );
577 virtual uint ideal_reg() const { return Op_RegX; }
578 virtual const Type *bottom_type() const { return TypeX_X; }
579 // Return false to keep node from moving away from an associated card mark.
580 virtual bool depends_only_on_test() const { return false; }
581 };
583 //------------------------------ThreadLocalNode--------------------------------
584 // Ideal Node which returns the base of ThreadLocalStorage.
585 class ThreadLocalNode : public Node {
586 public:
587 ThreadLocalNode( ) : Node((Node*)Compile::current()->root()) {}
588 virtual int Opcode() const;
589 virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM;}
590 virtual uint ideal_reg() const { return Op_RegP; }
591 };
593 //------------------------------LoadReturnPCNode-------------------------------
594 class LoadReturnPCNode: public Node {
595 public:
596 LoadReturnPCNode(Node *c) : Node(c) { }
597 virtual int Opcode() const;
598 virtual uint ideal_reg() const { return Op_RegP; }
599 };
602 //-----------------------------RoundFloatNode----------------------------------
603 class RoundFloatNode: public Node {
604 public:
605 RoundFloatNode(Node* c, Node *in1): Node(c, in1) {}
606 virtual int Opcode() const;
607 virtual const Type *bottom_type() const { return Type::FLOAT; }
608 virtual uint ideal_reg() const { return Op_RegF; }
609 virtual Node *Identity( PhaseTransform *phase );
610 virtual const Type *Value( PhaseTransform *phase ) const;
611 };
614 //-----------------------------RoundDoubleNode---------------------------------
615 class RoundDoubleNode: public Node {
616 public:
617 RoundDoubleNode(Node* c, Node *in1): Node(c, in1) {}
618 virtual int Opcode() const;
619 virtual const Type *bottom_type() const { return Type::DOUBLE; }
620 virtual uint ideal_reg() const { return Op_RegD; }
621 virtual Node *Identity( PhaseTransform *phase );
622 virtual const Type *Value( PhaseTransform *phase ) const;
623 };
625 //------------------------------Opaque1Node------------------------------------
626 // A node to prevent unwanted optimizations. Allows constant folding.
627 // Stops value-numbering, Ideal calls or Identity functions.
628 class Opaque1Node : public Node {
629 virtual uint hash() const ; // { return NO_HASH; }
630 virtual uint cmp( const Node &n ) const;
631 public:
632 Opaque1Node( Compile* C, Node *n ) : Node(0,n) {
633 // Put it on the Macro nodes list to removed during macro nodes expansion.
634 init_flags(Flag_is_macro);
635 C->add_macro_node(this);
636 }
637 // Special version for the pre-loop to hold the original loop limit
638 // which is consumed by range check elimination.
639 Opaque1Node( Compile* C, Node *n, Node* orig_limit ) : Node(0,n,orig_limit) {
640 // Put it on the Macro nodes list to removed during macro nodes expansion.
641 init_flags(Flag_is_macro);
642 C->add_macro_node(this);
643 }
644 Node* original_loop_limit() { return req()==3 ? in(2) : NULL; }
645 virtual int Opcode() const;
646 virtual const Type *bottom_type() const { return TypeInt::INT; }
647 virtual Node *Identity( PhaseTransform *phase );
648 };
650 //------------------------------Opaque2Node------------------------------------
651 // A node to prevent unwanted optimizations. Allows constant folding. Stops
652 // value-numbering, most Ideal calls or Identity functions. This Node is
653 // specifically designed to prevent the pre-increment value of a loop trip
654 // counter from being live out of the bottom of the loop (hence causing the
655 // pre- and post-increment values both being live and thus requiring an extra
656 // temp register and an extra move). If we "accidentally" optimize through
657 // this kind of a Node, we'll get slightly pessimal, but correct, code. Thus
658 // it's OK to be slightly sloppy on optimizations here.
659 class Opaque2Node : public Node {
660 virtual uint hash() const ; // { return NO_HASH; }
661 virtual uint cmp( const Node &n ) const;
662 public:
663 Opaque2Node( Compile* C, Node *n ) : Node(0,n) {
664 // Put it on the Macro nodes list to removed during macro nodes expansion.
665 init_flags(Flag_is_macro);
666 C->add_macro_node(this);
667 }
668 virtual int Opcode() const;
669 virtual const Type *bottom_type() const { return TypeInt::INT; }
670 };
672 //------------------------------Opaque3Node------------------------------------
673 // A node to prevent unwanted optimizations. Will be optimized only during
674 // macro nodes expansion.
675 class Opaque3Node : public Opaque2Node {
676 int _opt; // what optimization it was used for
677 public:
678 enum { RTM_OPT };
679 Opaque3Node(Compile* C, Node *n, int opt) : Opaque2Node(C, n), _opt(opt) {}
680 virtual int Opcode() const;
681 bool rtm_opt() const { return (_opt == RTM_OPT); }
682 };
684 //------------------------------ProfileBooleanNode-------------------------------
685 // A node represents value profile for a boolean during parsing.
686 // Once parsing is over, the node goes away (during IGVN).
687 // It is used to override branch frequencies from MDO (see has_injected_profile in parse2.cpp).
688 class ProfileBooleanNode : public Node {
689 uint _false_cnt;
690 uint _true_cnt;
691 bool _consumed;
692 bool _delay_removal;
693 virtual uint hash() const ; // { return NO_HASH; }
694 virtual uint cmp( const Node &n ) const;
695 public:
696 ProfileBooleanNode(Node *n, uint false_cnt, uint true_cnt) : Node(0, n),
697 _false_cnt(false_cnt), _true_cnt(true_cnt), _delay_removal(true), _consumed(false) {}
699 uint false_count() const { return _false_cnt; }
700 uint true_count() const { return _true_cnt; }
702 void consume() { _consumed = true; }
704 virtual int Opcode() const;
705 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
706 virtual Node *Identity(PhaseTransform *phase);
707 virtual const Type *bottom_type() const { return TypeInt::BOOL; }
708 };
710 //----------------------PartialSubtypeCheckNode--------------------------------
711 // The 2nd slow-half of a subtype check. Scan the subklass's 2ndary superklass
712 // array for an instance of the superklass. Set a hidden internal cache on a
713 // hit (cache is checked with exposed code in gen_subtype_check()). Return
714 // not zero for a miss or zero for a hit.
715 class PartialSubtypeCheckNode : public Node {
716 public:
717 PartialSubtypeCheckNode(Node* c, Node* sub, Node* super) : Node(c,sub,super) {}
718 virtual int Opcode() const;
719 virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; }
720 virtual uint ideal_reg() const { return Op_RegP; }
721 };
723 //
724 class MoveI2FNode : public Node {
725 public:
726 MoveI2FNode( Node *value ) : Node(0,value) {}
727 virtual int Opcode() const;
728 virtual const Type *bottom_type() const { return Type::FLOAT; }
729 virtual uint ideal_reg() const { return Op_RegF; }
730 virtual const Type* Value( PhaseTransform *phase ) const;
731 };
733 class MoveL2DNode : public Node {
734 public:
735 MoveL2DNode( Node *value ) : Node(0,value) {}
736 virtual int Opcode() const;
737 virtual const Type *bottom_type() const { return Type::DOUBLE; }
738 virtual uint ideal_reg() const { return Op_RegD; }
739 virtual const Type* Value( PhaseTransform *phase ) const;
740 };
742 class MoveF2INode : public Node {
743 public:
744 MoveF2INode( Node *value ) : Node(0,value) {}
745 virtual int Opcode() const;
746 virtual const Type *bottom_type() const { return TypeInt::INT; }
747 virtual uint ideal_reg() const { return Op_RegI; }
748 virtual const Type* Value( PhaseTransform *phase ) const;
749 };
751 class MoveD2LNode : public Node {
752 public:
753 MoveD2LNode( Node *value ) : Node(0,value) {}
754 virtual int Opcode() const;
755 virtual const Type *bottom_type() const { return TypeLong::LONG; }
756 virtual uint ideal_reg() const { return Op_RegL; }
757 virtual const Type* Value( PhaseTransform *phase ) const;
758 };
760 //---------- CountBitsNode -----------------------------------------------------
761 class CountBitsNode : public Node {
762 public:
763 CountBitsNode(Node* in1) : Node(0, in1) {}
764 const Type* bottom_type() const { return TypeInt::INT; }
765 virtual uint ideal_reg() const { return Op_RegI; }
766 };
768 //---------- CountLeadingZerosINode --------------------------------------------
769 // Count leading zeros (0-bit count starting from MSB) of an integer.
770 class CountLeadingZerosINode : public CountBitsNode {
771 public:
772 CountLeadingZerosINode(Node* in1) : CountBitsNode(in1) {}
773 virtual int Opcode() const;
774 virtual const Type* Value(PhaseTransform* phase) const;
775 };
777 //---------- CountLeadingZerosLNode --------------------------------------------
778 // Count leading zeros (0-bit count starting from MSB) of a long.
779 class CountLeadingZerosLNode : public CountBitsNode {
780 public:
781 CountLeadingZerosLNode(Node* in1) : CountBitsNode(in1) {}
782 virtual int Opcode() const;
783 virtual const Type* Value(PhaseTransform* phase) const;
784 };
786 //---------- CountTrailingZerosINode -------------------------------------------
787 // Count trailing zeros (0-bit count starting from LSB) of an integer.
788 class CountTrailingZerosINode : public CountBitsNode {
789 public:
790 CountTrailingZerosINode(Node* in1) : CountBitsNode(in1) {}
791 virtual int Opcode() const;
792 virtual const Type* Value(PhaseTransform* phase) const;
793 };
795 //---------- CountTrailingZerosLNode -------------------------------------------
796 // Count trailing zeros (0-bit count starting from LSB) of a long.
797 class CountTrailingZerosLNode : public CountBitsNode {
798 public:
799 CountTrailingZerosLNode(Node* in1) : CountBitsNode(in1) {}
800 virtual int Opcode() const;
801 virtual const Type* Value(PhaseTransform* phase) const;
802 };
804 //---------- PopCountINode -----------------------------------------------------
805 // Population count (bit count) of an integer.
806 class PopCountINode : public CountBitsNode {
807 public:
808 PopCountINode(Node* in1) : CountBitsNode(in1) {}
809 virtual int Opcode() const;
810 };
812 //---------- PopCountLNode -----------------------------------------------------
813 // Population count (bit count) of a long.
814 class PopCountLNode : public CountBitsNode {
815 public:
816 PopCountLNode(Node* in1) : CountBitsNode(in1) {}
817 virtual int Opcode() const;
818 };
820 #endif // SHARE_VM_OPTO_CONNODE_HPP