From: Richard Henderson <richard.henderson@linaro.org>
To: Thomas Huth <thuth@redhat.com>,
qemu-devel@nongnu.org, David Hildenbrand <david@redhat.com>,
Peter Xu <peterx@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Mark Burton" <mburton@qti.qualcomm.com>
Subject: Re: [PATCH 1/2] include/exec: Make ld*_p and st*_p functions available for generic code, too
Date: Wed, 17 May 2023 06:20:26 -0700 [thread overview]
Message-ID: <59f86761-effc-9cf0-ee17-4e8e81a8a47d@linaro.org> (raw)
In-Reply-To: <20230517074222.766683-2-thuth@redhat.com>
On 5/17/23 00:42, Thomas Huth wrote:
> +static inline int ldl_p(const void *ptr)
> +{
> + return tswap32(ldl_he_p(ptr));
Not an ideal formulation for some hosts, e.g. Power < 3.0, because there is no separate
bswap instruction. Power 2.07 only has bswapping-load/store. Keeping the bswap adjacent
to the memory operation helps the compiler.
> +static inline uint64_t ldn_p(const void *ptr, int sz)
> +{
> + if (target_needs_bswap()) {
> +#if HOST_BIG_ENDIAN
> + return ldn_le_p(ptr, sz);
> +#else
> + return ldn_be_p(ptr, sz);
> +#endif
> + } else {
> + return ldn_he_p(ptr, sz);
> + }
Better to avoid #if for if. And even better to merge to one test:
if (HOST_BIG_ENDIAN ^ target_needs_bswap()) {
return ldn_le_p(ptr, sz);
} else {
return ldn_be_p(ptr, sz);
}
r~
next prev parent reply other threads:[~2023-05-17 13:20 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-17 7:42 [PATCH 0/2] Make ioport.c target-independent Thomas Huth
2023-05-17 7:42 ` [PATCH 1/2] include/exec: Make ld*_p and st*_p functions available for generic code, too Thomas Huth
2023-05-17 10:18 ` Philippe Mathieu-Daudé
2023-05-17 10:38 ` Thomas Huth
2023-05-17 13:20 ` Richard Henderson [this message]
2023-05-17 7:42 ` [PATCH 2/2] softmmu: Move ioport.c into the target-independent source set Thomas Huth
2023-05-17 13:23 ` 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=59f86761-effc-9cf0-ee17-4e8e81a8a47d@linaro.org \
--to=richard.henderson@linaro.org \
--cc=david@redhat.com \
--cc=mburton@qti.qualcomm.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@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).