forked from OSchip/llvm-project
atomic: Implement generic atom[ic]_xchg
Signed-off-by: Aaron Watry <awatry@gmail.com> Reviewed-by: Tom Stellard <thomas.stellard@amd.com> llvm-svn: 217917
This commit is contained in:
parent
7cfa12c2a5
commit
025d79ad6c
|
@ -0,0 +1,5 @@
|
|||
#define __CLC_FUNCTION atomic_xchg
|
||||
#include <clc/atomic/atomic_decl.inc>
|
||||
__CLC_DECLARE_ATOMIC_ADDRSPACE(float);
|
||||
#undef __CLC_FUNCTION
|
||||
#undef __CLC_DECLARE_ATOMIC_ADDRSPACE
|
|
@ -0,0 +1,2 @@
|
|||
_CLC_OVERLOAD _CLC_DECL int atom_xchg(global int *p, int val);
|
||||
_CLC_OVERLOAD _CLC_DECL unsigned int atom_xchg(global unsigned int *p, unsigned int val);
|
|
@ -0,0 +1,2 @@
|
|||
_CLC_OVERLOAD _CLC_DECL int atom_xchg(local int *p, int val);
|
||||
_CLC_OVERLOAD _CLC_DECL unsigned int atom_xchg(local unsigned int *p, unsigned int val);
|
|
@ -148,6 +148,7 @@
|
|||
#include <clc/atomic/atomic_min.h>
|
||||
#include <clc/atomic/atomic_or.h>
|
||||
#include <clc/atomic/atomic_sub.h>
|
||||
#include <clc/atomic/atomic_xchg.h>
|
||||
#include <clc/atomic/atomic_xor.h>
|
||||
|
||||
/* cl_khr_global_int32_base_atomics Extension Functions */
|
||||
|
@ -155,6 +156,7 @@
|
|||
#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>
|
||||
#include <clc/cl_khr_global_int32_base_atomics/atom_xchg.h>
|
||||
|
||||
/* cl_khr_global_int32_extended_atomics Extension Functions */
|
||||
#include <clc/cl_khr_global_int32_extended_atomics/atom_and.h>
|
||||
|
@ -168,6 +170,7 @@
|
|||
#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>
|
||||
#include <clc/cl_khr_local_int32_base_atomics/atom_xchg.h>
|
||||
|
||||
/* cl_khr_local_int32_extended_atomics Extension Functions */
|
||||
#include <clc/cl_khr_local_int32_extended_atomics/atom_and.h>
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
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_dec.cl
|
||||
cl_khr_global_int32_base_atomics/atom_inc.cl
|
||||
cl_khr_global_int32_base_atomics/atom_sub.cl
|
||||
cl_khr_global_int32_base_atomics/atom_xchg.cl
|
||||
cl_khr_global_int32_extended_atomics/atom_and.cl
|
||||
cl_khr_global_int32_extended_atomics/atom_max.cl
|
||||
cl_khr_global_int32_extended_atomics/atom_min.cl
|
||||
|
@ -13,6 +15,7 @@ cl_khr_local_int32_base_atomics/atom_add.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
|
||||
cl_khr_local_int32_base_atomics/atom_xchg.cl
|
||||
cl_khr_local_int32_extended_atomics/atom_and.cl
|
||||
cl_khr_local_int32_extended_atomics/atom_max.cl
|
||||
cl_khr_local_int32_extended_atomics/atom_min.cl
|
||||
|
|
|
@ -94,6 +94,18 @@ entry:
|
|||
ret i32 %0
|
||||
}
|
||||
|
||||
define i32 @__clc_atomic_xchg_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
|
||||
entry:
|
||||
%0 = atomicrmw volatile xchg i32 addrspace(1)* %ptr, i32 %value seq_cst
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
define i32 @__clc_atomic_xchg_addr3(i32 addrspace(3)* nocapture %ptr, i32 %value) nounwind alwaysinline {
|
||||
entry:
|
||||
%0 = atomicrmw volatile xchg i32 addrspace(3)* %ptr, i32 %value seq_cst
|
||||
ret i32 %0
|
||||
}
|
||||
|
||||
define i32 @__clc_atomic_xor_addr1(i32 addrspace(1)* nocapture %ptr, i32 %value) nounwind alwaysinline {
|
||||
entry:
|
||||
%0 = atomicrmw volatile xor i32 addrspace(1)* %ptr, i32 %value seq_cst
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#include <clc/clc.h>
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float atomic_xchg(volatile global float *p, float val) {
|
||||
return as_float(atomic_xchg((volatile global int *)p, as_int(val)));
|
||||
}
|
||||
|
||||
_CLC_OVERLOAD _CLC_DEF float atomic_xchg(volatile local float *p, float val) {
|
||||
return as_float(atomic_xchg((volatile local int *)p, as_int(val)));
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#include <clc/clc.h>
|
||||
|
||||
#define IMPL(TYPE) \
|
||||
_CLC_OVERLOAD _CLC_DEF TYPE atom_xchg(global TYPE *p, TYPE val) { \
|
||||
return atomic_xchg(p, val); \
|
||||
}
|
||||
|
||||
IMPL(int)
|
||||
IMPL(unsigned int)
|
|
@ -0,0 +1,9 @@
|
|||
#include <clc/clc.h>
|
||||
|
||||
#define IMPL(TYPE) \
|
||||
_CLC_OVERLOAD _CLC_DEF TYPE atom_xchg(local TYPE *p, TYPE val) { \
|
||||
return atomic_xchg(p, val); \
|
||||
}
|
||||
|
||||
IMPL(int)
|
||||
IMPL(unsigned int)
|
Loading…
Reference in New Issue