Commit 9ecefc84 authored by Richard Henderson's avatar Richard Henderson
Browse files

tcg: Add tcg-be-ldst.h



Move TCGLabelQemuLdst and related stuff out of tcg.h.

Signed-off-by: default avatarRichard Henderson <rth@twiddle.net>
parent 3cf246f0
Loading
Loading
Loading
Loading
+2 −21
Original line number Diff line number Diff line
@@ -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;
+3 −24
Original line number Diff line number Diff line
@@ -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, { } },
+3 −27
Original line number Diff line number Diff line
@@ -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,
+3 −25
Original line number Diff line number Diff line
@@ -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
+3 −23
Original line number Diff line number Diff line
@@ -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)
Loading