From e14dcae6ba0016c845af43e3e5aaa06583adad25 Mon Sep 17 00:00:00 2001 From: Oliver Collyer Date: Mon, 10 Apr 2023 16:52:58 +0100 Subject: [PATCH] This removes some warnings when building with clang --- src/lib/block/aes/aes_armv8/aes_armv8.cpp | 24 +++++++++++++++++++ .../shacal2/shacal2_armv8/shacal2_arvm8.cpp | 4 ++++ src/lib/hash/sha1/sha1_armv8/sha1_armv8.cpp | 4 ++++ .../sha2_32/sha2_32_armv8/sha2_32_armv8.cpp | 4 ++++ src/lib/utils/simd/simd_32.h | 15 +++++++++--- 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/lib/block/aes/aes_armv8/aes_armv8.cpp b/src/lib/block/aes/aes_armv8/aes_armv8.cpp index 456c4bdfe34..d0173d8db04 100644 --- a/src/lib/block/aes/aes_armv8/aes_armv8.cpp +++ b/src/lib/block/aes/aes_armv8/aes_armv8.cpp @@ -54,7 +54,11 @@ namespace Botan { /* * AES-128 Encryption */ +#if defined(BOTAN_BUILD_COMPILER_IS_CLANG) +BOTAN_FUNC_ISA("crypto") +#else BOTAN_FUNC_ISA("+crypto") +#endif void AES_128::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { const uint8_t *skey = reinterpret_cast(m_EK.data()); @@ -119,7 +123,11 @@ void AES_128::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) /* * AES-128 Decryption */ +#if defined(BOTAN_BUILD_COMPILER_IS_CLANG) +BOTAN_FUNC_ISA("crypto") +#else BOTAN_FUNC_ISA("+crypto") +#endif void AES_128::hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { const uint8_t *skey = reinterpret_cast(m_DK.data()); @@ -184,7 +192,11 @@ void AES_128::hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) /* * AES-192 Encryption */ +#if defined(BOTAN_BUILD_COMPILER_IS_CLANG) +BOTAN_FUNC_ISA("crypto") +#else BOTAN_FUNC_ISA("+crypto") +#endif void AES_192::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { const uint8_t *skey = reinterpret_cast(m_EK.data()); @@ -255,7 +267,11 @@ void AES_192::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) /* * AES-192 Decryption */ +#if defined(BOTAN_BUILD_COMPILER_IS_CLANG) +BOTAN_FUNC_ISA("crypto") +#else BOTAN_FUNC_ISA("+crypto") +#endif void AES_192::hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { const uint8_t *skey = reinterpret_cast(m_DK.data()); @@ -326,7 +342,11 @@ void AES_192::hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) /* * AES-256 Encryption */ +#if defined(BOTAN_BUILD_COMPILER_IS_CLANG) +BOTAN_FUNC_ISA("crypto") +#else BOTAN_FUNC_ISA("+crypto") +#endif void AES_256::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { const uint8_t *skey = reinterpret_cast(m_EK.data()); @@ -403,7 +423,11 @@ void AES_256::hw_aes_encrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) /* * AES-256 Decryption */ +#if defined(BOTAN_BUILD_COMPILER_IS_CLANG) +BOTAN_FUNC_ISA("crypto") +#else BOTAN_FUNC_ISA("+crypto") +#endif void AES_256::hw_aes_decrypt_n(const uint8_t in[], uint8_t out[], size_t blocks) const { const uint8_t *skey = reinterpret_cast(m_DK.data()); diff --git a/src/lib/block/shacal2/shacal2_armv8/shacal2_arvm8.cpp b/src/lib/block/shacal2/shacal2_armv8/shacal2_arvm8.cpp index be9b62cc6a4..dfe31eca3a2 100644 --- a/src/lib/block/shacal2/shacal2_armv8/shacal2_arvm8.cpp +++ b/src/lib/block/shacal2/shacal2_armv8/shacal2_arvm8.cpp @@ -13,7 +13,11 @@ namespace Botan { Only encryption is supported since the inverse round function would require a different instruction */ +#if defined(BOTAN_BUILD_COMPILER_IS_CLANG) +BOTAN_FUNC_ISA("crypto") +#else BOTAN_FUNC_ISA("+crypto") +#endif void SHACAL2::armv8_encrypt_blocks(const uint8_t in[], uint8_t out[], size_t blocks) const { const uint32_t* input32 = reinterpret_cast(in); diff --git a/src/lib/hash/sha1/sha1_armv8/sha1_armv8.cpp b/src/lib/hash/sha1/sha1_armv8/sha1_armv8.cpp index bb52c801a8c..e653128553d 100644 --- a/src/lib/hash/sha1/sha1_armv8/sha1_armv8.cpp +++ b/src/lib/hash/sha1/sha1_armv8/sha1_armv8.cpp @@ -16,7 +16,11 @@ namespace Botan { * SHA-1 using CPU instructions in ARMv8 */ //static +#if defined(BOTAN_BUILD_COMPILER_IS_CLANG) +BOTAN_FUNC_ISA("crypto") +#else BOTAN_FUNC_ISA("+crypto") +#endif void SHA_1::sha1_armv8_compress_n(secure_vector& digest, const uint8_t input8[], size_t blocks) { uint32x4_t ABCD; diff --git a/src/lib/hash/sha2_32/sha2_32_armv8/sha2_32_armv8.cpp b/src/lib/hash/sha2_32/sha2_32_armv8/sha2_32_armv8.cpp index 04727b857b7..61d713ae2cb 100644 --- a/src/lib/hash/sha2_32/sha2_32_armv8/sha2_32_armv8.cpp +++ b/src/lib/hash/sha2_32/sha2_32_armv8/sha2_32_armv8.cpp @@ -18,7 +18,11 @@ namespace Botan { * SHA-256 using CPU instructions in ARMv8 */ //static +#if defined(BOTAN_BUILD_COMPILER_IS_CLANG) +BOTAN_FUNC_ISA("crypto") +#else BOTAN_FUNC_ISA("+crypto") +#endif void SHA_256::compress_digest_armv8(secure_vector& digest, const uint8_t input8[], size_t blocks) { alignas(64) static const uint32_t K[] = { diff --git a/src/lib/utils/simd/simd_32.h b/src/lib/utils/simd/simd_32.h index 9194caccde6..2a512d649cc 100644 --- a/src/lib/utils/simd/simd_32.h +++ b/src/lib/utils/simd/simd_32.h @@ -37,10 +37,19 @@ #define BOTAN_CLMUL_ISA "pclmul" #elif defined(BOTAN_SIMD_USE_NEON) #if defined(BOTAN_TARGET_ARCH_IS_ARM64) - #define BOTAN_SIMD_ISA "+simd" - #define BOTAN_CLMUL_ISA "+crypto" + #if defined(BOTAN_BUILD_COMPILER_IS_CLANG) + #define BOTAN_SIMD_ISA "neon" + #define BOTAN_CLMUL_ISA "crypto" + #else + #define BOTAN_SIMD_ISA "+simd" + #define BOTAN_CLMUL_ISA "+crypto" + #endif #else - #define BOTAN_SIMD_ISA "fpu=neon" + #if defined(BOTAN_BUILD_COMPILER_IS_CLANG) + #define BOTAN_SIMD_ISA "neon" + #else + #define BOTAN_SIMD_ISA "fpu=neon" + #endif #endif #define BOTAN_VPERM_ISA BOTAN_SIMD_ISA #elif defined(BOTAN_SIMD_USE_ALTIVEC)