Text file
src/math/floor_loong64.s
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 // derived from math/floor_riscv64.s
6
7 #include "textflag.h"
8
9 #define ROUNDFN(NAME, FUNC) \
10 TEXT NAME(SB),NOSPLIT,$0; \
11 MOVD x+0(FP), F0; \
12 MOVV F0, R11; \
13 /* 1023: bias of exponent, [-2^53, 2^53]: exactly integer represent range */; \
14 MOVV $1023+53, R12; \
15 /* Drop all fraction bits */; \
16 SRLV $52, R11, R11; \
17 /* Remove sign bit */; \
18 AND $0x7FF, R11, R11; \
19 BLTU R12, R11, isExtremum; \
20 normal:; \
21 FUNC F0, F2; \
22 MOVV F2, R10; \
23 BEQ R10, R0, is0; \
24 FFINTDV F2, F0; \
25 /* Return either input is +-Inf, NaN(0x7FF) or out of precision limitation */; \
26 isExtremum:; \
27 MOVD F0, ret+8(FP); \
28 RET; \
29 is0:; \
30 FCOPYSGD F0, F2, F2; \
31 MOVD F2, ret+8(FP); \
32 RET
33
34 // func archFloor(x float64) float64
35 ROUNDFN(·archFloor, FTINTRMVD)
36
37 // func archCeil(x float64) float64
38 ROUNDFN(·archCeil, FTINTRPVD)
39
40 // func archTrunc(x float64) float64
41 ROUNDFN(·archTrunc, FTINTRZVD)
42
View as plain text