diff options
Diffstat (limited to 'src/runtime/mkduff.go')
| -rw-r--r-- | src/runtime/mkduff.go | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/runtime/mkduff.go b/src/runtime/mkduff.go index 8859ed68cc..94ae75fbfe 100644 --- a/src/runtime/mkduff.go +++ b/src/runtime/mkduff.go @@ -27,8 +27,8 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "log" + "os" ) func main() { @@ -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)) { @@ -53,7 +54,7 @@ func gen(arch string, tags, zero, copy func(io.Writer)) { fmt.Fprintln(&buf) copy(&buf) - if err := ioutil.WriteFile("duff_"+arch+".s", buf.Bytes(), 0644); err != nil { + if err := os.WriteFile("duff_"+arch+".s", buf.Bytes(), 0644); err != nil { log.Fatalln(err) } } @@ -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") +} |
