target-sparc: Use tcg_gen_atomic_cmpxchg_tl

Backports commit 5a7267b6a9e94c264ca77a7ca5a239e70dac81da from qemu
This commit is contained in:
Richard Henderson 2018-03-01 08:34:32 -05:00 committed by Lioncash
parent 47313adedd
commit f9d91a81b5
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -2548,32 +2548,22 @@ static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src,
}
}
static void gen_cas_asi(DisasContext *dc, TCGv addr, TCGv cmpr,
static void gen_cas_asi(DisasContext *dc, TCGv addr, TCGv cmpv,
int insn, int rd)
{
TCGContext *tcg_ctx = dc->uc->tcg_ctx;
DisasASI da = get_asi(dc, insn, MO_TEUL);
TCGv cmpv, oldv, tmpv;
TCGv oldv;
switch (da.type) {
case GET_ASI_EXCP:
return;
case GET_ASI_DIRECT:
cmpv = tcg_temp_new(tcg_ctx);
oldv = tcg_temp_new(tcg_ctx);
tmpv = tcg_temp_new(tcg_ctx);
tcg_gen_ext32u_tl(tcg_ctx, cmpv, cmpr);
/* ??? Should be atomic. */
tcg_gen_qemu_ld_tl(dc->uc, oldv, addr, da.mem_idx, da.memop);
tcg_gen_movcond_tl(tcg_ctx, TCG_COND_EQ, tmpv, oldv, cmpv,
gen_load_gpr(dc, rd), oldv);
tcg_gen_qemu_st_tl(dc->uc, tmpv, addr, da.mem_idx, da.memop);
tcg_gen_atomic_cmpxchg_tl(tcg_ctx, oldv, addr, cmpv, gen_load_gpr(dc, rd),
da.mem_idx, da.memop);
gen_store_gpr(dc, rd, oldv);
tcg_temp_free(tcg_ctx, cmpv);
tcg_temp_free(tcg_ctx, oldv);
tcg_temp_free(tcg_ctx, tmpv);
break;
default:
/* ??? Should be DAE_invalid_asi. */
@ -2933,24 +2923,17 @@ static void gen_casx_asi(DisasContext *dc, TCGv addr, TCGv cmpv,
{
TCGContext *tcg_ctx = dc->uc->tcg_ctx;
DisasASI da = get_asi(dc, insn, MO_TEQ);
TCGv oldv, tmpv;
TCGv oldv;
switch (da.type) {
case GET_ASI_EXCP:
return;
case GET_ASI_DIRECT:
oldv = tcg_temp_new(tcg_ctx);
tmpv = tcg_temp_new(tcg_ctx);
/* ??? Should be atomic. */
tcg_gen_qemu_ld_tl(dc->uc, oldv, addr, da.mem_idx, da.memop);
tcg_gen_movcond_tl(tcg_ctx, TCG_COND_EQ, tmpv, oldv, cmpv,
gen_load_gpr(dc, rd), oldv);
tcg_gen_qemu_st_tl(dc->uc, tmpv, addr, da.mem_idx, da.memop);
tcg_gen_atomic_cmpxchg_tl(tcg_ctx, oldv, addr, cmpv, gen_load_gpr(dc, rd),
da.mem_idx, da.memop);
gen_store_gpr(dc, rd, oldv);
tcg_temp_free(tcg_ctx, oldv);
tcg_temp_free(tcg_ctx, tmpv);
break;
default:
/* ??? Should be DAE_invalid_asi. */