[libclc] r217918 - atomic: Add generic atom[ic]_cmpxchg
Aaron Watry
awatry at gmail.com
Tue Sep 16 15:34:49 PDT 2014
Author: awatry
Date: Tue Sep 16 17:34:49 2014
New Revision: 217918
URL: http://llvm.org/viewvc/llvm-project?rev=217918&view=rev
Log:
atomic: Add generic atom[ic]_cmpxchg
Signed-off-by: Aaron Watry <awatry at gmail.com>
Reviewed-by: Tom Stellard <thomas.stellard at amd.com>
Added:
libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h
libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h
libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h
libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl
libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES
libclc/trunk/generic/lib/atomic/atomic_impl.ll
Added: libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h?rev=217918&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h (added)
+++ libclc/trunk/generic/include/clc/atomic/atomic_cmpxchg.h Tue Sep 16 17:34:49 2014
@@ -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
\ No newline at end of file
Added: libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h?rev=217918&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h (added)
+++ libclc/trunk/generic/include/clc/cl_khr_global_int32_base_atomics/atom_cmpxchg.h Tue Sep 16 17:34:49 2014
@@ -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);
Added: libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h?rev=217918&view=auto
==============================================================================
--- libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h (added)
+++ libclc/trunk/generic/include/clc/cl_khr_local_int32_base_atomics/atom_cmpxchg.h Tue Sep 16 17:34:49 2014
@@ -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);
Modified: libclc/trunk/generic/include/clc/clc.h
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/clc.h?rev=217918&r1=217917&r2=217918&view=diff
==============================================================================
--- libclc/trunk/generic/include/clc/clc.h (original)
+++ libclc/trunk/generic/include/clc/clc.h Tue Sep 16 17:34:49 2014
@@ -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>
Modified: libclc/trunk/generic/lib/SOURCES
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=217918&r1=217917&r2=217918&view=diff
==============================================================================
--- libclc/trunk/generic/lib/SOURCES (original)
+++ libclc/trunk/generic/lib/SOURCES Tue Sep 16 17:34:49 2014
@@ -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/ato
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
Modified: libclc/trunk/generic/lib/atomic/atomic_impl.ll
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/atomic/atomic_impl.ll?rev=217918&r1=217917&r2=217918&view=diff
==============================================================================
--- libclc/trunk/generic/lib/atomic/atomic_impl.ll (original)
+++ libclc/trunk/generic/lib/atomic/atomic_impl.ll Tue Sep 16 17:34:49 2014
@@ -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
Added: libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl?rev=217918&view=auto
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl (added)
+++ libclc/trunk/generic/lib/cl_khr_global_int32_base_atomics/atom_cmpxchg.cl Tue Sep 16 17:34:49 2014
@@ -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)
Added: libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl
URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl?rev=217918&view=auto
==============================================================================
--- libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl (added)
+++ libclc/trunk/generic/lib/cl_khr_local_int32_base_atomics/atom_cmpxchg.cl Tue Sep 16 17:34:49 2014
@@ -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)
More information about the cfe-commits
mailing list