diff options
author | Richard Henderson <richard.henderson@linaro.org> | 2022-10-19 12:41:15 +1000 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2023-01-05 11:41:28 -0800 |
commit | 31c96417465b0ff32d6ec1ee8ef271c6e49ab5a3 (patch) | |
tree | 170042c046b3b6146ef8d13dfcb6cb48c55e11f1 /include/tcg | |
parent | 89496a85b4696b797e904a65a10b0600a95a12ec (diff) |
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>
Diffstat (limited to 'include/tcg')
-rw-r--r-- | include/tcg/tcg.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index f2da340bb9..8bcd60d0ed 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -320,6 +320,22 @@ typedef enum TCGType { } 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 * |