diff options
author | Joel Sing <joel@sing.id.au> | 2019-11-04 04:58:37 +1100 |
---|---|---|
committer | Joel Sing <joel@sing.id.au> | 2020-01-19 14:04:09 +0000 |
commit | 8e0be05ec7c369387c0ed3c9cf37968c6d3afbbd (patch) | |
tree | a52a3963edf41ea1960b0c018d047ecfe0756460 /src/runtime/memmove_riscv64.s | |
parent | cbaa666682386fe5350bf87d7d70171704c90fe4 (diff) | |
download | go-8e0be05ec7c369387c0ed3c9cf37968c6d3afbbd.tar.gz go-8e0be05ec7c369387c0ed3c9cf37968c6d3afbbd.zip |
runtime: add support for linux/riscv64
Based on riscv-go port.
Updates #27532
Change-Id: If522807a382130be3c8d40f4b4c1131d1de7c9e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/204632
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/runtime/memmove_riscv64.s')
-rwxr-xr-x | src/runtime/memmove_riscv64.s | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/runtime/memmove_riscv64.s b/src/runtime/memmove_riscv64.s new file mode 100755 index 0000000000..34e513cda7 --- /dev/null +++ b/src/runtime/memmove_riscv64.s @@ -0,0 +1,96 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +#include "textflag.h" + +// void runtime·memmove(void*, void*, uintptr) +TEXT runtime·memmove(SB),NOSPLIT,$-0-24 + MOV to+0(FP), T0 + MOV from+8(FP), T1 + MOV n+16(FP), T2 + ADD T1, T2, T5 + + // If the destination is ahead of the source, start at the end of the + // buffer and go backward. + BLTU T1, T0, b + + // If less than eight bytes, do one byte at a time. + SLTU $8, T2, T3 + BNE T3, ZERO, f_outcheck + + // Do one byte at a time until from is eight-aligned. + JMP f_aligncheck +f_align: + MOVB (T1), T3 + MOVB T3, (T0) + ADD $1, T0 + ADD $1, T1 +f_aligncheck: + AND $7, T1, T3 + BNE T3, ZERO, f_align + + // Do eight bytes at a time as long as there is room. + ADD $-7, T5, T6 + JMP f_wordscheck +f_words: + MOV (T1), T3 + MOV T3, (T0) + ADD $8, T0 + ADD $8, T1 +f_wordscheck: + SLTU T6, T1, T3 + BNE T3, ZERO, f_words + + // Finish off the remaining partial word. + JMP f_outcheck +f_out: + MOVB (T1), T3 + MOVB T3, (T0) + ADD $1, T0 + ADD $1, T1 +f_outcheck: + BNE T1, T5, f_out + + RET + +b: + ADD T0, T2, T4 + // If less than eight bytes, do one byte at a time. + SLTU $8, T2, T3 + BNE T3, ZERO, b_outcheck + + // Do one byte at a time until from+n is eight-aligned. + JMP b_aligncheck +b_align: + ADD $-1, T4 + ADD $-1, T5 + MOVB (T5), T3 + MOVB T3, (T4) +b_aligncheck: + AND $7, T5, T3 + BNE T3, ZERO, b_align + + // Do eight bytes at a time as long as there is room. + ADD $7, T1, T6 + JMP b_wordscheck +b_words: + ADD $-8, T4 + ADD $-8, T5 + MOV (T5), T3 + MOV T3, (T4) +b_wordscheck: + SLTU T5, T6, T3 + BNE T3, ZERO, b_words + + // Finish off the remaining partial word. + JMP b_outcheck +b_out: + ADD $-1, T4 + ADD $-1, T5 + MOVB (T5), T3 + MOVB T3, (T4) +b_outcheck: + BNE T5, T1, b_out + + RET |