Home | History | Annotate | Download | only in math
      1 // Copyright 2010 The Go Authors.  All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 #include "textflag.h"
      6 
      7 // func Exp(x float64) float64
      8 TEXT Exp(SB),NOSPLIT,$0
      9 // test bits for not-finite
     10 	MOVL    x_hi+4(FP), AX
     11 	ANDL    $0x7ff00000, AX
     12 	CMPL    AX, $0x7ff00000
     13 	JEQ     not_finite
     14 	FLDL2E                // F0=log2(e)
     15 	FMULD   x+0(FP), F0   // F0=x*log2(e)
     16 	FMOVD   F0, F1        // F0=x*log2(e), F1=x*log2(e)
     17 	FRNDINT               // F0=int(x*log2(e)), F1=x*log2(e)
     18 	FSUBD   F0, F1        // F0=int(x*log2(e)), F1=x*log2(e)-int(x*log2(e))
     19 	FXCHD   F0, F1        // F0=x*log2(e)-int(x*log2(e)), F1=int(x*log2(e))
     20 	F2XM1                 // F0=2**(x*log2(e)-int(x*log2(e)))-1, F1=int(x*log2(e))
     21 	FLD1                  // F0=1, F1=2**(x*log2(e)-int(x*log2(e)))-1, F2=int(x*log2(e))
     22 	FADDDP  F0, F1        // F0=2**(x*log2(e)-int(x*log2(e))), F1=int(x*log2(e))
     23 	FSCALE                // F0=e**x, F1=int(x*log2(e))
     24 	FMOVDP  F0, F1        // F0=e**x
     25 	FMOVDP  F0, ret+8(FP)
     26 	RET
     27 not_finite:
     28 // test bits for -Inf
     29 	MOVL    x_hi+4(FP), BX
     30 	MOVL    x_lo+0(FP), CX
     31 	CMPL    BX, $0xfff00000
     32 	JNE     not_neginf
     33 	CMPL    CX, $0
     34 	JNE     not_neginf
     35 	FLDZ                  // F0=0
     36 	FMOVDP  F0, ret+8(FP)
     37 	RET
     38 not_neginf:
     39 	MOVL    CX, ret_lo+8(FP)
     40 	MOVL    BX, ret_hi+12(FP)
     41 	RET
     42