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 ·Max(x, y float64) float64
14TEXT ·archMax(SB),NOSPLIT,$0
15 // +Inf special cases
16 MOVD $PosInf, R4
17 MOVD x+0(FP), R8
18 CMPUBEQ R4, R8, isPosInf
19 MOVD y+8(FP), R9
20 CMPUBEQ R4, R9, isPosInf
21 // NaN special cases
22 MOVD $~(1<<63), R5 // bit mask
23 MOVD $PosInf, R4
24 MOVD R8, R2
25 AND R5, R2 // x = |x|
26 CMPUBLT R4, R2, isMaxNaN
27 MOVD R9, R3
28 AND R5, R3 // y = |y|
29 CMPUBLT R4, R3, isMaxNaN
30 // ±0 special cases
31 OR R3, R2
32 BEQ isMaxZero
33
34 FMOVD x+0(FP), F1
35 FMOVD y+8(FP), F2
36 FCMPU F2, F1
37 BGT +3(PC)
38 FMOVD F1, ret+16(FP)
39 RET
40 FMOVD F2, ret+16(FP)
41 RET
42isMaxNaN: // return NaN
43 MOVD $NaN, R4
44isPosInf: // return +Inf
45 MOVD R4, ret+16(FP)
46 RET
47isMaxZero:
48 MOVD $(1<<63), R4 // -0.0
49 CMPUBEQ R4, R8, +3(PC)
50 MOVD R8, ret+16(FP) // return 0
51 RET
52 MOVD R9, ret+16(FP) // return other 0
53 RET
54
55// func archMin(x, y float64) float64
56TEXT ·archMin(SB),NOSPLIT,$0
57 // -Inf special cases
58 MOVD $NegInf, R4
59 MOVD x+0(FP), R8
60 CMPUBEQ R4, R8, isNegInf
61 MOVD y+8(FP), R9
62 CMPUBEQ R4, R9, isNegInf
63 // NaN special cases
64 MOVD $~(1<<63), R5
65 MOVD $PosInf, R4
66 MOVD R8, R2
67 AND R5, R2 // x = |x|
68 CMPUBLT R4, R2, isMinNaN
69 MOVD R9, R3
70 AND R5, R3 // y = |y|
71 CMPUBLT R4, R3, isMinNaN
72 // ±0 special cases
73 OR R3, R2
74 BEQ isMinZero
75
76 FMOVD x+0(FP), F1
77 FMOVD y+8(FP), F2
78 FCMPU F2, F1
79 BLT +3(PC)
80 FMOVD F1, ret+16(FP)
81 RET
82 FMOVD F2, ret+16(FP)
83 RET
84isMinNaN: // return NaN
85 MOVD $NaN, R4
86isNegInf: // return -Inf
87 MOVD R4, ret+16(FP)
88 RET
89isMinZero:
90 MOVD $(1<<63), R4 // -0.0
91 CMPUBEQ R4, R8, +3(PC)
92 MOVD R9, ret+16(FP) // return other 0
93 RET
94 MOVD R8, ret+16(FP) // return -0
95 RET
96
View as plain text