From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F1559C4167B for ; Tue, 31 Oct 2023 20:41:38 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qxvXG-0005jn-Po; Tue, 31 Oct 2023 16:40:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qxvXF-0005fU-CO for qemu-riscv@nongnu.org; Tue, 31 Oct 2023 16:40:25 -0400 Received: from mail-yw1-x1132.google.com ([2607:f8b0:4864:20::1132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qxvWr-0007cM-MP for qemu-riscv@nongnu.org; Tue, 31 Oct 2023 16:40:24 -0400 Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-5a7c95b8d14so54920597b3.3 for ; Tue, 31 Oct 2023 13:40:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698784801; x=1699389601; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=u7/QjhdY3KBtGGnqIOs7Ww/gYUu7Gb/03wH1v5rdfK0=; b=Y7H7s60EAP7u1Gt3qivETNYkKGQl0XNP9nUhk+nDkQljeym8RKWKQQ9aBtfdcRMrOF P0IlMRkY3Bxu8653iKE6YR+oYpyQWl6BR/osnmvPdwHdc09b6TowsrWuAxsR0bE6T+MJ 9Zj+t24SV4Dj55ks3lGsAZ0Yy481bUY2Rl3fKJpfJgnJLNOu1PiAVQKLatzudePyR/b2 +t/gIcegWXITKCxYPZaDfEfrE6A78VVQpP0/Kr8cLgo0kMVy2siJcj45KUUwzRUgRh3Y wiqAHNLrSBsiAPRaPP3NtH/8IksJMFNT7cj+iIinZmIulwUn+UcsqLbtoeZQBY4XQ6d1 wi0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698784801; x=1699389601; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=u7/QjhdY3KBtGGnqIOs7Ww/gYUu7Gb/03wH1v5rdfK0=; b=kuUSCKeWxtQbK/8ZsXUfP1w4IvAx1NwuOXiXs3YRz4NdMaRcP0hxIThd+K3UJWnppV qsHkZ1SIF5759+EhX1D0wzRz989JzxsamBbHcZ1in5SWTc1tsgoJRjmeCBF8TXaNwnGl 3ENDbL+BtZMflK6ul3zfItvOd8mOKd4HUWyAw38l2uIuo7NPLVvMof6c8KgfEBXSOxUX Fl+o8b9MAriGe1hMsXOEWrlDUVKPfxhYUM2ClUWoeptHzSDoQurjWCGvf9IgI0mkZZ/3 nk0ZisUfASpiCzHcTLBzFzA39njwgc66M5W8ICoSe/ImU0PsQHUb7CBtCUonOQSlNMCW +9ww== X-Gm-Message-State: AOJu0YxJpN/bfCvSFgyZUCrr2hWfPvhQhj6rZ0NrQZivyVsPlF45l8wp wNz9vQRZTtMRMFl7ezP1l/vxOQ== X-Google-Smtp-Source: AGHT+IGBf1xiktDdB6p0A+YSCjyrHK6NWyBRZG+EbeAU7YX+R8skw19UiOzpwGZm+oGPfC1v+FGAaw== X-Received: by 2002:a81:4521:0:b0:5a7:aa7f:17d5 with SMTP id s33-20020a814521000000b005a7aa7f17d5mr10612710ywa.11.1698784800839; Tue, 31 Oct 2023 13:40:00 -0700 (PDT) Received: from grind.. ([179.193.10.161]) by smtp.gmail.com with ESMTPSA id k1-20020a81ff01000000b005add997ae53sm1272802ywn.81.2023.10.31.13.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 13:40:00 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liweiwei@iscas.ac.cn, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, ajones@ventanamicro.com, Daniel Henrique Barboza Subject: [PATCH v7 13/16] target/riscv/tcg: add hash table insert helpers Date: Tue, 31 Oct 2023 17:39:13 -0300 Message-ID: <20231031203916.197332-14-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231031203916.197332-1-dbarboza@ventanamicro.com> References: <20231031203916.197332-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1132; envelope-from=dbarboza@ventanamicro.com; helo=mail-yw1-x1132.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Sender: qemu-riscv-bounces+qemu-riscv=archiver.kernel.org@nongnu.org Previous patches added several g_hash_table_insert() patterns. Add two helpers, one for each user hash, to make the code cleaner. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Andrew Jones --- target/riscv/tcg/tcg-cpu.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 4a915acff4..9127249f85 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -42,6 +42,18 @@ static bool cpu_cfg_ext_is_user_set(uint32_t ext_offset) GUINT_TO_POINTER(ext_offset)); } +static void cpu_cfg_ext_add_user_opt(uint32_t ext_offset, bool value) +{ + g_hash_table_insert(multi_ext_user_opts, GUINT_TO_POINTER(ext_offset), + (gpointer)value); +} + +static void cpu_misa_ext_add_user_opt(uint32_t bit, bool value) +{ + g_hash_table_insert(misa_ext_user_opts, GUINT_TO_POINTER(bit), + (gpointer)value); +} + static void riscv_cpu_write_misa_bit(RISCVCPU *cpu, uint32_t bit, bool enabled) { @@ -715,9 +727,7 @@ static void cpu_set_misa_ext_cfg(Object *obj, Visitor *v, const char *name, return; } - g_hash_table_insert(misa_ext_user_opts, - GUINT_TO_POINTER(misa_bit), - (gpointer)value); + cpu_misa_ext_add_user_opt(misa_bit, value); prev_val = env->misa_ext & misa_bit; @@ -844,18 +854,14 @@ static void cpu_set_profile(Object *obj, Visitor *v, const char *name, continue; } - g_hash_table_insert(misa_ext_user_opts, - GUINT_TO_POINTER(bit), - (gpointer)value); + cpu_misa_ext_add_user_opt(bit, profile->enabled); riscv_cpu_write_misa_bit(cpu, bit, profile->enabled); } for (i = 0; profile->ext_offsets[i] != RISCV_PROFILE_EXT_LIST_END; i++) { ext_offset = profile->ext_offsets[i]; - g_hash_table_insert(multi_ext_user_opts, - GUINT_TO_POINTER(ext_offset), - (gpointer)profile->enabled); + cpu_cfg_ext_add_user_opt(ext_offset, profile->enabled); isa_ext_update_enabled(cpu, ext_offset, profile->enabled); } } @@ -918,9 +924,7 @@ static void cpu_set_multi_ext_cfg(Object *obj, Visitor *v, const char *name, multi_ext_cfg->name, lower); } - g_hash_table_insert(multi_ext_user_opts, - GUINT_TO_POINTER(multi_ext_cfg->offset), - (gpointer)value); + cpu_cfg_ext_add_user_opt(multi_ext_cfg->offset, value); prev_val = isa_ext_is_enabled(cpu, multi_ext_cfg->offset); -- 2.41.0