1*09ff5f3bSriastradh/* $NetBSD: atomic_xor.S,v 1.4 2022/04/06 22:47:56 riastradh Exp $ */ 2ce6031c2Smartin 3ce6031c2Smartin/*- 4ce6031c2Smartin * Copyright (c) 2007 The NetBSD Foundation, Inc. 5ce6031c2Smartin * All rights reserved. 6ce6031c2Smartin * 7ce6031c2Smartin * This code is derived from software contributed to The NetBSD Foundation 8ce6031c2Smartin * by Jason R. Thorpe. 9ce6031c2Smartin * 10ce6031c2Smartin * Redistribution and use in source and binary forms, with or without 11ce6031c2Smartin * modification, are permitted provided that the following conditions 12ce6031c2Smartin * are met: 13ce6031c2Smartin * 1. Redistributions of source code must retain the above copyright 14ce6031c2Smartin * notice, this list of conditions and the following disclaimer. 15ce6031c2Smartin * 2. Redistributions in binary form must reproduce the above copyright 16ce6031c2Smartin * notice, this list of conditions and the following disclaimer in the 17ce6031c2Smartin * documentation and/or other materials provided with the distribution. 18ce6031c2Smartin * 19ce6031c2Smartin * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20ce6031c2Smartin * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21ce6031c2Smartin * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22ce6031c2Smartin * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23ce6031c2Smartin * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24ce6031c2Smartin * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25ce6031c2Smartin * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26ce6031c2Smartin * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27ce6031c2Smartin * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28ce6031c2Smartin * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29ce6031c2Smartin * POSSIBILITY OF SUCH DAMAGE. 30ce6031c2Smartin */ 31ce6031c2Smartin 32ce6031c2Smartin#include "atomic_op_asm.h" 33ce6031c2Smartin 34ce6031c2Smartin .text 35ce6031c2Smartin 36ce6031c2SmartinENTRY(_atomic_xor_32) 37ce6031c2Smartin movl 4(%sp), %a0 38ce6031c2Smartin movl 8(%sp), %d0 39ce6031c2Smartin eorl %d0, (%a0) 40ce6031c2Smartin rts 41ce6031c2SmartinEND(_atomic_xor_32) 42ce6031c2Smartin 43ce6031c2SmartinATOMIC_OP_ALIAS(atomic_xor_32,_atomic_xor_32) 44ce6031c2SmartinATOMIC_OP_ALIAS(atomic_xor_uint,_atomic_xor_32) 45ce6031c2SmartinSTRONG_ALIAS(_atomic_xor_uint,_atomic_xor_32) 46ce6031c2SmartinATOMIC_OP_ALIAS(atomic_xor_ulong,_atomic_xor_32) 47ce6031c2SmartinSTRONG_ALIAS(_atomic_xor_ulong,_atomic_xor_32) 48ce6031c2SmartinATOMIC_OP_ALIAS(atomic_xor_ptr,_atomic_xor_32) 49ce6031c2SmartinSTRONG_ALIAS(_atomic_xor_ptr,_atomic_xor_32) 50ce6031c2Smartin 51ce6031c2SmartinENTRY(_atomic_xor_32_nv) 52ce6031c2Smartin movl 4(%sp), %a0 53ce6031c2Smartin1: movl (%a0), %d0 54ce6031c2Smartin movl %d0, %d1 55ce6031c2Smartin movl 8(%sp), %d2 56ce6031c2Smartin eorl %d2, %d0 57ce6031c2Smartin casl %d1, %d0, (%a0) 58ce6031c2Smartin bne 1b 59ce6031c2Smartin movl %d0, %a0 60ce6031c2Smartin rts 61ce6031c2SmartinEND(_atomic_xor_32_nv) 62ce6031c2Smartin 63ce6031c2SmartinATOMIC_OP_ALIAS(atomic_xor_32_nv,_atomic_xor_32_nv) 64ce6031c2SmartinATOMIC_OP_ALIAS(atomic_xor_uint_nv,_atomic_xor_32_nv) 65ce6031c2SmartinSTRONG_ALIAS(_atomic_xor_uint_nv,_atomic_xor_32_nv) 66ce6031c2SmartinATOMIC_OP_ALIAS(atomic_xor_ulong_nv,_atomic_xor_32_nv) 67ce6031c2SmartinSTRONG_ALIAS(_atomic_xor_ulong_nv,_atomic_xor_32_nv) 68ce6031c2SmartinATOMIC_OP_ALIAS(atomic_xor_ptr_nv,_atomic_xor_32_nv) 69ce6031c2SmartinSTRONG_ALIAS(_atomic_xor_ptr_nv,_atomic_xor_32_nv) 70b290679aSmartinCRT_ALIAS(__sync_xor_and_fetch_4, _atomic_xor_32_nv) 71ce6031c2Smartin 72ce6031c2Smartin 73ce6031c2SmartinENTRY(__sync_fetch_and_xor_4) 74ce6031c2Smartin movl 4(%sp), %a0 75ce6031c2Smartin1: movl (%a0), %d0 76ce6031c2Smartin movl %d0, %d1 77ce6031c2Smartin movl 8(%sp), %d2 78ce6031c2Smartin eorl %d2, %d1 79ce6031c2Smartin casl %d0, %d1, (%a0) 80ce6031c2Smartin bne 1b 81ce6031c2Smartin movl %d0, %a0 82ce6031c2Smartin rts 83ce6031c2SmartinEND(__sync_fetch_and_xor_4) 84ce6031c2Smartin 85ce6031c2Smartin 86ce6031c2SmartinENTRY(_atomic_xor_16_nv) 87ce6031c2Smartin movl 4(%sp), %a0 88ce6031c2Smartin1: movw (%a0), %d0 89ce6031c2Smartin movw %d0, %d1 90ce6031c2Smartin movw 8(%sp), %d2 91ce6031c2Smartin eorw %d2, %d0 92ce6031c2Smartin casw %d1, %d0, (%a0) 93ce6031c2Smartin bne 1b 94ce6031c2Smartin rts 95ce6031c2SmartinEND(_atomic_xor_16_nv) 96b290679aSmartinCRT_ALIAS(__sync_xor_and_fetch_2, _atomic_xor_16_nv) 97ce6031c2Smartin 98ce6031c2SmartinENTRY(__sync_fetch_and_xor_2) 99ce6031c2Smartin movl 4(%sp), %a0 100ce6031c2Smartin1: movw (%a0), %d0 101ce6031c2Smartin movw %d0, %d1 102ce6031c2Smartin movw 8(%sp), %d2 103ce6031c2Smartin eorw %d2, %d1 104ce6031c2Smartin casw %d0, %d1, (%a0) 105ce6031c2Smartin bne 1b 106ce6031c2Smartin rts 107ce6031c2SmartinEND(__sync_fetch_and_xor_2) 108ce6031c2Smartin 109ce6031c2Smartin 110ce6031c2SmartinENTRY(_atomic_xor_8_nv) 111ce6031c2Smartin movl 4(%sp), %a0 112ce6031c2Smartin1: movb (%a0), %d0 113ce6031c2Smartin movb %d0, %d1 114ce6031c2Smartin movb 8(%sp), %d2 115ce6031c2Smartin eorb %d2, %d0 116ce6031c2Smartin casb %d1, %d0, (%a0) 117ce6031c2Smartin bne 1b 118ce6031c2Smartin rts 119ce6031c2SmartinEND(_atomic_xor_8_nv) 120b290679aSmartinCRT_ALIAS(__sync_xor_and_fetch_1, _atomic_xor_8_nv) 121ce6031c2Smartin 122ce6031c2SmartinENTRY(__sync_fetch_and_xor_1) 123ce6031c2Smartin movl 4(%sp), %a0 124ce6031c2Smartin1: movb (%a0), %d0 125ce6031c2Smartin movb %d0, %d1 126ce6031c2Smartin movb 8(%sp), %d2 127ce6031c2Smartin eorb %d2, %d1 128ce6031c2Smartin casb %d0, %d1, (%a0) 129ce6031c2Smartin bne 1b 130ce6031c2Smartin rts 131ce6031c2SmartinEND(__sync_fetch_and_xor_1) 132504e8e68Sjoerg 133504e8e68SjoergCRT_ALIAS(__atomic_fetch_xor_1,__sync_fetch_and_xor_1) 134504e8e68SjoergCRT_ALIAS(__atomic_fetch_xor_2,__sync_fetch_and_xor_2) 135504e8e68SjoergCRT_ALIAS(__atomic_fetch_xor_4,__sync_fetch_and_xor_4) 136