All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aurelien Jarno <aurelien@aurel32.net>
To: Max Filippov <jcmvbkbc@gmail.com>
Cc: Blue Swirl <blauwirbel@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] target-xtensa: make sar_m32 global instead of local temp
Date: Sat, 24 Nov 2012 11:59:48 +0100	[thread overview]
Message-ID: <20121124105948.GA4016@ohm.aurel32.net> (raw)
In-Reply-To: <1353718296-3884-1-git-send-email-jcmvbkbc@gmail.com>

On Sat, Nov 24, 2012 at 04:51:36AM +0400, Max Filippov wrote:
> This fixes the following assertion caused by local temp reaching the end
> of TB in discarded state:
> 
>   qemu-system-xtensa: tcg/tcg.c:1665: temp_save: Assertion `s->temps[temp].val_type == 2 || s->temps[temp].fixed_reg' failed.
>   Aborted
> 
> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
> ---
>  target-xtensa/cpu.h       |    1 +
>  target-xtensa/translate.c |   28 ++++++++--------------------
>  2 files changed, 9 insertions(+), 20 deletions(-)

I have just send a patch to fix the issue in the TCG code instead (sorry
for being so long, the last weeks have been quite busy). I think it is
better than fixing the issue in target-xtensa.

If it works for you, I'll commit it.

> diff --git a/target-xtensa/cpu.h b/target-xtensa/cpu.h
> index 74e9888..f021a9a 100644
> --- a/target-xtensa/cpu.h
> +++ b/target-xtensa/cpu.h
> @@ -323,6 +323,7 @@ typedef struct CPUXtensaState {
>      const XtensaConfig *config;
>      uint32_t regs[16];
>      uint32_t pc;
> +    uint32_t sar_m32;
>      uint32_t sregs[256];
>      uint32_t uregs[256];
>      uint32_t phys_regs[MAX_NAREG];
> diff --git a/target-xtensa/translate.c b/target-xtensa/translate.c
> index e5a3f49..4f3cf32 100644
> --- a/target-xtensa/translate.c
> +++ b/target-xtensa/translate.c
> @@ -56,8 +56,6 @@ typedef struct DisasContext {
>  
>      bool sar_5bit;
>      bool sar_m32_5bit;
> -    bool sar_m32_allocated;
> -    TCGv_i32 sar_m32;
>  
>      uint32_t ccount_delta;
>      unsigned used_window;
> @@ -71,6 +69,7 @@ typedef struct DisasContext {
>  
>  static TCGv_ptr cpu_env;
>  static TCGv_i32 cpu_pc;
> +static TCGv_i32 cpu_sar_m32;
>  static TCGv_i32 cpu_R[16];
>  static TCGv_i32 cpu_FR[16];
>  static TCGv_i32 cpu_SR[256];
> @@ -169,6 +168,8 @@ void xtensa_translate_init(void)
>      cpu_env = tcg_global_reg_new_ptr(TCG_AREG0, "env");
>      cpu_pc = tcg_global_mem_new_i32(TCG_AREG0,
>              offsetof(CPUXtensaState, pc), "pc");
> +    cpu_sar_m32 = tcg_global_mem_new_i32(TCG_AREG0,
> +            offsetof(CPUXtensaState, sar_m32), "sar_m32");
>  
>      for (i = 0; i < 16; i++) {
>          cpu_R[i] = tcg_global_mem_new_i32(TCG_AREG0,
> @@ -230,21 +231,13 @@ static void init_sar_tracker(DisasContext *dc)
>  {
>      dc->sar_5bit = false;
>      dc->sar_m32_5bit = false;
> -    dc->sar_m32_allocated = false;
> -}
> -
> -static void reset_sar_tracker(DisasContext *dc)
> -{
> -    if (dc->sar_m32_allocated) {
> -        tcg_temp_free(dc->sar_m32);
> -    }
>  }
>  
>  static void gen_right_shift_sar(DisasContext *dc, TCGv_i32 sa)
>  {
>      tcg_gen_andi_i32(cpu_SR[SAR], sa, 0x1f);
>      if (dc->sar_m32_5bit) {
> -        tcg_gen_discard_i32(dc->sar_m32);
> +        tcg_gen_discard_i32(cpu_sar_m32);
>      }
>      dc->sar_5bit = true;
>      dc->sar_m32_5bit = false;
> @@ -253,12 +246,8 @@ static void gen_right_shift_sar(DisasContext *dc, TCGv_i32 sa)
>  static void gen_left_shift_sar(DisasContext *dc, TCGv_i32 sa)
>  {
>      TCGv_i32 tmp = tcg_const_i32(32);
> -    if (!dc->sar_m32_allocated) {
> -        dc->sar_m32 = tcg_temp_local_new_i32();
> -        dc->sar_m32_allocated = true;
> -    }
> -    tcg_gen_andi_i32(dc->sar_m32, sa, 0x1f);
> -    tcg_gen_sub_i32(cpu_SR[SAR], tmp, dc->sar_m32);
> +    tcg_gen_andi_i32(cpu_sar_m32, sa, 0x1f);
> +    tcg_gen_sub_i32(cpu_SR[SAR], tmp, cpu_sar_m32);
>      dc->sar_5bit = false;
>      dc->sar_m32_5bit = true;
>      tcg_temp_free(tmp);
> @@ -498,7 +487,7 @@ static void gen_wsr_sar(DisasContext *dc, uint32_t sr, TCGv_i32 s)
>  {
>      tcg_gen_andi_i32(cpu_SR[sr], s, 0x3f);
>      if (dc->sar_m32_5bit) {
> -        tcg_gen_discard_i32(dc->sar_m32);
> +        tcg_gen_discard_i32(cpu_sar_m32);
>      }
>      dc->sar_5bit = false;
>      dc->sar_m32_5bit = false;
> @@ -1483,7 +1472,7 @@ static void disas_xtensa_insn(CPUXtensaState *env, DisasContext *dc)
>              case 10: /*SLL*/
>                  gen_window_check2(dc, RRR_R, RRR_S);
>                  if (dc->sar_m32_5bit) {
> -                    tcg_gen_shl_i32(cpu_R[RRR_R], cpu_R[RRR_S], dc->sar_m32);
> +                    tcg_gen_shl_i32(cpu_R[RRR_R], cpu_R[RRR_S], cpu_sar_m32);
>                  } else {
>                      TCGv_i64 v = tcg_temp_new_i64();
>                      TCGv_i32 s = tcg_const_i32(32);
> @@ -2947,7 +2936,6 @@ static void gen_intermediate_code_internal(
>              tcg_ctx.gen_opc_ptr < gen_opc_end);
>  
>      reset_litbase(&dc);
> -    reset_sar_tracker(&dc);
>      if (dc.icount) {
>          tcg_temp_free(dc.next_icount);
>      }
> -- 
> 1.7.7.6
> 
> 

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

  reply	other threads:[~2012-11-24 11:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-24  0:51 [Qemu-devel] [PATCH] target-xtensa: make sar_m32 global instead of local temp Max Filippov
2012-11-24 10:59 ` Aurelien Jarno [this message]
2012-11-24 11:27   ` Max Filippov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121124105948.GA4016@ohm.aurel32.net \
    --to=aurelien@aurel32.net \
    --cc=blauwirbel@gmail.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.