From patchwork Sun Oct 22 23:28:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 737039 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp1282751wrl; Sun, 22 Oct 2023 16:33:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IECvak+G0n51VsPnW4qaAfkWVLdhVHkqg/VkDKEk2BujmuXvTuXyIA3o2y7kdcUFB0+C8Go X-Received: by 2002:a05:620a:284b:b0:775:c0ba:50d0 with SMTP id h11-20020a05620a284b00b00775c0ba50d0mr6873870qkp.9.1698017613157; Sun, 22 Oct 2023 16:33:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698017613; cv=none; d=google.com; s=arc-20160816; b=gA0T+1PqP9S8FAZ24yA2fnRB7IH8kdEtX2HlwXq95ISH1Bv/hYPIJ/qxuUdAqAQHW8 N8O5d1RC5tMgiPnl/2L3EPlSBGlSmyjcPWeYBEnUKyb7ZPuJS+jlrCcnB3CcsgSL3HkS YOF2E5f8q7Ek3zUToaefrct8SaATtAz1fvD5rfJtAk2d3ZdoFYFctjBPl56X6CbaHVQs GDTnV0tJ2jiE66tRScPpEQWbTwpSwkf++EaST6QPpbW3PggSRBIImhNVLVFEHY6BTJBu Z0R/ApZIhZnizWxRp+QsZtoV3qsLZ6j5byd5XpjyV3WbWKm4BngOyDzk83EBCI+7v/X9 qL5A== 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=3tqKRfrHgf804PVSbuQwIQNkobvA0TCMv4wurSnK70U=; fh=TYrED6TOMxGX0VC4GtjviASLbYyJe19+7/tKWjN44KQ=; b=ac/VeDeLyoSqpG/Bpdx318KSLc4t5EXe7Dl5CStDJBeUI0QC8Q6yWK2bDfp8oE8wL5 sJV+81fH8NxVlr50BPtZoF6aJNuRlo62/qJBL02NC+xlI7MCNEL3e4M1uh/wm3M7bSXl uMkH9x2Z+c2UX1NfjXJM32Z2jEW9HcNJXKeFzmABCiJiU8eNZnurjR8d4NxYeNM4xI+3 nB9hu7nHtI6yOwy5FtueqyH/+J3YU3eFwzBTv9SWbV5J7LypaFY+UNR8r9vsMK6dlJzc Z/ar1hiaLSSlX0c+oIAb2BQt880DHd+FegpByT/1BGBxBjyYuxSljWJemdMUBj4PiMzx zX7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mGjTfaJv; 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 i3-20020a05620a404300b00775c5458f6esi4838312qko.267.2023.10.22.16.33.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 22 Oct 2023 16:33:33 -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=mGjTfaJv; 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 1quhtY-0007HN-US; Sun, 22 Oct 2023 19:30:08 -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 1quhtN-00078m-13 for qemu-devel@nongnu.org; Sun, 22 Oct 2023 19:29:58 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quhtA-0006ir-3m for qemu-devel@nongnu.org; Sun, 22 Oct 2023 19:29:56 -0400 Received: by mail-oi1-x236.google.com with SMTP id 5614622812f47-3b40d5ea323so452435b6e.0 for ; Sun, 22 Oct 2023 16:29:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698017383; x=1698622183; 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=mGjTfaJv+5TfPWEDiVKTyyKucHi+7U2lHPG0NrCRRg8n4h2b8V+r/X+AgBML/T9WHJ 5mqotcg/SqGK6HrJWtRbDg1N1dRFHDdmNE993o+meGM95W8pb79v/CmYw0vC4+ljkzsk O4ey5LT3cyTMeIJL2Y87lXs3GOZs8bAhsI6UPLkrNg+If3azgtlOCW79tRYT1Sf3Dt09 iypMgmbsvDsNzNqzBuhhv6b2zTJH4EHhzKwO8zgGnL4tPDkvOHp8xcobKN0qanAWuSjr //0kTK5jsxegwfeZhqp2sVzmqclSm/dCmt1htQkZ1xPaQ408H4/gIS1MugxTV98GNB7t dViw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698017383; x=1698622183; 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=U9cYqTu02e9lVjQ0hSGxo9Dng+fYFj6njjMQrOTmKL1AyfxlG0kRkxFTEDhsP/mHXw ORMe+OL+AKcJYJZCc8zxEYnDV9bk2xlKyK90K5kbdDD3l/eNne4IzpOALLwNrn57IWv6 AqARHEG+IHgmbZq9fCN4BGFbxkr0kCD6ZXJozXC9ALmc5r1KKer1cN/lfnw/ao7XEZqQ cai/xJ+zvwApzV4KmZOmqdmMk5nRJktYau2323uzwXP525Io701jdFqu1tU0nUVwzq1S IFZ+BjGw+t+XhjtDte4Y77CjzJxur1JW3uzcVlVRp40ahYnel+Byr3CRc+4SrnFb5+KX B52g== X-Gm-Message-State: AOJu0YwMGQuPu2ZVG3d93mP+D5e+3cuSv1UbIrlqOiBN/RAJo16sYpPo SIOq8AnynGaYHYEXT4UfDTOvjMn3m4mVnzRCYfQ= X-Received: by 2002:a05:6808:198c:b0:3ae:554b:9c97 with SMTP id bj12-20020a056808198c00b003ae554b9c97mr10890244oib.37.1698017382900; Sun, 22 Oct 2023 16:29:42 -0700 (PDT) Received: from stoup.. ([71.212.149.95]) by smtp.gmail.com with ESMTPSA id k26-20020a63ba1a000000b005b25a04cf8bsm4023772pgf.12.2023.10.22.16.29.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Oct 2023 16:29:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk Subject: [PATCH v5 10/94] target/sparc: Add decodetree infrastructure Date: Sun, 22 Oct 2023 16:28:08 -0700 Message-Id: <20231022232932.80507-11-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231022232932.80507-1-richard.henderson@linaro.org> References: <20231022232932.80507-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=richard.henderson@linaro.org; helo=mail-oi1-x236.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, 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 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 +/* 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',