[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 17/31] tcg: Use TCG_CALL_ARG_EVEN for TCI special case
From: |
Richard Henderson |
Subject: |
[PATCH 17/31] tcg: Use TCG_CALL_ARG_EVEN for TCI special case |
Date: |
Thu, 20 Oct 2022 21:52:28 +1000 |
Change 32-bit tci TCG_TARGET_CALL_ARG_I32 to TCG_CALL_ARG_EVEN, to
force 32-bit values to be aligned to 64-bit. With a small reorg
to the argument processing loop, this neatly replaces an ifdef for
CONFIG_TCG_INTERPRETER.
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/tci/tcg-target.h | 3 ++-
tcg/tcg.c | 62 ++++++++++++++++++++++++++------------------
2 files changed, 39 insertions(+), 26 deletions(-)
diff --git a/tcg/tci/tcg-target.h b/tcg/tci/tcg-target.h
index d6e0450ed8..94ec541b4e 100644
--- a/tcg/tci/tcg-target.h
+++ b/tcg/tci/tcg-target.h
@@ -158,10 +158,11 @@ typedef enum {
/* Used for function call generation. */
#define TCG_TARGET_CALL_STACK_OFFSET 0
#define TCG_TARGET_STACK_ALIGN 8
-#define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL
#if TCG_TARGET_REG_BITS == 32
+# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_EVEN
# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_EVEN
#else
+# define TCG_TARGET_CALL_ARG_I32 TCG_CALL_ARG_NORMAL
# define TCG_TARGET_CALL_ARG_I64 TCG_CALL_ARG_NORMAL
#endif
diff --git a/tcg/tcg.c b/tcg/tcg.c
index b83bb23281..5704373d57 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -1532,36 +1532,48 @@ void tcg_gen_callN(void *func, TCGTemp *ret, int nargs,
TCGTemp **args)
real_args = 0;
for (i = 0; i < nargs; i++) {
int argtype = extract32(typemask, (i + 1) * 3, 3);
- bool is_64bit = (argtype & ~1) == dh_typecode_i64;
- bool want_align = false;
+ TCGCallArgumentKind kind;
+ TCGType type;
-#if defined(CONFIG_TCG_INTERPRETER)
- /*
- * Align all arguments, so that they land in predictable places
- * for passing off to ffi_call.
- */
- want_align = true;
-#else
- /* Some targets want aligned 64 bit args */
- if (is_64bit) {
- want_align = TCG_TARGET_CALL_ARG_I64 == TCG_CALL_ARG_EVEN;
- }
-#endif
-
- if (TCG_TARGET_REG_BITS < 64 && want_align && (real_args & 1)) {
- op->args[pi++] = TCG_CALL_DUMMY_ARG;
- real_args++;
+ switch (argtype) {
+ case dh_typecode_i32:
+ case dh_typecode_s32:
+ type = TCG_TYPE_I32;
+ kind = TCG_TARGET_CALL_ARG_I32;
+ break;
+ case dh_typecode_i64:
+ case dh_typecode_s64:
+ type = TCG_TYPE_I64;
+ kind = TCG_TARGET_CALL_ARG_I64;
+ break;
+ case dh_typecode_ptr:
+ type = TCG_TYPE_PTR;
+ kind = TCG_CALL_ARG_NORMAL;
+ break;
+ default:
+ g_assert_not_reached();
}
- if (TCG_TARGET_REG_BITS < 64 && is_64bit) {
+ switch (kind) {
+ case TCG_CALL_ARG_EVEN:
+ if (real_args & 1) {
+ op->args[pi++] = TCG_CALL_DUMMY_ARG;
+ real_args++;
+ }
+ /* fall through */
+ case TCG_CALL_ARG_NORMAL:
+ if (TCG_TARGET_REG_BITS == 32 && type == TCG_TYPE_I64) {
+ op->args[pi++] = temp_arg(args[i]);
+ op->args[pi++] = temp_arg(args[i] + 1);
+ real_args += 2;
+ break;
+ }
op->args[pi++] = temp_arg(args[i]);
- op->args[pi++] = temp_arg(args[i] + 1);
- real_args += 2;
- continue;
+ real_args++;
+ break;
+ default:
+ g_assert_not_reached();
}
-
- op->args[pi++] = temp_arg(args[i]);
- real_args++;
}
op->args[pi++] = (uintptr_t)func;
op->args[pi++] = (uintptr_t)info;
--
2.34.1
- [PATCH 25/31] tcg: Add TCG_CALL_{RET,ARG}_BY_REF, (continued)
- [PATCH 25/31] tcg: Add TCG_CALL_{RET,ARG}_BY_REF, Richard Henderson, 2022/10/20
- [PATCH 01/31] tcg: Tidy tcg_reg_alloc_op, Richard Henderson, 2022/10/20
- [PATCH 21/31] tcg: Define TCG_TYPE_I128 and related helper macros, Richard Henderson, 2022/10/20
- [PATCH 02/31] tcg: Introduce paired register allocation, Richard Henderson, 2022/10/20
- [PATCH 19/31] tcg: Move ffi_cif pointer into TCGHelperInfo, Richard Henderson, 2022/10/20
- [PATCH 23/31] tcg: Allocate objects contiguously in temp_allocate_frame, Richard Henderson, 2022/10/20
- [PATCH 18/31] tcg: Reorg function calls, Richard Henderson, 2022/10/20
- [PATCH 27/31] tcg: Add TCG_CALL_RET_BY_VEC, Richard Henderson, 2022/10/20
- [PATCH 24/31] tcg: Introduce tcg_out_addi_ptr, Richard Henderson, 2022/10/20
- [PATCH 31/31] tcg: Add tcg_gen_extr_i128_i64, tcg_gen_concat_i64_i128, Richard Henderson, 2022/10/20
- [PATCH 17/31] tcg: Use TCG_CALL_ARG_EVEN for TCI special case,
Richard Henderson <=
- [PATCH 22/31] tcg: Add TCG_CALL_{RET,ARG}_NORMAL_4, Richard Henderson, 2022/10/20
- [PATCH 30/31] tcg: Add temp allocation for TCGv_i128, Richard Henderson, 2022/10/20
- [PATCH 03/31] tcg/s390x: Use register pair allocation for div and mulu2, Richard Henderson, 2022/10/20
- [PATCH 08/31] target/sparc: Avoid TCGV_{LOW,HIGH}, Richard Henderson, 2022/10/20
- [PATCH 28/31] include/qemu/int128: Use Int128 structure for TCI, Richard Henderson, 2022/10/20
- [PATCH 06/31] tcg: Remove TCG_TARGET_STACK_GROWSUP, Richard Henderson, 2022/10/20
- [PATCH 05/31] meson: Move CONFIG_TCG_INTERPRETER to config_host, Richard Henderson, 2022/10/20
- [PATCH 13/31] tcg: Introduce tcg_type_size, Richard Henderson, 2022/10/20