From patchwork Fri Jan 26 22:03:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 766397 Delivered-To: patch@linaro.org Received: by 2002:adf:a314:0:b0:337:62d3:c6d5 with SMTP id c20csp453849wrb; Fri, 26 Jan 2024 14:09:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEJJZpUdi1W3W4qShm0Pwe9P7S6gtqC9PpZJlWV2zYoBaj8k51PWq9rrsWqKCd+n4WNEJUo X-Received: by 2002:ad4:5768:0:b0:686:b0f2:5825 with SMTP id r8-20020ad45768000000b00686b0f25825mr762242qvx.69.1706306952777; Fri, 26 Jan 2024 14:09:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706306952; cv=none; d=google.com; s=arc-20160816; b=Fzt/zRwbILum8CaNI9KaHENoiproI0ga87mABQRRQBHO2O15rKq7IoWjXA12fkE+JU 4ZpvBudiRJOhni/vYwy+z5WWVsiQjikoy0qFlx40eT4bhecs+TSUFiE61RXGH4x/Y0e3 ohWGLPbxApRAa2WQ73yqhayt2JZIKBkHBMS0S68i9F/eglM+YRnVmrYsNVX+KU1Wtecg RpPcj7AwqoMoXMIn0LOeD/+InWM/Oh1rqwx7NulkLX2oGCFdQd0k8g1+6JWZhGrYbzLB Ovq+VKMB0cPYnfL+ZiYQ5LovwHBxg8UZdKBXLr6LeK+A7q6YJLzjRrqGVBHUQQFttOhA OMSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FFJLEX8dK90+jos80xXDDodOgI2wmwmhf0FUxCQuinw=; fh=lI5Wsv05ExsjZmYkykW8Qpb9ZaT0Mbjky7yp+criv00=; b=giJ2fcaGEFjRsSnyf6LIfnYhYM8lPZkn/zGBmvY3afEgazxHO+cKblukD5h8pFTJ23 kd56J9eHgbJ8FqHq6rG51mjm02uKeRVlZDr3Z3vFmILg/hWMrwDKSMIgBYSQ0ve+2sn6 GXnnkm1iwba9D0DCXrwL5ywlYMacXo3DciNun9GpieDElnXsdMFBFGlJt682R6v8OPES Y1UZiC4FrkFCMamcZUBreD7ra/EwJ+su6dwdn2NFJALNyMQgk6554OCSaZVCDHrvM0Vd Ty+bjYHn2/cznCzrBRoS/n0Il9Icbt7/S9NfIuIbmT4pHFsyWVb0iD8HSyUgyNaV57wp ImAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cz5GAQzX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r11-20020ad4576b000000b00683cd055183si2287805qvx.230.2024.01.26.14.09.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2024 14:09:12 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Cz5GAQzX; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rTUKu-0001oG-4e; Fri, 26 Jan 2024 17:06:08 -0500 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 1rTUKS-0000A7-Ll for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:05:41 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rTUKP-0004Cj-Hd for qemu-devel@nongnu.org; Fri, 26 Jan 2024 17:05:40 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40e7065b7bdso17231575e9.3 for ; Fri, 26 Jan 2024 14:05:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1706306735; x=1706911535; 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=FFJLEX8dK90+jos80xXDDodOgI2wmwmhf0FUxCQuinw=; b=Cz5GAQzXyFWJQnda5cT/mRJM4/z+9llym5n18wu+pTRcQrYEHaes3+dEXrVr6SD9uc FNP+8aFBPxkUuI/D0SE7WtV1oXxNiaxJjjTw5N2NJTNEKJ1S+q+AmW1lDbMDdYQMVR7I Cvc6Xb4bCKD809lorEV4AyW4b0DqPpiE5reWpKzzAyhCwPlOqqYHGSUlPhjAIzLcwVAL xtGMyOTmrXIjzbZ+B4qfuhLqge3ot7bqed4Pzu+V2ewdgVL0z+h8Ei/UE6XsvnSrOQlo HE0CpHaWNX6mtbQW6CedRX1yGukZP7rxMEQMyz9wwBOcaDbGvlJz45WwZXxdYTrfUYrx ooDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706306735; x=1706911535; 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=FFJLEX8dK90+jos80xXDDodOgI2wmwmhf0FUxCQuinw=; b=O5gKakjdt3l919lYXTgvF6SIzEx0AZCKYn+O03TWTeK9yN4qbGDfA+wh1mCcOVkfSm UOZWgpdmInshHUwuqheVz+wF/YBxxxD67T3/utunF8GGqcZJVzoBM3cOcuDvwxy1m3LE /rQGEC/y6I7tWJuAKvj0i9//6GEJqA2CPtkqmSBhGJ4zzIYIm2G9NQkeqAYLpl4VpO0l lAc8QLMT/DqFR7p7YvGbkNdQVDnnXKCmg2ZhVhYzDVmuoaWbQftmKDEwyyFRd1NaKTj/ vL7hTV85cSg5Ky1rxzEPqvWFRP8qiq2Zz3YeKLB6WRxaRU0SI2QJtLjL0kkJshEOTQkX 0z2Q== X-Gm-Message-State: AOJu0Yz0xvFjJdZNsTJ4I27yv6QLnSq4oJEFxIHA6LqZqB5sib75jv27 /wxEiwEa/wC4gIPnewCjqkWPaOq3wdkIkZA1olM2wTZBB3mZngJNZyrphccd/9f6RiPMDF5bEG6 Q X-Received: by 2002:a05:600c:2246:b0:40e:e944:154a with SMTP id a6-20020a05600c224600b0040ee944154amr243867wmm.198.1706306735629; Fri, 26 Jan 2024 14:05:35 -0800 (PST) Received: from m1x-phil.lan ([176.176.142.39]) by smtp.gmail.com with ESMTPSA id s6-20020a1709060c0600b00a2a37f63216sm1056778ejf.171.2024.01.26.14.05.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 26 Jan 2024 14:05:35 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Thomas Huth , qemu-s390x@nongnu.org, qemu-riscv@nongnu.org, Eduardo Habkost , kvm@vger.kernel.org, qemu-ppc@nongnu.org, Richard Henderson , Vladimir Sementsov-Ogievskiy , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Chris Wulff , Marek Vasut Subject: [PATCH v2 14/23] target/nios2: Prefer fast cpu_env() over slower CPU QOM cast macro Date: Fri, 26 Jan 2024 23:03:56 +0100 Message-ID: <20240126220407.95022-15-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240126220407.95022-1-philmd@linaro.org> References: <20240126220407.95022-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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, T_SCC_BODY_TEXT_LINE=-0.01 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Mechanical patch produced running the command documented in scripts/coccinelle/cpu_env.cocci_template header. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/nios2/cpu.c | 15 +++------------ target/nios2/helper.c | 3 +-- target/nios2/nios2-semi.c | 6 ++---- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index a27732bf2b..a2eaf35c1a 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -28,28 +28,19 @@ static void nios2_cpu_set_pc(CPUState *cs, vaddr value) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; - - env->pc = value; + cpu_env(cs)->pc = value; } static vaddr nios2_cpu_get_pc(CPUState *cs) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; - - return env->pc; + return cpu_env(cs)->pc; } static void nios2_restore_state_to_opc(CPUState *cs, const TranslationBlock *tb, const uint64_t *data) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; - - env->pc = data[0]; + cpu_env(cs)->pc = data[0]; } static bool nios2_cpu_has_work(CPUState *cs) diff --git a/target/nios2/helper.c b/target/nios2/helper.c index bb3b09e5a7..ac57121afc 100644 --- a/target/nios2/helper.c +++ b/target/nios2/helper.c @@ -287,8 +287,7 @@ void nios2_cpu_do_unaligned_access(CPUState *cs, vaddr addr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; + CPUNios2State *env = cpu_env(cs); env->ctrl[CR_BADADDR] = addr; cs->exception_index = EXCP_UNALIGN; diff --git a/target/nios2/nios2-semi.c b/target/nios2/nios2-semi.c index 0b84fcb6b6..420702e293 100644 --- a/target/nios2/nios2-semi.c +++ b/target/nios2/nios2-semi.c @@ -75,8 +75,7 @@ static int host_to_gdb_errno(int err) static void nios2_semi_u32_cb(CPUState *cs, uint64_t ret, int err) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; + CPUNios2State *env = cpu_env(cs); target_ulong args = env->regs[R_ARG1]; if (put_user_u32(ret, args) || @@ -93,8 +92,7 @@ static void nios2_semi_u32_cb(CPUState *cs, uint64_t ret, int err) static void nios2_semi_u64_cb(CPUState *cs, uint64_t ret, int err) { - Nios2CPU *cpu = NIOS2_CPU(cs); - CPUNios2State *env = &cpu->env; + CPUNios2State *env = cpu_env(cs); target_ulong args = env->regs[R_ARG1]; if (put_user_u32(ret >> 32, args) ||