[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 33/60] target/arm: Store cpregs key in the hash table dire
From: |
Peter Maydell |
Subject: |
Re: [PATCH v3 33/60] target/arm: Store cpregs key in the hash table directly |
Date: |
Fri, 22 Apr 2022 11:46:11 +0100 |
On Sun, 17 Apr 2022 at 19:09, Richard Henderson
<richard.henderson@linaro.org> wrote:
>
> Cast the uint32_t key into a gpointer directly, which
> allows us to avoid allocating storage for each key.
>
> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
> ---
> target/arm/cpu.c | 4 ++--
> target/arm/gdbstub.c | 2 +-
> target/arm/helper.c | 45 ++++++++++++++++++++------------------------
> 3 files changed, 23 insertions(+), 28 deletions(-)
>
> @@ -231,11 +228,9 @@ static void add_cpreg_to_list(gpointer key, gpointer
> opaque)
> static void count_cpreg(gpointer key, gpointer opaque)
> {
> ARMCPU *cpu = opaque;
> - uint64_t regidx;
> const ARMCPRegInfo *ri;
>
> - regidx = *(uint32_t *)key;
> - ri = get_arm_cp_reginfo(cpu->cp_regs, regidx);
> + ri = g_hash_table_lookup(cpu->cp_regs, key);
Here we turn a get_arm_cp_reginfo() call into a direct
g_hash_table_lookup()...
> if (!(ri->type & (ARM_CP_NO_RAW|ARM_CP_ALIAS))) {
> cpu->cpreg_array_len++;
> @@ -5915,16 +5910,17 @@ static void
> define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu)
>
> for (i = 0; i < ARRAY_SIZE(aliases); i++) {
> const struct E2HAlias *a = &aliases[i];
> - ARMCPRegInfo *src_reg, *dst_reg, *new_reg;
> - uint32_t *new_key;
> + const ARMCPRegInfo *dst_reg;
> + ARMCPRegInfo *src_reg;
> + ARMCPRegInfo *new_reg;
> bool ok;
>
> if (a->feature && !a->feature(&cpu->isar)) {
> continue;
> }
>
> - src_reg = g_hash_table_lookup(cpu->cp_regs, &a->src_key);
> - dst_reg = g_hash_table_lookup(cpu->cp_regs, &a->dst_key);
> + src_reg = (ARMCPRegInfo *)get_arm_cp_reginfo(cpu->cp_regs,
> a->src_key);
> + dst_reg = get_arm_cp_reginfo(cpu->cp_regs, a->dst_key);
...but here we turn g_hash_table_lookup() calls into
get_arm_cp_reginfo() calls (necessitating an ugly cast-away-const).
Is there a rationale for when we should use which function ?
> g_assert(src_reg != NULL);
> g_assert(dst_reg != NULL);
thanks
-- PMM
- Re: [PATCH v3 35/60] target/arm: Handle cpreg registration for missing EL, (continued)
- [PATCH v3 28/60] target/arm: Reorg ARMCPRegInfo type field bits, Richard Henderson, 2022/04/17
- [PATCH v3 30/60] target/arm: Name CPState type, Richard Henderson, 2022/04/17
- [PATCH v3 36/60] target/arm: Drop EL3 no EL2 fallbacks, Richard Henderson, 2022/04/17
- [PATCH v3 33/60] target/arm: Store cpregs key in the hash table directly, Richard Henderson, 2022/04/17
- Re: [PATCH v3 33/60] target/arm: Store cpregs key in the hash table directly,
Peter Maydell <=
- [PATCH v3 34/60] target/arm: Cleanup add_cpreg_to_hashtable, Richard Henderson, 2022/04/17
- [PATCH v3 37/60] target/arm: Merge zcr reginfo, Richard Henderson, 2022/04/17
- [PATCH v3 38/60] target/arm: Add isar predicates for FEAT_Debugv8p2, Richard Henderson, 2022/04/17
- [PATCH v3 39/60] target/arm: Adjust definition of CONTEXTIDR_EL2, Richard Henderson, 2022/04/17
- [PATCH v3 31/60] target/arm: Name CPSecureState type, Richard Henderson, 2022/04/17
- [PATCH v3 32/60] target/arm: Update sysreg fields when redirecting for E2H, Richard Henderson, 2022/04/17