8212481: PPC64: Enable POWER9 CPU detection
authorgromero
Tue, 16 Oct 2018 16:26:28 -0400
changeset 52355 0caa36de8703
parent 52354 a39d9d4ab891
child 52356 19c4a3eec4d7
8212481: PPC64: Enable POWER9 CPU detection Reviewed-by: mdoerr, simonis
src/hotspot/cpu/ppc/assembler_ppc.hpp
src/hotspot/cpu/ppc/assembler_ppc.inline.hpp
src/hotspot/cpu/ppc/vm_version_ppc.cpp
src/hotspot/cpu/ppc/vm_version_ppc.hpp
--- a/src/hotspot/cpu/ppc/assembler_ppc.hpp	Wed Oct 31 19:00:59 2018 +0100
+++ b/src/hotspot/cpu/ppc/assembler_ppc.hpp	Tue Oct 16 16:26:28 2018 -0400
@@ -535,6 +535,9 @@
     XVMULSP_OPCODE = (60u << OPCODE_SHIFT |   80u << 3),
     XVMULDP_OPCODE = (60u << OPCODE_SHIFT |  112u << 3),
 
+    // Deliver A Random Number (introduced with POWER9)
+    DARN_OPCODE    = (31u << OPCODE_SHIFT |  755u << 1),
+
     // Vector Permute and Formatting
     VPKPX_OPCODE   = (4u  << OPCODE_SHIFT |  782u     ),
     VPKSHSS_OPCODE = (4u  << OPCODE_SHIFT |  398u     ),
@@ -1072,6 +1075,7 @@
   static int frt(      int         x)  { return  opp_u_field(x,             10,  6); }
   static int fxm(      int         x)  { return  opp_u_field(x,             19, 12); }
   static int l10(      int         x)  { return  opp_u_field(x,             10, 10); }
+  static int l14(      int         x)  { return  opp_u_field(x,             15, 14); }
   static int l15(      int         x)  { return  opp_u_field(x,             15, 15); }
   static int l910(     int         x)  { return  opp_u_field(x,             10,  9); }
   static int e1215(    int         x)  { return  opp_u_field(x,             15, 12); }
@@ -2220,6 +2224,9 @@
   inline void mtfprwa(  FloatRegister   d, Register a);
   inline void mffprd(   Register        a, FloatRegister d);
 
+  // Deliver A Random Number (introduced with POWER9)
+  inline void darn( Register d, int l = 1 /*L=CRN*/);
+
   // AES (introduced with Power 8)
   inline void vcipher(     VectorRegister d, VectorRegister a, VectorRegister b);
   inline void vcipherlast( VectorRegister d, VectorRegister a, VectorRegister b);
--- a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp	Wed Oct 31 19:00:59 2018 +0100
+++ b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp	Tue Oct 16 16:26:28 2018 -0400
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -979,6 +979,9 @@
 inline void Assembler::tresume_()                               { emit_int32( TSR_OPCODE | /*L=1*/ 1u << (31-10) | rc(1)); }
 inline void Assembler::tcheck(int f)                            { emit_int32( TCHECK_OPCODE | bf(f)); }
 
+// Deliver A Random Number (introduced with POWER9)
+inline void Assembler::darn(Register d, int l /* =1 */) { emit_int32( DARN_OPCODE | rt(d) | l14(l)); }
+
 // ra0 version
 inline void Assembler::lwzx( Register d, Register s2) { emit_int32( LWZX_OPCODE | rt(d) | rb(s2));}
 inline void Assembler::lwz(  Register d, int si16   ) { emit_int32( LWZ_OPCODE  | rt(d) | d1(si16));}
