qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI
@ 2013-03-28 15:37 Richard Henderson
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 1/5] tci: Use 32-bit signed offsets to loads/stores Richard Henderson
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Richard Henderson @ 2013-03-28 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil

My main goal here is the last patch.  With the patches I've posted
for arm and s390, tci is the only remaining user of env->temp_buf.


r~


Richard Henderson (5):
  tci: Use 32-bit signed offsets to loads/stores
  tci: Use a local variable for env
  tci: Avoid code before declarations
  tci: Delete unused tb_ret_addr
  tci: Make tcg temporaries local to tcg_qemu_tb_exec

 tcg/tci/tcg-target.c | 22 +++++++++-----------
 tcg/tci/tcg-target.h |  8 +++++++-
 tci.c                | 57 ++++++++++++++++++++++++++++++----------------------
 3 files changed, 49 insertions(+), 38 deletions(-)

-- 
1.8.1.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 1/5] tci: Use 32-bit signed offsets to loads/stores
  2013-03-28 15:37 [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
@ 2013-03-28 15:37 ` Richard Henderson
  2013-03-28 15:45   ` Stefan Weil
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 2/5] tci: Use a local variable for env Richard Henderson
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Richard Henderson @ 2013-03-28 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil

Since the change to tcg_exit_req, the first insn of every TB is
a load with a negative offset from env.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/tci/tcg-target.c |  4 ++--
 tci.c                | 36 ++++++++++++++++++++++--------------
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/tcg/tci/tcg-target.c b/tcg/tci/tcg-target.c
index 2d561b3..a85095c 100644
--- a/tcg/tci/tcg-target.c
+++ b/tcg/tci/tcg-target.c
@@ -513,7 +513,7 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1,
         tcg_out_op_t(s, INDEX_op_ld_i64);
         tcg_out_r(s, ret);
         tcg_out_r(s, arg1);
-        assert(arg2 == (uint32_t)arg2);
+        assert(arg2 == (int32_t)arg2);
         tcg_out32(s, arg2);
 #else
         TODO();
@@ -636,7 +636,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
     case INDEX_op_st_i64:
         tcg_out_r(s, args[0]);
         tcg_out_r(s, args[1]);
-        assert(args[2] == (uint32_t)args[2]);
+        assert(args[2] == (int32_t)args[2]);
         tcg_out32(s, args[2]);
         break;
     case INDEX_op_add_i32:
diff --git a/tci.c b/tci.c
index 2b2c11f..9ce0be3 100644
--- a/tci.c
+++ b/tci.c
@@ -182,7 +182,7 @@ static tcg_target_ulong tci_read_i(uint8_t **tb_ptr)
     return value;
 }
 
-/* Read constant (32 bit) from bytecode. */
+/* Read unsigned constant (32 bit) from bytecode. */
 static uint32_t tci_read_i32(uint8_t **tb_ptr)
 {
     uint32_t value = *(uint32_t *)(*tb_ptr);
@@ -190,6 +190,14 @@ static uint32_t tci_read_i32(uint8_t **tb_ptr)
     return value;
 }
 
+/* Read signed constant (32 bit) from bytecode. */
+static int32_t tci_read_s32(uint8_t **tb_ptr)
+{
+    int32_t value = *(int32_t *)(*tb_ptr);
+    *tb_ptr += sizeof(value);
+    return value;
+}
+
 #if TCG_TARGET_REG_BITS == 64
 /* Read constant (64 bit) from bytecode. */
 static uint64_t tci_read_i64(uint8_t **tb_ptr)
@@ -550,7 +558,7 @@ tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *cpustate, uint8_t *tb_ptr)
         case INDEX_op_ld8u_i32:
             t0 = *tb_ptr++;
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             tci_write_reg8(t0, *(uint8_t *)(t1 + t2));
             break;
         case INDEX_op_ld8s_i32:
@@ -563,25 +571,25 @@ tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *cpustate, uint8_t *tb_ptr)
         case INDEX_op_ld_i32:
             t0 = *tb_ptr++;
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             tci_write_reg32(t0, *(uint32_t *)(t1 + t2));
             break;
         case INDEX_op_st8_i32:
             t0 = tci_read_r8(&tb_ptr);
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             *(uint8_t *)(t1 + t2) = t0;
             break;
         case INDEX_op_st16_i32:
             t0 = tci_read_r16(&tb_ptr);
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             *(uint16_t *)(t1 + t2) = t0;
             break;
         case INDEX_op_st_i32:
             t0 = tci_read_r32(&tb_ptr);
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             *(uint32_t *)(t1 + t2) = t0;
             break;
 
