sim-card
/
qemu
Archived
10
0
Fork 0

tcg: Use TCGReg for standard tcg-target entry points.

Including tcg_out_ld, tcg_out_st, tcg_out_mov, tcg_out_movi.

Signed-off-by: Richard Henderson <rth@twiddle.net>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
Richard Henderson 2011-11-09 08:03:34 +00:00 committed by Alexander Graf
parent 771142c2a7
commit 2a534aff30
10 changed files with 56 additions and 52 deletions

View File

@ -1808,25 +1808,26 @@ static void tcg_target_init(TCGContext *s)
CPU_TEMP_BUF_NLONGS * sizeof(long)); CPU_TEMP_BUF_NLONGS * sizeof(long));
} }
static inline void tcg_out_ld(TCGContext *s, TCGType type, int arg, static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
tcg_out_ld32u(s, COND_AL, arg, arg1, arg2); tcg_out_ld32u(s, COND_AL, arg, arg1, arg2);
} }
static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
tcg_out_st32(s, COND_AL, arg, arg1, arg2); tcg_out_st32(s, COND_AL, arg, arg1, arg2);
} }
static inline void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg) static inline void tcg_out_mov(TCGContext *s, TCGType type,
TCGReg ret, TCGReg arg)
{ {
tcg_out_dat_reg(s, COND_AL, ARITH_MOV, ret, 0, arg, SHIFT_IMM_LSL(0)); tcg_out_dat_reg(s, COND_AL, ARITH_MOV, ret, 0, arg, SHIFT_IMM_LSL(0));
} }
static inline void tcg_out_movi(TCGContext *s, TCGType type, static inline void tcg_out_movi(TCGContext *s, TCGType type,
int ret, tcg_target_long arg) TCGReg ret, tcg_target_long arg)
{ {
tcg_out_movi32(s, COND_AL, ret, arg); tcg_out_movi32(s, COND_AL, ret, arg);
} }

View File

