tcg: Return bool success from tcg_out_mov

This patch merely changes the interface, aborting on all failures,
of which there are currently none.

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2019-03-16 17:48:18 +00:00
parent c16f52b2c5
commit 78113e83e0
10 changed files with 31 additions and 16 deletions

View File

@ -938,10 +938,10 @@ static void tcg_out_ldst(TCGContext *s, AArch64Insn insn, TCGReg rd,
tcg_out_ldst_r(s, insn, rd, rn, TCG_TYPE_I64, TCG_REG_TMP); tcg_out_ldst_r(s, insn, rd, rn, TCG_TYPE_I64, TCG_REG_TMP);
} }
static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
{ {
if (ret == arg) { if (ret == arg) {
return; return true;
} }
switch (type) { switch (type) {
case TCG_TYPE_I32: case TCG_TYPE_I32:
@ -970,6 +970,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
default: default:
g_assert_not_reached(); g_assert_not_reached();
} }
return true;
} }
static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret,

View File

@ -2264,10 +2264,11 @@ static inline bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val,
return false; return false;
} }
static inline void tcg_out_mov(TCGContext *s, TCGType type, static inline bool tcg_out_mov(TCGContext *s, TCGType type,
TCGReg ret, TCGReg arg) TCGReg ret, TCGReg arg)
{ {
tcg_out_mov_reg(s, COND_AL, ret, arg); tcg_out_mov_reg(s, COND_AL, ret, arg);
return true;
} }
static inline void tcg_out_movi(TCGContext *s, TCGType type, static inline void tcg_out_movi(TCGContext *s, TCGType type,

View File

@ -809,12 +809,12 @@ 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 void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
{ {
int rexw = 0; int rexw = 0;
if (arg == ret) { if (arg == ret) {
return; return true;
} }
switch (type) { switch (type) {
case TCG_TYPE_I64: case TCG_TYPE_I64:
@ -852,6 +852,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
default: default:
g_assert_not_reached(); g_assert_not_reached();
} }
return true;
} }
static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece, static void tcg_out_dup_vec(TCGContext *s, TCGType type, unsigned vece,

View File

@ -558,13 +558,14 @@ static inline void tcg_out_dsra(TCGContext *s, TCGReg rd, TCGReg rt, TCGArg sa)
tcg_out_opc_sa64(s, OPC_DSRA, OPC_DSRA32, rd, rt, sa); tcg_out_opc_sa64(s, OPC_DSRA, OPC_DSRA32, rd, rt, sa);
} }
static inline void tcg_out_mov(TCGContext *s, TCGType type, static inline bool tcg_out_mov(TCGContext *s, TCGType type,
TCGReg ret, TCGReg arg) TCGReg ret, TCGReg arg)
{ {
/* Simple reg-reg move, optimising out the 'do nothing' case */ /* Simple reg-reg move, optimising out the 'do nothing' case */
if (ret != arg) { if (ret != arg) {
tcg_out_opc_reg(s, OPC_OR, ret, arg, TCG_REG_ZERO); tcg_out_opc_reg(s, OPC_OR, ret, arg, TCG_REG_ZERO);
} }
return true;
} }
static void tcg_out_movi(TCGContext *s, TCGType type, static void tcg_out_movi(TCGContext *s, TCGType type,

View File

@ -559,12 +559,13 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt, static void tcg_out_mem_long(TCGContext *s, int opi, int opx, TCGReg rt,
TCGReg base, tcg_target_long offset); TCGReg base, tcg_target_long offset);
static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
{ {
tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32); tcg_debug_assert(TCG_TARGET_REG_BITS == 64 || type == TCG_TYPE_I32);
if (ret != arg) { if (ret != arg) {
tcg_out32(s, OR | SAB(arg, ret, arg)); tcg_out32(s, OR | SAB(arg, ret, arg));
} }
return true;
} }
static inline void tcg_out_rld(TCGContext *s, int op, TCGReg ra, TCGReg rs, static inline void tcg_out_rld(TCGContext *s, int op, TCGReg ra, TCGReg rs,

View File

@ -515,10 +515,10 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type,
* TCG intrinsics * TCG intrinsics
*/ */
static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
{ {
if (ret == arg) { if (ret == arg) {
return; return true;
} }
switch (type) { switch (type) {
case TCG_TYPE_I32: case TCG_TYPE_I32:
@ -528,6 +528,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
default: default:
g_assert_not_reached(); g_assert_not_reached();
} }
return true;
} }
static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd,

View File

@ -548,7 +548,7 @@ static void tcg_out_sh32(TCGContext* s, S390Opcode op, TCGReg dest,
tcg_out_insn_RS(s, op, dest, sh_reg, 0, sh_imm); tcg_out_insn_RS(s, op, dest, sh_reg, 0, sh_imm);
} }
static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg dst, TCGReg src) static bool tcg_out_mov(TCGContext *s, TCGType type, TCGReg dst, TCGReg src)
{ {
if (src != dst) { if (src != dst) {
if (type == TCG_TYPE_I32) { if (type == TCG_TYPE_I32) {
@ -557,6 +557,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg dst, TCGReg src)
tcg_out_insn(s, RRE, LGR, dst, src); tcg_out_insn(s, RRE, LGR, dst, src);
} }
} }
return true;
} }
static const S390Opcode lli_insns[4] = { static const S390Opcode lli_insns[4] = {

View File

@ -407,12 +407,13 @@ static void tcg_out_arithc(TCGContext *s, TCGReg rd, TCGReg 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, static inline bool tcg_out_mov(TCGContext *s, TCGType type,
TCGReg ret, TCGReg arg) TCGReg ret, TCGReg arg)
{ {
if (ret != arg) { if (ret != arg) {
tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR); tcg_out_arith(s, ret, arg, TCG_REG_G0, ARITH_OR);
} }
return true;
} }
static inline void tcg_out_sethi(TCGContext *s, TCGReg ret, uint32_t arg) static inline void tcg_out_sethi(TCGContext *s, TCGReg ret, uint32_t arg)

View File

@ -103,7 +103,7 @@ static const char *target_parse_constraint(TCGArgConstraint *ct,
const char *ct_str, TCGType type); const char *ct_str, TCGType type);
static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1, static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg1,
intptr_t arg2); intptr_t arg2);
static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg); static bool 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,
TCGReg 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,
@ -3367,7 +3367,9 @@ static void tcg_reg_alloc_mov(TCGContext *s, const TCGOp *op)
allocated_regs, preferred_regs, allocated_regs, preferred_regs,
ots->indirect_base); ots->indirect_base);
} }
tcg_out_mov(s, otype, ots->reg, ts->reg); if (!tcg_out_mov(s, otype, ots->reg, ts->reg)) {
abort();
}
} }
ots->val_type = TEMP_VAL_REG; ots->val_type = TEMP_VAL_REG;
ots->mem_coherent = 0; ots->mem_coherent = 0;
@ -3467,7 +3469,9 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
i_allocated_regs, 0); i_allocated_regs, 0);
reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs, reg = tcg_reg_alloc(s, arg_ct->u.regs, i_allocated_regs,
o_preferred_regs, ts->indirect_base); o_preferred_regs, ts->indirect_base);
tcg_out_mov(s, ts->type, reg, ts->reg); if (!tcg_out_mov(s, ts->type, reg, ts->reg)) {
abort();
}
} }
new_args[i] = reg; new_args[i] = reg;
const_args[i] = 0; const_args[i] = 0;
@ -3626,7 +3630,9 @@ static void tcg_reg_alloc_call(TCGContext *s, TCGOp *op)
if (ts->val_type == TEMP_VAL_REG) { if (ts->val_type == TEMP_VAL_REG) {
if (ts->reg != reg) { if (ts->reg != reg) {
tcg_reg_free(s, reg, allocated_regs); tcg_reg_free(s, reg, allocated_regs);
tcg_out_mov(s, ts->type, reg, ts->reg); if (!tcg_out_mov(s, ts->type, reg, ts->reg)) {
abort();
}
} }
} else { } else {
TCGRegSet arg_set = 0; TCGRegSet arg_set = 0;

View File

@ -509,7 +509,7 @@ static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg ret, TCGReg 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, TCGReg ret, TCGReg arg) static bool 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;
tcg_debug_assert(ret != arg); tcg_debug_assert(ret != arg);
@ -521,6 +521,7 @@ static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg)
tcg_out_r(s, ret); tcg_out_r(s, ret);
tcg_out_r(s, arg); tcg_out_r(s, arg);
old_code_ptr[1] = s->code_ptr - old_code_ptr; old_code_ptr[1] = s->code_ptr - old_code_ptr;
return true;
} }
static void tcg_out_movi(TCGContext *s, TCGType type, static void tcg_out_movi(TCGContext *s, TCGType type,