0N/A/*
1879N/A * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_OPTO_ADDNODE_HPP
1879N/A#define SHARE_VM_OPTO_ADDNODE_HPP
1879N/A
1879N/A#include "opto/node.hpp"
1879N/A#include "opto/opcodes.hpp"
1879N/A#include "opto/type.hpp"
1879N/A
0N/A// Portions of code courtesy of Clifford Click
0N/A
0N/Aclass PhaseTransform;
0N/A
0N/A//------------------------------AddNode----------------------------------------
0N/A// Classic Add functionality. This covers all the usual 'add' behaviors for
0N/A// an algebraic ring. Add-integer, add-float, add-double, and binary-or are
0N/A// all inherited from this class. The various identity values are supplied
0N/A// by virtual functions.
0N/Aclass AddNode : public Node {
0N/A virtual uint hash() const;
0N/Apublic:
0N/A AddNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {
0N/A init_class_id(Class_Add);
0N/A }
0N/A
0N/A // Handle algebraic identities here. If we have an identity, return the Node
0N/A // we are equivalent to. We look for "add of zero" as an identity.
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A
0N/A // We also canonicalize the Node, moving constants to the right input,
0N/A // and flatten expressions (so that 1+x+2 becomes x+3).
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A
0N/A // Compute a new Type for this node. Basically we just do the pre-check,
0N/A // then call the virtual add() to set the type.
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A
0N/A // Check if this addition involves the additive identity
0N/A virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
0N/A
0N/A // Supplied function returns the sum of the inputs.
0N/A // This also type-checks the inputs for sanity. Guaranteed never to
0N/A // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
0N/A virtual const Type *add_ring( const Type *, const Type * ) const = 0;
0N/A
0N/A // Supplied function to return the additive identity type
0N/A virtual const Type *add_id() const = 0;
0N/A
0N/A};
0N/A
0N/A//------------------------------AddINode---------------------------------------
0N/A// Add 2 integers
0N/Aclass AddINode : public AddNode {
0N/Apublic:
0N/A AddINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeInt::ZERO; }
0N/A virtual const Type *bottom_type() const { return TypeInt::INT; }
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A virtual uint ideal_reg() const { return Op_RegI; }
0N/A};
0N/A
0N/A//------------------------------AddLNode---------------------------------------
0N/A// Add 2 longs
0N/Aclass AddLNode : public AddNode {
0N/Apublic:
0N/A AddLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeLong::ZERO; }
0N/A virtual const Type *bottom_type() const { return TypeLong::LONG; }
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A virtual uint ideal_reg() const { return Op_RegL; }
0N/A};
0N/A
0N/A//------------------------------AddFNode---------------------------------------
0N/A// Add 2 floats
0N/Aclass AddFNode : public AddNode {
0N/Apublic:
0N/A AddFNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeF::ZERO; }
0N/A virtual const Type *bottom_type() const { return Type::FLOAT; }
0N/A virtual Node *Identity( PhaseTransform *phase ) { return this; }
0N/A virtual uint ideal_reg() const { return Op_RegF; }
0N/A};
0N/A
0N/A//------------------------------AddDNode---------------------------------------
0N/A// Add 2 doubles
0N/Aclass AddDNode : public AddNode {
0N/Apublic:
0N/A AddDNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeD::ZERO; }
0N/A virtual const Type *bottom_type() const { return Type::DOUBLE; }
0N/A virtual Node *Identity( PhaseTransform *phase ) { return this; }
0N/A virtual uint ideal_reg() const { return Op_RegD; }
0N/A};
0N/A
0N/A//------------------------------AddPNode---------------------------------------
0N/A// Add pointer plus integer to get pointer. NOT commutative, really.
0N/A// So not really an AddNode. Lives here, because people associate it with
0N/A// an add.
0N/Aclass AddPNode : public Node {
0N/Apublic:
0N/A enum { Control, // When is it safe to do this add?
0N/A Base, // Base oop, for GC purposes
0N/A Address, // Actually address, derived from base
0N/A Offset } ; // Offset added to address
0N/A AddPNode( Node *base, Node *ptr, Node *off ) : Node(0,base,ptr,off) {
0N/A init_class_id(Class_AddP);
0N/A }
0N/A virtual int Opcode() const;
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A virtual const Type *Value( PhaseTransform *phase ) const;
0N/A virtual const Type *bottom_type() const;
0N/A virtual uint ideal_reg() const { return Op_RegP; }
0N/A Node *base_node() { assert( req() > Base, "Missing base"); return in(Base); }
0N/A static Node* Ideal_base_and_offset(Node* ptr, PhaseTransform* phase,
0N/A // second return value:
0N/A intptr_t& offset);
17N/A
17N/A // Collect the AddP offset values into the elements array, giving up
17N/A // if there are more than length.
17N/A int unpack_offsets(Node* elements[], int length);
17N/A
0N/A // Do not match base-ptr edge
0N/A virtual uint match_edge(uint idx) const;
0N/A};
0N/A
0N/A//------------------------------OrINode----------------------------------------
0N/A// Logically OR 2 integers. Included with the ADD nodes because it inherits
0N/A// all the behavior of addition on a ring.
0N/Aclass OrINode : public AddNode {
0N/Apublic:
0N/A OrINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeInt::ZERO; }
0N/A virtual const Type *bottom_type() const { return TypeInt::INT; }
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A virtual uint ideal_reg() const { return Op_RegI; }
0N/A};
0N/A
0N/A//------------------------------OrLNode----------------------------------------
0N/A// Logically OR 2 longs. Included with the ADD nodes because it inherits
0N/A// all the behavior of addition on a ring.
0N/Aclass OrLNode : public AddNode {
0N/Apublic:
0N/A OrLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeLong::ZERO; }
0N/A virtual const Type *bottom_type() const { return TypeLong::LONG; }
0N/A virtual Node *Identity( PhaseTransform *phase );
0N/A virtual uint ideal_reg() const { return Op_RegL; }
0N/A};
0N/A
0N/A//------------------------------XorINode---------------------------------------
0N/A// XOR'ing 2 integers
0N/Aclass XorINode : public AddNode {
0N/Apublic:
0N/A XorINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeInt::ZERO; }
0N/A virtual const Type *bottom_type() const { return TypeInt::INT; }
0N/A virtual uint ideal_reg() const { return Op_RegI; }
0N/A};
0N/A
0N/A//------------------------------XorINode---------------------------------------
0N/A// XOR'ing 2 longs
0N/Aclass XorLNode : public AddNode {
0N/Apublic:
0N/A XorLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeLong::ZERO; }
0N/A virtual const Type *bottom_type() const { return TypeLong::LONG; }
0N/A virtual uint ideal_reg() const { return Op_RegL; }
0N/A};
0N/A
0N/A//------------------------------MaxNode----------------------------------------
0N/A// Max (or min) of 2 values. Included with the ADD nodes because it inherits
0N/A// all the behavior of addition on a ring. Only new thing is that we allow
0N/A// 2 equal inputs to be equal.
0N/Aclass MaxNode : public AddNode {
0N/Apublic:
0N/A MaxNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
0N/A virtual int Opcode() const = 0;
0N/A};
0N/A
0N/A//------------------------------MaxINode---------------------------------------
0N/A// Maximum of 2 integers. Included with the ADD nodes because it inherits
0N/A// all the behavior of addition on a ring.
0N/Aclass MaxINode : public MaxNode {
0N/Apublic:
0N/A MaxINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeInt::make(min_jint); }
0N/A virtual const Type *bottom_type() const { return TypeInt::INT; }
0N/A virtual uint ideal_reg() const { return Op_RegI; }
0N/A};
0N/A
0N/A//------------------------------MinINode---------------------------------------
0N/A// MINimum of 2 integers. Included with the ADD nodes because it inherits
0N/A// all the behavior of addition on a ring.
0N/Aclass MinINode : public MaxNode {
0N/Apublic:
0N/A MinINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}
0N/A virtual int Opcode() const;
0N/A virtual const Type *add_ring( const Type *, const Type * ) const;
0N/A virtual const Type *add_id() const { return TypeInt::make(max_jint); }
0N/A virtual const Type *bottom_type() const { return TypeInt::INT; }
0N/A virtual uint ideal_reg() const { return Op_RegI; }
0N/A virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_OPTO_ADDNODE_HPP