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 */ 24 25 #ifndef SHARE_VM_OPTO_CONNODE_HPP 26 #define SHARE_VM_OPTO_CONNODE_HPP 27 28 #include "opto/node.hpp" 29 #include "opto/opcodes.hpp" 30 #include "opto/type.hpp" 31 32 class PhaseTransform; 33 class MachNode; 34 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; } 47 48 // Polymorphic factory method: 49 static ConNode* make( Compile* C, const Type *t ); 50 }; 51 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; 58 59 // Factory method: 60 static ConINode* make( Compile* C, int con ) { 61 return new (C) ConINode( TypeInt::make(con) ); 62 } 63 64 }; 65 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; 72 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 }; 81 82 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 }; 90 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 }; 98 99 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; 106 107 // Factory method: 108 static ConLNode* make( Compile *C ,jlong con ) { 109 return new (C) ConLNode( TypeLong::make(con) ); 110 } 111 112 }; 113 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; 120 121 // Factory method: 122 static ConFNode* make( Compile *C, float con ) { 123 return new (C) ConFNode( TypeF::make(con) ); 124 } 125 126 }; 127 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; 134 135 // Factory method: 136 static ConDNode* make( Compile *C, double con ) { 137 return new (C) ConDNode( TypeD::make(con) ); 138 } 139 140 }; 141 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 }; 154 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 }; 179 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 }; 187 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 }; 195 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 }; 203 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 }; 210 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 }; 217 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 }; 224 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 }; 239 240 //------------------------------CastIINode------------------------------------- 241 // cast integer to integer (different range) 242 class CastIINode: public ConstraintCastNode { 243 private: 244 // Can this node be removed post CCP or does it carry a required dependency? 245 const bool _carry_dependency; 246 // Is this node dependent on a range check? 247 const bool _range_check_dependency; 248 249 protected: 250 virtual uint cmp( const Node &n ) const; 251 virtual uint size_of() const; 252 253 public: 254 CastIINode(Node *n, const Type *t, bool carry_dependency = false, bool range_check_dependency = false) 255 : ConstraintCastNode(n,t), _carry_dependency(carry_dependency), _range_check_dependency(range_check_dependency) { 256 init_class_id(Class_CastII); 257 } 258 virtual int Opcode() const; 259 virtual uint ideal_reg() const { return Op_RegI; } 260 virtual Node *Identity( PhaseTransform *phase ); 261 virtual const Type *Value( PhaseTransform *phase ) const; 262 const bool has_range_check() { 263 #ifdef _LP64 264 return _range_check_dependency; 265 #else 266 assert(!_range_check_dependency, "Should not have range check dependency"); 267 return false; 268 #endif 269 } 270 #ifndef PRODUCT 271 virtual void dump_spec(outputStream *st) const; 272 #endif 273 }; 274 275 //------------------------------CastPPNode------------------------------------- 276 // cast pointer to pointer (different type) 277 class CastPPNode: public ConstraintCastNode { 278 public: 279 CastPPNode (Node *n, const Type *t ): ConstraintCastNode(n, t) {} 280 virtual int Opcode() const; 281 virtual uint ideal_reg() const { return Op_RegP; } 282 }; 283 284 //------------------------------CheckCastPPNode-------------------------------- 285 // for _checkcast, cast pointer to pointer (different type), without JOIN, 286 class CheckCastPPNode: public TypeNode { 287 public: 288 CheckCastPPNode( Node *c, Node *n, const Type *t ) : TypeNode(t,2) { 289 init_class_id(Class_CheckCastPP); 290 init_req(0, c); 291 init_req(1, n); 292 } 293 294 virtual Node *Identity( PhaseTransform *phase ); 295 virtual const Type *Value( PhaseTransform *phase ) const; 296 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 297 virtual int Opcode() const; 298 virtual uint ideal_reg() const { return Op_RegP; } 299 }; 300 301 302 //------------------------------EncodeNarrowPtr-------------------------------- 303 class EncodeNarrowPtrNode : public TypeNode { 304 protected: 305 EncodeNarrowPtrNode(Node* value, const Type* type): 306 TypeNode(type, 2) { 307 init_class_id(Class_EncodeNarrowPtr); 308 init_req(0, NULL); 309 init_req(1, value); 310 } 311 public: 312 virtual uint ideal_reg() const { return Op_RegN; } 313 }; 314 315 //------------------------------EncodeP-------------------------------- 316 // Encodes an oop pointers into its compressed form 317 // Takes an extra argument which is the real heap base as a long which 318 // may be useful for code generation in the backend. 319 class EncodePNode : public EncodeNarrowPtrNode { 320 public: 321 EncodePNode(Node* value, const Type* type): 322 EncodeNarrowPtrNode(value, type) { 323 init_class_id(Class_EncodeP); 324 } 325 virtual int Opcode() const; 326 virtual Node *Identity( PhaseTransform *phase ); 327 virtual const Type *Value( PhaseTransform *phase ) const; 328 }; 329 330 //------------------------------EncodePKlass-------------------------------- 331 // Encodes a klass pointer into its compressed form 332 // Takes an extra argument which is the real heap base as a long which 333 // may be useful for code generation in the backend. 334 class EncodePKlassNode : public EncodeNarrowPtrNode { 335 public: 336 EncodePKlassNode(Node* value, const Type* type): 337 EncodeNarrowPtrNode(value, type) { 338 init_class_id(Class_EncodePKlass); 339 } 340 virtual int Opcode() const; 341 virtual Node *Identity( PhaseTransform *phase ); 342 virtual const Type *Value( PhaseTransform *phase ) const; 343 }; 344 345 //------------------------------DecodeNarrowPtr-------------------------------- 346 class DecodeNarrowPtrNode : public TypeNode { 347 protected: 348 DecodeNarrowPtrNode(Node* value, const Type* type): 349 TypeNode(type, 2) { 350 init_class_id(Class_DecodeNarrowPtr); 351 init_req(0, NULL); 352 init_req(1, value); 353 } 354 public: 355 virtual uint ideal_reg() const { return Op_RegP; } 356 }; 357 358 //------------------------------DecodeN-------------------------------- 359 // Converts a narrow oop into a real oop ptr. 360 // Takes an extra argument which is the real heap base as a long which 361 // may be useful for code generation in the backend. 362 class DecodeNNode : public DecodeNarrowPtrNode { 363 public: 364 DecodeNNode(Node* value, const Type* type): 365 DecodeNarrowPtrNode(value, type) { 366 init_class_id(Class_DecodeN); 367 } 368 virtual int Opcode() const; 369 virtual const Type *Value( PhaseTransform *phase ) const; 370 virtual Node *Identity( PhaseTransform *phase ); 371 }; 372 373 //------------------------------DecodeNKlass-------------------------------- 374 // Converts a narrow klass pointer into a real klass ptr. 375 // Takes an extra argument which is the real heap base as a long which 376 // may be useful for code generation in the backend. 377 class DecodeNKlassNode : public DecodeNarrowPtrNode { 378 public: 379 DecodeNKlassNode(Node* value, const Type* type): 380 DecodeNarrowPtrNode(value, type) { 381 init_class_id(Class_DecodeNKlass); 382 } 383 virtual int Opcode() const; 384 virtual const Type *Value( PhaseTransform *phase ) const; 385 virtual Node *Identity( PhaseTransform *phase ); 386 }; 387 388 //------------------------------Conv2BNode------------------------------------- 389 // Convert int/pointer to a Boolean. Map zero to zero, all else to 1. 390 class Conv2BNode : public Node { 391 public: 392 Conv2BNode( Node *i ) : Node(0,i) {} 393 virtual int Opcode() const; 394 virtual const Type *bottom_type() const { return TypeInt::BOOL; } 395 virtual Node *Identity( PhaseTransform *phase ); 396 virtual const Type *Value( PhaseTransform *phase ) const; 397 virtual uint ideal_reg() const { return Op_RegI; } 398 }; 399 400 // The conversions operations are all Alpha sorted. Please keep it that way! 401 //------------------------------ConvD2FNode------------------------------------ 402 // Convert double to float 403 class ConvD2FNode : public Node { 404 public: 405 ConvD2FNode( Node *in1 ) : Node(0,in1) {} 406 virtual int Opcode() const; 407 virtual const Type *bottom_type() const { return Type::FLOAT; } 408 virtual const Type *Value( PhaseTransform *phase ) const; 409 virtual Node *Identity( PhaseTransform *phase ); 410 virtual uint ideal_reg() const { return Op_RegF; } 411 }; 412 413 //------------------------------ConvD2INode------------------------------------ 414 // Convert Double to Integer 415 class ConvD2INode : public Node { 416 public: 417 ConvD2INode( Node *in1 ) : Node(0,in1) {} 418 virtual int Opcode() const; 419 virtual const Type *bottom_type() const { return TypeInt::INT; } 420 virtual const Type *Value( PhaseTransform *phase ) const; 421 virtual Node *Identity( PhaseTransform *phase ); 422 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 423 virtual uint ideal_reg() const { return Op_RegI; } 424 }; 425 426 //------------------------------ConvD2LNode------------------------------------ 427 // Convert Double to Long 428 class ConvD2LNode : public Node { 429 public: 430 ConvD2LNode( Node *dbl ) : Node(0,dbl) {} 431 virtual int Opcode() const; 432 virtual const Type *bottom_type() const { return TypeLong::LONG; } 433 virtual const Type *Value( PhaseTransform *phase ) const; 434 virtual Node *Identity( PhaseTransform *phase ); 435 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 436 virtual uint ideal_reg() const { return Op_RegL; } 437 }; 438 439 //------------------------------ConvF2DNode------------------------------------ 440 // Convert Float to a Double. 441 class ConvF2DNode : public Node { 442 public: 443 ConvF2DNode( Node *in1 ) : Node(0,in1) {} 444 virtual int Opcode() const; 445 virtual const Type *bottom_type() const { return Type::DOUBLE; } 446 virtual const Type *Value( PhaseTransform *phase ) const; 447 virtual uint ideal_reg() const { return Op_RegD; } 448 }; 449 450 //------------------------------ConvF2INode------------------------------------ 451 // Convert float to integer 452 class ConvF2INode : public Node { 453 public: 454 ConvF2INode( Node *in1 ) : Node(0,in1) {} 455 virtual int Opcode() const; 456 virtual const Type *bottom_type() const { return TypeInt::INT; } 457 virtual const Type *Value( PhaseTransform *phase ) const; 458 virtual Node *Identity( PhaseTransform *phase ); 459 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 460 virtual uint ideal_reg() const { return Op_RegI; } 461 }; 462 463 //------------------------------ConvF2LNode------------------------------------ 464 // Convert float to long 465 class ConvF2LNode : public Node { 466 public: 467 ConvF2LNode( Node *in1 ) : Node(0,in1) {} 468 virtual int Opcode() const; 469 virtual const Type *bottom_type() const { return TypeLong::LONG; } 470 virtual const Type *Value( PhaseTransform *phase ) const; 471 virtual Node *Identity( PhaseTransform *phase ); 472 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 473 virtual uint ideal_reg() const { return Op_RegL; } 474 }; 475 476 //------------------------------ConvI2DNode------------------------------------ 477 // Convert Integer to Double 478 class ConvI2DNode : public Node { 479 public: 480 ConvI2DNode( Node *in1 ) : Node(0,in1) {} 481 virtual int Opcode() const; 482 virtual const Type *bottom_type() const { return Type::DOUBLE; } 483 virtual const Type *Value( PhaseTransform *phase ) const; 484 virtual uint ideal_reg() const { return Op_RegD; } 485 }; 486 487 //------------------------------ConvI2FNode------------------------------------ 488 // Convert Integer to Float 489 class ConvI2FNode : public Node { 490 public: 491 ConvI2FNode( Node *in1 ) : Node(0,in1) {} 492 virtual int Opcode() const; 493 virtual const Type *bottom_type() const { return Type::FLOAT; } 494 virtual const Type *Value( PhaseTransform *phase ) const; 495 virtual Node *Identity( PhaseTransform *phase ); 496 virtual uint ideal_reg() const { return Op_RegF; } 497 }; 498 499 //------------------------------ConvI2LNode------------------------------------ 500 // Convert integer to long 501 class ConvI2LNode : public TypeNode { 502 public: 503 ConvI2LNode(Node *in1, const TypeLong* t = TypeLong::INT) 504 : TypeNode(t, 2) 505 { init_req(1, in1); } 506 virtual int Opcode() const; 507 virtual const Type *Value( PhaseTransform *phase ) const; 508 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 509 virtual uint ideal_reg() const { return Op_RegL; } 510 }; 511 512 //------------------------------ConvL2DNode------------------------------------ 513 // Convert Long to Double 514 class ConvL2DNode : public Node { 515 public: 516 ConvL2DNode( Node *in1 ) : Node(0,in1) {} 517 virtual int Opcode() const; 518 virtual const Type *bottom_type() const { return Type::DOUBLE; } 519 virtual const Type *Value( PhaseTransform *phase ) const; 520 virtual uint ideal_reg() const { return Op_RegD; } 521 }; 522 523 //------------------------------ConvL2FNode------------------------------------ 524 // Convert Long to Float 525 class ConvL2FNode : public Node { 526 public: 527 ConvL2FNode( Node *in1 ) : Node(0,in1) {} 528 virtual int Opcode() const; 529 virtual const Type *bottom_type() const { return Type::FLOAT; } 530 virtual const Type *Value( PhaseTransform *phase ) const; 531 virtual uint ideal_reg() const { return Op_RegF; } 532 }; 533 534 //------------------------------ConvL2INode------------------------------------ 535 // Convert long to integer 536 class ConvL2INode : public Node { 537 public: 538 ConvL2INode( Node *in1 ) : Node(0,in1) {} 539 virtual int Opcode() const; 540 virtual const Type *bottom_type() const { return TypeInt::INT; } 541 virtual Node *Identity( PhaseTransform *phase ); 542 virtual const Type *Value( PhaseTransform *phase ) const; 543 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 544 virtual uint ideal_reg() const { return Op_RegI; } 545 }; 546 547 //------------------------------CastX2PNode------------------------------------- 548 // convert a machine-pointer-sized integer to a raw pointer 549 class CastX2PNode : public Node { 550 public: 551 CastX2PNode( Node *n ) : Node(NULL, n) {} 552 virtual int Opcode() const; 553 virtual const Type *Value( PhaseTransform *phase ) const; 554 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 555 virtual Node *Identity( PhaseTransform *phase ); 556 virtual uint ideal_reg() const { return Op_RegP; } 557 virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } 558 }; 559 560 //------------------------------CastP2XNode------------------------------------- 561 // Used in both 32-bit and 64-bit land. 562 // Used for card-marks and unsafe pointer math. 563 class CastP2XNode : public Node { 564 public: 565 CastP2XNode( Node *ctrl, Node *n ) : Node(ctrl, n) {} 566 virtual int Opcode() const; 567 virtual const Type *Value( PhaseTransform *phase ) const; 568 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 569 virtual Node *Identity( PhaseTransform *phase ); 570 virtual uint ideal_reg() const { return Op_RegX; } 571 virtual const Type *bottom_type() const { return TypeX_X; } 572 // Return false to keep node from moving away from an associated card mark. 573 virtual bool depends_only_on_test() const { return false; } 574 }; 575 576 //------------------------------ThreadLocalNode-------------------------------- 577 // Ideal Node which returns the base of ThreadLocalStorage. 578 class ThreadLocalNode : public Node { 579 public: 580 ThreadLocalNode( ) : Node((Node*)Compile::current()->root()) {} 581 virtual int Opcode() const; 582 virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM;} 583 virtual uint ideal_reg() const { return Op_RegP; } 584 }; 585 586 //------------------------------LoadReturnPCNode------------------------------- 587 class LoadReturnPCNode: public Node { 588 public: 589 LoadReturnPCNode(Node *c) : Node(c) { } 590 virtual int Opcode() const; 591 virtual uint ideal_reg() const { return Op_RegP; } 592 }; 593 594 595 //-----------------------------RoundFloatNode---------------------------------- 596 class RoundFloatNode: public Node { 597 public: 598 RoundFloatNode(Node* c, Node *in1): Node(c, in1) {} 599 virtual int Opcode() const; 600 virtual const Type *bottom_type() const { return Type::FLOAT; } 601 virtual uint ideal_reg() const { return Op_RegF; } 602 virtual Node *Identity( PhaseTransform *phase ); 603 virtual const Type *Value( PhaseTransform *phase ) const; 604 }; 605 606 607 //-----------------------------RoundDoubleNode--------------------------------- 608 class RoundDoubleNode: public Node { 609 public: 610 RoundDoubleNode(Node* c, Node *in1): Node(c, in1) {} 611 virtual int Opcode() const; 612 virtual const Type *bottom_type() const { return Type::DOUBLE; } 613 virtual uint ideal_reg() const { return Op_RegD; } 614 virtual Node *Identity( PhaseTransform *phase ); 615 virtual const Type *Value( PhaseTransform *phase ) const; 616 }; 617 618 //------------------------------Opaque1Node------------------------------------ 619 // A node to prevent unwanted optimizations. Allows constant folding. 620 // Stops value-numbering, Ideal calls or Identity functions. 621 class Opaque1Node : public Node { 622 virtual uint hash() const ; // { return NO_HASH; } 623 virtual uint cmp( const Node &n ) const; 624 public: 625 Opaque1Node( Compile* C, Node *n ) : Node(0,n) { 626 // Put it on the Macro nodes list to removed during macro nodes expansion. 627 init_flags(Flag_is_macro); 628 C->add_macro_node(this); 629 } 630 // Special version for the pre-loop to hold the original loop limit 631 // which is consumed by range check elimination. 632 Opaque1Node( Compile* C, Node *n, Node* orig_limit ) : Node(0,n,orig_limit) { 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 Node* original_loop_limit() { return req()==3 ? in(2) : NULL; } 638 virtual int Opcode() const; 639 virtual const Type *bottom_type() const { return TypeInt::INT; } 640 virtual Node *Identity( PhaseTransform *phase ); 641 }; 642 643 //------------------------------Opaque2Node------------------------------------ 644 // A node to prevent unwanted optimizations. Allows constant folding. Stops 645 // value-numbering, most Ideal calls or Identity functions. This Node is 646 // specifically designed to prevent the pre-increment value of a loop trip 647 // counter from being live out of the bottom of the loop (hence causing the 648 // pre- and post-increment values both being live and thus requiring an extra 649 // temp register and an extra move). If we "accidentally" optimize through 650 // this kind of a Node, we'll get slightly pessimal, but correct, code. Thus 651 // it's OK to be slightly sloppy on optimizations here. 652 class Opaque2Node : public Node { 653 virtual uint hash() const ; // { return NO_HASH; } 654 virtual uint cmp( const Node &n ) const; 655 public: 656 Opaque2Node( Compile* C, Node *n ) : Node(0,n) { 657 // Put it on the Macro nodes list to removed during macro nodes expansion. 658 init_flags(Flag_is_macro); 659 C->add_macro_node(this); 660 } 661 virtual int Opcode() const; 662 virtual const Type *bottom_type() const { return TypeInt::INT; } 663 }; 664 665 //------------------------------Opaque3Node------------------------------------ 666 // A node to prevent unwanted optimizations. Will be optimized only during 667 // macro nodes expansion. 668 class Opaque3Node : public Opaque2Node { 669 int _opt; // what optimization it was used for 670 public: 671 enum { RTM_OPT }; 672 Opaque3Node(Compile* C, Node *n, int opt) : Opaque2Node(C, n), _opt(opt) {} 673 virtual int Opcode() const; 674 bool rtm_opt() const { return (_opt == RTM_OPT); } 675 }; 676 677 //------------------------------ProfileBooleanNode------------------------------- 678 // A node represents value profile for a boolean during parsing. 679 // Once parsing is over, the node goes away (during IGVN). 680 // It is used to override branch frequencies from MDO (see has_injected_profile in parse2.cpp). 681 class ProfileBooleanNode : public Node { 682 uint _false_cnt; 683 uint _true_cnt; 684 bool _consumed; 685 bool _delay_removal; 686 virtual uint hash() const ; // { return NO_HASH; } 687 virtual uint cmp( const Node &n ) const; 688 public: 689 ProfileBooleanNode(Node *n, uint false_cnt, uint true_cnt) : Node(0, n), 690 _false_cnt(false_cnt), _true_cnt(true_cnt), _delay_removal(true), _consumed(false) {} 691 692 uint false_count() const { return _false_cnt; } 693 uint true_count() const { return _true_cnt; } 694 695 void consume() { _consumed = true; } 696 697 virtual int Opcode() const; 698 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 699 virtual Node *Identity(PhaseTransform *phase); 700 virtual const Type *bottom_type() const { return TypeInt::BOOL; } 701 }; 702 703 //----------------------PartialSubtypeCheckNode-------------------------------- 704 // The 2nd slow-half of a subtype check. Scan the subklass's 2ndary superklass 705 // array for an instance of the superklass. Set a hidden internal cache on a 706 // hit (cache is checked with exposed code in gen_subtype_check()). Return 707 // not zero for a miss or zero for a hit. 708 class PartialSubtypeCheckNode : public Node { 709 public: 710 PartialSubtypeCheckNode(Node* c, Node* sub, Node* super) : Node(c,sub,super) {} 711 virtual int Opcode() const; 712 virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } 713 virtual uint ideal_reg() const { return Op_RegP; } 714 }; 715 716 // 717 class MoveI2FNode : public Node { 718 public: 719 MoveI2FNode( Node *value ) : Node(0,value) {} 720 virtual int Opcode() const; 721 virtual const Type *bottom_type() const { return Type::FLOAT; } 722 virtual uint ideal_reg() const { return Op_RegF; } 723 virtual const Type* Value( PhaseTransform *phase ) const; 724 }; 725 726 class MoveL2DNode : public Node { 727 public: 728 MoveL2DNode( Node *value ) : Node(0,value) {} 729 virtual int Opcode() const; 730 virtual const Type *bottom_type() const { return Type::DOUBLE; } 731 virtual uint ideal_reg() const { return Op_RegD; } 732 virtual const Type* Value( PhaseTransform *phase ) const; 733 }; 734 735 class MoveF2INode : public Node { 736 public: 737 MoveF2INode( Node *value ) : Node(0,value) {} 738 virtual int Opcode() const; 739 virtual const Type *bottom_type() const { return TypeInt::INT; } 740 virtual uint ideal_reg() const { return Op_RegI; } 741 virtual const Type* Value( PhaseTransform *phase ) const; 742 }; 743 744 class MoveD2LNode : public Node { 745 public: 746 MoveD2LNode( Node *value ) : Node(0,value) {} 747 virtual int Opcode() const; 748 virtual const Type *bottom_type() const { return TypeLong::LONG; } 749 virtual uint ideal_reg() const { return Op_RegL; } 750 virtual const Type* Value( PhaseTransform *phase ) const; 751 }; 752 753 //---------- CountBitsNode ----------------------------------------------------- 754 class CountBitsNode : public Node { 755 public: 756 CountBitsNode(Node* in1) : Node(0, in1) {} 757 const Type* bottom_type() const { return TypeInt::INT; } 758 virtual uint ideal_reg() const { return Op_RegI; } 759 }; 760 761 //---------- CountLeadingZerosINode -------------------------------------------- 762 // Count leading zeros (0-bit count starting from MSB) of an integer. 763 class CountLeadingZerosINode : public CountBitsNode { 764 public: 765 CountLeadingZerosINode(Node* in1) : CountBitsNode(in1) {} 766 virtual int Opcode() const; 767 virtual const Type* Value(PhaseTransform* phase) const; 768 }; 769 770 //---------- CountLeadingZerosLNode -------------------------------------------- 771 // Count leading zeros (0-bit count starting from MSB) of a long. 772 class CountLeadingZerosLNode : public CountBitsNode { 773 public: 774 CountLeadingZerosLNode(Node* in1) : CountBitsNode(in1) {} 775 virtual int Opcode() const; 776 virtual const Type* Value(PhaseTransform* phase) const; 777 }; 778 779 //---------- CountTrailingZerosINode ------------------------------------------- 780 // Count trailing zeros (0-bit count starting from LSB) of an integer. 781 class CountTrailingZerosINode : public CountBitsNode { 782 public: 783 CountTrailingZerosINode(Node* in1) : CountBitsNode(in1) {} 784 virtual int Opcode() const; 785 virtual const Type* Value(PhaseTransform* phase) const; 786 }; 787 788 //---------- CountTrailingZerosLNode ------------------------------------------- 789 // Count trailing zeros (0-bit count starting from LSB) of a long. 790 class CountTrailingZerosLNode : public CountBitsNode { 791 public: 792 CountTrailingZerosLNode(Node* in1) : CountBitsNode(in1) {} 793 virtual int Opcode() const; 794 virtual const Type* Value(PhaseTransform* phase) const; 795 }; 796 797 //---------- PopCountINode ----------------------------------------------------- 798 // Population count (bit count) of an integer. 799 class PopCountINode : public CountBitsNode { 800 public: 801 PopCountINode(Node* in1) : CountBitsNode(in1) {} 802 virtual int Opcode() const; 803 }; 804 805 //---------- PopCountLNode ----------------------------------------------------- 806 // Population count (bit count) of a long. 807 class PopCountLNode : public CountBitsNode { 808 public: 809 PopCountLNode(Node* in1) : CountBitsNode(in1) {} 810 virtual int Opcode() const; 811 }; 812 813 #endif // SHARE_VM_OPTO_CONNODE_HPP