qemu-riscv
[Top][All Lists]
Advanced

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

Re: [PATCH v4 03/36] tcg: Allocate objects contiguously in temp_allocate


From: Alex Bennée
Subject: Re: [PATCH v4 03/36] tcg: Allocate objects contiguously in temp_allocate_frame
Date: Wed, 11 Jan 2023 09:59:52 +0000
User-agent: mu4e 1.9.12; emacs 29.0.60

Richard Henderson <richard.henderson@linaro.org> writes:

> When allocating a temp to the stack frame, consider the
> base type and allocate all parts at once.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
>  tcg/tcg.c | 30 ++++++++++++++++++++++--------
>  1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/tcg/tcg.c b/tcg/tcg.c
> index 99e6e4e1a8..7e69e2c9fd 100644
> --- a/tcg/tcg.c
> +++ b/tcg/tcg.c
> @@ -3242,11 +3242,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;
> @@ -3277,13 +3278,26 @@ 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;
> +
> +        ts -= ts->temp_subindex;

Whats going on here? Are we jumping to a previous temp? What guarentees
there is something at 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[]. */


-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro



reply via email to

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