Skip to contentSkip to conversation

target-alpha PALcode improvments

GIT PULL Applied Richard Henderson 2 participants 5 messages Aug 18, 2015 – Aug 19, 2015

lore
Share & tools
lore
#0 lore raw

Posted and reviewed back in June, queued for 2.5 development.

r~

The following changes since commit 074a9925e1cfd659d5376dcaccd1436d3840e611:

Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (2015-08-14 16:52:34 +0100)

are available in the git repository at:

git://github.com/rth7680/qemu.git tags/pull-axp-201508018

for you to fetch changes up to 6c05d3ded7b51154e67c35e270c48784b7046883:

target-alpha: Inline hw_ret (2015-08-18 11:08:59 -0700)

----------------------------------------------------------------
Alpha shadow register optimization

----------------------------------------------------------------
Richard Henderson (3):
target-alpha: Use separate TCGv temporaries for the shadow registers
target-alpha: Inline call_pal
target-alpha: Inline hw_ret

 target-alpha/cpu.h        |   3 +-
 target-alpha/gdbstub.c    |   4 +-
 target-alpha/helper.c     |  63 ++++++---------
 target-alpha/helper.h     |   3 -
 target-alpha/machine.c    |   4 +-
 target-alpha/sys_helper.c |  22 -----
 target-alpha/translate.c  | 201 ++++++++++++++++++++++++++++++----------------
 7 files changed, 166 insertions(+), 134 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 3/3] target-alpha: Inline hw_ret

---
 target-alpha/helper.h     |  2 --
 target-alpha/sys_helper.c |  8 --------
 target-alpha/translate.c  | 15 ++++++++++-----
 3 files changed, 10 insertions(+), 15 deletions(-)
target-alpha/helper.h +0 -2
index e7f0450..42bb247 100644
@@ -91,8 +91,6 @@ DEF_HELPER_FLAGS_2(ieee_input_cmp, TCG_CALL_NO_WG, void, env, i64)
 DEF_HELPER_FLAGS_2(ieee_input_s, TCG_CALL_NO_WG, void, env, i64)
 
 #if !defined (CONFIG_USER_ONLY)
-DEF_HELPER_2(hw_ret, void, env, i64)
-
 DEF_HELPER_2(ldl_phys, i64, env, i64)
 DEF_HELPER_2(ldq_phys, i64, env, i64)
 DEF_HELPER_2(ldl_l_phys, i64, env, i64)
target-alpha/sys_helper.c +0 -8
index 380d6e4..1f0e1a9 100644
@@ -40,14 +40,6 @@ uint64_t helper_load_pcc(CPUAlphaState *env)
 
 /* PALcode support special instructions */
 #ifndef CONFIG_USER_ONLY
-void helper_hw_ret(CPUAlphaState *env, uint64_t a)
-{
-    env->pc = a & ~3;
-    env->intr_flag = 0;
-    env->lock_addr = -1;
-    env->pal_mode = a & 1;
-}
-
 void helper_tbia(CPUAlphaState *env)
 {
     tlb_flush(CPU(alpha_env_get_cpu(env)), 1);
target-alpha/translate.c +10 -5
index 01e7f35..2849ede 100644
@@ -2635,13 +2635,18 @@ static ExitStatus translate_one(DisasContext *ctx, uint32_t insn)
             /* Pre-EV6 CPUs interpreted this as HW_REI, loading the return
                address from EXC_ADDR.  This turns out to be useful for our
                emulation PALcode, so continue to accept it.  */
-            tmp = tcg_temp_new();
-            tcg_gen_ld_i64(tmp, cpu_env, offsetof(CPUAlphaState, exc_addr));
-            gen_helper_hw_ret(cpu_env, tmp);
-            tcg_temp_free(tmp);
+            ctx->lit = vb = tcg_temp_new();
+            tcg_gen_ld_i64(vb, cpu_env, offsetof(CPUAlphaState, exc_addr));
         } else {
-            gen_helper_hw_ret(cpu_env, load_gpr(ctx, rb));
+            vb = load_gpr(ctx, rb);
         }
+        tmp = tcg_temp_new();
+        tcg_gen_movi_i64(tmp, 0);
+        tcg_gen_st8_i64(tmp, cpu_env, offsetof(CPUAlphaState, intr_flag));
+        tcg_gen_movi_i64(cpu_lock_addr, -1);
+        tcg_gen_andi_i64(tmp, vb, 1);
+        tcg_gen_st8_i64(tmp, cpu_env, offsetof(CPUAlphaState, pal_mode));
+        tcg_gen_andi_i64(cpu_pc, vb, ~3);
         ret = EXIT_PC_UPDATED;
         break;
 #else
Signature · 1 line
2.4.3
#2 lore raw

