]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/arch/riscv.h
gdb: Delay releasing target_desc_up in more cases
[thirdparty/binutils-gdb.git] / gdb / arch / riscv.h
index 79f5ec622d4fc80972bb58e8ee0941c722e1c53f..26db0dab0e0459a28b6eb0638039710a7401aeb9 100644 (file)
@@ -1,6 +1,6 @@
 /* Common target-dependent functionality for RISC-V
 
-   Copyright (C) 2018 Free Software Foundation, Inc.
+   Copyright (C) 2018-2020 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -20,7 +20,7 @@
 #ifndef ARCH_RISCV_H
 #define ARCH_RISCV_H
 
-#include "common/tdesc.h"
+#include "gdbsupport/tdesc.h"
 
 /* The set of RISC-V architectural features that we track that impact how
    we configure the actual gdbarch instance.  We hold one of these in the
@@ -46,19 +46,10 @@ struct riscv_gdbarch_features
      that there are no f-registers.  No other value is valid.  */
   int flen = 0;
 
-  /* This indicates if hardware floating point abi is in use.  If the FLEN
-     field is 0 then this value _must_ be false.  If the FLEN field is
-     non-zero and this field is false then this indicates the target has
-     floating point registers, but is still using the soft-float abi.  If
-     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);
+    return (xlen == rhs.xlen && flen == rhs.flen);
   }
 
   /* Inequality operator.  */
@@ -70,17 +61,33 @@ struct riscv_gdbarch_features
   /* Used by std::unordered_map to hash feature sets.  */
   std::size_t hash () const noexcept
   {
-    std::size_t val = ((xlen & 0x1f) << 6
-                       | (flen & 0x1f) << 1
-                       | (hw_float_abi ? 1 : 0));
+    std::size_t val = ((xlen & 0x1f) << 5 | (flen & 0x1f) << 0);
     return val;
   }
 };
 
-/* Create and return a target description that is compatible with
-   FEATURES.  */
+#ifdef GDBSERVER
+
+/* Create and return a target description that is compatible with FEATURES.
+   This is only used directly from the gdbserver where the created target
+   description is modified after it is return.  */
+
+target_desc_up riscv_create_target_description
+       (const struct riscv_gdbarch_features features);
+
+#else
+
+/* Lookup an already existing target description matching FEATURES, or
+   create a new target description if this is the first time we have seen
+   FEATURES.  For the same FEATURES the same target_desc is always
+   returned.  This is important when trying to lookup gdbarch objects as
+   GDBARCH_LIST_LOOKUP_BY_INFO performs a pointer comparison on target
+   descriptions to find candidate gdbarch objects.  */
+
+const target_desc *riscv_lookup_target_description
+       (const struct riscv_gdbarch_features features);
+
+#endif /* GDBSERVER */
 
-const target_desc *riscv_create_target_description
-       (struct riscv_gdbarch_features features);
 
 #endif /* ARCH_RISCV_H */