From: David Hildenbrand <david@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com
Subject: Re: [RFC v2 2/5] cputlb: Replace switches in load/store_helper with callback
Date: Thu, 19 Sep 2019 16:53:09 +0200 [thread overview]
Message-ID: <b11701c0-63cd-f313-fc0b-f66cb6d2f10a@redhat.com> (raw)
In-Reply-To: <20190918180251.32003-3-richard.henderson@linaro.org>
On 18.09.19 20:02, Richard Henderson wrote:
> Add a function parameter to perform the actual load/store to ram.
> With optimization, this results in identical code.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> accel/tcg/cputlb.c | 159 +++++++++++++++++++++++----------------------
> 1 file changed, 83 insertions(+), 76 deletions(-)
I would have guessed the compiler propagates the constant and eliminates
the switch completely for the variants. After all, we now have more LOC ...
I would have moved the actual read/write to a separate function
containing the switch statement instead.
But I am pretty sure you know what you're doing here :)
>
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index 2222b87764..b4a63d3928 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -1280,11 +1280,38 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
>
> typedef uint64_t FullLoadHelper(CPUArchState *env, target_ulong addr,
> TCGMemOpIdx oi, uintptr_t retaddr);
> +typedef uint64_t LoadHelper(const void *);
> +
> +/* Wrap the unaligned load helpers to that they have a common signature. */
> +static inline uint64_t wrap_ldub(const void *haddr)
> +{
> + return ldub_p(haddr);
I wonder if you should just add proper type cast to all of the <
uint64_t accessors (e.g., here (uint8_t) ). Shouldn't hurt and makes
people wonder less how the conversion from the int these accessors
return to uint64_t will turn out.
But yeah, you're simply moving code here.
> +}
> +
> +static inline uint64_t wrap_lduw_be(const void *haddr)
> +{
> + return lduw_be_p(haddr);
> +}
> +
> +static inline uint64_t wrap_lduw_le(const void *haddr)
> +{
> + return lduw_le_p(haddr);
> +}
> +
> +static inline uint64_t wrap_ldul_be(const void *haddr)
> +{
> + return (uint32_t)ldl_be_p(haddr);
> +}
> +
> +static inline uint64_t wrap_ldul_le(const void *haddr)
> +{
> + return (uint32_t)ldl_le_p(haddr);
> +}
Looks sane to me!
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-09-19 14:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-18 18:02 [Qemu-devel] [RFC v2 0/5] Move notdirty handling to cputlb Richard Henderson
2019-09-18 18:02 ` [Qemu-devel] [RFC v2 1/5] cputlb: Disable __always_inline__ without optimization Richard Henderson
2019-09-19 14:36 ` David Hildenbrand
2019-09-18 18:02 ` [Qemu-devel] [RFC v2 2/5] cputlb: Replace switches in load/store_helper with callback Richard Henderson
2019-09-19 14:53 ` David Hildenbrand [this message]
2019-09-19 15:10 ` Richard Henderson
2019-09-18 18:02 ` [Qemu-devel] [RFC v2 3/5] cputlb: Introduce TLB_BSWAP Richard Henderson
2019-09-19 15:09 ` David Hildenbrand
2019-09-19 15:13 ` Richard Henderson
2019-09-18 18:02 ` [Qemu-devel] [RFC v2 4/5] exec: Adjust notdirty tracing Richard Henderson
2019-09-19 15:40 ` David Hildenbrand
2019-09-18 18:02 ` [Qemu-devel] [RFC v2 5/5] cputlb: Move NOTDIRTY handling from I/O path to TLB path Richard Henderson
2019-09-19 10:27 ` [Qemu-devel] [RFC v2 0/5] Move notdirty handling to cputlb no-reply
2019-09-19 12:19 ` no-reply
2019-09-19 12:22 ` no-reply
2019-09-21 22:21 ` Richard Henderson
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=b11701c0-63cd-f313-fc0b-f66cb6d2f10a@redhat.com \
--to=david@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.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 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).