...
Run Format

Text file src/math/dim_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	// Based on dim_amd64.s
     6	
     7	#include "textflag.h"
     8	
     9	#define PosInf 0x7FF0000000000000
    10	#define NaN    0x7FF8000000000001
    11	#define NegInf 0xFFF0000000000000
    12	
    13	// func Dim(x, y float64) float64
    14	TEXT ·Dim(SB),NOSPLIT,$0
    15		// (+Inf, +Inf) special case
    16		MOVD    x+0(FP), R2
    17		MOVD    y+8(FP), R3
    18		MOVD    $PosInf, R4
    19		CMPUBNE R4, R2, dim2
    20		CMPUBEQ R4, R3, bothInf
    21	dim2:	// (-Inf, -Inf) special case
    22		MOVD    $NegInf, R4
    23		CMPUBNE R4, R2, dim3
    24		CMPUBEQ R4, R3, bothInf
    25	dim3:	// (NaN, x) or (x, NaN)
    26		MOVD    $~(1<<63), R5
    27		MOVD    $PosInf, R4
    28		AND     R5, R2 // x = |x|
    29		CMPUBLT R4, R2, isDimNaN
    30		AND     R5, R3 // y = |y|
    31		CMPUBLT R4, R3, isDimNaN
    32	
    33		FMOVD   x+0(FP), F1
    34		FMOVD   y+8(FP), F2
    35		FSUB    F2, F1
    36		FMOVD   $(0.0), F2
    37		FCMPU   F2, F1
    38		BGE     +3(PC)
    39		FMOVD   F1, ret+16(FP)
    40		RET
    41		FMOVD   F2, ret+16(FP)
    42		RET
    43	bothInf: // Dim(-Inf, -Inf) or Dim(+Inf, +Inf)
    44	isDimNaN:
    45		MOVD    $NaN, R4
    46		MOVD    R4, ret+16(FP)
    47		RET
    48	
    49	// func ·Max(x, y float64) float64
    50	TEXT ·Max(SB),NOSPLIT,$0
    51		// +Inf special cases
    52		MOVD    $PosInf, R4
    53		MOVD    x+0(FP), R8
    54		CMPUBEQ R4, R8, isPosInf
    55		MOVD    y+8(FP), R9
    56		CMPUBEQ R4, R9, isPosInf
    57		// NaN special cases
    58		MOVD    $~(1<<63), R5 // bit mask
    59		MOVD    $PosInf, R4
    60		MOVD    R8, R2
    61		AND     R5, R2 // x = |x|
    62		CMPUBLT R4, R2, isMaxNaN
    63		MOVD    R9, R3
    64		AND     R5, R3 // y = |y|
    65		CMPUBLT R4, R3, isMaxNaN
    66		// ±0 special cases
    67		OR      R3, R2
    68		BEQ     isMaxZero
    69	
    70		FMOVD   x+0(FP), F1
    71		FMOVD   y+8(FP), F2
    72		FCMPU   F2, F1
    73		BGT     +3(PC)
    74		FMOVD   F1, ret+16(FP)
    75		RET
    76		FMOVD   F2, ret+16(FP)
    77		RET
    78	isMaxNaN: // return NaN
    79		MOVD	$NaN, R4
    80	isPosInf: // return +Inf
    81		MOVD    R4, ret+16(FP)
    82		RET
    83	isMaxZero:
    84		MOVD    $(1<<63), R4 // -0.0
    85		CMPUBEQ R4, R8, +3(PC)
    86		MOVD    R8, ret+16(FP) // return 0
    87		RET
    88		MOVD    R9, ret+16(FP) // return other 0
    89		RET
    90	
    91	// func Min(x, y float64) float64
    92	TEXT ·Min(SB),NOSPLIT,$0
    93		// -Inf special cases
    94		MOVD    $NegInf, R4
    95		MOVD    x+0(FP), R8
    96		CMPUBEQ R4, R8, isNegInf
    97		MOVD    y+8(FP), R9
    98		CMPUBEQ R4, R9, isNegInf
    99		// NaN special cases
   100		MOVD    $~(1<<63), R5
   101		MOVD    $PosInf, R4
   102		MOVD    R8, R2
   103		AND     R5, R2 // x = |x|
   104		CMPUBLT R4, R2, isMinNaN
   105		MOVD    R9, R3
   106		AND     R5, R3 // y = |y|
   107		CMPUBLT R4, R3, isMinNaN
   108		// ±0 special cases
   109		OR      R3, R2
   110		BEQ     isMinZero
   111	
   112		FMOVD   x+0(FP), F1
   113		FMOVD   y+8(FP), F2
   114		FCMPU   F2, F1
   115		BLT     +3(PC)
   116		FMOVD   F1, ret+16(FP)
   117		RET
   118		FMOVD   F2, ret+16(FP)
   119		RET
   120	isMinNaN: // return NaN
   121		MOVD	$NaN, R4
   122	isNegInf: // return -Inf
   123		MOVD    R4, ret+16(FP)
   124		RET
   125	isMinZero:
   126		MOVD    $(1<<63), R4 // -0.0
   127		CMPUBEQ R4, R8, +3(PC)
   128		MOVD    R9, ret+16(FP) // return other 0
   129		RET
   130		MOVD    R8, ret+16(FP) // return -0
   131		RET
   132	

View as plain text