tcg: Introduce tcg_type_bits() helper
PATCH 1/1 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é <[email protected]>
--- include/tcg/tcg.h | 11 +++++++++++ tcg/optimize.c | 4 ++-- tcg/tcg.c | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-)
include/tcg/tcg.h +11 -0
@@ -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.
tcg/optimize.c +2 -2
@@ -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 ;
tcg/tcg.c +2 -2
@@ -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);
Signature · 1 line
2.53.0
Quoted 9 lines · Philippe Mathieu-Daudé
Add a helper function for computing the width (in bits) of a type. Use when appropriate.
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/tcg/tcg.h | 11 +++++++++++ tcg/optimize.c | 4 ++-- tcg/tcg.c | 4 ++-- 3 files changed, 15 insertions(+), 4 deletions(-)
Thanks, queued to tcg-next.
r~