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. --- gdbserver/linux-aarch64-ipa.cc | 4 ++-- gdbserver/linux-aarch64-low.cc | 11 ++++------- gdbserver/linux-aarch64-tdesc.cc | 18 +++++++++--------- gdbserver/linux-aarch64-tdesc.h | 6 ++++-- gdbserver/netbsd-aarch64-low.cc | 2 +- 5 files changed, 20 insertions(+), 21 deletions(-) (limited to 'gdbserver') diff --git a/gdbserver/linux-aarch64-ipa.cc b/gdbserver/linux-aarch64-ipa.cc index dc907d3..918f85f 100644 --- a/gdbserver/linux-aarch64-ipa.cc +++ b/gdbserver/linux-aarch64-ipa.cc @@ -152,7 +152,7 @@ get_raw_reg (const unsigned char *raw_regs, int regnum) const struct target_desc * get_ipa_tdesc (int idx) { - return aarch64_linux_read_description (0, false, false, false); + return aarch64_linux_read_description ({}); } /* Allocate buffer for the jump pads. The branch instruction has a reach @@ -205,5 +205,5 @@ void initialize_low_tracepoint (void) { /* SVE, pauth, MTE and TLS not yet supported. */ - aarch64_linux_read_description (0, false, false, false); + aarch64_linux_read_description ({}); } diff --git a/gdbserver/linux-aarch64-low.cc b/gdbserver/linux-aarch64-low.cc index ba0a810..db50869 100644 --- a/gdbserver/linux-aarch64-low.cc +++ b/gdbserver/linux-aarch64-low.cc @@ -779,11 +779,11 @@ aarch64_adjust_register_sets (const struct aarch64_features &features) break; case NT_FPREGSET: /* This is unavailable when SVE is present. */ - if (!features.sve) + if (features.vq == 0) regset->size = sizeof (struct user_fpsimd_state); break; case NT_ARM_SVE: - if (features.sve) + if (features.vq > 0) regset->size = SVE_PT_SIZE (AARCH64_MAX_SVE_VQ, SVE_PT_REGS_SVE); break; case NT_ARM_PAC_MASK: @@ -824,17 +824,14 @@ aarch64_target::low_arch_setup () { struct aarch64_features features; - uint64_t vq = aarch64_sve_get_vq (tid); - features.sve = (vq > 0); + features.vq = aarch64_sve_get_vq (tid); /* A-profile PAC is 64-bit only. */ features.pauth = linux_get_hwcap (8) & AARCH64_HWCAP_PACA; /* A-profile MTE is 64-bit only. */ features.mte = linux_get_hwcap2 (8) & HWCAP2_MTE; features.tls = true; - current_process ()->tdesc - = aarch64_linux_read_description (vq, features.pauth, features.mte, - features.tls); + current_process ()->tdesc = aarch64_linux_read_description (features); /* Adjust the register sets we should use for this particular set of features. */ diff --git a/gdbserver/linux-aarch64-tdesc.cc b/gdbserver/linux-aarch64-tdesc.cc index be96612..93f2bed 100644 --- a/gdbserver/linux-aarch64-tdesc.cc +++ b/gdbserver/linux-aarch64-tdesc.cc @@ -25,36 +25,36 @@ #include "arch/aarch64.h" #include "linux-aarch32-low.h" #include +#include /* All possible aarch64 target descriptors. */ -struct target_desc *tdesc_aarch64_list[AARCH64_MAX_SVE_VQ + 1][2/*pauth*/][2 /* mte */][2 /* tls */]; +static std::unordered_map tdesc_aarch64_map; /* Create the aarch64 target description. */ const target_desc * -aarch64_linux_read_description (uint64_t vq, bool pauth_p, bool mte_p, - bool tls_p) +aarch64_linux_read_description (const aarch64_features &features) { - if (vq > AARCH64_MAX_SVE_VQ) - error (_("VQ is %" PRIu64 ", maximum supported value is %d"), vq, + if (features.vq > AARCH64_MAX_SVE_VQ) + error (_("VQ is %" PRIu64 ", maximum supported value is %d"), features.vq, AARCH64_MAX_SVE_VQ); - struct target_desc *tdesc = tdesc_aarch64_list[vq][pauth_p][mte_p][tls_p]; + struct target_desc *tdesc = tdesc_aarch64_map[features]; if (tdesc == NULL) { - tdesc = aarch64_create_target_description (vq, pauth_p, mte_p, tls_p); + tdesc = aarch64_create_target_description (features); static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL }; static const char *expedite_regs_aarch64_sve[] = { "x29", "sp", "pc", "vg", NULL }; - if (vq == 0) + if (features.vq == 0) init_target_desc (tdesc, expedite_regs_aarch64); else init_target_desc (tdesc, expedite_regs_aarch64_sve); - tdesc_aarch64_list[vq][pauth_p][mte_p][tls_p] = tdesc; + tdesc_aarch64_map[features] = tdesc; } return tdesc; diff --git a/gdbserver/linux-aarch64-tdesc.h b/gdbserver/linux-aarch64-tdesc.h index 4ab6584..30bcd24 100644 --- a/gdbserver/linux-aarch64-tdesc.h +++ b/gdbserver/linux-aarch64-tdesc.h @@ -20,7 +20,9 @@ #ifndef GDBSERVER_LINUX_AARCH64_TDESC_H #define GDBSERVER_LINUX_AARCH64_TDESC_H -const target_desc * aarch64_linux_read_description (uint64_t vq, bool pauth_p, - bool mte_p, bool tls_p); +#include "arch/aarch64.h" + +const target_desc * + aarch64_linux_read_description (const aarch64_features &features); #endif /* GDBSERVER_LINUX_AARCH64_TDESC_H */ diff --git a/gdbserver/netbsd-aarch64-low.cc b/gdbserver/netbsd-aarch64-low.cc index b371e59..f8447b0 100644 --- a/gdbserver/netbsd-aarch64-low.cc +++ b/gdbserver/netbsd-aarch64-low.cc @@ -96,7 +96,7 @@ void netbsd_aarch64_target::low_arch_setup () { target_desc *tdesc - = aarch64_create_target_description (0, false, false, false); + = aarch64_create_target_description ({}); static const char *expedite_regs_aarch64[] = { "x29", "sp", "pc", NULL }; init_target_desc (tdesc, expedite_regs_aarch64); -- cgit v1.1