diff options
author | Richard Henderson <rth@twiddle.net> | 2016-07-12 16:10:32 -0700 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2016-10-31 09:46:25 -0600 |
commit | 7268adebfda6548b8ae6865dc8337f116a5d266d (patch) | |
tree | 20244be3e68f724dcff3a39bb7036630ea93aa00 /target-sparc/translate.c | |
parent | fbb4bbb62e5603c991b880e25dc4bb30d342b944 (diff) |
target-sparc: Implement cas_asi/casx_asi inline
Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'target-sparc/translate.c')
-rw-r--r-- | target-sparc/translate.c | 70 |
1 files changed, 47 insertions, 23 deletions
diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 8d879a9985..0fb361a8bb 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -2338,24 +2338,37 @@ static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src, } } -static void gen_cas_asi(DisasContext *dc, TCGv addr, TCGv val2, +static void gen_cas_asi(DisasContext *dc, TCGv addr, TCGv cmpr, int insn, int rd) { DisasASI da = get_asi(dc, insn, MO_TEUL); - TCGv val1, dst; - TCGv_i32 r_asi; + TCGv cmpv, oldv, tmpv; - if (da.type == GET_ASI_EXCP) { + switch (da.type) { + case GET_ASI_EXCP: return; + case GET_ASI_DIRECT: + cmpv = tcg_temp_new(); + oldv = tcg_temp_new(); + tmpv = tcg_temp_new(); + tcg_gen_ext32u_tl(cmpv, cmpr); + + /* ??? Should be atomic. */ + tcg_gen_qemu_ld_tl(oldv, addr, da.mem_idx, da.memop); + tcg_gen_movcond_tl(TCG_COND_EQ, tmpv, oldv, cmpv, + gen_load_gpr(dc, rd), oldv); + tcg_gen_qemu_st_tl(tmpv, addr, da.mem_idx, da.memop); + + gen_store_gpr(dc, rd, oldv); + tcg_temp_free(cmpv); + tcg_temp_free(oldv); + tcg_temp_free(tmpv); + break; + default: + /* ??? Should be DAE_invalid_asi. */ + gen_exception(dc, TT_DATA_ACCESS); + break; } - - save_state(dc); - val1 = gen_load_gpr(dc, rd); - dst = gen_dest_gpr(dc, rd); - r_asi = tcg_const_i32(da.asi); - gen_helper_cas_asi(dst, cpu_env, addr, val1, val2, r_asi); - tcg_temp_free_i32(r_asi); - gen_store_gpr(dc, rd, dst); } static void gen_ldstub_asi(DisasContext *dc, TCGv dst, TCGv addr, int insn) @@ -2668,23 +2681,34 @@ static void gen_stda_asi(DisasContext *dc, TCGv hi, TCGv addr, } } -static void gen_casx_asi(DisasContext *dc, TCGv addr, TCGv val2, +static void gen_casx_asi(DisasContext *dc, TCGv addr, TCGv cmpv, int insn, int rd) { DisasASI da = get_asi(dc, insn, MO_TEQ); - TCGv val1 = gen_load_gpr(dc, rd); - TCGv dst = gen_dest_gpr(dc, rd); - TCGv_i32 r_asi; + TCGv oldv, tmpv; - if (da.type == GET_ASI_EXCP) { + switch (da.type) { + case GET_ASI_EXCP: return; + case GET_ASI_DIRECT: + oldv = tcg_temp_new(); + tmpv = tcg_temp_new(); + + /* ??? Should be atomic. */ + tcg_gen_qemu_ld_tl(oldv, addr, da.mem_idx, da.memop); + tcg_gen_movcond_tl(TCG_COND_EQ, tmpv, oldv, cmpv, + gen_load_gpr(dc, rd), oldv); + tcg_gen_qemu_st_tl(tmpv, addr, da.mem_idx, da.memop); + + gen_store_gpr(dc, rd, oldv); + tcg_temp_free(oldv); + tcg_temp_free(tmpv); + break; + default: + /* ??? Should be DAE_invalid_asi. */ + gen_exception(dc, TT_DATA_ACCESS); + break; } - - save_state(dc); - r_asi = tcg_const_i32(da.asi); - gen_helper_casx_asi(dst, cpu_env, addr, val1, val2, r_asi); - tcg_temp_free_i32(r_asi); - gen_store_gpr(dc, rd, dst); } #elif !defined(CONFIG_USER_ONLY) |