1 /*
   2  * Copyright (c) 2014, 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 
  41 //---------- CountLeadingZerosINode --------------------------------------------
  42 // Count leading zeros (0-bit count starting from MSB) of an integer.
  43 class CountLeadingZerosINode : public CountBitsNode {
  44   public:
  45   CountLeadingZerosINode(Node* in1) : CountBitsNode(in1) {}
  46   virtual int Opcode() const;
  47   virtual const Type* Value(PhaseGVN* phase) const;
  48 };
  49 
  50 //---------- CountLeadingZerosLNode --------------------------------------------
  51 // Count leading zeros (0-bit count starting from MSB) of a long.
  52 class CountLeadingZerosLNode : public CountBitsNode {
  53   public:
  54   CountLeadingZerosLNode(Node* in1) : CountBitsNode(in1) {}
  55   virtual int Opcode() const;
  56   virtual const Type* Value(PhaseGVN* phase) const;
  57 };
  58 
  59 //---------- CountTrailingZerosINode -------------------------------------------
  60 // Count trailing zeros (0-bit count starting from LSB) of an integer.
  61 class CountTrailingZerosINode : public CountBitsNode {
  62   public:
  63   CountTrailingZerosINode(Node* in1) : CountBitsNode(in1) {}
  64   virtual int Opcode() const;
  65   virtual const Type* Value(PhaseGVN* phase) const;
  66 };
  67 
  68 //---------- CountTrailingZerosLNode -------------------------------------------
  69 // Count trailing zeros (0-bit count starting from LSB) of a long.
  70 class CountTrailingZerosLNode : public CountBitsNode {
  71   public:
  72   CountTrailingZerosLNode(Node* in1) : CountBitsNode(in1) {}
  73   virtual int Opcode() const;
  74   virtual const Type* Value(PhaseGVN* phase) const;
  75 };
  76 
  77 //---------- PopCountINode -----------------------------------------------------
  78 // Population count (bit count) of an integer.
  79 class PopCountINode : public CountBitsNode {
  80   public:
  81   PopCountINode(Node* in1) : CountBitsNode(in1) {}
  82   virtual int Opcode() const;
  83 };
  84 
  85 //---------- PopCountLNode -----------------------------------------------------
  86 // Population count (bit count) of a long.
  87 class PopCountLNode : public CountBitsNode {
  88   public:
  89   PopCountLNode(Node* in1) : CountBitsNode(in1) {}
  90   virtual int Opcode() const;
  91 };
  92 
  93 
  94 #endif // SHARE_VM_OPTO_COUNTBITSNODE_HPP