github.com/primecitizens/pcz/std@v0.2.1/core/mem/clear_arm.s (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 // 4 // Inferno's libkern/memset-arm.s 5 // https://bitbucket.org/inferno-os/inferno-os/src/master/libkern/memset-arm.s 6 // 7 // Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. 8 // Revisions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved. 9 // Portions Copyright 2009 The Go Authors. All rights reserved. 10 // 11 // Permission is hereby granted, free of charge, to any person obtaining a copy 12 // of this software and associated documentation files (the "Software"), to deal 13 // in the Software without restriction, including without limitation the rights 14 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 // copies of the Software, and to permit persons to whom the Software is 16 // furnished to do so, subject to the following conditions: 17 // 18 // The above copyright notice and this permission notice shall be included in 19 // all copies or substantial portions of the Software. 20 // 21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 // THE SOFTWARE. 28 29 //go:build pcz && arm 30 31 #include "textflag.h" 32 33 #define TO R8 34 #define TOE R11 35 #define N R12 36 #define TMP R12 /* N and TMP don't overlap */ 37 38 // See memclrNoHeapPointers Go doc for important implementation constraints. 39 40 // func Clear(ptr unsafe.Pointer, n uintptr) 41 // Also called from assembly in sys_windows_arm.s without g (but using Go stack convention). 42 TEXT ·Clear(SB),NOSPLIT,$0-8 43 MOVW ptr+0(FP), TO 44 MOVW n+4(FP), N 45 MOVW $0, R0 46 47 ADD N, TO, TOE /* to end pointer */ 48 49 CMP $4, N /* need at least 4 bytes to copy */ 50 BLT _1tail 51 52 _4align: /* align on 4 */ 53 AND.S $3, TO, TMP 54 BEQ _4aligned 55 56 MOVBU.P R0, 1(TO) /* implicit write back */ 57 B _4align 58 59 _4aligned: 60 SUB $31, TOE, TMP /* do 32-byte chunks if possible */ 61 CMP TMP, TO 62 BHS _4tail 63 64 MOVW R0, R1 /* replicate */ 65 MOVW R0, R2 66 MOVW R0, R3 67 MOVW R0, R4 68 MOVW R0, R5 69 MOVW R0, R6 70 MOVW R0, R7 71 72 _f32loop: 73 CMP TMP, TO 74 BHS _4tail 75 76 MOVM.IA.W [R0-R7], (TO) 77 B _f32loop 78 79 _4tail: 80 SUB $3, TOE, TMP /* do remaining words if possible */ 81 _4loop: 82 CMP TMP, TO 83 BHS _1tail 84 85 MOVW.P R0, 4(TO) /* implicit write back */ 86 B _4loop 87 88 _1tail: 89 CMP TO, TOE 90 BEQ _return 91 92 MOVBU.P R0, 1(TO) /* implicit write back */ 93 B _1tail 94 95 _return: 96 RET