From 0ee6b1c511c0e2a6793568692d2e5418cd6bc10d Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Wed, 18 May 2022 13:32:04 -0700 Subject: 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. --- gdb/arch/aarch64.c | 13 ++++++------- gdb/arch/aarch64.h | 40 ++++++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 17 deletions(-) (limited to 'gdb/arch') diff --git a/gdb/arch/aarch64.c b/gdb/arch/aarch64.c index 733a3fd..0f73286 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 8496a03..72ec419 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 +{ + 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 -- cgit v1.1