1 /*
   2  * Copyright (c) 2014, 2015, 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_CONVERTNODE_HPP
  26 #define SHARE_VM_OPTO_CONVERTNODE_HPP
  27 
  28 #include "opto/node.hpp"
  29 #include "opto/opcodes.hpp"
  30 
  31 
  32 //------------------------------Conv2BNode-------------------------------------
  33 // Convert int/pointer to a Boolean.  Map zero to zero, all else to 1.
  34 class Conv2BNode : public Node {
  35   public:
  36   Conv2BNode( Node *i ) : Node(0,i) {}
  37   virtual int Opcode() const;
  38   virtual const Type *bottom_type() const { return TypeInt::BOOL; }
  39   virtual Node *Identity( PhaseTransform *phase );
  40   virtual const Type *Value( PhaseTransform *phase ) const;
  41   virtual uint  ideal_reg() const { return Op_RegI; }
  42 };
  43 
  44 // The conversions operations are all Alpha sorted.  Please keep it that way!
  45 //------------------------------ConvD2FNode------------------------------------
  46 // Convert double to float
  47 class ConvD2FNode : public Node {
  48   public:
  49   ConvD2FNode( Node *in1 ) : Node(0,in1) {}
  50   virtual int Opcode() const;
  51   virtual const Type *bottom_type() const { return Type::FLOAT; }
  52   virtual const Type *Value( PhaseTransform *phase ) const;
  53   virtual Node *Identity( PhaseTransform *phase );
  54   virtual uint  ideal_reg() const { return Op_RegF; }
  55 };
  56 
  57 //------------------------------ConvD2INode------------------------------------
  58 // Convert Double to Integer
  59 class ConvD2INode : public Node {
  60   public:
  61   ConvD2INode( Node *in1 ) : Node(0,in1) {}
  62   virtual int Opcode() const;
  63   virtual const Type *bottom_type() const { return TypeInt::INT; }
  64   virtual const Type *Value( PhaseTransform *phase ) const;
  65   virtual Node *Identity( PhaseTransform *phase );
  66   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
  67   virtual uint  ideal_reg() const { return Op_RegI; }
  68 };
  69 
  70 //------------------------------ConvD2LNode------------------------------------
  71 // Convert Double to Long
  72 class ConvD2LNode : public Node {
  73   public:
  74   ConvD2LNode( Node *dbl ) : Node(0,dbl) {}
  75   virtual int Opcode() const;
  76   virtual const Type *bottom_type() const { return TypeLong::LONG; }
  77   virtual const Type *Value( PhaseTransform *phase ) const;
  78   virtual Node *Identity( PhaseTransform *phase );
  79   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
  80   virtual uint ideal_reg() const { return Op_RegL; }
  81 };
  82 
  83 //------------------------------ConvF2DNode------------------------------------
  84 // Convert Float to a Double.
  85 class ConvF2DNode : public Node {
  86   public:
  87   ConvF2DNode( Node *in1 ) : Node(0,in1) {}
  88   virtual int Opcode() const;
  89   virtual const Type *bottom_type() const { return Type::DOUBLE; }
  90   virtual const Type *Value( PhaseTransform *phase ) const;
  91   virtual uint  ideal_reg() const { return Op_RegD; }
  92 };
  93 
  94 //------------------------------ConvF2INode------------------------------------
  95 // Convert float to integer
  96 class ConvF2INode : public Node {
  97   public:
  98   ConvF2INode( Node *in1 ) : Node(0,in1) {}
  99   virtual int Opcode() const;
 100   virtual const Type *bottom_type() const { return TypeInt::INT; }
 101   virtual const Type *Value( PhaseTransform *phase ) const;
 102   virtual Node *Identity( PhaseTransform *phase );
 103   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
 104   virtual uint  ideal_reg() const { return Op_RegI; }
 105 };
 106 
 107 //------------------------------ConvF2LNode------------------------------------
 108 // Convert float to long
 109 class ConvF2LNode : public Node {
 110   public:
 111   ConvF2LNode( Node *in1 ) : Node(0,in1) {}
 112   virtual int Opcode() const;
 113   virtual const Type *bottom_type() const { return TypeLong::LONG; }
 114   virtual const Type *Value( PhaseTransform *phase ) const;
 115   virtual Node *Identity( PhaseTransform *phase );
 116   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
 117   virtual uint  ideal_reg() const { return Op_RegL; }
 118 };
 119 
 120 //------------------------------ConvI2DNode------------------------------------
 121 // Convert Integer to Double
 122 class ConvI2DNode : public Node {
 123   public:
 124   ConvI2DNode( Node *in1 ) : Node(0,in1) {}
 125   virtual int Opcode() const;
 126   virtual const Type *bottom_type() const { return Type::DOUBLE; }
 127   virtual const Type *Value( PhaseTransform *phase ) const;
 128   virtual uint  ideal_reg() const { return Op_RegD; }
 129 };
 130 
 131 //------------------------------ConvI2FNode------------------------------------
 132 // Convert Integer to Float
 133 class ConvI2FNode : public Node {
 134   public:
 135   ConvI2FNode( Node *in1 ) : Node(0,in1) {}
 136   virtual int Opcode() const;
 137   virtual const Type *bottom_type() const { return Type::FLOAT; }
 138   virtual const Type *Value( PhaseTransform *phase ) const;
 139   virtual Node *Identity( PhaseTransform *phase );
 140   virtual uint  ideal_reg() const { return Op_RegF; }
 141 };
 142 
 143 //------------------------------ConvI2LNode------------------------------------
 144 // Convert integer to long
 145 class ConvI2LNode : public TypeNode {
 146   public:
 147   ConvI2LNode(Node *in1, const TypeLong* t = TypeLong::INT)
 148   : TypeNode(t, 2)
 149   { init_req(1, in1); }
 150   virtual int Opcode() const;
 151   virtual const Type *Value( PhaseTransform *phase ) const;
 152   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
 153   virtual uint  ideal_reg() const { return Op_RegL; }
 154 };
 155 
 156 //------------------------------ConvL2DNode------------------------------------
 157 // Convert Long to Double
 158 class ConvL2DNode : public Node {
 159   public:
 160   ConvL2DNode( Node *in1 ) : Node(0,in1) {}
 161   virtual int Opcode() const;
 162   virtual const Type *bottom_type() const { return Type::DOUBLE; }
 163   virtual const Type *Value( PhaseTransform *phase ) const;
 164   virtual uint ideal_reg() const { return Op_RegD; }
 165 };
 166 
 167 //------------------------------ConvL2FNode------------------------------------
 168 // Convert Long to Float
 169 class ConvL2FNode : public Node {
 170   public:
 171   ConvL2FNode( Node *in1 ) : Node(0,in1) {}
 172   virtual int Opcode() const;
 173   virtual const Type *bottom_type() const { return Type::FLOAT; }
 174   virtual const Type *Value( PhaseTransform *phase ) const;
 175   virtual uint  ideal_reg() const { return Op_RegF; }
 176 };
 177 
 178 //------------------------------ConvL2INode------------------------------------
 179 // Convert long to integer
 180 class ConvL2INode : public Node {
 181   public:
 182   ConvL2INode( Node *in1 ) : Node(0,in1) {}
 183   virtual int Opcode() const;
 184   virtual const Type *bottom_type() const { return TypeInt::INT; }
 185   virtual Node *Identity( PhaseTransform *phase );
 186   virtual const Type *Value( PhaseTransform *phase ) const;
 187   virtual Node *Ideal(PhaseGVN *phase, bool can_reshape);
 188   virtual uint  ideal_reg() const { return Op_RegI; }
 189 };
 190 
 191 //-----------------------------RoundFloatNode----------------------------------
 192 class RoundFloatNode: public Node {
 193   public:
 194   RoundFloatNode(Node* c, Node *in1): Node(c, in1) {}
 195   virtual int   Opcode() const;
 196   virtual const Type *bottom_type() const { return Type::FLOAT; }
 197   virtual uint  ideal_reg() const { return Op_RegF; }
 198   virtual Node *Identity( PhaseTransform *phase );
 199   virtual const Type *Value( PhaseTransform *phase ) const;
 200 
 201 #ifndef PRODUCT
 202   REL_IN_DATA_OUT_1;
 203 #endif
 204 };
 205 
 206 
 207 //-----------------------------RoundDoubleNode---------------------------------
 208 class RoundDoubleNode: public Node {
 209   public:
 210   RoundDoubleNode(Node* c, Node *in1): Node(c, in1) {}
 211   virtual int   Opcode() const;
 212   virtual const Type *bottom_type() const { return Type::DOUBLE; }
 213   virtual uint  ideal_reg() const { return Op_RegD; }
 214   virtual Node *Identity( PhaseTransform *phase );
 215   virtual const Type *Value( PhaseTransform *phase ) const;
 216 
 217 #ifndef PRODUCT
 218   REL_IN_DATA_OUT_1;
 219 #endif
 220 };
 221 
 222 
 223 #endif // SHARE_VM_OPTO_CONVERTNODE_HPP