github.com/comwrg/go/src@v0.0.0-20220319063731-c238d0440370/runtime/memclr_mipsx.s (about) 1 // Copyright 2016 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build mips || mipsle 6 // +build mips mipsle 7 8 #include "textflag.h" 9 10 #ifdef GOARCH_mips 11 #define MOVWHI MOVWL 12 #define MOVWLO MOVWR 13 #else 14 #define MOVWHI MOVWR 15 #define MOVWLO MOVWL 16 #endif 17 18 // See memclrNoHeapPointers Go doc for important implementation constraints. 19 20 // func memclrNoHeapPointers(ptr unsafe.Pointer, n uintptr) 21 TEXT runtime·memclrNoHeapPointers(SB),NOSPLIT,$0-8 22 MOVW n+4(FP), R2 23 MOVW ptr+0(FP), R1 24 25 SGTU $4, R2, R3 26 ADDU R2, R1, R4 27 BNE R3, small_zero 28 29 ptr_align: 30 AND $3, R1, R3 31 BEQ R3, setup 32 SUBU R1, R0, R3 33 AND $3, R3 // R3 contains number of bytes needed to align ptr 34 MOVWHI R0, 0(R1) // MOVWHI will write zeros up to next word boundary 35 SUBU R3, R2 36 ADDU R3, R1 37 38 setup: 39 AND $31, R2, R6 40 AND $3, R2, R5 41 SUBU R6, R4, R6 // end pointer for 32-byte chunks 42 SUBU R5, R4, R5 // end pointer for 4-byte chunks 43 44 large: 45 BEQ R1, R6, words 46 MOVW R0, 0(R1) 47 MOVW R0, 4(R1) 48 MOVW R0, 8(R1) 49 MOVW R0, 12(R1) 50 MOVW R0, 16(R1) 51 MOVW R0, 20(R1) 52 MOVW R0, 24(R1) 53 MOVW R0, 28(R1) 54 ADDU $32, R1 55 JMP large 56 57 words: 58 BEQ R1, R5, tail 59 MOVW R0, 0(R1) 60 ADDU $4, R1 61 JMP words 62 63 tail: 64 BEQ R1, R4, ret 65 MOVWLO R0, -1(R4) 66 67 ret: 68 RET 69 70 small_zero: 71 BEQ R1, R4, ret 72 MOVB R0, 0(R1) 73 ADDU $1, R1 74 JMP small_zero