summaryrefslogtreecommitdiff
path: root/src/pal/tests/palsuite/composite/synchronization/nativecs_interlocked/hpitinterlock.s
blob: 062f4ebe6a7a3b45206915e2269816089c8ae3ae (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

/*++



Module Name:

    interlock.s

Abstract:

    Implementation of Interlocked functions (32 and 64 bits) for the HPUX/Itanium
    platform. These functions are processor dependent.
    See the i386 implementations for more information.

--*/
    .file   "interlock.s"
    .section    .text,  "ax",   "progbits"
    .align 16
    .global InterlockedExchangeAdd#
    .proc InterlockedExchangeAdd#
InterlockedExchangeAdd:
    .body
    ld4.nt1 r8 = [r32]
    ;;
Iea10:    
    mov ar.ccv = r8    
    add r15 = r33, r8
    mov r14 = r8
    ;;
    cmpxchg4.acq r8 = [r32], r15, ar.ccv
    ;;
    cmp.ne p6,p7 = r8, r14     // check if the target changes?
(p6)br.cond.spnt.few Iea10     // if yes, go back to do it again       
(p7)br.ret.sptk.clr b0
    ;;
    .endp InterlockedExchangeAdd#
        
    .align 16
    .global InterlockedIncrement#
    .proc InterlockedIncrement#
InterlockedIncrement:
    .body
    fetchadd4.acq r8 = [r32], 1
    ;;        
    adds r8 = 1, r8
    br.ret.sptk b0
    ;;
    .endp InterlockedIncrement#
    
    .align 16
    .global InterlockedIncrement64#
    .proc InterlockedIncrement64#
InterlockedIncrement64:
    .body
    fetchadd8.acq r8 = [r32], 1
    ;;        
    adds r8 = 1, r8
    br.ret.sptk b0
    ;;
    .endp InterlockedIncrement64#    
    
    .align 16
    .global InterlockedDecrement#
    .proc InterlockedDecrement#
InterlockedDecrement:
    .body
    fetchadd4.acq r8 = [r32], -1
    ;;
    adds r8 = -1, r8
    br.ret.sptk b0
    ;;
    .endp InterlockedDecrement#
    
    .align 16
    .global InterlockedDecrement64#
    .proc InterlockedDecrement64#
InterlockedDecrement64:
    .body
    fetchadd8.acq r8 = [r32], -1
    ;;
    adds r8 = -1, r8
    br.ret.sptk b0
    ;;
    .endp InterlockedDecrement64#    
    
    .align 16
    .global InterlockedExchange#
    .proc InterlockedExchange#
InterlockedExchange:
    .body
    mf
    zxt4 r33 = r33        // sanitize the upper 32 bits    
    ;;    
    xchg4 r8 = [r32], r33
    br.ret.sptk b0
    ;;
    .endp InterlockedExchange#
    
    .align 16
    .global InterlockedExchange64#
    .proc InterlockedExchange64#
InterlockedExchange64:
    .body
    mf
    xchg8 r8 = [r32], r33
    br.ret.sptk b0
    ;;
    .endp InterlockedExchange64#    
    
    .align 16
    .global InterlockedCompareExchange#
    .proc InterlockedCompareExchange#
InterlockedCompareExchange:
    .body
    mf
    zxt4 r33 = r33        // sanitize the upper 32 bits    
    zxt4 r34 = r34        // sanitize the upper 32 bits
    ;;    
    mov ar.ccv = r34
    ;;
    cmpxchg4.acq r8 = [r32], r33, ar.ccv
    br.ret.sptk.clr b0
    ;;
    .endp InterlockedCompareExchange#
    
    .align 16
    .global InterlockedCompareExchange64#
    .proc InterlockedCompareExchange64#
InterlockedCompareExchange64:
    .body
    mf
    mov ar.ccv = r34
    ;;
    cmpxchg8.acq r8 = [r32], r33, ar.ccv
    br.ret.sptk.clr b0
    ;;
    .endp InterlockedCompareExchange64#

/*++
    DBG_DebugBreak is extracted from DbgBreakPoint function
    in debugstb.s from win64.
--*/    
    BREAKPOINT_STOP = 0x80016
    .align 16
    .global DBG_DebugBreak#
    .proc DBG_DebugBreak#
DBG_DebugBreak:
    .body
    flushrs
    ;;
    break.i BREAKPOINT_STOP
    br.ret.sptk.clr b0
    ;;
    .endp DBG_DebugBreak#    
    
    .align 16
    .global MemoryBarrier#
    .proc MemoryBarrier#
MemoryBarrier:
    .body
    mf
    br.ret.sptk.clr b0
    ;;
    .endp MemoryBarrier#