Home | History | Annotate | Download | only in atomic
      1 // Copyright 2014 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 #include "textflag.h"
      6 
      7 TEXT SwapInt32(SB),NOSPLIT,$0-20
      8 	B	SwapUint32(SB)
      9 
     10 TEXT SwapUint32(SB),NOSPLIT,$0-20
     11 	MOVD	addr+0(FP), R0
     12 	MOVW	new+8(FP), R1
     13 again:
     14 	LDAXRW	(R0), R2
     15 	STLXRW	R1, (R0), R3
     16 	CBNZ	R3, again
     17 	MOVW	R2, old+16(FP)
     18 	RET
     19 
     20 TEXT SwapInt64(SB),NOSPLIT,$0-24
     21 	B	SwapUint64(SB)
     22 
     23 TEXT SwapUint64(SB),NOSPLIT,$0-24
     24 	MOVD	addr+0(FP), R0
     25 	MOVD	new+8(FP), R1
     26 again:
     27 	LDAXR	(R0), R2
     28 	STLXR	R1, (R0), R3
     29 	CBNZ	R3, again
     30 	MOVD	R2, old+16(FP)
     31 	RET
     32 
     33 TEXT SwapUintptr(SB),NOSPLIT,$0-24
     34 	B	SwapUint64(SB)
     35 
     36 TEXT CompareAndSwapInt32(SB),NOSPLIT,$0-17
     37 	B	CompareAndSwapUint32(SB)
     38 
     39 TEXT CompareAndSwapUint32(SB),NOSPLIT,$0-17
     40 	MOVD	addr+0(FP), R0
     41 	MOVW	old+8(FP), R1
     42 	MOVW	new+12(FP), R2
     43 again:
     44 	LDAXRW	(R0), R3
     45 	CMPW	R1, R3
     46 	BNE	ok
     47 	STLXRW	R2, (R0), R3
     48 	CBNZ	R3, again
     49 ok:
     50 	CSET	EQ, R0
     51 	MOVB	R0, swapped+16(FP)
     52 	RET
     53 
     54 TEXT CompareAndSwapUintptr(SB),NOSPLIT,$0-25
     55 	B	CompareAndSwapUint64(SB)
     56 
     57 TEXT CompareAndSwapInt64(SB),NOSPLIT,$0-25
     58 	B	CompareAndSwapUint64(SB)
     59 
     60 TEXT CompareAndSwapUint64(SB),NOSPLIT,$0-25
     61 	MOVD	addr+0(FP), R0
     62 	MOVD	old+8(FP), R1
     63 	MOVD	new+16(FP), R2
     64 again:
     65 	LDAXR	(R0), R3
     66 	CMP	R1, R3
     67 	BNE	ok
     68 	STLXR	R2, (R0), R3
     69 	CBNZ	R3, again
     70 ok:
     71 	CSET	EQ, R0
     72 	MOVB	R0, swapped+24(FP)
     73 	RET
     74 
     75 TEXT AddInt32(SB),NOSPLIT,$0-20
     76 	B	AddUint32(SB)
     77 
     78 TEXT AddUint32(SB),NOSPLIT,$0-20
     79 	MOVD	addr+0(FP), R0
     80 	MOVW	delta+8(FP), R1
     81 again:
     82 	LDAXRW	(R0), R2
     83 	ADDW	R2, R1, R2
     84 	STLXRW	R2, (R0), R3
     85 	CBNZ	R3, again
     86 	MOVW	R2, new+16(FP)
     87 	RET
     88 
     89 TEXT AddUintptr(SB),NOSPLIT,$0-24
     90 	B	AddUint64(SB)
     91 
     92 TEXT AddInt64(SB),NOSPLIT,$0-24
     93 	B	AddUint64(SB)
     94 
     95 TEXT AddUint64(SB),NOSPLIT,$0-24
     96 	MOVD	addr+0(FP), R0
     97 	MOVD	delta+8(FP), R1
     98 again:
     99 	LDAXR	(R0), R2
    100 	ADD	R2, R1, R2
    101 	STLXR	R2, (R0), R3
    102 	CBNZ	R3, again
    103 	MOVD	R2, new+16(FP)
    104 	RET
    105 
    106 TEXT LoadInt32(SB),NOSPLIT,$0-12
    107 	B	LoadUint32(SB)
    108 
    109 TEXT LoadUint32(SB),NOSPLIT,$0-12
    110 	MOVD	addr+0(FP), R0
    111 	LDARW	(R0), R0
    112 	MOVW	R0, val+8(FP)
    113 	RET
    114 
    115 TEXT LoadInt64(SB),NOSPLIT,$0-16
    116 	B	LoadUint64(SB)
    117 
    118 TEXT LoadUint64(SB),NOSPLIT,$0-16
    119 	MOVD	addr+0(FP), R0
    120 	LDAR	(R0), R0
    121 	MOVD	R0, val+8(FP)
    122 	RET
    123 
    124 TEXT LoadUintptr(SB),NOSPLIT,$0-16
    125 	B	LoadPointer(SB)
    126 
    127 TEXT LoadPointer(SB),NOSPLIT,$0-16
    128 	B	LoadUint64(SB)
    129 
    130 TEXT StoreInt32(SB),NOSPLIT,$0-12
    131 	B	StoreUint32(SB)
    132 
    133 TEXT StoreUint32(SB),NOSPLIT,$0-12
    134 	MOVD	addr+0(FP), R0
    135 	MOVW	val+8(FP), R1
    136 	STLRW	R1, (R0)
    137 	RET
    138 
    139 TEXT StoreInt64(SB),NOSPLIT,$0-16
    140 	B	StoreUint64(SB)
    141 
    142 TEXT StoreUint64(SB),NOSPLIT,$0-16
    143 	MOVD	addr+0(FP), R0
    144 	MOVD	val+8(FP), R1
    145 	STLR	R1, (R0)
    146 	RET
    147 
    148 TEXT StoreUintptr(SB),NOSPLIT,$0-16
    149 	B	StoreUint64(SB)
    150