src/share/vm/opto/addnode.hpp

Thu, 24 May 2018 19:26:50 +0800

author
aoqi
date
Thu, 24 May 2018 19:26:50 +0800
changeset 8862
fd13a567f179
parent 6876
710a3c8b516e
permissions
-rw-r--r--

#7046 C2 supports long branch
Contributed-by: fujie

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_OPTO_ADDNODE_HPP
aoqi@0 26 #define SHARE_VM_OPTO_ADDNODE_HPP
aoqi@0 27
aoqi@0 28 #include "opto/node.hpp"
aoqi@0 29 #include "opto/opcodes.hpp"
aoqi@0 30 #include "opto/type.hpp"
aoqi@0 31
aoqi@0 32 // Portions of code courtesy of Clifford Click
aoqi@0 33
aoqi@0 34 class PhaseTransform;
aoqi@0 35
aoqi@0 36 //------------------------------AddNode----------------------------------------
aoqi@0 37 // Classic Add functionality. This covers all the usual 'add' behaviors for
aoqi@0 38 // an algebraic ring. Add-integer, add-float, add-double, and binary-or are
aoqi@0 39 // all inherited from this class. The various identity values are supplied
aoqi@0 40 // by virtual functions.
aoqi@0 41 class AddNode : public Node {
aoqi@0 42 virtual uint hash() const;
aoqi@0 43 public:
aoqi@0 44 AddNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {
aoqi@0 45 init_class_id(Class_Add);
aoqi@0 46 }
aoqi@0 47
aoqi@0 48 // Handle algebraic identities here. If we have an identity, return the Node
aoqi@0 49 // we are equivalent to. We look for "add of zero" as an identity.
aoqi@0 50 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 51
aoqi@0 52 // We also canonicalize the Node, moving constants to the right input,
aoqi@0 53 // and flatten expressions (so that 1+x+2 becomes x+3).
aoqi@0 54 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 55
aoqi@0 56 // Compute a new Type for this node. Basically we just do the pre-check,
aoqi@0 57 // then call the virtual add() to set the type.
aoqi@0 58 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 59
aoqi@0 60 // Check if this addition involves the additive identity
aoqi@0 61 virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
aoqi@0 62
aoqi@0 63 // Supplied function returns the sum of the inputs.
aoqi@0 64 // This also type-checks the inputs for sanity. Guaranteed never to
aoqi@0 65 // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
aoqi@0 66 virtual const Type *add_ring( const Type *, const Type * ) const = 0;
aoqi@0 67
aoqi@0 68 // Supplied function to return the additive identity type
aoqi@0 69 virtual const Type *add_id() const = 0;
aoqi@0 70
aoqi@0 71 };
aoqi@0 72
aoqi@0 73 //------------------------------AddINode---------------------------------------
aoqi@0 74 // Add 2 integers
aoqi@0 75 class AddINode : public AddNode {
aoqi@0 76 public:
aoqi@0 77 AddINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
aoqi@0 78 virtual int Opcode() const;
aoqi@0 79 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 80 virtual const Type *add_id() const { return TypeInt::ZERO; }
aoqi@0 81 virtual const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 82 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 83 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 84 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 85 };
aoqi@0 86
aoqi@0 87 //------------------------------AddLNode---------------------------------------
aoqi@0 88 // Add 2 longs
aoqi@0 89 class AddLNode : public AddNode {
aoqi@0 90 public:
aoqi@0 91 AddLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
aoqi@0 92 virtual int Opcode() const;
aoqi@0 93 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 94 virtual const Type *add_id() const { return TypeLong::ZERO; }
aoqi@0 95 virtual const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 96 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 97 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 98 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 99 };
aoqi@0 100
aoqi@0 101 //------------------------------AddFNode---------------------------------------
aoqi@0 102 // Add 2 floats
aoqi@0 103 class AddFNode : public AddNode {
aoqi@0 104 public:
aoqi@0 105 AddFNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
aoqi@0 106 virtual int Opcode() const;
aoqi@0 107 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 108 virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
aoqi@0 109 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 110 virtual const Type *add_id() const { return TypeF::ZERO; }
aoqi@0 111 virtual const Type *bottom_type() const { return Type::FLOAT; }
aoqi@0 112 virtual Node *Identity( PhaseTransform *phase ) { return this; }
aoqi@0 113 virtual uint ideal_reg() const { return Op_RegF; }
aoqi@0 114 };
aoqi@0 115
aoqi@0 116 //------------------------------AddDNode---------------------------------------
aoqi@0 117 // Add 2 doubles
aoqi@0 118 class AddDNode : public AddNode {
aoqi@0 119 public:
aoqi@0 120 AddDNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
aoqi@0 121 virtual int Opcode() const;
aoqi@0 122 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 123 virtual const Type *add_of_identity( const Type *t1, const Type *t2 ) const;
aoqi@0 124 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 125 virtual const Type *add_id() const { return TypeD::ZERO; }
aoqi@0 126 virtual const Type *bottom_type() const { return Type::DOUBLE; }
aoqi@0 127 virtual Node *Identity( PhaseTransform *phase ) { return this; }
aoqi@0 128 virtual uint ideal_reg() const { return Op_RegD; }
aoqi@0 129 };
aoqi@0 130
aoqi@0 131 //------------------------------AddPNode---------------------------------------
aoqi@0 132 // Add pointer plus integer to get pointer. NOT commutative, really.
aoqi@0 133 // So not really an AddNode. Lives here, because people associate it with
aoqi@0 134 // an add.
aoqi@0 135 class AddPNode : public Node {
aoqi@0 136 public:
aoqi@0 137 enum { Control, // When is it safe to do this add?
aoqi@0 138 Base, // Base oop, for GC purposes
aoqi@0 139 Address, // Actually address, derived from base
aoqi@0 140 Offset } ; // Offset added to address
aoqi@0 141 AddPNode( Node *base, Node *ptr, Node *off ) : Node(0,base,ptr,off) {
aoqi@0 142 init_class_id(Class_AddP);
aoqi@0 143 }
aoqi@0 144 virtual int Opcode() const;
aoqi@0 145 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 146 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 147 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 148 virtual const Type *bottom_type() const;
aoqi@0 149 virtual uint ideal_reg() const { return Op_RegP; }
aoqi@0 150 Node *base_node() { assert( req() > Base, "Missing base"); return in(Base); }
aoqi@0 151 static Node* Ideal_base_and_offset(Node* ptr, PhaseTransform* phase,
aoqi@0 152 // second return value:
aoqi@0 153 intptr_t& offset);
aoqi@0 154
aoqi@0 155 // Collect the AddP offset values into the elements array, giving up
aoqi@0 156 // if there are more than length.
aoqi@0 157 int unpack_offsets(Node* elements[], int length);
aoqi@0 158
aoqi@0 159 // Do not match base-ptr edge
aoqi@0 160 virtual uint match_edge(uint idx) const;
aoqi@0 161 };
aoqi@0 162
aoqi@0 163 //------------------------------OrINode----------------------------------------
aoqi@0 164 // Logically OR 2 integers. Included with the ADD nodes because it inherits
aoqi@0 165 // all the behavior of addition on a ring.
aoqi@0 166 class OrINode : public AddNode {
aoqi@0 167 public:
aoqi@0 168 OrINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
aoqi@0 169 virtual int Opcode() const;
aoqi@0 170 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 171 virtual const Type *add_id() const { return TypeInt::ZERO; }
aoqi@0 172 virtual const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 173 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 174 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 175 };
aoqi@0 176
aoqi@0 177 //------------------------------OrLNode----------------------------------------
aoqi@0 178 // Logically OR 2 longs. Included with the ADD nodes because it inherits
aoqi@0 179 // all the behavior of addition on a ring.
aoqi@0 180 class OrLNode : public AddNode {
aoqi@0 181 public:
aoqi@0 182 OrLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
aoqi@0 183 virtual int Opcode() const;
aoqi@0 184 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 185 virtual const Type *add_id() const { return TypeLong::ZERO; }
aoqi@0 186 virtual const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 187 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 188 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 189 };
aoqi@0 190
aoqi@0 191 //------------------------------XorINode---------------------------------------
aoqi@0 192 // XOR'ing 2 integers
aoqi@0 193 class XorINode : public AddNode {
aoqi@0 194 public:
aoqi@0 195 XorINode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
aoqi@0 196 virtual int Opcode() const;
aoqi@0 197 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 198 virtual const Type *add_id() const { return TypeInt::ZERO; }
aoqi@0 199 virtual const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 200 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 201 };
aoqi@0 202
aoqi@0 203 //------------------------------XorINode---------------------------------------
aoqi@0 204 // XOR'ing 2 longs
aoqi@0 205 class XorLNode : public AddNode {
aoqi@0 206 public:
aoqi@0 207 XorLNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
aoqi@0 208 virtual int Opcode() const;
aoqi@0 209 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 210 virtual const Type *add_id() const { return TypeLong::ZERO; }
aoqi@0 211 virtual const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 212 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 213 };
aoqi@0 214
aoqi@0 215 //------------------------------MaxNode----------------------------------------
aoqi@0 216 // Max (or min) of 2 values. Included with the ADD nodes because it inherits
aoqi@0 217 // all the behavior of addition on a ring. Only new thing is that we allow
aoqi@0 218 // 2 equal inputs to be equal.
aoqi@0 219 class MaxNode : public AddNode {
aoqi@0 220 public:
aoqi@0 221 MaxNode( Node *in1, Node *in2 ) : AddNode(in1,in2) {}
aoqi@0 222 virtual int Opcode() const = 0;
aoqi@0 223 };
aoqi@0 224
aoqi@0 225 //------------------------------MaxINode---------------------------------------
aoqi@0 226 // Maximum of 2 integers. Included with the ADD nodes because it inherits
aoqi@0 227 // all the behavior of addition on a ring.
aoqi@0 228 class MaxINode : public MaxNode {
aoqi@0 229 public:
aoqi@0 230 MaxINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}
aoqi@0 231 virtual int Opcode() const;
aoqi@0 232 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 233 virtual const Type *add_id() const { return TypeInt::make(min_jint); }
aoqi@0 234 virtual const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 235 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 236 };
aoqi@0 237
aoqi@0 238 //------------------------------MinINode---------------------------------------
aoqi@0 239 // MINimum of 2 integers. Included with the ADD nodes because it inherits
aoqi@0 240 // all the behavior of addition on a ring.
aoqi@0 241 class MinINode : public MaxNode {
aoqi@0 242 public:
aoqi@0 243 MinINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}
aoqi@0 244 virtual int Opcode() const;
aoqi@0 245 virtual const Type *add_ring( const Type *, const Type * ) const;
aoqi@0 246 virtual const Type *add_id() const { return TypeInt::make(max_jint); }
aoqi@0 247 virtual const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 248 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 249 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 250 };
aoqi@0 251
aoqi@0 252 #endif // SHARE_VM_OPTO_ADDNODE_HPP

mercurial