gdb/riscv: Add equality operators to riscv_gdb_features
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 29 Nov 2018 15:07:59 +0000 (15:07 +0000)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 30 Nov 2018 18:13:42 +0000 (18:13 +0000)
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
gdb/arch/riscv.h
gdb/riscv-tdep.c

index 72c2ee16ca444779619e4ba92da65e1ed1ad9fc6..306e1a1132cb3e72635c5479a06c524893e63947 100644 (file)
@@ -1,3 +1,10 @@
+2018-11-30  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * 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.
+
 2018-11-30  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * arch/riscv.h (riscv_create_target_description): Make return type
index ec4d5f3952578d8b40e0637e034f6c74438e9e45..be41828eff67a1f5af59ad08e970b9706e76f0cf 100644 (file)
@@ -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
index d66fe5c87935788afd0ced0fd438cfcaf79fb778..30c777db6f2acf3483a0b8dab0bb4140b6495a86 100644 (file)
@@ -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;