* [Qemu-devel] [PATCH v3] tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st
@ 2018-04-29 23:58 Laurent Vivier
2018-05-01 18:43 ` Richard Henderson
0 siblings, 1 reply; 2+ messages in thread
From: Laurent Vivier @ 2018-04-29 23:58 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, Richard Henderson
ppc64 uses a BC instruction to call the tcg_out_qemu_ld/st
slow path. BC instruction uses a relative address encoded
on 14 bits.
The slow path functions are added at the end of the generated
instructions buffer, in the reverse order of the callers.
So more we have slow path functions more the distance between
the caller (BC) and the function increases.
This patch changes the behavior to generate the functions in
the same order of the callers.
Fixes: 15fa08f845 ("tcg: Dynamically allocate TCGOps")
Signed-off-by: Laurent Vivier <lvivier@redhat.com>
---
Notes:
v3:
- use QSIMPLEQ macros (rth)
- RFC -> PATCH
v2:
- add a pointer to the tail of the list to add new element
at the end and keep the original ordering
- remove the recursive call
tcg/tcg-ldst.inc.c | 8 ++++----
tcg/tcg.c | 2 +-
tcg/tcg.h | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/tcg/tcg-ldst.inc.c b/tcg/tcg-ldst.inc.c
index 0e14cf4357..47f41b921b 100644
--- a/tcg/tcg-ldst.inc.c
+++ b/tcg/tcg-ldst.inc.c
@@ -30,7 +30,7 @@ typedef struct TCGLabelQemuLdst {
TCGReg datahi_reg; /* reg index for high word to be loaded or stored */
tcg_insn_unit *raddr; /* gen code addr of the next IR of qemu_ld/st IR */
tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */
- struct TCGLabelQemuLdst *next;
+ QSIMPLEQ_ENTRY(TCGLabelQemuLdst) next;
} TCGLabelQemuLdst;
@@ -46,7 +46,7 @@ static bool tcg_out_ldst_finalize(TCGContext *s)
TCGLabelQemuLdst *lb;
/* qemu_ld/st slow paths */
- for (lb = s->ldst_labels; lb != NULL; lb = lb->next) {
+ QSIMPLEQ_FOREACH(lb, &s->ldst_labels, next) {
if (lb->is_ld) {
tcg_out_qemu_ld_slow_path(s, lb);
} else {
@@ -72,7 +72,7 @@ static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s)
{
TCGLabelQemuLdst *l = tcg_malloc(sizeof(*l));
- l->next = s->ldst_labels;
- s->ldst_labels = l;
+ QSIMPLEQ_INSERT_TAIL(&s->ldst_labels, l, next);
+
return l;
}
diff --git a/tcg/tcg.c b/tcg/tcg.c
index bb24526c93..b84850b726 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -3324,7 +3324,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
s->code_ptr = tb->tc.ptr;
#ifdef TCG_TARGET_NEED_LDST_LABELS
- s->ldst_labels = NULL;
+ QSIMPLEQ_INIT(&s->ldst_labels);
#endif
#ifdef TCG_TARGET_NEED_POOL_LABELS
s->pool_labels = NULL;
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 30896ca304..a3076c55d8 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -699,7 +699,7 @@ struct TCGContext {
/* These structures are private to tcg-target.inc.c. */
#ifdef TCG_TARGET_NEED_LDST_LABELS
- struct TCGLabelQemuLdst *ldst_labels;
+ QSIMPLEQ_HEAD(ldst_labels, TCGLabelQemuLdst) ldst_labels;
#endif
#ifdef TCG_TARGET_NEED_POOL_LABELS
struct TCGLabelPoolData *pool_labels;
--
2.14.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [PATCH v3] tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st
2018-04-29 23:58 [Qemu-devel] [PATCH v3] tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st Laurent Vivier
@ 2018-05-01 18:43 ` Richard Henderson
0 siblings, 0 replies; 2+ messages in thread
From: Richard Henderson @ 2018-05-01 18:43 UTC (permalink / raw)
To: Laurent Vivier, qemu-devel; +Cc: Richard Henderson
On 04/29/2018 04:58 PM, Laurent Vivier wrote:
> ppc64 uses a BC instruction to call the tcg_out_qemu_ld/st
> slow path. BC instruction uses a relative address encoded
> on 14 bits.
>
> The slow path functions are added at the end of the generated
> instructions buffer, in the reverse order of the callers.
> So more we have slow path functions more the distance between
> the caller (BC) and the function increases.
>
> This patch changes the behavior to generate the functions in
> the same order of the callers.
>
> Fixes: 15fa08f845 ("tcg: Dynamically allocate TCGOps")
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> ---
Thanks, applied to tcg-next.
r~
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-01 18:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-29 23:58 [Qemu-devel] [PATCH v3] tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st Laurent Vivier
2018-05-01 18:43 ` Richard Henderson
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).