From patchwork Fri Dec 20 16:15:34 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: 852431 Delivered-To: patch@linaro.org Received: by 2002:a5d:4888:0:b0:385:e875:8a9e with SMTP id g8csp2147417wrq; Fri, 20 Dec 2024 08:22:46 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWNVoEw4Nc934S+F1+yT5uwz6fKnisy9Zhxzib+DHGzC2XEH9Wfge9l52yiFjqYoNPg9vEg5g==@linaro.org X-Google-Smtp-Source: AGHT+IFp8kUG3SRLUwNP6NRDDDSs9Dg5gG10hiNbZ177IZamfiMXGEnWqhrluH3ksSwR4ooEZfSG X-Received: by 2002:a05:6214:27eb:b0:6dd:c91:73d4 with SMTP id 6a1803df08f44-6dd233a78c3mr58051946d6.49.1734711766758; Fri, 20 Dec 2024 08:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1734711766; cv=none; d=google.com; s=arc-20240605; b=Pf9Wk4t9EN6PNSFW4bOYk2kQ+qe95s6WxAEJ92goUmnHjv2w8hFL3uSEtNlRbkupR4 ULzrmEzkp4d7eliY0BBKe+IolJgsGqDGWv5P1k0UUhlijaGZHpDxk24NjOT0pXX+Cbvx EdIogkr06/oP/agcHOYbRLhiLr4JCy78cjdWN2lS+iyZ4lvgsEHR3F7NX/7JLHQ/Uh6p v0G5lwrgYO+N3wFGbNa1cD0DhvdCbpzy8J5I/xgRIl7Th62evNi1yTijxtBQ0Pcpkq8j 0VQXlQCS9AN9MNbRnu8I/0G9OLuyxnwQ5Svt0tGB1lgXQQTtQzCMAU3mq/sn9OUFZDpG ixuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; 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=cJe0InTlBUAjWEm5xiP9chgyYvTxYPda1BH0conYBG8=; fh=lWrt2iJqA36PKDJD9wOt2v37c1AMexkdbZlHxbViPQ4=; b=AU8pgNSX76s6Y/y52HeGUNmhn3lmhVYZJ03GEud70LuKMP3Qjo5Jp6H1IvZWuzMclQ PfVB15hpAF88rbxSOOICmILMicw/qzUNjIjMwtwOw9rKzl3Y859S+w6rC1Veh/IF8zVu 4BuAnvg2k6CBj6SKAUWxKSK0CKQ7BiQVl76D7cFrMLAZJPHZDL4pSWrmIMMgCaTGRoU7 DkTi4txW+mdvlAPg2ayTPKMkJbcOqVV1nYS3tZ+QzBsG9bWA5JoAxANRPEzYXjRJaPsz k8E4sBVkP3uixUiA7xk9sZ1aP6jNBRQjFGN86Zt26VzHLfrdoakP0QvlujE7sda+jJWh Vihw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Augm+Ect; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6dd18136bf2si46711256d6.115.2024.12.20.08.22.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Dec 2024 08:22:46 -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=Augm+Ect; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tOfih-0003TL-VF; Fri, 20 Dec 2024 11:19:20 -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 1tOfib-0002ag-AC for qemu-devel@nongnu.org; Fri, 20 Dec 2024 11:19:13 -0500 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tOfiZ-0008Ef-3J for qemu-devel@nongnu.org; Fri, 20 Dec 2024 11:19:12 -0500 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-4363dc916ceso20263875e9.0 for ; Fri, 20 Dec 2024 08:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1734711549; x=1735316349; 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=cJe0InTlBUAjWEm5xiP9chgyYvTxYPda1BH0conYBG8=; b=Augm+EctumBWNE4fvhGKn9LM5N3am0WXEVunz4CnOV37CBGJhJQusguiixpBvkanJn DthbjDRSw7hYYAfGapIF0pm4x5yK2n46crExZEVV0+XxtKMtwyuuul3DsSnD3+0A94FW kUJLk4HLDZc5+JuyUnnjYCvq7yQEpa5QotLR/U3e0F+o6m5PJk0PcuMPRTYOVPJdCdkN KvzBLYMR/KBdUYYkrrE9ofKTo1UZ+/z8URxuKBPO71wQ7LSKFeCsCoqqLmgI8GXRotYG kJlw38atx5UujoW+whjVVsd9TPD1Nt6DYJqg+DuPPhrXoe2RIwfwXy/VGMDHAMHcoP9x EmgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734711549; x=1735316349; 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=cJe0InTlBUAjWEm5xiP9chgyYvTxYPda1BH0conYBG8=; b=RPZ6RfYsvhe1dNxYgANSM7q4yTxDyyuRHFhmLHxLSe5asyABFrAK0laQGS9wkpvd/X OnMcUuVFIQJY8L2vUWKklsAjvqZnIhu0NFNSC5VudA28E35ZY2sn21vsWiOo08KY2Pqh 0chxRFW0fhiBm2ZjWQEIHIC/7+CJu3vvmLWjOYSkMHaITh9wMtd2L4JOGm6DGd9U0jNS Swrk7iPdr2IL/RrO3WK1rYfOe4DU0OnKVfWiWwi9Ep2kVdBws+fBjIp2hhtxkyad+yQL hrVW2+UPQEx+qrO/xPXCaeyXI4E+WNdTO2MAAzKkinlv8SaizduVioapSvmHnas9onTA lQaQ== X-Gm-Message-State: AOJu0YyTmPzT3EABIP/h7ZldTt7qI02e+aLaLBh0taR7kvIbPQFIwqEd NjfpStfEOYuinFjFM/dnXJ3LyFOmqNRvs6ItvQCQoySQs7ztIgvRZYvsOz+t3qRg/rue8ifRRqj c X-Gm-Gg: ASbGncvWSIxBrg9teTIpJnkr7rpEswXlFqqF0Zpro3Npw+ZY327XAtGEQiObfdbFeAn 6oWkxm20x3zJqmoYVuOzgUCcjIU7IFdxBbDwNp41aVSnxD548ovC/CWrkzFP54mkQUCxc9a9bbw tVnDmIe22Fq1cGZyTVU0A8MnIhSSES2TfzE+2URi+FwCh297Eqt+lv71/AW49ZuavMp5gSio4Ng AEgciVVNGbognnfVMQd9qRYLMnl58fJWjmAq223C35uNoAKv+Wr7xBffwVrraiC9SLc9CEkBVY= X-Received: by 2002:a5d:59a4:0:b0:385:df17:2148 with SMTP id ffacd0b85a97d-38a1a2641b7mr6518026f8f.20.1734711549419; Fri, 20 Dec 2024 08:19:09 -0800 (PST) Received: from localhost.localdomain ([78.196.4.158]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8474a9sm4353134f8f.52.2024.12.20.08.19.08 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 20 Dec 2024 08:19:08 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Richard Henderson , Peter Maydell Subject: [PULL 43/59] target/sparc: Move sparc_restore_state_to_opc() to cpu.c Date: Fri, 20 Dec 2024 17:15:34 +0100 Message-ID: <20241220161551.89317-44-philmd@linaro.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241220161551.89317-1-philmd@linaro.org> References: <20241220161551.89317-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=philmd@linaro.org; helo=mail-wm1-x32a.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=ham 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 Most targets define their restore_state_to_opc() handler in cpu.c. In order to keep SPARC aligned, move sparc_restore_state_to_opc() from translate.c to cpu.c. Suggested-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Message-Id: <20241115152053.66442-4-philmd@linaro.org> [PMD: Move definitions to new target/sparc/translate.h] --- target/sparc/cpu.h | 4 ---- target/sparc/translate.h | 17 +++++++++++++++++ target/sparc/cpu.c | 24 ++++++++++++++++++++++++ target/sparc/translate.c | 31 +------------------------------ 4 files changed, 42 insertions(+), 34 deletions(-) create mode 100644 target/sparc/translate.h diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index e9ccec6175f..5c981234bb3 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -607,12 +607,8 @@ int sparc_cpu_memory_rw_debug(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); #endif - /* translate.c */ void sparc_tcg_init(void); -void sparc_restore_state_to_opc(CPUState *cs, - const TranslationBlock *tb, - const uint64_t *data); /* fop_helper.c */ target_ulong cpu_get_fsr(CPUSPARCState *); diff --git a/target/sparc/translate.h b/target/sparc/translate.h new file mode 100644 index 00000000000..a46fa4f124b --- /dev/null +++ b/target/sparc/translate.h @@ -0,0 +1,17 @@ +/* + * QEMU translation definitions for SPARC + * + * Copyright (c) 2024 Linaro, Ltd + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef SPARC_TRANSLATION_H +#define SPARC_TRANSLATION_H + +/* Dynamic PC, must exit to main loop. */ +#define DYNAMIC_PC 1 +/* Dynamic PC, one of two values according to jump_pc[T2]. */ +#define JUMP_PC 2 +/* Dynamic PC, may lookup next TB. */ +#define DYNAMIC_PC_LOOKUP 3 + +#endif diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index b11f3248d82..fc0c66afecf 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -27,6 +27,7 @@ #include "qapi/visitor.h" #include "tcg/tcg.h" #include "fpu/softfloat.h" +#include "target/sparc/translate.h" //#define DEBUG_FEATURES @@ -751,6 +752,29 @@ void cpu_get_tb_cpu_state(CPUSPARCState *env, vaddr *pc, *pflags = flags; } +static void sparc_restore_state_to_opc(CPUState *cs, + const TranslationBlock *tb, + const uint64_t *data) +{ + CPUSPARCState *env = cpu_env(cs); + target_ulong pc = data[0]; + target_ulong npc = data[1]; + + env->pc = pc; + if (npc == DYNAMIC_PC) { + /* dynamic NPC: already stored */ + } else if (npc & JUMP_PC) { + /* jump PC: use 'cond' and the jump targets of the translation */ + if (env->cond) { + env->npc = npc & ~3; + } else { + env->npc = pc + 4; + } + } else { + env->npc = npc; + } +} + static bool sparc_cpu_has_work(CPUState *cs) { return (cs->interrupt_request & CPU_INTERRUPT_HARD) && diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 322319a1288..ac063772310 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -30,6 +30,7 @@ #include "exec/log.h" #include "fpu/softfloat.h" #include "asi.h" +#include "target/sparc/translate.h" #define HELPER_H "helper.h" #include "exec/helper-info.c.inc" @@ -101,13 +102,6 @@ # define MAXTL_MASK 0 #endif -/* Dynamic PC, must exit to main loop. */ -#define DYNAMIC_PC 1 -/* Dynamic PC, one of two values according to jump_pc[T2]. */ -#define JUMP_PC 2 -/* Dynamic PC, may lookup next TB. */ -#define DYNAMIC_PC_LOOKUP 3 - #define DISAS_EXIT DISAS_TARGET_0 /* global register indexes */ @@ -5881,26 +5875,3 @@ void sparc_tcg_init(void) gregnames[i]); } } - -void sparc_restore_state_to_opc(CPUState *cs, - const TranslationBlock *tb, - const uint64_t *data) -{ - CPUSPARCState *env = cpu_env(cs); - target_ulong pc = data[0]; - target_ulong npc = data[1]; - - env->pc = pc; - if (npc == DYNAMIC_PC) { - /* dynamic NPC: already stored */ - } else if (npc & JUMP_PC) { - /* jump PC: use 'cond' and the jump targets of the translation */ - if (env->cond) { - env->npc = npc & ~3; - } else { - env->npc = pc + 4; - } - } else { - env->npc = npc; - } -}