[Qemu-devel] [PULL 1/3] target-alpha: Use separate TCGv temporaries for the shadow registers

In reply to Richard Henderson

This avoids having to manually swap them around when swapping to and from PALmode. We simply encode the shadow registers into the translation.

The VMStateDescription version changes, because the meaning of "shadow" changes in the save file when in PALmode. It would be possible to fix this, but I don't think it's worth the effort.

---
 target-alpha/cpu.h        |   3 +-
 target-alpha/gdbstub.c    |   4 +-
 target-alpha/helper.c     |  63 ++++++++-----------
 target-alpha/machine.c    |   4 +-
 target-alpha/sys_helper.c |  10 +--
 target-alpha/translate.c  | 153 ++++++++++++++++++++++++++++++----------------
 6 files changed, 134 insertions(+), 103 deletions(-)
target-alpha/cpu.h +2 -1
index 91c56d6..3f1ece3 100644
@@ -445,8 +445,9 @@ void QEMU_NORETURN arith_excp(CPUAlphaState *, uintptr_t, int, uint64_t);
 
 uint64_t cpu_alpha_load_fpcr (CPUAlphaState *env);
 void cpu_alpha_store_fpcr (CPUAlphaState *env, uint64_t val);
+uint64_t cpu_alpha_load_gr(CPUAlphaState *env, unsigned reg);
+void cpu_alpha_store_gr(CPUAlphaState *env, unsigned reg, uint64_t val);
 #ifndef CONFIG_USER_ONLY
-void swap_shadow_regs(CPUAlphaState *env);
 QEMU_NORETURN void alpha_cpu_unassigned_access(CPUState *cpu, hwaddr addr,
                                                bool is_write, bool is_exec,
                                                int unused, unsigned size);
target-alpha/gdbstub.c +2 -2
index 980f140..99a4051 100644
@@ -30,7 +30,7 @@ int alpha_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n)
 
     switch (n) {
     case 0 ... 30:
-        val = env->ir[n];
+        val = cpu_alpha_load_gr(env, n);
         break;
     case 32 ... 62:
         d.d = env->fir[n - 32];
@@ -66,7 +66,7 @@ int alpha_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n)
 
     switch (n) {
     case 0 ... 30:
-        env->ir[n] = tmp;
+        cpu_alpha_store_gr(env, n, tmp);
         break;
     case 32 ... 62:
         d.ll = tmp;
target-alpha/helper.c +26 -37

87 lines not on this page · raw message

target-alpha/machine.c +2 -2
index e796bbe..d9bf977 100644
@@ -70,8 +70,8 @@ static VMStateField vmstate_env_fields[] = {
 
 static const VMStateDescription vmstate_env = {
     .name = "env",
-    .version_id = 1,
-    .minimum_version_id = 1,
+    .version_id = 2,
+    .minimum_version_id = 2,
     .fields = vmstate_env_fields,
 };
 
target-alpha/sys_helper.c +2 -8
index 1c59e10..f01eb96 100644
@@ -45,10 +45,7 @@ void helper_hw_ret(CPUAlphaState *env, uint64_t a)
     env->pc = a & ~3;
     env->intr_flag = 0;
     env->lock_addr = -1;
-    if ((a & 1) == 0) {
-        env->pal_mode = 0;
-        swap_shadow_regs(env);
-    }
+    env->pal_mode = a & 1;
 }
 
 void helper_call_pal(CPUAlphaState *env, uint64_t pc, uint64_t entry_ofs)
@@ -56,10 +53,7 @@ void helper_call_pal(CPUAlphaState *env, uint64_t pc, uint64_t entry_ofs)
     int pal_mode = env->pal_mode;
     env->exc_addr = pc | pal_mode;
     env->pc = env->palbr + entry_ofs;
-    if (!pal_mode) {
-        env->pal_mode = 1;
-        swap_shadow_regs(env);
-    }
+    env->pal_mode = 1;
 }
 
 void helper_tbia(CPUAlphaState *env)
target-alpha/translate.c +100 -53

350 lines not on this page · raw message

Signature · 1 line
2.4.3
#3 lore raw

[Qemu-devel] [PULL 2/3] target-alpha: Inline call_pal

In reply to Richard Henderson
---
 target-alpha/helper.h     |  1 -
 target-alpha/sys_helper.c |  8 --------
 target-alpha/translate.c  | 33 ++++++++++++++++++++++++---------
 3 files changed, 24 insertions(+), 18 deletions(-)
target-alpha/helper.h +0 -1
index d221f0d..e7f0450 100644
@@ -92,7 +92,6 @@ DEF_HELPER_FLAGS_2(ieee_input_s, TCG_CALL_NO_WG, void, env, i64)
 
 #if !defined (CONFIG_USER_ONLY)
 DEF_HELPER_2(hw_ret, void, env, i64)
