From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
"Dr. David Alan Gilbert" <dgilbert@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Peter Crosthwaite <crosthwaite.peter@gmail.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Juan Quintela <quintela@redhat.com>,
Markus Armbruster <armbru@redhat.com>,
Michael Roth <mdroth@linux.vnet.ibm.com>,
Peter Maydell <peter.maydell@linaro.org>,
"Emilio G. Cota" <cota@braap.org>
Subject: [Qemu-devel] [PULL 2/6] trace: simplify trace_mem functions
Date: Wed, 27 Jun 2018 13:58:43 +0100 [thread overview]
Message-ID: <20180627125847.5413-3-stefanha@redhat.com> (raw)
In-Reply-To: <20180627125847.5413-1-stefanha@redhat.com>
From: "Emilio G. Cota" <cota@braap.org>
Add some defines for the mem_info bits, simplify
trace_mem_build_info, and also simplify trace_mem_get_info
by making it a wrapper around trace_mem_build_info.
This paves the way for increasing size_shift by one bit.
Signed-off-by: Emilio G. Cota <cota@braap.org>
Message-id: 1527028012-21888-3-git-send-email-cota@braap.org
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
trace/mem-internal.h | 46 ++++++++++++++++++++------------------------
trace/mem.h | 2 +-
2 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/trace/mem-internal.h b/trace/mem-internal.h
index ddda934253..b684e2750c 100644
--- a/trace/mem-internal.h
+++ b/trace/mem-internal.h
@@ -10,37 +10,33 @@
#ifndef TRACE__MEM_INTERNAL_H
#define TRACE__MEM_INTERNAL_H
-static inline uint8_t trace_mem_get_info(TCGMemOp op, bool store)
-{
- uint8_t res = op;
- bool be = (op & MO_BSWAP) == MO_BE;
-
- /* remove untraced fields */
- res &= (1ULL << 4) - 1;
- /* make endianness absolute */
- res &= ~MO_BSWAP;
- if (be) {
- res |= 1ULL << 3;
- }
- /* add fields */
- if (store) {
- res |= 1ULL << 4;
- }
-
- return res;
-}
+#define TRACE_MEM_SZ_SHIFT_MASK 0x3 /* size shift mask */
+#define TRACE_MEM_SE (1ULL << 2) /* sign extended (y/n) */
+#define TRACE_MEM_BE (1ULL << 3) /* big endian (y/n) */
+#define TRACE_MEM_ST (1ULL << 4) /* store (y/n) */
static inline uint8_t trace_mem_build_info(
- TCGMemOp size, bool sign_extend, TCGMemOp endianness, bool store)
+ int size_shift, bool sign_extend, TCGMemOp endianness, bool store)
{
- uint8_t res = 0;
- res |= size;
- res |= (sign_extend << 2);
+ uint8_t res;
+
+ res = size_shift & TRACE_MEM_SZ_SHIFT_MASK;
+ if (sign_extend) {
+ res |= TRACE_MEM_SE;
+ }
if (endianness == MO_BE) {
- res |= (1ULL << 3);
+ res |= TRACE_MEM_BE;
+ }
+ if (store) {
+ res |= TRACE_MEM_ST;
}
- res |= (store << 4);
return res;
}
+static inline uint8_t trace_mem_get_info(TCGMemOp op, bool store)
+{
+ return trace_mem_build_info(op & MO_SIZE, !!(op & MO_SIGN),
+ op & MO_BSWAP, store);
+}
+
#endif /* TRACE__MEM_INTERNAL_H */
diff --git a/trace/mem.h b/trace/mem.h
index 9c88bcb4e6..2b58196e53 100644
--- a/trace/mem.h
+++ b/trace/mem.h
@@ -25,7 +25,7 @@ static uint8_t trace_mem_get_info(TCGMemOp op, bool store);
*
* Return a value for the 'info' argument in guest memory access traces.
*/
-static uint8_t trace_mem_build_info(TCGMemOp size, bool sign_extend,
+static uint8_t trace_mem_build_info(int size_shift, bool sign_extend,
TCGMemOp endianness, bool store);
--
2.17.1
next prev parent reply other threads:[~2018-06-27 12:59 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-27 12:58 [Qemu-devel] [PULL 0/6] Tracing patches Stefan Hajnoczi
2018-06-27 12:58 ` [Qemu-devel] [PULL 1/6] trace: fix misreporting of TCG access sizes for user-space Stefan Hajnoczi
2018-06-27 12:58 ` Stefan Hajnoczi [this message]
2018-06-27 12:58 ` [Qemu-devel] [PULL 3/6] trace: expand mem_info:size_shift to 3 bits Stefan Hajnoczi
2018-06-27 12:58 ` [Qemu-devel] [PULL 4/6] trace: add trace_mem_build_info_no_se_be/le Stefan Hajnoczi
2018-06-27 12:58 ` [Qemu-devel] [PULL 5/6] trace: enable tracing of TCG atomics Stefan Hajnoczi
2018-06-27 12:58 ` [Qemu-devel] [PULL 6/6] trace: forbid floating point types Stefan Hajnoczi
2018-06-28 13:26 ` [Qemu-devel] [PULL 0/6] Tracing patches Peter Maydell
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=20180627125847.5413-3-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=armbru@redhat.com \
--cc=cota@braap.org \
--cc=crosthwaite.peter@gmail.com \
--cc=dgilbert@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--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).