@ -338,7 +338,7 @@ static int tcg_target_const_match(tcg_target_long val,
/* supplied by libgcc */ /* supplied by libgcc */
extern void *__canonicalize_funcptr_for_compare(void *); extern void *__canonicalize_funcptr_for_compare(void *);
static void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg) static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
{ {
/* PA1.1 defines COPY as OR r,0,t; PA2.0 defines COPY as LDO 0(r),t /* PA1.1 defines COPY as OR r,0,t; PA2.0 defines COPY as LDO 0(r),t
but hppa-dis.c is unaware of this definition */ but hppa-dis.c is unaware of this definition */
@ -349,7 +349,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg)
} }
static void tcg_out_movi(TCGContext *s, TCGType type, static void tcg_out_movi(TCGContext *s, TCGType type,
int ret, tcg_target_long arg) TCGReg ret, tcg_target_long arg)
{ {
if (check_fit_tl(arg, 14)) { if (check_fit_tl(arg, 14)) {
tcg_out32(s, INSN_LDO | INSN_R1(ret) tcg_out32(s, INSN_LDO | INSN_R1(ret)
@ -393,15 +393,15 @@ static void tcg_out_ldst(TCGContext *s, int ret, int addr,
} }
/* This function is required by tcg.c. */ /* This function is required by tcg.c. */
static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
tcg_out_ldst(s, ret, arg1, arg2, INSN_LDW); tcg_out_ldst(s, ret, arg1, arg2, INSN_LDW);
} }
/* This function is required by tcg.c. */ /* This function is required by tcg.c. */
static inline void tcg_out_st(TCGContext *s, TCGType type, int ret, static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg ret,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
tcg_out_ldst(s, ret, arg1, arg2, INSN_STW); tcg_out_ldst(s, ret, arg1, arg2, INSN_STW);
} }

View File

@ -518,7 +518,8 @@ static inline void tgen_arithr(TCGContext *s, int subop, int dest, int src)
tcg_out_modrm(s, OPC_ARITH_GvEv + (subop << 3) + ext, dest, src); tcg_out_modrm(s, OPC_ARITH_GvEv + (subop << 3) + ext, dest, src);
} }
static inline void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg) static inline void tcg_out_mov(TCGContext *s, TCGType type,
TCGReg ret, TCGReg arg)
{ {
if (arg != ret) { if (arg != ret) {
int opc = OPC_MOVL_GvEv + (type == TCG_TYPE_I64 ? P_REXW : 0); int opc = OPC_MOVL_GvEv + (type == TCG_TYPE_I64 ? P_REXW : 0);
@ -527,7 +528,7 @@ static inline void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg)
} }
static void tcg_out_movi(TCGContext *s, TCGType type, static void tcg_out_movi(TCGContext *s, TCGType type,
int ret, tcg_target_long arg) TCGReg ret, tcg_target_long arg)
{ {
if (arg == 0) { if (arg == 0) {
tgen_arithr(s, ARITH_XOR, ret, ret); tgen_arithr(s, ARITH_XOR, ret, ret);
@ -568,15 +569,15 @@ static inline void tcg_out_pop(TCGContext *s, int reg)
tcg_out_opc(s, OPC_POP_r32 + LOWREGMASK(reg), 0, reg, 0); tcg_out_opc(s, OPC_POP_r32 + LOWREGMASK(reg), 0, reg, 0);
} }
static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
int opc = OPC_MOVL_GvEv + (type == TCG_TYPE_I64 ? P_REXW : 0); int opc = OPC_MOVL_GvEv + (type == TCG_TYPE_I64 ? P_REXW : 0);
tcg_out_modrm_offset(s, opc, ret, arg1, arg2); tcg_out_modrm_offset(s, opc, ret, arg1, arg2);
} }
static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
int opc = OPC_MOVL_EvGv + (type == TCG_TYPE_I64 ? P_REXW : 0); int opc = OPC_MOVL_EvGv + (type == TCG_TYPE_I64 ? P_REXW : 0);
tcg_out_modrm_offset(s, opc, arg, arg1, arg2); tcg_out_modrm_offset(s, opc, arg, arg1, arg2);

View File

@ -830,7 +830,7 @@ static inline void tcg_out_bundle(TCGContext *s, int template,
} }
static inline void tcg_out_mov(TCGContext *s, TCGType type, static inline void tcg_out_mov(TCGContext *s, TCGType type,
TCGArg ret, TCGArg arg) TCGReg ret, TCGReg arg)
{ {
tcg_out_bundle(s, mmI, tcg_out_bundle(s, mmI,
tcg_opc_m48(TCG_REG_P0, OPC_NOP_M48, 0), tcg_opc_m48(TCG_REG_P0, OPC_NOP_M48, 0),
@ -839,7 +839,7 @@ static inline void tcg_out_mov(TCGContext *s, TCGType type,
} }
static inline void tcg_out_movi(TCGContext *s, TCGType type, static inline void tcg_out_movi(TCGContext *s, TCGType type,
TCGArg reg, tcg_target_long arg) TCGReg reg, tcg_target_long arg)
{ {
tcg_out_bundle(s, mLX, tcg_out_bundle(s, mLX,
tcg_opc_m48(TCG_REG_P0, OPC_NOP_M48, 0), tcg_opc_m48(TCG_REG_P0, OPC_NOP_M48, 0),
@ -972,8 +972,8 @@ static inline void tcg_out_st_rel(TCGContext *s, uint64_t opc_m4, TCGArg arg,
} }
} }
static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGArg arg, static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg,
TCGArg arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
if (type == TCG_TYPE_I32) { if (type == TCG_TYPE_I32) {
tcg_out_ld_rel(s, OPC_LD4_M1, arg, arg1, arg2); tcg_out_ld_rel(s, OPC_LD4_M1, arg, arg1, arg2);
@ -982,8 +982,8 @@ static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGArg arg,
} }
} }
static inline void tcg_out_st(TCGContext *s, TCGType type, TCGArg arg, static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg,
TCGArg arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
if (type == TCG_TYPE_I32) { if (type == TCG_TYPE_I32) {
tcg_out_st_rel(s, OPC_ST4_M4, arg, arg1, arg2); tcg_out_st_rel(s, OPC_ST4_M4, arg, arg1, arg2);

View File

@ -379,13 +379,14 @@ static inline void tcg_out_nop(TCGContext *s)
tcg_out32(s, 0); tcg_out32(s, 0);
} }
static inline void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg) static inline void tcg_out_mov(TCGContext *s, TCGType type,
TCGReg ret, TCGReg arg)
{ {
tcg_out_opc_reg(s, OPC_ADDU, ret, arg, TCG_REG_ZERO); tcg_out_opc_reg(s, OPC_ADDU, ret, arg, TCG_REG_ZERO);
} }
static inline void tcg_out_movi(TCGContext *s, TCGType type, static inline void tcg_out_movi(TCGContext *s, TCGType type,
int reg, int32_t arg) TCGReg reg, tcg_target_long arg)
{ {
if (arg == (int16_t)arg) { if (arg == (int16_t)arg) {
tcg_out_opc_imm(s, OPC_ADDIU, reg, TCG_REG_ZERO, arg); tcg_out_opc_imm(s, OPC_ADDIU, reg, TCG_REG_ZERO, arg);
@ -480,14 +481,14 @@ static inline void tcg_out_ldst(TCGContext *s, int opc, int arg,
} }
} }
static inline void tcg_out_ld(TCGContext *s, TCGType type, int arg, static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
tcg_out_ldst(s, OPC_LW, arg, arg1, arg2); tcg_out_ldst(s, OPC_LW, arg, arg1, arg2);
} }
static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
tcg_out_ldst(s, OPC_SW, arg, arg1, arg2); tcg_out_ldst(s, OPC_SW, arg, arg1, arg2);
} }

