Path: blob/master/src/hotspot/share/opto/castnode.hpp
40930 views
/*1* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_OPTO_CASTNODE_HPP25#define SHARE_OPTO_CASTNODE_HPP2627#include "opto/node.hpp"28#include "opto/opcodes.hpp"293031//------------------------------ConstraintCastNode-----------------------------32// cast to a different range33class ConstraintCastNode: public TypeNode {34protected:35// Can this node be removed post CCP or does it carry a required dependency?36const bool _carry_dependency;37virtual bool cmp( const Node &n ) const;38virtual uint size_of() const;3940public:41ConstraintCastNode(Node *n, const Type *t, bool carry_dependency)42: TypeNode(t,2), _carry_dependency(carry_dependency) {43init_class_id(Class_ConstraintCast);44init_req(1, n);45}46virtual Node* Identity(PhaseGVN* phase);47virtual const Type* Value(PhaseGVN* phase) const;48virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);49virtual int Opcode() const;50virtual uint ideal_reg() const = 0;51virtual bool depends_only_on_test() const { return !_carry_dependency; }52bool carry_dependency() const { return _carry_dependency; }53TypeNode* dominating_cast(PhaseGVN* gvn, PhaseTransform* pt) const;54static Node* make_cast(int opcode, Node* c, Node *n, const Type *t, bool carry_dependency);55static Node* make(Node* c, Node *n, const Type *t, BasicType bt);56virtual bool operates_on(BasicType bt, bool signed_int) const {57assert(bt == T_INT || bt == T_LONG, "unsupported");58return false;59}6061#ifndef PRODUCT62virtual void dump_spec(outputStream *st) const;63#endif64};6566//------------------------------CastIINode-------------------------------------67// cast integer to integer (different range)68class CastIINode: public ConstraintCastNode {69protected:70// Is this node dependent on a range check?71const bool _range_check_dependency;72virtual bool cmp(const Node &n) const;73virtual uint size_of() const;7475public:76CastIINode(Node* n, const Type* t, bool carry_dependency = false, bool range_check_dependency = false)77: ConstraintCastNode(n, t, carry_dependency), _range_check_dependency(range_check_dependency) {78init_class_id(Class_CastII);79}80virtual int Opcode() const;81virtual uint ideal_reg() const { return Op_RegI; }82virtual Node* Identity(PhaseGVN* phase);83virtual const Type* Value(PhaseGVN* phase) const;84virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);85const bool has_range_check() {86#ifdef _LP6487return _range_check_dependency;88#else89assert(!_range_check_dependency, "Should not have range check dependency");90return false;91#endif92}93virtual bool operates_on(BasicType bt, bool signed_int) const {94assert(bt == T_INT || bt == T_LONG, "unsupported");95return bt == T_INT;96}9798#ifndef PRODUCT99virtual void dump_spec(outputStream* st) const;100#endif101};102103class CastLLNode: public ConstraintCastNode {104public:105CastLLNode(Node* n, const Type* t, bool carry_dependency = false)106: ConstraintCastNode(n, t, carry_dependency){107init_class_id(Class_CastLL);108}109virtual bool operates_on(BasicType bt, bool signed_int) const {110assert(bt == T_INT || bt == T_LONG, "unsupported");111return bt == T_LONG;112}113virtual int Opcode() const;114virtual uint ideal_reg() const { return Op_RegL; }115};116117class CastFFNode: public ConstraintCastNode {118public:119CastFFNode(Node* n, const Type* t, bool carry_dependency = false)120: ConstraintCastNode(n, t, carry_dependency){121init_class_id(Class_CastFF);122}123virtual int Opcode() const;124virtual uint ideal_reg() const { return Op_RegF; }125};126127class CastDDNode: public ConstraintCastNode {128public:129CastDDNode(Node* n, const Type* t, bool carry_dependency = false)130: ConstraintCastNode(n, t, carry_dependency){131init_class_id(Class_CastDD);132}133virtual int Opcode() const;134virtual uint ideal_reg() const { return Op_RegD; }135};136137class CastVVNode: public ConstraintCastNode {138public:139CastVVNode(Node* n, const Type* t, bool carry_dependency = false)140: ConstraintCastNode(n, t, carry_dependency){141init_class_id(Class_CastVV);142}143virtual int Opcode() const;144virtual uint ideal_reg() const { return in(1)->ideal_reg(); }145};146147148//------------------------------CastPPNode-------------------------------------149// cast pointer to pointer (different type)150class CastPPNode: public ConstraintCastNode {151public:152CastPPNode (Node *n, const Type *t, bool carry_dependency = false)153: ConstraintCastNode(n, t, carry_dependency) {154}155virtual int Opcode() const;156virtual uint ideal_reg() const { return Op_RegP; }157};158159//------------------------------CheckCastPPNode--------------------------------160// for _checkcast, cast pointer to pointer (different type), without JOIN,161class CheckCastPPNode: public ConstraintCastNode {162public:163CheckCastPPNode(Node *c, Node *n, const Type *t, bool carry_dependency = false)164: ConstraintCastNode(n, t, carry_dependency) {165init_class_id(Class_CheckCastPP);166init_req(0, c);167}168169virtual Node* Identity(PhaseGVN* phase);170virtual const Type* Value(PhaseGVN* phase) const;171virtual int Opcode() const;172virtual uint ideal_reg() const { return Op_RegP; }173bool depends_only_on_test() const { return !type()->isa_rawptr() && ConstraintCastNode::depends_only_on_test(); }174};175176177//------------------------------CastX2PNode-------------------------------------178// convert a machine-pointer-sized integer to a raw pointer179class CastX2PNode : public Node {180public:181CastX2PNode( Node *n ) : Node(NULL, n) {}182virtual int Opcode() const;183virtual const Type* Value(PhaseGVN* phase) const;184virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);185virtual Node* Identity(PhaseGVN* phase);186virtual uint ideal_reg() const { return Op_RegP; }187virtual const Type *bottom_type() const { return TypeRawPtr::BOTTOM; }188};189190//------------------------------CastP2XNode-------------------------------------191// Used in both 32-bit and 64-bit land.192// Used for card-marks and unsafe pointer math.193class CastP2XNode : public Node {194public:195CastP2XNode( Node *ctrl, Node *n ) : Node(ctrl, n) {}196virtual int Opcode() const;197virtual const Type* Value(PhaseGVN* phase) const;198virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);199virtual Node* Identity(PhaseGVN* phase);200virtual uint ideal_reg() const { return Op_RegX; }201virtual const Type *bottom_type() const { return TypeX_X; }202// Return false to keep node from moving away from an associated card mark.203virtual bool depends_only_on_test() const { return false; }204};205206207208#endif // SHARE_OPTO_CASTNODE_HPP209210211