File tree 3 files changed +43
-2
lines changed
3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change 2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
- //go:build 386 || amd64 || arm64 || ppc64 || ppc64le || riscv64 || s390x || wasm
5
+ //go:build 386 || amd64 || arm64 || loong64 || ppc64 || ppc64le || riscv64 || s390x || wasm
6
6
7
7
package math
8
8
Original file line number Diff line number Diff line change
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)
Original file line number Diff line number Diff line change 2
2
// Use of this source code is governed by a BSD-style
3
3
// license that can be found in the LICENSE file.
4
4
5
- //go:build !386 && !amd64 && !arm64 && !ppc64 && !ppc64le && !riscv64 && !s390x && !wasm
5
+ //go:build !386 && !amd64 && !arm64 && !loong64 && ! ppc64 && !ppc64le && !riscv64 && !s390x && !wasm
6
6
7
7
package math
8
8
You can’t perform that action at this time.
0 commit comments