tcg: Merge INDEX_op_deposit_{i32,i64}

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2025-01-12 20:48:57 -08:00
parent a5a8dd33aa
commit 4d137ff819
7 changed files with 16 additions and 20 deletions

View file

@ -442,7 +442,7 @@ Misc
- | Indicate that the value of *t0* won't be used later. It is useful to - | Indicate that the value of *t0* won't be used later. It is useful to
force dead code elimination. force dead code elimination.
* - deposit_i32/i64 *dest*, *t1*, *t2*, *pos*, *len* * - deposit *dest*, *t1*, *t2*, *pos*, *len*
- | Deposit *t2* as a bitfield into *t1*, placing the result in *dest*. - | Deposit *t2* as a bitfield into *t1*, placing the result in *dest*.
| |
@ -451,10 +451,12 @@ Misc
| *len* - the length of the bitfield | *len* - the length of the bitfield
| *pos* - the position of the first bit, counting from the LSB | *pos* - the position of the first bit, counting from the LSB
| |
| For example, "deposit_i32 dest, t1, t2, 8, 4" indicates a 4-bit field | For example, "deposit dest, t1, t2, 8, 4" indicates a 4-bit field
at bit 8. This operation would be equivalent to at bit 8. This operation would be equivalent to
| |
| *dest* = (*t1* & ~0x0f00) | ((*t2* << 8) & 0x0f00) | *dest* = (*t1* & ~0x0f00) | ((*t2* << 8) & 0x0f00)
|
| on TCG_TYPE_I32.
* - extract *dest*, *t1*, *pos*, *len* * - extract *dest*, *t1*, *pos*, *len*

View file

@ -49,6 +49,7 @@ DEF(bswap64, 1, 1, 1, TCG_OPF_INT)
DEF(clz, 1, 2, 0, TCG_OPF_INT) DEF(clz, 1, 2, 0, TCG_OPF_INT)
DEF(ctpop, 1, 1, 0, TCG_OPF_INT) DEF(ctpop, 1, 1, 0, TCG_OPF_INT)
DEF(ctz, 1, 2, 0, TCG_OPF_INT) DEF(ctz, 1, 2, 0, TCG_OPF_INT)
DEF(deposit, 1, 2, 2, TCG_OPF_INT)
DEF(divs, 1, 2, 0, TCG_OPF_INT) DEF(divs, 1, 2, 0, TCG_OPF_INT)
DEF(divs2, 2, 3, 0, TCG_OPF_INT) DEF(divs2, 2, 3, 0, TCG_OPF_INT)
DEF(divu, 1, 2, 0, TCG_OPF_INT) DEF(divu, 1, 2, 0, TCG_OPF_INT)
@ -90,7 +91,6 @@ DEF(st8_i32, 0, 2, 1, 0)
DEF(st16_i32, 0, 2, 1, 0) DEF(st16_i32, 0, 2, 1, 0)
DEF(st_i32, 0, 2, 1, 0) DEF(st_i32, 0, 2, 1, 0)
/* shifts/rotates */ /* shifts/rotates */
DEF(deposit_i32, 1, 2, 2, 0)
DEF(extract2_i32, 1, 2, 1, 0) DEF(extract2_i32, 1, 2, 1, 0)
DEF(add2_i32, 2, 4, 0, 0) DEF(add2_i32, 2, 4, 0, 0)
@ -111,7 +111,6 @@ DEF(st16_i64, 0, 2, 1, 0)
DEF(st32_i64, 0, 2, 1, 0) DEF(st32_i64, 0, 2, 1, 0)
DEF(st_i64, 0, 2, 1, 0) DEF(st_i64, 0, 2, 1, 0)
/* shifts/rotates */ /* shifts/rotates */
DEF(deposit_i64, 1, 2, 2, 0)
DEF(extract2_i64, 1, 2, 1, 0) DEF(extract2_i64, 1, 2, 1, 0)
/* size changing ops */ /* size changing ops */

View file

@ -2858,7 +2858,7 @@ void tcg_optimize(TCGContext *s)
case INDEX_op_ctpop: case INDEX_op_ctpop:
done = fold_ctpop(&ctx, op); done = fold_ctpop(&ctx, op);
break; break;
CASE_OP_32_64(deposit): case INDEX_op_deposit:
done = fold_deposit(&ctx, op); done = fold_deposit(&ctx, op);
break; break;
case INDEX_op_divs: case INDEX_op_divs:

View file

