github.com/primecitizens/pcz/std@v0.2.1/core/mem/equal_s390x.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Copyright 2018 The Go Authors. All rights reserved. 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file. 7 8 //go:build pcz && s390x 9 10 #include "textflag.h" 11 12 // Equal(a, b unsafe.Pointer, size uintptr) bool 13 TEXT ·Equal(SB),NOSPLIT|NOFRAME,$0-25 14 MOVD a+0(FP), R3 15 MOVD b+8(FP), R5 16 MOVD size+16(FP), R6 17 LA ret+24(FP), R7 18 BR memeqbody<>(SB) 19 20 // memequal_varlen(a, b unsafe.Pointer) bool 21 TEXT runtime·memequal_varlen(SB),NOSPLIT|NOFRAME,$0-17 22 MOVD a+0(FP), R3 23 MOVD b+8(FP), R5 24 MOVD 8(R12), R6 // compiler stores size at offset 8 in the closure 25 LA ret+16(FP), R7 26 BR memeqbody<>(SB) 27 28 // input: 29 // R3 = a 30 // R5 = b 31 // R6 = len 32 // R7 = address of output byte (stores 0 or 1 here) 33 // a and b have the same length 34 TEXT memeqbody<>(SB),NOSPLIT|NOFRAME,$0-0 35 CMPBEQ R3, R5, equal 36 loop: 37 CMPBEQ R6, $0, equal 38 CMPBLT R6, $32, tiny 39 CMP R6, $256 40 BLT tail 41 CLC $256, 0(R3), 0(R5) 42 BNE notequal 43 SUB $256, R6 44 LA 256(R3), R3 45 LA 256(R5), R5 46 BR loop 47 tail: 48 SUB $1, R6, R8 49 EXRL $memeqbodyclc<>(SB), R8 50 BEQ equal 51 notequal: 52 MOVB $0, 0(R7) 53 RET 54 equal: 55 MOVB $1, 0(R7) 56 RET 57 tiny: 58 MOVD $0, R2 59 CMPBLT R6, $16, lt16 60 MOVD 0(R3), R8 61 MOVD 0(R5), R9 62 CMPBNE R8, R9, notequal 63 MOVD 8(R3), R8 64 MOVD 8(R5), R9 65 CMPBNE R8, R9, notequal 66 LA 16(R2), R2 67 SUB $16, R6 68 lt16: 69 CMPBLT R6, $8, lt8 70 MOVD 0(R3)(R2*1), R8 71 MOVD 0(R5)(R2*1), R9 72 CMPBNE R8, R9, notequal 73 LA 8(R2), R2 74 SUB $8, R6 75 lt8: 76 CMPBLT R6, $4, lt4 77 MOVWZ 0(R3)(R2*1), R8 78 MOVWZ 0(R5)(R2*1), R9 79 CMPBNE R8, R9, notequal 80 LA 4(R2), R2 81 SUB $4, R6 82 lt4: 83 #define CHECK(n) \ 84 CMPBEQ R6, $n, equal \ 85 MOVB n(R3)(R2*1), R8 \ 86 MOVB n(R5)(R2*1), R9 \ 87 CMPBNE R8, R9, notequal 88 CHECK(0) 89 CHECK(1) 90 CHECK(2) 91 CHECK(3) 92 BR equal 93 94 TEXT memeqbodyclc<>(SB),NOSPLIT|NOFRAME,$0-0 95 CLC $1, 0(R3), 0(R5) 96 RET