qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com
Subject: [Qemu-devel] [PATCH 02/11] tcg-sparc: Fix tlb read
Date: Wed,  5 Mar 2014 10:11:12 -0800	[thread overview]
Message-ID: <1394043081-4668-3-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1394043081-4668-1-git-send-email-rth@twiddle.net>

We were computing the full address into %o0 and then not using it.
Adjust some of the computation to rely less on having to pull immediate
values into registers.

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

diff --git a/tcg/sparc/tcg-target.c b/tcg/sparc/tcg-target.c
index b459886..9d461a1 100644
--- a/tcg/sparc/tcg-target.c
+++ b/tcg/sparc/tcg-target.c
@@ -480,19 +480,6 @@ static inline void tcg_out_addi(TCGContext *s, int reg, tcg_target_long val)
     }
 }
 
-static inline void tcg_out_andi(TCGContext *s, int rd, int rs,
-                                tcg_target_long val)
-{
-    if (val != 0) {
-        if (check_fit_tl(val, 13))
-            tcg_out_arithi(s, rd, rs, val, ARITH_AND);
-        else {
-            tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T1, val);
-            tcg_out_arith(s, rd, rs, TCG_REG_T1, ARITH_AND);
-        }
-    }
-}
-
 static void tcg_out_div32(TCGContext *s, int rd, int rs1,
                           int val2, int val2const, int uns)
 {
@@ -880,17 +867,24 @@ static int tcg_out_tlb_load(TCGContext *s, int addrlo_idx, int mem_index,
         tcg_out_arithi(s, r0, addrlo, 0, SHIFT_SRL);
         tcg_out_arithi(s, r1, args[addrlo_idx + 1], 32, SHIFT_SLLX);
         tcg_out_arith(s, r0, r0, r1, ARITH_OR);
+        addr = r0;
     }
 
-    /* Shift the page number down to tlb-entry.  */
-    tcg_out_arithi(s, r1, addrlo,
-                   TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS, SHIFT_SRL);
+    /* Shift the page number down.  */
+    tcg_out_arithi(s, r1, addrlo, TARGET_PAGE_BITS, SHIFT_SRL);
 
     /* Mask out the page offset, except for the required alignment.  */
-    tcg_out_andi(s, r0, addr, TARGET_PAGE_MASK | ((1 << s_bits) - 1));
+    tcg_out_movi(s, TCG_TYPE_TL, TCG_REG_T1,
+                 TARGET_PAGE_MASK | ((1 << s_bits) - 1));
+
+    /* Mask the tlb index.  */
+    tcg_out_arithi(s, r1, r1, CPU_TLB_SIZE - 1, ARITH_AND);
+    
+    /* Mask page, part 2.  */
+    tcg_out_arith(s, r0, addr, TCG_REG_T1, ARITH_AND);
 
-    /* Compute tlb index, modulo tlb size.  */
-    tcg_out_andi(s, r1, r1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
+    /* Shift the tlb index into place.  */
+    tcg_out_arithi(s, r1, r1, CPU_TLB_ENTRY_BITS, SHIFT_SLL);
 
     /* Relative to the current ENV.  */
     tcg_out_arith(s, r1, TCG_AREG0, r1, ARITH_ADD);
@@ -898,8 +892,8 @@ static int tcg_out_tlb_load(TCGContext *s, int addrlo_idx, int mem_index,
     /* Find a base address that can load both tlb comparator and addend.  */
     tlb_ofs = offsetof(CPUArchState, tlb_table[mem_index][0]);
     if (!check_fit_tl(tlb_ofs + sizeof(CPUTLBEntry), 13)) {
-        tcg_out_addi(s, r1, tlb_ofs);
-        tlb_ofs = 0;
+        tcg_out_addi(s, r1, tlb_ofs & ~0x3ff);
+        tlb_ofs &= 0x3ff;
     }
 
     /* Load the tlb comparator and the addend.  */
-- 
1.8.5.3

  parent reply	other threads:[~2014-03-05 18:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-05 18:11 [Qemu-devel] [PATCH 00/11] tcg-sparc updates Richard Henderson
2014-03-05 18:11 ` [Qemu-devel] [PATCH 01/11] tcg-sparc: Fix ld64 for 32-bit mode Richard Henderson
2014-03-05 18:11 ` Richard Henderson [this message]
2014-03-05 18:11 ` [Qemu-devel] [PATCH 03/11] tcg-sparc: Tidy call+jump patterns Richard Henderson
2014-03-05 18:11 ` [Qemu-devel] [PATCH 04/11] tcg-sparc: Use intptr_t as appropriate Richard Henderson
2014-03-05 18:11 ` [Qemu-devel] [PATCH 05/11] tcg-sparc: Don't handle remainder Richard Henderson
2014-03-05 18:11 ` [Qemu-devel] [PATCH 06/11] tcg-sparc: Dont handle constant arguments to ext32 ops Richard Henderson
2014-03-05 18:11 ` [Qemu-devel] [PATCH 07/11] tcg-sparc: Improve tcg_out_movi Richard Henderson
2014-03-05 18:11 ` [Qemu-devel] [PATCH 08/11] tcg-sparc: Use TCGMemOp within qemu_ldst routines Richard Henderson
2014-03-05 18:11 ` [Qemu-devel] [PATCH 09/11] tcg-sparc: Tidy tcg_out_tlb_load interface Richard Henderson
2014-03-05 18:11 ` [Qemu-devel] [PATCH 10/11] tcg-sparc: Convert to new ldst helpers Richard Henderson
2014-03-05 18:11 ` [Qemu-devel] [PATCH 11/11] tcg-sparc: Convert to new ldst opcodes Richard Henderson
2014-03-09 22:21 ` [Qemu-devel] [PATCH 00/11] tcg-sparc updates Mark Cave-Ayland
2014-03-10  9:06   ` Artyom Tarasenko
2014-03-10  9:19     ` Mark Cave-Ayland
2014-03-10 16:03       ` Richard Henderson

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=1394043081-4668-3-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=blauwirbel@gmail.com \
    --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).