public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: jimw@sifive.com,	palmer@sifive.com,	jhb@FreeBSD.org,
	Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 2/4] gdb/riscv: Add equality operators to riscv_gdb_features
Date: Thu, 29 Nov 2018 16:50:00 -0000	[thread overview]
Message-ID: <ae2036cfc67ef47f172e6b5edd77b449de667f3b.1543509416.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1543509416.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1543509416.git.andrew.burgess@embecosm.com>

Add '==' and '!=' operators for the struct riscv_gdb_features,
allowing a small simplification.

gdb/ChangeLog:

	* arch/riscv.h (riscv_gdb_features::operator==): New.
	(riscv_gdb_features::operator!=): New.
	* riscv-tdep.c (riscv_gdbarch_init): Make use of the inequality
	operator.
---
 gdb/ChangeLog    |  7 +++++++
 gdb/arch/riscv.h | 13 +++++++++++++
 gdb/riscv-tdep.c |  4 +---
 3 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/gdb/arch/riscv.h b/gdb/arch/riscv.h
index ec4d5f39525..be41828eff6 100644
--- a/gdb/arch/riscv.h
+++ b/gdb/arch/riscv.h
@@ -53,6 +53,19 @@ struct riscv_gdbarch_features
      this field is true then the hardware floating point abi is in use, and
      values are passed in f-registers matching the size of FLEN.  */
   bool hw_float_abi = false;
+
+  /* Equality operator.  */
+  bool operator== (const struct riscv_gdbarch_features &rhs) const
+  {
+    return (xlen == rhs.xlen && flen == rhs.flen
+	    && hw_float_abi == rhs.hw_float_abi);
+  }
+
+  /* Inequality operator.  */
+  bool operator!= (const struct riscv_gdbarch_features &rhs) const
+  {
+    return !((*this) == rhs);
+  }
 };
 
 /* Create and return a target description that is compatible with
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index d66fe5c8793..30c777db6f2 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -3025,9 +3025,7 @@ riscv_gdbarch_init (struct gdbarch_info info,
          gdbarch.  */
       struct gdbarch_tdep *other_tdep = gdbarch_tdep (arches->gdbarch);
 
-      if (other_tdep->features.hw_float_abi != features.hw_float_abi
-          || other_tdep->features.xlen != features.xlen
-          || other_tdep->features.flen != features.flen)
+      if (other_tdep->features != features)
         continue;
 
       break;
-- 
2.14.5

  parent reply	other threads:[~2018-11-29 16:50 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28 22:50 [RFC] gdb/riscv: Add read_description method for riscv_linux_nat_target Andrew Burgess
2018-11-28 23:37 ` Jim Wilson
2018-11-29  2:23 ` Jim Wilson
2018-11-29 16:50   ` [PATCH 0/4] " Andrew Burgess
2018-11-29 16:50   ` Andrew Burgess [this message]
2018-11-29 16:50   ` [PATCH 3/4] gdb/riscv: Create each unique target description only once Andrew Burgess
2018-11-29 18:12     ` Pedro Alves
2018-11-29 19:17       ` Andrew Burgess
2018-11-29 22:32       ` Andrew Burgess
2018-11-30 17:07         ` Pedro Alves
2018-11-29 16:50   ` [PATCH 4/4] gdb/riscv: Add read_description method for riscv_linux_nat_target Andrew Burgess
2018-11-29 22:22     ` Jim Wilson
2018-11-29 16:50   ` [PATCH 1/4] gdb/riscv: Make some target description functions constant Andrew Burgess

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=ae2036cfc67ef47f172e6b5edd77b449de667f3b.1543509416.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jhb@FreeBSD.org \
    --cc=jimw@sifive.com \
    --cc=palmer@sifive.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 read-only IMAP folder(s) and NNTP newsgroup(s).