From: "Alex Bennée" <alex.bennee@linaro.org>
To: a.rigo@virtualopensystems.com
Cc: mttcg@listserver.greensocs.com,
"Peter Crosthwaite" <crosthwaite.peter@gmail.com>,
mark.burton@greensocs.com, qemu-devel@nongnu.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <rth@twiddle.net>,
"Alex Bennée" <alex.bennee@linaro.org>,
fred.konrad@greensocs.com
Subject: [Qemu-devel] [PATCH] softmmu_template: POC simpler do_unl_access inline
Date: Thu, 7 Jan 2016 15:10:25 +0000 [thread overview]
Message-ID: <1452179425-11353-1-git-send-email-alex.bennee@linaro.org> (raw)
In-Reply-To: <760z5cury.fsf@linaro.org>
As any constant arguments will be folded by the compiler when a function
is in-lined we can squash the be/le handlers together and let the
compiler figure it out.
---
softmmu_template.h | 68 ++++++++++++++++++++----------------------------------
1 file changed, 25 insertions(+), 43 deletions(-)
diff --git a/softmmu_template.h b/softmmu_template.h
index 65cce0a..6d86a21 100644
--- a/softmmu_template.h
+++ b/softmmu_template.h
@@ -108,6 +108,8 @@
# define helper_be_st_name glue(glue(helper_be_st, SUFFIX), MMUSUFFIX)
#endif
+#define helper_generic_st_name glue(glue(helper_generic_st, SUFFIX), MMUSUFFIX)
+
#ifdef TARGET_WORDS_BIGENDIAN
# define helper_te_ld_name helper_be_ld_name
# define helper_te_st_name helper_be_st_name
@@ -378,12 +380,13 @@ static inline void glue(io_write, SUFFIX)(CPUArchState *env,
iotlbentry->attrs);
}
-static inline void glue(helper_le_st_name, _do_unl_access)(CPUArchState *env,
- DATA_TYPE val,
- target_ulong addr,
- TCGMemOpIdx oi,
- unsigned mmu_idx,
- uintptr_t retaddr)
+static inline void glue(helper_generic_st_name, _do_unl_access)(CPUArchState *env,
+ bool little_endian,
+ DATA_TYPE val,
+ target_ulong addr,
+ TCGMemOpIdx oi,
+ unsigned mmu_idx,
+ uintptr_t retaddr)
{
int i;
@@ -391,12 +394,17 @@ static inline void glue(helper_le_st_name, _do_unl_access)(CPUArchState *env,
cpu_unaligned_access(ENV_GET_CPU(env), addr, MMU_DATA_STORE,
mmu_idx, retaddr);
}
- /* XXX: not efficient, but simple */
/* Note: relies on the fact that tlb_fill() does not remove the
* previous page from the TLB cache. */
for (i = DATA_SIZE - 1; i >= 0; i--) {
- /* Little-endian extract. */
- uint8_t val8 = val >> (i * 8);
+ uint8_t val8;
+ if (little_endian) {
+ /* Little-endian extract. */
+ val8 = val >> (i * 8);
+ } else {
+ /* Big-endian extract. */
+ val8 = val >> (((DATA_SIZE - 1) * 8) - (i * 8));
+ }
/* Note the adjustment at the beginning of the function.
Undo that for the recursion. */
glue(helper_ret_stb, MMUSUFFIX)(env, addr + i, val8,
@@ -415,8 +423,8 @@ static inline void glue(helper_le_st_name, _do_mmio_access)(CPUArchState *env,
CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index];
if ((addr & (DATA_SIZE - 1)) != 0) {
- glue(helper_le_st_name, _do_unl_access)(env, val, addr, mmu_idx,
- oi, retaddr);
+ glue(helper_generic_st_name, _do_unl_access)(env, true, val, addr,
+ mmu_idx, oi, retaddr);
}
/* ??? Note that the io helpers always read data in the target
byte ordering. We should push the LE/BE request down into io. */
@@ -438,8 +446,8 @@ static inline void glue(helper_le_st_name, _do_ram_access)(CPUArchState *env,
if (DATA_SIZE > 1
&& unlikely((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1
>= TARGET_PAGE_SIZE)) {
- glue(helper_le_st_name, _do_unl_access)(env, val, addr, oi, mmu_idx,
- retaddr);
+ glue(helper_generic_st_name, _do_unl_access)(env, true, val, addr, oi, mmu_idx,
+ retaddr);
return;
}
@@ -538,32 +546,6 @@ void helper_le_st_name(CPUArchState *env, target_ulong addr, DATA_TYPE val,
}
#if DATA_SIZE > 1
-static inline void glue(helper_be_st_name, _do_unl_access)(CPUArchState *env,
- DATA_TYPE val,
- target_ulong addr,
- TCGMemOpIdx oi,
- unsigned mmu_idx,
- uintptr_t retaddr)
-{
- int i;
-
- if ((get_memop(oi) & MO_AMASK) == MO_ALIGN) {
- cpu_unaligned_access(ENV_GET_CPU(env), addr, MMU_DATA_STORE,
- mmu_idx, retaddr);
- }
- /* XXX: not efficient, but simple */
- /* Note: relies on the fact that tlb_fill() does not remove the
- * previous page from the TLB cache. */
- for (i = DATA_SIZE - 1; i >= 0; i--) {
- /* Big-endian extract. */
- uint8_t val8 = val >> (((DATA_SIZE - 1) * 8) - (i * 8));
- /* Note the adjustment at the beginning of the function.
- Undo that for the recursion. */
- glue(helper_ret_stb, MMUSUFFIX)(env, addr + i, val8,
- oi, retaddr + GETPC_ADJ);
- }
-}
-
static inline void glue(helper_be_st_name, _do_mmio_access)(CPUArchState *env,
DATA_TYPE val,
target_ulong addr,
@@ -575,8 +557,8 @@ static inline void glue(helper_be_st_name, _do_mmio_access)(CPUArchState *env,
CPUIOTLBEntry *iotlbentry = &env->iotlb[mmu_idx][index];
if ((addr & (DATA_SIZE - 1)) != 0) {
- glue(helper_be_st_name, _do_unl_access)(env, val, addr, mmu_idx,
- oi, retaddr);
+ glue(helper_generic_st_name, _do_unl_access)(env, false, val, addr, mmu_idx,
+ oi, retaddr);
}
/* ??? Note that the io helpers always read data in the target
byte ordering. We should push the LE/BE request down into io. */
@@ -598,8 +580,8 @@ static inline void glue(helper_be_st_name, _do_ram_access)(CPUArchState *env,
if (DATA_SIZE > 1
&& unlikely((addr & ~TARGET_PAGE_MASK) + DATA_SIZE - 1
>= TARGET_PAGE_SIZE)) {
- glue(helper_be_st_name, _do_unl_access)(env, val, addr, oi, mmu_idx,
- retaddr);
+ glue(helper_generic_st_name, _do_unl_access)(env, false, val, addr, oi, mmu_idx,
+ retaddr);
return;
}
--
2.6.4
next parent reply other threads:[~2016-01-07 15:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <760z5cury.fsf@linaro.org>
2016-01-07 15:10 ` Alex Bennée [this message]
2016-01-07 15:21 ` [Qemu-devel] [PATCH] softmmu_template: POC simpler do_unl_access inline alvise rigo
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=1452179425-11353-1-git-send-email-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=a.rigo@virtualopensystems.com \
--cc=crosthwaite.peter@gmail.com \
--cc=fred.konrad@greensocs.com \
--cc=mark.burton@greensocs.com \
--cc=mttcg@listserver.greensocs.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).