| 1 |
/** |
| 2 |
* This file has no copyright assigned and is placed in the Public Domain. |
| 3 |
* This file is part of the mingw-w64 runtime package. |
| 4 |
* No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 |
*/ |
| 6 |
#include <_mingw_mac.h> |
| 7 |
|
| 8 |
.file "ceil.S" |
| 9 |
.text |
| 10 |
.align 4 |
| 11 |
.globl __MINGW_USYMBOL(ceil) |
| 12 |
.def __MINGW_USYMBOL(ceil); .scl 2; .type 32; .endef |
| 13 |
#ifdef __x86_64__ |
| 14 |
.seh_proc __MINGW_USYMBOL(ceil) |
| 15 |
#endif |
| 16 |
|
| 17 |
__MINGW_USYMBOL(ceil): |
| 18 |
#if defined(_AMD64_) || defined(__x86_64__) |
| 19 |
.seh_endprologue |
| 20 |
movd %xmm0, %rax |
| 21 |
movq %rax, %rcx |
| 22 |
sarq $52, %rcx |
| 23 |
andl $2047, %ecx |
| 24 |
subl $1023, %ecx |
| 25 |
cmpl $51, %ecx |
| 26 |
jg .is_intnaninf |
| 27 |
/* Is x zero? */ |
| 28 |
testq %rax, %rax |
| 29 |
je .ret_org |
| 30 |
/* Is x signed? */ |
| 31 |
testl %ecx, %ecx |
| 32 |
js .signed_val |
| 33 |
/* Is x integral? */ |
| 34 |
movabsq $4503599627370495, %rdx |
| 35 |
sarq %cl, %rdx |
| 36 |
testq %rax, %rdx |
| 37 |
je .ret_org |
| 38 |
addsd .huge(%rip), %xmm0 |
| 39 |
ucomisd .zero(%rip), %xmm0 |
| 40 |
jbe .doret |
| 41 |
testq %rax, %rax |
| 42 |
jle .l1 |
| 43 |
/* inexact ... */ |
| 44 |
movabsq $4503599627370496, %r8 |
| 45 |
shrq %cl, %r8 |
| 46 |
addq %r8, %rax |
| 47 |
.l1: |
| 48 |
notq %rdx |
| 49 |
andq %rdx, %rax |
| 50 |
.doret: |
| 51 |
movd %rax, %xmm0 |
| 52 |
ret |
| 53 |
.p2align 4,,10 |
| 54 |
.signed_val: |
| 55 |
addsd .huge(%rip), %xmm0 |
| 56 |
ucomisd .zero(%rip), %xmm0 |
| 57 |
jbe .doret2 |
| 58 |
testq %rax, %rax |
| 59 |
movabsq $4607182418800017408, %rdx |
| 60 |
movabsq $-9223372036854775808, %rax |
| 61 |
cmovns %rdx, %rax |
| 62 |
.p2align 4,,10 |
| 63 |
.doret2: |
| 64 |
movd %rax, %xmm0 |
| 65 |
ret |
| 66 |
|
| 67 |
.p2align 4,,10 |
| 68 |
.is_intnaninf: |
| 69 |
/* Is Nan or Inf? */ |
| 70 |
cmpl $1024, %ecx |
| 71 |
je .ret_naninf |
| 72 |
.p2align 4,,10 |
| 73 |
.ret_org: |
| 74 |
/* return x. */ |
| 75 |
rep |
| 76 |
ret |
| 77 |
.p2align 4,,10 |
| 78 |
.ret_naninf: |
| 79 |
/* return x + x; */ |
| 80 |
addsd %xmm0, %xmm0 |
| 81 |
ret |
| 82 |
.seh_endproc |
| 83 |
|
| 84 |
/* local data. */ |
| 85 |
.section .rdata,"dr" |
| 86 |
.align 8 |
| 87 |
.huge: |
| 88 |
.long -2013235812 |
| 89 |
.long 2117592124 |
| 90 |
.align 8 |
| 91 |
.zero: |
| 92 |
.long 0 |
| 93 |
.long 0 |
| 94 |
#elif defined(_X86_) || defined(__i386__) |
| 95 |
fldl 4(%esp) |
| 96 |
subl $8,%esp |
| 97 |
|
| 98 |
fstcw 4(%esp) /* store fpu control word */ |
| 99 |
|
| 100 |
/* We use here %edx although only the low 1 bits are defined. |
| 101 |
But none of the operations should care and they are faster |
| 102 |
than the 16 bit operations. */ |
| 103 |
movl $0x0800,%edx /* round towards +oo */ |
| 104 |
orl 4(%esp),%edx |
| 105 |
andl $0xfbff,%edx |
| 106 |
movl %edx,(%esp) |
| 107 |
fldcw (%esp) /* load modified control word */ |
| 108 |
|
| 109 |
frndint /* round */ |
| 110 |
|
| 111 |
fldcw 4(%esp) /* restore original control word */ |
| 112 |
|
| 113 |
addl $8,%esp |
| 114 |
ret |
| 115 |
#endif |