qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Max Filippov <jcmvbkbc@gmail.com>, qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [RFC] target/xtensa: rework zero overhead loops implementation
Date: Thu, 4 Oct 2018 16:13:43 -0500	[thread overview]
Message-ID: <39db072a-4ed9-834e-a77f-bb06df42a9f1@linaro.org> (raw)
In-Reply-To: <CAMo8BfJ==eV4g7L3nSuYa=o2RNw98nUg_0VJeBD6V8Q54m0wkg@mail.gmail.com>

On 10/4/18 3:14 PM, Max Filippov wrote:
> I thought about it some more and it looks like this is not going to work
> in general case in the presence of TB linking: a block with a big (and thus
> not precise) LEND distance may be linked to a block with a small (and
> thus precise) LEND distance. Then LEND may change so that next time
> it still goes to the first TB. In that case it shouldn't go from the first TB
> to the second, but with this scheme it will.

Indeed.  Perhaps think of ways in which LBEG and LEND can be represented
relative to each other and PC and store than in the 32-bits you have available
in the CS_BASE field.

Think first about how, if PC >= LEND or LEND - PC > PAGE_SIZE, that all of the
loop stuff is irrelevant because we won't hit LEND within this TB.

Think second about how to represent the common case -- how LOOP sets LBEG and
LEND together.  That is, LEND - LBEG <= 256.  So, usually, we can also have an
exact representation of LBEG and have a direct link rather than an indirect
link.  But I presume that one can play games with special registers to create
ranges that LOOP won't.  So we need some setting that will indicate that.

Consider CS_BASE fields:

  [12: 0]  EDIF = LEND - PC, if PC < LEND && LEND - PC < 2*PAGE_SIZE, or 0.
  [20:13]  BDIF = LEND - LBEG, if LEND - LBEG < 256, or 0.

So you can tell if advancing PC within a TB will exactly match LEND.  You can
tell what LBEG should be, except if BDIF == 0.  In that, presumably rare case,
you load LBEG at runtime as you did in this patch.

Note that if CS_BASE == 0, and thus EDIF == 0, looping is disabled for the TB.

I'll note that this also makes XTENSA_TBFLAG_EXCM redundant.  Simply skip
setting CS_BASE to a non-zero value instead.


r~

  reply	other threads:[~2018-10-04 21:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-04  1:05 [Qemu-devel] [RFC] target/xtensa: rework zero overhead loops implementation Max Filippov
2018-10-04 20:14 ` Max Filippov
2018-10-04 21:13   ` Richard Henderson [this message]
2018-10-04 22:03     ` Max Filippov
2018-10-04 22:05       ` 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=39db072a-4ed9-834e-a77f-bb06df42a9f1@linaro.org \
    --to=richard.henderson@linaro.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).