aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mkduff.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/runtime/mkduff.go')
-rw-r--r--src/runtime/mkduff.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/runtime/mkduff.go b/src/runtime/mkduff.go
index 8859ed68cc..6ddf0256e9 100644
--- a/src/runtime/mkduff.go
+++ b/src/runtime/mkduff.go
@@ -38,6 +38,7 @@ func main() {
gen("arm64", notags, zeroARM64, copyARM64)
gen("ppc64x", tagsPPC64x, zeroPPC64x, copyPPC64x)
gen("mips64x", tagsMIPS64x, zeroMIPS64x, copyMIPS64x)
+ gen("riscv64", notags, zeroRISCV64, copyRISCV64)
}
func gen(arch string, tags, zero, copy func(io.Writer)) {
@@ -227,3 +228,30 @@ func copyMIPS64x(w io.Writer) {
}
fmt.Fprintln(w, "\tRET")
}
+
+func zeroRISCV64(w io.Writer) {
+ // ZERO: always zero
+ // X10: ptr to memory to be zeroed
+ // X10 is updated as a side effect.
+ fmt.Fprintln(w, "TEXT runtime·duffzero(SB), NOSPLIT|NOFRAME, $0-0")
+ for i := 0; i < 128; i++ {
+ fmt.Fprintln(w, "\tMOV\tZERO, (X10)")
+ fmt.Fprintln(w, "\tADD\t$8, X10")
+ }
+ fmt.Fprintln(w, "\tRET")
+}
+
+func copyRISCV64(w io.Writer) {
+ // X10: ptr to source memory
+ // X11: ptr to destination memory
+ // X10 and X11 are updated as a side effect
+ fmt.Fprintln(w, "TEXT runtime·duffcopy(SB), NOSPLIT|NOFRAME, $0-0")
+ for i := 0; i < 128; i++ {
+ fmt.Fprintln(w, "\tMOV\t(X10), X31")
+ fmt.Fprintln(w, "\tADD\t$8, X10")
+ fmt.Fprintln(w, "\tMOV\tX31, (X11)")
+ fmt.Fprintln(w, "\tADD\t$8, X11")
+ fmt.Fprintln(w)
+ }
+ fmt.Fprintln(w, "\tRET")
+}