@samitouri / QOSamiQemu / commits / fa70120a71

tcg/loongarch64: Implement revbit{8,32,64}

Reviewed-by: Anton Johansson <anjo@rev.ng> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Richard Henderson committed Jul 30, 2026 at 23:52 UTC fa70120a71e51358523a1c1d6321a884def054af
1 file changed +31 -3
tcg/loongarch64/tcg-target.c.inc
+31 -3
@@ -1866,16 +1866,44 @@ static const TCGOutOpUnary outop_bswap64 = {
1866 .out_rr = tgen_bswap64,
1867 };
1868
1869 +static void tgen_revbit8(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1)
1870 +{
1871 + if (type == TCG_TYPE_I32) {
1872 + tcg_out_opc_revbit_4b(s, a0, a1);
1873 + } else {
1874 + tcg_out_opc_revbit_8b(s, a0, a1);
1875 + }
1876 +}
1877 +
1878 static const TCGOutOpUnary outop_revbit8 = {
1870 - .base.static_constraint = C_NotImplemented,
1879 + .base.static_constraint = C_O1_I1(r, r),
1880 + .out_rr = tgen_revbit8;
1881 };
1882
1883 +static void tgen_revbit32(TCGContext *s, TCGType type,
1884 + TCGReg a0, TCGReg a1, unsigned flags)
1885 +{
1886 + tcg_out_opc_revbit_w(s, a0, a1);
1887 +
1888 + /* All 32-bit values are computed sign-extended in the register. */
1889 + if (type == TCG_TYPE_I64 && (flags & TCG_BSWAP_OZ)) {
1890 + tcg_out_ext32u(s, a0, a0);
1891 + }
1892 +}
1893 +
1894 static const TCGOutOpBswap outop_revbit32 = {
1874 - .base.static_constraint = C_NotImplemented,
1895 + .base.static_constraint = C_O1_I1(r, r),
1896 + .out_rr = tgen_revbit32,
1897 };
1898
1899 +static void tgen_revbit64(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1)
1900 +{
1901 + tcg_out_opc_revbit_d(s, a0, a1);
1902 +}
1903 +
1904 static const TCGOutOpUnary outop_revbit64 = {
1878 - .base.static_constraint = C_NotImplemented,
1905 + .base.static_constraint = C_O1_I1(r, r),
1906 + .out_rr = tgen_revbit64,
1907 };
1908
1909 static void tgen_neg(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1)