From nobody Wed Nov 27 16:31:22 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1698277637; cv=none; d=zohomail.com; s=zohoarc; b=mRj0Q5SQBKb2/I1TwqDuQixic2un1Qy0eGUEqpOHn9O3yzpx+CG1nZTixMXfR2tW8dhNghf4JnNoN/4afnCK0jwqqVo6xS/t+4cvG+NN0S9+Smme2ZNEkyEJdpRA5ZOiW+tfyfGCo6Ze+9fqxSIIY2gJLwhtaYdXrPiFAFr5aPw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698277637; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=3jz6QPtK8VtnFWFXVTNqCUkfRcOHZqUbOgSb1yU0vAY=; b=ceNu30cOB/M7P1s7pNVN13B8M0hr2Vc2jenkut6bQsm1GuUzgu7nxEfko+SH9zC87ZQ5CwcTzw+7MihpIdJzv22wCsPk2TtbVDAfbtbP79FoiVbLOzxN9CwSR9ca/D0qbF3dFwCGmcTAcH5iz9kM+qzOMri1VlHB/J0jmDvUNfQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698277637248627.0754150947857; Wed, 25 Oct 2023 16:47:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvnZM-000110-UD; Wed, 25 Oct 2023 19:45:48 -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 1qvnZD-0000xl-2c for qemu-devel@nongnu.org; Wed, 25 Oct 2023 19:45:40 -0400 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvnZB-0002Jw-EP for qemu-devel@nongnu.org; Wed, 25 Oct 2023 19:45:38 -0400 Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1c9a1762b43so2077945ad.1 for ; Wed, 25 Oct 2023 16:45:36 -0700 (PDT) Received: from grind.. ([191.255.2.33]) by smtp.gmail.com with ESMTPSA id w14-20020a170902e88e00b001c736746d33sm9738654plg.217.2023.10.25.16.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 16:45:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1698277534; x=1698882334; 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=3jz6QPtK8VtnFWFXVTNqCUkfRcOHZqUbOgSb1yU0vAY=; b=BelH3bdTXh0TJ62lOlppRQfSLqhuNelHN8blRuKmkoQZUeaN3bzkO6+ANu2VPo9cZs hEgwwctQp6CwMzf1iv15i8MMHw/Au8DzDJZlZYyQUGZd7uLFp7CEOS7WUE8l0Aeb9/Fq S73kk2pPp61414C4PsHnWXGTKvYW4cE/JRW223tYBH0NjiGHhLIthUAd6WBJ4/U0rAST HbV2uhRnaLdciyfbDm5x12WBI/TCHK/6A8UX+zJqeYvpPQzKDQtK6KZtx9xF7v1zVQL1 /9TG15I+txLYNWy0yDMsVRlDmxx+RnM/iOvt/gpXKCr7KEYH3aPCLqCrRnahAlNB2yQs gv3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698277534; x=1698882334; 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=3jz6QPtK8VtnFWFXVTNqCUkfRcOHZqUbOgSb1yU0vAY=; b=CsfagLvp3qhLZY3ULf+ljP10YDdHVlVfK4uYJAa0RsBqSiMvcwzyix1wkt1BtT2D8H rc7KuO+0oVDxWStqolzpkmonAMpmxJG2QXlXC6pSCli7YvYVys9Z1GwHMF9jQpVp61C4 EesOpSfBX6lmgq640Odaxlr3VWtmcfkWrswz2s8GSqamiyfZM98/uQxdIiMYAwHFqeB3 BJ7Jpxe3RMUHb++GnE5l0+MPMRtTwXBctGJ2fhpDUbFsQ8s+kwgupKxR1QZ85LwDTT1s UMz4Tu9qmY/O+4tfzp4tepjIvSmfIPe3jyIzw1l2x7oa4Vj5qDE1Sz/l+a50sZjTrVnt XIiA== X-Gm-Message-State: AOJu0YxrqqABR+rdBsLjAvLtRbPNjCAeqTQl9PqOI3c0YtJigTUpw7pN Ke9V0KoSCWafb8HLepOM+ZiuDMQ5YxZwAUm/fCo= X-Google-Smtp-Source: AGHT+IHQxgvj8qXQWpfSUUtGMo0gGNF588ZheTm2oxeF79XYehYmmfuS+pugR3fCKWYTrX527C9Q8w== X-Received: by 2002:a17:903:84c:b0:1ca:1be4:bda4 with SMTP id ks12-20020a170903084c00b001ca1be4bda4mr15200297plb.4.1698277534273; Wed, 25 Oct 2023 16:45:34 -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 v5 08/10] target/riscv/tcg: add hash table insert helpers Date: Wed, 25 Oct 2023 20:44:57 -0300 Message-ID: <20231025234459.581697-9-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231025234459.581697-1-dbarboza@ventanamicro.com> References: <20231025234459.581697-1-dbarboza@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::62a; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x62a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@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-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1698277638427100005 Content-Type: text/plain; charset="utf-8" Latest 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 4f4bc58627..423328b1c7 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)); } =20 +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) { @@ -721,9 +733,7 @@ static void cpu_set_misa_ext_cfg(Object *obj, Visitor *= v, const char *name, return; } =20 - g_hash_table_insert(misa_ext_user_opts, - GUINT_TO_POINTER(misa_bit), - (gpointer)value); + cpu_misa_ext_add_user_opt(misa_bit, value); =20 prev_val =3D env->misa_ext & misa_bit; =20 @@ -836,18 +846,14 @@ static void cpu_set_profile(Object *obj, Visitor *v, = const char *name, continue; } =20 - 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); } =20 for (i =3D 0; profile->ext_offsets[i] !=3D RISCV_PROFILE_EXT_LIST_END;= i++) { ext_offset =3D profile->ext_offsets[i]; =20 - 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); } } @@ -910,9 +916,7 @@ static void cpu_set_multi_ext_cfg(Object *obj, Visitor = *v, const char *name, multi_ext_cfg->name, lower); } =20 - 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); =20 prev_val =3D isa_ext_is_enabled(cpu, multi_ext_cfg->offset); =20 --=20 2.41.0