@@ -86,47 +86,6 @@ extern "C" {
8686
8787#endif // IREE_COMPILER_*
8888
89- // If the compiler can automatically determine the types:
90- #ifdef iree_atomic_load_auto
91-
92- #define iree_atomic_load_int32 iree_atomic_load_auto
93- #define iree_atomic_store_int32 iree_atomic_store_auto
94- #define iree_atomic_fetch_add_int32 iree_atomic_fetch_add_auto
95- #define iree_atomic_fetch_sub_int32 iree_atomic_fetch_sub_auto
96- #define iree_atomic_fetch_and_int32 iree_atomic_fetch_and_auto
97- #define iree_atomic_fetch_or_int32 iree_atomic_fetch_or_auto
98- #define iree_atomic_fetch_xor_int32 iree_atomic_fetch_xor_auto
99- #define iree_atomic_exchange_int32 iree_atomic_exchange_auto
100- #define iree_atomic_compare_exchange_strong_int32 \
101- iree_atomic_compare_exchange_strong_auto
102- #define iree_atomic_compare_exchange_weak_int32 \
103- iree_atomic_compare_exchange_weak_auto
104-
105- #define iree_atomic_load_int64 iree_atomic_load_auto
106- #define iree_atomic_store_int64 iree_atomic_store_auto
107- #define iree_atomic_fetch_add_int64 iree_atomic_fetch_add_auto
108- #define iree_atomic_fetch_sub_int64 iree_atomic_fetch_sub_auto
109- #define iree_atomic_fetch_and_int64 iree_atomic_fetch_and_auto
110- #define iree_atomic_fetch_or_int64 iree_atomic_fetch_or_auto
111- #define iree_atomic_fetch_xor_int64 iree_atomic_fetch_xor_auto
112- #define iree_atomic_exchange_int64 iree_atomic_exchange_auto
113- #define iree_atomic_compare_exchange_strong_int64 \
114- iree_atomic_compare_exchange_strong_auto
115- #define iree_atomic_compare_exchange_weak_int64 \
116- iree_atomic_compare_exchange_weak_auto
117-
118- #define iree_atomic_load_intptr iree_atomic_load_auto
119- #define iree_atomic_store_intptr iree_atomic_store_auto
120- #define iree_atomic_fetch_add_intptr iree_atomic_fetch_add_auto
121- #define iree_atomic_fetch_sub_intptr iree_atomic_fetch_sub_auto
122- #define iree_atomic_exchange_intptr iree_atomic_exchange_auto
123- #define iree_atomic_compare_exchange_strong_intptr \
124- iree_atomic_compare_exchange_strong_auto
125- #define iree_atomic_compare_exchange_weak_intptr \
126- iree_atomic_compare_exchange_weak_auto
127-
128- #endif // iree_atomic_load_auto
129-
13089//==============================================================================
13190// Reference count atomics
13291//==============================================================================
@@ -140,10 +99,10 @@ typedef iree_atomic_int32_t iree_atomic_ref_count_t;
14099// should use IREE_ATOMIC_VAR_INIT, but apparently this has to be fixed
141100// at call sites (where the variables are initialized in the first place).
142101#define iree_atomic_ref_count_init_value (count_ptr , value ) \
143- iree_atomic_store_int32( count_ptr, value, iree_memory_order_relaxed)
102+ iree_atomic_store(( count_ptr), ( value) , iree_memory_order_relaxed)
144103
145104#define iree_atomic_ref_count_init (count_ptr ) \
146- iree_atomic_ref_count_init_value(count_ptr, 1)
105+ iree_atomic_ref_count_init_value(( count_ptr) , 1)
147106
148107// Why relaxed order:
149108// https://www.boost.org/doc/libs/1_57_0/doc/html/atomic/usage_examples.html#boost_atomic.usage_examples.example_reference_counters.discussion
@@ -155,9 +114,9 @@ typedef iree_atomic_int32_t iree_atomic_ref_count_t;
155114// value (unlike iree_atomic_ref_count_dec), so we make sure that it does not,
156115// which allows the implementation to use faster atomic instructions where
157116// available, e.g. STADD on ARMv8.1-a.
158- #define iree_atomic_ref_count_inc (count_ptr ) \
159- do { \
160- iree_atomic_fetch_add_int32( count_ptr, 1, iree_memory_order_relaxed); \
117+ #define iree_atomic_ref_count_inc (count_ptr ) \
118+ do { \
119+ iree_atomic_fetch_add(( count_ptr) , 1, iree_memory_order_relaxed); \
161120 } while (false)
162121
163122// For now we stick to acq_rel order. TODO: should we follow Boost's advice?
@@ -169,13 +128,13 @@ typedef iree_atomic_int32_t iree_atomic_ref_count_t;
169128// may be a pessimization... I would like to hear a second opinion on this,
170129// particularly regarding how x86-centric this might be.
171130#define iree_atomic_ref_count_dec (count_ptr ) \
172- iree_atomic_fetch_sub_int32( count_ptr, 1, iree_memory_order_acq_rel)
131+ iree_atomic_fetch_sub(( count_ptr) , 1, iree_memory_order_acq_rel)
173132
174133// memory_order_acquire order ensures that this sees decrements from
175134// iree_atomic_ref_count_dec. On the other hand, there is no ordering with
176135// iree_atomic_ref_count_inc.
177136#define iree_atomic_ref_count_load (count_ptr ) \
178- iree_atomic_load_int32( count_ptr, iree_memory_order_acquire)
137+ iree_atomic_load(( count_ptr) , iree_memory_order_acquire)
179138
180139// Aborts the program if the given reference count value is not 1.
181140// This should be avoided in all situations but those where continuing execution
0 commit comments