From nobody Fri Dec 19 14:31:15 2025 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1688992410; cv=none; d=zohomail.com; s=zohoarc; b=OvuuqRDRAw3VdT6as1XwB8xBRdZ/PGMRvcR+WL/Pl5KNR8Is2UJtlN4R3DAtOs6Y9Iv4bAHC4cYp0WqySAUIHH42wMvyKubuBGAgI+26g4ZybkRzKnSxSwNYs8EzHCUnUbaGvaHnegySzby0kC/TntfaVpeoHw6tUuAffG+B40c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1688992410; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9P8qx+1uFw5tUq4aTdGQKaVSrAL369V4RguW7Aqapy0=; b=JcmQGF0WbZ+LAD19Ab9KjjdQcAbYvq459eMpRYcw3belyCnFLm2YI0ebvaHWjPmGL86NyDRim8LYc6SCAkEnq9hUatruQmi0NEyXc+qsE4qjQHwrviE5vV7J78qUsrWRD6SlJDPodVI8S3XnCdOUHZxtJ5Vs5aDsTjZP2A5qQEg= 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 1688992410090780.1793539327622; Mon, 10 Jul 2023 05:33:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qIq4Y-0000GB-0Q; Mon, 10 Jul 2023 08:32:58 -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 1qIq4N-0008TJ-EG for qemu-devel@nongnu.org; Mon, 10 Jul 2023 08:32:47 -0400 Received: from mail-oo1-xc2c.google.com ([2607:f8b0:4864:20::c2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIq4K-0002yy-DU for qemu-devel@nongnu.org; Mon, 10 Jul 2023 08:32:47 -0400 Received: by mail-oo1-xc2c.google.com with SMTP id 006d021491bc7-563439ea4a2so3109958eaf.0 for ; Mon, 10 Jul 2023 05:32:42 -0700 (PDT) Received: from toolbox.alistair23.me (2403-580b-97e8-0-321-6fb2-58f1-a1b1.ip6.aussiebb.net. [2403:580b:97e8:0:321:6fb2:58f1:a1b1]) by smtp.gmail.com with ESMTPSA id i126-20020a639d84000000b0055b44a901absm181559pgd.70.2023.07.10.05.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 05:32:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688992360; x=1691584360; 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=9P8qx+1uFw5tUq4aTdGQKaVSrAL369V4RguW7Aqapy0=; b=BQNtSulm00nbg9BITnnHUTjpS0RBfbUNyvg66UlUL7DGJWTEqNO6J7DvL4QJub65Ep 1Rl7CGCmR6ohMwHLy8FWdzqhncO//6Mf1g15G+kActjK+ZUsosAb9fFcS3VpB8rLjYDA sPKjDdfJDYCHZKGL/CwMvZncaD2ayIAeHDRMranWmx5PGoC9PCpXcSsPpl1Glv0/FbJq WZ4S6xOpiENffymP24E2yP6tBxuw43WmHreMIvZdVlhAfMpm6uQ9K4lwEfhucDvulNcB whfknO1isMxOmmkIlMJN2wV3vDsRevobToedqdEyFx8E/Os/4gUqDxdFgqqOtlSVLt/6 zyQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688992360; x=1691584360; 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=9P8qx+1uFw5tUq4aTdGQKaVSrAL369V4RguW7Aqapy0=; b=G4DU306++8TVO1mckq+rMqjQ4yV1ZoYUZ4lg+cAz5YenPTyf6bwJ/21lWVzE+W3RqJ 0bIgCEL2GtSfbPf6pfRGhBsDH4ab5kPVffCTnUZppShrvjsh4gcvWiCOb+GKboI4bzDQ xnVVN7jDs8DZTjky2VTmuRXjEo0epdQPshuDrP+4/DJfjL4QcdPl4LKt7JpIv+Yqalzp eB0uRPTYoMBSSSFizqIenIDneArcgPUYHSrRhjo1siDW5wunOP3aWR3e/4xcV99Pw7se HRWNOgwycauB3BPXjT6FcsktXiDdTJUlJbEnj7zjerujiyI1qV/uvcsw63OENV4w7Zi3 4PQg== X-Gm-Message-State: ABy/qLbuFHOV/sDShM8q4NWphvY5wZxfFpBvh9WuRdrsUm1pqtxPvRCY NKHdg2gfEqlVm/nVb6t7DW9TVTTOAWcPHw== X-Google-Smtp-Source: APBJJlFJO7xE77sE8oOYemZYdvjU/eMbXP8/0Xo4a/IZ3uNCCc7j5imYVVxYWk7bpY0cQlg/OoPsIg== X-Received: by 2002:a05:6358:7f18:b0:135:5da6:d303 with SMTP id p24-20020a0563587f1800b001355da6d303mr3955858rwn.5.1688992360110; Mon, 10 Jul 2023 05:32:40 -0700 (PDT) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, =?UTF-8?q?Christoph=20M=C3=BCllner?= , LIU Zhiwei , Alistair Francis Subject: [PULL 06/54] disas/riscv: Provide infrastructure for vendor extensions Date: Mon, 10 Jul 2023 22:31:17 +1000 Message-Id: <20230710123205.2441106-7-alistair.francis@wdc.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230710123205.2441106-1-alistair.francis@wdc.com> References: <20230710123205.2441106-1-alistair.francis@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::c2c; envelope-from=alistair23@gmail.com; helo=mail-oo1-xc2c.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 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, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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 @gmail.com) X-ZM-MESSAGEID: 1688992411418100003 From: Christoph M=C3=BCllner A previous patch provides a pointer to the RISCVCPUConfig data. Let's use this to add the necessary code for vendor extensions. This patch does not change the current behaviour, but clearly defines how vendor extension support can be added to the disassembler. Reviewed-by: LIU Zhiwei Reviewed-by: Alistair Francis Signed-off-by: Christoph M=C3=BCllner Message-Id: <20230612111034.3955227-7-christoph.muellner@vrull.eu> Signed-off-by: Alistair Francis --- disas/riscv.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/disas/riscv.c b/disas/riscv.c index b6789ab92a..dc3bfb0123 100644 --- a/disas/riscv.c +++ b/disas/riscv.c @@ -4700,9 +4700,33 @@ disasm_inst(char *buf, size_t buflen, rv_isa isa, ui= nt64_t pc, rv_inst inst, rv_decode dec =3D { 0 }; dec.pc =3D pc; dec.inst =3D inst; - dec.opcode_data =3D rvi_opcode_data; dec.cfg =3D cfg; - decode_inst_opcode(&dec, isa); + + static const struct { + bool (*guard_func)(const RISCVCPUConfig *); + const rv_opcode_data *opcode_data; + void (*decode_func)(rv_decode *, rv_isa); + } decoders[] =3D { + { always_true_p, rvi_opcode_data, decode_inst_opcode }, + }; + + for (size_t i =3D 0; i < ARRAY_SIZE(decoders); i++) { + bool (*guard_func)(const RISCVCPUConfig *) =3D decoders[i].guard_f= unc; + const rv_opcode_data *opcode_data =3D decoders[i].opcode_data; + void (*decode_func)(rv_decode *, rv_isa) =3D decoders[i].decode_fu= nc; + + if (guard_func(cfg)) { + dec.opcode_data =3D opcode_data; + decode_func(&dec, isa); + if (dec.op !=3D rv_op_illegal) + break; + } + } + + if (dec.op =3D=3D rv_op_illegal) { + dec.opcode_data =3D rvi_opcode_data; + } + decode_inst_operands(&dec, isa); decode_inst_decompress(&dec, isa); decode_inst_lift_pseudo(&dec); --=20 2.40.1