From patchwork Sun Jan 26 03:32:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: daichengrong X-Patchwork-Id: 105394 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B99EC3858424 for ; Sun, 26 Jan 2025 03:38:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B99EC3858424 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by sourceware.org (Postfix) with ESMTPS id 595DD3858406 for ; Sun, 26 Jan 2025 03:33:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 595DD3858406 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=iscas.ac.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 595DD3858406 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737862398; cv=none; b=SujrjvqpHcLnNGwBlW19EnoOiWbdie3zOR5jME5g+xy1sp3sVkwNkdgJ4MaU525/8rY/IjI7t5vdZiImBaIAGAP6aVFdhy0ENY/gSIkVDiWSy4VEY0lVP91VhvF8PUzj9x3qRgTC4kl1yEWnkn5kO9hrWTFsOSKSDj4yVfAL/oU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737862398; c=relaxed/simple; bh=6clYkB/8p0uKMvLpjhccTbK17/rZimtw78wMsmThQSg=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=DiFY2XuKX3jojyzfbcQK8MGu47oAnbk0D9O3/4U0CcZXis9WBPiLcIQ/6l/ygM8hQ3LVVNxnk1RDcwBDJ0IyLU9L0L0M+7TJsqNgLRDW1omOi3a2Ndr//RsV0j6cL0blqlnWc+OEMEQlyuyFDoaebxxvoeu6cCnL6+xNcvVqETo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 595DD3858406 Received: from chengrong-ubuntu-02.home.arpa (unknown [124.16.138.129]) by APP-01 (Coremail) with SMTP id qwCowAB3f1f1rJVnzKl3CQ--.15818S3; Sun, 26 Jan 2025 11:33:11 +0800 (CST) From: daichengrong@iscas.ac.cn To: libc-alpha@sourceware.org Cc: aswaterman@gmail.com, palmer@rivosinc.com, adhemerval.zanella@linaro.org, darius@bluespec.com, jiageng08@iscas.ac.cn, enh@google.com Subject: [PATCH v5 1/3] check rvv support in asm at sysdeps/riscv Date: Sun, 26 Jan 2025 11:32:12 +0800 Message-Id: <20250126033214.809182-2-daichengrong@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250126033214.809182-1-daichengrong@iscas.ac.cn> References: <20250126033214.809182-1-daichengrong@iscas.ac.cn> MIME-Version: 1.0 X-CM-TRANSID: qwCowAB3f1f1rJVnzKl3CQ--.15818S3 X-Coremail-Antispam: 1UD129KBjvJXoWxuF1rXw4ftFW7KFW8tF1fZwb_yoW5Ww1rpF ySkr15GasxArn3CanIyry2gr4rJF4rCr1rAw1fCw1UJaykAa98ZrZruw1ayrs5WF95ZFn8 Cr1rK3W2k398XrDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUm2b7Iv0xC_KF4lb4IE77IF4wAFF20E14v26r4j6ryUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI 8067AKxVWUGwA2048vs2IY020Ec7CjxVAFwI0_JFI_Gr1l8cAvFVAK0II2c7xJM28CjxkF 64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcV CY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv 6xkF7I0E14v26F4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzV Aqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Gr1j6F4UJwAm 72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lw4CEc2x0rVAKj4xxMxkF7I0En4 kS14v26r126r1DMxkIecxEwVAFwVW8GwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMI IF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVF xhVjvjDU0xZFpf9x07jxcTPUUUUU= X-Originating-IP: [124.16.138.129] X-CM-SenderInfo: pgdluxxhqj201qj6x2xfdvhtffof0/ X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: daichengrong Changes in v5: update riscv vector support check to assembler update vector support macro to HAVE_RISCV_ASM_VECTOR_SUPPORT --- config.h.in | 3 +++ sysdeps/riscv/configure | 30 ++++++++++++++++++++++++++++++ sysdeps/riscv/configure.ac | 20 ++++++++++++++++++++ 3 files changed, 53 insertions(+) mode change 100644 => 100755 sysdeps/riscv/configure diff --git a/config.h.in b/config.h.in index cdbd555366..7802e8f9c4 100644 --- a/config.h.in +++ b/config.h.in @@ -139,6 +139,9 @@ /* RISC-V floating-point ABI for ld.so. */ #undef RISCV_ABI_FLEN +/* Define if assembler supports vector instructions on RISC-V. */ +#undef HAVE_RISCV_ASM_VECTOR_SUPPORT + /* LOONGARCH integer ABI for ld.so. */ #undef LOONGARCH_ABI_GRLEN diff --git a/sysdeps/riscv/configure b/sysdeps/riscv/configure old mode 100644 new mode 100755 index 3ae4ae3bdb..10ee993f75 --- a/sysdeps/riscv/configure +++ b/sysdeps/riscv/configure @@ -83,3 +83,33 @@ if test "$libc_cv_static_pie_on_riscv" = yes; then fi +# Check if gcc assembler supports attribute riscv vector macro. +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for gcc attribute riscv vector support" >&5 +printf %s "checking for gcc attribute riscv vector support... " >&6; } +if test ${libc_cv_gcc_rvv+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) cat > conftest.S <&5 \ + 2>&5 ; then + libc_cv_gcc_rvv=yes +fi +rm -f conftest* ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_gcc_rvv" >&5 +printf "%s\n" "$libc_cv_gcc_rvv" >&6; } + +if test x"$libc_cv_gcc_rvv" = xyes; then + printf "%s\n" "#define HAVE_RISCV_ASM_VECTOR_SUPPORT 1" >>confdefs.h + +fi +config_vars="$config_vars +have-gcc-riscv-rvv = $libc_cv_gcc_rvv" + diff --git a/sysdeps/riscv/configure.ac b/sysdeps/riscv/configure.ac index ee3d1ed014..b582078586 100644 --- a/sysdeps/riscv/configure.ac +++ b/sysdeps/riscv/configure.ac @@ -43,3 +43,23 @@ EOF if test "$libc_cv_static_pie_on_riscv" = yes; then AC_DEFINE(SUPPORT_STATIC_PIE) fi + +# Check if gcc assembler supports attribute riscv vector macro. +AC_CACHE_CHECK([for gcc attribute riscv vector support], + libc_cv_gcc_rvv, [dnl +cat > conftest.S <&AS_MESSAGE_LOG_FD \ + 2>&AS_MESSAGE_LOG_FD ; then + libc_cv_gcc_rvv=yes +fi +rm -f conftest*]) + +if test x"$libc_cv_gcc_rvv" = xyes; then + AC_DEFINE(HAVE_RISCV_ASM_VECTOR_SUPPORT) +fi +LIBC_CONFIG_VAR([have-gcc-riscv-rvv], [$libc_cv_gcc_rvv]) From patchwork Sun Jan 26 03:32:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: daichengrong X-Patchwork-Id: 105392 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 292063858420 for ; Sun, 26 Jan 2025 03:35:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 292063858420 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by sourceware.org (Postfix) with ESMTPS id 95CE2385840C for ; Sun, 26 Jan 2025 03:33:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 95CE2385840C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=iscas.ac.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 95CE2385840C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737862398; cv=none; b=g+B4k/5EOhoGB3J8+pvKJMbCXunTK9G4/7YhfDhrJ6LYWelzD3W+ynZDtg0CVGw1ztvEcaiNvGnPrXGlyv2Ft2jHFUm2i6xPrVxMawxj9nPx/bWrxAQyhKy7iLPtrrJnnfXosAdME29vJHkzPKNrb73AazTavEh9Nq3JX0BXT2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737862398; c=relaxed/simple; bh=QALCklik7XlSHLwwQfpP56+fg8zXOcqEeJIvEuBPtU0=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=lrcgWn4GwskjsUYM0fbO5viX94Xz2gXxE9jN0X7foj5CjhMfgnT6gAalttInF92vqZyq6FruC+Ax50k3raqTJXJ/4bC0PoK2grjA1o6SVDYEkY15tYOAvNkxBNts09AJdCQaokvKFaFBul8h8P0dywXo4hrICD2cUH3CeyPJ76o= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 95CE2385840C Received: from chengrong-ubuntu-02.home.arpa (unknown [124.16.138.129]) by APP-01 (Coremail) with SMTP id qwCowAB3f1f1rJVnzKl3CQ--.15818S4; Sun, 26 Jan 2025 11:33:12 +0800 (CST) From: daichengrong@iscas.ac.cn To: libc-alpha@sourceware.org Cc: aswaterman@gmail.com, palmer@rivosinc.com, adhemerval.zanella@linaro.org, darius@bluespec.com, jiageng08@iscas.ac.cn, enh@google.com Subject: [PATCH v5 2/3] add hwprobe support for dl_hwcap Date: Sun, 26 Jan 2025 11:32:13 +0800 Message-Id: <20250126033214.809182-3-daichengrong@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250126033214.809182-1-daichengrong@iscas.ac.cn> References: <20250126033214.809182-1-daichengrong@iscas.ac.cn> MIME-Version: 1.0 X-CM-TRANSID: qwCowAB3f1f1rJVnzKl3CQ--.15818S4 X-Coremail-Antispam: 1UD129KBjvJXoW7KrW3Ww1rWFW7ArWxCw48Zwb_yoW8Xr48pF 4Y93WYyFn8JFy7Cr9Ig3WjgF4F9F4kJ3WUAr9xCr1Utay5JrZ7X39I9r1fCF9xZFyfKayY yr1jg3sY9a9xZFDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUm2b7Iv0xC_KF4lb4IE77IF4wAFF20E14v26ryj6rWUM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI 8067AKxVWUXwA2048vs2IY020Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF 64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcV CY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv 6xkF7I0E14v26F4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzV Aqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Gr1j6F4UJwAm 72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lw4CEc2x0rVAKj4xxMxkF7I0En4 kS14v26r126r1DMxkIecxEwVAFwVW8GwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMI IF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVF xhVjvjDU0xZFpf9x07jSLvtUUUUU= X-Originating-IP: [124.16.138.129] X-CM-SenderInfo: pgdluxxhqj201qj6x2xfdvhtffof0/ X-Spam-Status: No, score=-13.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: daichengrong --- sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h b/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h index bebad6cf70..250f019766 100644 --- a/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h +++ b/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h @@ -61,6 +61,26 @@ struct riscv_hwprobe { #endif /* RISCV_HWPROBE_KEY_MVENDORID */ +#ifndef _UAPI_ASM_RISCV_HWCAP_H +#define _UAPI_ASM_RISCV_HWCAP_H + +/* + * Linux saves the floating-point registers according to the ISA Linux is + * executing on, as opposed to the ISA the user program is compiled for. This + * is necessary for a handful of esoteric use cases: for example, userspace + * threading libraries must be able to examine the actual machine state in + * order to fully reconstruct the state of a thread. + */ +#define COMPAT_HWCAP_ISA_I (1 << ('I' - 'A')) +#define COMPAT_HWCAP_ISA_M (1 << ('M' - 'A')) +#define COMPAT_HWCAP_ISA_A (1 << ('A' - 'A')) +#define COMPAT_HWCAP_ISA_F (1 << ('F' - 'A')) +#define COMPAT_HWCAP_ISA_D (1 << ('D' - 'A')) +#define COMPAT_HWCAP_ISA_C (1 << ('C' - 'A')) +#define COMPAT_HWCAP_ISA_V (1 << ('V' - 'A')) + +#endif /* _UAPI_ASM_RISCV_HWCAP_H */ + __BEGIN_DECLS extern int __riscv_hwprobe (struct riscv_hwprobe *__pairs, size_t __pair_count, From patchwork Sun Jan 26 03:32:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: daichengrong X-Patchwork-Id: 105393 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 612D93858428 for ; Sun, 26 Jan 2025 03:36:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 612D93858428 X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by sourceware.org (Postfix) with ESMTPS id 679583858414 for ; Sun, 26 Jan 2025 03:33:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 679583858414 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=iscas.ac.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 679583858414 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737862400; cv=none; b=IWlAX6hl8QTvEN+Io/j5txH6BBXTovGPHEtYADmgx+SfBA4wTNXNX8T1zIpE9gfZItT7Z81hIz3oFZ4S97aQoYdg8WwTUQq5XKDt4DqtYAJXkpWzjmYZDwUwjnqiwuntl7KTig2/qlP/L1gXXDnY0oE4eaQHUkObzcqskYILr5A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737862400; c=relaxed/simple; bh=4B0QE7L41Vs5jeU4EXGfZ7G0LSe4ZXwMDQhb29MspIQ=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=B7q21nMtG4V+YLXm65En0nouEJTjK3aeFvyx7oR4UjVrwSglsk0YFIIOgC6jgax1zn7zA/sb4I8FdHKAONGopmDh9L350Os2dxo51QYbFCSNHnCPZzQF89MvGgLQzjE7tAXwrR6CZggYkTY0haQlG/UXd0ixHbM/N+6PdiC24hg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 679583858414 Received: from chengrong-ubuntu-02.home.arpa (unknown [124.16.138.129]) by APP-01 (Coremail) with SMTP id qwCowAB3f1f1rJVnzKl3CQ--.15818S5; Sun, 26 Jan 2025 11:33:13 +0800 (CST) From: daichengrong@iscas.ac.cn To: libc-alpha@sourceware.org Cc: aswaterman@gmail.com, palmer@rivosinc.com, adhemerval.zanella@linaro.org, darius@bluespec.com, jiageng08@iscas.ac.cn, enh@google.com Subject: [PATCH v5 3/3] add riscv vector support for memcpy Date: Sun, 26 Jan 2025 11:32:14 +0800 Message-Id: <20250126033214.809182-4-daichengrong@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250126033214.809182-1-daichengrong@iscas.ac.cn> References: <20250126033214.809182-1-daichengrong@iscas.ac.cn> MIME-Version: 1.0 X-CM-TRANSID: qwCowAB3f1f1rJVnzKl3CQ--.15818S5 X-Coremail-Antispam: 1UD129KBjvJXoWxuw48AFy7KFykKw1furykKrg_yoW7WrWxpF s5C3W5Kan5Jr1xGrWSkw1jg3W5Zry8JF1Yk34Y93yUA3yUZr47Ja92ywn8GFyDtr4SkFWf ZFn5WF1qk3yYva7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUm2b7Iv0xC_Kw4lb4IE77IF4wAFF20E14v26rWj6s0DM7CY07I2 0VC2zVCF04k26cxKx2IYs7xG6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI 8067AKxVWUWwA2048vs2IY020Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF 64kEwVA0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcV CY1x0267AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIE14v26r4UJVWxJr1l84ACjcxK6I8E87Iv 6xkF7I0E14v26F4UJVW0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzV Aqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAFwI0_Gr1j6F4UJwAm 72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lw4CEc2x0rVAKj4xxMxkF7I0En4 kS14v26r126r1DMxkIecxEwVAFwVW8GwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkE bVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67 AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI 42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMI IF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVF xhVjvjDU0xZFpf9x07bF2-5UUUUU= X-Originating-IP: [124.16.138.129] X-CM-SenderInfo: pgdluxxhqj201qj6x2xfdvhtffof0/ X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org From: daichengrong Changes in v2: delete size-0 branch Changes in v2: delete size-0 branch Changes in v3: Remove unnecessary whitespace Changes in v4: update rvv memcpy support by compiler check whether rvv enabled by dl_hwcap Changes in v5: fix Indentation in memcpy.c check ifunc-impl-list memcpy vector support with by dl_hwcap --- sysdeps/riscv/multiarch/memcpy_vector.S | 35 +++++++++++++++++++ .../unix/sysv/linux/riscv/multiarch/Makefile | 8 +++++ .../linux/riscv/multiarch/ifunc-impl-list.c | 13 +++++++ .../unix/sysv/linux/riscv/multiarch/memcpy.c | 7 ++++ 4 files changed, 63 insertions(+) create mode 100644 sysdeps/riscv/multiarch/memcpy_vector.S diff --git a/sysdeps/riscv/multiarch/memcpy_vector.S b/sysdeps/riscv/multiarch/memcpy_vector.S new file mode 100644 index 0000000000..91236e8aa9 --- /dev/null +++ b/sysdeps/riscv/multiarch/memcpy_vector.S @@ -0,0 +1,35 @@ +/* memcpy for RISC-V Vector. + Copyright (C) 2024-2025 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + + +#include +#include + +ENTRY (__memcpy_vector) + mv a6, a0 +L(loop): + vsetvli a3,a2,e8,m8,ta,ma + vle8.v v8,(a1) + vse8.v v8,(a6) + add a1,a1,a3 + sub a2,a2,a3 + add a6,a6,a3 + bnez a2,L(loop) +L(ret): + ret +END (__memcpy_vector) diff --git a/sysdeps/unix/sysv/linux/riscv/multiarch/Makefile b/sysdeps/unix/sysv/linux/riscv/multiarch/Makefile index fcef5659d4..394033e077 100644 --- a/sysdeps/unix/sysv/linux/riscv/multiarch/Makefile +++ b/sysdeps/unix/sysv/linux/riscv/multiarch/Makefile @@ -5,5 +5,13 @@ sysdep_routines += \ memcpy_noalignment \ # sysdep_routines +ifeq ($(have-gcc-riscv-rvv),yes) +sysdep_routines += \ + memcpy_vector \ + # rvv sysdep_routines + +ASFLAGS-memcpy_vector.S += -march=rv64gcv +endif + CFLAGS-memcpy_noalignment.c += -mno-strict-align endif diff --git a/sysdeps/unix/sysv/linux/riscv/multiarch/ifunc-impl-list.c b/sysdeps/unix/sysv/linux/riscv/multiarch/ifunc-impl-list.c index 1c1deca8f6..2088097558 100644 --- a/sysdeps/unix/sysv/linux/riscv/multiarch/ifunc-impl-list.c +++ b/sysdeps/unix/sysv/linux/riscv/multiarch/ifunc-impl-list.c @@ -19,6 +19,7 @@ #include #include #include +#include size_t __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, @@ -27,6 +28,9 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, size_t i = max; bool fast_unaligned = false; +#if defined(HAVE_RISCV_ASM_VECTOR_SUPPORT) + bool rvv_ext = false; +#endif struct riscv_hwprobe pair = { .key = RISCV_HWPROBE_KEY_CPUPERF_0 }; if (__riscv_hwprobe (&pair, 1, 0, NULL, 0) == 0 @@ -34,7 +38,16 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, == RISCV_HWPROBE_MISALIGNED_FAST) fast_unaligned = true; +#if defined(HAVE_RISCV_ASM_VECTOR_SUPPORT) + if (GLRO(dl_hwcap) & COMPAT_HWCAP_ISA_V) + rvv_ext = true; +#endif + IFUNC_IMPL (i, name, memcpy, +#if defined(HAVE_RISCV_ASM_VECTOR_SUPPORT) + IFUNC_IMPL_ADD (array, i, memcpy, rvv_ext, + __memcpy_vector) +#endif IFUNC_IMPL_ADD (array, i, memcpy, fast_unaligned, __memcpy_noalignment) IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_generic)) diff --git a/sysdeps/unix/sysv/linux/riscv/multiarch/memcpy.c b/sysdeps/unix/sysv/linux/riscv/multiarch/memcpy.c index 8544f5402a..1982e4ab65 100644 --- a/sysdeps/unix/sysv/linux/riscv/multiarch/memcpy.c +++ b/sysdeps/unix/sysv/linux/riscv/multiarch/memcpy.c @@ -32,11 +32,18 @@ extern __typeof (__redirect_memcpy) __libc_memcpy; extern __typeof (__redirect_memcpy) __memcpy_generic attribute_hidden; extern __typeof (__redirect_memcpy) __memcpy_noalignment attribute_hidden; +extern __typeof (__redirect_memcpy) __memcpy_vector attribute_hidden; static inline __typeof (__redirect_memcpy) * select_memcpy_ifunc (uint64_t dl_hwcap, __riscv_hwprobe_t hwprobe_func) { unsigned long long int v; + +#if defined(HAVE_RISCV_ASM_VECTOR_SUPPORT) + if (dl_hwcap & COMPAT_HWCAP_ISA_V) + return __memcpy_vector; +#endif + if (__riscv_hwprobe_one (hwprobe_func, RISCV_HWPROBE_KEY_CPUPERF_0, &v) == 0 && (v & RISCV_HWPROBE_MISALIGNED_MASK) == RISCV_HWPROBE_MISALIGNED_FAST) return __memcpy_noalignment;