From: Mike Frysinger <vapier@gentoo.org>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] sim: endian: leverage __int128 when available
Date: Thu, 11 Jan 2024 00:51:16 -0500 [thread overview]
Message-ID: <20240111055116.29216-2-vapier@gentoo.org> (raw)
In-Reply-To: <20240111055116.29216-1-vapier@gentoo.org>
Should be functionally the same, but the code is a little simpler.
---
sim/common/sim-endian.c | 8 ++++++++
sim/common/sim-types.h | 5 +++++
2 files changed, 13 insertions(+)
diff --git a/sim/common/sim-endian.c b/sim/common/sim-endian.c
index 9b498fbf94e3..76735ea6cfd5 100644
--- a/sim/common/sim-endian.c
+++ b/sim/common/sim-endian.c
@@ -98,6 +98,9 @@ INLINE_SIM_ENDIAN\
(unsigned_8)
sim_endian_split_16 (unsigned_16 word, int w)
{
+#ifdef HAVE___INT128
+ return w == 0 ? word >> 64 : word;
+#else
if (HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE)
{
return word.a[1 - w];
@@ -106,6 +109,7 @@ sim_endian_split_16 (unsigned_16 word, int w)
{
return word.a[w];
}
+#endif
}
@@ -114,6 +118,9 @@ INLINE_SIM_ENDIAN\
sim_endian_join_16 (unsigned_8 h, unsigned_8 l)
{
+#ifdef HAVE___INT128
+ return (unsigned_16)h << 64 | l;
+#else
unsigned_16 word;
if (HOST_BYTE_ORDER == BFD_ENDIAN_LITTLE)
{
@@ -126,6 +133,7 @@ sim_endian_join_16 (unsigned_8 h, unsigned_8 l)
word.a[1] = l;
}
return word;
+#endif
}
diff --git a/sim/common/sim-types.h b/sim/common/sim-types.h
index 182f0dbe1f38..f5f863c536e7 100644
--- a/sim/common/sim-types.h
+++ b/sim/common/sim-types.h
@@ -67,8 +67,13 @@
# define SIGNED64(X) ((int64_t) X##LL)
#endif
+#ifdef HAVE___INT128
+typedef unsigned __int128 unsigned128;
+typedef __int128 signed128;
+#else
typedef struct { uint64_t a[2]; } unsigned128;
typedef struct { int64_t a[2]; } signed128;
+#endif
/* byte based */
--
2.43.0
prev parent reply other threads:[~2024-01-11 5:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-11 5:51 [PATCH 1/2] sim: ppc: implement 128-bit register read/writes with sim-endian APIs Mike Frysinger
2024-01-11 5:51 ` Mike Frysinger [this message]
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=20240111055116.29216-2-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gdb-patches@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).