qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-8.0 v3 14/45] tcg: Introduce tcg_type_size


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH for-8.0 v3 14/45] tcg: Introduce tcg_type_size
Date: Tue, 22 Nov 2022 19:14:00 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.5.0

On 22/11/22 17:54, Richard Henderson wrote:
On 11/22/22 03:30, Philippe Mathieu-Daudé wrote:
On 11/11/22 08:40, Richard Henderson wrote:
Add a helper function for computing the size of a type.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
  include/tcg/tcg.h | 16 ++++++++++++++++
  tcg/tcg.c         | 26 ++++++++++++--------------
  2 files changed, 28 insertions(+), 14 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
@@ -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;

I'd feel safer if we assign TCG_TYPE_I32 .. TCG_TYPE_V256 in TCGType,
just in case.

What do you mean?

-- >8 --
diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
@@ -289,8 +289,8 @@ typedef struct TCGPool {
 typedef enum TCGType {
-    TCG_TYPE_I32,
-    TCG_TYPE_I64,
+    TCG_TYPE_I32  = 0,
+    TCG_TYPE_I64  = 1,

-    TCG_TYPE_V64,
-    TCG_TYPE_V128,
-    TCG_TYPE_V256,
+    TCG_TYPE_V64  = 2,
+    TCG_TYPE_V128 = 3,
+    TCG_TYPE_V256 = 4,

---



reply via email to

[Prev in Thread] Current Thread [Next in Thread]