[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v2 05/10] tcg: Use GEN_ATOMIC_HELPER_FN for opposite e
From: |
Richard Henderson |
Subject: |
[Qemu-arm] [PATCH v2 05/10] tcg: Use GEN_ATOMIC_HELPER_FN for opposite endian atomic add |
Date: |
Fri, 4 May 2018 11:30:16 -0700 |
Suggested-by: Peter Maydell <address@hidden>
Signed-off-by: Richard Henderson <address@hidden>
---
accel/tcg/atomic_template.h | 49 +++++++--------------------------------------
1 file changed, 7 insertions(+), 42 deletions(-)
diff --git a/accel/tcg/atomic_template.h b/accel/tcg/atomic_template.h
index 2489dd3ec1..3f41ef2782 100644
--- a/accel/tcg/atomic_template.h
+++ b/accel/tcg/atomic_template.h
@@ -229,48 +229,6 @@ GEN_ATOMIC_HELPER(xor_fetch)
#undef GEN_ATOMIC_HELPER
-/* Note that for addition, we need to use a separate cmpxchg loop instead
- of bswaps for the reverse-host-endian helpers. */
-ABI_TYPE ATOMIC_NAME(fetch_add)(CPUArchState *env, target_ulong addr,
- ABI_TYPE val EXTRA_ARGS)
-{
- ATOMIC_MMU_DECLS;
- DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
- DATA_TYPE ldo, ldn, ret, sto;
-
- ldo = atomic_read__nocheck(haddr);
- while (1) {
- ret = BSWAP(ldo);
- sto = BSWAP(ret + val);
- ldn = atomic_cmpxchg__nocheck(haddr, ldo, sto);
- if (ldn == ldo) {
- ATOMIC_MMU_CLEANUP;
- return ret;
- }
- ldo = ldn;
- }
-}
-
-ABI_TYPE ATOMIC_NAME(add_fetch)(CPUArchState *env, target_ulong addr,
- ABI_TYPE val EXTRA_ARGS)
-{
- ATOMIC_MMU_DECLS;
- DATA_TYPE *haddr = ATOMIC_MMU_LOOKUP;
- DATA_TYPE ldo, ldn, ret, sto;
-
- ldo = atomic_read__nocheck(haddr);
- while (1) {
- ret = BSWAP(ldo) + val;
- sto = BSWAP(ret);
- ldn = atomic_cmpxchg__nocheck(haddr, ldo, sto);
- if (ldn == ldo) {
- ATOMIC_MMU_CLEANUP;
- return ret;
- }
- ldo = ldn;
- }
-}
-
/* These helpers are, as a whole, full barriers. Within the helper,
* the leading barrier is explicit and the trailing barrier is within
* cmpxchg primitive.
@@ -302,6 +260,13 @@ GEN_ATOMIC_HELPER_FN(umin_fetch, MIN, DATA_TYPE, new)
GEN_ATOMIC_HELPER_FN(smax_fetch, MAX, SDATA_TYPE, new)
GEN_ATOMIC_HELPER_FN(umax_fetch, MAX, DATA_TYPE, new)
+/* Note that for addition, we need to use a separate cmpxchg loop instead
+ of bswaps for the reverse-host-endian helpers. */
+#define ADD(X, Y) (X + Y)
+GEN_ATOMIC_HELPER_FN(fetch_add, ADD, DATA_TYPE, old)
+GEN_ATOMIC_HELPER_FN(add_fetch, ADD, DATA_TYPE, new)
+#undef ADD
+
#undef GEN_ATOMIC_HELPER_FN
#endif /* DATA_SIZE >= 16 */
--
2.14.3
- [Qemu-arm] [PATCH v2 00/10] target/arm: Implement v8.1-Atomics, Richard Henderson, 2018/05/04
- [Qemu-arm] [PATCH v2 01/10] tcg: Introduce helpers for integer min/max, Richard Henderson, 2018/05/04
- [Qemu-arm] [PATCH v2 02/10] target/arm: Use new min/max expanders, Richard Henderson, 2018/05/04
- [Qemu-arm] [PATCH v2 03/10] target/xtensa: Use new min/max expanders, Richard Henderson, 2018/05/04
- [Qemu-arm] [PATCH v2 04/10] tcg: Introduce atomic helpers for integer min/max, Richard Henderson, 2018/05/04
- [Qemu-arm] [PATCH v2 05/10] tcg: Use GEN_ATOMIC_HELPER_FN for opposite endian atomic add,
Richard Henderson <=
- [Qemu-arm] [PATCH v2 06/10] target/riscv: Use new atomic min/max expanders, Richard Henderson, 2018/05/04
- [Qemu-arm] [PATCH v2 08/10] target/arm: Fill in disas_ldst_atomic, Richard Henderson, 2018/05/04
- [Qemu-arm] [PATCH v2 07/10] target/arm: Introduce ARM_FEATURE_V8_ATOMICS and initial decode, Richard Henderson, 2018/05/04
- [Qemu-arm] [PATCH v2 09/10] target/arm: Implement CAS and CASP, Richard Henderson, 2018/05/04
- [Qemu-arm] [PATCH v2 10/10] target/arm: Enable ARM_FEATURE_V8_ATOMICS for user-only, Richard Henderson, 2018/05/04
- Re: [Qemu-arm] [Qemu-devel] [PATCH v2 00/10] target/arm: Implement v8.1-Atomics, no-reply, 2018/05/04
- [Qemu-arm] [PATCH v3 08/10] target/arm: Fill in disas_ldst_atomic, Richard Henderson, 2018/05/04