1 /* 2 * Copyright (c) 2014, 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_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 virtual Node *Ideal_DU_postCCP( PhaseCCP * ); 46 }; 47 48 //------------------------------CastIINode------------------------------------- 49 // cast integer to integer (different range) 50 class CastIINode: public ConstraintCastNode { 51 public: 52 CastIINode (Node *n, const Type *t ): ConstraintCastNode(n,t) {} 53 virtual int Opcode() const; 54 virtual uint ideal_reg() const { return Op_RegI; } 55 }; 56 57 //------------------------------CastPPNode------------------------------------- 58 // cast pointer to pointer (different type) 59 class CastPPNode: public ConstraintCastNode { 60 public: 61 CastPPNode (Node *n, const Type *t ): ConstraintCastNode(n, t) {} 62 virtual int Opcode() const; 63 virtual uint ideal_reg() const { return Op_RegP; } 64 virtual Node *Ideal_DU_postCCP( PhaseCCP * ); 65 }; 66 67 //------------------------------CheckCastPPNode-------------------------------- 68 // for _checkcast, cast pointer to pointer (different type), without JOIN, 69 class CheckCastPPNode: public TypeNode { 70 public: 71 CheckCastPPNode( Node *c, Node *n, const Type *t ) : TypeNode(t,2) { 72 init_class_id(Class_CheckCastPP); 73 init_req(0, c); 74 init_req(1, n); 75 } 76 77 virtual Node *Identity( PhaseTransform *phase ); 78 virtual const Type *Value( PhaseTransform *phase ) const; 79 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 80 virtual int Opcode() const; 81 virtual uint ideal_reg() const { return Op_RegP; } 82 // No longer remove CheckCast after CCP as it gives me a place to hang 83 // the proper address type - which is required to compute anti-deps. 84 //virtual Node *Ideal_DU_postCCP( PhaseCCP * ); 85 }; 86 87 88 //------------------------------CastX2PNode------------------------------------- 89 // convert a machine-pointer-sized integer to a raw pointer 90 class CastX2PNode : public Node { 91 public: 92 CastX2PNode( Node *n ) : Node(NULL, n) {} 93 virtual int Opcode() const; 94 virtual const Type *Value( PhaseTransform *phase ) const; 95 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 96 virtual Node *Identity( PhaseTransform *phase ); 97 virtual uint ideal_reg() const { return Op_RegP; } 98 virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } 99 }; 100 101 //------------------------------CastP2XNode------------------------------------- 102 // Used in both 32-bit and 64-bit land. 103 // Used for card-marks and unsafe pointer math. 104 class CastP2XNode : public Node { 105 public: 106 CastP2XNode( Node *ctrl, Node *n ) : Node(ctrl, n) {} 107 virtual int Opcode() const; 108 virtual const Type *Value( PhaseTransform *phase ) const; 109 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); 110 virtual Node *Identity( PhaseTransform *phase ); 111 virtual uint ideal_reg() const { return Op_RegX; } 112 virtual const Type *bottom_type() const { return TypeX_X; } 113 // Return false to keep node from moving away from an associated card mark. 114 virtual bool depends_only_on_test() const { return false; } 115 }; 116 117 118 119 #endif // SHARE_VM_OPTO_CASTNODE_HPP