Bug 1359333 - detect aes-ni support, r=froydnj
authorFranziskus Kiefer <franziskuskiefer@gmail.com>
Fri, 31 Mar 2017 18:59:56 +0200
changeset 357323 94600876bb6e45c6b73a4d7ff9bcec4c27bf2b28
parent 357322 dfa904c745092fefb7874762667688c2d2b03d44
child 357324 3be9f4acec69b52aa0e34a949bfa1f938ed2d1e2
push id90104
push userfranziskuskiefer@gmail.com
push dateTue, 09 May 2017 21:17:38 +0000
treeherdermozilla-inbound@3be9f4acec69 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1359333
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1359333 - detect aes-ni support, r=froydnj MozReview-Commit-ID: 4cCVIntG9bD
mozglue/build/SSE.cpp
mozglue/build/SSE.h
--- a/mozglue/build/SSE.cpp
+++ b/mozglue/build/SSE.cpp
@@ -195,12 +195,16 @@ namespace sse_private {
 #if !defined(MOZILLA_PRESUME_AVX)
   bool avx_enabled = has_avx();
 #endif
 
 #if !defined(MOZILLA_PRESUME_AVX2)
   bool avx2_enabled = has_avx() && has_cpuid_bits(7u, ebx, (1u<<5));
 #endif
 
+#if !defined(MOZILLA_PRESUME_AES)
+  bool aes_enabled = has_cpuid_bits(1u, ecx, (1u<<25));
+#endif
+
 #endif
 
 } // namespace sse_private
 } // namespace mozilla
--- a/mozglue/build/SSE.h
+++ b/mozglue/build/SSE.h
@@ -26,16 +26,17 @@
  *    mozilla::supports_sse2
  *    mozilla::supports_sse3
  *    mozilla::supports_ssse3
  *    mozilla::supports_sse4a
  *    mozilla::supports_sse4_1
  *    mozilla::supports_sse4_2
  *    mozilla::supports_avx
  *    mozilla::supports_avx2
+ *    mozilla::supports_aes
  *
  * If you're writing code using inline assembly, you should guard it with a
  * call to one of these functions.  For instance:
  *
  *   if (mozilla::supports_sse2()) {
  *     asm(" ... ");
  *   }
  *   else {
@@ -131,16 +132,20 @@
 #ifdef __AVX__
   // It's ok to use AVX instructions based on the -march option.
   #define MOZILLA_PRESUME_AVX 1
 #endif
 #ifdef __AVX2__
   // It's ok to use AVX instructions based on the -march option.
   #define MOZILLA_PRESUME_AVX2 1
 #endif
+#ifdef __AES__
+  // It's ok to use AES instructions based on the -march option.
+  #define MOZILLA_PRESUME_AES 1
+#endif
 
 
 
 #ifdef HAVE_CPUID_H
   #define MOZILLA_SSE_HAVE_CPUID_DETECTION
 #endif
 
 #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))
@@ -212,16 +217,19 @@ namespace mozilla {
     extern bool MFBT_DATA sse4_2_enabled;
 #endif
 #if !defined(MOZILLA_PRESUME_AVX)
     extern bool MFBT_DATA avx_enabled;
 #endif
 #if !defined(MOZILLA_PRESUME_AVX2)
     extern bool MFBT_DATA avx2_enabled;
 #endif
+#if !defined(MOZILLA_PRESUME_AES)
+    extern bool MFBT_DATA aes_enabled;
+#endif
 
 
 #endif
   } // namespace sse_private
 
 #if defined(MOZILLA_PRESUME_MMX)
 #define MOZILLA_MAY_SUPPORT_MMX 1
   inline bool supports_mmx() { return true; }
@@ -321,12 +329,22 @@ namespace mozilla {
   inline bool supports_avx2() { return true; }
 #elif defined(MOZILLA_SSE_HAVE_CPUID_DETECTION)
 #define MOZILLA_MAY_SUPPORT_AVX2 1
   inline bool supports_avx2() { return sse_private::avx2_enabled; }
 #else
   inline bool supports_avx2() { return false; }
 #endif
 
+#if defined(MOZILLA_PRESUME_AES)
+#define MOZILLA_MAY_SUPPORT_AES 1
+  inline bool supports_aes() { return true; }
+#elif defined(MOZILLA_SSE_HAVE_CPUID_DETECTION)
+#define MOZILLA_MAY_SUPPORT_AES 1
+  inline bool supports_aes() { return sse_private::aes_enabled; }
+#else
+  inline bool supports_aes() { return false; }
+#endif
+
 
 } // namespace mozilla
 
 #endif /* !defined(mozilla_SSE_h_) */