diff options
author | lloyd <[email protected]> | 2009-10-29 04:40:49 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-10-29 04:40:49 +0000 |
commit | 511f670f32f920ace6352c4216a4a124dc9b01ac (patch) | |
tree | 8648bb13472dfb4367c813423ce15e2e55b1a728 | |
parent | 053ee3cc52a44a450001eb9b1f907ce91fad39f9 (diff) |
Add new function enabled() to each of the SIMD_32 instantiations which
returns true if they might plausibly work. AltiVec and SSE2 versions call
into CPUID, scalar version always works.
-rw-r--r-- | src/utils/simd_32/simd_altivec.h | 3 | ||||
-rw-r--r-- | src/utils/simd_32/simd_scalar.h | 2 | ||||
-rw-r--r-- | src/utils/simd_32/simd_sse.h | 5 |
3 files changed, 9 insertions, 1 deletions
diff --git a/src/utils/simd_32/simd_altivec.h b/src/utils/simd_32/simd_altivec.h index e63b9bdcc..c3d1a76dc 100644 --- a/src/utils/simd_32/simd_altivec.h +++ b/src/utils/simd_32/simd_altivec.h @@ -9,6 +9,8 @@ #define BOTAN_SIMD_ALTIVEC_H__ #include <botan/loadstor.h> +#include <botan/cpuid.h> + #include <altivec.h> #undef vector @@ -17,6 +19,7 @@ namespace Botan { class SIMD_Altivec { public: + bool enabled() const { return CPUID::has_altivec(); } SIMD_Altivec(const u32bit B[4]) { diff --git a/src/utils/simd_32/simd_scalar.h b/src/utils/simd_32/simd_scalar.h index 38f69c294..606923289 100644 --- a/src/utils/simd_32/simd_scalar.h +++ b/src/utils/simd_32/simd_scalar.h @@ -15,6 +15,8 @@ namespace Botan { class SIMD_Scalar { public: + bool enabled() const { return true; } + SIMD_Scalar(const u32bit B[4]) { R0 = B[0]; diff --git a/src/utils/simd_32/simd_sse.h b/src/utils/simd_32/simd_sse.h index 267852554..fcfe6f203 100644 --- a/src/utils/simd_32/simd_sse.h +++ b/src/utils/simd_32/simd_sse.h @@ -8,7 +8,8 @@ #ifndef BOTAN_SIMD_SSE_H__ #define BOTAN_SIMD_SSE_H__ -#include <botan/types.h> +#include <botan/cpuid.h> + #include <emmintrin.h> namespace Botan { @@ -16,6 +17,8 @@ namespace Botan { class SIMD_SSE2 { public: + bool enabled() const { return CPUID::has_sse2(); } + SIMD_SSE2(const u32bit B[4]) { reg = _mm_loadu_si128((const __m128i*)B); |