Author: jvesely Date: Thu Jun 21 12:27:26 2018 New Revision: 335278 URL: http://llvm.org/viewvc/llvm-project?rev=335278&view=rev Log: atomic: Provide function implementation of atomic_{dec,inc}
Reviewed-By: Aaron Watry <awa...@gmail.com> Tested-By: Aaron Watry <awa...@gmail.com> Signed-off-by: Jan Vesely <jan.ves...@rutgers.edu> Added: libclc/trunk/generic/lib/atomic/atomic_dec.cl libclc/trunk/generic/lib/atomic/atomic_inc.cl Modified: libclc/trunk/generic/include/clc/atomic/atomic_dec.h libclc/trunk/generic/include/clc/atomic/atomic_inc.h libclc/trunk/generic/lib/SOURCES Modified: libclc/trunk/generic/include/clc/atomic/atomic_dec.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_dec.h?rev=335278&r1=335277&r2=335278&view=diff ============================================================================== --- libclc/trunk/generic/include/clc/atomic/atomic_dec.h (original) +++ libclc/trunk/generic/include/clc/atomic/atomic_dec.h Thu Jun 21 12:27:26 2018 @@ -1 +1,4 @@ -#define atomic_dec(p) atomic_sub(p, 1) +_CLC_OVERLOAD _CLC_DECL int atomic_dec (volatile local int *); +_CLC_OVERLOAD _CLC_DECL int atomic_dec (volatile global int *); +_CLC_OVERLOAD _CLC_DECL uint atomic_dec (volatile local uint *); +_CLC_OVERLOAD _CLC_DECL uint atomic_dec (volatile global uint *); Modified: libclc/trunk/generic/include/clc/atomic/atomic_inc.h URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/atomic/atomic_inc.h?rev=335278&r1=335277&r2=335278&view=diff ============================================================================== --- libclc/trunk/generic/include/clc/atomic/atomic_inc.h (original) +++ libclc/trunk/generic/include/clc/atomic/atomic_inc.h Thu Jun 21 12:27:26 2018 @@ -1 +1,4 @@ -#define atomic_inc(p) atomic_add(p, 1) +_CLC_OVERLOAD _CLC_DECL int atomic_inc (volatile local int *); +_CLC_OVERLOAD _CLC_DECL int atomic_inc (volatile global int *); +_CLC_OVERLOAD _CLC_DECL uint atomic_inc (volatile local uint *); +_CLC_OVERLOAD _CLC_DECL uint atomic_inc (volatile global uint *); Modified: libclc/trunk/generic/lib/SOURCES URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/SOURCES?rev=335278&r1=335277&r2=335278&view=diff ============================================================================== --- libclc/trunk/generic/lib/SOURCES (original) +++ libclc/trunk/generic/lib/SOURCES Thu Jun 21 12:27:26 2018 @@ -7,6 +7,8 @@ async/wait_group_events.cl atomic/atomic_add.cl atomic/atomic_and.cl atomic/atomic_cmpxchg.cl +atomic/atomic_dec.cl +atomic/atomic_inc.cl atomic/atomic_max.cl atomic/atomic_min.cl atomic/atomic_or.cl Added: libclc/trunk/generic/lib/atomic/atomic_dec.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/atomic/atomic_dec.cl?rev=335278&view=auto ============================================================================== --- libclc/trunk/generic/lib/atomic/atomic_dec.cl (added) +++ libclc/trunk/generic/lib/atomic/atomic_dec.cl Thu Jun 21 12:27:26 2018 @@ -0,0 +1,12 @@ +#include <clc/clc.h> + +#define IMPL(TYPE, AS) \ +_CLC_OVERLOAD _CLC_DEF TYPE atomic_dec(volatile AS TYPE *p) { \ + return __sync_fetch_and_sub(p, (TYPE)1); \ +} + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL Added: libclc/trunk/generic/lib/atomic/atomic_inc.cl URL: http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/atomic/atomic_inc.cl?rev=335278&view=auto ============================================================================== --- libclc/trunk/generic/lib/atomic/atomic_inc.cl (added) +++ libclc/trunk/generic/lib/atomic/atomic_inc.cl Thu Jun 21 12:27:26 2018 @@ -0,0 +1,12 @@ +#include <clc/clc.h> + +#define IMPL(TYPE, AS) \ +_CLC_OVERLOAD _CLC_DEF TYPE atomic_inc(volatile AS TYPE *p) { \ + return __sync_fetch_and_add(p, (TYPE)1); \ +} + +IMPL(int, global) +IMPL(unsigned int, global) +IMPL(int, local) +IMPL(unsigned int, local) +#undef IMPL _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits