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