From nobody Sat Nov 23 23:43:44 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1730952735; cv=none; d=zohomail.com; s=zohoarc; b=M4b6wcBVuVbtezDdCsPkyPs1FbYDIZ+5WC1Pbf/+ITkmpa3mKGOKnWCCF17pd6eiLOViURQu/Fv5KP8lY8/M5Oe4q4i6sL6tSSt1QYNJJGjW25VO566vGhe4R6T9xxvwZj+oarjbyeoezg11JAwYFDR6ZxxgUlAyxk/M3YR5+9A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730952735; 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=1miqYX0xQo/7o/8q+JA+EDvRgf2MXw9rICv8IrHiWDQ=; b=angCamWekoQ8bCXoRTkUYtcmCjJXHYsMjOrj6NkL8vb1348pWLpxGI9a7AolfyqCUIBN7/5rMUz0douH1cc/4wRPGP1OWhpJgmhQ4GDX0t4NnPEZilhhx7xq4E7nsJcZXHeyTLCaEHEOB6orIsr8C9l/Oc5KEURcF5vhlvY1VEU= 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 1730952735455273.5955146826187; Wed, 6 Nov 2024 20:12:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8trG-0006GJ-4n; Wed, 06 Nov 2024 23:10:58 -0500 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 1t8trE-0006G3-OO for qemu-devel@nongnu.org; Wed, 06 Nov 2024 23:10:56 -0500 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1t8trD-00050Y-0G for qemu-devel@nongnu.org; Wed, 06 Nov 2024 23:10:56 -0500 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-20c8b557f91so5579045ad.2 for ; Wed, 06 Nov 2024 20:10:54 -0800 (PST) Received: from toolbox.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21177dc3f12sm2789105ad.9.2024.11.06.20.10.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 20:10:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1730952653; x=1731557453; 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=1miqYX0xQo/7o/8q+JA+EDvRgf2MXw9rICv8IrHiWDQ=; b=LIfoQQ45FZNaVboiNp5B0zXM5oci0TZbrRAQo/nZ1nOlEXIvpGKX3y6usXW+OqjQsz eU+emWG2CQGaY7dvN/DNBLMry/tlaib5ziHjG08UN7CRKJ4AzgZP1HlLHyuvzZY4pzGO gv9SrPWfSjVlHqgXOHqq2iLvKruEmmym//t9/LggZNtwQ2Yb3beKYV9LHiqykOcHR0qc 0MbjBl0x0Bk0vmJ1VV6rf+8KQ0nMMoBoWJO2fYqBJAcAUqtwwbskSDDlQ7HFZ/YaFQm/ nq9RlqMVopJcZv2QyueH+AbJIO+l3h0KiYYwNz7lQ2h5Grh/zH2rcedno2Pipbvoboeo ZprA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730952653; x=1731557453; 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=1miqYX0xQo/7o/8q+JA+EDvRgf2MXw9rICv8IrHiWDQ=; b=fcHglFf/94s1fkMBkr1RtY1jAmWydPDnMDbaQW5L7/xevlUlF+XyCyRVmjpCrAcyMB 53/1VncIgKz94n33Ot+EK7FZ5HPb9gHj6lkJMH3hriZXZDaVOIuwXJW269JjrzMS+5ZP twMw2pWkMqXH6qSV4Mu8CPGYn79pj2ynHt1wgfkdGmqnw8/EZksf4O2SP2NEGKlS86jv 3r24KeVMM6hvH7v6FYqdfzKLQG5Bo8Z0fXKnCDksPwS3k9lJQkMj0MH4wO4nYUbw2ZHc Trf1cbV4NAjwqM1Wua5U+zXUZCGIdEClakKtPSx9dJ+V/8y5dUyI2fGsqw/VTPcoLtUO HVng== X-Gm-Message-State: AOJu0Yxp/arhy8wuyG0HlhxmFynULDtCi1oAQoWCpl+/8eB0JREFQdeP v6ks9cxXBGzoe5PMWW4UuwLT8pMC1veoz6WY0M1xPiluR2txNYy+a+C+Rw== X-Google-Smtp-Source: AGHT+IHDMsDC5fhe/N7zHMbAe760SlKOpfirGBaN0Lq6v4MCBEBC2h33cV9Mo7Sv8Q8k1SY71gq96g== X-Received: by 2002:a17:902:db01:b0:20c:9983:27ae with SMTP id d9443c01a7336-210c6c88004mr551524995ad.48.1730952653422; Wed, 06 Nov 2024 20:10:53 -0800 (PST) From: Alistair Francis X-Google-Original-From: Alistair Francis To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Max Chou , Daniel Henrique Barboza , Alistair Francis Subject: [PULL 09/12] target/riscv: rvv: Provide group continuous ld/st flow for unit-stride ld/st instructions Date: Thu, 7 Nov 2024 14:10:13 +1000 Message-ID: <20241107041016.40800-10-alistair.francis@wdc.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241107041016.40800-1-alistair.francis@wdc.com> References: <20241107041016.40800-1-alistair.francis@wdc.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::635; envelope-from=alistair23@gmail.com; helo=mail-pl1-x635.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 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 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: 1730952736545116600 Content-Type: text/plain; charset="utf-8" From: Max Chou 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 Message-ID: <20240918171412.150107-7-max.chou@sifive.com> Signed-off-by: Alistair Francis --- 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 d8d476c3ea..3d10ff94cd 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -190,6 +190,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) @@ -298,24 +337,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.47.0