tcg: Introduce tcg_type_size

Add a helper function for computing the size of a type.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Richard Henderson 2022-10-19 12:41:15 +10:00
parent 89496a85b4
commit 31c9641746
2 changed files with 28 additions and 15 deletions

View file

@ -319,6 +319,22 @@ typedef enum TCGType {
#endif
} TCGType;
/**
* tcg_type_size
* @t: type
*
* Return the size of the type in bytes.
*/
static inline int tcg_type_size(TCGType t)
{
unsigned i = t;
if (i >= TCG_TYPE_V64) {
tcg_debug_assert(i < TCG_TYPE_COUNT);
i -= TCG_TYPE_V64 - 1;
}
return 4 << i;
}
/**
* get_alignment_bits
* @memop: MemOp value