[PATCH 7/8] Add W64 support for mpi amd64 assembly
Jussi Kivilinna
jussi.kivilinna at iki.fi
Fri May 1 19:40:04 CEST 2015
acinclude.m4 (GNUPG_SYS_SYMBOL_UNDERSCORE): Set
'ac_cv_sys_symbol_underscore=no' on MingW-W64.
mpi/amd64/func_abi.h: New.
mpi/amd64/mpih-add1.S (_gcry_mpih_add_n): Add FUNC_ENTRY and FUNC_EXIT.
mpi/amd64/mpih-lshift.S (_gcry_mpih_lshift): Ditto.
mpi/amd64/mpih-mul1.S (_gcry_mpih_mul_1): Ditto.
mpi/amd64/mpih-mul2.S (_gcry_mpih_addmul_1): Ditto.
mpi/amd64/mpih-mul3.S (_gcry_mpih_submul_1): Ditto.
mpi/amd64/mpih-rshift.S (_gcry_mpih_rshift): Ditto.
mpi/amd64/mpih-sub1.S (_gcry_mpih_sub_n): Ditto.
mpi/config.links [host=x86_64-*mingw*]: Enable assembly modules.
[host=x86_64-*-*]: Append mpi/amd64/func_abi.h to mpi/asm-syntax.h.
--
Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
acinclude.m4 | 5 ++++-
mpi/amd64/func_abi.h | 19 +++++++++++++++++++
mpi/amd64/mpih-add1.S | 2 ++
mpi/amd64/mpih-lshift.S | 2 ++
mpi/amd64/mpih-mul1.S | 2 ++
mpi/amd64/mpih-mul2.S | 2 ++
mpi/amd64/mpih-mul3.S | 3 ++-
mpi/amd64/mpih-rshift.S | 2 ++
mpi/amd64/mpih-sub1.S | 2 ++
mpi/config.links | 13 +++++++++----
10 files changed, 46 insertions(+), 6 deletions(-)
create mode 100644 mpi/amd64/func_abi.h
diff --git a/acinclude.m4 b/acinclude.m4
index 0791b84..764efd4 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -101,9 +101,12 @@ AC_DEFUN([GNUPG_CHECK_GNUMAKE],
AC_DEFUN([GNUPG_SYS_SYMBOL_UNDERSCORE],
[tmp_do_check="no"
case "${host}" in
- *-mingw32*)
+ i?86-*-mingw32*)
ac_cv_sys_symbol_underscore=yes
;;
+ x86_64-*-mingw32*)
+ ac_cv_sys_symbol_underscore=no
+ ;;
i386-emx-os2 | i[3456]86-pc-os2*emx | i386-pc-msdosdjgpp)
ac_cv_sys_symbol_underscore=yes
;;
diff --git a/mpi/amd64/func_abi.h b/mpi/amd64/func_abi.h
new file mode 100644
index 0000000..ce44674
--- /dev/null
+++ b/mpi/amd64/func_abi.h
@@ -0,0 +1,19 @@
+#ifdef USE_MS_ABI
+ /* Store registers and move four first input arguments from MS ABI to
+ * SYSV ABI. */
+ #define FUNC_ENTRY() \
+ pushq %rsi; \
+ pushq %rdi; \
+ movq %rdx, %rsi; \
+ movq %rcx, %rdi; \
+ movq %r8, %rdx; \
+ movq %r9, %rcx;
+
+ /* Restore registers. */
+ #define FUNC_EXIT() \
+ popq %rdi; \
+ popq %rsi;
+#else
+ #define FUNC_ENTRY() /**/
+ #define FUNC_EXIT() /**/
+#endif
diff --git a/mpi/amd64/mpih-add1.S b/mpi/amd64/mpih-add1.S
index f0ec89c..6a90262 100644
--- a/mpi/amd64/mpih-add1.S
+++ b/mpi/amd64/mpih-add1.S
@@ -43,6 +43,7 @@
.text
.globl C_SYMBOL_NAME(_gcry_mpih_add_n)
C_SYMBOL_NAME(_gcry_mpih_add_n:)
+ FUNC_ENTRY()
leaq (%rsi,%rcx,8), %rsi
leaq (%rdi,%rcx,8), %rdi
leaq (%rdx,%rcx,8), %rdx
@@ -59,5 +60,6 @@ C_SYMBOL_NAME(_gcry_mpih_add_n:)
movq %rcx, %rax /* zero %rax */
adcq %rax, %rax
+ FUNC_EXIT()
ret
\ No newline at end of file
diff --git a/mpi/amd64/mpih-lshift.S b/mpi/amd64/mpih-lshift.S
index e87dd1a..9e8979b 100644
--- a/mpi/amd64/mpih-lshift.S
+++ b/mpi/amd64/mpih-lshift.S
@@ -42,6 +42,7 @@
.text
.globl C_SYMBOL_NAME(_gcry_mpih_lshift)
C_SYMBOL_NAME(_gcry_mpih_lshift:)
+ FUNC_ENTRY()
movq -8(%rsi,%rdx,8), %mm7
movd %ecx, %mm1
movl $64, %eax
@@ -74,4 +75,5 @@ C_SYMBOL_NAME(_gcry_mpih_lshift:)
.Lende: psllq %mm1, %mm2
movq %mm2, (%rdi)
emms
+ FUNC_EXIT()
ret
diff --git a/mpi/amd64/mpih-mul1.S b/mpi/amd64/mpih-mul1.S
index 54b0ab4..67ab47e 100644
--- a/mpi/amd64/mpih-mul1.S
+++ b/mpi/amd64/mpih-mul1.S
@@ -46,6 +46,7 @@
GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1)
C_SYMBOL_NAME(_gcry_mpih_mul_1:)
+ FUNC_ENTRY()
movq %rdx, %r11
leaq (%rsi,%rdx,8), %rsi
leaq (%rdi,%rdx,8), %rdi
@@ -62,4 +63,5 @@ C_SYMBOL_NAME(_gcry_mpih_mul_1:)
jne .Loop
movq %r8, %rax
+ FUNC_EXIT()
ret
diff --git a/mpi/amd64/mpih-mul2.S b/mpi/amd64/mpih-mul2.S
index a332a1d..1aa4fa0 100644
--- a/mpi/amd64/mpih-mul2.S
+++ b/mpi/amd64/mpih-mul2.S
@@ -41,6 +41,7 @@
TEXT
GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1)
C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
+ FUNC_ENTRY()
movq %rdx, %r11
leaq (%rsi,%rdx,8), %rsi
leaq (%rdi,%rdx,8), %rdi
@@ -61,4 +62,5 @@ C_SYMBOL_NAME(_gcry_mpih_addmul_1:)
jne .Loop
movq %r8, %rax
+ FUNC_EXIT()
ret
diff --git a/mpi/amd64/mpih-mul3.S b/mpi/amd64/mpih-mul3.S
index 4d458a7..bc41c4e 100644
--- a/mpi/amd64/mpih-mul3.S
+++ b/mpi/amd64/mpih-mul3.S
@@ -42,7 +42,7 @@
TEXT
GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1)
C_SYMBOL_NAME(_gcry_mpih_submul_1:)
-
+ FUNC_ENTRY()
movq %rdx, %r11
leaq (%rsi,%r11,8), %rsi
leaq (%rdi,%r11,8), %rdi
@@ -63,4 +63,5 @@ C_SYMBOL_NAME(_gcry_mpih_submul_1:)
jne .Loop
movq %r8, %rax
+ FUNC_EXIT()
ret
diff --git a/mpi/amd64/mpih-rshift.S b/mpi/amd64/mpih-rshift.S
index 4cfc8f6..311b85b 100644
--- a/mpi/amd64/mpih-rshift.S
+++ b/mpi/amd64/mpih-rshift.S
@@ -42,6 +42,7 @@
.text
.globl C_SYMBOL_NAME(_gcry_mpih_rshift)
C_SYMBOL_NAME(_gcry_mpih_rshift:)
+ FUNC_ENTRY()
movq (%rsi), %mm7
movd %ecx, %mm1
movl $64, %eax
@@ -77,4 +78,5 @@ C_SYMBOL_NAME(_gcry_mpih_rshift:)
.Lende: psrlq %mm1, %mm2
movq %mm2, -8(%rdi)
emms
+ FUNC_EXIT()
ret
diff --git a/mpi/amd64/mpih-sub1.S b/mpi/amd64/mpih-sub1.S
index b3609b0..ccf6496 100644
--- a/mpi/amd64/mpih-sub1.S
+++ b/mpi/amd64/mpih-sub1.S
@@ -42,6 +42,7 @@
.text
.globl C_SYMBOL_NAME(_gcry_mpih_sub_n)
C_SYMBOL_NAME(_gcry_mpih_sub_n:)
+ FUNC_ENTRY()
leaq (%rsi,%rcx,8), %rsi
leaq (%rdi,%rcx,8), %rdi
leaq (%rdx,%rcx,8), %rdx
@@ -58,4 +59,5 @@ C_SYMBOL_NAME(_gcry_mpih_sub_n:)
movq %rcx, %rax /* zero %rax */
adcq %rax, %rax
+ FUNC_EXIT()
ret
diff --git a/mpi/config.links b/mpi/config.links
index d71918a..2fb5e8a 100644
--- a/mpi/config.links
+++ b/mpi/config.links
@@ -129,17 +129,22 @@ case "${host}" in
x86_64-apple-darwin*)
echo '#define BSD_SYNTAX' >>./mpi/asm-syntax.h
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/amd64/func_abi.h >>./mpi/asm-syntax.h
path="amd64"
mpi_cpu_arch="x86"
;;
x86_64-*mingw32*)
- echo '/* No working assembler modules available */' >>./mpi/asm-syntax.h
- path=""
- mpi_cpu_arch="x86"
+ echo '#define USE_MS_ABI' >>./mpi/asm-syntax.h
+ echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/amd64/func_abi.h >>./mpi/asm-syntax.h
+ path="amd64"
+ mpi_cpu_arch="x86"
;;
x86_64-*-*)
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
cat $srcdir/mpi/i386/syntax.h >>./mpi/asm-syntax.h
+ cat $srcdir/mpi/amd64/func_abi.h >>./mpi/asm-syntax.h
path="amd64"
mpi_cpu_arch="x86"
;;
@@ -314,7 +319,7 @@ case "${host}" in
echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h
cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h
path="powerpc32"
- mpi_cpu_arch="ppc"
+ mpi_cpu_arch="ppc"
;;
rs6000-*-aix[456789]* | \
More information about the Gcrypt-devel
mailing list