target/arm: Convert disas_add_sub_reg to decodetree

This includes ADD, SUB, ADDS, SUBS (shifted register).

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20241211163036.2297116-14-richard.henderson@linaro.org
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Richard Henderson 2024-12-11 10:29:40 -06:00 committed by Peter Maydell
parent 7e16f3c3d4
commit bde86f2868
2 changed files with 27 additions and 46 deletions

View File

@ -726,6 +726,15 @@ EOR_r . 10 01010 .. . ..... ...... ..... ..... @logic_shift
ANDS_r . 11 01010 .. . ..... ...... ..... ..... @logic_shift ANDS_r . 11 01010 .. . ..... ...... ..... ..... @logic_shift
# Add/subtract (shifted reg) # Add/subtract (shifted reg)
&addsub_shift rd rn rm sf sa st
@addsub_shift sf:1 .. ..... st:2 . rm:5 sa:6 rn:5 rd:5 &addsub_shift
ADD_r . 00 01011 .. 0 ..... ...... ..... ..... @addsub_shift
SUB_r . 10 01011 .. 0 ..... ...... ..... ..... @addsub_shift
ADDS_r . 01 01011 .. 0 ..... ...... ..... ..... @addsub_shift
SUBS_r . 11 01011 .. 0 ..... ...... ..... ..... @addsub_shift
# Add/subtract (extended reg) # Add/subtract (extended reg)
&addsub_ext rd rn rm sf sa st &addsub_ext rd rn rm sf sa st

View File

@ -7912,47 +7912,22 @@ TRANS(SUB_ext, do_addsub_ext, a, true, false)
TRANS(ADDS_ext, do_addsub_ext, a, false, true) TRANS(ADDS_ext, do_addsub_ext, a, false, true)
TRANS(SUBS_ext, do_addsub_ext, a, true, true) TRANS(SUBS_ext, do_addsub_ext, a, true, true)
/* static bool do_addsub_reg(DisasContext *s, arg_addsub_shift *a,
* Add/subtract (shifted register) bool sub_op, bool setflags)
*
* 31 30 29 28 24 23 22 21 20 16 15 10 9 5 4 0
* +--+--+--+-----------+-----+--+-------+---------+------+------+
* |sf|op| S| 0 1 0 1 1 |shift| 0| Rm | imm6 | Rn | Rd |
* +--+--+--+-----------+-----+--+-------+---------+------+------+
*
* sf: 0 -> 32bit, 1 -> 64bit
* op: 0 -> add , 1 -> sub
* S: 1 -> set flags
* shift: 00 -> LSL, 01 -> LSR, 10 -> ASR, 11 -> RESERVED
* imm6: Shift amount to apply to Rm before the add/sub
*/
static void disas_add_sub_reg(DisasContext *s, uint32_t insn)
{ {
int rd = extract32(insn, 0, 5); TCGv_i64 tcg_rd, tcg_rn, tcg_rm, tcg_result;
int rn = extract32(insn, 5, 5);
int imm6 = extract32(insn, 10, 6);
int rm = extract32(insn, 16, 5);
int shift_type = extract32(insn, 22, 2);
bool setflags = extract32(insn, 29, 1);
bool sub_op = extract32(insn, 30, 1);
bool sf = extract32(insn, 31, 1);
TCGv_i64 tcg_rd = cpu_reg(s, rd); if (a->st == 3 || (!a->sf && (a->sa & 32))) {
TCGv_i64 tcg_rn, tcg_rm; return false;
TCGv_i64 tcg_result;
if ((shift_type == 3) || (!sf && (imm6 > 31))) {
unallocated_encoding(s);
return;
} }
tcg_rn = read_cpu_reg(s, rn, sf); tcg_rd = cpu_reg(s, a->rd);
tcg_rm = read_cpu_reg(s, rm, sf); tcg_rn = read_cpu_reg(s, a->rn, a->sf);
tcg_rm = read_cpu_reg(s, a->rm, a->sf);
shift_reg_imm(tcg_rm, tcg_rm, sf, shift_type, imm6); shift_reg_imm(tcg_rm, tcg_rm, a->sf, a->st, a->sa);
tcg_result = tcg_temp_new_i64(); tcg_result = tcg_temp_new_i64();
if (!setflags) { if (!setflags) {
if (sub_op) { if (sub_op) {
tcg_gen_sub_i64(tcg_result, tcg_rn, tcg_rm); tcg_gen_sub_i64(tcg_result, tcg_rn, tcg_rm);
@ -7961,19 +7936,25 @@ static void disas_add_sub_reg(DisasContext *s, uint32_t insn)
} }
} else { } else {
if (sub_op) { if (sub_op) {
gen_sub_CC(sf, tcg_result, tcg_rn, tcg_rm); gen_sub_CC(a->sf, tcg_result, tcg_rn, tcg_rm);
} else { } else {
gen_add_CC(sf, tcg_result, tcg_rn, tcg_rm); gen_add_CC(a->sf, tcg_result, tcg_rn, tcg_rm);
} }
} }
if (sf) { if (a->sf) {
tcg_gen_mov_i64(tcg_rd, tcg_result); tcg_gen_mov_i64(tcg_rd, tcg_result);
} else { } else {
tcg_gen_ext32u_i64(tcg_rd, tcg_result); tcg_gen_ext32u_i64(tcg_rd, tcg_result);
} }
return true;
} }
TRANS(ADD_r, do_addsub_reg, a, false, false)
TRANS(SUB_r, do_addsub_reg, a, true, false)
TRANS(ADDS_r, do_addsub_reg, a, false, true)
TRANS(SUBS_r, do_addsub_reg, a, true, true)
/* Data-processing (3 source) /* Data-processing (3 source)
* *
* 31 30 29 28 24 23 21 20 16 15 14 10 9 5 4 0 * 31 30 29 28 24 23 21 20 16 15 14 10 9 5 4 0
@ -8348,15 +8329,6 @@ static void disas_data_proc_reg(DisasContext *s, uint32_t insn)
int op3 = extract32(insn, 10, 6); int op3 = extract32(insn, 10, 6);
if (!op1) { if (!op1) {
if (op2 & 8) {
if (op2 & 1) {
goto do_unallocated;
} else {
/* Add/sub (shifted register) */
disas_add_sub_reg(s, insn);
}
return;
}
goto do_unallocated; goto do_unallocated;
} }