Commit 43b400e7da for qemu.org

commit 43b400e7da2f632b10066e4abf0db5058a00c4e9
Author: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Date:   Mon Sep 28 13:39:38 2026 +0200

    tcg: Introduce tcg_type_bits() helper

    Add a helper function for computing the width (in bits)
    of a type. Use when appropriate.

    Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
    Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    Message-ID: <20260928113938.3157-1-philmd@oss.qualcomm.com>

diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index 7669dc1c2d..2e00518934 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -164,6 +164,17 @@ static inline int tcg_type_size(TCGType t)
     return 4 << i;
 }

+/**
+ * tcg_type_bits
+ * @t: type
+ *
+ * Return the size of the type in bits.
+ */
+static inline int tcg_type_bits(TCGType t)
+{
+    return 8 * tcg_type_size(t);
+}
+
 typedef tcg_target_ulong TCGArg;

 /* Define type and accessor macros for TCG variables.
diff --git a/tcg/optimize.c b/tcg/optimize.c
index c631f690af..294eb5ed29 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1704,7 +1704,7 @@ static bool fold_deposit(OptContext *ctx, TCGOp *op)
                                           ti_const_val(t2)));
     }

-    width = 8 * tcg_type_size(ctx->type);
+    width = tcg_type_bits(ctx->type);
     type_mask = MAKE_64BIT_MASK(0, width);
     len_mask = MAKE_64BIT_MASK(0, len);

@@ -2279,7 +2279,7 @@ static bool fold_multiply2(OptContext *ctx, TCGOp *op)
                 op->args[0] = rh;
                 op->args[1] = rl;
                 op->args[2] =
-                    arg_new_constant(ctx, tcg_type_size(ctx->type) * 8 - 1);
+                    arg_new_constant(ctx, tcg_type_bits(ctx->type) - 1);
                 return fold_shift(ctx, op);
             default:
                 break;
diff --git a/tcg/tcg.c b/tcg/tcg.c
index ecc1f54c1b..65d3190a8e 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -2883,11 +2883,11 @@ void tcg_dump_ops(TCGContext *s, FILE *f, bool have_prefs)
             if (def->flags & TCG_OPF_INT) {
                 col += ne_fprintf(f, " %s_i%d ",
                                   def->name,
-                                  8 * tcg_type_size(TCGOP_TYPE(op)));
+                                  tcg_type_bits(TCGOP_TYPE(op)));
             } else if (def->flags & TCG_OPF_VECTOR) {
                 col += ne_fprintf(f, "%s v%d,e%d,",
                                   def->name,
-                                  8 * tcg_type_size(TCGOP_TYPE(op)),
+                                  tcg_type_bits(TCGOP_TYPE(op)),
                                   8 << TCGOP_VECE(op));
             } else {
                 col += ne_fprintf(f, " %s ", def->name);