@@ -818,7 +826,7 @@ tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *cpustate, uint8_t *tb_ptr)
         case INDEX_op_ld8u_i64:
             t0 = *tb_ptr++;
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             tci_write_reg8(t0, *(uint8_t *)(t1 + t2));
             break;
         case INDEX_op_ld8s_i64:
@@ -829,43 +837,43 @@ tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *cpustate, uint8_t *tb_ptr)
         case INDEX_op_ld32u_i64:
             t0 = *tb_ptr++;
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             tci_write_reg32(t0, *(uint32_t *)(t1 + t2));
             break;
         case INDEX_op_ld32s_i64:
             t0 = *tb_ptr++;
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             tci_write_reg32s(t0, *(int32_t *)(t1 + t2));
             break;
         case INDEX_op_ld_i64:
             t0 = *tb_ptr++;
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             tci_write_reg64(t0, *(uint64_t *)(t1 + t2));
             break;
         case INDEX_op_st8_i64:
             t0 = tci_read_r8(&tb_ptr);
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             *(uint8_t *)(t1 + t2) = t0;
             break;
         case INDEX_op_st16_i64:
             t0 = tci_read_r16(&tb_ptr);
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             *(uint16_t *)(t1 + t2) = t0;
             break;
         case INDEX_op_st32_i64:
             t0 = tci_read_r32(&tb_ptr);
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             *(uint32_t *)(t1 + t2) = t0;
             break;
         case INDEX_op_st_i64:
             t0 = tci_read_r64(&tb_ptr);
             t1 = tci_read_r(&tb_ptr);
-            t2 = tci_read_i32(&tb_ptr);
+            t2 = tci_read_s32(&tb_ptr);
             *(uint64_t *)(t1 + t2) = t0;
             break;
 
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 2/5] tci: Use a local variable for env
  2013-03-28 15:37 [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 1/5] tci: Use 32-bit signed offsets to loads/stores Richard Henderson
@ 2013-03-28 15:37 ` Richard Henderson
  2013-03-28 15:52   ` Stefan Weil
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 3/5] tci: Avoid code before declarations Richard Henderson
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 12+ messages in thread
From: Richard Henderson @ 2013-03-28 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil

Since we have total conversion away from global AREG0, we do not
need a global variable named "env".  Retain that name as the
function parameter inside the interpreter.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tci.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/tci.c b/tci.c
index 9ce0be3..77e0980 100644
--- a/tci.c
+++ b/tci.c
@@ -51,11 +51,6 @@ typedef uint64_t (*helper_function)(tcg_target_ulong, tcg_target_ulong,
                                     tcg_target_ulong);
 #endif
 
-/* TCI can optionally use a global register variable for env. */
-#if !defined(AREG0)
-CPUArchState *env;
-#endif
-
 /* Targets which don't use GETPC also don't need tci_tb_ptr
    which makes them a little faster. */
 #if defined(GETPC)
@@ -438,11 +433,10 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition)
 }
 
 /* Interpret pseudo code in tb. */
-tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *cpustate, uint8_t *tb_ptr)
+tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
 {
     tcg_target_ulong next_tb = 0;
 
-    env = cpustate;
     tci_reg[TCG_AREG0] = (tcg_target_ulong)env;
     assert(tb_ptr);
 
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 3/5] tci: Avoid code before declarations
  2013-03-28 15:37 [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 1/5] tci: Use 32-bit signed offsets to loads/stores Richard Henderson
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 2/5] tci: Use a local variable for env Richard Henderson
@ 2013-03-28 15:37 ` Richard Henderson
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 4/5] tci: Delete unused tb_ret_addr Richard Henderson
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2013-03-28 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil

This only valid with c99 extensions enabled, and easy to avoid.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tci.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tci.c b/tci.c
index 77e0980..70f8308 100644
--- a/tci.c
+++ b/tci.c
@@ -441,9 +441,6 @@ tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
     assert(tb_ptr);
 
     for (;;) {
-#if defined(GETPC)
-        tci_tb_ptr = (uintptr_t)tb_ptr;
-#endif
         TCGOpcode opc = tb_ptr[0];
 #if !defined(NDEBUG)
         uint8_t op_size = tb_ptr[1];
@@ -466,6 +463,10 @@ tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
         uint64_t v64;
 #endif
 
+#if defined(GETPC)
+        tci_tb_ptr = (uintptr_t)tb_ptr;
+#endif
+
         /* Skip opcode and size entry. */
         tb_ptr += 2;
 
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 4/5] tci: Delete unused tb_ret_addr
  2013-03-28 15:37 [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
                   ` (2 preceding siblings ...)
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 3/5] tci: Avoid code before declarations Richard Henderson
@ 2013-03-28 15:37 ` Richard Henderson
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 5/5] tci: Make tcg temporaries local to tcg_qemu_tb_exec Richard Henderson
  2013-04-03 22:11 ` [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
  5 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2013-03-28 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/tci/tcg-target.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tcg/tci/tcg-target.c b/tcg/tci/tcg-target.c
index a85095c..b096a84 100644
--- a/tcg/tci/tcg-target.c
+++ b/tcg/tci/tcg-target.c
@@ -45,9 +45,6 @@
 #define TCG_TARGET_STACK_ALIGN          16
 #define TCG_TARGET_CALL_STACK_OFFSET    0
 
-/* TODO: documentation. */
-static uint8_t *tb_ret_addr;
-
 /* Macros used in tcg_target_op_defs. */
 #define R       "r"
 #define RI      "ri"
@@ -912,7 +909,6 @@ static void tcg_target_init(TCGContext *s)
 }
 
 /* Generate global QEMU prologue and epilogue code. */
