From nobody Wed Nov 27 14:31:00 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; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1698280626; cv=none; d=zohomail.com; s=zohoarc; b=N0lsFehcJyS4V8cs62hXrmcIqv3+Pg3KmrPfg9oUmY5U+3TC6mF5+RS22QbdklivV/gz0DorRuqa4/sSqWJdbE2fq0uDcHbWOSQAKibjg+U4Ig3ToJNM/62OGdLLjClCjWWHGUtuCRDOlT5xAyOzkv9DtZJvLNCAOrksIEK+lo0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1698280626; 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=3tqKRfrHgf804PVSbuQwIQNkobvA0TCMv4wurSnK70U=; b=I8Le0hrL5GAav8wtlE8CN78sTGj6B1sKg4HQeWJj/JMvyIXPk3uJ6A+UwVZgS/BquYwW6b3BOWiaVhsqEIvR7FXfsAckWIDfViUw1BM+cdyoxTnTfjcCwtBGCL2Qr4D1G9gLHtjfL0LmyZMpNiEVb+2XAk5HaMvSSs7fP19Ny+s= 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1698280626699535.7301518909752; Wed, 25 Oct 2023 17:37:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qvo2t-0007A0-4X; Wed, 25 Oct 2023 20:16:19 -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 1qvo2o-00072w-5B for qemu-devel@nongnu.org; Wed, 25 Oct 2023 20:16:14 -0400 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qvo2h-0004rJ-Kf for qemu-devel@nongnu.org; Wed, 25 Oct 2023 20:16:13 -0400 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1c87a85332bso2311545ad.2 for ; Wed, 25 Oct 2023 17:16:00 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id ij23-20020a170902ab5700b001c582de968dsm10038433plb.72.2023.10.25.17.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 17:15:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698279360; x=1698884160; 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=3tqKRfrHgf804PVSbuQwIQNkobvA0TCMv4wurSnK70U=; b=Q7KsIQ+cwLgSl+d5X2Be0oi3HG1QjXMfaTIGH2ZNhS6U8r6r4nBDjr17HinvGfoaAp MGFe2RytQ4R7OpfTRw5Mii9VHbNaGZ0HNOAjKp8i78ZupkIvx4CNTWBTynaFRYoI2CRi cTKUu3rTlQ0mjIB/D8eqxrPlWZdfbwLX+hG2ivw8IQk9dChRjAy7NCVsavmmPgcg8pDB oTEbGwAQx7jZ8tFYoCsMoBx8InR1kH0kt5AW/jQcMsngzBy0YsNRyDtm/wJ5zgGXbp1h WnXH0j4UrcWyQrNwtwEhw8t3l1lsoQsVfMXgznaXXYRKWX57Q7B2MEUnRTxynuwH5TyW j5EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698279360; x=1698884160; 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=3tqKRfrHgf804PVSbuQwIQNkobvA0TCMv4wurSnK70U=; b=F4qkGaVMNBiet8D15xhEcBu8R/fYd/ysdAA6mcOtURgE+aCwkix2GUVT3cWRNi+W6V Y0vpjdU8TKwv6lmCib/yH6kf7CFjXVoi6blMDx9YPYK6562a7OqMDrwe8QESTqhjO9u2 mUi1uJejO7lWA9Te4B6tasIpe/SK0SFF7nherz+pEAWccp7D2ifPZ/2wmNZmXs5uSokp Kfv/EqIVmowGE/V6WqQbh/bmMtu8HgyqjZepcG472CxvPYR0trFejJCo/aqvhqbmFicr WarbJnXZr1hIgkGytZBnK7VHt8sp/BhFNf3BM554Wjxub5xcwOJuA5ikidgU2DUXAsNM 0q5g== X-Gm-Message-State: AOJu0Yxq1920bG67PiSX1/LHmDyuaEXN9zG9aP5xC3vSedoJ+eLgZKOw EN4yvb+kjzWFyZQAdRXUolx6d/43JaDL8wbW6Vk= X-Google-Smtp-Source: AGHT+IGP2nbbJWPzCcr0ZXnTaGczEMxqTViR+TSpYPE506MFAzEuUdgz2kBp4gQ9o6+1h9sWZBGqNg== X-Received: by 2002:a17:902:e80b:b0:1c5:6157:f073 with SMTP id u11-20020a170902e80b00b001c56157f073mr17257385plg.11.1698279359858; Wed, 25 Oct 2023 17:15:59 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Mark Cave-Ayland Subject: [PULL 10/94] target/sparc: Add decodetree infrastructure Date: Wed, 25 Oct 2023 17:13:58 -0700 Message-Id: <20231026001542.1141412-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231026001542.1141412-1-richard.henderson@linaro.org> References: <20231026001542.1141412-1-richard.henderson@linaro.org> 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::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1698280628029100003 Content-Type: text/plain; charset="utf-8" Tested-by: Mark Cave-Ayland Acked-by: Mark Cave-Ayland Signed-off-by: Richard Henderson --- target/sparc/insns.decode | 5 +++ target/sparc/translate.c | 69 ++++++++++++++++++++++++++------------- target/sparc/meson.build | 3 ++ 3 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 target/sparc/insns.decode diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode new file mode 100644 index 0000000000..5811a679db --- /dev/null +++ b/target/sparc/insns.decode @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: LGPL-2.0+ +# +# Sparc instruction decode definitions. +# Copyright (c) 2023 Richard Henderson + diff --git a/target/sparc/translate.c b/target/sparc/translate.c index cab9f13421..080bc5f8a2 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -3003,6 +3003,47 @@ static void gen_faligndata(TCGv dst, TCGv gsr, TCGv = s1, TCGv s2) } #endif =20 +/* Include the auto-generated decoder. */ +#include "decode-insns.c.inc" + +#define TRANS(NAME, AVAIL, FUNC, ...) \ + static bool trans_##NAME(DisasContext *dc, arg_##NAME *a) \ + { return avail_##AVAIL(dc) && FUNC(dc, __VA_ARGS__); } + +#define avail_ALL(C) true +#ifdef TARGET_SPARC64 +# define avail_32(C) false +# define avail_64(C) true +#else +# define avail_32(C) true +# define avail_64(C) false +#endif + +/* Default case for non jump instructions. */ +static bool advance_pc(DisasContext *dc) +{ + if (dc->npc & 3) { + switch (dc->npc) { + case DYNAMIC_PC: + case DYNAMIC_PC_LOOKUP: + dc->pc =3D dc->npc; + gen_op_next_insn(); + break; + case JUMP_PC: + /* we can do a static jump */ + gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1], cpu_cond); + dc->base.is_jmp =3D DISAS_NORETURN; + break; + default: + g_assert_not_reached(); + } + } else { + dc->pc =3D dc->npc; + dc->npc =3D dc->npc + 4; + } + return true; +} + #define CHECK_IU_FEATURE(dc, FEATURE) \ if (!((dc)->def->features & CPU_FEATURE_ ## FEATURE)) \ goto illegal_insn; @@ -3011,7 +3052,7 @@ static void gen_faligndata(TCGv dst, TCGv gsr, TCGv s= 1, TCGv s2) goto nfpu_insn; =20 /* before an instruction, dc->pc must be static */ -static void disas_sparc_insn(DisasContext * dc, unsigned int insn) +static void disas_sparc_legacy(DisasContext *dc, unsigned int insn) { unsigned int opc, rs1, rs2, rd; TCGv cpu_src1, cpu_src2; @@ -5544,26 +5585,7 @@ static void disas_sparc_insn(DisasContext * dc, unsi= gned int insn) } break; } - /* default case for non jump instructions */ - if (dc->npc & 3) { - switch (dc->npc) { - case DYNAMIC_PC: - case DYNAMIC_PC_LOOKUP: - dc->pc =3D dc->npc; - gen_op_next_insn(); - break; - case JUMP_PC: - /* we can do a static jump */ - gen_branch2(dc, dc->jump_pc[0], dc->jump_pc[1], cpu_cond); - dc->base.is_jmp =3D DISAS_NORETURN; - break; - default: - g_assert_not_reached(); - } - } else { - dc->pc =3D dc->npc; - dc->npc =3D dc->npc + 4; - } + advance_pc(dc); jmp_insn: return; illegal_insn: @@ -5654,7 +5676,10 @@ static void sparc_tr_translate_insn(DisasContextBase= *dcbase, CPUState *cs) =20 insn =3D translator_ldl(env, &dc->base, dc->pc); dc->base.pc_next +=3D 4; - disas_sparc_insn(dc, insn); + + if (!decode(dc, insn)) { + disas_sparc_legacy(dc, insn); + } =20 if (dc->base.is_jmp =3D=3D DISAS_NORETURN) { return; diff --git a/target/sparc/meson.build b/target/sparc/meson.build index 48025cce76..c316773db6 100644 --- a/target/sparc/meson.build +++ b/target/sparc/meson.build @@ -1,4 +1,7 @@ +gen =3D decodetree.process('insns.decode') + sparc_ss =3D ss.source_set() +sparc_ss.add(gen) sparc_ss.add(files( 'cc_helper.c', 'cpu.c', --=20 2.34.1