@samitouri / QOSamiQemu / commits / 9ad7cc1386

target/arm: Implement CB (immediate)

Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260518174750.660258-4-richard.henderson@linaro.org Reviewed-by: Peter Maydell <peter.maydell@linaro.org> [PMM: var decl at top of function; add comment] Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Richard Henderson committed May 18, 2026 at 10:47 UTC 9ad7cc13862645992a10fdc65583284d7bd2f773
2 files changed +45
target/arm/tcg/a64.decode
+2
@@ -217,6 +217,8 @@ CB_cond 1 1110100 ... ..... 00 ......... ..... @cb esz=3
217 CB_cond 0 1110100 ... ..... 10 ......... ..... @cb esz=0 # CBB
218 CB_cond 0 1110100 ... ..... 11 ......... ..... @cb esz=1 # CBH
219
220 +CB_cond_imm sf:1 1110101 cc:3 imm6:6 0 ......... rt:5 %imm9
221 +
222 BR 1101011 0000 11111 000000 rn:5 00000 &r
223 BLR 1101011 0001 11111 000000 rn:5 00000 &r
224 RET 1101011 0010 11111 000000 rn:5 00000 &r
target/arm/tcg/translate-a64.c
+43
@@ -1817,6 +1817,49 @@ static bool trans_CB_cond(DisasContext *s, arg_CB_cond *a)
1817 return true;
1818 }
1819
1820 +static bool trans_CB_cond_imm(DisasContext *s, arg_CB_cond_imm *a)
1821 +{
1822 + /* Note that CB imm and CB encode the condition differently */
1823 + static const TCGCond cb_cond[8] = {
1824 + [0] = TCG_COND_GT,
1825 + [1] = TCG_COND_LT,
1826 + [2] = TCG_COND_GTU,
1827 + [3] = TCG_COND_LTU,
1828 + [4] = TCG_COND_NEVER, /* reserved */
1829 + [5] = TCG_COND_NEVER, /* reserved */
1830 + [6] = TCG_COND_EQ,
1831 + [7] = TCG_COND_NE,
1832 + };
1833 + TCGCond cond = cb_cond[a->cc];
1834 + TCGv_i64 t;
1835 + DisasLabel match;
1836 +
1837 + if (!dc_isar_feature(aa64_cmpbr, s) || cond == TCG_COND_NEVER) {
1838 + return false;
1839 + }
1840 +
1841 + t = cpu_reg(s, a->rt);
1842 + if (!a->sf) {
1843 + TCGv_i64 tt = tcg_temp_new_i64();
1844 +
1845 + if (is_signed_cond(cond)) {
1846 + tcg_gen_ext32s_i64(tt, t);
1847 + } else {
1848 + tcg_gen_ext32u_i64(tt, t);
1849 + }
1850 + t = tt;
1851 + }
1852 +
1853 + reset_btype(s);
1854 + match = gen_disas_label(s);
1855 +
1856 + tcg_gen_brcondi_i64(cond, t, a->imm6, match.label);
1857 + gen_goto_tb(s, 0, 4);
1858 + set_disas_label(s, match);
1859 + gen_goto_tb(s, 1, a->imm9);
1860 + return true;
1861 +}
1862 +
1863 static void set_btype_for_br(DisasContext *s, int rn)
1864 {
1865 if (dc_isar_feature(aa64_bti, s)) {