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_COUNTBITSNODE_HPP
  26 #define SHARE_VM_OPTO_COUNTBITSNODE_HPP
  27 
  28 #include "opto/node.hpp"
  29 #include "opto/opcodes.hpp"
  30 
  31 class PhaseTransform;
  32 
  33 //---------- CountBitsNode -----------------------------------------------------
  34 class CountBitsNode : public Node {
  35   public:
  36   CountBitsNode(Node* in1) : Node(0, in1) {}
  37   const Type* bottom_type() const { return TypeInt::INT; }
  38   virtual uint ideal_reg() const { return Op_RegI; }
  39 
  40 #ifndef PRODUCT
  41   REL_IN_DATA_OUT_1;
  42 #endif
  43 };
  44 
  45 //---------- CountLeadingZerosINode --------------------------------------------
  46 // Count leading zeros (0-bit count starting from MSB) of an integer.
  47 class CountLeadingZerosINode : public CountBitsNode {
  48   public:
  49   CountLeadingZerosINode(Node* in1) : CountBitsNode(in1) {}
  50   virtual int Opcode() const;
  51   virtual const Type* Value(PhaseTransform* phase) const;
  52 };
  53 
  54 //---------- CountLeadingZerosLNode --------------------------------------------
  55 // Count leading zeros (0-bit count starting from MSB) of a long.
  56 class CountLeadingZerosLNode : public CountBitsNode {
  57   public:
  58   CountLeadingZerosLNode(Node* in1) : CountBitsNode(in1) {}
  59   virtual int Opcode() const;
  60   virtual const Type* Value(PhaseTransform* phase) const;
  61 };
  62 
  63 //---------- CountTrailingZerosINode -------------------------------------------
  64 // Count trailing zeros (0-bit count starting from LSB) of an integer.
  65 class CountTrailingZerosINode : public CountBitsNode {
  66   public:
  67   CountTrailingZerosINode(Node* in1) : CountBitsNode(in1) {}
  68   virtual int Opcode() const;
  69   virtual const Type* Value(PhaseTransform* phase) const;
  70 };
  71 
  72 //---------- CountTrailingZerosLNode -------------------------------------------
  73 // Count trailing zeros (0-bit count starting from LSB) of a long.
  74 class CountTrailingZerosLNode : public CountBitsNode {
  75   public:
  76   CountTrailingZerosLNode(Node* in1) : CountBitsNode(in1) {}
  77   virtual int Opcode() const;
  78   virtual const Type* Value(PhaseTransform* phase) const;
  79 };
  80 
  81 //---------- PopCountINode -----------------------------------------------------
  82 // Population count (bit count) of an integer.
  83 class PopCountINode : public CountBitsNode {
  84   public:
  85   PopCountINode(Node* in1) : CountBitsNode(in1) {}
  86   virtual int Opcode() const;
  87 };
  88 
  89 //---------- PopCountLNode -----------------------------------------------------
  90 // Population count (bit count) of a long.
  91 class PopCountLNode : public CountBitsNode {
  92   public:
  93   PopCountLNode(Node* in1) : CountBitsNode(in1) {}
  94   virtual int Opcode() const;
  95 };
  96 
  97 
  98 #endif // SHARE_VM_OPTO_COUNTBITSNODE_HPP