src/share/vm/opto/addnode.hpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2006, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 







  25 // Portions of code courtesy of Clifford Click
  26 
  27 class PhaseTransform;
  28 
  29 //------------------------------AddNode----------------------------------------
  30 // Classic Add functionality.  This covers all the usual 'add' behaviors for
  31 // an algebraic ring.  Add-integer, add-float, add-double, and binary-or are
  32 // all inherited from this class.  The various identity values are supplied
  33 // by virtual functions.
  34 class AddNode : public Node {
  35   virtual uint hash() const;
  36 public:
  37   AddNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {
  38     init_class_id(Class_Add);
  39   }
  40 
  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 );
  44 


 224   virtual int Opcode() const;
 225   virtual const Type *add_ring( const Type *, const Type * ) const;
 226   virtual const Type *add_id() const { return TypeInt::make(min_jint); }
 227   virtual const Type *bottom_type() const { return TypeInt::INT; }
 228   virtual uint ideal_reg() const { return Op_RegI; }
 229 };
 230 
 231 //------------------------------MinINode---------------------------------------
 232 // MINimum of 2 integers.  Included with the ADD nodes because it inherits
 233 // all the behavior of addition on a ring.
 234 class MinINode : public MaxNode {
 235 public:
 236   MinINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}
 237   virtual int Opcode() const;
 238   virtual const Type *add_ring( const Type *, const Type * ) const;
 239   virtual const Type *add_id() const { return TypeInt::make(max_jint); }
 240   virtual const Type *bottom_type() const { return TypeInt::INT; }
 241   virtual uint ideal_reg() const { return Op_RegI; }
 242   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
 243 };


   1 /*
   2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_OPTO_ADDNODE_HPP
  26 #define SHARE_VM_OPTO_ADDNODE_HPP
  27 
  28 #include "opto/node.hpp"
  29 #include "opto/opcodes.hpp"
  30 #include "opto/type.hpp"
  31 
  32 // Portions of code courtesy of Clifford Click
  33 
  34 class PhaseTransform;
  35 
  36 //------------------------------AddNode----------------------------------------
  37 // Classic Add functionality.  This covers all the usual 'add' behaviors for
  38 // an algebraic ring.  Add-integer, add-float, add-double, and binary-or are
  39 // all inherited from this class.  The various identity values are supplied
  40 // by virtual functions.
  41 class AddNode : public Node {
  42   virtual uint hash() const;
  43 public:
  44   AddNode( Node *in1, Node *in2 ) : Node(0,in1,in2) {
  45     init_class_id(Class_Add);
  46   }
  47 
  48   // Handle algebraic identities here.  If we have an identity, return the Node
  49   // we are equivalent to.  We look for "add of zero" as an identity.
  50   virtual Node *Identity( PhaseTransform *phase );
  51 


 231   virtual int Opcode() const;
 232   virtual const Type *add_ring( const Type *, const Type * ) const;
 233   virtual const Type *add_id() const { return TypeInt::make(min_jint); }
 234   virtual const Type *bottom_type() const { return TypeInt::INT; }
 235   virtual uint ideal_reg() const { return Op_RegI; }
 236 };
 237 
 238 //------------------------------MinINode---------------------------------------
 239 // MINimum of 2 integers.  Included with the ADD nodes because it inherits
 240 // all the behavior of addition on a ring.
 241 class MinINode : public MaxNode {
 242 public:
 243   MinINode( Node *in1, Node *in2 ) : MaxNode(in1,in2) {}
 244   virtual int Opcode() const;
 245   virtual const Type *add_ring( const Type *, const Type * ) const;
 246   virtual const Type *add_id() const { return TypeInt::make(max_jint); }
 247   virtual const Type *bottom_type() const { return TypeInt::INT; }
 248   virtual uint ideal_reg() const { return Op_RegI; }
 249   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
 250 };
 251 
 252 #endif // SHARE_VM_OPTO_ADDNODE_HPP