-DEF_HELPER_3(call_pal, void, env, i64, i64)
 
 DEF_HELPER_2(ldl_phys, i64, env, i64)
 DEF_HELPER_2(ldq_phys, i64, env, i64)
target-alpha/sys_helper.c +0 -8
index f01eb96..380d6e4 100644
@@ -48,14 +48,6 @@ void helper_hw_ret(CPUAlphaState *env, uint64_t a)
     env->pal_mode = a & 1;
 }
 
-void helper_call_pal(CPUAlphaState *env, uint64_t pc, uint64_t entry_ofs)
-{
-    int pal_mode = env->pal_mode;
-    env->exc_addr = pc | pal_mode;
-    env->pc = env->palbr + entry_ofs;
-    env->pal_mode = 1;
-}
-
 void helper_tbia(CPUAlphaState *env)
 {
     tlb_flush(CPU(alpha_env_get_cpu(env)), 1);
target-alpha/translate.c +24 -9
index 62002dc..01e7f35 100644
@@ -42,6 +42,9 @@ typedef struct DisasContext DisasContext;
 struct DisasContext {
     struct TranslationBlock *tb;
     uint64_t pc;
+#ifndef CONFIG_USER_ONLY
+    uint64_t palbr;
+#endif
     int mem_idx;
 
     /* Current rounding mode for this TB.  */
@@ -1206,15 +1209,24 @@ static ExitStatus gen_call_pal(DisasContext *ctx, int palcode)
     return gen_excp(ctx, EXCP_CALL_PAL, palcode);
 #else
     {
-        TCGv pc = tcg_const_i64(ctx->pc);
-        TCGv entry = tcg_const_i64(palcode & 0x80
-                                   ? 0x2000 + (palcode - 0x80) * 64
-                                   : 0x1000 + palcode * 64);
+        TCGv tmp = tcg_temp_new();
+        uint64_t exc_addr = ctx->pc;
+        uint64_t entry = ctx->palbr;
+
+        if (ctx->tb->flags & TB_FLAGS_PAL_MODE) {
+            exc_addr |= 1;
+        } else {
+            tcg_gen_movi_i64(tmp, 1);
+            tcg_gen_st8_i64(tmp, cpu_env, offsetof(CPUAlphaState, pal_mode));
+        }
 
-        gen_helper_call_pal(cpu_env, pc, entry);
+        tcg_gen_movi_i64(tmp, exc_addr);
+        tcg_gen_st_i64(tmp, cpu_env, offsetof(CPUAlphaState, exc_addr));
+        tcg_temp_free(tmp);
 
-        tcg_temp_free(entry);
-        tcg_temp_free(pc);
+        entry += (palcode & 0x80
+                  ? 0x2000 + (palcode - 0x80) * 64
+                  : 0x1000 + palcode * 64);
 
         /* Since the destination is running in PALmode, we don't really
            need the page permissions check.  We'll see the existence of
@@ -1222,11 +1234,13 @@ static ExitStatus gen_call_pal(DisasContext *ctx, int palcode)
            we change the PAL base register.  */
         if (!ctx->singlestep_enabled && !(ctx->tb->cflags & CF_LAST_IO)) {
             tcg_gen_goto_tb(0);
+            tcg_gen_movi_i64(cpu_pc, entry);
             tcg_gen_exit_tb((uintptr_t)ctx->tb);
             return EXIT_GOTO_TB;
+        } else {
+            tcg_gen_movi_i64(cpu_pc, entry);
+            return EXIT_PC_UPDATED;
         }
-
-        return EXIT_PC_UPDATED;
     }
 #endif
 }
@@ -2861,6 +2875,7 @@ static inline void gen_intermediate_code_internal(AlphaCPU *cpu,
 #ifdef CONFIG_USER_ONLY
     ctx.ir = cpu_std_ir;
 #else
+    ctx.palbr = env->palbr;
     ctx.ir = (tb->flags & TB_FLAGS_PAL_MODE ? cpu_pal_ir : cpu_std_ir);
 #endif
 
Signature · 1 line
2.4.3
#4 lore raw
In reply to Richard Henderson
Quoted 12 lines · Richard Henderson

Posted and reviewed back in June, queued for 2.5 development.

r~

The following changes since commit 074a9925e1cfd659d5376dcaccd1436d3840e611:

Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (2015-08-14 16:52:34 +0100)

are available in the git repository at:

Quoted 9 lines

git://github.com/rth7680/qemu.git tags/pull-axp-201508018

for you to fetch changes up to 6c05d3ded7b51154e67c35e270c48784b7046883:

target-alpha: Inline hw_ret (2015-08-18 11:08:59 -0700)

----------------------------------------------------------------
Alpha shadow register optimization

Applied, thanks.

-- PMM