From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 05/19] Convert target-descriptions.c to new hash table
Date: Fri, 07 Apr 2023 09:25:37 -0600 [thread overview]
Message-ID: <20230407-t-robin-hood-hash-v1-5-900d93ef1510@tromey.com> (raw)
In-Reply-To: <20230407-t-robin-hood-hash-v1-0-900d93ef1510@tromey.com>
This converts target-descriptions.c to use the new hash table. This
is an example of using the standard traits -- i.e., std::hash and
operator==.
---
gdb/target-descriptions.c | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c
index 7ae9058b2f2..a06c7d885e2 100644
--- a/gdb/target-descriptions.c
+++ b/gdb/target-descriptions.c
@@ -31,7 +31,7 @@
#include "osabi.h"
#include "gdbsupport/gdb_obstack.h"
-#include "hashtab.h"
+#include "gdbsupport/hash-table.h"
#include "inferior.h"
#include <algorithm>
#include "completer.h"
@@ -1047,14 +1047,11 @@ tdesc_use_registers (struct gdbarch *gdbarch,
/* Build up a set of all registers, so that we can assign register
numbers where needed. The hash table expands as necessary, so
the initial size is arbitrary. */
- htab_up reg_hash (htab_create (37, htab_hash_pointer, htab_eq_pointer,
- NULL));
+ gdb::hash_set<tdesc_reg *> reg_hash;
for (const tdesc_feature_up &feature : target_desc->features)
for (const tdesc_reg_up ® : feature->registers)
{
- void **slot = htab_find_slot (reg_hash.get (), reg.get (), INSERT);
-
- *slot = reg.get ();
+ reg_hash.insert (reg.get ());
/* Add reggroup if its new. */
if (!reg->group.empty ())
if (reggroup_find (gdbarch, reg->group.c_str ()) == NULL)
@@ -1067,7 +1064,7 @@ tdesc_use_registers (struct gdbarch *gdbarch,
architecture. */
for (const tdesc_arch_reg &arch_reg : data->arch_regs)
if (arch_reg.reg != NULL)
- htab_remove_elt (reg_hash.get (), arch_reg.reg);
+ reg_hash.erase (arch_reg.reg);
/* Assign numbers to the remaining registers and add them to the
list of registers. The new numbers are always above gdbarch_num_regs.
@@ -1085,7 +1082,7 @@ tdesc_use_registers (struct gdbarch *gdbarch,
{
for (const tdesc_feature_up &feature : target_desc->features)
for (const tdesc_reg_up ® : feature->registers)
- if (htab_find (reg_hash.get (), reg.get ()) != NULL)
+ if (reg_hash.contains (reg.get ()))
{
int regno = unk_reg_cb (gdbarch, feature.get (),
reg->name.c_str (), num_regs);
@@ -1096,7 +1093,7 @@ tdesc_use_registers (struct gdbarch *gdbarch,
data->arch_regs.emplace_back (nullptr, nullptr);
data->arch_regs[regno] = tdesc_arch_reg (reg.get (), NULL);
num_regs = regno + 1;
- htab_remove_elt (reg_hash.get (), reg.get ());
+ reg_hash.erase (reg.get ());
}
}
}
@@ -1108,7 +1105,7 @@ tdesc_use_registers (struct gdbarch *gdbarch,
unnumbered registers. */
for (const tdesc_feature_up &feature : target_desc->features)
for (const tdesc_reg_up ® : feature->registers)
- if (htab_find (reg_hash.get (), reg.get ()) != NULL)
+ if (reg_hash.contains (reg.get ()))
{
data->arch_regs.emplace_back (reg.get (), nullptr);
num_regs++;
--
2.39.2
next prev parent reply other threads:[~2023-04-07 15:25 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-07 15:25 [PATCH 00/19] Add hash table to gdbsupport Tom Tromey
2023-04-07 15:25 ` [PATCH 01/19] Add a " Tom Tromey
2023-04-07 15:41 ` Tom Tromey
2023-04-07 15:25 ` [PATCH 02/19] Convert compile-c-symbols.c to new hash table Tom Tromey
2023-04-07 15:25 ` [PATCH 03/19] Convert filename-seen-cache.h " Tom Tromey
2023-04-07 15:25 ` [PATCH 04/19] Convert linespec.c " Tom Tromey
2023-04-07 15:25 ` Tom Tromey [this message]
2023-04-07 15:25 ` [PATCH 06/19] Convert dwarf2/macro.c " Tom Tromey
2023-04-07 15:25 ` [PATCH 07/19] Convert breakpoint.c " Tom Tromey
2023-04-07 15:25 ` [PATCH 08/19] Convert py-framefilter.c " Tom Tromey
2023-04-07 15:25 ` [PATCH 09/19] Convert disasm.c " Tom Tromey
2023-04-07 15:25 ` [PATCH 10/19] Convert compile/compile.c " Tom Tromey
2023-04-07 15:25 ` [PATCH 11/19] Convert type copying " Tom Tromey
2023-04-07 15:25 ` [PATCH 12/19] Convert static links " Tom Tromey
2023-04-07 15:25 ` [PATCH 13/19] Convert gnu-v3-abi.c " Tom Tromey
2023-04-07 15:25 ` [PATCH 14/19] Convert abbrev cache " Tom Tromey
2023-04-07 15:25 ` [PATCH 15/19] Convert abbrevs " Tom Tromey
2023-04-07 15:25 ` [PATCH 16/19] Convert typedef hash " Tom Tromey
2023-04-07 15:25 ` [PATCH 17/19] Convert all_bfds " Tom Tromey
2023-04-07 15:25 ` [PATCH 18/19] Convert more DWARF code " Tom Tromey
2023-04-07 15:25 ` [PATCH 19/19] Convert gdb_bfd.c " Tom Tromey
2023-04-10 19:45 ` [PATCH 00/19] Add hash table to gdbsupport John Baldwin
2023-11-03 18:54 ` Tom Tromey
2023-12-08 18:28 ` Tom Tromey
2024-01-11 18:07 ` Tom Tromey
2024-01-11 19:35 ` John Baldwin
2024-01-12 2:57 ` Simon Marchi
2024-01-12 18:22 ` Tom Tromey
2024-01-12 19:12 ` Simon Marchi
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=20230407-t-robin-hood-hash-v1-5-900d93ef1510@tromey.com \
--to=tom@tromey.com \
--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).