[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/40] tcg: Allocate objects contiguously in temp_allocate_frame
From: |
Richard Henderson |
Subject: |
[PULL 05/40] tcg: Allocate objects contiguously in temp_allocate_frame |
Date: |
Sat, 4 Feb 2023 06:32:35 -1000 |
When allocating a temp to the stack frame, consider the
base type and allocate all parts at once.
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
tcg/tcg.c | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/tcg/tcg.c b/tcg/tcg.c
index bc7198e5d0..cdfc50b164 100644
--- a/tcg/tcg.c
+++ b/tcg/tcg.c
@@ -3267,11 +3267,12 @@ static bool liveness_pass_2(TCGContext *s)
static void temp_allocate_frame(TCGContext *s, TCGTemp *ts)
{
- int size = tcg_type_size(ts->type);
- int align;
intptr_t off;
+ int size, align;
- switch (ts->type) {
+ /* When allocating an object, look at the full type. */
+ size = tcg_type_size(ts->base_type);
+ switch (ts->base_type) {
case TCG_TYPE_I32:
align = 4;
break;
@@ -3302,13 +3303,30 @@ static void temp_allocate_frame(TCGContext *s, TCGTemp
*ts)
tcg_raise_tb_overflow(s);
}
s->current_frame_offset = off + size;
-
- ts->mem_offset = off;
#if defined(__sparc__)
- ts->mem_offset += TCG_TARGET_STACK_BIAS;
+ off += TCG_TARGET_STACK_BIAS;
#endif
- ts->mem_base = s->frame_temp;
- ts->mem_allocated = 1;
+
+ /* If the object was subdivided, assign memory to all the parts. */
+ if (ts->base_type != ts->type) {
+ int part_size = tcg_type_size(ts->type);
+ int part_count = size / part_size;
+
+ /*
+ * Each part is allocated sequentially in tcg_temp_new_internal.
+ * Jump back to the first part by subtracting the current index.
+ */
+ ts -= ts->temp_subindex;
+ for (int i = 0; i < part_count; ++i) {
+ ts[i].mem_offset = off + i * part_size;
+ ts[i].mem_base = s->frame_temp;
+ ts[i].mem_allocated = 1;
+ }
+ } else {
+ ts->mem_offset = off;
+ ts->mem_base = s->frame_temp;
+ ts->mem_allocated = 1;
+ }
}
/* Assign @reg to @ts, and update reg_to_temp[]. */
--
2.34.1
- [PULL 00/40] tcg patch queue, Richard Henderson, 2023/02/04
- [PULL 09/40] tcg: Add TCG_CALL_RET_BY_VEC, Richard Henderson, 2023/02/04
- [PULL 10/40] include/qemu/int128: Use Int128 structure for TCI, Richard Henderson, 2023/02/04
- [PULL 03/40] tcg: Define TCG_TYPE_I128 and related helper macros, Richard Henderson, 2023/02/04
- [PULL 16/40] tcg: Add basic data movement for TCGv_i128, Richard Henderson, 2023/02/04
- [PULL 08/40] tcg: Introduce tcg_target_call_oarg_reg, Richard Henderson, 2023/02/04
- [PULL 13/40] tcg/tci: Add TCG_TARGET_CALL_{RET,ARG}_I128, Richard Henderson, 2023/02/04
- [PULL 06/40] tcg: Introduce tcg_out_addi_ptr, Richard Henderson, 2023/02/04
- [PULL 12/40] tcg/tci: Fix big-endian return register ordering, Richard Henderson, 2023/02/04
- [PULL 14/40] tcg: Add TCG_TARGET_CALL_{RET,ARG}_I128, Richard Henderson, 2023/02/04
- [PULL 05/40] tcg: Allocate objects contiguously in temp_allocate_frame,
Richard Henderson <=
- [PULL 07/40] tcg: Add TCG_CALL_{RET,ARG}_BY_REF, Richard Henderson, 2023/02/04
- [PULL 02/40] tcg: Init temp_subindex in liveness_pass_2, Richard Henderson, 2023/02/04
- [PULL 01/40] accel/tcg: Test CPUJumpCache in tb_jmp_cache_clear_page, Richard Henderson, 2023/02/04
- [PULL 11/40] tcg/i386: Add TCG_TARGET_CALL_{RET,ARG}_I128, Richard Henderson, 2023/02/04
- [PULL 04/40] tcg: Handle dh_typecode_i128 with TCG_CALL_{RET, ARG}_NORMAL, Richard Henderson, 2023/02/04
- [PULL 15/40] tcg: Add temp allocation for TCGv_i128, Richard Henderson, 2023/02/04
- [PULL 17/40] tcg: Add guest load/store primitives for TCGv_i128, Richard Henderson, 2023/02/04
- [PULL 18/40] tcg: Add tcg_gen_{non}atomic_cmpxchg_i128, Richard Henderson, 2023/02/04
- [PULL 20/40] target/arm: Use tcg_gen_atomic_cmpxchg_i128 for STXP, Richard Henderson, 2023/02/04
- [PULL 19/40] tcg: Split out tcg_gen_nonatomic_cmpxchg_i{32,64}, Richard Henderson, 2023/02/04