Bug 1359333 - detect aes-ni support, r?froydnj
MozReview-Commit-ID: 4cCVIntG9bD
--- 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,17 @@
#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
+// There's no preprocessor symbol for __AES__
#ifdef HAVE_CPUID_H
#define MOZILLA_SSE_HAVE_CPUID_DETECTION
#endif
#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))
@@ -212,16 +214,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 +326,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_) */