Skip to content

Commit 6001f77

Browse files
vivierrth7680
authored andcommitted
tcg: workaround branch instruction overflow in tcg_out_qemu_ld/st
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. Cc: [email protected] Fixes: 15fa08f ("tcg: Dynamically allocate TCGOps") Signed-off-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]> Signed-off-by: Richard Henderson <[email protected]>
1 parent 5bfa803 commit 6001f77

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

tcg/tcg-ldst.inc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ typedef struct TCGLabelQemuLdst {
3030
TCGReg datahi_reg; /* reg index for high word to be loaded or stored */
3131
tcg_insn_unit *raddr; /* gen code addr of the next IR of qemu_ld/st IR */
3232
tcg_insn_unit *label_ptr[2]; /* label pointers to be updated */
33-
struct TCGLabelQemuLdst *next;
33+
QSIMPLEQ_ENTRY(TCGLabelQemuLdst) next;
3434
} TCGLabelQemuLdst;
3535

3636

@@ -46,7 +46,7 @@ static bool tcg_out_ldst_finalize(TCGContext *s)
4646
TCGLabelQemuLdst *lb;
4747

4848
/* qemu_ld/st slow paths */
49-
for (lb = s->ldst_labels; lb != NULL; lb = lb->next) {
49+
QSIMPLEQ_FOREACH(lb, &s->ldst_labels, next) {
5050
if (lb->is_ld) {
5151
tcg_out_qemu_ld_slow_path(s, lb);
5252
} else {
@@ -72,7 +72,7 @@ static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s)
7272
{
7373
TCGLabelQemuLdst *l = tcg_malloc(sizeof(*l));
7474

75-
l->next = s->ldst_labels;
76-
s->ldst_labels = l;
75+
QSIMPLEQ_INSERT_TAIL(&s->ldst_labels, l, next);
76+
7777
return l;
7878
}

tcg/tcg.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3297,7 +3297,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb)
32973297
s->code_ptr = tb->tc.ptr;
32983298

32993299
#ifdef TCG_TARGET_NEED_LDST_LABELS
3300-
s->ldst_labels = NULL;
3300+
QSIMPLEQ_INIT(&s->ldst_labels);
33013301
#endif
33023302
#ifdef TCG_TARGET_NEED_POOL_LABELS
33033303
s->pool_labels = NULL;

tcg/tcg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,7 @@ struct TCGContext {
699699

700700
/* These structures are private to tcg-target.inc.c. */
701701
#ifdef TCG_TARGET_NEED_LDST_LABELS
702-
struct TCGLabelQemuLdst *ldst_labels;
702+
QSIMPLEQ_HEAD(ldst_labels, TCGLabelQemuLdst) ldst_labels;
703703
#endif
704704
#ifdef TCG_TARGET_NEED_POOL_LABELS
705705
struct TCGLabelPoolData *pool_labels;

0 commit comments

Comments
 (0)