Skip to content

Commit

Permalink
Merge 13789 via bugfix_asm_pragmas
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-jr committed Jun 21, 2024
2 parents 5bb4fd2 + ea93c03 commit 2dc1722
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
18 changes: 18 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,12 @@ AC_MSG_CHECKING([for SSE4.1 intrinsics])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>
#include <immintrin.h>
#if defined(__clang__)
#pragma clang attribute push(__attribute__((__target__("sse4.1"))), apply_to = function)
#elif defined(__GNUC__)
#pragma GCC target ("sse4.1")
#endif
]],[[
__m128i l = _mm_set1_epi32(0);
return _mm_extract_epi32(l, 3);
Expand All @@ -521,6 +527,12 @@ AC_MSG_CHECKING([for AVX2 intrinsics])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>
#include <immintrin.h>
#if defined(__clang__)
#pragma clang attribute push(__attribute__((__target__("avx,avx2"))), apply_to = function)
#elif defined(__GNUC__)
#pragma GCC target ("avx,avx2")
#endif
]],[[
__m256i l = _mm256_set1_epi32(0);
return _mm256_extract_epi32(l, 7);
Expand All @@ -536,6 +548,12 @@ AC_MSG_CHECKING([for x86 SHA-NI intrinsics])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdint.h>
#include <immintrin.h>
#if defined(__clang__)
#pragma clang attribute push(__attribute__((__target__("sse4,sha"))), apply_to = function)
#elif defined(__GNUC__)
#pragma GCC target ("sse4,sha")
#endif
]],[[
__m128i i = _mm_set1_epi32(0);
__m128i j = _mm_set1_epi32(1);
Expand Down
10 changes: 10 additions & 0 deletions src/crypto/sha256_avx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
#include <attributes.h>
#include <crypto/common.h>

#if defined(__clang__)
#pragma clang attribute push(__attribute__((__target__("avx,avx2"))), apply_to = function)
#elif defined(__GNUC__)
#pragma GCC target ("avx,avx2")
#endif

namespace sha256d64_avx2 {
namespace {

Expand Down Expand Up @@ -326,4 +332,8 @@ void Transform_8way(unsigned char* out, const unsigned char* in)

}

#if defined(__clang__)
#pragma clang attribute pop
#endif

#endif
10 changes: 10 additions & 0 deletions src/crypto/sha256_sse41.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
#include <attributes.h>
#include <crypto/common.h>

#if defined(__clang__)
#pragma clang attribute push(__attribute__((__target__("sse4.1"))), apply_to = function)
#elif defined(__GNUC__)
#pragma GCC target ("sse4.1")
#endif

namespace sha256d64_sse41 {
namespace {

Expand Down Expand Up @@ -318,4 +324,8 @@ void Transform_4way(unsigned char* out, const unsigned char* in)

}

#if defined(__clang__)
#pragma clang attribute pop
#endif

#endif
10 changes: 10 additions & 0 deletions src/crypto/sha256_x86_shani.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@

#include <attributes.h>

#if defined(__clang__)
#pragma clang attribute push(__attribute__((__target__("sse4,sha"))), apply_to = function)
#elif defined(__GNUC__)
#pragma GCC target ("sse4,sha")
#endif

namespace {

alignas(__m128i) const uint8_t MASK[16] = {0x03, 0x02, 0x01, 0x00, 0x07, 0x06, 0x05, 0x04, 0x0b, 0x0a, 0x09, 0x08, 0x0f, 0x0e, 0x0d, 0x0c};
Expand Down Expand Up @@ -355,4 +361,8 @@ void Transform_2way(unsigned char* out, const unsigned char* in)

}

#if defined(__clang__)
#pragma clang attribute pop
#endif

#endif

0 comments on commit 2dc1722

Please sign in to comment.