Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/opto/addnode.hpp
32285 views
/*1* Copyright (c) 1997, 2010, 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_VM_OPTO_ADDNODE_HPP25#define SHARE_VM_OPTO_ADDNODE_HPP2627#include "opto/node.hpp"28#include "opto/opcodes.hpp"29#include "opto/type.hpp"3031// Portions of code courtesy of Clifford Click3233class PhaseTransform;3435//------------------------------AddNode----------------------------------------36// Classic Add functionality. This covers all the usual 'add' behaviors for37// an algebraic ring. Add-integer, add-float, add-double, and binary-or are38// all inherited from this class. The various identity values are supplied39// by virtual functions.40class AddNode : public Node {41virtual uint hash() const;42public:43AddNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {44init_class_id(Class_Add);45}4647// Handle algebraic identities here. If we have an identity, return the Node48// we are equivalent to. We look for "add of zero" as an identity.49virtual Node *Identity( PhaseTransform *phase );5051// We also canonicalize the Node, moving constants to the right input,52// and flatten expressions (so that 1+x+2 becomes x+3).53virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);5455// Compute a new Type for this node. Basically we just do the pre-check,56// then call the virtual add() to set the type.57virtual const Type *Value( PhaseTransform *phase ) const;5859// Check if this addition involves the additive identity60virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;6162// Supplied function returns the sum of the inputs.63// This also type-checks the inputs for sanity. Guaranteed never to64// be passed a TOP or BOTTOM type, these are filtered out by a pre-check.65virtual const Type *add_ring( const Type *, const Type * ) const = 0;6667// Supplied function to return the additive identity type68virtual const Type *add_id() const = 0;6970};7172//------------------------------AddINode---------------------------------------73// Add 2 integers74class AddINode : public AddNode {75public:76AddINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}77virtual int Opcode() const;78virtual const Type *add_ring( const Type *, const Type * ) const;79virtual const Type *add_id() const { return TypeInt::ZERO; }80virtual const Type *bottom_type() const { return TypeInt::INT; }81virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);82virtual Node *Identity( PhaseTransform *phase );83virtual uint ideal_reg() const { return Op_RegI; }84};8586//------------------------------AddLNode---------------------------------------87// Add 2 longs88class AddLNode : public AddNode {89public:90AddLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}91virtual int Opcode() const;92virtual const Type *add_ring( const Type *, const Type * ) const;93virtual const Type *add_id() const { return TypeLong::ZERO; }94virtual const Type *bottom_type() const { return TypeLong::LONG; }95virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);96virtual Node *Identity( PhaseTransform *phase );97virtual uint ideal_reg() const { return Op_RegL; }98};99100//------------------------------AddFNode---------------------------------------101// Add 2 floats102class AddFNode : public AddNode {103public:104AddFNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}105virtual int Opcode() const;106virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);107virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;108virtual const Type *add_ring( const Type *, const Type * ) const;109virtual const Type *add_id() const { return TypeF::ZERO; }110virtual const Type *bottom_type() const { return Type::FLOAT; }111virtual Node *Identity( PhaseTransform *phase ) { return this; }112virtual uint ideal_reg() const { return Op_RegF; }113};114115//------------------------------AddDNode---------------------------------------116// Add 2 doubles117class AddDNode : public AddNode {118public:119AddDNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}120virtual int Opcode() const;121virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);122virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;123virtual const Type *add_ring( const Type *, const Type * ) const;124virtual const Type *add_id() const { return TypeD::ZERO; }125virtual const Type *bottom_type() const { return Type::DOUBLE; }126virtual Node *Identity( PhaseTransform *phase ) { return this; }127virtual uint ideal_reg() const { return Op_RegD; }128};129130//------------------------------AddPNode---------------------------------------131// Add pointer plus integer to get pointer. NOT commutative, really.132// So not really an AddNode. Lives here, because people associate it with133// an add.134class AddPNode : public Node {135public:136enum { Control, // When is it safe to do this add?137Base, // Base oop, for GC purposes138Address, // Actually address, derived from base139Offset } ; // Offset added to address140AddPNode( Node *base, Node *ptr, Node *off ) : Node(0,base,ptr,off) {141init_class_id(Class_AddP);142}143virtual int Opcode() const;144virtual Node *Identity( PhaseTransform *phase );145virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);146virtual const Type *Value( PhaseTransform *phase ) const;147virtual const Type *bottom_type() const;148virtual uint ideal_reg() const { return Op_RegP; }149Node *base_node() { assert( req() > Base, "Missing base"); return in(Base); }150static Node* Ideal_base_and_offset(Node* ptr, PhaseTransform* phase,151// second return value:152intptr_t& offset);153154// Collect the AddP offset values into the elements array, giving up155// if there are more than length.156int unpack_offsets(Node* elements[], int length);157158// Do not match base-ptr edge159virtual uint match_edge(uint idx) const;160};161162//------------------------------OrINode----------------------------------------163// Logically OR 2 integers. Included with the ADD nodes because it inherits164// all the behavior of addition on a ring.165class OrINode : public AddNode {166public:167OrINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}168virtual int Opcode() const;169virtual const Type *add_ring( const Type *, const Type * ) const;170virtual const Type *add_id() const { return TypeInt::ZERO; }171virtual const Type *bottom_type() const { return TypeInt::INT; }172virtual Node *Identity( PhaseTransform *phase );173virtual uint ideal_reg() const { return Op_RegI; }174};175176//------------------------------OrLNode----------------------------------------177// Logically OR 2 longs. Included with the ADD nodes because it inherits178// all the behavior of addition on a ring.179class OrLNode : public AddNode {180public:181OrLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}182virtual int Opcode() const;183virtual const Type *add_ring( const Type *, const Type * ) const;184virtual const Type *add_id() const { return TypeLong::ZERO; }185virtual const Type *bottom_type() const { return TypeLong::LONG; }186virtual Node *Identity( PhaseTransform *phase );187virtual uint ideal_reg() const { return Op_RegL; }188};189190//------------------------------XorINode---------------------------------------191// XOR'ing 2 integers192class XorINode : public AddNode {193public:194XorINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}195virtual int Opcode() const;196virtual const Type *add_ring( const Type *, const Type * ) const;197virtual const Type *add_id() const { return TypeInt::ZERO; }198virtual const Type *bottom_type() const { return TypeInt::INT; }199virtual uint ideal_reg() const { return Op_RegI; }200};201202//------------------------------XorINode---------------------------------------203// XOR'ing 2 longs204class XorLNode : public AddNode {205public:206XorLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}207virtual int Opcode() const;208virtual const Type *add_ring( const Type *, const Type * ) const;209virtual const Type *add_id() const { return TypeLong::ZERO; }210virtual const Type *bottom_type() const { return TypeLong::LONG; }211virtual uint ideal_reg() const { return Op_RegL; }212};213214//------------------------------MaxNode----------------------------------------215// Max (or min) of 2 values. Included with the ADD nodes because it inherits216// all the behavior of addition on a ring. Only new thing is that we allow217// 2 equal inputs to be equal.218class MaxNode : public AddNode {219public:220MaxNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}221virtual int Opcode() const = 0;222};223224//------------------------------MaxINode---------------------------------------225// Maximum of 2 integers. Included with the ADD nodes because it inherits226// all the behavior of addition on a ring.227class MaxINode : public MaxNode {228public:229MaxINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}230virtual int Opcode() const;231virtual const Type *add_ring( const Type *, const Type * ) const;232virtual const Type *add_id() const { return TypeInt::make(min_jint); }233virtual const Type *bottom_type() const { return TypeInt::INT; }234virtual uint ideal_reg() const { return Op_RegI; }235};236237//------------------------------MinINode---------------------------------------238// MINimum of 2 integers. Included with the ADD nodes because it inherits239// all the behavior of addition on a ring.240class MinINode : public MaxNode {241public:242MinINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}243virtual int Opcode() const;244virtual const Type *add_ring( const Type *, const Type * ) const;245virtual const Type *add_id() const { return TypeInt::make(max_jint); }246virtual const Type *bottom_type() const { return TypeInt::INT; }247virtual uint ideal_reg() const { return Op_RegI; }248virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);249};250251#endif // SHARE_VM_OPTO_ADDNODE_HPP252253254