summaryrefslogtreecommitdiff
path: root/gdb/arch
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2022-05-18 13:32:04 -0700
committerJohn Baldwin <jhb@FreeBSD.org>2022-05-18 13:32:04 -0700
commit0ee6b1c511c0e2a6793568692d2e5418cd6bc10d (patch)
tree9bdc905affb28e3214b29ff650ef51650c020d06 /gdb/arch
parent04dfe7aa52171d110db813bce67c0eea5f4b18cd (diff)
downloadbinutils-gdb-0ee6b1c511c0e2a6793568692d2e5418cd6bc10d.tar.gz
Use aarch64_features to describe register features in target descriptions.
Replace the sve bool member of aarch64_features with a vq member that holds the vector quotient. It is zero if SVE is not present. Add std::hash<> specialization and operator== so that aarch64_features can be used as a key with std::unordered_map<>. Change the various functions that create or lookup aarch64 target descriptions to accept a const aarch64_features object rather than a growing number of arguments. Replace the multi-dimension tdesc_aarch64_list arrays used to cache target descriptions with unordered_maps indexed by aarch64_feature.
Diffstat (limited to 'gdb/arch')
-rw-r--r--gdb/arch/aarch64.c13
-rw-r--r--gdb/arch/aarch64.h40
2 files changed, 36 insertions, 17 deletions
diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c
index 733a3fd6d2a..0f73286f145 100644
--- a/gdb/arch/aarch64.c
+++ b/gdb/arch/aarch64.c
@@ -29,8 +29,7 @@
/* See arch/aarch64.h. */
target_desc *
-aarch64_create_target_description (uint64_t vq, bool pauth_p, bool mte_p,
- bool tls_p)
+aarch64_create_target_description (const aarch64_features &features)
{
target_desc_up tdesc = allocate_target_description ();
@@ -42,19 +41,19 @@ aarch64_create_target_description (uint64_t vq, bool pauth_p, bool mte_p,
regnum = create_feature_aarch64_core (tdesc.get (), regnum);
- if (vq == 0)
+ if (features.vq == 0)
regnum = create_feature_aarch64_fpu (tdesc.get (), regnum);
else
- regnum = create_feature_aarch64_sve (tdesc.get (), regnum, vq);
+ regnum = create_feature_aarch64_sve (tdesc.get (), regnum, features.vq);
- if (pauth_p)
+ if (features.pauth)
regnum = create_feature_aarch64_pauth (tdesc.get (), regnum);
/* Memory tagging extension registers. */
- if (mte_p)
+ if (features.mte)
regnum = create_feature_aarch64_mte (tdesc.get (), regnum);
- if (tls_p)
+ if (features.tls)
regnum = create_feature_aarch64_tls (tdesc.get (), regnum);
return tdesc.release ();
diff --git a/gdb/arch/aarch64.h b/gdb/arch/aarch64.h
index 8496a0341f7..72ec4193eba 100644
--- a/gdb/arch/aarch64.h
+++ b/gdb/arch/aarch64.h
@@ -26,23 +26,43 @@
used to select register sets. */
struct aarch64_features
{
- bool sve = false;
+ /* A non zero VQ value indicates both the presence of SVE and the
+ Vector Quotient - the number of 128bit chunks in an SVE Z
+ register. */
+ uint64_t vq = 0;
+
bool pauth = false;
bool mte = false;
bool tls = false;
};
-/* Create the aarch64 target description. A non zero VQ value indicates both
- the presence of SVE and the Vector Quotient - the number of 128bit chunks in
- an SVE Z register. HAS_PAUTH_P indicates the presence of the PAUTH
- feature.
-
- MTE_P indicates the presence of the Memory Tagging Extension feature.
+inline bool operator==(const aarch64_features &lhs, const aarch64_features &rhs)
+{
+ return lhs.vq == rhs.vq
+ && lhs.pauth == rhs.pauth
+ && lhs.mte == rhs.mte
+ && lhs.tls == rhs.tls;
+}
+
+template<>
+struct std::hash<aarch64_features>
+{
+ std::size_t operator()(const aarch64_features &features) const noexcept
+ {
+ std::size_t h;
+
+ h = features.vq;
+ h = h << 1 | features.pauth;
+ h = h << 1 | features.mte;
+ h = h << 1 | features.tls;
+ return h;
+ }
+};
- TLS_P indicates the presence of the Thread Local Storage feature. */
+/* Create the aarch64 target description. */
-target_desc *aarch64_create_target_description (uint64_t vq, bool has_pauth_p,
- bool mte_p, bool tls_p);
+target_desc *
+ aarch64_create_target_description (const aarch64_features &features);
/* Register numbers of various important registers.
Note that on SVE, the Z registers reuse the V register numbers and the V