diff mbox series

[01/73] tcg: Add TCGOp.type

Message ID 20250102180654.1420056-2-richard.henderson@linaro.org
State New
Headers show
Series tcg: Merge *_i32 and *_i64 opcodes | expand

Commit Message

Richard Henderson Jan. 2, 2025, 6:05 p.m. UTC
Steal 3 bits from nargs to add type without expanding
the size of the structure.  Move the build-time asserts
to the top of tcg.c, so that MAX_CALL_IARGS is in scope
without exporting that detail in the main tcg.h header.

So far, the type field is unused and memset initialized to 0.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 include/tcg/tcg.h | 6 ++----
 tcg/tcg.c         | 9 +++++++++
 2 files changed, 11 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h
index a77ed12b9d..f2ffb69c0c 100644
--- a/include/tcg/tcg.h
+++ b/include/tcg/tcg.h
@@ -417,7 +417,8 @@  typedef uint32_t TCGLifeData;
 
 struct TCGOp {
     TCGOpcode opc   : 8;
-    unsigned nargs  : 8;
+    TCGType type    : 3;
+    unsigned nargs  : 5;
 
     /* Parameters for this opcode.  See below.  */
     unsigned param1 : 8;
@@ -442,9 +443,6 @@  struct TCGOp {
 #define TCGOP_VECL(X)     (X)->param1
 #define TCGOP_VECE(X)     (X)->param2
 
-/* Make sure operands fit in the bitfields above.  */
-QEMU_BUILD_BUG_ON(NB_OPS > (1 << 8));
-
 static inline TCGRegSet output_pref(const TCGOp *op, unsigned i)
 {
     return i < ARRAY_SIZE(op->output_pref) ? op->output_pref[i] : 0;
diff --git a/tcg/tcg.c b/tcg/tcg.c
index 4578b185be..f8c4394e1d 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -60,6 +60,15 @@ 
 #include "user/guest-base.h"
 #endif
 
+/*
+ * Make sure operands fit in the TCGOp bitfields.
+ * For TCGOp.nargs, maximum physical arguments are constrained by
+ * MAX_CALL_IARGS * TCG_TYPE_I128 on 32-bit hosts, so 128 / 32.
+ */
+QEMU_BUILD_BUG_ON(NB_OPS > (1 << 8));
+QEMU_BUILD_BUG_ON(TCG_TYPE_COUNT > (1 << 3));
+QEMU_BUILD_BUG_ON(MAX_CALL_IARGS * (128 / 32) > (1 << 5));
+
 /* Forward declarations for functions declared in tcg-target.c.inc and
    used here. */
 static void tcg_target_init(TCGContext *s);