Skip to content

Commit fe70838

Browse files
4a6f656cgriesemer
authored andcommitted
math/big: initial vector arithmetic in riscv64 assembly
Provide an assembly implementation of mulWW - for now all others run the Go code. Change-Id: Icb594c31048255f131bdea8d64f56784fc9db4d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/220919 Reviewed-by: Robert Griesemer <[email protected]>
1 parent 89f249a commit fe70838

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

src/math/big/arith_decl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build !math_big_pure_go,!riscv64
5+
// +build !math_big_pure_go
66

77
package big
88

src/math/big/arith_decl_pure.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
// +build math_big_pure_go riscv64
5+
// +build math_big_pure_go
66

77
package big
88

src/math/big/arith_riscv64.s

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2020 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+
// +build !math_big_pure_go,riscv64
6+
7+
#include "textflag.h"
8+
9+
// This file provides fast assembly versions for the elementary
10+
// arithmetic operations on vectors implemented in arith.go.
11+
12+
// func mulWW(x, y Word) (z1, z0 Word)
13+
TEXT ·mulWW(SB),NOSPLIT,$0
14+
MOV x+0(FP), X5
15+
MOV y+8(FP), X6
16+
MULHU X5, X6, X7
17+
MUL X5, X6, X8
18+
MOV X7, z1+16(FP)
19+
MOV X8, z0+24(FP)
20+
RET
21+
22+
// func divWW(x1, x0, y Word) (q, r Word)
23+
TEXT ·divWW(SB),NOSPLIT,$0
24+
JMP ·divWW_g(SB) // riscv64 has no multiword division
25+
26+
TEXT ·addVV(SB),NOSPLIT,$0
27+
JMP ·addVV_g(SB)
28+
29+
TEXT ·subVV(SB),NOSPLIT,$0
30+
JMP ·subVV_g(SB)
31+
32+
TEXT ·addVW(SB),NOSPLIT,$0
33+
JMP ·addVW_g(SB)
34+
35+
TEXT ·subVW(SB),NOSPLIT,$0
36+
JMP ·subVW_g(SB)
37+
38+
TEXT ·shlVU(SB),NOSPLIT,$0
39+
JMP ·shlVU_g(SB)
40+
41+
TEXT ·shrVU(SB),NOSPLIT,$0
42+
JMP ·shrVU_g(SB)
43+
44+
TEXT ·mulAddVWW(SB),NOSPLIT,$0
45+
JMP ·mulAddVWW_g(SB)
46+
47+
TEXT ·addMulVVW(SB),NOSPLIT,$0
48+
JMP ·addMulVVW_g(SB)
49+
50+
TEXT ·divWVW(SB),NOSPLIT,$0
51+
JMP ·divWVW_g(SB)

0 commit comments

Comments
 (0)