From nobody Sun Nov 24 17:36:34 2024 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=reject dis=none) header.from=sifive.com ARC-Seal: i=1; a=rsa-sha256; t=1726679805; cv=none; d=zohomail.com; s=zohoarc; b=OHNfl9m8IlznwPd/JSWG7ifnV2Gf+qKrS13r7cN3lcqAl4mTCFm6NGG6gKK9/Q9tbeuQvpU1zWSbtVqh9KiGBcAQm4s4t1lPyNaVuy42Ud3eqIofkfFpv7lx2K7F3gyQJatrmXMcZ45yIBKFMsIh6dZbbZIwXCYv3Y1SsIPcamo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726679805; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=e21ToE/HJXzkFx4begXiNagynBpQzCVjg3pkA/vtkjA=; b=ZXPORWSNx7m6EJLA0m60BKGyaihgt96Nu/XjxY9uRx35tjXU8MSodyZvb3Ew3wo7QwUQhFxb2GvmeF+TEdggaNVMcANre5GxhbLDQDsWwBxG3Hr2G07UBYrw7X+1V/TJtRpbWlLOizdVKzzTYbY+6okbu+gE3XeJAhE59Nw08L4= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1726679805940537.7522272112237; Wed, 18 Sep 2024 10:16:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sqyGa-0007r4-C3; Wed, 18 Sep 2024 13:15:00 -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 1sqyGY-0007kK-Mb for qemu-devel@nongnu.org; Wed, 18 Sep 2024 13:14:58 -0400 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sqyGT-0001uY-9s for qemu-devel@nongnu.org; Wed, 18 Sep 2024 13:14:58 -0400 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-2d89dbb60bdso3490a91.1 for ; Wed, 18 Sep 2024 10:14:52 -0700 (PDT) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2dd608e2318sm1914577a91.32.2024.09.18.10.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2024 10:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1726679691; x=1727284491; 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=e21ToE/HJXzkFx4begXiNagynBpQzCVjg3pkA/vtkjA=; b=UTZsMiXteZSlapUNpGnwo9hu8bMhLKXSguavjagt8DeExLw3QnH20bhx5OC02QdsDP /hPHCPrtSaUlgH4/+H4fg1w8ja3peG7OvErxjJufn9K6k0yeut1TU3U3uKZusQVeAsdq Sdt9aOpgYdvn95Uj4wiGjT0Phih2SGawy3Fv5eYKZenkF0YCIug5d+dA1vMrdmbHq8at rYiHNXmFtbkDf+cEdhOIOoqK3HcGUC/FhTiKZ3SG1FD+3BzygOIL9Cl/3PoX2xF6J9Ty UWuBkoeXMT0EcLE/q+zSIroiqg7AAyymWeDbVQkDPHkekhhz6kOlAGRHFJ9ncuUN2lG4 gNpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726679691; x=1727284491; 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=e21ToE/HJXzkFx4begXiNagynBpQzCVjg3pkA/vtkjA=; b=oUdKTrvRKjfe6Jls13MuerWTLFY5Ral/TJJpa1+7qKyfXjtA5Tk2KYjtBCRJU0CPf1 m/lnsir9iOT95FIDK9ILPd/d5iYZVr2IYSQtR2PCnPdJvtTjwkF1iscBdFAbVPCVwVF7 45/ObDvYeRELa8HADC95NxBF4iFUhtTI0nJOGYJ4lxiJ1Pd9PHpzH3SlWlUmUzFozDUa TGZgNj+LlgV7QfxLo46p+hJVO+E8N8ckM2ApHCULYSytgLMi3HXgn8Ku7c3bjFN7pPnk UJxSq89hYH123mKYkAzFucQFmOXBkFBCLzSV3rhMyblGEpKI6ET19NFTeZKNvoTLqpTp M3aQ== X-Gm-Message-State: AOJu0Yy76iTddCUWb5yigiF15wjQVcqOz1pp2gtMNgtm23qPmeBEN03E HPYxGsiJKinG4HvcoE3CV4b0fwnisxmelrZg6FY0PzpYbiDLxhgJKwV1YLtMYS0OJWcjNvHU3Es VV6V+b+Waaw27IjFJkqinTySlhyQPjolYT7RC7rTJnkfLz5QPrm/9JnKEtuK1Nl78g2xHNoV/s9 rgeoj/lg0rOnIMJJe0Trc3Zylf5QPVwZPTjyKuJA== X-Google-Smtp-Source: AGHT+IHmPC7r4D1pHZ65Xf9g/juUNVNn4FjJQxuEfFiq9OavfkgPER76FjkG+u5oQuaOkqMJdhioSw== X-Received: by 2002:a17:90b:3888:b0:2d8:9dd2:b8a1 with SMTP id 98e67ed59e1d1-2db9ff91bd9mr21719444a91.9.1726679691211; Wed, 18 Sep 2024 10:14:51 -0700 (PDT) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , richard.henderson@linaro.org, negge@google.com, Max Chou Subject: [PATCH v6 6/7] target/riscv: rvv: Provide group continuous ld/st flow for unit-stride ld/st instructions Date: Thu, 19 Sep 2024 01:14:11 +0800 Message-Id: <20240918171412.150107-7-max.chou@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240918171412.150107-1-max.chou@sifive.com> References: <20240918171412.150107-1-max.chou@sifive.com> MIME-Version: 1.0 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::1031; envelope-from=max.chou@sifive.com; helo=mail-pj1-x1031.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=unavailable 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 @sifive.com) X-ZM-MESSAGEID: 1726679807900116600 Content-Type: text/plain; charset="utf-8" The vector unmasked unit-stride and whole register load/store instructions will load/store continuous memory. If the endian of both the host and guest architecture are the same, then we can group the element load/store to load/store more data at a time. Signed-off-by: Max Chou Reviewed-by: Daniel Henrique Barboza --- target/riscv/vector_helper.c | 77 +++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 14 deletions(-) diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 59009a940ff..654d5e111f3 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -189,6 +189,45 @@ GEN_VEXT_ST_ELEM(ste_h, uint16_t, H2, stw) GEN_VEXT_ST_ELEM(ste_w, uint32_t, H4, stl) GEN_VEXT_ST_ELEM(ste_d, uint64_t, H8, stq) =20 +static inline QEMU_ALWAYS_INLINE void +vext_continus_ldst_tlb(CPURISCVState *env, vext_ldst_elem_fn_tlb *ldst_tlb, + void *vd, uint32_t evl, target_ulong addr, + uint32_t reg_start, uintptr_t ra, uint32_t esz, + bool is_load) +{ + uint32_t i; + for (i =3D env->vstart; i < evl; env->vstart =3D ++i, addr +=3D esz) { + ldst_tlb(env, adjust_addr(env, addr), i, vd, ra); + } +} + +static inline QEMU_ALWAYS_INLINE void +vext_continus_ldst_host(CPURISCVState *env, vext_ldst_elem_fn_host *ldst_h= ost, + void *vd, uint32_t evl, uint32_t reg_start, void *= host, + uint32_t esz, bool is_load) +{ +#if HOST_BIG_ENDIAN + for (; reg_start < evl; reg_start++, host +=3D esz) { + ldst_host(vd, reg_start, host); + } +#else + if (esz =3D=3D 1) { + uint32_t byte_offset =3D reg_start * esz; + uint32_t size =3D (evl - reg_start) * esz; + + if (is_load) { + memcpy(vd + byte_offset, host, size); + } else { + memcpy(host, vd + byte_offset, size); + } + } else { + for (; reg_start < evl; reg_start++, host +=3D esz) { + ldst_host(vd, reg_start, host); + } + } +#endif +} + static void vext_set_tail_elems_1s(target_ulong vl, void *vd, uint32_t desc, uint32_t nf, uint32_t esz, uint32_t max_elems) @@ -297,24 +336,34 @@ vext_page_ldst_us(CPURISCVState *env, void *vd, targe= t_ulong addr, mmu_index, true, &host, ra); =20 if (flags =3D=3D 0) { - for (i =3D env->vstart; i < evl; ++i) { - k =3D 0; - while (k < nf) { - ldst_host(vd, i + k * max_elems, host); - host +=3D esz; - k++; + if (nf =3D=3D 1) { + vext_continus_ldst_host(env, ldst_host, vd, evl, env->vstart, = host, + esz, is_load); + } else { + for (i =3D env->vstart; i < evl; ++i) { + k =3D 0; + while (k < nf) { + ldst_host(vd, i + k * max_elems, host); + host +=3D esz; + k++; + } } } env->vstart +=3D elems; } else { - /* load bytes from guest memory */ - for (i =3D env->vstart; i < evl; env->vstart =3D ++i) { - k =3D 0; - while (k < nf) { - ldst_tlb(env, adjust_addr(env, addr), i + k * max_elems, v= d, - ra); - addr +=3D esz; - k++; + if (nf =3D=3D 1) { + vext_continus_ldst_tlb(env, ldst_tlb, vd, evl, addr, env->vsta= rt, + ra, esz, is_load); + } else { + /* load bytes from guest memory */ + for (i =3D env->vstart; i < evl; env->vstart =3D ++i) { + k =3D 0; + while (k < nf) { + ldst_tlb(env, adjust_addr(env, addr), i + k * max_elem= s, + vd, ra); + addr +=3D esz; + k++; + } } } } --=20 2.34.1