From patchwork Sat Oct 21 05:30:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 736655 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp634456wrl; Fri, 20 Oct 2023 22:45:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IERUavt8RfM0E6FWtyPngkBAIw07silsBks6a/obckTHwByYrWYdg49Fr2HQ7iweHMY6W0a X-Received: by 2002:ad4:5966:0:b0:66d:3f76:c626 with SMTP id eq6-20020ad45966000000b0066d3f76c626mr4691829qvb.11.1697867126102; Fri, 20 Oct 2023 22:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697867126; cv=none; d=google.com; s=arc-20160816; b=UEaxnAXlNiDY2ROYH3VS9cFO3t9SjsHlZnCHB6tU2TzwOkFrZkY9r3OL72UWDNaUej 8E64yLcc1ojfXFzgPnuUxgYcG0vrjqbJMXFlyd8nJjttgCFzabUNeT2wrxvV/7GoclmT msL9cNqRtYb4Jb1QO4JB5MkGUK3zQsg1OgiuncuUoV4r1dbEMEzanAHLnMsYnlrNglTn T83egTcQijmygPGrUKyDcQorX0VBmrlgj3TPusKgFJpHLnIk41dNiZOrzAHqGkrrSR/b uKSHmsWojYW1E/LNQyStcBbNZbn4/l98OSyNWFb7VRogRULjGIBwn0WD95tr/LTKwlTT PAbA== 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=yCQ11G4CDtK3oW1LuqfPuIgRALcswxq9MCt2fHEKN58=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=cI0rtbOUmXZUS6WkfEitc9PrhoRitB4jxZ7uZm4aqU8MDJ9LvK35FrD2uAob9ZmZC6 NjI5hDG8/M0J+EaDNbqUbMEUECCQ1NAJn2d4iLy66pp2KMjAK6mf313WyAdcyqWLBbav R1tei6QNeXMLs3EPjdT9Eocl1UGidgJ/0bGifYf5rdsptoWfcUYtmDOnohEgDLSCIjjR t4k8BTeS/BoqwC6w0WjOWkOEWhd88q52Fd4xbNZTXdYYxr16pAToBsnOe32WlJBQB+eS A3f/83BaCmAHwn2FCI5oTFnLglqISSgjfEALWRW8SXBsjGeOys9xS46RqPWwvuSWBvsK 95ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wQEXyh1J; 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 kj23-20020a056214529700b0066d2004c2besi2677606qvb.427.2023.10.20.22.45.25 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 20 Oct 2023 22:45:26 -0700 (PDT) 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=wQEXyh1J; 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 1qu4as-00079I-FN; Sat, 21 Oct 2023 01:32:14 -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 1qu4ao-00077D-KP for qemu-devel@nongnu.org; Sat, 21 Oct 2023 01:32:10 -0400 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qu4am-0008MI-WC for qemu-devel@nongnu.org; Sat, 21 Oct 2023 01:32:10 -0400 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-6b7f0170d7bso1416303b3a.2 for ; Fri, 20 Oct 2023 22:32:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697866327; x=1698471127; 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=yCQ11G4CDtK3oW1LuqfPuIgRALcswxq9MCt2fHEKN58=; b=wQEXyh1JB0/ZM5CfI2JY4tIzp9aeHCAXzZxIN1HFdMHXhGrrFjfpq+EIbS4xUYG2aF IHZta2batqozw47OBd3pyneqUJhsFHAqZdGEG/lpBPFxIdGuBhZet2whsLo6RUIywhbO MQhwcothiMMN8v+YAmfHtJkQLKaGGb/zADrutiGeWxuN2uzl7AgVwnB2pQc0SNnwI2Nu ceg06d+xtxzRvpCFWThqT9Od4RrViw29R68blndBJ7+pMdSbV3AfLLQvaarOdtbVXMd/ FCIKJiWyMNEI6M7xDBGswSWOHVQOZfwKSHnyMJGHzkyZ+MYDcLHADUo33OsBLPYIzh+c +mYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697866327; x=1698471127; 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=yCQ11G4CDtK3oW1LuqfPuIgRALcswxq9MCt2fHEKN58=; b=VgSJTU1TqMephGG01A9yiwoTpRZRb1DPX2ePNFe9dCflfmZlKH9qG1PIP90lfk9Isk Gv12cE2iOpxpFF2bLmWY26+7ojBeIVJXX4oxAzEgdjUgPuSFUp6oxlHdfx01xtyY9xSm XJUbkQlyDi6YI95XJqXVjgN4ixpwuzZUvVht8IQ6q1CjEvNg/fxrG2HdqAfWsA8zbWcc yTsqFqJ4pHs1OyZAUMGtcGl3JuUp8cCvTVpshsj6h58BexaC/8IsiIRIMyokmVsRxCRf 3gdKqrsV+08ALX7vAimEXHvM8v6S1OY121B22BSiSjvVCPPVnsNyYs+/YZ9tlIRX1vcT hsgg== X-Gm-Message-State: AOJu0Yy/RYLlPSH5dwXH0mqkRC4gd1luCmvxVOWGSb/ikyZuknX2Nvef bFtaLzq0y9s1BgAE+SCk/tWkPdkug0r+g1jaF4g= X-Received: by 2002:a05:6a00:21c4:b0:6bf:50df:2df5 with SMTP id t4-20020a056a0021c400b006bf50df2df5mr1291085pfj.13.1697866327652; Fri, 20 Oct 2023 22:32:07 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id f20-20020a056a001ad400b006b2677d3684sm2434831pfv.206.2023.10.20.22.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 22:32:07 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 09/90] target/sparc: Add decodetree infrastructure Date: Fri, 20 Oct 2023 22:30:37 -0700 Message-Id: <20231021053158.278135-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231021053158.278135-1-richard.henderson@linaro.org> References: <20231021053158.278135-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42d; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42d.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 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 +/* 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 = 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 = DISAS_NORETURN; + break; + default: + g_assert_not_reached(); + } + } else { + dc->pc = dc->npc; + dc->npc = 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 s1, TCGv s2) goto nfpu_insn; /* 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, unsigned 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 = 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 = DISAS_NORETURN; - break; - default: - g_assert_not_reached(); - } - } else { - dc->pc = dc->npc; - dc->npc = 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) insn = translator_ldl(env, &dc->base, dc->pc); dc->base.pc_next += 4; - disas_sparc_insn(dc, insn); + + if (!decode(dc, insn)) { + disas_sparc_legacy(dc, insn); + } if (dc->base.is_jmp == 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 = decodetree.process('insns.decode') + sparc_ss = ss.source_set() +sparc_ss.add(gen) sparc_ss.add(files( 'cc_helper.c', 'cpu.c',