--- a/src/hotspot/cpu/ppc/vm_version_ppc.cpp	Wed Oct 31 19:00:59 2018 +0100
+++ b/src/hotspot/cpu/ppc/vm_version_ppc.cpp	Tue Oct 16 16:26:28 2018 -0400
@@ -63,7 +63,9 @@
 
   // If PowerArchitecturePPC64 hasn't been specified explicitly determine from features.
   if (FLAG_IS_DEFAULT(PowerArchitecturePPC64)) {
-    if (VM_Version::has_lqarx()) {
+    if (VM_Version::has_darn()) {
+      FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 9);
+    } else if (VM_Version::has_lqarx()) {
       FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 8);
     } else if (VM_Version::has_popcntw()) {
       FLAG_SET_ERGO(uintx, PowerArchitecturePPC64, 7);
@@ -78,6 +80,7 @@
 
   bool PowerArchitecturePPC64_ok = false;
   switch (PowerArchitecturePPC64) {
+    case 9: if (!VM_Version::has_darn()   ) break;
     case 8: if (!VM_Version::has_lqarx()  ) break;
     case 7: if (!VM_Version::has_popcntw()) break;
     case 6: if (!VM_Version::has_cmpb()   ) break;
@@ -131,12 +134,11 @@
   // Create and print feature-string.
   char buf[(num_features+1) * 16]; // Max 16 chars per feature.
   jio_snprintf(buf, sizeof(buf),
-               "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+               "ppc64%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
                (has_fsqrt()   ? " fsqrt"   : ""),
                (has_isel()    ? " isel"    : ""),
                (has_lxarxeh() ? " lxarxeh" : ""),
                (has_cmpb()    ? " cmpb"    : ""),
-               //(has_mftgpr()? " mftgpr"  : ""),
                (has_popcntb() ? " popcntb" : ""),
                (has_popcntw() ? " popcntw" : ""),
                (has_fcfids()  ? " fcfids"  : ""),
@@ -149,7 +151,8 @@
                (has_ldbrx()   ? " ldbrx"   : ""),
                (has_stdbrx()  ? " stdbrx"  : ""),
                (has_vshasig() ? " sha"     : ""),
-               (has_tm()      ? " rtm"     : "")
+               (has_tm()      ? " rtm"     : ""),
+               (has_darn()    ? " darn"    : "")
                // Make sure number of %s matches num_features!
               );
   _features_string = os::strdup(buf);
@@ -663,6 +666,8 @@
   a->ldbrx(R7, R3_ARG1, R4_ARG2);              // code[14] -> ldbrx
   a->stdbrx(R7, R3_ARG1, R4_ARG2);             // code[15] -> stdbrx
   a->vshasigmaw(VR0, VR1, 1, 0xF);             // code[16] -> vshasig
+  // rtm is determined by OS
+  a->darn(R7);                                 // code[17] -> darn
   a->blr();
 
   // Emit function to set one cache line to zero. Emit function descriptor and get pointer to it.
@@ -714,6 +719,8 @@
   if (code[feature_cntr++]) features |= ldbrx_m;
   if (code[feature_cntr++]) features |= stdbrx_m;
   if (code[feature_cntr++]) features |= vshasig_m;
+  // feature rtm_m is determined by OS
+  if (code[feature_cntr++]) features |= darn_m;
 
   // Print the detection code.
   if (PrintAssembly) {
--- a/src/hotspot/cpu/ppc/vm_version_ppc.hpp	Wed Oct 31 19:00:59 2018 +0100
+++ b/src/hotspot/cpu/ppc/vm_version_ppc.hpp	Tue Oct 16 16:26:28 2018 -0400
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2017 SAP SE. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,6 +50,7 @@
     stdbrx,
     vshasig,
     rtm,
+    darn,
     num_features // last entry to count features
   };
   enum Feature_Flag_Set {
@@ -72,6 +73,7 @@
     stdbrx_m              = (1 << stdbrx ),
     vshasig_m             = (1 << vshasig),
     rtm_m                 = (1 << rtm    ),
+    darn_m                = (1 << darn   ),
     all_features_m        = (unsigned long)-1
   };
 
@@ -108,9 +110,10 @@
   static bool has_ldbrx()   { return (_features & ldbrx_m) != 0; }
   static bool has_stdbrx()  { return (_features & stdbrx_m) != 0; }
   static bool has_vshasig() { return (_features & vshasig_m) != 0; }
+  static bool has_tm()      { return (_features & rtm_m) != 0; }
+  static bool has_darn()    { return (_features & darn_m) != 0; }
+
   static bool has_mtfprd()  { return has_vpmsumb(); } // alias for P8
-  // OS feature support
-  static bool has_tm()      { return (_features & rtm_m) != 0; }
 
   // Assembler testing
   static void allow_all();