Skip to contentSkip to conversation

tcg-arm: Define TCG_TARGET_INSN_UNIT_SIZE

PATCH Peter Maydell 2 participants 10 messages May 2, 2014 – May 12, 2014 6 messages not in the archive

lore
Share & tools
lore
#2 lore raw
In reply to a message not in the archive
Quoted 11 lines · Richard Henderson

And use tcg pointer differencing functions as appropriate.

---

(quoted diff) +0 -2
@@ -1670,51 +1651,28 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
 
     switch (opc) {
     case INDEX_op_exit_tb:
-        if (use_armv7_instructions || check_fit_imm(args[0])) {
-            tcg_out_movi32(s, COND_AL, TCG_REG_R0, args[0]);

Review static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, · line 1655

Quoted 10 lines
(quoted diff) +2 -8
-            tcg_out_goto(s, COND_AL, (tcg_target_ulong) tb_ret_addr);
-        } else {
-            uint8_t *ld_ptr = s->code_ptr;
-            tcg_out_ld32_12(s, COND_AL, TCG_REG_R0, TCG_REG_PC, 0);
-            tcg_out_goto(s, COND_AL, (tcg_target_ulong) tb_ret_addr);
-            *ld_ptr = (uint8_t) (s->code_ptr - ld_ptr) - 8;
-            tcg_out32(s, args[0]);
-        }
+        tcg_out_movi32(s, COND_AL, TCG_REG_R0, args[0]);
+        tcg_out_goto(s, COND_AL, tb_ret_addr);

Why is it OK not to have the pre-v7/non-fitting-immediate code now? I guess movi32 will handle it all though probably in a less efficient way.

Quoted 22 lines
(quoted diff) +1 -14
         break;
     case INDEX_op_goto_tb:
         if (s->tb_jmp_offset) {
             /* Direct jump method */
-#if defined(USE_DIRECT_JUMP)
-            s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
+            s->tb_jmp_offset[args[0]] = tcg_current_code_size(s);
             tcg_out_b_noaddr(s, COND_AL);
-#else
-            tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_PC, -4);
-            s->tb_jmp_offset[args[0]] = s->code_ptr - s->code_buf;
-            tcg_out32(s, 0);
-#endif
         } else {
             /* Indirect jump method */
-#if 1
-            c = (int) (s->tb_next + args[0]) - ((int) s->code_ptr + 8);
-            if (c > 0xfff || c < -0xfff) {
-                tcg_out_movi32(s, COND_AL, TCG_REG_R0,
-                                (tcg_target_long) (s->tb_next + args[0]));
-                tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_R0, 0);
-            } else

Review static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, · line 1667

Quoted 10 lines
(quoted diff) +3 -6
-                tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_PC, c);
-#else
-            tcg_out_ld32_12(s, COND_AL, TCG_REG_R0, TCG_REG_PC, 0);
-            tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_R0, 0);
-            tcg_out32(s, (tcg_target_long) (s->tb_next + args[0]));
-#endif
+            intptr_t ptr = (intptr_t)(s->tb_next + args[0]);
+            tcg_out_movi32(s, COND_AL, TCG_REG_R0, ptr & ~0xfff);
+            tcg_out_ld32_12(s, COND_AL, TCG_REG_PC, TCG_REG_R0, ptr & 0xfff);
         }

This change also confused me but we're again relying on movi32 generating correct-but-inefficient code now, right?

thanks
-- PMM

#3 lore raw
Quoted 2 lines · Peter Maydell

This change also confused me but we're again relying on movi32 generating correct-but-inefficient code now, right?

Yes. IMO if we want to do a constant pool, let's do a proper one, not just in a few places.

r~

#6 lore raw

Re: [Qemu-devel] [PATCH v3 12/16] tcg-s390: Define TCG_TARGET_INSN_UNIT_SIZE

In reply to a message not in the archive
Quoted 22 lines · Richard Henderson

And use tcg pointer differencing functions as appropriate.

---
 tcg/s390/tcg-target.c | 91 ++++++++++++++++++++++++---------------------------
 tcg/s390/tcg-target.h |  2 ++
 2 files changed, 45 insertions(+), 48 deletions(-)
tcg/s390/tcg-target.c +1 -1
index 1d912a7..ae1be1c 100644
@@ -320,7 +320,7 @@ static const uint8_t tcg_cond_to_ltr_cond[] = {
 #ifdef CONFIG_SOFTMMU
 /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
    int mmu_idx) */
