| 1 |
// Copyright 2024 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 |
#define PosInf 0x7FF0000000000000 |
| 8 |
#define NaN 0x7FF8000000000001 |
| 9 |
#define NegInf 0xFFF0000000000000 |
| 10 |
|
| 11 |
TEXT ·archMax(SB),NOSPLIT,$0 |
| 12 |
MOVD x+0(FP), F0 |
| 13 |
MOVD y+8(FP), F1 |
| 14 |
FCLASSD F0, F2 |
| 15 |
FCLASSD F1, F3 |
| 16 |
|
| 17 |
// combine x and y categories together to judge |
| 18 |
MOVV F2, R4 |
| 19 |
MOVV F3, R5 |
| 20 |
OR R5, R4 |
| 21 |
|
| 22 |
// +Inf special cases |
| 23 |
AND $64, R4, R5 |
| 24 |
BNE R5, isPosInf |
| 25 |
|
| 26 |
// NaN special cases |
| 27 |
AND $2, R4, R5 |
| 28 |
BNE R5, isMaxNaN |
| 29 |
|
| 30 |
// normal case |
| 31 |
FMAXD F0, F1, F0 |
| 32 |
MOVD F0, ret+16(FP) |
| 33 |
RET |
| 34 |
|
| 35 |
isMaxNaN: |
| 36 |
MOVV $NaN, R6 |
| 37 |
MOVV R6, ret+16(FP) |
| 38 |
RET |
| 39 |
|
| 40 |
isPosInf: |
| 41 |
MOVV $PosInf, R6 |
| 42 |
MOVV R6, ret+16(FP) |
| 43 |
RET |
| 44 |
|
| 45 |
TEXT ·archMin(SB),NOSPLIT,$0 |
| 46 |
MOVD x+0(FP), F0 |
| 47 |
MOVD y+8(FP), F1 |
| 48 |
FCLASSD F0, F2 |
| 49 |
FCLASSD F1, F3 |
| 50 |
|
| 51 |
// combine x and y categories together to judge |
| 52 |
MOVV F2, R4 |
| 53 |
MOVV F3, R5 |
| 54 |
OR R5, R4 |
| 55 |
|
| 56 |
// -Inf special cases |
| 57 |
AND $4, R4, R5 |
| 58 |
BNE R5, isNegInf |
| 59 |
|
| 60 |
// NaN special cases |
| 61 |
AND $2, R4, R5 |
| 62 |
BNE R5, isMinNaN |
| 63 |
|
| 64 |
// normal case |
| 65 |
FMIND F0, F1, F0 |
| 66 |
MOVD F0, ret+16(FP) |
| 67 |
RET |
| 68 |
|
| 69 |
isMinNaN: |
| 70 |
MOVV $NaN, R6 |
| 71 |
MOVV R6, ret+16(FP) |
| 72 |
RET |
| 73 |
|
| 74 |
isNegInf: |
| 75 |
MOVV $NegInf, R6 |
| 76 |
MOVV R6, ret+16(FP) |
| 77 |
RET |