|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
dnl AMD64 MULX/ADX simulation support.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
dnl Contributed to the GNU project by Torbjörn Granlund.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
dnl Copyright 2013 Free Software Foundation, Inc.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
dnl This file is part of the GNU MP Library.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl The GNU MP Library is free software; you can redistribute it and/or modify
|
|
Packit |
5c3484 |
dnl it under the terms of either:
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl * the GNU Lesser General Public License as published by the Free
|
|
Packit |
5c3484 |
dnl Software Foundation; either version 3 of the License, or (at your
|
|
Packit |
5c3484 |
dnl option) any later version.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl or
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl * the GNU General Public License as published by the Free Software
|
|
Packit |
5c3484 |
dnl Foundation; either version 2 of the License, or (at your option) any
|
|
Packit |
5c3484 |
dnl later version.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl or both in parallel, as here.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl The GNU MP Library is distributed in the hope that it will be useful, but
|
|
Packit |
5c3484 |
dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
Packit |
5c3484 |
dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
Packit |
5c3484 |
dnl for more details.
|
|
Packit |
5c3484 |
dnl
|
|
Packit |
5c3484 |
dnl You should have received copies of the GNU General Public License and the
|
|
Packit |
5c3484 |
dnl GNU Lesser General Public License along with the GNU MP Library. If not,
|
|
Packit |
5c3484 |
dnl see https://www.gnu.org/licenses/.
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
include(`../config.m4')
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
ASM_START()
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
C Fake the MULX instruction
|
|
Packit |
5c3484 |
C
|
|
Packit |
5c3484 |
C Accept the single explicit parameter on the stack, return the two result
|
|
Packit |
5c3484 |
C words on the stack. This calling convention means that we need to move the
|
|
Packit |
5c3484 |
C return address up.
|
|
Packit |
5c3484 |
C
|
|
Packit |
5c3484 |
PROLOGUE(__gmp_mulx)
|
|
Packit |
5c3484 |
lea -8(%rsp), %rsp
|
|
Packit |
5c3484 |
push %rax
|
|
Packit |
5c3484 |
push %rdx
|
|
Packit |
5c3484 |
pushfq C preserve all flags
|
|
Packit |
5c3484 |
mov 32(%rsp), %rax C move retaddr...
|
|
Packit |
5c3484 |
mov %rax, 24(%rsp) C ...up the stack
|
|
Packit |
5c3484 |
mov 40(%rsp), %rax C input parameter
|
|
Packit |
5c3484 |
mul %rdx
|
|
Packit |
5c3484 |
mov %rax, 32(%rsp)
|
|
Packit |
5c3484 |
mov %rdx, 40(%rsp)
|
|
Packit |
5c3484 |
popfq C restore eflags
|
|
Packit |
5c3484 |
pop %rdx
|
|
Packit |
5c3484 |
pop %rax
|
|
Packit |
5c3484 |
ret
|
|
Packit |
5c3484 |
EPILOGUE()
|
|
Packit |
5c3484 |
PROTECT(__gmp_mulx)
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
C Fake the ADOX instruction
|
|
Packit |
5c3484 |
C
|
|
Packit |
5c3484 |
C Accept the two parameters on the stack, return the result word on the stack.
|
|
Packit |
5c3484 |
C This calling convention means that we need to move the return address down.
|
|
Packit |
5c3484 |
C
|
|
Packit |
5c3484 |
PROLOGUE(__gmp_adox)
|
|
Packit |
5c3484 |
push %rcx
|
|
Packit |
5c3484 |
push %rbx
|
|
Packit |
5c3484 |
push %rax
|
|
Packit |
5c3484 |
mov 32(%rsp), %rcx C src2
|
|
Packit |
5c3484 |
mov 24(%rsp), %rax C move retaddr...
|
|
Packit |
5c3484 |
mov %rax, 32(%rsp) C ...down the stack
|
|
Packit |
5c3484 |
pushfq
|
|
Packit |
5c3484 |
C copy 0(%rsp):11 to 0(%rsp):0
|
|
Packit |
5c3484 |
mov (%rsp), %rbx
|
|
Packit |
5c3484 |
shr %rbx
|
|
Packit |
5c3484 |
bt $10, %rbx
|
|
Packit |
5c3484 |
adc %rbx, %rbx
|
|
Packit |
5c3484 |
push %rbx
|
|
Packit |
5c3484 |
C put manipulated flags into eflags, execute a plain adc
|
|
Packit |
5c3484 |
popfq
|
|
Packit |
5c3484 |
adc %rcx, 48(%rsp)
|
|
Packit |
5c3484 |
C copy CF to 0(%rsp):11
|
|
Packit |
5c3484 |
pop %rbx
|
|
Packit |
5c3484 |
sbb R32(%rax), R32(%rax)
|
|
Packit |
5c3484 |
and $0x800, R32(%rax)
|
|
Packit |
5c3484 |
and $0xfffffffffffff7ff, %rbx
|
|
Packit |
5c3484 |
or %rax, %rbx
|
|
Packit |
5c3484 |
push %rbx
|
|
Packit |
5c3484 |
C put manipulated flags into eflags
|
|
Packit |
5c3484 |
popfq
|
|
Packit |
5c3484 |
pop %rax
|
|
Packit |
5c3484 |
pop %rbx
|
|
Packit |
5c3484 |
pop %rcx
|
|
Packit |
5c3484 |
lea 8(%rsp), %rsp
|
|
Packit |
5c3484 |
ret
|
|
Packit |
5c3484 |
EPILOGUE()
|
|
Packit |
5c3484 |
PROTECT(__gmp_adox)
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
|
|
Packit |
5c3484 |
C Fake the ADCX instruction
|
|
Packit |
5c3484 |
C
|
|
Packit |
5c3484 |
C Accept the two parameters on the stack, return the result word on the stack.
|
|
Packit |
5c3484 |
C This calling convention means that we need to move the return address down.
|
|
Packit |
5c3484 |
C
|
|
Packit |
5c3484 |
PROLOGUE(__gmp_adcx)
|
|
Packit |
5c3484 |
push %rcx
|
|
Packit |
5c3484 |
push %rbx
|
|
Packit |
5c3484 |
push %rax
|
|
Packit |
5c3484 |
mov 32(%rsp), %rcx C src2
|
|
Packit |
5c3484 |
mov 24(%rsp), %rax C move retaddr...
|
|
Packit |
5c3484 |
mov %rax, 32(%rsp) C ...down the stack
|
|
Packit |
5c3484 |
pushfq
|
|
Packit |
5c3484 |
adc %rcx, 48(%rsp)
|
|
Packit |
5c3484 |
pop %rbx
|
|
Packit |
5c3484 |
sbb R32(%rax), R32(%rax)
|
|
Packit |
5c3484 |
and $`'0xfffffffffffffffe, %rbx
|
|
Packit |
5c3484 |
sub %rax, %rbx
|
|
Packit |
5c3484 |
push %rbx
|
|
Packit |
5c3484 |
popfq
|
|
Packit |
5c3484 |
pop %rax
|
|
Packit |
5c3484 |
pop %rbx
|
|
Packit |
5c3484 |
pop %rcx
|
|
Packit |
5c3484 |
lea 8(%rsp), %rsp
|
|
Packit |
5c3484 |
ret
|
|
Packit |
5c3484 |
EPILOGUE()
|
|
Packit |
5c3484 |
PROTECT(__gmp_adcx)
|
|
rpm-build |
c3cd4f |
CF_PROT
|