1 /
   2 / CDDL HEADER START
   3 /
   4 / The contents of this file are subject to the terms of the
   5 / Common Development and Distribution License (the "License").
   6 / You may not use this file except in compliance with the License.
   7 /
   8 / You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9 / or http://www.opensolaris.org/os/licensing.
  10 / See the License for the specific language governing permissions
  11 / and limitations under the License.
  12 /
  13 / When distributing Covered Code,  this CDDL HEADER in each
  14 / file and  the License file at usr/src/OPENSOLARIS.LICENSE.
  15 / If applicable, add the following below this CDDL HEADER, with the
  16 / fields enclosed by brackets "[]" replaced with your own identifying
  17 / information: Portions Copyright [yyyy] [name of copyright owner]
  18 /
  19 / CDDL HEADER END
  20 /
  21 /
  22 / Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  23 /
  24 / Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  25 / Use is subject to license terms.
  26 /
  27 
  28 / Portions of this file are duplicated as GCC inline assembly in
  29 / libm_inlines.h.  Keep them in sync.
  30 
  31         .inline __ieee754_sqrt,0
  32         sqrtsd  %xmm0,%xmm0
  33         .end
  34 
  35         .inline __inline_sqrtf,0
  36         sqrtss  %xmm0,%xmm0
  37         .end
  38 
  39         .inline __inline_sqrt,0
  40         sqrtsd  %xmm0,%xmm0
  41         .end
  42 
  43 /
  44 / 00 - 24 bits
  45 / 01 - reserved
  46 / 10 - 53 bits
  47 / 11 - 64 bits
  48 /
  49         .inline __swapRP,0
  50         subq    $16,%rsp
  51         fstcw   (%rsp)
  52         movw    (%rsp),%ax
  53         movw    %ax,%cx
  54         andw    $0xfcff,%cx
  55         andl    $0x3,%edi
  56         shlw    $8,%di
  57         orw     %di,%cx
  58         movl    %ecx,(%rsp)
  59         fldcw   (%rsp)
  60         shrw    $8,%ax
  61         andq    $0x3,%rax
  62         addq    $16,%rsp
  63         .end
  64 
  65 /
  66 / 00 - Round to nearest, with even preferred
  67 / 01 - Round down
  68 / 10 - Round up
  69 / 11 - Chop
  70 /
  71         .inline __swap87RD,0
  72         subq    $16,%rsp
  73         fstcw   (%rsp)
  74         movw    (%rsp),%ax
  75         movw    %ax,%cx
  76         andw    $0xf3ff,%cx
  77         andl    $0x3,%edi
  78         shlw    $10,%di
  79         orw     %di,%cx
  80         movl    %ecx,(%rsp)
  81         fldcw   (%rsp)
  82         shrw    $10,%ax
  83         andq    $0x3,%rax
  84         addq    $16,%rsp
  85         .end
  86 
  87         .inline abs,0
  88         cmpl    $0,%edi
  89         jge     1f
  90         negl    %edi
  91 1:      movl    %edi,%eax
  92         .end
  93 
  94         .inline __copysign,0
  95         movq    $0x7fffffffffffffff,%rax
  96         movdq   %rax,%xmm2
  97         andpd   %xmm2,%xmm0
  98         andnpd  %xmm1,%xmm2
  99         orpd    %xmm2,%xmm0
 100         .end
 101 
 102         .inline __fabs,0
 103         movq    $0x7fffffffffffffff,%rax
 104         movdq   %rax,%xmm1
 105         andpd   %xmm1,%xmm0
 106         .end
 107 
 108         .inline __fabsf,0
 109         movl    $0x7fffffff,%eax
 110         movdl   %eax,%xmm1
 111         andps   %xmm1,%xmm0
 112         .end
 113 
 114         .inline _finite,0
 115         subq    $16,%rsp
 116         movlpd  %xmm0,(%rsp)
 117         movq    (%rsp),%rcx
 118         movq    $0x7fffffffffffffff,%rax
 119         andq    %rcx,%rax
 120         movq    $0x7ff0000000000000,%rcx
 121         subq    %rcx,%rax
 122         shrq    $63,%rax
 123         addq    $16,%rsp
 124         .end
 125 
 126         .inline __signbit,0
 127         movmskpd %xmm0,%eax
 128         andq    $1,%rax
 129         .end
 130 
 131         .inline __sqrt,0
 132         sqrtsd  %xmm0,%xmm0
 133         .end
 134 
 135         .inline __sqrtf,0
 136         sqrtss  %xmm0,%xmm0
 137         .end
 138 
 139         .inline __f95_signf,0
 140         movl    (%rdi),%eax
 141         movl    (%rsi),%ecx
 142         andl    $0x7fffffff,%eax
 143         andl    $0x80000000,%ecx
 144         orl     %ecx,%eax
 145         movdl   %eax,%xmm0
 146         .end
 147 
 148         .inline __f95_sign,0
 149         movq    (%rsi),%rax
 150         movq    $0x7fffffffffffffff,%rdx
 151         shrq    $63,%rax
 152         shlq    $63,%rax
 153         andq    (%rdi),%rdx
 154         orq     %rdx,%rax
 155         movdq   %rax,%xmm0
 156         .end
 157 
 158         .inline __r_sign,0
 159         movl    $0x7fffffff,%eax
 160         movl    $0x80000000,%edx
 161         andl    (%rdi),%eax
 162         cmpl    (%rsi),%edx
 163         cmovel  %eax,%edx
 164         andl    (%rsi),%edx
 165         orl     %edx,%eax
 166         movdl   %eax,%xmm0
 167         .end
 168 
 169         .inline __d_sign,0
 170         movq    $0x7fffffffffffffff,%rax
 171         movq    $0x8000000000000000,%rdx
 172         andq    (%rdi),%rax
 173         cmpq    (%rsi),%rdx
 174         cmoveq  %rax,%rdx
 175         andq    (%rsi),%rdx
 176         orq     %rdx,%rax
 177         movdq   %rax,%xmm0
 178         .end