target/arm: Implement v8.1-Atomics
v2 cover target/arm: Implement v8.1-Atomics
This implements the Atomics extension, which is mandatory for v8.1. While testing the v8.2-SVE extension, I've run into issues with the GCC testsuite expecting this to exist.
Missing is the wiring up of the system registers to indicate that the extension exists, but we have no system CPU model that would exercise such a setting.
Changes since v2:
* New patch to use a helper macro for opposite-endian atomic_fetch_add and atomic_add_fetch, as suggested by pm215.
* Introduce ARM_FEATURE_V8_1 and define ARM_FEATURE_V8_ATOMICS in terms of that, reinforcing the mandatory nature of the extension.
* Typo fix in patch 8.
Peter, do you want to take the whole thing into target-arm.next, or have it split? We have a review and an ack for the riscv and xtensa patches.
r~
Richard Henderson (10):
tcg: Introduce helpers for integer min/max target/arm: Use new min/max expanders
target/xtensa: Use new min/max expanders
tcg: Introduce atomic helpers for integer min/max
tcg: Use GEN_ATOMIC_HELPER_FN for opposite endian atomic add target/riscv: Use new atomic min/max expanders target/arm: Introduce ARM_FEATURE_V8_ATOMICS and initial decode target/arm: Fill in disas_ldst_atomic
target/arm: Implement CAS and CASP
target/arm: Enable ARM_FEATURE_V8_ATOMICS for user-only
accel/tcg/atomic_template.h | 112 ++++++++----- accel/tcg/tcg-runtime.h | 8 + target/arm/cpu.h | 2 + target/arm/helper-a64.h | 2 + tcg/tcg-op.h | 50 ++++++ tcg/tcg.h | 8 + linux-user/elfload.c | 1 + target/arm/cpu64.c | 1 + target/arm/helper-a64.c | 43 +++++ target/arm/translate-a64.c | 375 +++++++++++++++++++++++++++++++++++--------- target/riscv/translate.c | 72 +++------ target/xtensa/translate.c | 50 ++++-- tcg/tcg-op.c | 48 ++++++ 13 files changed, 587 insertions(+), 185 deletions(-)
Signature · 1 line
2.14.3
PATCH v2 1/10 tcg: Introduce helpers for integer min/max
These operations are re-invented by several targets so far. Several supported hosts have insns for these, so place the expanders out-of-line for a future introduction of tcg opcodes.
--- tcg/tcg-op.h | 16 ++++++++++++++++ tcg/tcg-op.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+)
tcg/tcg-op.h +16 -0
@@ -324,6 +324,10 @@ void tcg_gen_ext8u_i32(TCGv_i32 ret, TCGv_i32 arg);void tcg_gen_ext16u_i32 (TCGv_i32 ret,TCGv_i32 arg);void tcg_gen_bswap16_i32 (TCGv_i32 ret,TCGv_i32 arg);void tcg_gen_bswap32_i32 (TCGv_i32 ret,TCGv_i32 arg); +void tcg_gen_smin_i32 (TCGv_i32 ,TCGv_i32 arg1,TCGv_i32 arg2); +void tcg_gen_smax_i32 (TCGv_i32 ,TCGv_i32 arg1,TCGv_i32 arg2); +void tcg_gen_umin_i32 (TCGv_i32 ,TCGv_i32 arg1,TCGv_i32 arg2); +void tcg_gen_umax_i32 (TCGv_i32 ,TCGv_i32 arg1,TCGv_i32 arg2);static inline void tcg_gen_discard_i32 (TCGv_i32 arg) {
@@ -517,6 +521,10 @@ void tcg_gen_ext32u_i64(TCGv_i64 ret, TCGv_i64 arg);void tcg_gen_bswap16_i64 (TCGv_i64 ret,TCGv_i64 arg);void tcg_gen_bswap32_i64 (TCGv_i64 ret,TCGv_i64 arg);void tcg_gen_bswap64_i64 (TCGv_i64 ret,TCGv_i64 arg); +void tcg_gen_smin_i64 (TCGv_i64 ,TCGv_i64 arg1,TCGv_i64 arg2); +void tcg_gen_smax_i64 (TCGv_i64 ,TCGv_i64 arg1,TCGv_i64 arg2); +void tcg_gen_umin_i64 (TCGv_i64 ,TCGv_i64 arg1,TCGv_i64 arg2); +void tcg_gen_umax_i64 (TCGv_i64 ,TCGv_i64 arg1,TCGv_i64 arg2);#if TCG_TARGET_REG_BITS ==64 static inline void tcg_gen_discard_i64 (TCGv_i64 arg)
@@ -1025,6 +1033,10 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t);#define tcg_gen_mulu2_tl tcg_gen_mulu2_i64#define tcg_gen_muls2_tl tcg_gen_muls2_i64#define tcg_gen_mulsu2_tl tcg_gen_mulsu2_i64 +#define tcg_gen_smin_tl tcg_gen_smin_i64 +#define tcg_gen_umin_tl tcg_gen_umin_i64 +#define tcg_gen_smax_tl tcg_gen_smax_i64 +#define tcg_gen_umax_tl tcg_gen_umax_i64#define tcg_gen_atomic_cmpxchg_tl tcg_gen_atomic_cmpxchg_i64#define tcg_gen_atomic_xchg_tl tcg_gen_atomic_xchg_i64#define tcg_gen_atomic_fetch_add_tl tcg_gen_atomic_fetch_add_i64
@@ -1123,6 +1135,10 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t);#define tcg_gen_mulu2_tl tcg_gen_mulu2_i32#define tcg_gen_muls2_tl tcg_gen_muls2_i32#define tcg_gen_mulsu2_tl tcg_gen_mulsu2_i32 +#define tcg_gen_smin_tl tcg_gen_smin_i32 +#define tcg_gen_umin_tl tcg_gen_umin_i32 +#define tcg_gen_smax_tl tcg_gen_smax_i32 +#define tcg_gen_umax_tl tcg_gen_umax_i32#define tcg_gen_atomic_cmpxchg_tl tcg_gen_atomic_cmpxchg_i32#define tcg_gen_atomic_xchg_tl tcg_gen_atomic_xchg_i32#define tcg_gen_atomic_fetch_add_tl tcg_gen_atomic_fetch_add_i32
tcg/tcg-op.c +40 -0
@@ -1033,6 +1033,26 @@ void tcg_gen_bswap32_i32(TCGv_i32 ret, TCGv_i32 arg) } } +void tcg_gen_smin_i32 (TCGv_i32 ret,TCGv_i32 a,TCGv_i32 b) +{ +tcg_gen_movcond_i32 (TCG_COND_LT , ret, a, b, a, b); +} + +void tcg_gen_umin_i32 (TCGv_i32 ret,TCGv_i32 a,TCGv_i32 b) +{ +tcg_gen_movcond_i32 (TCG_COND_LTU , ret, a, b, a, b); +} + +void tcg_gen_smax_i32 (TCGv_i32 ret,TCGv_i32 a,TCGv_i32 b) +{ +tcg_gen_movcond_i32 (TCG_COND_LT , ret, a, b, b, a); +} + +void tcg_gen_umax_i32 (TCGv_i32 ret,TCGv_i32 a,TCGv_i32 b) +{ +tcg_gen_movcond_i32 (TCG_COND_LTU , ret, a, b, b, a); +} +/* 64-bit ops */ #if TCG_TARGET_REG_BITS ==32
@@ -2438,6 +2458,26 @@ void tcg_gen_mulsu2_i64(TCGv_i64 rl, TCGv_i64 rh, TCGv_i64 arg1, TCGv_i64 arg2)tcg_temp_free_i64 (t2); } +void tcg_gen_smin_i64 (TCGv_i64 ret,TCGv_i64 a,TCGv_i64 b) +{ +tcg_gen_movcond_i64 (TCG_COND_LT , ret, a, b, a, b); +} + +void tcg_gen_umin_i64 (TCGv_i64 ret,TCGv_i64 a,TCGv_i64 b) +{ +tcg_gen_movcond_i64 (TCG_COND_LTU , ret, a, b, a, b); +} + +void tcg_gen_smax_i64 (TCGv_i64 ret,TCGv_i64 a,TCGv_i64 b) +{ +tcg_gen_movcond_i64 (TCG_COND_LT , ret, a, b, b, a); +} + +void tcg_gen_umax_i64 (TCGv_i64 ret,TCGv_i64 a,TCGv_i64 b) +{ +tcg_gen_movcond_i64 (TCG_COND_LTU , ret, a, b, b, a); +} +/* Size changing operations. */ void tcg_gen_extrl_i64_i32 (TCGv_i32 ret,TCGv_i64 arg)
Signature · 1 line
2.14.3
PATCH v2 2/10 target/arm: Use new min/max expanders
In reply to Richard HendersonThe generic expanders replace nearly identical code in the translator.
--- target/arm/translate-a64.c | 46 ++++++++++++++-------------------------------- 1 file changed, 14 insertions(+), 32 deletions(-)
target/arm/translate-a64.c +14 -32
@@ -6021,15 +6021,18 @@ static void disas_simd_across_lanes(DisasContext *s, uint32_t insn)tcg_gen_add_i64 (tcg_res, tcg_res, tcg_elt);break ;case 0x0a :/* SMAXV / UMAXV */ -tcg_gen_movcond_i64 (is_u ?TCG_COND_GEU :TCG_COND_GE , - tcg_res, - tcg_res, tcg_elt, tcg_res, tcg_elt); +if (is_u) { +tcg_gen_umax_i64 (tcg_res, tcg_res, tcg_elt); + }else { +tcg_gen_smax_i64 (tcg_res, tcg_res, tcg_elt); + }break ;case 0x1a :/* SMINV / UMINV */ -tcg_gen_movcond_i64 (is_u ?TCG_COND_LEU :TCG_COND_LE , - tcg_res, - tcg_res, tcg_elt, tcg_res, tcg_elt); -break ; +if (is_u) { +tcg_gen_umin_i64 (tcg_res, tcg_res, tcg_elt); + }else { +tcg_gen_smin_i64 (tcg_res, tcg_res, tcg_elt); + }break ;default :g_assert_not_reached ();
@@ -9931,27 +9934,6 @@ static void disas_simd_3same_logic(DisasContext *s, uint32_t insn) } } -/* Helper functions for 32 bit comparisons */ -static void gen_max_s32 (TCGv_i32 res,TCGv_i32 op1,TCGv_i32 op2) -{ -tcg_gen_movcond_i32 (TCG_COND_GE , res, op1, op2, op1, op2); -} - -static void gen_max_u32 (TCGv_i32 res,TCGv_i32 op1,TCGv_i32 op2) -{ -tcg_gen_movcond_i32 (TCG_COND_GEU , res, op1, op2, op1, op2); -} - -static void gen_min_s32 (TCGv_i32 res,TCGv_i32 op1,TCGv_i32 op2) -{ -tcg_gen_movcond_i32 (TCG_COND_LE , res, op1, op2, op1, op2); -} - -static void gen_min_u32 (TCGv_i32 res,TCGv_i32 op1,TCGv_i32 op2) -{ -tcg_gen_movcond_i32 (TCG_COND_LEU , res, op1, op2, op1, op2); -} -/* Pairwise op subgroup of C3.6.16. * * This is called directly or via the handle_3same_float for float pairwise
@@ -10051,7 +10033,7 @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode,static NeonGenTwoOpFn *const fns[3 ][2 ] = { { gen_helper_neon_pmax_s8, gen_helper_neon_pmax_u8 }, { gen_helper_neon_pmax_s16, gen_helper_neon_pmax_u16 }, - { gen_max_s32, gen_max_u32 }, + { tcg_gen_smax_i32, tcg_gen_umax_i32 }, }; genfn = fns[size][u];break ;
@@ -10061,7 +10043,7 @@ static void handle_simd_3same_pair(DisasContext *s, int is_q, int u, int opcode,static NeonGenTwoOpFn *const fns[3 ][2 ] = { { gen_helper_neon_pmin_s8, gen_helper_neon_pmin_u8 }, { gen_helper_neon_pmin_s16, gen_helper_neon_pmin_u16 }, - { gen_min_s32, gen_min_u32 }, + { tcg_gen_smin_i32, tcg_gen_umin_i32 }, }; genfn = fns[size][u];break ;
@@ -10516,7 +10498,7 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn)static NeonGenTwoOpFn *const fns[3 ][2 ] = { { gen_helper_neon_max_s8, gen_helper_neon_max_u8 }, { gen_helper_neon_max_s16, gen_helper_neon_max_u16 }, - { gen_max_s32, gen_max_u32 }, + { tcg_gen_smax_i32, tcg_gen_umax_i32 }, }; genfn = fns[size][u];break ;
@@ -10527,7 +10509,7 @@ static void disas_simd_3same_int(DisasContext *s, uint32_t insn)static NeonGenTwoOpFn *const fns[3 ][2 ] = { { gen_helper_neon_min_s8, gen_helper_neon_min_u8 }, { gen_helper_neon_min_s16, gen_helper_neon_min_u16 }, - { gen_min_s32, gen_min_u32 }, + { tcg_gen_smin_i32, tcg_gen_umin_i32 }, }; genfn = fns[size][u];break ;
Signature · 1 line
2.14.3
PATCH v2 3/10 target/xtensa: Use new min/max expanders
In reply to Richard HendersonThe generic expanders replace nearly identical code in the translator.
--- target/xtensa/translate.c | 50 +++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 17 deletions(-)
target/xtensa/translate.c +33 -17
@@ -1527,10 +1527,8 @@ static void translate_clamps(DisasContext *dc, const uint32_t arg[],TCGv_i32 tmp1 =tcg_const_i32 (-1u << arg[2 ]);TCGv_i32 tmp2 =tcg_const_i32 ((1 << arg[2 ]) -1 ); -tcg_gen_movcond_i32 (TCG_COND_GT , tmp1, - cpu_R[arg[1 ]], tmp1, cpu_R[arg[1 ]], tmp1); -tcg_gen_movcond_i32 (TCG_COND_LT , cpu_R[arg[0 ]], - tmp1, tmp2, tmp1, tmp2); +tcg_gen_smax_i32 (tmp1, tmp1, cpu_R[arg[1 ]]); +tcg_gen_smin_i32 (cpu_R[arg[0 ]], tmp1, tmp2);tcg_temp_free (tmp1);tcg_temp_free (tmp2); }
@@ -1855,13 +1853,35 @@ static void translate_memw(DisasContext *dc, const uint32_t arg[],tcg_gen_mb (TCG_BAR_SC |TCG_MO_ALL ); } -static void translate_minmax (DisasContext *dc,const uint32_t arg[], -const uint32_t par[]) +static void translate_smin (DisasContext *dc,const uint32_t arg[], +const uint32_t par[]) {if (gen_window_check3 (dc, arg[0 ], arg[1 ], arg[2 ])) { -tcg_gen_movcond_i32 (par[0 ], cpu_R[arg[0 ]], - cpu_R[arg[1 ]], cpu_R[arg[2 ]], - cpu_R[arg[1 ]], cpu_R[arg[2 ]]); +tcg_gen_smin_i32 (cpu_R[arg[0 ]], cpu_R[arg[1 ]], cpu_R[arg[2 ]]); + } +} + +static void translate_umin (DisasContext *dc,const uint32_t arg[], +const uint32_t par[]) +{ +if (gen_window_check3 (dc, arg[0 ], arg[1 ], arg[2 ])) { +tcg_gen_umin_i32 (cpu_R[arg[0 ]], cpu_R[arg[1 ]], cpu_R[arg[2 ]]); + } +} + +static void translate_smax (DisasContext *dc,const uint32_t arg[], +const uint32_t par[]) +{ +if (gen_window_check3 (dc, arg[0 ], arg[1 ], arg[2 ])) { +tcg_gen_smax_i32 (cpu_R[arg[0 ]], cpu_R[arg[1 ]], cpu_R[arg[2 ]]); + } +} + +static void translate_umax (DisasContext *dc,const uint32_t arg[], +const uint32_t par[]) +{ +if (gen_window_check3 (dc, arg[0 ], arg[1 ], arg[2 ])) { +tcg_gen_umax_i32 (cpu_R[arg[0 ]], cpu_R[arg[1 ]], cpu_R[arg[2 ]]); } }
@@ -2984,23 +3004,19 @@ static const XtensaOpcodeOps core_ops[] = { .par = (const uint32_t[]){TCG_COND_NE}, }, { .name = "max", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_GE}, + .translate = translate_smax, }, { .name = "maxu", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_GEU}, + .translate = translate_umax, }, { .name = "memw", .translate = translate_memw, }, { .name = "min", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_LT}, + .translate = translate_smin, }, { .name = "minu", - .translate = translate_minmax, - .par = (const uint32_t[]){TCG_COND_LTU}, + .translate = translate_umin, }, { .name = "mov", .translate = translate_mov,
Signature · 1 line
2.14.3
PATCH v2 4/10 tcg: Introduce atomic helpers for integer min/max
In reply to Richard HendersonGiven that this atomic operation will be used by both risc-v and aarch64, let's not duplicate code across the two targets.
--- accel/tcg/atomic_template.h | 71 +++++++++++++++++++++++++++++++++++++++++++++ accel/tcg/tcg-runtime.h | 8 +++++ tcg/tcg-op.h | 34 ++++++++++++++++++++++ tcg/tcg.h | 8 +++++ tcg/tcg-op.c | 8 +++++ 5 files changed, 129 insertions(+)
accel/tcg/atomic_template.h +71 -0
@@ -25,18 +25,22 @@#elif DATA_SIZE ==8 # define SUFFIX q# define DATA_TYPE uint64_t +# define SDATA_TYPE int64_t# define BSWAP bswap64#elif DATA_SIZE ==4 # define SUFFIX l# define DATA_TYPE uint32_t +# define SDATA_TYPE int32_t# define BSWAP bswap32#elif DATA_SIZE ==2 # define SUFFIX w# define DATA_TYPE uint16_t +# define SDATA_TYPE int16_t# define BSWAP bswap16#elif DATA_SIZE ==1 # define SUFFIX b# define DATA_TYPE uint8_t +# define SDATA_TYPE int8_t# define BSWAP #else # error unsupported data size
@@ -118,6 +122,39 @@ GEN_ATOMIC_HELPER(or_fetch) GEN_ATOMIC_HELPER(xor_fetch)#undef GEN_ATOMIC_HELPER + +/* These helpers are, as a whole, full barriers. Within the helper, +* the leading barrier is explicit and the trailing barrier is within +* cmpxchg primitive. +*/ +#define GEN_ATOMIC_HELPER_FN (X ,FN ,XDATA_TYPE ,RET ) \ +ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ + ABI_TYPE xval EXTRA_ARGS) \ +{ \ + ATOMIC_MMU_DECLS; \ + XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ + XDATA_TYPE cmp, old, new, val = xval; \ + smp_mb(); \ + cmp = atomic_read__nocheck(haddr); \ + do { \ + old = cmp; new = FN(old, val); \ + cmp = atomic_cmpxchg__nocheck(haddr, old, new); \ + } while (cmp != old); \ + ATOMIC_MMU_CLEANUP; \ + return RET; \ +} + +GEN_ATOMIC_HELPER_FN(fetch_smin, MIN, SDATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_umin, MIN, DATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_smax, MAX, SDATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_umax, MAX, DATA_TYPE, old) + +GEN_ATOMIC_HELPER_FN(smin_fetch, MIN, SDATA_TYPE, new) +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) + +#undef GEN_ATOMIC_HELPER_FN#endif /* DATA SIZE >= 16 */ #undef END
@@ -233,6 +270,39 @@ ABI_TYPE ATOMIC_NAME(add_fetch)(CPUArchState *env, target_ulong addr, 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. +*/ +#define GEN_ATOMIC_HELPER_FN (X ,FN ,XDATA_TYPE ,RET ) \ +ABI_TYPE ATOMIC_NAME(X)(CPUArchState *env, target_ulong addr, \ + ABI_TYPE xval EXTRA_ARGS) \ +{ \ + ATOMIC_MMU_DECLS; \ + XDATA_TYPE *haddr = ATOMIC_MMU_LOOKUP; \ + XDATA_TYPE ldo, ldn, old, new, val = xval; \ + smp_mb(); \ + ldn = atomic_read__nocheck(haddr); \ + do { \ + ldo = ldn; old = BSWAP(ldo); new = FN(old, val); \ + ldn = atomic_cmpxchg__nocheck(haddr, ldo, BSWAP(new)); \ + } while (ldo != ldn); \ + ATOMIC_MMU_CLEANUP; \ + return RET; \ +} + +GEN_ATOMIC_HELPER_FN(fetch_smin, MIN, SDATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_umin, MIN, DATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_smax, MAX, SDATA_TYPE, old) +GEN_ATOMIC_HELPER_FN(fetch_umax, MAX, DATA_TYPE, old) + +GEN_ATOMIC_HELPER_FN(smin_fetch, MIN, SDATA_TYPE, new) +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) + +#undef GEN_ATOMIC_HELPER_FN#endif /* DATA_SIZE >= 16 */ #undef END
@@ -241,5 +311,6 @@ ABI_TYPE ATOMIC_NAME(add_fetch)(CPUArchState *env, target_ulong addr,#undef BSWAP#undef ABI_TYPE#undef DATA_TYPE +#undef SDATA_TYPE#undef SUFFIX#undef DATA_SIZE
accel/tcg/tcg-runtime.h +8 -0
@@ -125,11 +125,19 @@ GEN_ATOMIC_HELPERS(fetch_add) GEN_ATOMIC_HELPERS(fetch_and) GEN_ATOMIC_HELPERS(fetch_or) GEN_ATOMIC_HELPERS(fetch_xor) +GEN_ATOMIC_HELPERS(fetch_smin) +GEN_ATOMIC_HELPERS(fetch_umin) +GEN_ATOMIC_HELPERS(fetch_smax) +GEN_ATOMIC_HELPERS(fetch_umax) GEN_ATOMIC_HELPERS(add_fetch) GEN_ATOMIC_HELPERS(and_fetch) GEN_ATOMIC_HELPERS(or_fetch) GEN_ATOMIC_HELPERS(xor_fetch) +GEN_ATOMIC_HELPERS(smin_fetch) +GEN_ATOMIC_HELPERS(umin_fetch) +GEN_ATOMIC_HELPERS(smax_fetch) +GEN_ATOMIC_HELPERS(umax_fetch) GEN_ATOMIC_HELPERS(xchg)
tcg/tcg-op.h +34 -0
@@ -898,6 +898,7 @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64, TCGv, TCGv_i64, TCGv_i64,void tcg_gen_atomic_xchg_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp );void tcg_gen_atomic_xchg_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_fetch_add_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp );void tcg_gen_atomic_fetch_add_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp );void tcg_gen_atomic_fetch_and_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp );
@@ -906,6 +907,15 @@ void tcg_gen_atomic_fetch_or_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp);void tcg_gen_atomic_fetch_or_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp );void tcg_gen_atomic_fetch_xor_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp );void tcg_gen_atomic_fetch_xor_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_fetch_smin_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_fetch_smin_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_fetch_umin_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_fetch_umin_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_fetch_smax_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_fetch_smax_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_fetch_umax_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_fetch_umax_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_add_fetch_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp );void tcg_gen_atomic_add_fetch_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp );void tcg_gen_atomic_and_fetch_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp );
@@ -914,6 +924,14 @@ void tcg_gen_atomic_or_fetch_i32(TCGv_i32, TCGv, TCGv_i32, TCGArg, TCGMemOp);void tcg_gen_atomic_or_fetch_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp );void tcg_gen_atomic_xor_fetch_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp );void tcg_gen_atomic_xor_fetch_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_smin_fetch_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_smin_fetch_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_umin_fetch_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_umin_fetch_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_smax_fetch_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_smax_fetch_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_umax_fetch_i32 (TCGv_i32 ,TCGv ,TCGv_i32 ,TCGArg ,TCGMemOp ); +void tcg_gen_atomic_umax_fetch_i64 (TCGv_i64 ,TCGv ,TCGv_i64 ,TCGArg ,TCGMemOp );void tcg_gen_mov_vec (TCGv_vec ,TCGv_vec );void tcg_gen_dup_i32_vec (unsigned vece,TCGv_vec ,TCGv_i32 );
@@ -1043,10 +1061,18 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t);#define tcg_gen_atomic_fetch_and_tl tcg_gen_atomic_fetch_and_i64#define tcg_gen_atomic_fetch_or_tl tcg_gen_atomic_fetch_or_i64#define tcg_gen_atomic_fetch_xor_tl tcg_gen_atomic_fetch_xor_i64 +#define tcg_gen_atomic_fetch_smin_tl tcg_gen_atomic_fetch_smin_i64 +#define tcg_gen_atomic_fetch_umin_tl tcg_gen_atomic_fetch_umin_i64 +#define tcg_gen_atomic_fetch_smax_tl tcg_gen_atomic_fetch_smax_i64 +#define tcg_gen_atomic_fetch_umax_tl tcg_gen_atomic_fetch_umax_i64#define tcg_gen_atomic_add_fetch_tl tcg_gen_atomic_add_fetch_i64#define tcg_gen_atomic_and_fetch_tl tcg_gen_atomic_and_fetch_i64#define tcg_gen_atomic_or_fetch_tl tcg_gen_atomic_or_fetch_i64#define tcg_gen_atomic_xor_fetch_tl tcg_gen_atomic_xor_fetch_i64 +#define tcg_gen_atomic_smin_fetch_tl tcg_gen_atomic_smin_fetch_i64 +#define tcg_gen_atomic_umin_fetch_tl tcg_gen_atomic_umin_fetch_i64 +#define tcg_gen_atomic_smax_fetch_tl tcg_gen_atomic_smax_fetch_i64 +#define tcg_gen_atomic_umax_fetch_tl tcg_gen_atomic_umax_fetch_i64#define tcg_gen_dup_tl_vec tcg_gen_dup_i64_vec#else #define tcg_gen_movi_tl tcg_gen_movi_i32
@@ -1145,10 +1171,18 @@ void tcg_gen_stl_vec(TCGv_vec r, TCGv_ptr base, TCGArg offset, TCGType t);#define tcg_gen_atomic_fetch_and_tl tcg_gen_atomic_fetch_and_i32#define tcg_gen_atomic_fetch_or_tl tcg_gen_atomic_fetch_or_i32#define tcg_gen_atomic_fetch_xor_tl tcg_gen_atomic_fetch_xor_i32 +#define tcg_gen_atomic_fetch_smin_tl tcg_gen_atomic_fetch_smin_i32 +#define tcg_gen_atomic_fetch_umin_tl tcg_gen_atomic_fetch_umin_i32 +#define tcg_gen_atomic_fetch_smax_tl tcg_gen_atomic_fetch_smax_i32 +#define tcg_gen_atomic_fetch_umax_tl tcg_gen_atomic_fetch_umax_i32#define tcg_gen_atomic_add_fetch_tl tcg_gen_atomic_add_fetch_i32#define tcg_gen_atomic_and_fetch_tl tcg_gen_atomic_and_fetch_i32#define tcg_gen_atomic_or_fetch_tl tcg_gen_atomic_or_fetch_i32#define tcg_gen_atomic_xor_fetch_tl tcg_gen_atomic_xor_fetch_i32 +#define tcg_gen_atomic_smin_fetch_tl tcg_gen_atomic_smin_fetch_i32 +#define tcg_gen_atomic_umin_fetch_tl tcg_gen_atomic_umin_fetch_i32 +#define tcg_gen_atomic_smax_fetch_tl tcg_gen_atomic_smax_fetch_i32 +#define tcg_gen_atomic_umax_fetch_tl tcg_gen_atomic_umax_fetch_i32#define tcg_gen_dup_tl_vec tcg_gen_dup_i32_vec#endif
tcg/tcg.h +8 -0
@@ -1415,12 +1415,20 @@ GEN_ATOMIC_HELPER_ALL(fetch_sub) GEN_ATOMIC_HELPER_ALL(fetch_and) GEN_ATOMIC_HELPER_ALL(fetch_or) GEN_ATOMIC_HELPER_ALL(fetch_xor) +GEN_ATOMIC_HELPER_ALL(fetch_smin) +GEN_ATOMIC_HELPER_ALL(fetch_umin) +GEN_ATOMIC_HELPER_ALL(fetch_smax) +GEN_ATOMIC_HELPER_ALL(fetch_umax) GEN_ATOMIC_HELPER_ALL(add_fetch) GEN_ATOMIC_HELPER_ALL(sub_fetch) GEN_ATOMIC_HELPER_ALL(and_fetch) GEN_ATOMIC_HELPER_ALL(or_fetch) GEN_ATOMIC_HELPER_ALL(xor_fetch) +GEN_ATOMIC_HELPER_ALL(smin_fetch) +GEN_ATOMIC_HELPER_ALL(umin_fetch) +GEN_ATOMIC_HELPER_ALL(smax_fetch) +GEN_ATOMIC_HELPER_ALL(umax_fetch) GEN_ATOMIC_HELPER_ALL(xchg)
tcg/tcg-op.c +8 -0
@@ -3051,11 +3051,19 @@ GEN_ATOMIC_HELPER(fetch_add, add, 0) GEN_ATOMIC_HELPER(fetch_and, and, 0) GEN_ATOMIC_HELPER(fetch_or, or, 0) GEN_ATOMIC_HELPER(fetch_xor, xor, 0) +GEN_ATOMIC_HELPER(fetch_smin, smin, 0) +GEN_ATOMIC_HELPER(fetch_umin, umin, 0) +GEN_ATOMIC_HELPER(fetch_smax, smax, 0) +GEN_ATOMIC_HELPER(fetch_umax, umax, 0) GEN_ATOMIC_HELPER(add_fetch, add, 1) GEN_ATOMIC_HELPER(and_fetch, and, 1) GEN_ATOMIC_HELPER(or_fetch, or, 1) GEN_ATOMIC_HELPER(xor_fetch, xor, 1) +GEN_ATOMIC_HELPER(smin_fetch, smin, 1) +GEN_ATOMIC_HELPER(umin_fetch, umin, 1) +GEN_ATOMIC_HELPER(smax_fetch, smax, 1) +GEN_ATOMIC_HELPER(umax_fetch, umax, 1)static void tcg_gen_mov2_i32 (TCGv_i32 r,TCGv_i32 a,TCGv_i32 b) {
Signature · 1 line
2.14.3
PATCH v2 5/10 tcg: Use GEN_ATOMIC_HELPER_FN for opposite endian atomic add
In reply to Richard Henderson--- accel/tcg/atomic_template.h | 49 +++++++-------------------------------------- 1 file changed, 7 insertions(+), 42 deletions(-)
accel/tcg/atomic_template.h +7 -42
@@ -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 */
Signature · 1 line
2.14.3
PATCH v2 6/10 target/riscv: Use new atomic min/max expanders
In reply to Richard Henderson--- target/riscv/translate.c | 72 ++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 52 deletions(-)
target/riscv/translate.c +20 -52
@@ -725,7 +725,6 @@ static void gen_atomic(DisasContext *ctx, uint32_t opc,TCGv src1, src2, dat;TCGLabel *l1, *l2;TCGMemOp mop; -TCGCond cond;bool aq, rl;/* Extract the size of the atomic operation. */
@@ -823,60 +822,29 @@ static void gen_atomic(DisasContext *ctx, uint32_t opc,tcg_gen_atomic_fetch_or_tl (src2, src1, src2, ctx->mem_idx, mop);gen_set_gpr (rd, src2);break ; -case OPC_RISC_AMOMIN : - cond =TCG_COND_LT ; - goto do_minmax; -case OPC_RISC_AMOMAX : - cond =TCG_COND_GT ; - goto do_minmax; -case OPC_RISC_AMOMINU : - cond =TCG_COND_LTU ; - goto do_minmax; -case OPC_RISC_AMOMAXU : - cond =TCG_COND_GTU ; - goto do_minmax; - do_minmax: -/* Handle the RL barrier. The AQ barrier is handled along the -parallel path by the SC atomic cmpxchg. On the serial path, -of course, barriers do not matter. */ -if (rl) { -tcg_gen_mb (TCG_MO_ALL |TCG_BAR_STRL ); - } -if (tb_cflags (ctx->tb) &CF_PARALLEL ) { - l1 =gen_new_label (); -gen_set_label (l1); - }else { - l1 =NULL ; - } -gen_get_gpr (src1, rs1);gen_get_gpr (src2, rs2); -if ((mop &MO_SSIZE ) ==MO_SL ) { -/* Sign-extend the register comparison input. */ -tcg_gen_ext32s_tl (src2, src2); - } - dat =tcg_temp_local_new (); -tcg_gen_qemu_ld_tl (dat, src1, ctx->mem_idx, mop); -tcg_gen_movcond_tl (cond, src2, dat, src2, dat, src2); - -if (tb_cflags (ctx->tb) &CF_PARALLEL ) { -/* Parallel context. Make this operation atomic by verifying -that the memory didn't change while we computed the result. */ -tcg_gen_atomic_cmpxchg_tl (src2, src1, dat, src2, ctx->mem_idx, mop); - -/* If the cmpxchg failed, retry. */ -/* ??? There is an assumption here that this will eventually -succeed, such that we don't live-lock. This is not unlike -a similar loop that the compiler would generate for e.g. -__atomic_fetch_and_xor, so don't worry about it. */ -tcg_gen_brcond_tl (TCG_COND_NE , dat, src2, l1); - }else { -/* Serial context. Directly store the result. */ -tcg_gen_qemu_st_tl (src2, src1, ctx->mem_idx, mop); - } -gen_set_gpr (rd, dat); -tcg_temp_free (dat); +tcg_gen_atomic_fetch_smin_tl (src2, src1, src2, ctx->mem_idx, mop); +gen_set_gpr (rd, src2); +break ; +case OPC_RISC_AMOMAX : +gen_get_gpr (src1, rs1); +gen_get_gpr (src2, rs2); +tcg_gen_atomic_fetch_smax_tl (src2, src1, src2, ctx->mem_idx, mop); +gen_set_gpr (rd, src2); +break ; +case OPC_RISC_AMOMINU : +gen_get_gpr (src1, rs1); +gen_get_gpr (src2, rs2); +tcg_gen_atomic_fetch_umin_tl (src2, src1, src2, ctx->mem_idx, mop); +gen_set_gpr (rd, src2); +break ; +case OPC_RISC_AMOMAXU : +gen_get_gpr (src1, rs1); +gen_get_gpr (src2, rs2); +tcg_gen_atomic_fetch_umax_tl (src2, src1, src2, ctx->mem_idx, mop); +gen_set_gpr (rd, src2);break ;default :
Signature · 1 line
2.14.3
PATCH v2 7/10 target/arm: Introduce ARM_FEATURE_V8_ATOMICS and initial decode
In reply to Richard HendersonThe insns in the ARMv8.1-Atomics are added to the existing load/store exclusive and load/store reg opcode spaces. Rearrange the top-level decoders for these to accomodate. The Atomics insns themselves still generate Unallocated.
--- target/arm/cpu.h | 2 + linux-user/elfload.c | 1 + target/arm/translate-a64.c | 182 +++++++++++++++++++++++++++++++++------------ 3 files changed, 139 insertions(+), 46 deletions(-)
target/arm/cpu.h +2 -0
@@ -1449,6 +1449,8 @@ enum arm_features {ARM_FEATURE_V8_SHA3 ,/* implements SHA3 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SM3 ,/* implements SM3 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SM4 ,/* implements SM4 part of v8 Crypto Extensions */ +ARM_FEATURE_V8_1 , +ARM_FEATURE_V8_ATOMICS =ARM_FEATURE_V8_1 ,/* mandatory extension */ ARM_FEATURE_V8_RDM ,/* implements v8.1 simd round multiply */ ARM_FEATURE_V8_FP16 ,/* implements v8.2 half-precision float */ ARM_FEATURE_V8_FCMA, /* has complex number part of v8.3 extensions. */
linux-user/elfload.c +1 -0
@@ -581,6 +581,7 @@ static uint32_t get_elf_hwcap(void)GET_FEATURE (ARM_FEATURE_V8_SHA512 ,ARM_HWCAP_A64_SHA512 );GET_FEATURE (ARM_FEATURE_V8_FP16 ,ARM_HWCAP_A64_FPHP |ARM_HWCAP_A64_ASIMDHP ); +GET_FEATURE (ARM_FEATURE_V8_ATOMICS ,ARM_HWCAP_A64_ATOMICS );GET_FEATURE (ARM_FEATURE_V8_RDM ,ARM_HWCAP_A64_ASIMDRDM );GET_FEATURE (ARM_FEATURE_V8_FCMA ,ARM_HWCAP_A64_FCMA );#undef GET_FEATURE
target/arm/translate-a64.c +136 -46
227 lines not on this page · raw message
Signature · 1 line
2.14.3
PATCH v2 8/10 target/arm: Fill in disas_ldst_atomic
In reply to Richard HendersonThis implements all of the v8.1-Atomics instructions except for compare-and-swap, which is decoded elsewhere.
--- target/arm/translate-a64.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
target/arm/translate-a64.c +36 -2
@@ -84,6 +84,7 @@ typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64);typedef void CryptoTwoOpFn (TCGv_ptr ,TCGv_ptr );typedef void CryptoThreeOpIntFn (TCGv_ptr ,TCGv_ptr ,TCGv_i32 );typedef void CryptoThreeOpFn (TCGv_ptr ,TCGv_ptr ,TCGv_ptr ); +typedef void AtomicThreeOpFn (TCGv_i64 ,TCGv_i64 ,TCGv_i64 ,TCGArg ,TCGMemOp );/* Note that the gvec expanders operate on offsets + sizes. */ typedef void GVecGen2Fn (unsigned ,uint32_t ,uint32_t ,uint32_t ,uint32_t );
@@ -2772,6 +2773,8 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn,int rn =extract32 (insn,5 ,5 );int o3_opc =extract32 (insn,12 ,4 );int feature =ARM_FEATURE_V8_ATOMICS ; +TCGv_i64 tcg_rn, tcg_rs; +AtomicThreeOpFn *fn;if (is_vector) {unallocated_encoding (s);
@@ -2779,14 +2782,32 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, }switch (o3_opc) {case 000 :/* LDADD */ + fn = tcg_gen_atomic_fetch_add_i64; +break ;case 001 :/* LDCLR */ + fn = tcg_gen_atomic_fetch_and_i64; +break ;case 002 :/* LDEOR */ + fn = tcg_gen_atomic_fetch_xor_i64; +break ;case 003 :/* LDSET */ + fn = tcg_gen_atomic_fetch_or_i64; +break ;case 004 :/* LDSMAX */ + fn = tcg_gen_atomic_fetch_smax_i64; +break ;case 005 :/* LDSMIN */ + fn = tcg_gen_atomic_fetch_smin_i64; +break ;case 006 :/* LDUMAX */ + fn = tcg_gen_atomic_fetch_umax_i64; +break ;case 007 :/* LDUMIN */ + fn = tcg_gen_atomic_fetch_umin_i64; +break ;case 010 :/* SWP */ + fn = tcg_gen_atomic_xchg_i64; +break ;default :unallocated_encoding (s);return ;
@@ -2796,8 +2817,21 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn,return ; } - (void )rs; - (void )rn; +if (rn ==31 ) { +gen_check_sp_alignment (s); + } + tcg_rn =cpu_reg_sp (s, rn); + tcg_rs =read_cpu_reg (s, rs, false); + +if (o3_opc ==1 ) {/* LDCLR */ +tcg_gen_not_i64 (tcg_rs, tcg_rs); + } + +/* The tcg atomic primitives are all full barriers. Therefore we +* can ignore the Acquire and Release bits of this instruction. +*/ +fn (cpu_reg (s, rt), tcg_rn, tcg_rs,get_mem_index (s), + s->be_data | size |MO_ALIGN ); }/* Load/store register (all forms) */
Signature · 1 line
2.14.3
PATCH v2 9/10 target/arm: Implement CAS and CASP
In reply to Richard Henderson--- target/arm/helper-a64.h | 2 + target/arm/helper-a64.c | 43 ++++++++++++++++ target/arm/translate-a64.c | 119 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 161 insertions(+), 3 deletions(-)
target/arm/helper-a64.h +2 -0
@@ -51,6 +51,8 @@ DEF_HELPER_FLAGS_4(paired_cmpxchg64_le_parallel, TCG_CALL_NO_WG, DEF_HELPER_FLAGS_4(paired_cmpxchg64_be, TCG_CALL_NO_WG, i64, env, i64, i64, i64)DEF_HELPER_FLAGS_4 (paired_cmpxchg64_be_parallel,TCG_CALL_NO_WG , i64, env, i64, i64, i64) +DEF_HELPER_5(casp_le_parallel, void, env, i32, i64, i64, i64) +DEF_HELPER_5(casp_be_parallel, void, env, i32, i64, i64, i64) DEF_HELPER_FLAGS_3(advsimd_maxh, TCG_CALL_NO_RWG, f16, f16, f16, ptr) DEF_HELPER_FLAGS_3(advsimd_minh, TCG_CALL_NO_RWG, f16, f16, f16, ptr)DEF_HELPER_FLAGS_3 (advsimd_maxnumh,TCG_CALL_NO_RWG , f16, f16, f16, ptr)
target/arm/helper-a64.c +43 -0
49 lines not on this page · raw message
target/arm/translate-a64.c +116 -3
145 lines not on this page · raw message
Signature · 1 line
2.14.3
PATCH v2 10/10 target/arm: Enable ARM_FEATURE_V8_ATOMICS for user-only
In reply to Richard Henderson--- target/arm/cpu64.c | 1 + 1 file changed, 1 insertion(+)
target/arm/cpu64.c +1 -0
@@ -248,6 +248,7 @@ static void aarch64_max_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_V8_SM4 );set_feature (&cpu->env,ARM_FEATURE_V8_PMULL );set_feature (&cpu->env,ARM_FEATURE_CRC ); +set_feature (&cpu->env,ARM_FEATURE_V8_ATOMICS );set_feature (&cpu->env,ARM_FEATURE_V8_RDM );set_feature (&cpu->env,ARM_FEATURE_V8_FP16 );set_feature (&cpu->env,ARM_FEATURE_V8_FCMA );
Signature · 1 line
2.14.3
This series seems to have some coding style problems. See output below for more information:
Hi,
This series seems to have some coding style problems. See output below for more information:
Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v2 00/10] target/arm: Implement v8.1-Atomics
=== TEST SCRIPT BEGIN ===
#!/bin/bash
BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do
echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
failed=1
echo
fi
n=$((n+1))done
exit $failed
=== TEST SCRIPT END ===
Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
t [tag update] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'85278ba514 target/arm: Enable ARM_FEATURE_V8_ATOMICS for user-only 94bdcba55b target/arm: Implement CAS and CASP62f42319cf target/arm: Fill in disas_ldst_atomic8d29049006 target/arm: Introduce ARM_FEATURE_V8_ATOMICS and initial decode faec1dbe5a target/riscv: Use new atomic min/max expanders 1fa0baa271 tcg: Use GEN_ATOMIC_HELPER_FN for opposite endian atomic add bb9e6b5cdb tcg: Introduce atomic helpers for integer min/max b0c37750f7 target/xtensa: Use new min/max expanders3373196e98 target/arm: Use new min/max expanders38706ce634 tcg: Introduce helpers for integer min/max
=== OUTPUT BEGIN ===
Checking PATCH 1/10: tcg: Introduce helpers for integer min/max... Checking PATCH 2/10: target/arm: Use new min/max expanders... Checking PATCH 3/10: target/xtensa: Use new min/max expanders... Checking PATCH 4/10: tcg: Introduce atomic helpers for integer min/max...
ERROR: memory barrier without comment
#56: FILE: accel/tcg/atomic_template.h:137:
+ smp_mb(); \
ERROR: memory barrier without comment
#96: FILE: accel/tcg/atomic_template.h:285:
+ smp_mb(); \
total: 2 errors, 0 warnings, 236 lines checked
Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
Checking PATCH 5/10: tcg: Use GEN_ATOMIC_HELPER_FN for opposite endian atomic add... Checking PATCH 6/10: target/riscv: Use new atomic min/max expanders... Checking PATCH 7/10: target/arm: Introduce ARM_FEATURE_V8_ATOMICS and initial decode... Checking PATCH 8/10: target/arm: Fill in disas_ldst_atomic...
Checking PATCH 9/10: target/arm: Implement CAS and CASP...
Checking PATCH 10/10: target/arm: Enable ARM_FEATURE_V8_ATOMICS for user-only... === OUTPUT END ===
Test command exited with code: 1
---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]
PATCH v3 8/10 target/arm: Fill in disas_ldst_atomic
In reply to Richard HendersonThis implements all of the v8.1-Atomics instructions except for compare-and-swap, which is decoded elsewhere.
---
v3: Do not zero-extend X[s] via the third parameter to read_cpu_reg.
--- target/arm/translate-a64.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-)
target/arm/translate-a64.c +36 -2
@@ -84,6 +84,7 @@ typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64);typedef void CryptoTwoOpFn (TCGv_ptr ,TCGv_ptr );typedef void CryptoThreeOpIntFn (TCGv_ptr ,TCGv_ptr ,TCGv_i32 );typedef void CryptoThreeOpFn (TCGv_ptr ,TCGv_ptr ,TCGv_ptr ); +typedef void AtomicThreeOpFn (TCGv_i64 ,TCGv_i64 ,TCGv_i64 ,TCGArg ,TCGMemOp );/* Note that the gvec expanders operate on offsets + sizes. */ typedef void GVecGen2Fn (unsigned ,uint32_t ,uint32_t ,uint32_t ,uint32_t );
@@ -2772,6 +2773,8 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn,int rn =extract32 (insn,5 ,5 );int o3_opc =extract32 (insn,12 ,4 );int feature =ARM_FEATURE_V8_ATOMICS ; +TCGv_i64 tcg_rn, tcg_rs; +AtomicThreeOpFn *fn;if (is_vector) {unallocated_encoding (s);
@@ -2779,14 +2782,32 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, }switch (o3_opc) {case 000 :/* LDADD */ + fn = tcg_gen_atomic_fetch_add_i64; +break ;case 001 :/* LDCLR */ + fn = tcg_gen_atomic_fetch_and_i64; +break ;case 002 :/* LDEOR */ + fn = tcg_gen_atomic_fetch_xor_i64; +break ;case 003 :/* LDSET */ + fn = tcg_gen_atomic_fetch_or_i64; +break ;case 004 :/* LDSMAX */ + fn = tcg_gen_atomic_fetch_smax_i64; +break ;case 005 :/* LDSMIN */ + fn = tcg_gen_atomic_fetch_smin_i64; +break ;case 006 :/* LDUMAX */ + fn = tcg_gen_atomic_fetch_umax_i64; +break ;case 007 :/* LDUMIN */ + fn = tcg_gen_atomic_fetch_umin_i64; +break ;case 010 :/* SWP */ + fn = tcg_gen_atomic_xchg_i64; +break ;default :unallocated_encoding (s);return ;
@@ -2796,8 +2817,21 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn,return ; } - (void )rs; - (void )rn; +if (rn ==31 ) { +gen_check_sp_alignment (s); + } + tcg_rn =cpu_reg_sp (s, rn); + tcg_rs =read_cpu_reg (s, rs, true); + +if (o3_opc ==1 ) {/* LDCLR */ +tcg_gen_not_i64 (tcg_rs, tcg_rs); + } + +/* The tcg atomic primitives are all full barriers. Therefore we +* can ignore the Acquire and Release bits of this instruction. +*/ +fn (cpu_reg (s, rt), tcg_rn, tcg_rs,get_mem_index (s), + s->be_data | size |MO_ALIGN ); }/* Load/store register (all forms) */
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH v3 08/10] target/arm: Fill in disas_ldst_atomic
Quoted 7 lines · Richard Henderson
This implements all of the v8.1-Atomics instructions except for compare-and-swap, which is decoded elsewhere.
Reviewed-by Peter Maydell <[email protected]>Signed-off-by Richard Henderson <[email protected]>---
v3: Do not zero-extend X[s] via the third parameter toread_cpu_reg.
Can you just resend the full series, please? Sending a single patch rather than the whole thing means that 'patches' complains about "series is either incomplete or improperly threaded", and my eyeball for updated versions to add to my to-review queue generally skips over patches which aren't cover letters or single-patches...
thanks
-- PMM