Unfortunately, some assemblers still don't know about AVX opcodes

This commit is contained in:
Frank Denis 2015-11-04 23:29:27 +01:00
parent 3f3969ffae
commit 18906a078c
7 changed files with 38 additions and 11 deletions

View File

@ -399,7 +399,7 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
HAVE_AMD64_ASM_V=0 HAVE_AMD64_ASM_V=0
AS_IF([test "$enable_asm" != "no"],[ AS_IF([test "$enable_asm" != "no"],[
AC_MSG_CHECKING(whether we should use x86_64 asm code) AC_MSG_CHECKING(whether we can use x86_64 asm code)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
]], [[ ]], [[
#if defined(__amd64) || defined(__amd64__) || defined(__x86_64__) #if defined(__amd64) || defined(__amd64__) || defined(__x86_64__)
@ -413,13 +413,36 @@ AS_IF([test "$enable_asm" != "no"],[
__asm__("pxor %xmm12,%xmm6"); __asm__("pxor %xmm12,%xmm6");
]])], ]])],
[AC_MSG_RESULT(yes) [AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_AMD64_ASM], [1], [x86_64 asm code should be used]) AC_DEFINE([HAVE_AMD64_ASM], [1], [x86_64 asm code can be used])
HAVE_AMD64_ASM_V=1], HAVE_AMD64_ASM_V=1],
[AC_MSG_RESULT(no)]) [AC_MSG_RESULT(no)])
]) ])
AM_CONDITIONAL([HAVE_AMD64_ASM], [test $HAVE_AMD64_ASM_V = 1]) AM_CONDITIONAL([HAVE_AMD64_ASM], [test $HAVE_AMD64_ASM_V = 1])
AC_SUBST(HAVE_AMD64_ASM_V) AC_SUBST(HAVE_AMD64_ASM_V)
HAVE_AVX_ASM_V=0
AS_IF([test "$enable_asm" != "no"],[
AC_MSG_CHECKING(whether we can assemble AVX opcodes)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
]], [[
#if defined(__amd64) || defined(__amd64__) || defined(__x86_64__)
# if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__MINGW64__) || defined(_WIN32) || defined(_WIN64)
# error Windows x86_64 calling conventions are not supported yet
# endif
/* neat */
#else
# error !x86_64
#endif
__asm__("vpunpcklqdq %xmm0,%xmm13,%xmm0");
]])],
[AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_AVX_ASM], [1], [AVX opcodes are supported])
HAVE_AVX_ASM_V=1],
[AC_MSG_RESULT(no)])
])
AM_CONDITIONAL([HAVE_AVX_ASM], [test $HAVE_AVX_ASM_V = 1])
AC_SUBST(HAVE_AVX_ASM_V)
AC_MSG_CHECKING(for 128-bit arithmetic) AC_MSG_CHECKING(for 128-bit arithmetic)
HAVE_TI_MODE_V=0 HAVE_TI_MODE_V=0
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[

View File

@ -204,10 +204,8 @@ EXTRA_DIST = \
crypto_scalarmult/curve25519/sandy2x/ladder.S \ crypto_scalarmult/curve25519/sandy2x/ladder.S \
crypto_scalarmult/curve25519/sandy2x/ladder_base.S crypto_scalarmult/curve25519/sandy2x/ladder_base.S
if HAVE_AMD64_ASM if HAVE_AVX_ASM
libsodium_la_SOURCES += \ libsodium_la_SOURCES += \
crypto_stream/salsa20/amd64_xmm6/api.h \
crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S \
crypto_scalarmult/curve25519/sandy2x/consts_namespace.h \ crypto_scalarmult/curve25519/sandy2x/consts_namespace.h \
crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.c \ crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.c \
crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.h \ crypto_scalarmult/curve25519/sandy2x/curve25519_sandy2x.h \
@ -221,6 +219,12 @@ libsodium_la_SOURCES += \
crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h \ crypto_scalarmult/curve25519/sandy2x/ladder_base_namespace.h \
crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h \ crypto_scalarmult/curve25519/sandy2x/ladder_namespace.h \
crypto_scalarmult/curve25519/sandy2x/sandy2x.S crypto_scalarmult/curve25519/sandy2x/sandy2x.S
endif
if HAVE_AMD64_ASM
libsodium_la_SOURCES += \
crypto_stream/salsa20/amd64_xmm6/api.h \
crypto_stream/salsa20/amd64_xmm6/stream_salsa20_amd64_xmm6.S
else else
libsodium_la_SOURCES += \ libsodium_la_SOURCES += \
crypto_stream/salsa20/ref/api.h \ crypto_stream/salsa20/ref/api.h \

View File

@ -7,7 +7,7 @@
#include <stddef.h> #include <stddef.h>
#ifdef HAVE_AMD64_ASM #ifdef HAVE_AVX_ASM
#include "utils.h" #include "utils.h"
#include "curve25519_sandy2x.h" #include "curve25519_sandy2x.h"

View File

@ -5,7 +5,7 @@
#include "fe51.h" #include "fe51.h"
#ifdef HAVE_AMD64_ASM #ifdef HAVE_AVX_ASM
#define fe51_square(x, y) fe51_nsquare(x, y, 1) #define fe51_square(x, y) fe51_nsquare(x, y, 1)

View File

@ -5,7 +5,7 @@
#include "fe.h" #include "fe.h"
#include "crypto_uint64.h" #include "crypto_uint64.h"
#ifdef HAVE_AMD64_ASM #ifdef HAVE_AVX_ASM
static crypto_uint64 load_3(const unsigned char *in) static crypto_uint64 load_3(const unsigned char *in)
{ {

View File

@ -1,5 +1,5 @@
#ifdef HAVE_AMD64_ASM #ifdef HAVE_AVX_ASM
#define IN_SANDY2X #define IN_SANDY2X

View File

@ -3,7 +3,7 @@
#include "scalarmult_curve25519.h" #include "scalarmult_curve25519.h"
#include "runtime.h" #include "runtime.h"
#ifdef HAVE_AMD64_ASM #ifdef HAVE_AVX_ASM
# include "sandy2x/curve25519_sandy2x.h" # include "sandy2x/curve25519_sandy2x.h"
#endif #endif
#ifdef HAVE_TI_MODE #ifdef HAVE_TI_MODE
@ -49,7 +49,7 @@ _crypto_scalarmult_curve25519_pick_best_implementation(void)
#else #else
implementation = &crypto_scalarmult_curve25519_ref10_implementation; implementation = &crypto_scalarmult_curve25519_ref10_implementation;
#endif #endif
#ifdef HAVE_AMD64_ASM #ifdef HAVE_AVX_ASM
if (sodium_runtime_has_avx()) { if (sodium_runtime_has_avx()) {
implementation = &crypto_scalarmult_curve25519_sandy2x_implementation; implementation = &crypto_scalarmult_curve25519_sandy2x_implementation;
} }