[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 27/43] tcg: Introduce tcg_type_size
From: |
Richard Henderson |
Subject: |
[PATCH v5 27/43] tcg: Introduce tcg_type_size |
Date: |
Sat, 24 Dec 2022 15:57:04 -0800 |
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>
---
include/tcg/tcg.h | 16 ++++++++++++++++
tcg/tcg.c | 27 ++++++++++++---------------
2 files changed, 28 insertions(+), 15 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;
+}
+
/**
* get_alignment_bits
* @memop: MemOp value
diff --git a/tcg/tcg.c b/tcg/tcg.c
index dbf4e864eb..12676268a2 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -3038,22 +3038,22 @@ static bool liveness_pass_2(TCGContext *s)
static void temp_allocate_frame(TCGContext *s, TCGTemp *ts)
{
- intptr_t off, size, align;
+ int size = tcg_type_size(ts->type);
+ int align;
+ intptr_t off;
switch (ts->type) {
case TCG_TYPE_I32:
- size = align = 4;
+ align = 4;
break;
case TCG_TYPE_I64:
case TCG_TYPE_V64:
- size = align = 8;
+ align = 8;
break;
case TCG_TYPE_V128:
- size = align = 16;
- break;
case TCG_TYPE_V256:
/* Note that we do not require aligned storage for V256. */
- size = 32, align = 16;
+ align = 16;
break;
default:
g_assert_not_reached();
@@ -3593,8 +3593,8 @@ static void tcg_reg_alloc_dup(TCGContext *s, const TCGOp
*op)
TCGRegSet dup_out_regs, dup_in_regs;
TCGTemp *its, *ots;
TCGType itype, vtype;
- intptr_t endian_fixup;
unsigned vece;
+ int lowpart_ofs;
bool ok;
ots = arg_temp(op->args[0]);
@@ -3662,15 +3662,12 @@ static void tcg_reg_alloc_dup(TCGContext *s, const
TCGOp *op)
/* fall through */
case TEMP_VAL_MEM:
-#if HOST_BIG_ENDIAN
- endian_fixup = itype == TCG_TYPE_I32 ? 4 : 8;
- endian_fixup -= 1 << vece;
-#else
- endian_fixup = 0;
-#endif
- /* Attempt to dup directly from the input memory slot. */
+ lowpart_ofs = 0;
+ if (HOST_BIG_ENDIAN) {
+ lowpart_ofs = tcg_type_size(itype) - (1 << vece);
+ }
if (tcg_out_dupm_vec(s, vtype, vece, ots->reg, its->mem_base->reg,
- its->mem_offset + endian_fixup)) {
+ its->mem_offset + lowpart_ofs)) {
goto done;
}
/* Load the input into the destination vector register. */
--
2.34.1
- [PATCH v5 30/43] tcg: Replace TCG_TARGET_EXTEND_ARGS with TCG_TARGET_CALL_ARG_I32, (continued)
- [PATCH v5 30/43] tcg: Replace TCG_TARGET_EXTEND_ARGS with TCG_TARGET_CALL_ARG_I32, Richard Henderson, 2022/12/24
- [PATCH v5 22/43] tcg: Move TCG_{LOW,HIGH} to tcg-internal.h, Richard Henderson, 2022/12/24
- [PATCH v5 24/43] tcg: Simplify calls to temp_sync vs mem_coherent, Richard Henderson, 2022/12/24
- [PATCH v5 37/43] tcg: Use output_pref wrapper function, Richard Henderson, 2022/12/24
- [PATCH v5 26/43] tcg: Move TCG_TYPE_COUNT outside enum, Richard Henderson, 2022/12/24
- [PATCH v5 35/43] tcg: Pass number of arguments to tcg_emit_op() / tcg_op_insert_*(), Richard Henderson, 2022/12/24
- [PATCH v5 25/43] tcg: Allocate TCGTemp pairs in host memory order, Richard Henderson, 2022/12/24
- [PATCH v5 34/43] accel/tcg/plugin: Use copy_op in append_{udata, mem}_cb, Richard Henderson, 2022/12/24
- [PATCH v5 33/43] accel/tcg/plugin: Avoid duplicate copy in copy_call, Richard Henderson, 2022/12/24
- [PATCH v5 39/43] tcg: Convert typecode_to_ffi from array to function, Richard Henderson, 2022/12/24
- [PATCH v5 27/43] tcg: Introduce tcg_type_size,
Richard Henderson <=
- [PATCH v5 29/43] tcg: Replace TCG_TARGET_CALL_ALIGN_ARGS with TCG_TARGET_CALL_ARG_I64, Richard Henderson, 2022/12/24
- [PATCH v5 32/43] accel/tcg/plugin: Don't search for the function pointer index, Richard Henderson, 2022/12/24
- [PATCH v5 36/43] tcg: Vary the allocation size for TCGOp, Richard Henderson, 2022/12/24
- [PATCH v5 38/43] tcg: Reorg function calls, Richard Henderson, 2022/12/24
- [PATCH v5 19/43] tcg: Introduce paired register allocation, Richard Henderson, 2022/12/24
- [PATCH v5 31/43] tcg: Use TCG_CALL_ARG_EVEN for TCI special case, Richard Henderson, 2022/12/24
- [PATCH v5 40/43] tcg: Factor init_ffi_layouts() out of tcg_context_init(), Richard Henderson, 2022/12/24
- [PATCH v5 42/43] tcg/aarch64: Merge tcg_out_callr into tcg_out_call, Richard Henderson, 2022/12/24
- [PATCH v5 41/43] tcg: Move ffi_cif pointer into TCGHelperInfo, Richard Henderson, 2022/12/24
- [PATCH v5 43/43] tcg: Add TCGHelperInfo argument to tcg_out_call, Richard Henderson, 2022/12/24