From nobody Thu Nov 6 10:35:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540296650237946.2392327773697; Tue, 23 Oct 2018 05:10:50 -0700 (PDT) Received: from localhost ([::1]:40744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEvWK-0003Fk-Tb for importer@patchew.org; Tue, 23 Oct 2018 08:10:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54234) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEvR6-000648-SU for qemu-devel@nongnu.org; Tue, 23 Oct 2018 08:05:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEvQt-0007fA-Hj for qemu-devel@nongnu.org; Tue, 23 Oct 2018 08:05:20 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:53645) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gEvQt-0007dY-7b for qemu-devel@nongnu.org; Tue, 23 Oct 2018 08:05:11 -0400 Received: by mail-wm1-x343.google.com with SMTP id y11-v6so1502573wma.3 for ; Tue, 23 Oct 2018 05:05:11 -0700 (PDT) Received: from cloudburst.twiddle.net.net ([185.7.230.213]) by smtp.gmail.com with ESMTPSA id a1-v6sm1009200wrt.79.2018.10.23.05.05.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 23 Oct 2018 05:05:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=iDUqaEveb3IkLYpksCTFb7oVkzqW/bs6K5TztFxBVfQ=; b=K/m3FMJM1sTfPubVkVvCgex7XpqxwNpMwYacAnpaQHUQJAxHD5CbrATmyQUcBUo2Gy xtXgwsWdZyjuHDzZsWGWK8xbK6Zb8EpLrF9VpZTjGxg5rLnVr+DaVM0JKr/0TDW7zCvf v5DWe+Mp4gPvE1NtvEd7KqtjZbIwWv1vPmtBo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iDUqaEveb3IkLYpksCTFb7oVkzqW/bs6K5TztFxBVfQ=; b=NTFaURYdEC9nfsAZAdRbLgK+CgatJmYvLrt+d9QMW/M9TdEcJFmnn3gBHxl5x6bfSX fqreFb+FIxlgc74ZOf+oeHvVHdixNWJ7d3VBvZsMR7IcfDju/193g7TqstsN5KCdd3VO DRVBcFz6fQU59/Y0iMWm8o9VjWuH/FZ4QZsI/Lp8q0fRAl6N37jzZ4j8h4yLGdPFTEUm GL3DyAE6X/9OApfRZXtRHxu4my49EobcNNEgX3FMTYjXHOOEt8bZ6epHhgfcPnzy0N08 FdTl45G4tgW8D8C58baBZqXJoEnztqAb2jkjnA5OcY23itC0kTj6ADakJqC9xVz29stZ cceg== X-Gm-Message-State: ABuFfojhYbHuU0VEAJ/l806KqpG+WKbB0gv+ChK0OKDOdrb0FMBM1NgE BnCdf9MnImYkAABtpt9e0NAyK3tNjkM= X-Google-Smtp-Source: ACcGV61TtaZZc1vNRA6KKiUH1svpxeK24DcP5T/s/iSSqwW0C5gGIRq7R5FftZlOo+eHzV+oXNTsAQ== X-Received: by 2002:a1c:ee8d:: with SMTP id j13-v6mr20289624wmi.125.1540296309448; Tue, 23 Oct 2018 05:05:09 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 23 Oct 2018 13:04:52 +0100 Message-Id: <20181023120454.28553-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181023120454.28553-1-richard.henderson@linaro.org> References: <20181023120454.28553-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::343 Subject: [Qemu-devel] [PATCH 5/7] target/riscv: Convert @cs_2 insns to share translation functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, palmer@sifive.com, peer.adelt@hni.uni-paderborn.de, Alistair.Francis@wdc.com, mjc@sifive.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" These all expand simply to R format instructions. Reviewed-by: Bastian Koppelmann Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/riscv/insn_trans/trans_rvc.inc.c | 36 ------------------------- target/riscv/translate.c | 20 +++++++++++--- target/riscv/insn16.decode | 17 +++++++----- 3 files changed, 26 insertions(+), 47 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvc.inc.c b/target/riscv/insn_tr= ans/trans_rvc.inc.c index 7e2668c03d..152c1c9bca 100644 --- a/target/riscv/insn_trans/trans_rvc.inc.c +++ b/target/riscv/insn_trans/trans_rvc.inc.c @@ -176,42 +176,6 @@ static bool trans_c_andi(DisasContext *ctx, arg_c_andi= *a) return trans_andi(ctx, &arg); } =20 -static bool trans_c_sub(DisasContext *ctx, arg_c_sub *a) -{ - arg_sub arg =3D { .rd =3D a->rd, .rs1 =3D a->rd, .rs2 =3D a->rs2 }; - return trans_sub(ctx, &arg); -} - -static bool trans_c_xor(DisasContext *ctx, arg_c_xor *a) -{ - arg_xor arg =3D { .rd =3D a->rd, .rs1 =3D a->rd, .rs2 =3D a->rs2 }; - return trans_xor(ctx, &arg); -} - -static bool trans_c_or(DisasContext *ctx, arg_c_or *a) -{ - arg_or arg =3D { .rd =3D a->rd, .rs1 =3D a->rd, .rs2 =3D a->rs2 }; - return trans_or(ctx, &arg); -} - -static bool trans_c_and(DisasContext *ctx, arg_c_and *a) -{ - arg_and arg =3D { .rd =3D a->rd, .rs1 =3D a->rd, .rs2 =3D a->rs2 }; - return trans_and(ctx, &arg); -} - -static bool trans_c_subw(DisasContext *ctx, arg_c_subw *a) -{ - arg_subw arg =3D { .rd =3D a->rd, .rs1 =3D a->rd, .rs2 =3D a->rs2 }; - return trans_subw(ctx, &arg); -} - -static bool trans_c_addw(DisasContext *ctx, arg_c_addw *a) -{ - arg_addw arg =3D { .rd =3D a->rd, .rs1 =3D a->rd, .rs2 =3D a->rs2 }; - return trans_addw(ctx, &arg); -} - static bool trans_c_j(DisasContext *ctx, arg_c_j *a) { arg_jal arg =3D { .rd =3D 0, .imm =3D a->imm }; diff --git a/target/riscv/translate.c b/target/riscv/translate.c index e7fe8720ac..f4d2a56f9a 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -322,10 +322,25 @@ static int ex_rvc_register(int reg) return 8 + reg; } =20 +/* + * Include the auto-generated decoders. + * Note that the 16-bit decoder reuses some of the trans_* functions + * from the 32-bit decoder, which results in duplicate declarations + * of the relevant helpers. Suppress the warning. + */ bool decode_insn32(DisasContext *ctx, uint32_t insn); -/* Include the auto-generated decoder for 32 bit insn */ +bool decode_insn16(DisasContext *ctx, uint16_t insn); + #include "decode_insn32.inc.c" =20 +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wredundant-decls" + +#include "decode_insn16.inc.c" + +#pragma GCC diagnostic pop + + static bool gen_arith_imm(DisasContext *ctx, arg_i *a, void(*func)(TCGv, TCGv, TCGv)) { @@ -410,9 +425,6 @@ static bool gen_shift(DisasContext *ctx, arg_r *a, #include "insn_trans/trans_rvd.inc.c" #include "insn_trans/trans_privileged.inc.c" =20 -bool decode_insn16(DisasContext *ctx, uint16_t insn); -/* auto-generated decoder*/ -#include "decode_insn16.inc.c" #include "insn_trans/trans_rvc.inc.c" =20 static void decode_opc(DisasContext *ctx) diff --git a/target/riscv/insn16.decode b/target/riscv/insn16.decode index 138290c450..16525486ae 100644 --- a/target/riscv/insn16.decode +++ b/target/riscv/insn16.decode @@ -39,6 +39,9 @@ %imm_addi16sp 12:s1 3:2 5:1 2:1 6:1 !function=3Dex_shift_4 %imm_lui 12:s1 2:5 !function=3Dex_shift_12 =20 +# Argument sets imported from insn32.decode: +&r rd rs1 rs2 !extern + # Argument sets: &cl rs1 rd &cl_dw uimm rs1 rd @@ -65,7 +68,7 @@ @cl_w ... ... ... .. ... .. &cl_dw uimm=3D%uimm_cl_w rs1=3D%rs1_3 = rd=3D%rs2_3 @cl ... ... ... .. ... .. &cl rs1=3D%rs1_3 rd= =3D%rs2_3 @cs ... ... ... .. ... .. &cs rs1=3D%rs1_3 rs= 2=3D%rs2_3 -@cs_2 ... ... ... .. ... .. &cr rd=3D%rs1_3 rs= 2=3D%rs2_3 +@cs_2 ... ... ... .. ... .. &r rd=3D%rs1_3 rs1=3D%rs1_3 rs2=3D%r= s2_3 @cs_d ... ... ... .. ... .. &cs_dw uimm=3D%uimm_cl_d rs1=3D%rs1_3 = rs2=3D%rs2_3 @cs_w ... ... ... .. ... .. &cs_dw uimm=3D%uimm_cl_w rs1=3D%rs1_3 = rs2=3D%rs2_3 @cb ... ... ... .. ... .. &cb imm=3D%imm_cb rs1=3D%rs1_3 @@ -104,12 +107,12 @@ c_addi16sp_lui 011 . ..... ..... 01 @c_addi16sp_= lui # shares opc with C.LUI c_srli 100 . 00 ... ..... 01 @c_shift c_srai 100 . 01 ... ..... 01 @c_shift c_andi 100 . 10 ... ..... 01 @c_andi -c_sub 100 0 11 ... 00 ... 01 @cs_2 -c_xor 100 0 11 ... 01 ... 01 @cs_2 -c_or 100 0 11 ... 10 ... 01 @cs_2 -c_and 100 0 11 ... 11 ... 01 @cs_2 -c_subw 100 1 11 ... 00 ... 01 @cs_2 -c_addw 100 1 11 ... 01 ... 01 @cs_2 +sub 100 0 11 ... 00 ... 01 @cs_2 +xor 100 0 11 ... 01 ... 01 @cs_2 +or 100 0 11 ... 10 ... 01 @cs_2 +and 100 0 11 ... 11 ... 01 @cs_2 +subw 100 1 11 ... 00 ... 01 @cs_2 +addw 100 1 11 ... 01 ... 01 @cs_2 c_j 101 ........... 01 @cj c_beqz 110 ... ... ..... 01 @cb c_bnez 111 ... ... ..... 01 @cb --=20 2.17.2