-static void tcg_target_qemu_prologue(TCGContext *s)
+static inline void tcg_target_qemu_prologue(TCGContext *s)
 {
-    tb_ret_addr = s->code_ptr;
 }
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 5/5] tci: Make tcg temporaries local to tcg_qemu_tb_exec
  2013-03-28 15:37 [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
                   ` (3 preceding siblings ...)
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 4/5] tci: Delete unused tb_ret_addr Richard Henderson
@ 2013-03-28 15:37 ` Richard Henderson
  2013-04-03 22:11 ` [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
  5 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2013-03-28 15:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil

We're moving away from the temporaries stored in env.  Make sure we can
differentiate between temp stores and possibly bogus stores for extra
call arguments.  Move TCG_AREG0 and TCG_REG_CALL_STACK out of the way
of the parameter passing registers.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 tcg/tci/tcg-target.c | 12 ++++++------
 tcg/tci/tcg-target.h |  8 +++++++-
 tci.c                |  6 ++++++
 3 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/tcg/tci/tcg-target.c b/tcg/tci/tcg-target.c
index b096a84..d1241b5 100644
--- a/tcg/tci/tcg-target.c
+++ b/tcg/tci/tcg-target.c
@@ -40,11 +40,6 @@
 /* Bitfield n...m (in 32 bit value). */
 #define BITS(n, m) (((0xffffffffU << (31 - n)) >> (31 - n + m)) << m)
 
-/* Used for function call generation. */
-#define TCG_REG_CALL_STACK              TCG_REG_R4
-#define TCG_TARGET_STACK_ALIGN          16
-#define TCG_TARGET_CALL_STACK_OFFSET    0
-
 /* Macros used in tcg_target_op_defs. */
 #define R       "r"
 #define RI      "ri"
@@ -901,10 +896,15 @@ static void tcg_target_init(TCGContext *s)
     /* TODO: Which registers should be set here? */
     tcg_regset_set32(tcg_target_call_clobber_regs, 0,
                      BIT(TCG_TARGET_NB_REGS) - 1);
+
     tcg_regset_clear(s->reserved_regs);
     tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);
     tcg_add_target_add_op_defs(tcg_target_op_defs);
-    tcg_set_frame(s, TCG_AREG0, offsetof(CPUArchState, temp_buf),
+
+    /* We use negative offsets from "sp" so that we can distinguish
+       stores that might pretend to be call arguments.  */
+    tcg_set_frame(s, TCG_REG_CALL_STACK,
+                  -CPU_TEMP_BUF_NLONGS * sizeof(long),
                   CPU_TEMP_BUF_NLONGS * sizeof(long));
 }
 
diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h
index 1f17576..0395bbb 100644
--- a/tcg/tci/tcg-target.h
+++ b/tcg/tci/tcg-target.h
@@ -127,7 +127,6 @@ typedef enum {
     TCG_REG_R5,
     TCG_REG_R6,
     TCG_REG_R7,
-    TCG_AREG0 = TCG_REG_R7,
 #if TCG_TARGET_NB_REGS >= 16
     TCG_REG_R8,
     TCG_REG_R9,
@@ -160,6 +159,13 @@ typedef enum {
     TCG_CONST = UINT8_MAX
 } TCGReg;
 
+#define TCG_AREG0                       (TCG_TARGET_NB_REGS - 2)
+
+/* Used for function call generation. */
+#define TCG_REG_CALL_STACK              (TCG_TARGET_NB_REGS - 1)
+#define TCG_TARGET_CALL_STACK_OFFSET    0
+#define TCG_TARGET_STACK_ALIGN          16
+
 void tci_disas(uint8_t opc);
 
 tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr);
diff --git a/tci.c b/tci.c
index 70f8308..c742c8d 100644
--- a/tci.c
+++ b/tci.c
@@ -112,6 +112,7 @@ static void tci_write_reg(TCGReg index, tcg_target_ulong value)
 {
     assert(index < ARRAY_SIZE(tci_reg));
     assert(index != TCG_AREG0);
+    assert(index != TCG_REG_CALL_STACK);
     tci_reg[index] = value;
 }
 
@@ -435,9 +436,12 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition)
 /* Interpret pseudo code in tb. */
 tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
 {
+    long tcg_temps[CPU_TEMP_BUF_NLONGS];
+    uintptr_t sp_value = (uintptr_t)(tcg_temps + CPU_TEMP_BUF_NLONGS);
     tcg_target_ulong next_tb = 0;
 
     tci_reg[TCG_AREG0] = (tcg_target_ulong)env;
+    tci_reg[TCG_REG_CALL_STACK] = sp_value;
     assert(tb_ptr);
 
     for (;;) {
@@ -585,6 +589,7 @@ tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
             t0 = tci_read_r32(&tb_ptr);
             t1 = tci_read_r(&tb_ptr);
             t2 = tci_read_s32(&tb_ptr);
+            assert(t1 != sp_value || (int32_t)t2 < 0);
             *(uint32_t *)(t1 + t2) = t0;
             break;
 
@@ -869,6 +874,7 @@ tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
             t0 = tci_read_r64(&tb_ptr);
             t1 = tci_read_r(&tb_ptr);
             t2 = tci_read_s32(&tb_ptr);
+            assert(t1 != sp_value || (int32_t)t2 < 0);
             *(uint64_t *)(t1 + t2) = t0;
             break;
 
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 1/5] tci: Use 32-bit signed offsets to loads/stores
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 1/5] tci: Use 32-bit signed offsets to loads/stores Richard Henderson
@ 2013-03-28 15:45   ` Stefan Weil
  2013-03-28 15:56     ` Richard Henderson
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Weil @ 2013-03-28 15:45 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel

Am 28.03.2013 16:37, schrieb Richard Henderson:
> Since the change to tcg_exit_req, the first insn of every TB is
> a load with a negative offset from env.
>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  tcg/tci/tcg-target.c |  4 ++--
>  tci.c                | 36 ++++++++++++++++++++++--------------
>  2 files changed, 24 insertions(+), 16 deletions(-)
>
> diff --git a/tcg/tci/tcg-target.c b/tcg/tci/tcg-target.c
> index 2d561b3..a85095c 100644
> --- a/tcg/tci/tcg-target.c
> +++ b/tcg/tci/tcg-target.c
> @@ -513,7 +513,7 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1,
>          tcg_out_op_t(s, INDEX_op_ld_i64);
>          tcg_out_r(s, ret);
>          tcg_out_r(s, arg1);
> -        assert(arg2 == (uint32_t)arg2);
> +        assert(arg2 == (int32_t)arg2);
>          tcg_out32(s, arg2);
>  #else
>          TODO();
> @@ -636,7 +636,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
>      case INDEX_op_st_i64:
>          tcg_out_r(s, args[0]);
>          tcg_out_r(s, args[1]);
> -        assert(args[2] == (uint32_t)args[2]);
> +        assert(args[2] == (int32_t)args[2]);
>          tcg_out32(s, args[2]);
>          break;
>      case INDEX_op_add_i32:
> diff --git a/tci.c b/tci.c
> index 2b2c11f..9ce0be3 100644
> --- a/tci.c
> +++ b/tci.c
> @@ -182,7 +182,7 @@ static tcg_target_ulong tci_read_i(uint8_t **tb_ptr)
>      return value;
>  }
>  
> -/* Read constant (32 bit) from bytecode. */
> +/* Read unsigned constant (32 bit) from bytecode. */
>  static uint32_t tci_read_i32(uint8_t **tb_ptr)
>  {
>      uint32_t value = *(uint32_t *)(*tb_ptr);
> @@ -190,6 +190,14 @@ static uint32_t tci_read_i32(uint8_t **tb_ptr)
>      return value;
>  }
>  
> +/* Read signed constant (32 bit) from bytecode. */
> +static int32_t tci_read_s32(uint8_t **tb_ptr)
> +{
> +    int32_t value = *(int32_t *)(*tb_ptr);
> +    *tb_ptr += sizeof(value);
> +    return value;
> +}
> +
>  #if TCG_TARGET_REG_BITS == 64
>  /* Read constant (64 bit) from bytecode. */
>  static uint64_t tci_read_i64(uint8_t **tb_ptr)
> @@ -550,7 +558,7 @@ tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *cpustate, uint8_t *tb_ptr)
>          case INDEX_op_ld8u_i32:
>              t0 = *tb_ptr++;
>              t1 = tci_read_r(&tb_ptr);
> -            t2 = tci_read_i32(&tb_ptr);
> +            t2 = tci_read_s32(&tb_ptr);

I'm afraid that old and new generated code are identical,
because t2 is an unsigned tcg_target_ulong.

Regards,
Stefan

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 2/5] tci: Use a local variable for env
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 2/5] tci: Use a local variable for env Richard Henderson
@ 2013-03-28 15:52   ` Stefan Weil
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Weil @ 2013-03-28 15:52 UTC (permalink / raw)
  To: Richard Henderson; +Cc: qemu-devel

Am 28.03.2013 16:37, schrieb Richard Henderson:
> Since we have total conversion away from global AREG0, we do not
> need a global variable named "env".  Retain that name as the
> function parameter inside the interpreter.
>
> Signed-off-by: Richard Henderson <rth@twiddle.net>
> ---
>  tci.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/tci.c b/tci.c
> index 9ce0be3..77e0980 100644
> --- a/tci.c
> +++ b/tci.c
> @@ -51,11 +51,6 @@ typedef uint64_t (*helper_function)(tcg_target_ulong, tcg_target_ulong,
>                                      tcg_target_ulong);
>  #endif
>  
> -/* TCI can optionally use a global register variable for env. */
> -#if !defined(AREG0)
> -CPUArchState *env;
> -#endif
> -
>  /* Targets which don't use GETPC also don't need tci_tb_ptr
>     which makes them a little faster. */
>  #if defined(GETPC)
> @@ -438,11 +433,10 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition)
>  }
>  
>  /* Interpret pseudo code in tb. */
> -tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *cpustate, uint8_t *tb_ptr)
> +tcg_target_ulong tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr)
>  {
>      tcg_target_ulong next_tb = 0;
>  
> -    env = cpustate;
>      tci_reg[TCG_AREG0] = (tcg_target_ulong)env;
>      assert(tb_ptr);

Reviewed-by: Stefan Weil <sw@weilnetz.de>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 1/5] tci: Use 32-bit signed offsets to loads/stores
  2013-03-28 15:45   ` Stefan Weil
@ 2013-03-28 15:56     ` Richard Henderson
  0 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2013-03-28 15:56 UTC (permalink / raw)
  To: Stefan Weil; +Cc: qemu-devel

