src/share/vm/opto/mulnode.hpp

Mon, 25 Feb 2008 15:05:44 -0800

author
kvn
date
Mon, 25 Feb 2008 15:05:44 -0800
changeset 464
d5fc211aea19
parent 435
a61af66fc99e
child 580
f3de1255b035
permissions
-rw-r--r--

6633953: type2aelembytes{T_ADDRESS} should be 8 bytes in 64 bit VM
Summary: T_ADDRESS size is defined as 'int' size (4 bytes) but C2 use it for raw pointers and as memory type for StoreP and LoadP nodes.
Reviewed-by: jrose

     1 /*
     2  * Copyright 1997-2005 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 // Portions of code courtesy of Clifford Click
    27 class PhaseTransform;
    29 //------------------------------MulNode----------------------------------------
    30 // Classic MULTIPLY functionality.  This covers all the usual 'multiply'
    31 // behaviors for an algebraic ring.  Multiply-integer, multiply-float,
    32 // multiply-double, and binary-and are all inherited from this class.  The
    33 // various identity values are supplied by virtual functions.
    34 class MulNode : public Node {
    35   virtual uint hash() const;
    36 public:
    37   MulNode( Node *in1, Node *in2 ): Node(0,in1,in2) {
    38     init_class_id(Class_Mul);
    39   }
    41   // Handle algebraic identities here.  If we have an identity, return the Node
    42   // we are equivalent to.  We look for "add of zero" as an identity.
    43   virtual Node *Identity( PhaseTransform *phase );
    45   // We also canonicalize the Node, moving constants to the right input,
    46   // and flatten expressions (so that 1+x+2 becomes x+3).
    47   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    49   // Compute a new Type for this node.  Basically we just do the pre-check,
    50   // then call the virtual add() to set the type.
    51   virtual const Type *Value( PhaseTransform *phase ) const;
    53   // Supplied function returns the product of the inputs.
    54   // This also type-checks the inputs for sanity.  Guaranteed never to
    55   // be passed a TOP or BOTTOM type, these are filtered out by a pre-check.
    56   // This call recognizes the multiplicative zero type.
    57   virtual const Type *mul_ring( const Type *, const Type * ) const = 0;
    59   // Supplied function to return the multiplicative identity type
    60   virtual const Type *mul_id() const = 0;
    62   // Supplied function to return the additive identity type
    63   virtual const Type *add_id() const = 0;
    65   // Supplied function to return the additive opcode
    66   virtual int add_opcode() const = 0;
    68   // Supplied function to return the multiplicative opcode
    69   virtual int mul_opcode() const = 0;
    71 };
    73 //------------------------------MulINode---------------------------------------
    74 // Multiply 2 integers
    75 class MulINode : public MulNode {
    76 public:
    77   MulINode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
    78   virtual int Opcode() const;
    79   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    80   virtual const Type *mul_ring( const Type *, const Type * ) const;
    81   const Type *mul_id() const { return TypeInt::ONE; }
    82   const Type *add_id() const { return TypeInt::ZERO; }
    83   int add_opcode() const { return Op_AddI; }
    84   int mul_opcode() const { return Op_MulI; }
    85   const Type *bottom_type() const { return TypeInt::INT; }
    86   virtual uint ideal_reg() const { return Op_RegI; }
    87 };
    89 //------------------------------MulLNode---------------------------------------
    90 // Multiply 2 longs
    91 class MulLNode : public MulNode {
    92 public:
    93   MulLNode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
    94   virtual int Opcode() const;
    95   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
    96   virtual const Type *mul_ring( const Type *, const Type * ) const;
    97   const Type *mul_id() const { return TypeLong::ONE; }
    98   const Type *add_id() const { return TypeLong::ZERO; }
    99   int add_opcode() const { return Op_AddL; }
   100   int mul_opcode() const { return Op_MulL; }
   101   const Type *bottom_type() const { return TypeLong::LONG; }
   102   virtual uint ideal_reg() const { return Op_RegL; }
   103 };
   106 //------------------------------MulFNode---------------------------------------
   107 // Multiply 2 floats
   108 class MulFNode : public MulNode {
   109 public:
   110   MulFNode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
   111   virtual int Opcode() const;
   112   virtual const Type *mul_ring( const Type *, const Type * ) const;
   113   const Type *mul_id() const { return TypeF::ONE; }
   114   const Type *add_id() const { return TypeF::ZERO; }
   115   int add_opcode() const { return Op_AddF; }
   116   int mul_opcode() const { return Op_MulF; }
   117   const Type *bottom_type() const { return Type::FLOAT; }
   118   virtual uint ideal_reg() const { return Op_RegF; }
   119 };
   121 //------------------------------MulDNode---------------------------------------
   122 // Multiply 2 doubles
   123 class MulDNode : public MulNode {
   124 public:
   125   MulDNode( Node *in1, Node *in2 ) : MulNode(in1,in2) {}
   126   virtual int Opcode() const;
   127   virtual const Type *mul_ring( const Type *, const Type * ) const;
   128   const Type *mul_id() const { return TypeD::ONE; }
   129   const Type *add_id() const { return TypeD::ZERO; }
   130   int add_opcode() const { return Op_AddD; }
   131   int mul_opcode() const { return Op_MulD; }
   132   const Type *bottom_type() const { return Type::DOUBLE; }
   133   virtual uint ideal_reg() const { return Op_RegD; }
   134 };
   137 //------------------------------AndINode---------------------------------------
   138 // Logically AND 2 integers.  Included with the MUL nodes because it inherits
   139 // all the behavior of multiplication on a ring.
   140 class AndINode : public MulINode {
   141 public:
   142   AndINode( Node *in1, Node *in2 ) : MulINode(in1,in2) {}
   143   virtual int Opcode() const;
   144   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   145   virtual Node *Identity( PhaseTransform *phase );
   146   virtual const Type *mul_ring( const Type *, const Type * ) const;
   147   const Type *mul_id() const { return TypeInt::MINUS_1; }
   148   const Type *add_id() const { return TypeInt::ZERO; }
   149   int add_opcode() const { return Op_OrI; }
   150   int mul_opcode() const { return Op_AndI; }
   151   virtual uint ideal_reg() const { return Op_RegI; }
   152 };
   154 //------------------------------AndINode---------------------------------------
   155 // Logically AND 2 longs.  Included with the MUL nodes because it inherits
   156 // all the behavior of multiplication on a ring.
   157 class AndLNode : public MulLNode {
   158 public:
   159   AndLNode( Node *in1, Node *in2 ) : MulLNode(in1,in2) {}
   160   virtual int Opcode() const;
   161   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   162   virtual Node *Identity( PhaseTransform *phase );
   163   virtual const Type *mul_ring( const Type *, const Type * ) const;
   164   const Type *mul_id() const { return TypeLong::MINUS_1; }
   165   const Type *add_id() const { return TypeLong::ZERO; }
   166   int add_opcode() const { return Op_OrL; }
   167   int mul_opcode() const { return Op_AndL; }
   168   virtual uint ideal_reg() const { return Op_RegL; }
   169 };
   171 //------------------------------LShiftINode------------------------------------
   172 // Logical shift left
   173 class LShiftINode : public Node {
   174 public:
   175   LShiftINode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
   176   virtual int Opcode() const;
   177   virtual Node *Identity( PhaseTransform *phase );
   178   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   179   virtual const Type *Value( PhaseTransform *phase ) const;
   180   const Type *bottom_type() const { return TypeInt::INT; }
   181   virtual uint ideal_reg() const { return Op_RegI; }
   182 };
   184 //------------------------------LShiftLNode------------------------------------
   185 // Logical shift left
   186 class LShiftLNode : public Node {
   187 public:
   188   LShiftLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
   189   virtual int Opcode() const;
   190   virtual Node *Identity( PhaseTransform *phase );
   191   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   192   virtual const Type *Value( PhaseTransform *phase ) const;
   193   const Type *bottom_type() const { return TypeLong::LONG; }
   194   virtual uint ideal_reg() const { return Op_RegL; }
   195 };
   197 //------------------------------RShiftINode------------------------------------
   198 // Signed shift right
   199 class RShiftINode : public Node {
   200 public:
   201   RShiftINode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
   202   virtual int Opcode() const;
   203   virtual Node *Identity( PhaseTransform *phase );
   204   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   205   virtual const Type *Value( PhaseTransform *phase ) const;
   206   const Type *bottom_type() const { return TypeInt::INT; }
   207   virtual uint ideal_reg() const { return Op_RegI; }
   208 };
   210 //------------------------------RShiftLNode------------------------------------
   211 // Signed shift right
   212 class RShiftLNode : public Node {
   213 public:
   214   RShiftLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
   215   virtual int Opcode() const;
   216   virtual Node *Identity( PhaseTransform *phase );
   217   virtual const Type *Value( PhaseTransform *phase ) const;
   218   const Type *bottom_type() const { return TypeLong::LONG; }
   219   virtual uint ideal_reg() const { return Op_RegL; }
   220 };
   223 //------------------------------URShiftINode-----------------------------------
   224 // Logical shift right
   225 class URShiftINode : public Node {
   226 public:
   227   URShiftINode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
   228   virtual int Opcode() const;
   229   virtual Node *Identity( PhaseTransform *phase );
   230   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   231   virtual const Type *Value( PhaseTransform *phase ) const;
   232   const Type *bottom_type() const { return TypeInt::INT; }
   233   virtual uint ideal_reg() const { return Op_RegI; }
   234 };
   236 //------------------------------URShiftLNode-----------------------------------
   237 // Logical shift right
   238 class URShiftLNode : public Node {
   239 public:
   240   URShiftLNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {}
   241   virtual int Opcode() const;
   242   virtual Node *Identity( PhaseTransform *phase );
   243   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
   244   virtual const Type *Value( PhaseTransform *phase ) const;
   245   const Type *bottom_type() const { return TypeLong::LONG; }
   246   virtual uint ideal_reg() const { return Op_RegL; }
   247 };

mercurial