All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chen Gang S <gang.chen@sunrus.com.cn>
To: Richard Henderson <rth@twiddle.net>,
	Peter Maydell <peter.maydell@linaro.org>,
	Chris Metcalf <cmetcalf@ezchip.com>,
	Riku Voipio <riku.voipio@iki.fi>,
	"walt@tilera.com" <walt@tilera.com>
Cc: qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] target-tilegx: Finish decoding the first TB block.
Date: Sun, 22 Feb 2015 08:25:06 +0800	[thread overview]
Message-ID: <54E921E2.4070503@sunrus.com.cn> (raw)
In-Reply-To: <54E8B352.9040309@twiddle.net>

On 2/22/15 00:33, Richard Henderson wrote:
> On 02/21/2015 07:31 AM, Chen Gang S wrote:
>>
>>  - We can still use the original pipes order: "y0, y2, y1" and "x0, x1".
> 
> I guess, sure, though I don't think that'll help as much as you imagine.
> 
>>  - y0, y2, and x0 need to use tcg temporary variables, but y1 and x1 can
>>    still use real variables.
> 
> Possibly, but I wouldn't structure it that way.  I'd have all of the pipes
> write to temporaries.
> 
>>  - y1 and x1 need to flush the temporary variables, they also need to
>>    consider about jump cases for tcg code (flush tcg temporary variables
>>    after comparing and before jump).
> 
> I wouldn't do that either.  I'd have y1/x1 record that a branch occurred, and
> the condition, but delay the flushing and branching to common code.
>

OK, thanks. For me, your idea is OK, it is more simpler (although with
more tcg temporary variables).

At present, the performance is not quite important, so I shall implement
the translation with the way which you provide below, thanks.

> For instance:
> 

The demo code below is much valuable to me, but I guess, it can be
improved too (the related reply is below):

> typedef enum ExitStatus {
>     NO_EXIT,         /* Fall through to next bundle */
>     EXIT_JUMP,       /* Normal branch exit */
>     EXIT_NORETURN    /* Exception taken (e.g. syscall) */
> } ExitStatus;
> 
> typedef struct DisasContext {
>     struct TranslationBlock *tb;
>     int mem_idx;
> 
>     uint64_t pc;
>     ExitStatus exit;
> 
>     int result_regs[3];
>     TCGv result_vals[3];
> 
>     TCGCond branch_cond;
>     TCGv branch_dest;
>     TCGv branch_val1;
>     TCGv branch_val2;
> } DisasContext;
> 
> 
> static void translate_one_bundle(DisasContext *dc, uint64_t bundle)
> {
>     int i;
> 
>     /* Initialize the per-bundle state of DC.  */
>     dc->exit = NO_EXIT;
>     for (i = 0; i < 3; ++i) {
>         dc->result_regs[i] = -1;
>         TCGV_UNUSED_I64(dc->result_vals[i]);
>     }
>     dc->branch_cond = TCG_COND_NEVER;
>     dc->branch_desti = -1;

It is branch_dest, not branch_desti.

>     TCGV_UNUSED_I64(dc->branch_dest);
>     TCGV_UNUSED_I64(dc->branch_val1);
>     TCGV_UNUSED_I64(dc->branch_val2);
> 
>     /* Decode all pipes, writing results into DC.  */
> 
>     /* If some pipe raises an exception, nothing left to do.  */
>     if (dc->exit == EXIT_NORETURN) {
>         return;
>     }
> 
>     /* Write back register results from all pipes.  */
>     for (i = 0; i < 3; ++i) {
>         int r = dc->result_regs[i];
>         if (r >= 0)
>             tcg_gen_mov_i64(cpu_regs[r], dc->result_vals[i]);
>             tcg_temp_free_i64(dc->result_vals[i]);
>         }
>     }
> 
>     /* Write back branch results, i.e. take the branch now.  */
>     if (dc->branch_cond != TCG_COND_NEVER) {
>         if (dc->branch_cond == TCG_COND_ALWAYS) {
>             /* Unconditional branch */
>             tcg_gen_mov_i64(cpu_pc, dc->branch_dest);
>         } else {
>             /* Conditional branch */
>             TCGv next_pc = tcg_const_i64(dc->pc + 8);
>             tcg_gen_movcond_i64(dc->branch_cond, cpu_pc,
>                                 dc->branch_val1, dc->branch_val2,
>                                 dc->branch_dest, next_pc);
>             tcg_temp_free_i64(dc->branch_val1);
>             tcg_temp_free_i64(dc->branch_val2);
>             tcg_temp_free_i64(next_pc);
>         }
>         tcg_temp_free_i64(dc->branch_dest);
>         dc->exit = EXIT_JUMP;

Do we need tcg_gen_exit_tb(0)? At present for simplify thinking, I always
use tcg_gen_exit_tb(0) for the end of one TB block.

>     }
> }
> 
> This mostly ignores the use of tcg_gen_goto_tb for now.  It's slightly more
> complicated to use, and it makes debugging execution traces a bit harder.
> Neither of which do you really want while bringing up the decoder.  However,
> the eventual use of goto_tb is why we want to delay performing the branch until
> after writing back the registers, rather than simply writing to cpu_pc right away.
>

Excuse me, I am not quite familiar with tcg_gen_goto/exit_tb(), at
present, I still don't understand their parameters.

I guess, they are for performance (tb chaining), so I simply only use
tcg_gen_exit_tb(0), at present.

Welcome more information about tcg_gen_goto_tb() and tcg_gen_exit_tb().


> I hope this is enough to get started properly.
> 

Yeah, it is really enough.

Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed

  reply	other threads:[~2015-02-22  0:17 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-21  3:05 [Qemu-devel] [PATCH] target-tilegx: Finish decoding the first TB block Chen Gang S
2015-02-21  7:16 ` Chen Gang S
2015-02-21 15:31   ` Chen Gang S
2015-02-21 16:02     ` Chen Gang S
2015-02-21 16:33     ` Richard Henderson
2015-02-22  0:25       ` Chen Gang S [this message]
2015-02-22  0:25         ` Chris Metcalf
2015-02-22  1:08           ` Chen Gang S
2015-02-22  4:42             ` Chen Gang S

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=54E921E2.4070503@sunrus.com.cn \
    --to=gang.chen@sunrus.com.cn \
    --cc=cmetcalf@ezchip.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    --cc=rth@twiddle.net \
    --cc=walt@tilera.com \
    /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.