1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2012, 2013 SAP AG. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef CPU_PPC_VM_VM_VERSION_PPC_HPP
  27 #define CPU_PPC_VM_VM_VERSION_PPC_HPP
  28 
  29 #include "runtime/globals_extension.hpp"
  30 #include "runtime/vm_version.hpp"
  31 
  32 class VM_Version: public Abstract_VM_Version {
  33 protected:
  34   enum Feature_Flag {
  35     fsqrt,
  36     isel,
  37     lxarxeh,
  38     cmpb,
  39     popcntb,
  40     popcntw,
  41     fcfids,
  42     vand,
  43     dcba,
  44     num_features // last entry to count features
  45   };
  46   enum Feature_Flag_Set {
  47     unknown_m             = 0,
  48     fsqrt_m               = (1 << fsqrt  ),
  49     isel_m                = (1 << isel   ),
  50     lxarxeh_m             = (1 << lxarxeh),
  51     cmpb_m                = (1 << cmpb   ),
  52     popcntb_m             = (1 << popcntb),
  53     popcntw_m             = (1 << popcntw),
  54     fcfids_m              = (1 << fcfids ),
  55     vand_m                = (1 << vand   ),
  56     dcba_m                = (1 << dcba   ),
  57     all_features_m        = -1
  58   };
  59   static int  _features;
  60   static int  _measured_cache_line_size;
  61   static const char* _features_str;
  62   static bool _is_determine_features_test_running;
  63 
  64   static void print_features();
  65   static void determine_features(); // also measures cache line size
  66   static void determine_section_size();
  67   static void power6_micro_bench();
  68 public:
  69   // Initialization
  70   static void initialize();
  71 
  72   static bool is_determine_features_test_running() { return _is_determine_features_test_running; }
  73   // CPU instruction support
  74   static bool has_fsqrt()   { return (_features & fsqrt_m) != 0; }
  75   static bool has_isel()    { return (_features & isel_m) != 0; }
  76   static bool has_lxarxeh() { return (_features & lxarxeh_m) !=0; }
  77   static bool has_cmpb()    { return (_features & cmpb_m) != 0; }
  78   static bool has_popcntb() { return (_features & popcntb_m) != 0; }
  79   static bool has_popcntw() { return (_features & popcntw_m) != 0; }
  80   static bool has_fcfids()  { return (_features & fcfids_m) != 0; }
  81   static bool has_vand()    { return (_features & vand_m) != 0; }
  82   static bool has_dcba()    { return (_features & dcba_m) != 0; }
  83 
  84   static const char* cpu_features() { return _features_str; }
  85 
  86   static int get_cache_line_size()  { return _measured_cache_line_size; }
  87 
  88   // Assembler testing
  89   static void allow_all();
  90   static void revert();
  91 };
  92 
  93 #endif // CPU_PPC_VM_VM_VERSION_PPC_HPP