[PATCH] Add clang target pragma for mixed C/assembly x86-64 implementations

Jussi Kivilinna jussi.kivilinna at iki.fi
Sun Nov 11 14:41:24 CET 2018


* cipher/cipher-gcm-intel-pclmul.c: Add target 'no-sse' attribute
pragma for clang.
* cipher/crc-intel-pclmul.c: Ditto.
* cipher/rijndael-aesni.c: Ditto.
* cipher/rijndael-ssse3-amd64.c: Ditto.
* cipher/sha1-intel-shaext.c: Ditto.
* cipher/sha256-intel-shaext.c: Ditto.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 0 files changed

diff --git a/cipher/cipher-gcm-intel-pclmul.c b/cipher/cipher-gcm-intel-pclmul.c
index 0f26277a5..60ae7aa9a 100644
--- a/cipher/cipher-gcm-intel-pclmul.c
+++ b/cipher/cipher-gcm-intel-pclmul.c
@@ -37,6 +37,9 @@
 /* Prevent compiler from issuing SSE instructions between asm blocks. */
 #  pragma GCC target("no-sse")
 #endif
+#if __clang__
+#  pragma clang attribute push (__attribute__((target("no-sse"))), apply_to = function)
+#endif
 
 
 /*
@@ -474,4 +477,8 @@ _gcry_ghash_intel_pclmul (gcry_cipher_hd_t c, byte *result, const byte *buf,
   return 0;
 }
 
+#if __clang__
+#  pragma clang attribute pop
+#endif
+
 #endif /* GCM_USE_INTEL_PCLMUL */
diff --git a/cipher/crc-intel-pclmul.c b/cipher/crc-intel-pclmul.c
index 8ff08ec10..482b260bf 100644
--- a/cipher/crc-intel-pclmul.c
+++ b/cipher/crc-intel-pclmul.c
@@ -39,6 +39,9 @@
 /* Prevent compiler from issuing SSE instructions between asm blocks. */
 #  pragma GCC target("no-sse")
 #endif
+#if __clang__
+#  pragma clang attribute push (__attribute__((target("no-sse"))), apply_to = function)
+#endif
 
 
 #define ALIGNED_16 __attribute__ ((aligned (16)))
@@ -922,4 +925,8 @@ _gcry_crc24rfc2440_intel_pclmul (u32 *pcrc, const byte *inbuf, size_t inlen)
 #endif
 }
 
+#if __clang__
+#  pragma clang attribute pop
+#endif
+
 #endif /* USE_INTEL_PCLMUL */
diff --git a/cipher/rijndael-aesni.c b/cipher/rijndael-aesni.c
index 081bf124c..c29be50e5 100644
--- a/cipher/rijndael-aesni.c
+++ b/cipher/rijndael-aesni.c
@@ -39,6 +39,9 @@
 /* Prevent compiler from issuing SSE instructions between asm blocks. */
 #  pragma GCC target("no-sse")
 #endif
+#if __clang__
+#  pragma clang attribute push (__attribute__((target("no-sse"))), apply_to = function)
+#endif
 
 
 #define ALWAYS_INLINE inline __attribute__((always_inline))
@@ -3494,4 +3497,8 @@ _gcry_aes_aesni_xts_crypt (RIJNDAEL_context *ctx, unsigned char *tweak,
     _gcry_aes_aesni_xts_dec(ctx, tweak, outbuf, inbuf, nblocks);
 }
 
+#if __clang__
+#  pragma clang attribute pop
+#endif
+
 #endif /* USE_AESNI */
diff --git a/cipher/rijndael-ssse3-amd64.c b/cipher/rijndael-ssse3-amd64.c
index fa481bb4f..0c1ae6e6e 100644
--- a/cipher/rijndael-ssse3-amd64.c
+++ b/cipher/rijndael-ssse3-amd64.c
@@ -55,6 +55,9 @@
 /* Prevent compiler from issuing SSE instructions between asm blocks. */
 #  pragma GCC target("no-sse")
 #endif
+#if __clang__
+#  pragma clang attribute push (__attribute__((target("no-sse"))), apply_to = function)
+#endif
 
 
 /* Copy of ocb_get_l needed here as GCC is unable to inline ocb_get_l
@@ -726,4 +729,8 @@ _gcry_aes_ssse3_ocb_auth (gcry_cipher_hd_t c, const void *abuf_arg,
   return 0;
 }
 
+#if __clang__
+#  pragma clang attribute pop
+#endif
+
 #endif /* USE_SSSE3 */
diff --git a/cipher/sha1-intel-shaext.c b/cipher/sha1-intel-shaext.c
index 5a2349e1e..d7e3d4f8e 100644
--- a/cipher/sha1-intel-shaext.c
+++ b/cipher/sha1-intel-shaext.c
@@ -29,6 +29,9 @@
 /* Prevent compiler from issuing SSE instructions between asm blocks. */
 #  pragma GCC target("no-sse")
 #endif
+#if __clang__
+#  pragma clang attribute push (__attribute__((target("no-sse"))), apply_to = function)
+#endif
 
 /* Two macros to be called prior and after the use of SHA-EXT
    instructions.  There should be no external function calls between
@@ -278,4 +281,8 @@ _gcry_sha1_transform_intel_shaext(void *state, const unsigned char *data,
   return 0;
 }
 
+#if __clang__
+#  pragma clang attribute pop
+#endif
+
 #endif /* HAVE_GCC_INLINE_ASM_SHA_EXT */
diff --git a/cipher/sha256-intel-shaext.c b/cipher/sha256-intel-shaext.c
index 0c107bb4c..2eda42d8d 100644
--- a/cipher/sha256-intel-shaext.c
+++ b/cipher/sha256-intel-shaext.c
@@ -29,6 +29,9 @@
 /* Prevent compiler from issuing SSE instructions between asm blocks. */
 #  pragma GCC target("no-sse")
 #endif
+#if __clang__
+#  pragma clang attribute push (__attribute__((target("no-sse"))), apply_to = function)
+#endif
 
 /* Two macros to be called prior and after the use of SHA-EXT
    instructions.  There should be no external function calls between
@@ -349,4 +352,8 @@ _gcry_sha256_transform_intel_shaext(u32 state[8], const unsigned char *data,
   return 0;
 }
 
+#if __clang__
+#  pragma clang attribute pop
+#endif
+
 #endif /* HAVE_GCC_INLINE_ASM_SHA_EXT */




More information about the Gcrypt-devel mailing list