x32 port (diff against vanilla x86_64)
This commit is contained in:
parent
323272db17
commit
664cd34192
39 changed files with 882 additions and 793 deletions
|
|
@ -8,14 +8,14 @@ feclearexcept:
|
|||
test %eax,%ecx
|
||||
jz 1f
|
||||
fnclex
|
||||
1: stmxcsr -8(%rsp)
|
||||
1: stmxcsr -8(%esp)
|
||||
and $0x3f,%eax
|
||||
or %eax,-8(%rsp)
|
||||
test %ecx,-8(%rsp)
|
||||
or %eax,-8(%esp)
|
||||
test %ecx,-8(%esp)
|
||||
jz 1f
|
||||
not %ecx
|
||||
and %ecx,-8(%rsp)
|
||||
ldmxcsr -8(%rsp)
|
||||
and %ecx,-8(%esp)
|
||||
ldmxcsr -8(%esp)
|
||||
1: xor %eax,%eax
|
||||
ret
|
||||
|
||||
|
|
@ -23,9 +23,9 @@ feclearexcept:
|
|||
.type feraiseexcept,@function
|
||||
feraiseexcept:
|
||||
and $0x3f,%edi
|
||||
stmxcsr -8(%rsp)
|
||||
or %edi,-8(%rsp)
|
||||
ldmxcsr -8(%rsp)
|
||||
stmxcsr -8(%esp)
|
||||
or %edi,-8(%esp)
|
||||
ldmxcsr -8(%esp)
|
||||
xor %eax,%eax
|
||||
ret
|
||||
|
||||
|
|
@ -35,15 +35,15 @@ __fesetround:
|
|||
push %rax
|
||||
xor %eax,%eax
|
||||
mov %edi,%ecx
|
||||
fnstcw (%rsp)
|
||||
andb $0xf3,1(%rsp)
|
||||
or %ch,1(%rsp)
|
||||
fldcw (%rsp)
|
||||
stmxcsr (%rsp)
|
||||
fnstcw (%esp)
|
||||
andb $0xf3,1(%esp)
|
||||
or %ch,1(%esp)
|
||||
fldcw (%esp)
|
||||
stmxcsr (%esp)
|
||||
shl $3,%ch
|
||||
andb $0x9f,1(%rsp)
|
||||
or %ch,1(%rsp)
|
||||
ldmxcsr (%rsp)
|
||||
andb $0x9f,1(%esp)
|
||||
or %ch,1(%esp)
|
||||
ldmxcsr (%esp)
|
||||
pop %rcx
|
||||
ret
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ __fesetround:
|
|||
.type fegetround,@function
|
||||
fegetround:
|
||||
push %rax
|
||||
stmxcsr (%rsp)
|
||||
stmxcsr (%esp)
|
||||
pop %rax
|
||||
shr $3,%eax
|
||||
and $0xc00,%eax
|
||||
|
|
@ -61,27 +61,27 @@ fegetround:
|
|||
.type fegetenv,@function
|
||||
fegetenv:
|
||||
xor %eax,%eax
|
||||
fnstenv (%rdi)
|
||||
stmxcsr 28(%rdi)
|
||||
fnstenv (%edi)
|
||||
stmxcsr 28(%edi)
|
||||
ret
|
||||
|
||||
.global fesetenv
|
||||
.type fesetenv,@function
|
||||
fesetenv:
|
||||
xor %eax,%eax
|
||||
inc %rdi
|
||||
inc %edi
|
||||
jz 1f
|
||||
fldenv -1(%rdi)
|
||||
ldmxcsr 27(%rdi)
|
||||
fldenv -1(%edi)
|
||||
ldmxcsr 27(%edi)
|
||||
ret
|
||||
1: push %rax
|
||||
push %rax
|
||||
pushq $0xffff
|
||||
pushq $0x37f
|
||||
fldenv (%rsp)
|
||||
fldenv (%esp)
|
||||
pushq $0x1f80
|
||||
ldmxcsr (%rsp)
|
||||
add $40,%rsp
|
||||
ldmxcsr (%esp)
|
||||
add $40,%esp
|
||||
ret
|
||||
|
||||
.global fetestexcept
|
||||
|
|
@ -89,7 +89,7 @@ fesetenv:
|
|||
fetestexcept:
|
||||
and $0x3f,%edi
|
||||
push %rax
|
||||
stmxcsr (%rsp)
|
||||
stmxcsr (%esp)
|
||||
pop %rsi
|
||||
fnstsw %ax
|
||||
or %esi,%eax
|
||||
|
|
|
|||
|
|
@ -1,16 +1,24 @@
|
|||
.text
|
||||
.global _start
|
||||
_start:
|
||||
mov (%rsp),%rdi
|
||||
lea 8(%rsp),%rsi
|
||||
mov (%rsp),%rdi /* move argc into 1st argument slot */
|
||||
lea 4(%rsp),%rsi /* move argv into 2nd argument slot */
|
||||
call __dynlink
|
||||
pop %rdi
|
||||
/* in case the dynlinker was called directly, it sets the "consumed"
|
||||
argv values to -1. so we must loop over the array as long as -1
|
||||
is in the top argv slot, decrement argc, and then set the stackpointer
|
||||
to the new argc as well as argc's new value.
|
||||
as the x32 abi has longs in the argv array, we cannot use push/pop.*/
|
||||
movl (%rsp),%edi /* copy argc into edi */
|
||||
xor %rdx,%rdx /* we use rdx as an offset to the current argv member */
|
||||
1: dec %edi
|
||||
pop %rsi
|
||||
cmp $-1,%rsi
|
||||
addl $4, %edx
|
||||
movl (%rsp, %rdx), %esi
|
||||
cmp $-1,%esi
|
||||
jz 1b
|
||||
inc %edi
|
||||
push %rsi
|
||||
push %rdi
|
||||
subl $4, %edx
|
||||
lea (%rsp, %rdx), %rsp /* set rsp to new argv[-1] */
|
||||
movl %edi, (%rsp) /* write new argc there */
|
||||
xor %edx,%edx
|
||||
jmp *%rax
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
.global acosl
|
||||
.type acosl,@function
|
||||
acosl:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
1: fld %st(0)
|
||||
fld1
|
||||
fsub %st(0),%st(1)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.global asinl
|
||||
.type asinl,@function
|
||||
asinl:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
1: fld %st(0)
|
||||
fld1
|
||||
fsub %st(0),%st(1)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.global atan2l
|
||||
.type atan2l,@function
|
||||
atan2l:
|
||||
fldt 8(%rsp)
|
||||
fldt 24(%rsp)
|
||||
fldt 8(%esp)
|
||||
fldt 24(%esp)
|
||||
fpatan
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.global atanl
|
||||
.type atanl,@function
|
||||
atanl:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
fld1
|
||||
fpatan
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
.global expm1l
|
||||
.type expm1l,@function
|
||||
expm1l:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
fldl2e
|
||||
fmulp
|
||||
movl $0xc2820000,-4(%rsp)
|
||||
flds -4(%rsp)
|
||||
movl $0xc2820000,-4(%esp)
|
||||
flds -4(%esp)
|
||||
fucomp %st(1)
|
||||
fnstsw %ax
|
||||
sahf
|
||||
|
|
@ -35,21 +35,21 @@ expm1l:
|
|||
.global exp2l
|
||||
.type exp2l,@function
|
||||
exp2l:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
1: fld %st(0)
|
||||
sub $16,%rsp
|
||||
fstpt (%rsp)
|
||||
mov 8(%rsp),%ax
|
||||
sub $16,%esp
|
||||
fstpt (%esp)
|
||||
mov 8(%esp),%ax
|
||||
and $0x7fff,%ax
|
||||
cmp $0x3fff+13,%ax
|
||||
jb 4f # |x| < 8192
|
||||
cmp $0x3fff+15,%ax
|
||||
jae 3f # |x| >= 32768
|
||||
fsts (%rsp)
|
||||
cmpl $0xc67ff800,(%rsp)
|
||||
fsts (%esp)
|
||||
cmpl $0xc67ff800,(%esp)
|
||||
jb 2f # x > -16382
|
||||
movl $0x5f000000,(%rsp)
|
||||
flds (%rsp) # 0x1p63
|
||||
movl $0x5f000000,(%esp)
|
||||
flds (%esp) # 0x1p63
|
||||
fld %st(1)
|
||||
fsub %st(1)
|
||||
faddp
|
||||
|
|
@ -57,10 +57,10 @@ exp2l:
|
|||
fnstsw
|
||||
sahf
|
||||
je 2f # x - 0x1p63 + 0x1p63 == x
|
||||
movl $1,(%rsp)
|
||||
flds (%rsp) # 0x1p-149
|
||||
movl $1,(%esp)
|
||||
flds (%esp) # 0x1p-149
|
||||
fdiv %st(1)
|
||||
fstps (%rsp) # raise underflow
|
||||
fstps (%esp) # raise underflow
|
||||
2: fld1
|
||||
fld %st(1)
|
||||
frndint
|
||||
|
|
@ -70,21 +70,21 @@ exp2l:
|
|||
faddp # 2^(x-rint(x))
|
||||
1: fscale
|
||||
fstp %st(1)
|
||||
add $16,%rsp
|
||||
add $16,%esp
|
||||
ret
|
||||
3: xor %eax,%eax
|
||||
4: cmp $0x3fff-64,%ax
|
||||
fld1
|
||||
jb 1b # |x| < 0x1p-64
|
||||
fstpt (%rsp)
|
||||
fistl 8(%rsp)
|
||||
fildl 8(%rsp)
|
||||
fstpt (%esp)
|
||||
fistl 8(%esp)
|
||||
fildl 8(%esp)
|
||||
fsubrp %st(1)
|
||||
addl $0x3fff,8(%rsp)
|
||||
addl $0x3fff,8(%esp)
|
||||
f2xm1
|
||||
fld1
|
||||
faddp # 2^(x-rint(x))
|
||||
fldt (%rsp) # 2^rint(x)
|
||||
fldt (%esp) # 2^rint(x)
|
||||
fmulp
|
||||
add $16,%rsp
|
||||
add $16,%esp
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -6,11 +6,11 @@
|
|||
.global expl
|
||||
.type expl,@function
|
||||
expl:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
|
||||
# interesting case: 0x1p-32 <= |x| < 16384
|
||||
# check if (exponent|0x8000) is in [0xbfff-32, 0xbfff+13]
|
||||
mov 16(%rsp), %ax
|
||||
mov 16(%esp), %ax
|
||||
or $0x8000, %ax
|
||||
sub $0xbfdf, %ax
|
||||
cmp $45, %ax
|
||||
|
|
@ -29,29 +29,29 @@ expl:
|
|||
# should be 0x1.71547652b82fe178p0L == 0x3fff b8aa3b29 5c17f0bc
|
||||
# it will be wrong on non-nearest rounding mode
|
||||
2: fldl2e
|
||||
subq $48, %rsp
|
||||
sub $48, %esp
|
||||
# hi = log2e_hi*x
|
||||
# 2^hi = exp2l(hi)
|
||||
fmul %st(1),%st
|
||||
fld %st(0)
|
||||
fstpt (%rsp)
|
||||
fstpt 16(%rsp)
|
||||
fstpt 32(%rsp)
|
||||
fstpt (%esp)
|
||||
fstpt 16(%esp)
|
||||
fstpt 32(%esp)
|
||||
call exp2l
|
||||
# if 2^hi == inf return 2^hi
|
||||
fld %st(0)
|
||||
fstpt (%rsp)
|
||||
cmpw $0x7fff, 8(%rsp)
|
||||
fstpt (%esp)
|
||||
cmpw $0x7fff, 8(%esp)
|
||||
je 1f
|
||||
fldt 32(%rsp)
|
||||
fldt 16(%rsp)
|
||||
fldt 32(%esp)
|
||||
fldt 16(%esp)
|
||||
# fpu stack: 2^hi x hi
|
||||
# exact mult: x*log2e
|
||||
fld %st(1)
|
||||
# c = 0x1p32+1
|
||||
movq $0x41f0000000100000,%rax
|
||||
pushq %rax
|
||||
fldl (%rsp)
|
||||
fldl (%esp)
|
||||
# xh = x - c*x + c*x
|
||||
# xl = x - xh
|
||||
fmulp
|
||||
|
|
@ -63,7 +63,7 @@ expl:
|
|||
# yh = log2e_hi - c*log2e_hi + c*log2e_hi
|
||||
movq $0x3ff7154765200000,%rax
|
||||
pushq %rax
|
||||
fldl (%rsp)
|
||||
fldl (%esp)
|
||||
# fpu stack: 2^hi x hi xh xl yh
|
||||
# lo = hi - xh*yh + xl*yh
|
||||
fld %st(2)
|
||||
|
|
@ -74,7 +74,7 @@ expl:
|
|||
# yl = log2e_hi - yh
|
||||
movq $0x3de705fc2f000000,%rax
|
||||
pushq %rax
|
||||
fldl (%rsp)
|
||||
fldl (%esp)
|
||||
# fpu stack: 2^hi x lo xh xl yl
|
||||
# lo += xh*yl + xl*yl
|
||||
fmul %st, %st(2)
|
||||
|
|
@ -87,8 +87,8 @@ expl:
|
|||
pushq %rax
|
||||
movq $0x82f0025f2dc582ee,%rax
|
||||
pushq %rax
|
||||
fldt (%rsp)
|
||||
addq $40,%rsp
|
||||
fldt (%esp)
|
||||
add $40,%esp
|
||||
# fpu stack: 2^hi x lo log2e_lo
|
||||
# lo += log2e_lo*x
|
||||
# return 2^hi + 2^hi (2^lo - 1)
|
||||
|
|
@ -97,5 +97,5 @@ expl:
|
|||
f2xm1
|
||||
fmul %st(1), %st
|
||||
faddp
|
||||
1: addq $48, %rsp
|
||||
1: add $48, %esp
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.global fabsl
|
||||
.type fabsl,@function
|
||||
fabsl:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
fabs
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -1,27 +1,27 @@
|
|||
.global floorl
|
||||
.type floorl,@function
|
||||
floorl:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
1: mov $0x7,%al
|
||||
1: fstcw 8(%rsp)
|
||||
mov 9(%rsp),%ah
|
||||
mov %al,9(%rsp)
|
||||
fldcw 8(%rsp)
|
||||
1: fstcw 8(%esp)
|
||||
mov 9(%esp),%ah
|
||||
mov %al,9(%esp)
|
||||
fldcw 8(%esp)
|
||||
frndint
|
||||
mov %ah,9(%rsp)
|
||||
fldcw 8(%rsp)
|
||||
mov %ah,9(%esp)
|
||||
fldcw 8(%esp)
|
||||
ret
|
||||
|
||||
.global ceill
|
||||
.type ceill,@function
|
||||
ceill:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
mov $0xb,%al
|
||||
jmp 1b
|
||||
|
||||
.global truncl
|
||||
.type truncl,@function
|
||||
truncl:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
mov $0xf,%al
|
||||
jmp 1b
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
.global fmodl
|
||||
.type fmodl,@function
|
||||
fmodl:
|
||||
fldt 24(%rsp)
|
||||
fldt 8(%rsp)
|
||||
fldt 24(%esp)
|
||||
fldt 8(%esp)
|
||||
1: fprem
|
||||
fstsw %ax
|
||||
sahf
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.global llrintl
|
||||
.type llrintl,@function
|
||||
llrintl:
|
||||
fldt 8(%rsp)
|
||||
fistpll 8(%rsp)
|
||||
mov 8(%rsp),%rax
|
||||
fldt 8(%esp)
|
||||
fistpll 8(%esp)
|
||||
mov 8(%esp),%rax
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
.type log10l,@function
|
||||
log10l:
|
||||
fldlg2
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
fyl2x
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
.global log1pl
|
||||
.type log1pl,@function
|
||||
log1pl:
|
||||
mov 14(%rsp),%eax
|
||||
mov 14(%esp),%eax
|
||||
fldln2
|
||||
and $0x7fffffff,%eax
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
cmp $0x3ffd9400,%eax
|
||||
ja 1f
|
||||
fyl2xp1
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
.type log2l,@function
|
||||
log2l:
|
||||
fld1
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
fyl2x
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
.type logl,@function
|
||||
logl:
|
||||
fldln2
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
fyl2x
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.global lrintl
|
||||
.type lrintl,@function
|
||||
lrintl:
|
||||
fldt 8(%rsp)
|
||||
fistpll 8(%rsp)
|
||||
mov 8(%rsp),%rax
|
||||
fldt 8(%esp)
|
||||
fistpll 8(%esp)
|
||||
mov 8(%esp),%rax
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
.global remainderl
|
||||
.type remainderl,@function
|
||||
remainderl:
|
||||
fldt 24(%rsp)
|
||||
fldt 8(%rsp)
|
||||
fldt 24(%esp)
|
||||
fldt 8(%esp)
|
||||
1: fprem1
|
||||
fstsw %ax
|
||||
sahf
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
.global rintl
|
||||
.type rintl,@function
|
||||
rintl:
|
||||
fldt 8(%rsp)
|
||||
fldt 8(%esp)
|
||||
frndint
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
.global sqrtl
|
||||
.type sqrtl,@function
|
||||
sqrtl: fldt 8(%rsp)
|
||||
sqrtl: fldt 8(%esp)
|
||||
fsqrt
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
__vfork:
|
||||
vfork:
|
||||
pop %rdx
|
||||
mov $58,%eax
|
||||
mov $0x4000003a,%eax /* SYS_vfork */
|
||||
syscall
|
||||
push %rdx
|
||||
mov %rax,%rdi
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@
|
|||
.type __restore,@function
|
||||
__restore_rt:
|
||||
__restore:
|
||||
movl $15, %eax
|
||||
movl $0x40000201, %eax /* SYS_rt_sigreturn */
|
||||
syscall
|
||||
|
|
|
|||
|
|
@ -5,6 +5,6 @@
|
|||
__set_thread_area:
|
||||
mov %rdi,%rsi /* shift for syscall */
|
||||
movl $0x1002,%edi /* SET_FS register */
|
||||
movl $158,%eax /* set fs segment to */
|
||||
movl $0x4000009e,%eax /* set fs segment to */
|
||||
syscall /* arch_prctl(SET_FS, arg)*/
|
||||
ret
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@
|
|||
.global __unmapself
|
||||
.type __unmapself,@function
|
||||
__unmapself:
|
||||
movl $11,%eax /* SYS_munmap */
|
||||
movl $0x4000000b,%eax /* SYS_munmap */
|
||||
syscall /* munmap(arg2,arg3) */
|
||||
xor %rdi,%rdi /* exit() args: always return success */
|
||||
movl $60,%eax /* SYS_exit */
|
||||
movl $0x4000003c,%eax /* SYS_exit */
|
||||
syscall /* exit(0) */
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
.global __clone
|
||||
.type __clone,@function
|
||||
__clone:
|
||||
xor %eax,%eax
|
||||
mov $56,%al
|
||||
movl $0x40000038,%eax /* SYS_clone */
|
||||
mov %rdi,%r11
|
||||
mov %rdx,%rdi
|
||||
mov %r8,%rdx
|
||||
|
|
@ -20,8 +19,7 @@ __clone:
|
|||
pop %rdi
|
||||
call *%r9
|
||||
mov %eax,%edi
|
||||
xor %eax,%eax
|
||||
mov $60,%al
|
||||
movl $0x4000003c,%eax /* SYS_exit */
|
||||
syscall
|
||||
hlt
|
||||
1: ret
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.text
|
||||
.global __syscall_cp_asm
|
||||
.type __syscall_cp_asm,@function
|
||||
__syscall_cp_asm:
|
||||
.global __syscall_cp_internal
|
||||
.type __syscall_cp_internal,@function
|
||||
__syscall_cp_internal:
|
||||
|
||||
.global __cp_begin
|
||||
__cp_begin:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue