From patchwork Fri Oct 15 07:46:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Chang X-Patchwork-Id: 12560855 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC33FC433EF for ; Fri, 15 Oct 2021 09:14:14 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 78A4960FF2 for ; Fri, 15 Oct 2021 09:14:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 78A4960FF2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:59936 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mbJI3-0006S2-Fz for qemu-devel@archiver.kernel.org; Fri, 15 Oct 2021 05:14:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mbHzr-0005Pq-PF for qemu-devel@nongnu.org; Fri, 15 Oct 2021 03:51:19 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]:34362) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mbHzo-0005hv-Ux for qemu-devel@nongnu.org; Fri, 15 Oct 2021 03:51:19 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 133so7888393pgb.1 for ; Fri, 15 Oct 2021 00:51:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zIj430FIbZ9EdxzXNCCDp2iO8R3sg5cdcprIACul/Yw=; b=Lf1419+oahomCOE3TzdfpuOj3Tqoqg1QLvZne8rn2OxcDiMqQg+NyfyuNh2k1t0Xux GubQV3EYSLyIHAAreRcvKWXnzNz4ABbXlozyRrBoEIK+/fdCXPPdM4bfu5Q5bVnRwsYN AX/kKAO9toKOlvxBAUWhHWhBxHwslCOmF2dloas2KXA1gCYazoQC80IVt2T3TzrzLTme plj6N2NHVyRrmIstiwWCAvUVgSEfw79VLAp2uZx4Wj1cU/XxCdgHiKEPOUM/IwGPUGns l8gZ+FY19MMcU8Xq1B5c+hcNzoOI/UyMMOktrd0tG+ix9SWk7IoGiRmNg4rkmKnjn0Q4 ih5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zIj430FIbZ9EdxzXNCCDp2iO8R3sg5cdcprIACul/Yw=; b=NKrhdXRoq8QlqQfEQxRZEd2QgxPBuA4Sux8+8J8VMAYyCmgPeczsmK5QDm4JHbTsOl 4lYwZDETqvuWvl4swO2yBjH+1rQaqUy53oN7CZa1+SR9G9Z6dsweoGg4CQp2JcWmEowp fo5AfNMsh5ad8rZfl8/LpjtPdpprR+jqtVQ6Us8BHdNKuE1hstMm5nwNDOJEdRcT2CUE JdGj/xSDWZB9slulved3dn9jLNgZ2JeCbo1JMj2HSSoR61IGVE6fQgguuGkf5FBJpF1w YmY5OBYvM6iltFHCF2hac36P4LRAhKRLcTjBpa3BsNyikC0gKv2ulYWFCCCVZAuThtLB SwMA== X-Gm-Message-State: AOAM530aQmzbRPy6qt019iJd1FFmGxJgoGqumejdnYmUMJm12/VvZ+v/ +R+RCmhJmLsoQXbgFnvF/WnwOTHpfJpcGbK3 X-Google-Smtp-Source: ABdhPJyrQkdxqaeeJFYJALExUPNreO7i7q9RHe9mUsi7PZiRxcFz7HFDqYOShcR9of+ktQXdsjgtxg== X-Received: by 2002:a63:b94b:: with SMTP id v11mr8109205pgo.145.1634284274871; Fri, 15 Oct 2021 00:51:14 -0700 (PDT) Received: from localhost.localdomain (123-193-74-252.dynamic.kbronet.com.tw. [123.193.74.252]) by smtp.gmail.com with ESMTPSA id z13sm4271680pfq.130.2021.10.15.00.51.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Oct 2021 00:51:14 -0700 (PDT) From: frank.chang@sifive.com To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Subject: [PATCH v8 74/78] target/riscv: rvv-1.0: add vsetivli instruction Date: Fri, 15 Oct 2021 15:46:22 +0800 Message-Id: <20211015074627.3957162-82-frank.chang@sifive.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211015074627.3957162-1-frank.chang@sifive.com> References: <20211015074627.3957162-1-frank.chang@sifive.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::52b; envelope-from=frank.chang@sifive.com; helo=mail-pg1-x52b.google.com X-Spam_score_int: -1 X-Spam_score: -0.2 X-Spam_bar: / X-Spam_report: (-0.2 / 5.0 requ) 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Frank Chang , Alistair Francis , Richard Henderson , Bin Meng , Palmer Dabbelt Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Frank Chang Signed-off-by: Frank Chang Reviewed-by: Alistair Francis --- target/riscv/insn32.decode | 2 ++ target/riscv/insn_trans/trans_rvv.c.inc | 27 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/target/riscv/insn32.decode b/target/riscv/insn32.decode index d7c6bc9af26..3b6524bad91 100644 --- a/target/riscv/insn32.decode +++ b/target/riscv/insn32.decode @@ -79,6 +79,7 @@ @r_vm_1 ...... . ..... ..... ... ..... ....... &rmrr vm=1 %rs2 %rs1 %rd @r_vm_0 ...... . ..... ..... ... ..... ....... &rmrr vm=0 %rs2 %rs1 %rd @r2_zimm11 . zimm:11 ..... ... ..... ....... %rs1 %rd +@r2_zimm10 .. zimm:10 ..... ... ..... ....... %rs1 %rd @r2_s ....... ..... ..... ... ..... ....... %rs2 %rs1 @hfence_gvma ....... ..... ..... ... ..... ....... %rs2 %rs1 @@ -672,6 +673,7 @@ vsext_vf4 010010 . ..... 00101 010 ..... 1010111 @r2_vm vsext_vf8 010010 . ..... 00011 010 ..... 1010111 @r2_vm vsetvli 0 ........... ..... 111 ..... 1010111 @r2_zimm11 +vsetivli 11 .......... ..... 111 ..... 1010111 @r2_zimm10 vsetvl 1000000 ..... ..... 111 ..... 1010111 @r # *** RV32 Zba Standard Extension *** diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_trans/trans_rvv.c.inc index d463e494b71..9dedcdf4779 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -160,6 +160,26 @@ static bool do_vsetvl(DisasContext *s, int rd, int rs1, TCGv s2) return true; } +static bool do_vsetivli(DisasContext *s, int rd, TCGv s1, TCGv s2) +{ + TCGv dst; + + if (!require_rvv(s) || !has_ext(s, RVV)) { + return false; + } + + dst = dest_gpr(s, rd); + + gen_helper_vsetvl(dst, cpu_env, s1, s2); + gen_set_gpr(s, rd, dst); + mark_vs_dirty(s); + tcg_gen_movi_tl(cpu_pc, s->pc_succ_insn); + lookup_and_goto_ptr(s); + s->base.is_jmp = DISAS_NORETURN; + + return true; +} + static bool trans_vsetvl(DisasContext *s, arg_vsetvl *a) { TCGv s2 = get_gpr(s, a->rs2, EXT_ZERO); @@ -172,6 +192,13 @@ static bool trans_vsetvli(DisasContext *s, arg_vsetvli *a) return do_vsetvl(s, a->rd, a->rs1, s2); } +static bool trans_vsetivli(DisasContext *s, arg_vsetivli *a) +{ + TCGv s1 = tcg_const_tl(a->rs1); + TCGv s2 = tcg_const_tl(a->zimm); + return do_vsetivli(s, a->rd, s1, s2); +} + /* vector register offset from env */ static uint32_t vreg_ofs(DisasContext *s, int reg) {