diff options
author | Jeffrey Walton <noloader@gmail.com> | 2018-11-15 02:11:00 -0500 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2018-11-15 02:11:00 -0500 |
commit | 10f85d65967bbe15ad807ee214fdf4babec1a991 (patch) | |
tree | a59dd02fa458c41ecc49151c4eb2bf368a0b8899 /chacha.cpp | |
parent | 3c7bdf1a2681f227a2a91e9bdde37e3bd4313bf3 (diff) | |
download | cryptopp-git-10f85d65967bbe15ad807ee214fdf4babec1a991.tar.gz |
Make Altivec vector wraps friendly to downgrades
The way the existing ppc_simd.h is written makes it hard to to switch between the old Altivec loads and stores and the new POWER7 loads and stores. This checkin rewrites the wrappers to use _ALTIVEC_, _ARCH_PWR7 and _ARCH_PWR8. The wrappers in this file now honor -maltivec, -mcpu-power7 and -mcpu=power8. It allows users to compile a source file, like chacha_simd.cpp, with a lower ISA and things just work for them.
Diffstat (limited to 'chacha.cpp')
-rw-r--r-- | chacha.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
@@ -24,7 +24,7 @@ extern void ChaCha_OperateKeystream_SSE2(const word32 *state, const byte* input, extern void ChaCha_OperateKeystream_AVX2(const word32 *state, const byte* input, byte *output, unsigned int rounds);
#endif
-#if (CRYPTOPP_POWER7_AVAILABLE)
+#if (CRYPTOPP_ALTIVEC_AVAILABLE)
extern void ChaCha_OperateKeystream_POWER7(const word32 *state, const byte* input, byte *output, unsigned int rounds);
#endif
@@ -86,6 +86,11 @@ std::string ChaCha_Policy::AlgorithmProvider() const return "Power7";
else
#endif
+#if (CRYPTOPP_ALTIVEC_AVAILABLE)
+ if (HasAltivec())
+ return "Altivec";
+ else
+#endif
return "C++";
}
@@ -139,8 +144,8 @@ unsigned int ChaCha_Policy::GetAlignment() const return 16;
else
#endif
-#if (CRYPTOPP_POWER7_AVAILABLE)
- if (HasPower7())
+#if (CRYPTOPP_ALTIVEC_AVAILABLE)
+ if (HasAltivec())
return 16;
else
#endif
@@ -164,8 +169,8 @@ unsigned int ChaCha_Policy::GetOptimalBlockSize() const return 4*BYTES_PER_ITERATION;
else
#endif
-#if (CRYPTOPP_POWER7_AVAILABLE)
- if (HasPower7())
+#if (CRYPTOPP_ALTIVEC_AVAILABLE)
+ if (HasAltivec())
return 4*BYTES_PER_ITERATION;
else
#endif
@@ -245,8 +250,8 @@ void ChaCha_Policy::OperateKeystream(KeystreamOperation operation, }
#endif
-#if (CRYPTOPP_POWER7_AVAILABLE)
- if (HasPower7())
+#if (CRYPTOPP_ALTIVEC_AVAILABLE)
+ if (HasAltivec())
{
while (iterationCount >= 4 && MultiBlockSafe(4))
{
|