summaryrefslogtreecommitdiff
path: root/arm_simd.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2021-05-25 20:24:58 -0400
committerJeffrey Walton <noloader@gmail.com>2021-05-25 20:24:58 -0400
commit1221e0dc9eaaa1bf65c739ac12e52527bd356986 (patch)
tree9c6ae20d194d029713aaa86cd6f03666813a846e /arm_simd.h
parentc3d1eedff06ac236331cf1af0d06731c0b050381 (diff)
downloadcryptopp-git-1221e0dc9eaaa1bf65c739ac12e52527bd356986.tar.gz
Use inline ASM for CRC on Apple ARMv8
Diffstat (limited to 'arm_simd.h')
-rw-r--r--arm_simd.h78
1 files changed, 74 insertions, 4 deletions
diff --git a/arm_simd.h b/arm_simd.h
index 3e77ae77..00b4f9e2 100644
--- a/arm_simd.h
+++ b/arm_simd.h
@@ -13,10 +13,80 @@
# include <arm_neon.h>
#endif
-//#if (CRYPTOPP_ARM_ACLE_HEADER)
-//# include <stdint.h>
-//# include <arm_acle.h>
-//#endif
+#if (CRYPTOPP_ARM_ACLE_HEADER)
+# include <stdint.h>
+# include <arm_acle.h>
+#endif
+
+#if (CRYPTOPP_ARM_CRC32_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)
+/// \brief CRC32
+/// \param a the first value
+/// \param b the second value
+/// \return CRC32 value
+/// \since Crypto++ 8.6
+inline uint32_t CRC32B (uint32_t crc, uint8_t val)
+{
+#if defined(_MSC_VER)
+ return __crc32b(crc, val);
+#else
+ uint32_t r;
+ __asm__ ("crc32b %w0, %w1, %w2 \n\t"
+ :"=r" (r) : "r" (crc), "r" (val) );
+ return r;
+#endif
+}
+
+/// \brief CRC32
+/// \param a the first value
+/// \param b the second value
+/// \return CRC32 value
+/// \since Crypto++ 8.6
+inline uint32_t CRC32W (uint32_t crc, uint32_t val)
+{
+#if defined(_MSC_VER)
+ return __crc32w(crc, val);
+#else
+ uint32_t r;
+ __asm__ ("crc32w %w0, %w1, %w2 \n\t"
+ :"=r" (r) : "r" (crc), "r" (val) );
+ return r;
+#endif
+}
+
+/// \brief CRC32-C
+/// \param a the first value
+/// \param b the second value
+/// \return CRC32 value
+/// \since Crypto++ 8.6
+inline uint32_t CRC32CB (uint32_t crc, uint8_t val)
+{
+#if defined(_MSC_VER)
+ return __crc32cb(crc, val);
+#else
+ uint32_t r;
+ __asm__ ("crc32cb %w0, %w1, %w2 \n\t"
+ :"=r" (r) : "r" (crc), "r" (val) );
+ return r;
+#endif
+}
+
+/// \brief CRC32-C
+/// \param a the first value
+/// \param b the second value
+/// \return CRC32 value
+/// \since Crypto++ 8.6
+inline uint32_t CRC32CW (uint32_t crc, uint32_t val)
+{
+#if defined(_MSC_VER)
+ return __crc32cw(crc, val);
+#else
+ uint32_t r;
+ __asm__ ("crc32cw %w0, %w1, %w2 \n\t"
+ :"=r" (r) : "r" (crc), "r" (val) );
+ return r;
+#endif
+}
+#endif // CRYPTOPP_ARM_CRC32_AVAILABLE
#if (CRYPTOPP_ARM_PMULL_AVAILABLE) || defined(CRYPTOPP_DOXYGEN_PROCESSING)