Commit fa70120a71 for qemu.org
commit fa70120a71e51358523a1c1d6321a884def054af
Author: Richard Henderson <richard.henderson@linaro.org>
Date: Thu Jul 30 23:52:07 2026 +0000
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>
diff --git a/tcg/loongarch64/tcg-target.c.inc b/tcg/loongarch64/tcg-target.c.inc
index 97ed51d99c..7d89e80886 100644
--- a/tcg/loongarch64/tcg-target.c.inc
+++ b/tcg/loongarch64/tcg-target.c.inc
@@ -1866,16 +1866,44 @@ static const TCGOutOpUnary outop_bswap64 = {
.out_rr = tgen_bswap64,
};
+static void tgen_revbit8(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1)
+{
+ if (type == TCG_TYPE_I32) {
+ tcg_out_opc_revbit_4b(s, a0, a1);
+ } else {
+ tcg_out_opc_revbit_8b(s, a0, a1);
+ }
+}
+
static const TCGOutOpUnary outop_revbit8 = {
- .base.static_constraint = C_NotImplemented,
+ .base.static_constraint = C_O1_I1(r, r),
+ .out_rr = tgen_revbit8;
};
+static void tgen_revbit32(TCGContext *s, TCGType type,
+ TCGReg a0, TCGReg a1, unsigned flags)
+{
+ tcg_out_opc_revbit_w(s, a0, a1);
+
+ /* All 32-bit values are computed sign-extended in the register. */
+ if (type == TCG_TYPE_I64 && (flags & TCG_BSWAP_OZ)) {
+ tcg_out_ext32u(s, a0, a0);
+ }
+}
+
static const TCGOutOpBswap outop_revbit32 = {
- .base.static_constraint = C_NotImplemented,
+ .base.static_constraint = C_O1_I1(r, r),
+ .out_rr = tgen_revbit32,
};
+static void tgen_revbit64(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1)
+{
+ tcg_out_opc_revbit_d(s, a0, a1);
+}
+
static const TCGOutOpUnary outop_revbit64 = {
- .base.static_constraint = C_NotImplemented,
+ .base.static_constraint = C_O1_I1(r, r),
+ .out_rr = tgen_revbit64,
};
static void tgen_neg(TCGContext *s, TCGType type, TCGReg a0, TCGReg a1)