From nobody Tue Feb 10 08:31:37 2026 Delivered-To: importer@patchew.org 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; Authentication-Results: mx.zohomail.com; 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 ARC-Seal: i=1; a=rsa-sha256; t=1585582851; cv=none; d=zohomail.com; s=zohoarc; b=JnjNIOImx2+I+/xoshENEAWUoQqK6IdeEZbUu8GRXcCHtI0UBd3PQMRUCuOHKJLplZAUYDYKYYTApMGSd45KXIx4qZK2YvizR28YMSEQEkjs5f3fXkARMKSElQPWZ3Ip6U5O1lIzsQLN9mpXgIl5eA9S3SBFYoK0IRPb8I39agA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585582851; h=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=a5+7RKwlVRToe9OwsFDc+tpEjeXkGwxjwwONyFVx6gM=; b=M7Uf0DYKgapKtRerFui9GBx0qX7+27z5LOrJyG/Nc0c9+MlaYMpYivUkA54oZgM8QiOtd58ZJWgh2TDibiZD775cg8r88IfaIUkDHo3jRBGnF0AhbtutmEAjUeG7sw16p8dO7lQar7yOGxU+pcVUuLX8Fjll0sttnMGWAcfogW8= ARC-Authentication-Results: i=1; mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1585582851513871.750049402913; Mon, 30 Mar 2020 08:40:51 -0700 (PDT) Received: from localhost ([::1]:51512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIwWw-0003dd-3J for importer@patchew.org; Mon, 30 Mar 2020 11:40:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40516) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jIwVP-0002E8-Nu for qemu-devel@nongnu.org; Mon, 30 Mar 2020 11:39:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jIwVN-00082n-Vw for qemu-devel@nongnu.org; Mon, 30 Mar 2020 11:39:15 -0400 Received: from smtp2200-217.mail.aliyun.com ([121.197.200.217]:50883) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jIwVN-0007cj-FX; Mon, 30 Mar 2020 11:39:13 -0400 Received: from L-PF1D6DP4-1208.hz.ali.com(mailfrom:zhiwei_liu@c-sky.com fp:SMTPD_---.H7jiUNJ_1585582735) by smtp.aliyun-inc.com(10.147.41.137); Mon, 30 Mar 2020 23:38:55 +0800 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.07854487|-1; CH=green; DM=|CONTINUE|false|; DS=CONTINUE|ham_regular_dialog|0.00410776-0.00307122-0.992821; FP=0|0|0|0|0|-1|-1|-1; HT=e02c03267; MF=zhiwei_liu@c-sky.com; NM=1; PH=DS; RN=11; RT=11; SR=0; TI=SMTPD_---.H7jiUNJ_1585582735; From: LIU Zhiwei To: richard.henderson@linaro.org, alistair23@gmail.com, chihmin.chao@sifive.com, palmer@dabbelt.com Subject: [PATCH v7 01/61] target/riscv: add vector extension field in CPURISCVState Date: Mon, 30 Mar 2020 23:35:33 +0800 Message-Id: <20200330153633.15298-2-zhiwei_liu@c-sky.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200330153633.15298-1-zhiwei_liu@c-sky.com> References: <20200330153633.15298-1-zhiwei_liu@c-sky.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 121.197.200.217 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: guoren@linux.alibaba.com, qemu-riscv@nongnu.org, qemu-devel@nongnu.org, wxy194768@alibaba-inc.com, wenmeng_zhang@c-sky.com, Alistair Francis , LIU Zhiwei Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The 32 vector registers will be viewed as a continuous memory block. It avoids the convension between element index and (regno, offset). Thus elements can be directly accessed by offset from the first vector base address. Signed-off-by: LIU Zhiwei Acked-by: Alistair Francis Reviewed-by: Richard Henderson --- target/riscv/cpu.h | 12 ++++++++++++ target/riscv/translate.c | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7d21addbab..6663ee8b8c 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -64,6 +64,7 @@ #define RVA RV('A') #define RVF RV('F') #define RVD RV('D') +#define RVV RV('V') #define RVC RV('C') #define RVS RV('S') #define RVU RV('U') @@ -94,9 +95,20 @@ typedef struct CPURISCVState CPURISCVState; =20 #include "pmp.h" =20 +#define RV_VLEN_MAX 512 + struct CPURISCVState { target_ulong gpr[32]; uint64_t fpr[32]; /* assume both F and D extensions */ + + /* vector coprocessor state. */ + uint64_t vreg[32 * RV_VLEN_MAX / 64] QEMU_ALIGNED(16); + target_ulong vxrm; + target_ulong vxsat; + target_ulong vl; + target_ulong vstart; + target_ulong vtype; + target_ulong pc; target_ulong load_res; target_ulong load_val; diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 43bf7e39a6..b71b7e4bc2 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -32,7 +32,7 @@ #include "instmap.h" =20 /* global register indices */ -static TCGv cpu_gpr[32], cpu_pc; +static TCGv cpu_gpr[32], cpu_pc, cpu_vl; static TCGv_i64 cpu_fpr[32]; /* assume F and D extensions */ static TCGv load_res; static TCGv load_val; @@ -886,6 +886,7 @@ void riscv_translate_init(void) } =20 cpu_pc =3D tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, pc), "p= c"); + cpu_vl =3D tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, vl), "v= l"); load_res =3D tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, load_= res), "load_res"); load_val =3D tcg_global_mem_new(cpu_env, offsetof(CPURISCVState, load_= val), --=20 2.23.0