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_CASTNODE_HPP 26 #define SHARE_VM_OPTO_CASTNODE_HPP 27 28 #include "opto/node.hpp" 29 #include "opto/opcodes.hpp" 30 31 32 //------------------------------ConstraintCastNode----------------------------- 33 // cast to a different range 34 class ConstraintCastNode: public TypeNode { 35 public: 36 ConstraintCastNode (Node *n, const Type *t ): TypeNode(t,2) { 37 init_class_id(Class_ConstraintCast); 38 init_req(1, n); 39 } 40 virtual Node *Identity( PhaseTransform *phase ); 41 virtual const Type *Value( PhaseTransform *phase ) const; 42 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 43 virtual int Opcode() const; 44 virtual uint ideal_reg() const = 0; 45 }; 46 47 //------------------------------CastIINode------------------------------------- 48 // cast integer to integer (different range) 49 class CastIINode: public ConstraintCastNode { 50 private: 51 // Can this node be removed post CCP or does it carry a required dependency? 52 const bool _carry_dependency; 53 54 protected: 55 virtual uint cmp( const Node &n ) const; 56 virtual uint size_of() const; 57 58 public: 59 CastIINode(Node *n, const Type *t, bool carry_dependency = false) 60 : ConstraintCastNode(n,t), _carry_dependency(carry_dependency) {} 61 virtual int Opcode() const; 62 virtual uint ideal_reg() const { return Op_RegI; } 63 virtual Node *Identity( PhaseTransform *phase ); 64 virtual const Type *Value( PhaseTransform *phase ) const; 65 #ifndef PRODUCT 66 virtual void dump_spec(outputStream *st) const; 67 #endif 68 }; 69 70 //------------------------------CastPPNode------------------------------------- 71 // cast pointer to pointer (different type) 72 class CastPPNode: public ConstraintCastNode { 73 public: 74 CastPPNode (Node *n, const Type *t ): ConstraintCastNode(n, t) {} 75 virtual int Opcode() const; 76 virtual uint ideal_reg() const { return Op_RegP; } 77 }; 78 79 //------------------------------CheckCastPPNode-------------------------------- 80 // for _checkcast, cast pointer to pointer (different type), without JOIN, 81 class CheckCastPPNode: public TypeNode { 82 public: 83 CheckCastPPNode( Node *c, Node *n, const Type *t ) : TypeNode(t,2) { 84 init_class_id(Class_CheckCastPP); 85 init_req(0, c); 86 init_req(1, n); 87 } 88 89 virtual Node *Identity( PhaseTransform *phase ); 90 virtual const Type *Value( PhaseTransform *phase ) const; 91 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 92 virtual int Opcode() const; 93 virtual uint ideal_reg() const { return Op_RegP; } 94 }; 95 96 97 //------------------------------CastX2PNode------------------------------------- 98 // convert a machine-pointer-sized integer to a raw pointer 99 class CastX2PNode : public Node { 100 public: 101 CastX2PNode( Node *n ) : Node(NULL, n) {} 102 virtual int Opcode() const; 103 virtual const Type *Value( PhaseTransform *phase ) const; 104 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 105 virtual Node *Identity( PhaseTransform *phase ); 106 virtual uint ideal_reg() const { return Op_RegP; } 107 virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } 108 }; 109 110 //------------------------------CastP2XNode------------------------------------- 111 // Used in both 32-bit and 64-bit land. | 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_CASTNODE_HPP 26 #define SHARE_VM_OPTO_CASTNODE_HPP 27 28 #include "opto/node.hpp" 29 #include "opto/opcodes.hpp" 30 31 32 //------------------------------ConstraintCastNode----------------------------- 33 // cast to a different range 34 class ConstraintCastNode: public TypeNode { 35 protected: 36 // Can this node be removed post CCP or does it carry a required dependency? 37 const bool _carry_dependency; 38 virtual uint cmp( const Node &n ) const; 39 virtual uint size_of() const; 40 41 public: 42 ConstraintCastNode(Node *n, const Type *t, bool carry_dependency) 43 : TypeNode(t,2), _carry_dependency(carry_dependency) { 44 init_class_id(Class_ConstraintCast); 45 init_req(1, n); 46 } 47 virtual Node *Identity( PhaseTransform *phase ); 48 virtual const Type *Value( PhaseTransform *phase ) const; 49 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 50 virtual int Opcode() const; 51 virtual uint ideal_reg() const = 0; 52 virtual bool depends_only_on_test() const { return !_carry_dependency; } 53 bool carry_dependency() const { return _carry_dependency; } 54 TypeNode* dominating_cast(PhaseTransform *phase) const; 55 static Node* make_cast(int opcode, Node* c, Node *n, const Type *t, bool carry_dependency); 56 57 #ifndef PRODUCT 58 virtual void dump_spec(outputStream *st) const; 59 #endif 60 }; 61 62 //------------------------------CastIINode------------------------------------- 63 // cast integer to integer (different range) 64 class CastIINode: public ConstraintCastNode { 65 public: 66 CastIINode(Node *n, const Type *t, bool carry_dependency = false) 67 : ConstraintCastNode(n, t, carry_dependency) {} 68 virtual int Opcode() const; 69 virtual uint ideal_reg() const { return Op_RegI; } 70 virtual const Type *Value( PhaseTransform *phase ) const; 71 }; 72 73 //------------------------------CastPPNode------------------------------------- 74 // cast pointer to pointer (different type) 75 class CastPPNode: public ConstraintCastNode { 76 public: 77 CastPPNode (Node *n, const Type *t, bool carry_dependency = false) 78 : ConstraintCastNode(n, t, carry_dependency) { 79 } 80 virtual int Opcode() const; 81 virtual uint ideal_reg() const { return Op_RegP; } 82 }; 83 84 //------------------------------CheckCastPPNode-------------------------------- 85 // for _checkcast, cast pointer to pointer (different type), without JOIN, 86 class CheckCastPPNode: public ConstraintCastNode { 87 public: 88 CheckCastPPNode(Node *c, Node *n, const Type *t, bool carry_dependency = false) 89 : ConstraintCastNode(n, t, carry_dependency) { 90 init_class_id(Class_CheckCastPP); 91 init_req(0, c); 92 } 93 94 virtual Node *Identity(PhaseTransform *phase); 95 virtual const Type *Value(PhaseTransform *phase) const; 96 virtual int Opcode() const; 97 virtual uint ideal_reg() const { return Op_RegP; } 98 }; 99 100 101 //------------------------------CastX2PNode------------------------------------- 102 // convert a machine-pointer-sized integer to a raw pointer 103 class CastX2PNode : public Node { 104 public: 105 CastX2PNode( Node *n ) : Node(NULL, n) {} 106 virtual int Opcode() const; 107 virtual const Type *Value( PhaseTransform *phase ) const; 108 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 109 virtual Node *Identity( PhaseTransform *phase ); 110 virtual uint ideal_reg() const { return Op_RegP; } 111 virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } 112 }; 113 114 //------------------------------CastP2XNode------------------------------------- 115 // Used in both 32-bit and 64-bit land. |