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 "ilogbf.S" 9 .text 10 .p2align 4,,15 11.globl __MINGW_USYMBOL(ilogbf) 12 .def __MINGW_USYMBOL(ilogbf); .scl 2; .type 32; .endef 13#ifdef __x86_64__ 14 .seh_proc __MINGW_USYMBOL(ilogbf) 15#endif 16__MINGW_USYMBOL(ilogbf): 17#ifdef __x86_64__ 18/* generated code for: 19int 20ilogbf (float x) 21{ 22 __mingw_flt_type_t hlp; 23 int hx, ix; 24 25 hlp.x = x; 26 hx = (int) hlp.val & 0x7fffffff; 27 if (hx < 0x800000) 28 { 29 if (hx == 0) 30 return 0x80000000; // ilogb(0) = FP_ILOGB0 31 for (ix = -126, hx <<= 8; hx > 0; hx <<= 1) 32 ix -= 1; 33 return ix; 34 } 35 if (hx < 0x7f800000) 36 return (hx >> 23) - 127; 37 return 0x7fffffff; 38} */ 39 subq $24, %rsp 40 .seh_stackalloc 24 41 .seh_endprologue 42 movss %xmm0, 12(%rsp) 43 movl 12(%rsp), %edx 44 andl $2147483647, %edx 45 cmpl $8388607, %edx 46 jg .L2 47 testl %edx, %edx 48 je .L6 49 sall $8, %edx 50 movl $-126, %eax 51 testl %edx, %edx 52 jle .L3 53 .p2align 4,,10 54.L4: 55 addl %edx, %edx 56 subl $1, %eax 57 testl %edx, %edx 58 jg .L4 59.L3: 60 addq $24, %rsp 61 ret 62 .p2align 4,,10 63.L2: 64 cmpl $2139095039, %edx 65 jle .L10 66 movl $2147483647, %eax 67 addq $24, %rsp 68 ret 69 .p2align 4,,10 70.L10: 71 sarl $23, %edx 72 leal -127(%rdx), %eax 73 addq $24, %rsp 74 ret 75.L6: 76 movl $-2147483648, %eax 77 jmp .L3 78 .seh_endproc 79#else 80 flds 4(%esp) 81/* I added the following ugly construct because ilogb(+-Inf) is 82 required to return INT_MAX in ISO C99. 83 -- jakub@redhat.com. */ 84 fxam /* Is NaN or +-Inf? */ 85 fstsw %ax 86 movb $0x45, %dh 87 andb %ah, %dh 88 cmpb $0x05, %dh 89 je 1f /* Is +-Inf, jump. */ 90 cmpb $0x01, %dh 91 je 1f /* Is Nan, jump. */ 92 93 fxtract 94 pushl %eax 95 fstp %st 96 97 fistpl (%esp) 98 fwait 99 popl %eax 100 101 ret 102 1031: fstp %st 104 movl $0x7fffffff, %eax 105 ret 106#endif 107