mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-14 19:49:36 +00:00
atomic: Add generic atom[ic]_cmpxchg
Signed-off-by: Aaron Watry <awatry@gmail.com> Reviewed-by: Tom Stellard <thomas.stellard@amd.com> llvm-svn: 217918
This commit is contained in:
parent
025d79ad6c
commit
0d976ba497
15
libclc/generic/include/clc/atomic/atomic_cmpxchg.h
Normal file
15
libclc/generic/include/clc/atomic/atomic_cmpxchg.h
Normal file
@ -0,0 +1,15 @@
|
||||
#define __CLC_FUNCTION atomic_cmpxchg
|
||||
|
||||
#define __CLC_DECLARE_ATOMIC_3_ARG(ADDRSPACE, TYPE) \
|
||||
_CLC_OVERLOAD _CLC_DECL TYPE __CLC_FUNCTION (volatile ADDRSPACE TYPE *, TYPE, TYPE);
|
||||
|
||||
#define __CLC_DECLARE_ATOMIC_ADDRSPACE_3_ARG(TYPE) \
|
||||
__CLC_DECLARE_ATOMIC_3_ARG(global, TYPE); \
|
||||
__CLC_DECLARE_ATOMIC_3_ARG(local, TYPE);
|
||||
|
||||
__CLC_DECLARE_ATOMIC_ADDRSPACE_3_ARG(int);
|
||||
__CLC_DECLARE_ATOMIC_ADDRSPACE_3_ARG(uint);
|
||||
|
||||
#undef __CLC_FUNCTION
|
||||
#undef __CLC_DECLARE_ATOMIC_3_ARG
|
||||
#undef __CLC_DECLARE_ATOMIC_ADDRESS_SPACE_3_ARG
|
@ -0,0 +1,2 @@
|
||||
_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(global int *p, int cmp, int val);
|
||||
_CLC_OVERLOAD _CLC_DECL unsigned int atom_cmpxchg(global unsigned int *p, unsigned int cmp, unsigned int val);
|
@ -0,0 +1,2 @@
|
||||
_CLC_OVERLOAD _CLC_DECL int atom_cmpxchg(local int *p, int cmp, int val);
|
||||
_CLC_OVERLOAD _CLC_DECL unsigned int atom_cmpxchg(local unsigned int *p, unsigned int cmp, unsigned int val);
|
@ -142,6 +142,7 @@
|
||||
/* 6.11.11 Atomic Functions */
|
||||
#include <clc/atomic/atomic_add.h>
|
||||
#include <clc/atomic/atomic_and.h>
|
||||
#include <clc/atomic/atomic_cmpxchg.h>
|
||||
#include <clc/atomic/atomic_dec.h>
|
||||
#include <clc/atomic/atomic_inc.h>
|
||||
#include <clc/atomic/atomic_max.h>
|
||||
@ -153,6 +154,7 @@
|
||||
|
||||
/* cl_khr_global_int32_base_atomics Extension Functions */
|
||||
#include <clc/cl_khr_global_int32_base_atomics/atom_add.h>
|
||||
#include <clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h>
|
||||
#include <clc/cl_khr_global_int32_base_atomics/atom_dec.h>
|
||||
#include <clc/cl_khr_global_int32_base_atomics/atom_inc.h>
|
||||
#include <clc/cl_khr_global_int32_base_atomics/atom_sub.h>
|
||||
@ -167,6 +169,7 @@
|
||||
|
||||
/* cl_khr_local_int32_base_atomics Extension Functions */
|
||||
#include <clc/cl_khr_local_int32_base_atomics/atom_add.h>
|
||||
#include <clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h>
|
||||
#include <clc/cl_khr_local_int32_base_atomics/atom_dec.h>
|
||||
#include <clc/cl_khr_local_int32_base_atomics/atom_inc.h>
|
||||
#include <clc/cl_khr_local_int32_base_atomics/atom_sub.h>
|
||||
|
@ -2,6 +2,7 @@ async/prefetch.cl
|
||||
atomic/atomic_xchg.cl
|
||||
atomic/atomic_impl.ll
|
||||
cl_khr_global_int32_base_atomics/atom_add.cl
|
||||
cl_khr_global_int32_base_atomics/atom_cmpxchg.cl
|
||||
cl_khr_global_int32_base_atomics/atom_dec.cl
|
||||
cl_khr_global_int32_base_atomics/atom_inc.cl
|
||||
cl_khr_global_int32_base_atomics/atom_sub.cl
|
||||
@ -12,6 +13,7 @@ cl_khr_global_int32_extended_atomics/atom_min.cl
|
||||
cl_khr_global_int32_extended_atomics/atom_or.cl
|
||||
cl_khr_global_int32_extended_atomics/atom_xor.cl
|
||||
cl_khr_local_int32_base_atomics/atom_add.cl
|
||||
cl_khr_local_int32_base_atomics/atom_cmpxchg.cl
|
||||
cl_khr_local_int32_base_atomics/atom_dec.cl
|
||||
cl_khr_local_int32_base_atomics/atom_inc.cl
|
||||
cl_khr_local_int32_base_atomics/atom_sub.cl
|
||||
|
@ -22,6 +22,20 @@ entry:
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
define i32 @__clc_atomic_cmpxchg_addr1(i32 addrspace(1)* nocapture %ptr, i32 %compare, i32 %value) nounwind alwaysinline {
|
||||
entry:
|
||||
%0 = cmpxchg volatile i32 addrspace(1)* %ptr, i32 %compare, i32 %value seq_cst seq_cst
|
||||
%1 = extractvalue { i32, i1 } %0, 0
|
||||
ret i32 %1
|
||||
}
|
||||
|
||||
define i32 @__clc_atomic_cmpxchg_addr3(i32 addrspace(3)* nocapture %ptr, i32 %compare, i32 %value) nounwind alwaysinline {
|
||||
entry:
|
||||
%0 = cmpxchg volatile i32 addrspace(3)* %ptr, i32 %compare, i32 %value seq_cst seq_cst
|
||||
%1 = extractvalue { i32, i1 } %0, 0
|
||||
ret i32 %1
|
||||
}
|
||||
|
||||
define i32 @__clc_atomic_max_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
|
||||
entry:
|
||||
%0 = atomicrmw volatile max i32 addrspace(1)* %ptr, i32 %value seq_cst
|
||||
|
@ -0,0 +1,9 @@
|
||||
#include <clc/clc.h>
|
||||
|
||||
#define IMPL(TYPE) \
|
||||
_CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(global TYPE *p, TYPE cmp, TYPE val) { \
|
||||
return atomic_cmpxchg(p, cmp, val); \
|
||||
}
|
||||
|
||||
IMPL(int)
|
||||
IMPL(unsigned int)
|
@ -0,0 +1,9 @@
|
||||
#include <clc/clc.h>
|
||||
|
||||
#define IMPL(TYPE) \
|
||||
_CLC_OVERLOAD _CLC_DEF TYPE atom_cmpxchg(local TYPE *p, TYPE cmp, TYPE val) { \
|
||||
return atomic_cmpxchg(p, cmp, val); \
|
||||
}
|
||||
|
||||
IMPL(int)
|
||||
IMPL(unsigned int)
|
Loading…
Reference in New Issue
Block a user