View File

@ -436,13 +436,13 @@ static const uint32_t tcg_to_bc[10] = {
[TCG_COND_GTU] = BC | BI (7, CR_GT) | BO_COND_TRUE, [TCG_COND_GTU] = BC | BI (7, CR_GT) | BO_COND_TRUE,
}; };
static void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg) static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
{ {
tcg_out32 (s, OR | SAB (arg, ret, arg)); tcg_out32 (s, OR | SAB (arg, ret, arg));
} }
static void tcg_out_movi(TCGContext *s, TCGType type, static void tcg_out_movi(TCGContext *s, TCGType type,
int ret, tcg_target_long arg) TCGReg ret, tcg_target_long arg)
{ {
if (arg == (int16_t) arg) if (arg == (int16_t) arg)
tcg_out32 (s, ADDI | RT (ret) | RA (0) | (arg & 0xffff)); tcg_out32 (s, ADDI | RT (ret) | RA (0) | (arg & 0xffff));
@ -961,13 +961,13 @@ static void tcg_target_qemu_prologue (TCGContext *s)
tcg_out32 (s, BCLR | BO_ALWAYS); tcg_out32 (s, BCLR | BO_ALWAYS);
} }
static void tcg_out_ld (TCGContext *s, TCGType type, int ret, int arg1, static void tcg_out_ld (TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1,
tcg_target_long arg2) tcg_target_long arg2)
{ {
tcg_out_ldst (s, ret, arg1, arg2, LWZ, LWZX); tcg_out_ldst (s, ret, arg1, arg2, LWZ, LWZX);
} }
static void tcg_out_st (TCGContext *s, TCGType type, int arg, int arg1, static void tcg_out_st (TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1,
tcg_target_long arg2) tcg_target_long arg2)
{ {
tcg_out_ldst (s, arg, arg1, arg2, STW, STWX); tcg_out_ldst (s, arg, arg1, arg2, STW, STWX);

View File

@ -435,7 +435,7 @@ static const uint32_t tcg_to_bc[10] = {
[TCG_COND_GTU] = BC | BI (7, CR_GT) | BO_COND_TRUE, [TCG_COND_GTU] = BC | BI (7, CR_GT) | BO_COND_TRUE,
}; };
static void tcg_out_mov (TCGContext *s, TCGType type, int ret, int arg) static void tcg_out_mov (TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
{ {
tcg_out32 (s, OR | SAB (arg, ret, arg)); tcg_out32 (s, OR | SAB (arg, ret, arg));
} }
@ -459,7 +459,7 @@ static void tcg_out_movi32 (TCGContext *s, int ret, int32_t arg)
} }
static void tcg_out_movi (TCGContext *s, TCGType type, static void tcg_out_movi (TCGContext *s, TCGType type,
int ret, tcg_target_long arg) TCGReg ret, tcg_target_long arg)
{ {
int32_t arg32 = arg; int32_t arg32 = arg;
arg = type == TCG_TYPE_I32 ? arg & 0xffffffff : arg; arg = type == TCG_TYPE_I32 ? arg & 0xffffffff : arg;
@ -930,7 +930,7 @@ static void tcg_target_qemu_prologue (TCGContext *s)
tcg_out32 (s, BCLR | BO_ALWAYS); tcg_out32 (s, BCLR | BO_ALWAYS);
} }
static void tcg_out_ld (TCGContext *s, TCGType type, int ret, int arg1, static void tcg_out_ld (TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1,
tcg_target_long arg2) tcg_target_long arg2)
{ {
if (type == TCG_TYPE_I32) if (type == TCG_TYPE_I32)
@ -939,7 +939,7 @@ static void tcg_out_ld (TCGContext *s, TCGType type, int ret, int arg1,
tcg_out_ldsta (s, ret, arg1, arg2, LD, LDX); tcg_out_ldsta (s, ret, arg1, arg2, LD, LDX);
} }
static void tcg_out_st (TCGContext *s, TCGType type, int arg, int arg1, static void tcg_out_st (TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1,
tcg_target_long arg2) tcg_target_long arg2)
{ {
if (type == TCG_TYPE_I32) if (type == TCG_TYPE_I32)

View File

@ -306,7 +306,8 @@ static void tcg_out_arithc(TCGContext *s, int rd, int rs1,
| (val2const ? INSN_IMM13(val2) : INSN_RS2(val2))); | (val2const ? INSN_IMM13(val2) : INSN_RS2(val2)));
} }
static inline void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg) static inline void tcg_out_mov(TCGContext *s, TCGType type,
TCGReg ret, TCGReg arg)
{ {
tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR); tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR);
} }
@ -333,7 +334,7 @@ static inline void tcg_out_movi_imm32(TCGContext *s, int ret, uint32_t arg)
} }
static inline void tcg_out_movi(TCGContext *s, TCGType type, static inline void tcg_out_movi(TCGContext *s, TCGType type,
int ret, tcg_target_long arg) TCGReg ret, tcg_target_long arg)
{ {
/* All 32-bit constants, as well as 64-bit constants with /* All 32-bit constants, as well as 64-bit constants with
no high bits set go through movi_imm32. */ no high bits set go through movi_imm32. */
@ -398,8 +399,8 @@ static inline void tcg_out_ldst_asi(TCGContext *s, int ret, int addr,
INSN_ASI(asi) | INSN_RS2(addr)); INSN_ASI(asi) | INSN_RS2(addr));
} }
static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret, static inline void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
if (type == TCG_TYPE_I32) if (type == TCG_TYPE_I32)
tcg_out_ldst(s, ret, arg1, arg2, LDUW); tcg_out_ldst(s, ret, arg1, arg2, LDUW);
@ -407,8 +408,8 @@ static inline void tcg_out_ld(TCGContext *s, TCGType type, int ret,
tcg_out_ldst(s, ret, arg1, arg2, LDX); tcg_out_ldst(s, ret, arg1, arg2, LDX);
} }
static inline void tcg_out_st(TCGContext *s, TCGType type, int arg, static inline void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg,
int arg1, tcg_target_long arg2) TCGReg arg1, tcg_target_long arg2)
{ {
if (type == TCG_TYPE_I32) if (type == TCG_TYPE_I32)
tcg_out_ldst(s, arg, arg1, arg2, STW); tcg_out_ldst(s, arg, arg1, arg2, STW);

View File

@ -71,14 +71,14 @@ static void patch_reloc(uint8_t *code_ptr, int type,
/* Forward declarations for functions declared and used in tcg-target.c. */ /* Forward declarations for functions declared and used in tcg-target.c. */
static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str); static int target_parse_constraint(TCGArgConstraint *ct, const char **pct_str);
static void tcg_out_ld(TCGContext *s, TCGType type, int ret, int arg1, static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1,
tcg_target_long arg2); tcg_target_long arg2);
static void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg); static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg);
static void tcg_out_movi(TCGContext *s, TCGType type, static void tcg_out_movi(TCGContext *s, TCGType type,
int ret, tcg_target_long arg); TCGReg ret, tcg_target_long arg);
static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args, static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
const int *const_args); const int *const_args);
static void tcg_out_st(TCGContext *s, TCGType type, int arg, int arg1, static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1,
tcg_target_long arg2); tcg_target_long arg2);
static int tcg_target_const_match(tcg_target_long val, static int tcg_target_const_match(tcg_target_long val,
const TCGArgConstraint *arg_ct); const TCGArgConstraint *arg_ct);

