summaryrefslogtreecommitdiff
path: root/src/thread/sh/atomics.s
blob: 3b58ccccb2cbb454e99878bec6a1eda033f47d1c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* Contract for all versions is same as cas.l r2,r3,@r0
 * pr and r1 are also clobbered (by jsr & r1 as temp).
 * r0,r2,r4-r15 must be preserved.
 * r3 contains result (==r2 iff cas succeeded). */

	.align 2
.global __sh_cas_gusa
.hidden __sh_cas_gusa
__sh_cas_gusa:
	mov.l r5,@-r15
	mov.l r4,@-r15
	mov r0,r4
	mova 1f,r0
	mov r15,r1
	mov #(0f-1f),r15
0:	mov.l @r4,r5
	cmp/eq r5,r2
	bf 1f
	mov.l r3,@r4
1:	mov r1,r15
	mov r5,r3
	mov r4,r0
	mov.l @r15+,r4
	rts
	 mov.l @r15+,r5

.global __sh_cas_llsc
.hidden __sh_cas_llsc
__sh_cas_llsc:
	mov r0,r1
	synco
0:	movli.l @r1,r0
	cmp/eq r0,r2
	bf 1f
	mov r3,r0
	movco.l r0,@r1
	bf 0b
	mov r2,r0
1:	synco
	mov r0,r3
	rts
	 mov r1,r0

.global __sh_cas_imask
.hidden __sh_cas_imask
__sh_cas_imask:
	mov r0,r1
	stc sr,r0
	mov.l r0,@-r15
	or #0xf0,r0
	ldc r0,sr
	mov.l @r1,r0
	cmp/eq r0,r2
	bf 1f
	mov.l r3,@r1
1:	ldc.l @r15+,sr
	mov r0,r3
	rts
	 mov r1,r0

.global __sh_cas_cas_l
.hidden __sh_cas_cas_l
__sh_cas_cas_l:
	rts
	 .word 0x2323 /* cas.l r2,r3,@r0 */