Skip to content

Commit 6e19359

Browse files
committed
atomics: update llvmcall for load,store,cmpxchg
1 parent 284d17a commit 6e19359

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/atomics.jl

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,21 @@
1+
12
for (ityp,jtyp) [("i8", UInt8), ("i16", UInt16), ("i32", UInt32), ("i64", UInt64), ("i128", UInt128)]
23
@eval begin
34
@inline function _atomic_load(ptr::Ptr{$jtyp})
45
Base.llvmcall($("""
5-
%p = inttoptr i$(8sizeof(Int)) %0 to $(ityp)*
6-
%v = load atomic $(ityp), $(ityp)* %p acquire, align $(Base.gc_alignment(jtyp))
6+
%v = load atomic $(ityp), ptr %0 acquire, align $(Base.gc_alignment(jtyp))
77
ret $(ityp) %v
88
"""), $jtyp, Tuple{Ptr{$jtyp}}, ptr)
99
end
1010
@inline function _atomic_store!(ptr::Ptr{$jtyp}, x::$jtyp)
1111
Base.llvmcall($("""
12-
%p = inttoptr i$(8sizeof(Int)) %0 to $(ityp)*
13-
store atomic $(ityp) %1, $(ityp)* %p release, align $(Base.gc_alignment(jtyp))
12+
store atomic $(ityp) %1, ptr %0 release, align $(Base.gc_alignment(jtyp))
1413
ret void
1514
"""), Cvoid, Tuple{Ptr{$jtyp}, $jtyp}, ptr, x)
1615
end
1716
@inline function _atomic_cas_cmp!(ptr::Ptr{$jtyp}, cmp::$jtyp, newval::$jtyp)
1817
Base.llvmcall($("""
19-
%p = inttoptr i$(8sizeof(Int)) %0 to $(ityp)*
20-
%c = cmpxchg $(ityp)* %p, $(ityp) %1, $(ityp) %2 acq_rel acquire
18+
%c = cmpxchg ptr %0, $(ityp) %1, $(ityp) %2 acq_rel acquire
2119
%bit = extractvalue { $ityp, i1 } %c, 1
2220
%bool = zext i1 %bit to i8
2321
ret i8 %bool

0 commit comments

Comments
 (0)