From c83b5fefabe514ce5315135621b962f120277d23 Mon Sep 17 00:00:00 2001 From: Guoqi Chen Date: Wed, 16 Aug 2023 09:05:30 +0800 Subject: [PATCH] runtime: add regABI support in memclr and memmove functions on loong64 Update #40724 Co-authored-by: Xiaolin Zhao Change-Id: I55c78bab5c697ea6c30f9d81f5f8fb75abb3987c Reviewed-on: https://go-review.googlesource.com/c/go/+/521786 TryBot-Result: Gopher Robot Reviewed-by: Cherry Mui Reviewed-by: Meidan Li Run-TryBot: David Chase Auto-Submit: David Chase Reviewed-by: David Chase --- src/runtime/memclr_loong64.s | 32 +++++++++++++++++--------------- src/runtime/memmove_loong64.s | 4 +++- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/runtime/memclr_loong64.s b/src/runtime/memclr_loong64.s index 7bb6f3dfc9..313e4d4f33 100644 --- a/src/runtime/memclr_loong64.s +++ b/src/runtime/memclr_loong64.s @@ -6,37 +6,39 @@ #include "textflag.h" // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) -TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16 - MOVV ptr+0(FP), R6 - MOVV n+8(FP), R7 - ADDV R6, R7, R4 +TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-16 +#ifndef GOEXPERIMENT_regabiargs + MOVV ptr+0(FP), R4 + MOVV n+8(FP), R5 +#endif + ADDV R4, R5, R6 // if less than 8 bytes, do one byte at a time - SGTU $8, R7, R8 + SGTU $8, R5, R8 BNE R8, out // do one byte at a time until 8-aligned - AND $7, R6, R8 + AND $7, R4, R8 BEQ R8, words - MOVB R0, (R6) - ADDV $1, R6 + MOVB R0, (R4) + ADDV $1, R4 JMP -4(PC) words: // do 8 bytes at a time if there is room - ADDV $-7, R4, R7 + ADDV $-7, R6, R5 PCALIGN $16 - SGTU R7, R6, R8 + SGTU R5, R4, R8 BEQ R8, out - MOVV R0, (R6) - ADDV $8, R6 + MOVV R0, (R4) + ADDV $8, R4 JMP -4(PC) out: - BEQ R6, R4, done - MOVB R0, (R6) - ADDV $1, R6 + BEQ R4, R6, done + MOVB R0, (R4) + ADDV $1, R4 JMP -3(PC) done: RET diff --git a/src/runtime/memmove_loong64.s b/src/runtime/memmove_loong64.s index 0f139bcc13..5b7aeba698 100644 --- a/src/runtime/memmove_loong64.s +++ b/src/runtime/memmove_loong64.s @@ -7,10 +7,12 @@ // See memmove Go doc for important implementation constraints. // func memmove(to, from unsafe.Pointer, n uintptr) -TEXT runtime·memmove(SB), NOSPLIT|NOFRAME, $0-24 +TEXT runtime·memmove(SB), NOSPLIT|NOFRAME, $0-24 +#ifndef GOEXPERIMENT_regabiargs MOVV to+0(FP), R4 MOVV from+8(FP), R5 MOVV n+16(FP), R6 +#endif BNE R6, check RET -- 2.48.1