...
Run Format

Text file src/math/tanh_s390x.s

Documentation: math

     1	// Copyright 2016 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	// Minimax polynomial approximations
     8	DATA tanhrodataL18<>+0(SB)/8, $-1.0
     9	DATA tanhrodataL18<>+8(SB)/8, $-2.0
    10	DATA tanhrodataL18<>+16(SB)/8, $1.0
    11	DATA tanhrodataL18<>+24(SB)/8, $2.0
    12	DATA tanhrodataL18<>+32(SB)/8, $0.20000000000000011868E+01
    13	DATA tanhrodataL18<>+40(SB)/8, $0.13333333333333341256E+01
    14	DATA tanhrodataL18<>+48(SB)/8, $0.26666666663549111502E+00
    15	DATA tanhrodataL18<>+56(SB)/8, $0.66666666658721844678E+00
    16	DATA tanhrodataL18<>+64(SB)/8, $0.88890217768964374821E-01
    17	DATA tanhrodataL18<>+72(SB)/8, $0.25397199429103821138E-01
    18	DATA tanhrodataL18<>+80(SB)/8, $-.346573590279972643E+00
    19	DATA tanhrodataL18<>+88(SB)/8, $20.E0
    20	GLOBL tanhrodataL18<>+0(SB), RODATA, $96
    21	
    22	// Constants
    23	DATA tanhrlog2<>+0(SB)/8, $0x4007154760000000
    24	GLOBL tanhrlog2<>+0(SB), RODATA, $8
    25	DATA tanhxadd<>+0(SB)/8, $0xc2f0000100003ff0
    26	GLOBL tanhxadd<>+0(SB), RODATA, $8
    27	DATA tanhxmone<>+0(SB)/8, $-1.0
    28	GLOBL tanhxmone<>+0(SB), RODATA, $8
    29	DATA tanhxzero<>+0(SB)/8, $0
    30	GLOBL tanhxzero<>+0(SB), RODATA, $8
    31	
    32	// Polynomial coefficients
    33	DATA tanhtab<>+0(SB)/8, $0.000000000000000000E+00
    34	DATA tanhtab<>+8(SB)/8, $-.171540871271399150E-01
    35	DATA tanhtab<>+16(SB)/8, $-.306597931864376363E-01
    36	DATA tanhtab<>+24(SB)/8, $-.410200970469965021E-01
    37	DATA tanhtab<>+32(SB)/8, $-.486343079978231466E-01
    38	DATA tanhtab<>+40(SB)/8, $-.538226193725835820E-01
    39	DATA tanhtab<>+48(SB)/8, $-.568439602538111520E-01
    40	DATA tanhtab<>+56(SB)/8, $-.579091847395528847E-01
    41	DATA tanhtab<>+64(SB)/8, $-.571909584179366341E-01
    42	DATA tanhtab<>+72(SB)/8, $-.548312665987204407E-01
    43	DATA tanhtab<>+80(SB)/8, $-.509471843643441085E-01
    44	DATA tanhtab<>+88(SB)/8, $-.456353588448863359E-01
    45	DATA tanhtab<>+96(SB)/8, $-.389755254243262365E-01
    46	DATA tanhtab<>+104(SB)/8, $-.310332908285244231E-01
    47	DATA tanhtab<>+112(SB)/8, $-.218623539150173528E-01
    48	DATA tanhtab<>+120(SB)/8, $-.115062908917949451E-01
    49	GLOBL tanhtab<>+0(SB), RODATA, $128
    50	
    51	// Tanh returns the hyperbolic tangent of the argument.
    52	//
    53	// Special cases are:
    54	//      Tanh(±0) = ±0
    55	//      Tanh(±Inf) = ±1
    56	//      Tanh(NaN) = NaN
    57	// The algorithm used is minimax polynomial approximation using a table of
    58	// polynomial coefficients determined with a Remez exchange algorithm.
    59	
    60	TEXT ·tanhAsm(SB),NOSPLIT,$0-16
    61		FMOVD   x+0(FP), F0
    62		// special case Tanh(±0) = ±0
    63		FMOVD   $(0.0), F1
    64		FCMPU   F0, F1
    65		BEQ     tanhIsZero
    66		MOVD    $tanhrodataL18<>+0(SB), R5
    67		WORD    $0xB3120000     //ltdbr %f0,%f0
    68		MOVD    $0x4034000000000000, R1
    69		BLTU    L15
    70		FMOVD   F0, F1
    71	L2:
    72		MOVD    $tanhxadd<>+0(SB), R2
    73		FMOVD   0(R2), F2
    74		MOVD    tanhrlog2<>+0(SB), R2
    75		LDGR    R2, F4
    76		WFMSDB  V0, V4, V2, V4
    77		MOVD    $tanhtab<>+0(SB), R3
    78		LGDR    F4, R2
    79		WORD    $0xEC4239BC     //risbg %r4,%r2,57,128+60,3
    80		BYTE    $0x03
    81		BYTE    $0x55
    82		WORD    $0xED105058     //cdb %f1,.L19-.L18(%r5)
    83		BYTE    $0x00
    84		BYTE    $0x19
    85		WORD    $0xEC12000F     //risbgn %r1,%r2,64-64+0,64-64+0+16-1,64-0-16
    86		BYTE    $0x30
    87		BYTE    $0x59
    88		WORD    $0x68543000     //ld %f5,0(%r4,%r3)
    89		LDGR    R1, F6
    90		BLT     L3
    91		MOVD    $tanhxzero<>+0(SB), R1
    92		FMOVD   0(R1), F2
    93		WFCHDBS V0, V2, V4
    94		BEQ     L9
    95		WFCHDBS V2, V0, V2
    96		BNE     L1
    97		MOVD    $tanhxmone<>+0(SB), R1
    98		FMOVD   0(R1), F0
    99		FMOVD   F0, ret+8(FP)
   100		RET
   101	
   102	L3:
   103		FADD    F4, F2
   104		FMOVD   tanhrodataL18<>+80(SB), F4
   105		FMADD   F4, F2, F0
   106		FMOVD   tanhrodataL18<>+72(SB), F1
   107		WFMDB   V0, V0, V3
   108		FMOVD   tanhrodataL18<>+64(SB), F2
   109		WFMADB  V0, V1, V2, V1
   110		FMOVD   tanhrodataL18<>+56(SB), F4
   111		FMOVD   tanhrodataL18<>+48(SB), F2
   112		WFMADB  V1, V3, V4, V1
   113		FMOVD   tanhrodataL18<>+40(SB), F4
   114		WFMADB  V3, V2, V4, V2
   115		FMOVD   tanhrodataL18<>+32(SB), F4
   116		WORD    $0xB9270022     //lhr %r2,%r2
   117		WFMADB  V3, V1, V4, V1
   118		FMOVD   tanhrodataL18<>+24(SB), F4
   119		WFMADB  V3, V2, V4, V3
   120		WFMADB  V0, V5, V0, V2
   121		WFMADB  V0, V1, V3, V0
   122		WORD    $0xA7183ECF     //lhi %r1,16079
   123		WFMADB  V0, V2, V5, V2
   124		FMUL    F6, F2
   125		MOVW    R2, R10
   126		MOVW    R1, R11
   127		CMPBLE  R10, R11, L16
   128		FMOVD   F6, F0
   129		WORD    $0xED005010     //adb %f0,.L28-.L18(%r5)
   130		BYTE    $0x00
   131		BYTE    $0x1A
   132		WORD    $0xA7184330     //lhi %r1,17200
   133		FADD    F2, F0
   134		MOVW    R2, R10
   135		MOVW    R1, R11
   136		CMPBGT  R10, R11, L17
   137		WORD    $0xED605010     //sdb %f6,.L28-.L18(%r5)
   138		BYTE    $0x00
   139		BYTE    $0x1B
   140		FADD    F6, F2
   141		WFDDB   V0, V2, V0
   142		FMOVD   F0, ret+8(FP)
   143		RET
   144	
   145	L9:
   146		FMOVD   tanhrodataL18<>+16(SB), F0
   147	L1:
   148		FMOVD   F0, ret+8(FP)
   149		RET
   150	
   151	L15:
   152		FNEG    F0, F1
   153		BR      L2
   154	L16:
   155		FADD    F6, F2
   156		FMOVD   tanhrodataL18<>+8(SB), F0
   157		FMADD   F4, F2, F0
   158		FMOVD   tanhrodataL18<>+0(SB), F4
   159		FNEG    F0, F0
   160		WFMADB  V0, V2, V4, V0
   161		FMOVD   F0, ret+8(FP)
   162		RET
   163	
   164	L17:
   165		WFDDB   V0, V4, V0
   166		FMOVD   tanhrodataL18<>+16(SB), F2
   167		WFSDB   V0, V2, V0
   168		FMOVD   F0, ret+8(FP)
   169		RET
   170	
   171	tanhIsZero:      //return ±0
   172		FMOVD   F0, ret+8(FP)
   173		RET

View as plain text