-static const void * const qemu_ld_helpers[4] = {
+static void * const qemu_ld_helpers[4] = {
     helper_ldb_mmu,
     helper_ldw_mmu,
     helper_ldl_mmu,

tcg/s390/tcg-target.c static const void * const qemu_ld_helpers[4] = { · line 335

Quoted 8 lines
tcg/s390/tcg-target.c +1 -1
@@ -329,7 +329,7 @@ static const void * const qemu_ld_helpers[4] = {
 
 /* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
    uintxx_t val, int mmu_idx) */
-static const void * const qemu_st_helpers[4] = {
+static void * const qemu_st_helpers[4] = {
     helper_stb_mmu,
     helper_stw_mmu,
     helper_stl_mmu,

Why do these lose the 'const' ?

Patch looks ok otherwise from a quick scan.

thanks
-- PMM

author Reviewed-by
#12 lore raw

Re: [Qemu-devel] [PATCH v3 15/16] tci: Define TCG_TARGET_INSN_UNIT_SIZE

In reply to a message not in the archive
Quoted 8 lines · Richard Henderson

And use tcg pointer differencing functions as appropriate.

---
 tcg/tci/tcg-target.c | 19 +++++++++++++------
 tcg/tci/tcg-target.h |  1 +
 2 files changed, 14 insertions(+), 6 deletions(-)

though I note there are a number of functions that use the pattern

    uint8_t *old_code_ptr = s->code_ptr;
    [...emit stuff...]
    old_code_ptr[1] = s->code_ptr - old_code_ptr;

which could perhaps use tcg_insn_unit * rather than uint8_t * ?

thanks
-- PMM

author Reviewed-by
#4 lore raw
In reply to Richard Henderson
Quoted 6 lines · Richard Henderson
Quoted 2 lines · Peter Maydell

This change also confused me but we're again relying on movi32 generating correct-but-inefficient code now, right?

Yes. IMO if we want to do a constant pool, let's do a proper one, not just in a few places.

Fair enough. I don't care very much about pre-v7 hosts anyway...

-- PMM

#7 lore raw

Re: [Qemu-devel] [PATCH v3 12/16] tcg-s390: Define TCG_TARGET_INSN_UNIT_SIZE

In reply to Peter Maydell
Quoted 24 lines · Peter Maydell
Quoted 23 lines · Richard Henderson

And use tcg pointer differencing functions as appropriate.

---
 tcg/s390/tcg-target.c | 91 ++++++++++++++++++++++++---------------------------
 tcg/s390/tcg-target.h |  2 ++
 2 files changed, 45 insertions(+), 48 deletions(-)
tcg/s390/tcg-target.c +1 -1
index 1d912a7..ae1be1c 100644
@@ -320,7 +320,7 @@ static const uint8_t tcg_cond_to_ltr_cond[] = {
 #ifdef CONFIG_SOFTMMU
 /* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr,
    int mmu_idx) */
-static const void * const qemu_ld_helpers[4] = {
+static void * const qemu_ld_helpers[4] = {
     helper_ldb_mmu,
     helper_ldw_mmu,
     helper_ldl_mmu,
@@ -329,7 +329,7 @@ static const void * const qemu_ld_helpers[4] = {
 
Quoted 9 lines

tcg/s390/tcg-target.c static const void * const qemu_ld_helpers[4] = { · line 335

Quoted 7 lines
tcg/s390/tcg-target.c +1 -1
 /* helper signature: helper_st_mmu(CPUState *env, target_ulong addr,
    uintxx_t val, int mmu_idx) */
-static const void * const qemu_st_helpers[4] = {
+static void * const qemu_st_helpers[4] = {
     helper_stb_mmu,
     helper_stw_mmu,
     helper_stl_mmu,

Why do these lose the 'const' ?

Because "const void *" has a conversion warning to non-const "tcg_type_unit *". One would have to carry the const all the way through all of the relocation routines to solve it.

You had the exact same question about the ppc patch.

r~

#8 lore raw

Re: [Qemu-devel] [PATCH v3 12/16] tcg-s390: Define TCG_TARGET_INSN_UNIT_SIZE

Quoted 7 lines · Richard Henderson
Quoted 1 line · Peter Maydell

Why do these lose the 'const' ?

Because "const void *" has a conversion warning to non-const "tcg_type_unit *". One would have to carry the const all the way through all of the relocation routines to solve it.

Ah, right.

Quoted 1 line

You had the exact same question about the ppc patch.

Whoops :-)

thanks
-- PMM

#13 lore raw

Re: [Qemu-devel] [PATCH v3 15/16] tci: Define TCG_TARGET_INSN_UNIT_SIZE

In reply to Peter Maydell
Quoted 8 lines · Peter Maydell

though I note there are a number of functions that use the pattern

    uint8_t *old_code_ptr = s->code_ptr;
    [...emit stuff...]
    old_code_ptr[1] = s->code_ptr - old_code_ptr;

which could perhaps use tcg_insn_unit * rather than uint8_t * ?

Yes, probably. There are quite a few changes I'd like to make to tci...

r~