From: Lynn Boger Date: Tue, 21 Sep 2021 14:36:40 +0000 (-0500) Subject: internal/bytealg: port bytealg functions to reg ABI on ppc64x X-Git-Tag: go1.18beta1~1137 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=b8a601756abdb6f1503e41d86c122c4e7c7409ff;p=gostls13.git internal/bytealg: port bytealg functions to reg ABI on ppc64x This adds support for the reg ABI to the bytes functions for ppc64/ppc64le. These are initially under control of the GOEXPERIMENT macro until all changes are in. Change-Id: Id82f31056af8caa8541e27c6735f6b815a5dbf5a Reviewed-on: https://go-review.googlesource.com/c/go/+/351190 Trust: Lynn Boger Reviewed-by: Cherry Mui --- diff --git a/src/internal/bytealg/compare_ppc64x.s b/src/internal/bytealg/compare_ppc64x.s index 83444fa826..390a72688b 100644 --- a/src/internal/bytealg/compare_ppc64x.s +++ b/src/internal/bytealg/compare_ppc64x.s @@ -8,64 +8,99 @@ #include "go_asm.h" #include "textflag.h" -TEXT ·Compare(SB),NOSPLIT|NOFRAME,$0-56 +TEXT ·Compare(SB),NOSPLIT|NOFRAME,$0-56 +#ifdef GOEXPERIMENT_regabiargs +// incoming: +// R3 a addr -> R5 +// R4 a len -> R3 +// R5 a cap unused +// R6 b addr -> R6 +// R7 b len -> R4 +// R8 b cap unused + MOVD R3, R5 + MOVD R4, R3 + MOVD R7, R4 +#else MOVD a_base+0(FP), R5 MOVD b_base+24(FP), R6 MOVD a_len+8(FP), R3 - CMP R5,R6,CR7 MOVD b_len+32(FP), R4 MOVD $ret+48(FP), R7 +#endif + CMP R5,R6,CR7 CMP R3,R4,CR6 BEQ CR7,equal - #ifdef GOARCH_ppc64le BR cmpbodyLE<>(SB) #else BR cmpbodyBE<>(SB) #endif - equal: BEQ CR6,done MOVD $1, R8 BGT CR6,greater NEG R8 - greater: +#ifdef GOEXPERIMENT_regabiargs + MOVD R8, R3 +#else MOVD R8, (R7) +#endif RET - done: +#ifdef GOEXPERIMENT_regabiargs + MOVD $0, R3 +#else MOVD $0, (R7) +#endif RET -TEXT runtime·cmpstring(SB),NOSPLIT|NOFRAME,$0-40 +TEXT runtime·cmpstring(SB),NOSPLIT|NOFRAME,$0-40 +#ifdef GOEXPERIMENT_regabiargs +// incoming: +// R3 a addr -> R5 +// R4 a len -> R3 +// R5 b addr -> R6 +// R6 b len -> R4 + MOVD R6, R7 + MOVD R5, R6 + MOVD R3, R5 + MOVD R4, R3 + MOVD R7, R4 +#else MOVD a_base+0(FP), R5 MOVD b_base+16(FP), R6 MOVD a_len+8(FP), R3 - CMP R5,R6,CR7 MOVD b_len+24(FP), R4 MOVD $ret+32(FP), R7 +#endif + CMP R5,R6,CR7 CMP R3,R4,CR6 BEQ CR7,equal - #ifdef GOARCH_ppc64le BR cmpbodyLE<>(SB) #else BR cmpbodyBE<>(SB) #endif - equal: BEQ CR6,done MOVD $1, R8 BGT CR6,greater NEG R8 - greater: +#ifdef GOEXPERIMENT_regabiargs + MOVD R8, R3 +#else MOVD R8, (R7) +#endif RET done: +#ifdef GOEXPERIMENT_regabiargs + MOVD $0, R3 +#else MOVD $0, (R7) +#endif RET // Do an efficient memcmp for ppc64le @@ -73,7 +108,7 @@ done: // R4 = b len // R5 = a addr // R6 = b addr -// R7 = addr of return value +// R7 = addr of return value if not regabi TEXT cmpbodyLE<>(SB),NOSPLIT|NOFRAME,$0-0 MOVD R3,R8 // set up length CMP R3,R4,CR2 // unequal? @@ -168,14 +203,22 @@ cmpne: // only here is not equal BGT greater // here only if NE less: MOVD $-1,R3 +#ifndef GOEXPERIMENT_regabiargs MOVD R3,(R7) // return value if A < B +#endif RET equal: +#ifdef GOEXPERIMENT_regabiargs + MOVD $0, R3 +#else MOVD $0,(R7) // return value if A == B +#endif RET greater: MOVD $1,R3 +#ifndef GOEXPERIMENT_regabiargs MOVD R3,(R7) // return value if A > B +#endif RET // Do an efficient memcmp for ppc64 (BE) @@ -267,12 +310,20 @@ simple: BC 12,9,greater // 2nd len > 1st len less: MOVD $-1,R3 +#ifndef GOEXPERIMENT_regabiargs MOVD R3,(R7) // return value if A < B +#endif RET equal: +#ifdef GOEXPERIMENT_regabiargs + MOVD $0, R3 +#else MOVD $0,(R7) // return value if A == B +#endif RET greater: MOVD $1,R3 +#ifndef GOEXPERIMENT_regabiargs MOVD R3,(R7) // return value if A > B +#endif RET diff --git a/src/internal/bytealg/equal_ppc64x.s b/src/internal/bytealg/equal_ppc64x.s index 5f0fea521b..d59154101a 100644 --- a/src/internal/bytealg/equal_ppc64x.s +++ b/src/internal/bytealg/equal_ppc64x.s @@ -9,33 +9,38 @@ #include "textflag.h" // memequal(a, b unsafe.Pointer, size uintptr) bool -TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-25 +TEXT runtime·memequal(SB),NOSPLIT|NOFRAME,$0-25 +#ifndef GOEXPERIMENT_regabiargs MOVD a+0(FP), R3 MOVD b+8(FP), R4 MOVD size+16(FP), R5 MOVD $ret+24(FP), R10 - +#endif BR memeqbody<>(SB) // memequal_varlen(a, b unsafe.Pointer) bool -TEXT runtime·memequal_varlen(SB),NOSPLIT|NOFRAME,$0-17 +TEXT runtime·memequal_varlen(SB),NOSPLIT|NOFRAME,$0-17 +#ifndef GOEXPERIMENT_regabiargs MOVD a+0(FP), R3 MOVD b+8(FP), R4 + MOVD $ret+16(FP), R10 +#endif CMP R3, R4 BEQ eq MOVD 8(R11), R5 // compiler stores size at offset 8 in the closure - MOVD $ret+16(FP), R10 BR memeqbody<>(SB) eq: MOVD $1, R3 +#ifndef GOEXPERIMENT_regabiargs MOVB R3, ret+16(FP) +#endif RET // Do an efficient memequal for ppc64 // R3 = s1 // R4 = s2 // R5 = len -// R10 = addr of return value (byte) +// R10 = addr of return value (byte) when not regabi TEXT memeqbody<>(SB),NOSPLIT|NOFRAME,$0-0 MOVD R5,CTR CMP R5,$8 // only optimize >=8 @@ -94,10 +99,16 @@ simple: BNE noteq BR equal noteq: +#ifdef GOEXPERIMENT_regabiargs + MOVD $0, R3 +#else MOVB $0, (R10) +#endif RET equal: MOVD $1, R3 +#ifndef GOEXPERIMENT_regabiargs MOVB R3, (R10) +#endif RET diff --git a/src/internal/bytealg/indexbyte_ppc64x.s b/src/internal/bytealg/indexbyte_ppc64x.s index 8e13c5a56e..27e1ad7e0d 100644 --- a/src/internal/bytealg/indexbyte_ppc64x.s +++ b/src/internal/bytealg/indexbyte_ppc64x.s @@ -8,20 +8,29 @@ #include "go_asm.h" #include "textflag.h" -TEXT ·IndexByte(SB),NOSPLIT|NOFRAME,$0-40 +TEXT ·IndexByte(SB),NOSPLIT|NOFRAME,$0-40 +#ifndef GOEXPERIMENT_regabiargs MOVD b_base+0(FP), R3 // R3 = byte array pointer MOVD b_len+8(FP), R4 // R4 = length MOVBZ c+24(FP), R5 // R5 = byte MOVD $ret+32(FP), R14 // R14 = &ret +#else + MOVD R6, R5 +#endif BR indexbytebody<>(SB) -TEXT ·IndexByteString(SB),NOSPLIT|NOFRAME,$0-32 +TEXT ·IndexByteString(SB),NOSPLIT|NOFRAME,$0-32 +#ifndef GOEXPERIMENT_regabiargs MOVD s_base+0(FP), R3 // R3 = string MOVD s_len+8(FP), R4 // R4 = length MOVBZ c+16(FP), R5 // R5 = byte MOVD $ret+24(FP), R14 // R14 = &ret +#endif BR indexbytebody<>(SB) - +// R3 = addr of string +// R4 = len of string +// R5 = byte to find +// R14 = addr of return value when not regabi TEXT indexbytebody<>(SB),NOSPLIT|NOFRAME,$0-0 MOVD R3,R17 // Save base address for calculating the index later. RLDICR $0,R3,$60,R8 // Align address to doubleword boundary in R8. @@ -186,7 +195,9 @@ tail: notfound: MOVD $-1,R3 +#ifndef GOEXPERIMENT_regabiargs MOVD R3,(R14) +#endif RET found: @@ -229,7 +240,9 @@ found: return: SUB R17,R3 +#ifndef GOEXPERIMENT_regabiargs MOVD R3,(R14) +#endif RET found_qw_align: