src/share/vm/opto/mulnode.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2012, 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_MULNODE_HPP
aoqi@0 26 #define SHARE_VM_OPTO_MULNODE_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 //------------------------------MulNode----------------------------------------
aoqi@0 37 // Classic MULTIPLY functionality. This covers all the usual 'multiply'
aoqi@0 38 // behaviors for an algebraic ring. Multiply-integer, multiply-float,
aoqi@0 39 // multiply-double, and binary-and are all inherited from this class. The
aoqi@0 40 // various identity values are supplied by virtual functions.
aoqi@0 41 class MulNode : public Node {
aoqi@0 42 virtual uint hash() const;
aoqi@0 43 public:
aoqi@0 44 MulNode( Node *in1, Node *in2 ): Node(0,in1,in2) {
aoqi@0 45 init_class_id(Class_Mul);
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 // Supplied function returns the product of the inputs.
aoqi@0 61 // This also type-checks the inputs for sanity. Guaranteed never to
aoqi@0 62 // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
aoqi@0 63 // This call recognizes the multiplicative zero type.
aoqi@0 64 virtual const Type *mul_ring( const Type *, const Type * ) const = 0;
aoqi@0 65
aoqi@0 66 // Supplied function to return the multiplicative identity type
aoqi@0 67 virtual const Type *mul_id() const = 0;
aoqi@0 68
aoqi@0 69 // Supplied function to return the additive identity type
aoqi@0 70 virtual const Type *add_id() const = 0;
aoqi@0 71
aoqi@0 72 // Supplied function to return the additive opcode
aoqi@0 73 virtual int add_opcode() const = 0;
aoqi@0 74
aoqi@0 75 // Supplied function to return the multiplicative opcode
aoqi@0 76 virtual int mul_opcode() const = 0;
aoqi@0 77
aoqi@0 78 };
aoqi@0 79
aoqi@0 80 //------------------------------MulINode---------------------------------------
aoqi@0 81 // Multiply 2 integers
aoqi@0 82 class MulINode : public MulNode {
aoqi@0 83 public:
aoqi@0 84 MulINode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
aoqi@0 85 virtual int Opcode() const;
aoqi@0 86 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 87 virtual const Type *mul_ring( const Type *, const Type * ) const;
aoqi@0 88 const Type *mul_id() const { return TypeInt::ONE; }
aoqi@0 89 const Type *add_id() const { return TypeInt::ZERO; }
aoqi@0 90 int add_opcode() const { return Op_AddI; }
aoqi@0 91 int mul_opcode() const { return Op_MulI; }
aoqi@0 92 const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 93 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 94 };
aoqi@0 95
aoqi@0 96 //------------------------------MulLNode---------------------------------------
aoqi@0 97 // Multiply 2 longs
aoqi@0 98 class MulLNode : public MulNode {
aoqi@0 99 public:
aoqi@0 100 MulLNode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
aoqi@0 101 virtual int Opcode() const;
aoqi@0 102 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 103 virtual const Type *mul_ring( const Type *, const Type * ) const;
aoqi@0 104 const Type *mul_id() const { return TypeLong::ONE; }
aoqi@0 105 const Type *add_id() const { return TypeLong::ZERO; }
aoqi@0 106 int add_opcode() const { return Op_AddL; }
aoqi@0 107 int mul_opcode() const { return Op_MulL; }
aoqi@0 108 const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 109 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 110 };
aoqi@0 111
aoqi@0 112
aoqi@0 113 //------------------------------MulFNode---------------------------------------
aoqi@0 114 // Multiply 2 floats
aoqi@0 115 class MulFNode : public MulNode {
aoqi@0 116 public:
aoqi@0 117 MulFNode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
aoqi@0 118 virtual int Opcode() const;
aoqi@0 119 virtual const Type *mul_ring( const Type *, const Type * ) const;
aoqi@0 120 const Type *mul_id() const { return TypeF::ONE; }
aoqi@0 121 const Type *add_id() const { return TypeF::ZERO; }
aoqi@0 122 int add_opcode() const { return Op_AddF; }
aoqi@0 123 int mul_opcode() const { return Op_MulF; }
aoqi@0 124 const Type *bottom_type() const { return Type::FLOAT; }
aoqi@0 125 virtual uint ideal_reg() const { return Op_RegF; }
aoqi@0 126 };
aoqi@0 127
aoqi@0 128 //------------------------------MulDNode---------------------------------------
aoqi@0 129 // Multiply 2 doubles
aoqi@0 130 class MulDNode : public MulNode {
aoqi@0 131 public:
aoqi@0 132 MulDNode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
aoqi@0 133 virtual int Opcode() const;
aoqi@0 134 virtual const Type *mul_ring( const Type *, const Type * ) const;
aoqi@0 135 const Type *mul_id() const { return TypeD::ONE; }
aoqi@0 136 const Type *add_id() const { return TypeD::ZERO; }
aoqi@0 137 int add_opcode() const { return Op_AddD; }
aoqi@0 138 int mul_opcode() const { return Op_MulD; }
aoqi@0 139 const Type *bottom_type() const { return Type::DOUBLE; }
aoqi@0 140 virtual uint ideal_reg() const { return Op_RegD; }
aoqi@0 141 };
aoqi@0 142
aoqi@0 143 //-------------------------------MulHiLNode------------------------------------
aoqi@0 144 // Upper 64 bits of a 64 bit by 64 bit multiply
aoqi@0 145 class MulHiLNode : public Node {
aoqi@0 146 public:
aoqi@0 147 MulHiLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
aoqi@0 148 virtual int Opcode() const;
aoqi@0 149 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 150 const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 151 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 152 };
aoqi@0 153
aoqi@0 154 //------------------------------AndINode---------------------------------------
aoqi@0 155 // Logically AND 2 integers. Included with the MUL nodes because it inherits
aoqi@0 156 // all the behavior of multiplication on a ring.
aoqi@0 157 class AndINode : public MulINode {
aoqi@0 158 public:
aoqi@0 159 AndINode( Node *in1, Node *in2 ) : MulINode(in1,in2) {}
aoqi@0 160 virtual int Opcode() const;
aoqi@0 161 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 162 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 163 virtual const Type *mul_ring( const Type *, const Type * ) const;
aoqi@0 164 const Type *mul_id() const { return TypeInt::MINUS_1; }
aoqi@0 165 const Type *add_id() const { return TypeInt::ZERO; }
aoqi@0 166 int add_opcode() const { return Op_OrI; }
aoqi@0 167 int mul_opcode() const { return Op_AndI; }
aoqi@0 168 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 169 };
aoqi@0 170
aoqi@0 171 //------------------------------AndINode---------------------------------------
aoqi@0 172 // Logically AND 2 longs. Included with the MUL nodes because it inherits
aoqi@0 173 // all the behavior of multiplication on a ring.
aoqi@0 174 class AndLNode : public MulLNode {
aoqi@0 175 public:
aoqi@0 176 AndLNode( Node *in1, Node *in2 ) : MulLNode(in1,in2) {}
aoqi@0 177 virtual int Opcode() const;
aoqi@0 178 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 179 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 180 virtual const Type *mul_ring( const Type *, const Type * ) const;
aoqi@0 181 const Type *mul_id() const { return TypeLong::MINUS_1; }
aoqi@0 182 const Type *add_id() const { return TypeLong::ZERO; }
aoqi@0 183 int add_opcode() const { return Op_OrL; }
aoqi@0 184 int mul_opcode() const { return Op_AndL; }
aoqi@0 185 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 186 };
aoqi@0 187
aoqi@0 188 //------------------------------LShiftINode------------------------------------
aoqi@0 189 // Logical shift left
aoqi@0 190 class LShiftINode : public Node {
aoqi@0 191 public:
aoqi@0 192 LShiftINode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
aoqi@0 193 virtual int Opcode() const;
aoqi@0 194 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 195 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 196 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 197 const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 198 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 199 };
aoqi@0 200
aoqi@0 201 //------------------------------LShiftLNode------------------------------------
aoqi@0 202 // Logical shift left
aoqi@0 203 class LShiftLNode : public Node {
aoqi@0 204 public:
aoqi@0 205 LShiftLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
aoqi@0 206 virtual int Opcode() const;
aoqi@0 207 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 208 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 209 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 210 const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 211 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 212 };
aoqi@0 213
aoqi@0 214 //------------------------------RShiftINode------------------------------------
aoqi@0 215 // Signed shift right
aoqi@0 216 class RShiftINode : public Node {
aoqi@0 217 public:
aoqi@0 218 RShiftINode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
aoqi@0 219 virtual int Opcode() const;
aoqi@0 220 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 221 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 222 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 223 const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 224 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 225 };
aoqi@0 226
aoqi@0 227 //------------------------------RShiftLNode------------------------------------
aoqi@0 228 // Signed shift right
aoqi@0 229 class RShiftLNode : public Node {
aoqi@0 230 public:
aoqi@0 231 RShiftLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
aoqi@0 232 virtual int Opcode() const;
aoqi@0 233 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 234 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 235 const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 236 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 237 };
aoqi@0 238
aoqi@0 239
aoqi@0 240 //------------------------------URShiftINode-----------------------------------
aoqi@0 241 // Logical shift right
aoqi@0 242 class URShiftINode : public Node {
aoqi@0 243 public:
aoqi@0 244 URShiftINode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
aoqi@0 245 virtual int Opcode() const;
aoqi@0 246 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 247 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 248 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 249 const Type *bottom_type() const { return TypeInt::INT; }
aoqi@0 250 virtual uint ideal_reg() const { return Op_RegI; }
aoqi@0 251 };
aoqi@0 252
aoqi@0 253 //------------------------------URShiftLNode-----------------------------------
aoqi@0 254 // Logical shift right
aoqi@0 255 class URShiftLNode : public Node {
aoqi@0 256 public:
aoqi@0 257 URShiftLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
aoqi@0 258 virtual int Opcode() const;
aoqi@0 259 virtual Node *Identity( PhaseTransform *phase );
aoqi@0 260 virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
aoqi@0 261 virtual const Type *Value( PhaseTransform *phase ) const;
aoqi@0 262 const Type *bottom_type() const { return TypeLong::LONG; }
aoqi@0 263 virtual uint ideal_reg() const { return Op_RegL; }
aoqi@0 264 };
aoqi@0 265
aoqi@0 266 #endif // SHARE_VM_OPTO_MULNODE_HPP

mercurial