@ -915,7 +915,7 @@ void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2,
return; return;
} }
if (TCG_TARGET_deposit_valid(TCG_TYPE_I32, ofs, len)) { if (TCG_TARGET_deposit_valid(TCG_TYPE_I32, ofs, len)) {
tcg_gen_op5ii_i32(INDEX_op_deposit_i32, ret, arg1, arg2, ofs, len); tcg_gen_op5ii_i32(INDEX_op_deposit, ret, arg1, arg2, ofs, len);
return; return;
} }
@ -961,7 +961,7 @@ void tcg_gen_deposit_z_i32(TCGv_i32 ret, TCGv_i32 arg,
tcg_gen_andi_i32(ret, arg, (1u << len) - 1); tcg_gen_andi_i32(ret, arg, (1u << len) - 1);
} else if (TCG_TARGET_deposit_valid(TCG_TYPE_I32, ofs, len)) { } else if (TCG_TARGET_deposit_valid(TCG_TYPE_I32, ofs, len)) {
TCGv_i32 zero = tcg_constant_i32(0); TCGv_i32 zero = tcg_constant_i32(0);
tcg_gen_op5ii_i32(INDEX_op_deposit_i32, ret, zero, arg, ofs, len); tcg_gen_op5ii_i32(INDEX_op_deposit, ret, zero, arg, ofs, len);
} else { } else {
/* /*
* To help two-operand hosts we prefer to zero-extend first, * To help two-operand hosts we prefer to zero-extend first,
@ -2533,7 +2533,7 @@ void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2,
if (TCG_TARGET_REG_BITS == 64) { if (TCG_TARGET_REG_BITS == 64) {
if (TCG_TARGET_deposit_valid(TCG_TYPE_I64, ofs, len)) { if (TCG_TARGET_deposit_valid(TCG_TYPE_I64, ofs, len)) {
tcg_gen_op5ii_i64(INDEX_op_deposit_i64, ret, arg1, arg2, ofs, len); tcg_gen_op5ii_i64(INDEX_op_deposit, ret, arg1, arg2, ofs, len);
return; return;
} }
} else { } else {
@ -2594,7 +2594,7 @@ void tcg_gen_deposit_z_i64(TCGv_i64 ret, TCGv_i64 arg,
} else if (TCG_TARGET_REG_BITS == 64 && } else if (TCG_TARGET_REG_BITS == 64 &&
TCG_TARGET_deposit_valid(TCG_TYPE_I64, ofs, len)) { TCG_TARGET_deposit_valid(TCG_TYPE_I64, ofs, len)) {
TCGv_i64 zero = tcg_constant_i64(0); TCGv_i64 zero = tcg_constant_i64(0);
tcg_gen_op5ii_i64(INDEX_op_deposit_i64, ret, zero, arg, ofs, len); tcg_gen_op5ii_i64(INDEX_op_deposit, ret, zero, arg, ofs, len);
} else { } else {
if (TCG_TARGET_REG_BITS == 32) { if (TCG_TARGET_REG_BITS == 32) {
if (ofs >= 32) { if (ofs >= 32) {

View file

@ -1133,8 +1133,7 @@ static const TCGOutOp * const all_outop[NB_OPS] = {
OUTOP(INDEX_op_clz, TCGOutOpBinary, outop_clz), OUTOP(INDEX_op_clz, TCGOutOpBinary, outop_clz),
OUTOP(INDEX_op_ctpop, TCGOutOpUnary, outop_ctpop), OUTOP(INDEX_op_ctpop, TCGOutOpUnary, outop_ctpop),
OUTOP(INDEX_op_ctz, TCGOutOpBinary, outop_ctz), OUTOP(INDEX_op_ctz, TCGOutOpBinary, outop_ctz),
OUTOP(INDEX_op_deposit_i32, TCGOutOpDeposit, outop_deposit), OUTOP(INDEX_op_deposit, TCGOutOpDeposit, outop_deposit),
OUTOP(INDEX_op_deposit_i64, TCGOutOpDeposit, outop_deposit),
OUTOP(INDEX_op_divs, TCGOutOpBinary, outop_divs), OUTOP(INDEX_op_divs, TCGOutOpBinary, outop_divs),
OUTOP(INDEX_op_divu, TCGOutOpBinary, outop_divu), OUTOP(INDEX_op_divu, TCGOutOpBinary, outop_divu),
OUTOP(INDEX_op_divs2, TCGOutOpDivRem, outop_divs2), OUTOP(INDEX_op_divs2, TCGOutOpDivRem, outop_divs2),
@ -2379,6 +2378,7 @@ bool tcg_op_supported(TCGOpcode op, TCGType type, unsigned flags)
case INDEX_op_add: case INDEX_op_add:
case INDEX_op_and: case INDEX_op_and:
case INDEX_op_brcond: case INDEX_op_brcond:
case INDEX_op_deposit:
case INDEX_op_extract: case INDEX_op_extract:
case INDEX_op_mov: case INDEX_op_mov:
case INDEX_op_movcond: case INDEX_op_movcond:
@ -2397,7 +2397,6 @@ bool tcg_op_supported(TCGOpcode op, TCGType type, unsigned flags)
case INDEX_op_st8_i32: case INDEX_op_st8_i32:
case INDEX_op_st16_i32: case INDEX_op_st16_i32:
case INDEX_op_st_i32: case INDEX_op_st_i32:
case INDEX_op_deposit_i32:
return true; return true;
case INDEX_op_extract2_i32: case INDEX_op_extract2_i32:
@ -2426,7 +2425,6 @@ bool tcg_op_supported(TCGOpcode op, TCGType type, unsigned flags)
case INDEX_op_extu_i32_i64: case INDEX_op_extu_i32_i64:
case INDEX_op_extrl_i64_i32: case INDEX_op_extrl_i64_i32:
case INDEX_op_extrh_i64_i32: case INDEX_op_extrh_i64_i32:
case INDEX_op_deposit_i64:
return TCG_TARGET_REG_BITS == 64; return TCG_TARGET_REG_BITS == 64;
case INDEX_op_extract2_i64: case INDEX_op_extract2_i64:
@ -5549,8 +5547,7 @@ static void tcg_reg_alloc_op(TCGContext *s, const TCGOp *op)
} }
break; break;
case INDEX_op_deposit_i32: case INDEX_op_deposit:
case INDEX_op_deposit_i64:
{ {
const TCGOutOpDeposit *out = &outop_deposit; const TCGOutOpDeposit *out = &outop_deposit;

View file

@ -655,8 +655,7 @@ uintptr_t QEMU_DISABLE_CFI tcg_qemu_tb_exec(CPUArchState *env,
tci_args_rrr(insn, &r0, &r1, &r2); tci_args_rrr(insn, &r0, &r1, &r2);
regs[r0] = ror32(regs[r1], regs[r2] & 31); regs[r0] = ror32(regs[r1], regs[r2] & 31);
break; break;
case INDEX_op_deposit_i32: case INDEX_op_deposit:
case INDEX_op_deposit_i64:
tci_args_rrrbb(insn, &r0, &r1, &r2, &pos, &len); tci_args_rrrbb(insn, &r0, &r1, &r2, &pos, &len);
regs[r0] = deposit_tr(regs[r1], pos, len, regs[r2]); regs[r0] = deposit_tr(regs[r1], pos, len, regs[r2]);
break; break;
@ -1042,8 +1041,7 @@ int print_insn_tci(bfd_vma addr, disassemble_info *info)
op_name, str_r(r0), str_r(r1), str_r(r2)); op_name, str_r(r0), str_r(r1), str_r(r2));
break; break;
case INDEX_op_deposit_i32: case INDEX_op_deposit:
case INDEX_op_deposit_i64:
tci_args_rrrbb(insn, &r0, &r1, &r2, &pos, &len); tci_args_rrrbb(insn, &r0, &r1, &r2, &pos, &len);
info->fprintf_func(info->stream, "%-12s %s, %s, %s, %d, %d", info->fprintf_func(info->stream, "%-12s %s, %s, %s, %d, %d",
op_name, str_r(r0), str_r(r1), str_r(r2), pos, len); op_name, str_r(r0), str_r(r1), str_r(r2), pos, len);

View file

@ -622,7 +622,7 @@ static const TCGOutOpBinary outop_ctz = {
static void tgen_deposit(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1, static void tgen_deposit(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1,
TCGReg a2, unsigned ofs, unsigned len) TCGReg a2, unsigned ofs, unsigned len)
{ {
tcg_out_op_rrrbb(s, INDEX_op_deposit_i64, a0, a1, a2, ofs, len); tcg_out_op_rrrbb(s, INDEX_op_deposit, a0, a1, a2, ofs, len);
} }
static const TCGOutOpDeposit outop_deposit = { static const TCGOutOpDeposit outop_deposit = {