Skip to content

Commit 7b0fb18

Browse files
committed
Merge bitcoin#366: ARM assembly implementation of field_10x26 inner (rebase of bitcoin#173)
001f176 ARM assembly implementation of field_10x26 inner (Wladimir J. van der Laan)
2 parents 0172be9 + 001f176 commit 7b0fb18

File tree

7 files changed

+968
-11
lines changed

7 files changed

+968
-11
lines changed

Makefile.am

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,25 @@ noinst_HEADERS += contrib/lax_der_parsing.c
5252
noinst_HEADERS += contrib/lax_der_privatekey_parsing.h
5353
noinst_HEADERS += contrib/lax_der_privatekey_parsing.c
5454

55+
if USE_EXTERNAL_ASM
56+
COMMON_LIB = libsecp256k1_common.la
57+
noinst_LTLIBRARIES = $(COMMON_LIB)
58+
else
59+
COMMON_LIB =
60+
endif
61+
5562
pkgconfigdir = $(libdir)/pkgconfig
5663
pkgconfig_DATA = libsecp256k1.pc
5764

65+
if USE_EXTERNAL_ASM
66+
if USE_ASM_ARM
67+
libsecp256k1_common_la_SOURCES = src/asm/field_10x26_arm.s
68+
endif
69+
endif
70+
5871
libsecp256k1_la_SOURCES = src/secp256k1.c
5972
libsecp256k1_la_CPPFLAGS = -DSECP256K1_BUILD -I$(top_srcdir)/include -I$(top_srcdir)/src $(SECP_INCLUDES)
60-
libsecp256k1_la_LIBADD = $(JNI_LIB) $(SECP_LIBS)
73+
libsecp256k1_la_LIBADD = $(JNI_LIB) $(SECP_LIBS) $(COMMON_LIB)
6174

6275
libsecp256k1_jni_la_SOURCES = src/java/org_bitcoin_NativeSecp256k1.c src/java/org_bitcoin_Secp256k1Context.c
6376
libsecp256k1_jni_la_CPPFLAGS = -DSECP256K1_BUILD $(JNI_INCLUDES)
@@ -66,19 +79,19 @@ noinst_PROGRAMS =
6679
if USE_BENCHMARK
6780
noinst_PROGRAMS += bench_verify bench_sign bench_internal
6881
bench_verify_SOURCES = src/bench_verify.c
69-
bench_verify_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS)
82+
bench_verify_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
7083
bench_sign_SOURCES = src/bench_sign.c
71-
bench_sign_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS)
84+
bench_sign_LDADD = libsecp256k1.la $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
7285
bench_internal_SOURCES = src/bench_internal.c
73-
bench_internal_LDADD = $(SECP_LIBS)
86+
bench_internal_LDADD = $(SECP_LIBS) $(COMMON_LIB)
7487
bench_internal_CPPFLAGS = $(SECP_INCLUDES)
7588
endif
7689

7790
if USE_TESTS
7891
noinst_PROGRAMS += tests
7992
tests_SOURCES = src/tests.c
8093
tests_CPPFLAGS = -DSECP256K1_BUILD -DVERIFY -I$(top_srcdir)/src -I$(top_srcdir)/include $(SECP_INCLUDES) $(SECP_TEST_INCLUDES)
81-
tests_LDADD = $(SECP_LIBS) $(SECP_TEST_LIBS)
94+
tests_LDADD = $(SECP_LIBS) $(SECP_TEST_LIBS) $(COMMON_LIB)
8295
tests_LDFLAGS = -static
8396
TESTS = tests
8497
endif

configure.ac

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ AC_PROG_CC_C89
2929
if test x"$ac_cv_prog_cc_c89" = x"no"; then
3030
AC_MSG_ERROR([c89 compiler support required])
3131
fi
32+
AM_PROG_AS
3233

3334
case $host_os in
3435
*darwin*)
@@ -137,8 +138,8 @@ AC_ARG_WITH([bignum], [AS_HELP_STRING([--with-bignum=gmp|no|auto],
137138
AC_ARG_WITH([scalar], [AS_HELP_STRING([--with-scalar=64bit|32bit|auto],
138139
[Specify scalar implementation. Default is auto])],[req_scalar=$withval], [req_scalar=auto])
139140

140-
AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|no|auto]
141-
[Specify assembly optimizations to use. Default is auto])],[req_asm=$withval], [req_asm=auto])
141+
AC_ARG_WITH([asm], [AS_HELP_STRING([--with-asm=x86_64|arm|no|auto]
142+
[Specify assembly optimizations to use. Default is auto (experimental: arm)])],[req_asm=$withval], [req_asm=auto])
142143

143144
AC_CHECK_TYPES([__int128])
144145

@@ -165,6 +166,8 @@ else
165166
AC_MSG_ERROR([x86_64 assembly optimization requested but not available])
166167
fi
167168
;;
169+
arm)
170+
;;
168171
no)
169172
;;
170173
*)
@@ -257,10 +260,15 @@ else
257260
fi
258261

259262
# select assembly optimization
263+
use_external_asm=no
264+
260265
case $set_asm in
261266
x86_64)
262267
AC_DEFINE(USE_ASM_X86_64, 1, [Define this symbol to enable x86_64 assembly optimizations])
263268
;;
269+
arm)
270+
use_external_asm=yes
271+
;;
264272
no)
265273
;;
266274
*)
@@ -371,6 +379,10 @@ fi
371379

372380
AC_C_BIGENDIAN()
373381

382+
if test x"$use_external_asm" = x"yes"; then
383+
AC_DEFINE(USE_EXTERNAL_ASM, 1, [Define this symbol if an external (non-inline) assembly implementation is used])
384+
fi
385+
374386
AC_MSG_NOTICE([Using assembly optimizations: $set_asm])
375387
AC_MSG_NOTICE([Using field implementation: $set_field])
376388
AC_MSG_NOTICE([Using bignum implementation: $set_bignum])
@@ -395,6 +407,9 @@ else
395407
if test x"$enable_module_ecdh" = x"yes"; then
396408
AC_MSG_ERROR([ECDH module is experimental. Use --enable-experimental to allow.])
397409
fi
410+
if test x"$set_asm" = x"arm"; then
411+
AC_MSG_ERROR([ARM assembly optimization is experimental. Use --enable-experimental to allow.])
412+
fi
398413
fi
399414

400415
AC_CONFIG_HEADERS([src/libsecp256k1-config.h])
@@ -411,6 +426,8 @@ AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
411426
AM_CONDITIONAL([ENABLE_MODULE_SCHNORR], [test x"$enable_module_schnorr" = x"yes"])
412427
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
413428
AM_CONDITIONAL([USE_JNI], [test x"$use_jni" == x"yes"])
429+
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])
430+
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
414431

415432
dnl make sure nothing new is exported so that we don't break the cache
416433
PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH"

0 commit comments

Comments
 (0)