diff options
author | Jack Lloyd <[email protected]> | 2015-09-21 17:23:45 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2015-09-21 17:23:45 -0400 |
commit | b999079ebdfd1c9bd288763ae06dfdf6a31325e0 (patch) | |
tree | b68ccafd36b7d9c9b07042e31ddd44908876584f | |
parent | 4a82605e745cf9a288806b31929ec0fe7c0c1bdc (diff) |
Move check for SIMD instructions to CPUID
Avoids needing to include simd_32 to see if SIMD is disabled. This
had caused a build break on Linux x86-32 as SSE2 must be enabled on
a per-file basis.
-rw-r--r-- | src/lib/block/block_cipher.cpp | 10 | ||||
-rw-r--r-- | src/lib/utils/cpuid.cpp | 13 | ||||
-rw-r--r-- | src/lib/utils/cpuid.h | 2 | ||||
-rw-r--r-- | src/lib/utils/simd/simd_altivec/simd_altivec.h | 2 | ||||
-rw-r--r-- | src/lib/utils/simd/simd_scalar/simd_scalar.h | 2 | ||||
-rw-r--r-- | src/lib/utils/simd/simd_sse2/simd_sse2.h | 2 |
6 files changed, 18 insertions, 13 deletions
diff --git a/src/lib/block/block_cipher.cpp b/src/lib/block/block_cipher.cpp index 5b9c4f0ba..7b52f8716 100644 --- a/src/lib/block/block_cipher.cpp +++ b/src/lib/block/block_cipher.cpp @@ -9,10 +9,6 @@ #include <botan/cpuid.h> #include <botan/internal/algo_registry.h> -#if defined(BOTAN_HAS_SIMD_32) - #include <botan/internal/simd_32.h> -#endif - #if defined(BOTAN_HAS_AES) #include <botan/aes.h> #endif @@ -249,7 +245,7 @@ BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Noekeon); #endif #if defined(BOTAN_HAS_NOEKEON_SIMD) -BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Noekeon_SIMD, "Noekeon", +BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_simd_32(), Noekeon_SIMD, "Noekeon", "simd32", BOTAN_SIMD_ALGORITHM_PRIO); #endif @@ -278,7 +274,7 @@ BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(Serpent); #endif #if defined(BOTAN_HAS_SERPENT_SIMD) -BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), Serpent_SIMD, "Serpent", +BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_simd_32(), Serpent_SIMD, "Serpent", "simd32", BOTAN_SIMD_ALGORITHM_PRIO); #endif @@ -304,7 +300,7 @@ BOTAN_REGISTER_BLOCK_CIPHER_NOARGS(XTEA); #endif #if defined(BOTAN_HAS_XTEA_SIMD) -BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(SIMD_32::enabled(), XTEA_SIMD, "XTEA", +BOTAN_REGISTER_BLOCK_CIPHER_NOARGS_IF(CPUID::has_simd_32(), XTEA_SIMD, "XTEA", "simd32", BOTAN_SIMD_ALGORITHM_PRIO); #endif diff --git a/src/lib/utils/cpuid.cpp b/src/lib/utils/cpuid.cpp index 218b6553c..c98829789 100644 --- a/src/lib/utils/cpuid.cpp +++ b/src/lib/utils/cpuid.cpp @@ -157,6 +157,19 @@ bool altivec_check_pvr_emul() } +bool CPUID::has_simd_32() + { +#if defined(BOTAN_HAS_SIMD_SSE2) + return CPUID::has_sse2(); +#elif defined(BOTAN_HAS_SIMD_ALTIVEC) + return CPUID::has_altivec(); +#elif defined(BOTAN_HAS_SIMD_SCALAR) + return true; +#else + return false; +#endif + } + void CPUID::print(std::ostream& o) { o << "CPUID flags: "; diff --git a/src/lib/utils/cpuid.h b/src/lib/utils/cpuid.h index 5d8093753..36c301c2f 100644 --- a/src/lib/utils/cpuid.h +++ b/src/lib/utils/cpuid.h @@ -118,6 +118,8 @@ class BOTAN_DLL CPUID static bool has_rdseed() { return x86_processor_flags_has(CPUID_RDSEED_BIT); } + static bool has_simd_32(); + static void print(std::ostream& o); private: enum CPUID_bits { diff --git a/src/lib/utils/simd/simd_altivec/simd_altivec.h b/src/lib/utils/simd/simd_altivec/simd_altivec.h index 32533aafb..0a77d60fa 100644 --- a/src/lib/utils/simd/simd_altivec/simd_altivec.h +++ b/src/lib/utils/simd/simd_altivec/simd_altivec.h @@ -22,8 +22,6 @@ namespace Botan { class SIMD_Altivec { public: - static bool enabled() { return CPUID::has_altivec(); } - SIMD_Altivec(const u32bit B[4]) { m_reg = (__vector unsigned int){B[0], B[1], B[2], B[3]}; diff --git a/src/lib/utils/simd/simd_scalar/simd_scalar.h b/src/lib/utils/simd/simd_scalar/simd_scalar.h index 379e2d6a8..28d72c615 100644 --- a/src/lib/utils/simd/simd_scalar/simd_scalar.h +++ b/src/lib/utils/simd/simd_scalar/simd_scalar.h @@ -21,8 +21,6 @@ template<typename T, size_t N> class SIMD_Scalar { public: - static bool enabled() { return true; } - static size_t size() { return N; } SIMD_Scalar() { /* uninitialized */ } diff --git a/src/lib/utils/simd/simd_sse2/simd_sse2.h b/src/lib/utils/simd/simd_sse2/simd_sse2.h index 61989eb8e..9e85bd45b 100644 --- a/src/lib/utils/simd/simd_sse2/simd_sse2.h +++ b/src/lib/utils/simd/simd_sse2/simd_sse2.h @@ -18,8 +18,6 @@ namespace Botan { class SIMD_SSE2 { public: - static bool enabled() { return CPUID::has_sse2(); } - SIMD_SSE2(const u32bit B[4]) { reg = _mm_loadu_si128(reinterpret_cast<const __m128i*>(B)); |