mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2024-12-23 05:05:36 +00:00
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. Backports commit 6001f7729e12dd1d810291e4cbf83cee8e07441d from qemu
This commit is contained in:
parent
2150745db4
commit
ec12091943
|
@ -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;
|
||||
|
||||
/*
|
||||
|
@ -45,7 +45,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 {
|
||||
|
@ -71,7 +71,7 @@ static inline TCGLabelQemuLdst *new_ldst_label(TCGContext *s)
|
|||
{
|
||||
TCGLabelQemuLdst *l = tcg_malloc(s, sizeof(*l));
|
||||
|
||||
l->next = s->ldst_labels;
|
||||
s->ldst_labels = l;
|
||||
QSIMPLEQ_INSERT_TAIL(&s->ldst_labels, l, next);
|
||||
|
||||
return l;
|
||||
}
|
||||
|
|
|
@ -2968,7 +2968,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;
|
||||
|
|
|
@ -787,7 +787,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;
|
||||
|
|
Loading…
Reference in a new issue