qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: mark.cave-ayland@ilande.co.uk, atar4qemu@gmail.com
Subject: [Qemu-devel] [PATCH 06/16] target-sparc: Implement swap_asi inline
Date: Mon, 10 Oct 2016 10:16:58 -0500	[thread overview]
Message-ID: <1476112628-12241-7-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1476112628-12241-1-git-send-email-rth@twiddle.net>

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 target-sparc/translate.c | 49 +++++++++++++++++++++---------------------------
 1 file changed, 21 insertions(+), 28 deletions(-)

diff --git a/target-sparc/translate.c b/target-sparc/translate.c
index e7e07de..8cd8bb6 100644
--- a/target-sparc/translate.c
+++ b/target-sparc/translate.c
@@ -2001,6 +2001,18 @@ static inline void gen_ne_fop_QD(DisasContext *dc, int rd, int rs,
     gen_update_fprs_dirty(dc, QFPREG(rd));
 }
 
+static void gen_swap(DisasContext *dc, TCGv dst, TCGv src,
+                     TCGv addr, int mmu_idx, TCGMemOp memop)
+{
+    /* ??? Should be atomic.  */
+    TCGv t0 = tcg_temp_new();
+    gen_address_mask(dc, addr);
+    tcg_gen_qemu_ld_tl(t0, addr, mmu_idx, memop);
+    tcg_gen_qemu_st_tl(src, addr, mmu_idx, memop);
+    tcg_gen_mov_tl(dst, t0);
+    tcg_temp_free(t0);
+}
+
 /* asi moves */
 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
 typedef enum {
@@ -2302,26 +2314,12 @@ static void gen_swap_asi(DisasContext *dc, TCGv dst, TCGv src,
     switch (da.type) {
     case GET_ASI_EXCP:
         break;
+    case GET_ASI_DIRECT:
+        gen_swap(dc, dst, src, addr, da.mem_idx, da.memop);
+        break;
     default:
-        {
-            TCGv_i32 r_asi = tcg_const_i32(da.asi);
-            TCGv_i32 r_mop = tcg_const_i32(MO_UL);
-            TCGv_i64 s64, t64;
-
-            save_state(dc);
-            t64 = tcg_temp_new_i64();
-            gen_helper_ld_asi(t64, cpu_env, addr, r_asi, r_mop);
-
-            s64 = tcg_temp_new_i64();
-            tcg_gen_extu_tl_i64(s64, src);
-            gen_helper_st_asi(cpu_env, addr, s64, r_asi, r_mop);
-            tcg_temp_free_i64(s64);
-            tcg_temp_free_i32(r_mop);
-            tcg_temp_free_i32(r_asi);
-
-            tcg_gen_trunc_i64_tl(dst, t64);
-            tcg_temp_free_i64(t64);
-        }
+        /* ??? Should be DAE_invalid_asi.  */
+        gen_exception(dc, TT_DATA_ACCESS);
         break;
     }
 }
@@ -5207,15 +5205,10 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
                     break;
                 case 0x0f:
                     /* swap, swap register with memory. Also atomically */
-                    {
-                        TCGv t0 = get_temp_tl(dc);
-                        CHECK_IU_FEATURE(dc, SWAP);
-                        cpu_src1 = gen_load_gpr(dc, rd);
-                        gen_address_mask(dc, cpu_addr);
-                        tcg_gen_qemu_ld32u(t0, cpu_addr, dc->mem_idx);
-                        tcg_gen_qemu_st32(cpu_src1, cpu_addr, dc->mem_idx);
-                        tcg_gen_mov_tl(cpu_val, t0);
-                    }
+                    CHECK_IU_FEATURE(dc, SWAP);
+                    cpu_src1 = gen_load_gpr(dc, rd);
+                    gen_swap(dc, cpu_val, cpu_src1, cpu_addr,
+                             dc->mem_idx, MO_TEUL);
                     break;
 #if !defined(CONFIG_USER_ONLY) || defined(TARGET_SPARC64)
                 case 0x10:      /* lda, V9 lduwa, load word alternate */
-- 
2.7.4

  parent reply	other threads:[~2016-10-10 15:17 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10 15:16 [Qemu-devel] [PATCH 00/16] target-sparc improvements Richard Henderson
2016-10-10 15:16 ` [Qemu-devel] [PATCH 01/16] target-sparc: Use overalignment flags for twinx and block asis Richard Henderson
2016-10-10 15:16 ` [Qemu-devel] [PATCH 02/16] target-sparc: Introduce cpu_raise_exception_ra Richard Henderson
2016-10-10 15:16 ` [Qemu-devel] [PATCH 03/16] target-sparc: Add MMU_PHYS_IDX Richard Henderson
2016-10-10 15:16 ` [Qemu-devel] [PATCH 04/16] target-sparc: Use MMU_PHYS_IDX for bypass asis Richard Henderson
2016-10-10 15:16 ` [Qemu-devel] [PATCH 05/16] target-sparc: Handle more twinx asis Richard Henderson
2016-10-10 15:16 ` Richard Henderson [this message]
2016-10-10 15:16 ` [Qemu-devel] [PATCH 07/16] target-sparc: Implement ldstub_asi inline Richard Henderson
2016-10-10 15:17 ` [Qemu-devel] [PATCH 08/16] target-sparc: Implement cas_asi/casx_asi inline Richard Henderson
2016-10-10 15:17 ` [Qemu-devel] [PATCH 09/16] target-sparc: Implement BCOPY/BFILL inline Richard Henderson
2016-10-10 15:17 ` [Qemu-devel] [PATCH 10/16] target-sparc: Remove asi helper code handled inline Richard Henderson
2016-10-10 15:17 ` [Qemu-devel] [PATCH 11/16] target-sparc: Implement ldqf and stqf inline Richard Henderson
2016-10-10 15:17 ` [Qemu-devel] [PATCH 12/16] target-sparc: Allow 4-byte alignment on fp mem ops Richard Henderson
2016-10-10 15:17 ` [Qemu-devel] [PATCH 13/16] target-sparc: Remove MMU_MODE*_SUFFIX Richard Henderson
2016-10-10 15:17 ` [Qemu-devel] [PATCH 14/16] target-sparc: Optmize writeback of cpu_cond Richard Henderson
2016-10-10 15:17 ` [Qemu-devel] [PATCH 15/16] target-sparc: Use tcg_gen_atomic_xchg_tl Richard Henderson
2016-10-10 15:17 ` [Qemu-devel] [PATCH 16/16] target-sparc: Use tcg_gen_atomic_cmpxchg_tl Richard Henderson
2016-10-10 17:02 ` [Qemu-devel] [PATCH 00/16] target-sparc improvements no-reply
2016-10-11 21:42 ` Mark Cave-Ayland
2016-10-12  1:42   ` Richard Henderson
2016-10-15  8:08     ` Mark Cave-Ayland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1476112628-12241-7-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=atar4qemu@gmail.com \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).