Remove CONFIG_QEMU_LDST_OPTIMIZATION
cover Remove CONFIG_QEMU_LDST_OPTIMIZATION
This patch set is based upon
git://github.com/rth7680/qemu.git tcg-arm-pull
With the first patch, to convert aarch64 away from the old ldst helpers, we wean exec-all.h from any knowledge of the tcg backend implementation. Which means we no longer need to involve configure in the backend implementation either.
The structure I've chosen, a TCGBackendData structure that is (technically) totally private to the backend, is based on my long-term assumption that many targets would do better with some sort of constant pool. Or allowing ia64 to save data with which it could produce better instruction bundling across tcg opcodes.
That said, until there is some need for the TCGBackendData structure to be unique, let's share as much code as we can. Thus the two helper header files, which allow all of the boilerplate code for ldst optimization to be shared.
r~
Richard Henderson (5):
tcg-aarch64: Update to helper_ret_*_mmu routines
exec: Delete is_tcg_gen_code and GETRA_EXT
tcg: Add tcg-be-null.h
tcg: Add tcg-be-ldst.h
configure: Remove CONFIG_QEMU_LDST_OPTIMIZATION
configure | 8 ---- include/exec/exec-all.h | 30 -------------- include/exec/softmmu_template.h | 4 +- tcg/aarch64/tcg-target.c | 51 +++++++++-------------- tcg/arm/tcg-target.c | 27 ++----------- tcg/i386/tcg-target.c | 30 ++------------ tcg/ia64/tcg-target.c | 2 + tcg/mips/tcg-target.c | 2 + tcg/ppc/tcg-target.c | 28 ++----------- tcg/ppc64/tcg-target.c | 26 ++---------- tcg/s390/tcg-target.c | 2 + tcg/sparc/tcg-target.c | 2 + tcg/tcg-be-ldst.h | 90 +++++++++++++++++++++++++++++++++++++++++ tcg/tcg-be-null.h | 43 ++++++++++++++++++++ tcg/tcg.c | 15 +++---- tcg/tcg.h | 31 +------------- tcg/tci/tcg-target.c | 2 + translate-all.c | 12 ------ 18 files changed, 183 insertions(+), 222 deletions(-) create mode 100644 tcg/tcg-be-ldst.h create mode 100644 tcg/tcg-be-null.h
Signature · 1 line
1.8.3.1
PATCH 1/5 tcg-aarch64: Update to helper_ret_*_mmu routines
A minimal update to use the new helpers with the return address argument.
--- include/exec/exec-all.h | 18 ------------------ tcg/aarch64/tcg-target.c | 28 ++++++++++++++++------------ 2 files changed, 16 insertions(+), 30 deletions(-)
include/exec/exec-all.h +0 -18
@@ -320,24 +320,6 @@ extern uintptr_t tci_tb_ptr;#define GETPC () (GETRA() - GETPC_ADJ) -/* The LDST optimizations splits code generation into fast and slow path. -In some implementations, we pass the "logical" return address manually; -in others, we must infer the logical return from the true return. */ -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION ) && defined(CONFIG_SOFTMMU ) -# if defined(__aarch64__) -# define GETRA_LDST (RA ) tcg_getra_ldst(RA) -static inline uintptr_t tcg_getra_ldst (uintptr_t ra) -{ -int32_t b; - ra +=4 ;/* skip one instruction */ - b = *(int32_t *)ra;/* load the branch insn */ - b = (b <<6 ) >> (6 -2 );/* extract the displacement */ - ra += b;/* apply the displacement */ -return ra; -} -# endif -#endif /* CONFIG_QEMU_LDST_OPTIMIZATION */ -/* ??? Delete these once they are no longer used. */ bool is_tcg_gen_code (uintptr_t pc_ptr);#ifdef GETRA_LDST
tcg/aarch64/tcg-target.c +16 -12
@@ -778,22 +778,24 @@ static inline void tcg_out_nop(TCGContext *s) }#ifdef CONFIG_SOFTMMU -/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, -int mmu_idx) */ +/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, +* int mmu_idx, uintptr_t ra) +*/ static const void *const qemu_ld_helpers[4 ] = { - helper_ldb_mmu, - helper_ldw_mmu, - helper_ldl_mmu, - helper_ldq_mmu, + helper_ret_ldub_mmu, + helper_ret_lduw_mmu, + helper_ret_ldul_mmu, + helper_ret_ldq_mmu, }; -/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr, -uintxx_t val, int mmu_idx) */ +/* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, +* uintxx_t val, int mmu_idx, uintptr_t ra) +*/ static const void *const qemu_st_helpers[4 ] = { - helper_stb_mmu, - helper_stw_mmu, - helper_stl_mmu, - helper_stq_mmu, + helper_ret_stb_mmu, + helper_ret_stw_mmu, + helper_ret_stl_mmu, + helper_ret_stq_mmu, };static void tcg_out_qemu_ld_slow_path (TCGContext *s,TCGLabelQemuLdst *lb)
@@ -802,6 +804,7 @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)tcg_out_movr (s,1 ,TCG_REG_X0 ,TCG_AREG0 );tcg_out_movr (s, (TARGET_LONG_BITS ==64 ),TCG_REG_X1 , lb->addrlo_reg);tcg_out_movi (s,TCG_TYPE_I32 ,TCG_REG_X2 , lb->mem_index); +tcg_out_movi (s,TCG_TYPE_PTR ,TCG_REG_X3 , (tcg_target_long )lb->raddr);tcg_out_movi (s,TCG_TYPE_I64 ,TCG_REG_TMP , (tcg_target_long )qemu_ld_helpers[lb->opc &3 ]);tcg_out_callr (s,TCG_REG_TMP );
@@ -822,6 +825,7 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)tcg_out_movr (s, (TARGET_LONG_BITS ==64 ),TCG_REG_X1 , lb->addrlo_reg);tcg_out_movr (s,1 ,TCG_REG_X2 , lb->datalo_reg);tcg_out_movi (s,TCG_TYPE_I32 ,TCG_REG_X3 , lb->mem_index); +tcg_out_movi (s,TCG_TYPE_PTR ,TCG_REG_X4 , (tcg_target_long )lb->raddr);tcg_out_movi (s,TCG_TYPE_I64 ,TCG_REG_TMP , (tcg_target_long )qemu_st_helpers[lb->opc &3 ]);tcg_out_callr (s,TCG_REG_TMP );
Signature · 1 line
1.8.3.1
PATCH 1/5 tcg-aarch64: Update to helper_ret_*_mmu routines
Hello
Richard,
Quoted 89 lines
A minimal update to use the new helpers with the return address argument.
Cc Claudio Fontana <address@hidden>Signed-off-by Richard Henderson <address@hidden>--- include/exec/exec-all.h | 18 ------------------ tcg/aarch64/tcg-target.c | 28 ++++++++++++++++------------ 2 files changed, 16 insertions(+), 30 deletions(-)include/exec/exec-all.h +0
-18@@ -320,24 +320,6 @@ extern uintptr_t tci_tb_ptr;#define GETPC () (GETRA() - GETPC_ADJ) -/* The LDST optimizations splits code generation into fast and slow path. -In some implementations, we pass the "logical" return address manually; -in others, we must infer the logical return from the true return. */ -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION ) && defined(CONFIG_SOFTMMU ) -# if defined(__aarch64__) -# define GETRA_LDST (RA ) tcg_getra_ldst(RA) -static inline uintptr_t tcg_getra_ldst (uintptr_t ra) -{ -int32_t b; - ra +=4 ;/* skip one instruction */ - b = *(int32_t *)ra;/* load the branch insn */ - b = (b <<6 ) >> (6 -2 );/* extract the displacement */ - ra += b;/* apply the displacement */ -return ra; -} -# endif -#endif /* CONFIG_QEMU_LDST_OPTIMIZATION */ -/* ??? Delete these once they are no longer used. */ bool is_tcg_gen_code (uintptr_t pc_ptr);#ifdef GETRA_LDST tcg/aarch64/tcg-target.c +15
-12@@ -778,22 +778,24 @@ static inline void tcg_out_nop(TCGContext *s) }#ifdef CONFIG_SOFTMMU -/* helper signature: helper_ld_mmu(CPUState *env, target_ulong addr, -int mmu_idx) */ +/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, +* int mmu_idx, uintptr_t ra) +*/ static const void *const qemu_ld_helpers[4 ] = { - helper_ldb_mmu, - helper_ldw_mmu, - helper_ldl_mmu, - helper_ldq_mmu, + helper_ret_ldub_mmu, + helper_ret_lduw_mmu, + helper_ret_ldul_mmu, + helper_ret_ldq_mmu, }; -/* helper signature: helper_st_mmu(CPUState *env, target_ulong addr, -uintxx_t val, int mmu_idx) */ +/* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, +* uintxx_t val, int mmu_idx, uintptr_t ra) +*/ static const void *const qemu_st_helpers[4 ] = { - helper_stb_mmu, - helper_stw_mmu, - helper_stl_mmu, - helper_stq_mmu, + helper_ret_stb_mmu, + helper_ret_stw_mmu, + helper_ret_stl_mmu, + helper_ret_stq_mmu, };static void tcg_out_qemu_ld_slow_path (TCGContext *s,TCGLabelQemuLdst *lb)@@ -802,6 +804,7 @@ static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_movr(s, 1, TCG_REG_X0, TCG_AREG0);tcg_out_movr (s, (TARGET_LONG_BITS ==64 ),TCG_REG_X1 , lb->addrlo_reg);tcg_out_movi (s,TCG_TYPE_I32 ,TCG_REG_X2 , lb->mem_index); +tcg_out_movi (s,TCG_TYPE_PTR ,TCG_REG_X3 , (tcg_target_long )lb->raddr);tcg_out_movi (s,TCG_TYPE_I64 ,TCG_REG_TMP , (tcg_target_long )qemu_ld_helpers[lb->opc &3 ]);tcg_out_callr(s, TCG_REG_TMP);
tcg/aarch64/tcg-target.c static void tcg_out_qemu_st_slow_path(TCGContext *s, · line 829
Quoted 5 lines
tcg/aarch64/tcg-target.c +1
-0@@ -822,6 +825,7 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_movr(s, (TARGET_LONG_BITS == 64), TCG_REG_X1, lb->addrlo_reg);tcg_out_movr (s,1 ,TCG_REG_X2 , lb->datalo_reg);tcg_out_movi (s,TCG_TYPE_I32 ,TCG_REG_X3 , lb->mem_index); +tcg_out_movi (s,TCG_TYPE_PTR ,TCG_REG_X4 , (tcg_target_long )lb->raddr);
At first
glance I
think we
should add
X4 to the
list of
restrictions
in
function
`target_parse_constraint':
tcg_regset_reset_reg(ct->u.regs,TCG_REG_X4);
Otherwise
I am more
than happy
with the
intention
to removetcg_getra_ldst.
Quoted 6 lines
tcg/aarch64/tcg-target.c +0
-0tcg_out_movi (s,TCG_TYPE_I64 ,TCG_REG_TMP , (tcg_target_long )qemu_st_helpers[lb->opc &3 ]);tcg_out_callr(s, TCG_REG_TMP);Signature · 1 line
1.8.3.1
Claudio
Re: [Qemu-devel] [PATCH 1/5] tcg-aarch64: Update to helper_ret_*_mmu routines
Quoted 2 lines · Claudio Fontana
At first glance I think we should add X4 to the list of restrictions in function `target_parse_constraint':
No, we've consumed all of the inputs at this point. We only need list those registers we're going to clobber before the inputs are consumed.
r~
Re: [Qemu-devel] [PATCH 1/5] tcg-aarch64: Update to helper_ret_*_mmu routines
Quoted 11 lines · Richard Henderson
Quoted 2 lines · Claudio Fontana
At first glance I think we should add X4 to the list of restrictions in function `target_parse_constraint':
No, we've consumed all of the inputs at this point. We only need list those registers we're going to clobber before the inputs are consumed.
r~
Indeed. Tested with target arm, x86-64, sparc, all good.
PATCH 2/5 exec: Delete is_tcg_gen_code and GETRA_EXT
In reply to Richard HendersonAll implementations now boil down to GETRA.
--- include/exec/exec-all.h | 12 ------------ include/exec/softmmu_template.h | 4 ++-- translate-all.c | 12 ------------ 3 files changed, 2 insertions(+), 26 deletions(-)
include/exec/exec-all.h +0 -12
@@ -320,18 +320,6 @@ extern uintptr_t tci_tb_ptr;#define GETPC () (GETRA() - GETPC_ADJ) -/* ??? Delete these once they are no longer used. */ -bool is_tcg_gen_code (uintptr_t pc_ptr); -#ifdef GETRA_LDST -# define GETRA_EXT () tcg_getra_ext(GETRA()) -static inline uintptr_t tcg_getra_ext (uintptr_t ra) -{ -return is_tcg_gen_code (ra) ?GETRA_LDST (ra) : ra; -} -#else -# define GETRA_EXT () GETRA() -#endif -#if !defined(CONFIG_USER_ONLY )void phys_mem_set_alloc (void *(*alloc)(ram_addr_t ));
include/exec/softmmu_template.h +2 -2
@@ -172,7 +172,7 @@ glue(glue(helper_ld, SUFFIX), MMUSUFFIX)(CPUArchState *env, target_ulong addr, int mmu_idx) {return glue (glue (helper_ret_ld,USUFFIX ),MMUSUFFIX )(env, addr, mmu_idx, -GETRA_EXT ()); +GETRA ()); }#ifndef SOFTMMU_CODE_ACCESS
@@ -285,7 +285,7 @@ glue(glue(helper_st, SUFFIX), MMUSUFFIX)(CPUArchState *env, target_ulong addr, DATA_TYPE val, int mmu_idx) {glue (glue (helper_ret_st ,SUFFIX ),MMUSUFFIX )(env ,addr ,val ,mmu_idx , -GETRA_EXT ()); +GETRA ()); }#endif /* !defined(SOFTMMU_CODE_ACCESS) */
translate-all.c +0 -12
@@ -1318,18 +1318,6 @@ static void tb_link_page(TranslationBlock *tb, tb_page_addr_t phys_pc,mmap_unlock (); } -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION ) && defined(CONFIG_SOFTMMU ) -/* check whether the given addr is in TCG generated code buffer or not */ -bool is_tcg_gen_code (uintptr_t tc_ptr) -{ -/* This can be called during code generation, code_gen_buffer_size -is used instead of code_gen_ptr for upper boundary checking */ -return (tc_ptr >= (uintptr_t )tcg_ctx.code_gen_buffer && - tc_ptr < (uintptr_t )(tcg_ctx.code_gen_buffer + - tcg_ctx.code_gen_buffer_size)); -} -#endif -/* find the TB 'tb' such that tb[0].tc_ptr <= tc_ptr < tb[1].tc_ptr. Return NULL if not found */ static TranslationBlock *tb_find_pc (uintptr_t tc_ptr)
Signature · 1 line
1.8.3.1
PATCH 3/5 tcg: Add tcg-be-null.h
In reply to Richard HendersonThis is a no-op backend data implementation, for those targets that are not currently using the load/store optimization path.
This is prepatory to always requiring these functions in all backends.
--- tcg/ia64/tcg-target.c | 2 ++ tcg/mips/tcg-target.c | 2 ++ tcg/s390/tcg-target.c | 2 ++ tcg/sparc/tcg-target.c | 2 ++ tcg/tcg-be-null.h | 43 +++++++++++++++++++++++++++++++++++++++++++ tcg/tci/tcg-target.c | 2 ++ 6 files changed, 53 insertions(+) create mode 100644 tcg/tcg-be-null.h
tcg/ia64/tcg-target.c +2 -0
@@ -23,6 +23,8 @@* THE SOFTWARE. */ +#include "tcg-be-null.h" +/* * Register definitions */
tcg/mips/tcg-target.c +2 -0
@@ -24,6 +24,8 @@* THE SOFTWARE. */ +#include "tcg-be-null.h" +#if defined(TCG_TARGET_WORDS_BIGENDIAN ) == defined(TARGET_WORDS_BIGENDIAN )# define TCG_NEED_BSWAP 0#else
tcg/s390/tcg-target.c +2 -0
@@ -24,6 +24,8 @@* THE SOFTWARE. */ +#include "tcg-be-null.h" +/* We only support generating code for 64-bit mode. */ #if TCG_TARGET_REG_BITS !=64 #error "unsupported code generation mode"
tcg/sparc/tcg-target.c +2 -0
@@ -22,6 +22,8 @@* THE SOFTWARE. */ +#include "tcg-be-null.h" +#ifndef NDEBUG static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS ] = { "%g0",
tcg/tcg-be-null.h new file +43 -0
43 lines not on this page · raw message
tcg/tci/tcg-target.c +2 -0
@@ -22,6 +22,8 @@* THE SOFTWARE. */ +#include "tcg-be-null.h" +/* TODO list: * - See TODO comments in code. */
Signature · 1 line
1.8.3.1
PATCH 4/5 tcg: Add tcg-be-ldst.h
In reply to Richard HendersonMove TCGLabelQemuLdst and related stuff out of tcg.h.
--- tcg/aarch64/tcg-target.c | 23 ++----------- tcg/arm/tcg-target.c | 27 ++------------- tcg/i386/tcg-target.c | 30 ++-------------- tcg/ppc/tcg-target.c | 28 ++------------- tcg/ppc64/tcg-target.c | 26 ++------------ tcg/tcg-be-ldst.h | 90 ++++++++++++++++++++++++++++++++++++++++++++++++ tcg/tcg.c | 15 ++++---- tcg/tcg.h | 31 ++--------------- 8 files changed, 112 insertions(+), 158 deletions(-) create mode 100644 tcg/tcg-be-ldst.h
tcg/aarch64/tcg-target.c +2 -21
@@ -10,6 +10,7 @@* See the COPYING file in the top-level directory for details. */ +#include "tcg-be-ldst.h" #include "qemu/bitops.h" #ifndef NDEBUG
@@ -834,33 +835,13 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb)tcg_out_goto (s, (tcg_target_long )lb->raddr); } -void tcg_out_tb_finalize (TCGContext *s) -{ -int i; -for (i =0 ; i < s->nb_qemu_ldst_labels; i++) { -TCGLabelQemuLdst *label = &s->qemu_ldst_labels[i]; -if (label->is_ld) { -tcg_out_qemu_ld_slow_path (s, label); - }else { -tcg_out_qemu_st_slow_path (s, label); - } - } -} -static void add_qemu_ldst_label (TCGContext *s,int is_ld,int opc,TCGReg data_reg,TCGReg addr_reg,int mem_index,uint8_t *raddr,uint8_t *label_ptr) { -int idx; -TCGLabelQemuLdst *label; - -if (s->nb_qemu_ldst_labels >=TCG_MAX_QEMU_LDST ) { -tcg_abort (); - } +TCGLabelQemuLdst *label =new_ldst_label (s); - idx = s->nb_qemu_ldst_labels++; - label = &s->qemu_ldst_labels[idx]; label->is_ld = is_ld; label->opc = opc; label->datalo_reg = data_reg;
tcg/arm/tcg-target.c +3 -24
@@ -22,6 +22,8 @@* THE SOFTWARE. */ +#include "tcg-be-ldst.h" +/* The __ARM_ARCH define is provided by gcc 4.8. Construct it otherwise. */ #ifndef __ARM_ARCH# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
@@ -1243,15 +1245,8 @@ static void add_qemu_ldst_label(TCGContext *s, int is_ld, int opc, int addrhi_reg, int mem_index, uint8_t *raddr, uint8_t *label_ptr) { - int idx; -TCGLabelQemuLdst *label; - -if (s->nb_qemu_ldst_labels >=TCG_MAX_QEMU_LDST ) { -tcg_abort (); - } + TCGLabelQemuLdst *label = new_ldst_label(s); - idx = s->nb_qemu_ldst_labels++; - label = (TCGLabelQemuLdst *)&s->qemu_ldst_labels[idx]; label->is_ld = is_ld; label->opc = opc; label->datalo_reg = data_reg;
@@ -1968,22 +1963,6 @@ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc, } } -#ifdef CONFIG_SOFTMMU -/* Generate TB finalization at the end of block. */ -void tcg_out_tb_finalize (TCGContext *s) -{ -int i; -for (i =0 ; i < s->nb_qemu_ldst_labels; i++) { -TCGLabelQemuLdst *label = &s->qemu_ldst_labels[i]; -if (label->is_ld) { -tcg_out_qemu_ld_slow_path (s, label); - }else { -tcg_out_qemu_st_slow_path (s, label); - } - } -} -#endif /* SOFTMMU */ -static const TCGTargetOpDef arm_op_defs[] = { { INDEX_op_exit_tb, { } }, { INDEX_op_goto_tb, { } },
tcg/i386/tcg-target.c +3 -27
@@ -22,6 +22,8 @@* THE SOFTWARE. */ +#include "tcg-be-ldst.h" +#ifndef NDEBUG static const char *const tcg_target_reg_names[TCG_TARGET_NB_REGS ] = { #if TCG_TARGET_REG_BITS == 64
@@ -1455,15 +1457,8 @@ static void add_qemu_ldst_label(TCGContext *s,uint8_t *raddr, uint8_t **label_ptr) { - int idx; -TCGLabelQemuLdst *label; - -if (s->nb_qemu_ldst_labels >=TCG_MAX_QEMU_LDST ) { -tcg_abort (); - } + TCGLabelQemuLdst *label = new_ldst_label(s); - idx = s->nb_qemu_ldst_labels++; - label = (TCGLabelQemuLdst *)&s->qemu_ldst_labels[idx]; label->is_ld = is_ld; label->opc = opc; label->datalo_reg = data_reg;
@@ -1628,25 +1623,6 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l)tcg_out_push (s, retaddr);tcg_out_jmp (s, (uintptr_t )qemu_st_helpers[s_bits]); } - -/* -* Generate TB finalization at the end of block -*/ -void tcg_out_tb_finalize (TCGContext *s) -{ -int i; -TCGLabelQemuLdst *label; - -/* qemu_ld/st slow paths */ -for (i =0 ; i < s->nb_qemu_ldst_labels; i++) { - label = (TCGLabelQemuLdst *)&s->qemu_ldst_labels[i]; -if (label->is_ld) { -tcg_out_qemu_ld_slow_path (s, label); - }else { -tcg_out_qemu_st_slow_path (s, label); - } - } -}#endif /* CONFIG_SOFTMMU */ static inline void tcg_out_op(TCGContext *s, TCGOpcode opc,
tcg/ppc/tcg-target.c +3 -25
@@ -22,6 +22,8 @@* THE SOFTWARE. */ +#include "tcg-be-ldst.h" +static uint8_t *tb_ret_addr;#if defined _CALL_DARWIN || defined __APPLE__
@@ -532,15 +534,8 @@ static void add_qemu_ldst_label (TCGContext *s,uint8_t *raddr, uint8_t *label_ptr) { - int idx; -TCGLabelQemuLdst *label; - -if (s->nb_qemu_ldst_labels >=TCG_MAX_QEMU_LDST ) { -tcg_abort (); - } + TCGLabelQemuLdst *label = new_ldst_label(s); - idx = s->nb_qemu_ldst_labels++; - label = (TCGLabelQemuLdst *)&s->qemu_ldst_labels[idx]; label->is_ld = is_ld; label->opc = opc; label->datalo_reg = data_reg;
@@ -889,23 +884,6 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l)tcg_out_b (s,LK , (uintptr_t )st_trampolines[l->opc]); tcg_out_b(s, 0, (uintptr_t)l->raddr); } - -void tcg_out_tb_finalize (TCGContext *s) -{ -int i; -TCGLabelQemuLdst *label; - -/* qemu_ld/st slow paths */ -for (i =0 ; i < s->nb_qemu_ldst_labels; i++) { - label = (TCGLabelQemuLdst *) &s->qemu_ldst_labels[i]; -if (label->is_ld) { -tcg_out_qemu_ld_slow_path (s, label); - } -else { -tcg_out_qemu_st_slow_path (s, label); - } - } -}#endif #ifdef CONFIG_SOFTMMU
tcg/ppc64/tcg-target.c +3 -23
@@ -22,6 +22,8 @@* THE SOFTWARE. */ +#include "tcg-be-ldst.h" +#define TCG_CT_CONST_S16 0x100#define TCG_CT_CONST_U16 0x200#define TCG_CT_CONST_S32 0x400
@@ -931,15 +933,8 @@ static void add_qemu_ldst_label(TCGContext *s, bool is_ld, int opc, int data_reg, int addr_reg, int mem_index, uint8_t *raddr, uint8_t *label_ptr) { - int idx; -TCGLabelQemuLdst *label; - -if (s->nb_qemu_ldst_labels >=TCG_MAX_QEMU_LDST ) { -tcg_abort (); - } + TCGLabelQemuLdst *label = new_ldst_label(s); - idx = s->nb_qemu_ldst_labels++; - label = (TCGLabelQemuLdst *)&s->qemu_ldst_labels[idx]; label->is_ld = is_ld; label->opc = opc; label->datalo_reg = data_reg;
@@ -998,21 +993,6 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *lb) tcg_out_b(s, 0, (uintptr_t)lb->raddr); } - -void tcg_out_tb_finalize (TCGContext *s) -{ -int i, n = s->nb_qemu_ldst_labels; - -/* qemu_ld/st slow paths */ -for (i =0 ; i < n; i++) { -TCGLabelQemuLdst *label = &s->qemu_ldst_labels[i]; -if (label->is_ld) { -tcg_out_qemu_ld_slow_path (s, label); - }else { -tcg_out_qemu_st_slow_path (s, label); - } - } -}#endif /* SOFTMMU */ static void tcg_out_qemu_ld (TCGContext *s,const TCGArg *args,int opc)
tcg/tcg-be-ldst.h new file +90 -0
90 lines not on this page · raw message
tcg/tcg.c +6 -9
@@ -103,6 +103,9 @@ static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1, intptr_t arg2);static int tcg_target_const_match (tcg_target_long val,const TCGArgConstraint *arg_ct); +static void tcg_out_tb_init (TCGContext *s); +static void tcg_out_tb_finalize (TCGContext *s); +TCGOpDef tcg_op_defs[] = { #define DEF(s, oargs, iargs, cargs, flags) { #s, oargs, iargs, cargs, iargs + oargs + cargs, flags },
@@ -332,13 +335,7 @@ void tcg_func_start(TCGContext *s) s->gen_opc_ptr = s->gen_opc_buf; s->gen_opparam_ptr = s->gen_opparam_buf; -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION ) && defined(CONFIG_SOFTMMU ) -/* Initialize qemu_ld/st labels to assist code generation at the end of TB -for TLB miss cases at the end of TB */ - s->qemu_ldst_labels =tcg_malloc (sizeof (TCGLabelQemuLdst) * -TCG_MAX_QEMU_LDST ); - s->nb_qemu_ldst_labels =0 ; -#endif + s->be =tcg_malloc (sizeof (TCGBackendData)); }static inline void tcg_temp_alloc (TCGContext *s,int n)
@@ -2311,6 +2308,8 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf, s->code_buf = gen_code_buf; s->code_ptr = gen_code_buf; +tcg_out_tb_init (s); + args = s->gen_opparam_buf; op_index =0 ;
@@ -2384,10 +2383,8 @@ static inline int tcg_gen_code_common(TCGContext *s, uint8_t *gen_code_buf,#endif } the_end: -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION ) && defined(CONFIG_SOFTMMU )/* Generate TB finalization at the end of block */ tcg_out_tb_finalize (s); -#endif return -1 ; }
tcg/tcg.h +2 -29
@@ -211,24 +211,6 @@ typedef tcg_target_ulong TCGArg;are aliases for target_ulong and host pointer sized values respectively. */ -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION ) && defined(CONFIG_SOFTMMU ) -/* Macros/structures for qemu_ld/st IR code optimization: -TCG_MAX_HELPER_LABELS is defined as same as OPC_BUF_SIZE in exec-all.h. */ -#define TCG_MAX_QEMU_LDST 640 - -typedef struct TCGLabelQemuLdst { -int is_ld:1 ;/* qemu_ld: 1, qemu_st: 0 */ -int opc:4 ; -int addrlo_reg;/* reg index for low word of guest virtual addr */ -int addrhi_reg;/* reg index for high word of guest virtual addr */ -int datalo_reg;/* reg index for low word to be loaded or stored */ -int datahi_reg;/* reg index for high word to be loaded or stored */ -int mem_index;/* soft MMU memory index */ -uint8_t *raddr;/* gen code addr of the next IR of qemu_ld/st IR */ -uint8_t *label_ptr[2 ];/* label pointers to be updated */ -}TCGLabelQemuLdst ; -#endif -#ifdef CONFIG_DEBUG_TCG #define DEBUG_TCGV 1#endif
@@ -496,12 +478,8 @@ struct TCGContext {TBContext tb_ctx; -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION ) && defined(CONFIG_SOFTMMU ) -/* labels info for qemu_ld/st IRs -The labels help to generate TLB miss case codes at the end of TB */ -TCGLabelQemuLdst *qemu_ldst_labels; -int nb_qemu_ldst_labels; -#endif +/* The TCGBackendData structure is private to tcg-target.c. */ +struct TCGBackendData *be; };extern TCGContext tcg_ctx;
@@ -745,11 +723,6 @@ TCGv_i64 tcg_const_local_i64(int64_t val);void tcg_register_jit (void *buf,size_t buf_size); -#if defined(CONFIG_QEMU_LDST_OPTIMIZATION ) && defined(CONFIG_SOFTMMU ) -/* Generate TB finalization at the end of block */ -void tcg_out_tb_finalize (TCGContext *s); -#endif -/* * Memory helpers that will be used by TCG generated code. */
Signature · 1 line
1.8.3.1
PATCH 5/5 configure: Remove CONFIG_QEMU_LDST_OPTIMIZATION
In reply to Richard HendersonNo longer used.
--- configure | 8 -------- 1 file changed, 8 deletions(-)
configure +0 -8
@@ -3794,14 +3794,6 @@ echo "libs_softmmu=$libs_softmmu" >> $config_host_mak echo "ARCH=$ARCH" >> $config_host_mak -case "$cpu" in - aarch64 | arm | i386 | x86_64 | x32 | ppc*) - # The TCG interpreter currently does not support ld/st optimization. - if test "$tcg_interpreter" = "no" ; then - echo "CONFIG_QEMU_LDST_OPTIMIZATION=y" >> $config_host_mak - fi - ;; -esac if test "$debug_tcg" = "yes" ; then echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak fi
Signature · 1 line
1.8.3.1