23#include "../all_atomic_load_store.h"
25#include "../all_acquire_release_volatile.h"
27#include "../test_and_set_t_is_char.h"
45# define AO_IN_ADDR "1"(addr)
46# define AO_OUT_ADDR , "=r"(addr)
47# define AO_SWIZZLE "addp4 %1=0,%1;;\n"
48# define AO_MASK(ptr) __asm__ __volatile__("zxt4 %1=%1": "=r"(ptr) : "0"(ptr))
51# define AO_IN_ADDR "r"(addr)
60 __asm__ __volatile__(
"mf" : : :
"memory");
62#define AO_HAVE_nop_full
64#ifndef AO_PREFER_GENERALIZED
71 "fetchadd" AO_LEN ".acq %0=[%1],1":
75#define AO_HAVE_fetch_and_add1_acquire
83 "fetchadd" AO_LEN ".rel %0=[%1],1":
87#define AO_HAVE_fetch_and_add1_release
95 "fetchadd" AO_LEN ".acq %0=[%1],-1":
99#define AO_HAVE_fetch_and_sub1_acquire
107 "fetchadd" AO_LEN ".rel %0=[%1],-1":
111#define AO_HAVE_fetch_and_sub1_release
120 "mov ar.ccv=%[old] ;; cmpxchg" AO_LEN
121 ".acq %0=[%1],%[new_val],ar.ccv"
123 :
AO_IN_ADDR, [new_val]
"r"(new_val), [old]
"r"(old)
127#define AO_HAVE_fetch_compare_and_swap_acquire
135 "mov ar.ccv=%[old] ;; cmpxchg" AO_LEN
136 ".rel %0=[%1],%[new_val],ar.ccv"
138 :
AO_IN_ADDR, [new_val]
"r"(new_val), [old]
"r"(old)
142#define AO_HAVE_fetch_compare_and_swap_release
146 unsigned char old,
unsigned char new_val)
148 unsigned char fetched_val;
150 "mov ar.ccv=%[old] ;; cmpxchg1.acq %0=[%1],%[new_val],ar.ccv"
156#define AO_HAVE_char_fetch_compare_and_swap_acquire
160 unsigned char old,
unsigned char new_val)
162 unsigned char fetched_val;
164 "mov ar.ccv=%[old] ;; cmpxchg1.rel %0=[%1],%[new_val],ar.ccv"
170#define AO_HAVE_char_fetch_compare_and_swap_release
174 unsigned short old,
unsigned short new_val)
176 unsigned short fetched_val;
178 "mov ar.ccv=%[old] ;; cmpxchg2.acq %0=[%1],%[new_val],ar.ccv"
184#define AO_HAVE_short_fetch_compare_and_swap_acquire
188 unsigned short old,
unsigned short new_val)
190 unsigned short fetched_val;
192 "mov ar.ccv=%[old] ;; cmpxchg2.rel %0=[%1],%[new_val],ar.ccv"
198#define AO_HAVE_short_fetch_compare_and_swap_release
207# ifndef AO_PREFER_GENERALIZED
212 __asm__ __volatile__(
"fetchadd4.acq %0=[%1],1"
217# define AO_HAVE_int_fetch_and_add1_acquire
223 __asm__ __volatile__(
"fetchadd4.rel %0=[%1],1"
228# define AO_HAVE_int_fetch_and_add1_release
234 __asm__ __volatile__(
"fetchadd4.acq %0=[%1],-1"
239# define AO_HAVE_int_fetch_and_sub1_acquire
245 __asm__ __volatile__(
"fetchadd4.rel %0=[%1],-1"
250# define AO_HAVE_int_fetch_and_sub1_release
255 unsigned int old,
unsigned int new_val)
257 unsigned int fetched_val;
258 __asm__ __volatile__(
"mov ar.ccv=%3 ;; cmpxchg4.acq %0=[%1],%2,ar.ccv"
264# define AO_HAVE_int_fetch_compare_and_swap_acquire
268 unsigned int old,
unsigned int new_val)
270 unsigned int fetched_val;
271 __asm__ __volatile__(
"mov ar.ccv=%3 ;; cmpxchg4.rel %0=[%1],%2,ar.ccv"
277# define AO_HAVE_int_fetch_compare_and_swap_release
AO_INLINE unsigned short AO_short_fetch_compare_and_swap_acquire(volatile unsigned short *addr, unsigned short old, unsigned short new_val)
AO_INLINE unsigned char AO_char_fetch_compare_and_swap_acquire(volatile unsigned char *addr, unsigned char old, unsigned char new_val)
AO_INLINE unsigned int AO_int_fetch_compare_and_swap_acquire(volatile unsigned int *addr, unsigned int old, unsigned int new_val)
AO_INLINE unsigned int AO_int_fetch_compare_and_swap_release(volatile unsigned int *addr, unsigned int old, unsigned int new_val)
AO_INLINE AO_t AO_fetch_and_add1_release(volatile AO_t *addr)
AO_INLINE unsigned int AO_int_fetch_and_sub1_release(volatile unsigned int *addr)
AO_INLINE unsigned int AO_int_fetch_and_add1_acquire(volatile unsigned int *addr)
AO_INLINE AO_t AO_fetch_compare_and_swap_release(volatile AO_t *addr, AO_t old, AO_t new_val)
AO_INLINE unsigned int AO_int_fetch_and_add1_release(volatile unsigned int *addr)
AO_INLINE unsigned int AO_int_fetch_and_sub1_acquire(volatile unsigned int *addr)
AO_INLINE AO_t AO_fetch_and_sub1_acquire(volatile AO_t *addr)
AO_INLINE AO_t AO_fetch_and_add1_acquire(volatile AO_t *addr)
AO_INLINE unsigned short AO_short_fetch_compare_and_swap_release(volatile unsigned short *addr, unsigned short old, unsigned short new_val)
AO_INLINE unsigned char AO_char_fetch_compare_and_swap_release(volatile unsigned char *addr, unsigned char old, unsigned char new_val)
AO_INLINE AO_t AO_fetch_and_sub1_release(volatile AO_t *addr)
AO_INLINE AO_t AO_fetch_compare_and_swap_acquire(volatile AO_t *addr, AO_t old, AO_t new_val)
AO_INLINE void AO_nop_full(void)