On 03/28/2013 08:45 AM, Stefan Weil wrote:
>> > -            t2 = tci_read_i32(&tb_ptr);
>> > +            t2 = tci_read_s32(&tb_ptr);
> I'm afraid that old and new generated code are identical,
> because t2 is an unsigned tcg_target_ulong.

No it's not, because s32 is sign-extended from int32_t to tcg_target_ulong.

If you're thinking of the later arithmetic in type tcg_target_ulong, that's
fine.  Just so long as the sign-extension happened first.


r~

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI
  2013-03-28 15:37 [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
                   ` (4 preceding siblings ...)
  2013-03-28 15:37 ` [Qemu-devel] [PATCH 5/5] tci: Make tcg temporaries local to tcg_qemu_tb_exec Richard Henderson
@ 2013-04-03 22:11 ` Richard Henderson
  2013-04-09 11:37   ` Richard Henderson
  5 siblings, 1 reply; 12+ messages in thread
From: Richard Henderson @ 2013-04-03 22:11 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil

Ping?

On 2013-03-28 10:37, Richard Henderson wrote:
> My main goal here is the last patch.  With the patches I've posted
> for arm and s390, tci is the only remaining user of env->temp_buf.
>
>
> r~
>
>
> Richard Henderson (5):
>    tci: Use 32-bit signed offsets to loads/stores
>    tci: Use a local variable for env
>    tci: Avoid code before declarations
>    tci: Delete unused tb_ret_addr
>    tci: Make tcg temporaries local to tcg_qemu_tb_exec
>
>   tcg/tci/tcg-target.c | 22 +++++++++-----------
>   tcg/tci/tcg-target.h |  8 +++++++-
>   tci.c                | 57 ++++++++++++++++++++++++++++++----------------------
>   3 files changed, 49 insertions(+), 38 deletions(-)
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI
  2013-04-03 22:11 ` [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
@ 2013-04-09 11:37   ` Richard Henderson
  0 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2013-04-09 11:37 UTC (permalink / raw)
  To: qemu-devel; +Cc: Stefan Weil

Ping 2.


On 2013-04-03 17:11, Richard Henderson wrote:
> Ping?
>
> On 2013-03-28 10:37, Richard Henderson wrote:
>> My main goal here is the last patch.  With the patches I've posted
>> for arm and s390, tci is the only remaining user of env->temp_buf.
>>
>>
>> r~
>>
>>
>> Richard Henderson (5):
>>    tci: Use 32-bit signed offsets to loads/stores
>>    tci: Use a local variable for env
>>    tci: Avoid code before declarations
>>    tci: Delete unused tb_ret_addr
>>    tci: Make tcg temporaries local to tcg_qemu_tb_exec
>>
>>   tcg/tci/tcg-target.c | 22 +++++++++-----------
>>   tcg/tci/tcg-target.h |  8 +++++++-
>>   tci.c                | 57 ++++++++++++++++++++++++++++++----------------------
>>   3 files changed, 49 insertions(+), 38 deletions(-)
>>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 4/5] tci: Delete unused tb_ret_addr
  2013-04-11 18:15 [Qemu-devel] [PULL] " Stefan Weil
