@samitouri / QOSamiQemu / commits / 583b84e18f

disas/riscv: Chain "ret" pseudo off "jr" pseudo

"jr" has already checked two conditions that apply to "ret". Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-ID: <20260812223142.349142-31-richard.henderson@linaro.org> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Richard Henderson committed Aug 12, 2026 at 15:31 UTC 583b84e18f4e793aade850315013f60ed8ae2d84
1 file changed +7 -4
disas/riscv.c
+7 -4
@@ -1061,8 +1061,7 @@ static const rvc_constraint rvcc_bgez[] = { rvc_rs2_eq_x0, rvc_end };
1061 static const rvc_constraint rvcc_bltz[] = { rvc_rs2_eq_x0, rvc_end };
1062 static const rvc_constraint rvcc_bgtz[] = { rvc_rs1_eq_x0, rvc_end };
1063 static const rvc_constraint rvcc_j[] = { rvc_rd_eq_x0, rvc_end };
1064 -static const rvc_constraint rvcc_ret[] = { rvc_rd_eq_x0, rvc_rs1_eq_ra,
1065 - rvc_end };
1064 +static const rvc_constraint rvcc_ret[] = { rvc_rs1_eq_ra, rvc_end };
1065 static const rvc_constraint rvcc_jr[] = { rvc_rd_eq_x0, rvc_imm_eq_zero,
1066 rvc_end };
1067 static const rvc_constraint rvcc_true[] = { rvc_end };
@@ -1076,12 +1075,16 @@ static const rv_comp_data rvcp_jal[] = {
1075 };
1076
1077 static const rv_comp_data rvcp_jalr[] = {
1079 - { rv_op_ret, rvcc_ret },
1078 { rv_op_jr, rvcc_jr },
1079 { rv_op_jalr_ra, rvcc_jalr_ra },
1080 { },
1081 };
1082
1083 +static const rv_comp_data rvcp_jr[] = {
1084 + { rv_op_ret, rvcc_ret },
1085 + { },
1086 +};
1087 +
1088 static const rv_comp_data rvcp_beq[] = {
1089 { rv_op_beqz, rvcc_beqz },
1090 { },
@@ -1896,7 +1899,7 @@ static const rv_opcode_data rvi_opcode_data[] = {
1899 { },
1900 { "j", rv_codec_uj, rv_fmt_offset },
1901 { "ret", rv_codec_i, rv_fmt_none },
1899 - { "jr", rv_codec_i, rv_fmt_rs1 },
1902 + { "jr", rv_codec_i, rv_fmt_rs1, rvcp_jr },
1903 { "rdcycle", rv_codec_i_csr, rv_fmt_rd },
1904 { "rdtime", rv_codec_i_csr, rv_fmt_rd },
1905 { "rdinstret", rv_codec_i_csr, rv_fmt_rd },