View File

@ -495,7 +495,7 @@ static void tci_out_label(TCGContext *s, TCGArg arg)
} }
} }
static void tcg_out_ld(TCGContext *s, TCGType type, int ret, int arg1, static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1,
tcg_target_long arg2) tcg_target_long arg2)
{ {
uint8_t *old_code_ptr = s->code_ptr; uint8_t *old_code_ptr = s->code_ptr;
@ -519,7 +519,7 @@ static void tcg_out_ld(TCGContext *s, TCGType type, int ret, int arg1,
old_code_ptr[1] = s->code_ptr - old_code_ptr; old_code_ptr[1] = s->code_ptr - old_code_ptr;
} }
static void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg) static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
{ {
uint8_t *old_code_ptr = s->code_ptr; uint8_t *old_code_ptr = s->code_ptr;
assert(ret != arg); assert(ret != arg);
@ -534,7 +534,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, int ret, int arg)
} }
static void tcg_out_movi(TCGContext *s, TCGType type, static void tcg_out_movi(TCGContext *s, TCGType type,
int t0, tcg_target_long arg) TCGReg t0, tcg_target_long arg)
{ {
uint8_t *old_code_ptr = s->code_ptr; uint8_t *old_code_ptr = s->code_ptr;
uint32_t arg32 = arg; uint32_t arg32 = arg;
@ -834,7 +834,7 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, const TCGArg *args,
old_code_ptr[1] = s->code_ptr - old_code_ptr; old_code_ptr[1] = s->code_ptr - old_code_ptr;
} }
static void tcg_out_st(TCGContext *s, TCGType type, int arg, int arg1, static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, TCGReg arg1,
tcg_target_long arg2) tcg_target_long arg2)
{ {
uint8_t *old_code_ptr = s->code_ptr; uint8_t *old_code_ptr = s->code_ptr;