@ 2013-04-11 18:15 ` Stefan Weil
  0 siblings, 0 replies; 12+ messages in thread
From: Stefan Weil @ 2013-04-11 18:15 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: qemu-devel, Richard Henderson

From: Richard Henderson <rth@twiddle.net>

Signed-off-by: Richard Henderson <rth@twiddle.net>
Signed-off by: Stefan Weil <sw@weilnetz.de>
---
 tcg/tci/tcg-target.c |    6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/tcg/tci/tcg-target.c b/tcg/tci/tcg-target.c
index a85095c..b096a84 100644
--- a/tcg/tci/tcg-target.c
+++ b/tcg/tci/tcg-target.c
@@ -45,9 +45,6 @@
 #define TCG_TARGET_STACK_ALIGN          16
 #define TCG_TARGET_CALL_STACK_OFFSET    0
 
-/* TODO: documentation. */
-static uint8_t *tb_ret_addr;
-
 /* Macros used in tcg_target_op_defs. */
 #define R       "r"
 #define RI      "ri"
@@ -912,7 +909,6 @@ static void tcg_target_init(TCGContext *s)
 }
 
 /* Generate global QEMU prologue and epilogue code. */
-static void tcg_target_qemu_prologue(TCGContext *s)
+static inline void tcg_target_qemu_prologue(TCGContext *s)
 {
-    tb_ret_addr = s->code_ptr;
 }
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-04-11 18:16 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-28 15:37 [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
2013-03-28 15:37 ` [Qemu-devel] [PATCH 1/5] tci: Use 32-bit signed offsets to loads/stores Richard Henderson
2013-03-28 15:45   ` Stefan Weil
2013-03-28 15:56     ` Richard Henderson
2013-03-28 15:37 ` [Qemu-devel] [PATCH 2/5] tci: Use a local variable for env Richard Henderson
2013-03-28 15:52   ` Stefan Weil
2013-03-28 15:37 ` [Qemu-devel] [PATCH 3/5] tci: Avoid code before declarations Richard Henderson
2013-03-28 15:37 ` [Qemu-devel] [PATCH 4/5] tci: Delete unused tb_ret_addr Richard Henderson
2013-03-28 15:37 ` [Qemu-devel] [PATCH 5/5] tci: Make tcg temporaries local to tcg_qemu_tb_exec Richard Henderson
2013-04-03 22:11 ` [Qemu-devel] [PATCH 0/5] Fixes and minor improvements to TCI Richard Henderson
2013-04-09 11:37   ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2013-04-11 18:15 [Qemu-devel] [PULL] " Stefan Weil
2013-04-11 18:15 ` [Qemu-devel] [PATCH 4/5] tci: Delete unused tb_ret_addr Stefan Weil

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).