From patchwork Tue Dec 5 12:03:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liao Shihua X-Patchwork-Id: 174017 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp3380039vqy; Tue, 5 Dec 2023 04:06:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IEdkBZZTXDBkqUhC4HAUsR/y+tuYl5s82WdcaUsQqg+F9aUKJKmvJoZ7n9M0wAMrwLuVAVi X-Received: by 2002:a05:6102:1914:b0:464:8f9f:f08a with SMTP id jk20-20020a056102191400b004648f9ff08amr1027839vsb.2.1701777968609; Tue, 05 Dec 2023 04:06:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1701777968; cv=pass; d=google.com; s=arc-20160816; b=yKyj1XT10XGDrX93S4c7/F7S8eRRHCRFT7aDI6B9mt4DTbXDd3F1mYPJQX51SULRxL 8wEYr6/CiLy4RtPEVYB1FCLeRCMmGDXmmz6R+2GhVk9vcGcvXtf++sVipKJP9ByWaODt PjaMG8kMzbrzroadeWJWQG9dcMv/BaqguXqW2NmbKofq67G4n25JGm+qYqCf/fBm9O9k YIcxVXJOcvm7txgsulJy4KTMpGjrGBHSB3XMhUVw393M/UgnfB+o+PpHSNmH/4gJQvA6 +UDax2J49RyMZkgNMk8/pHqybwVdkJmAEz36sOF9T83xHeLXaPNSqOnjo0aYYFFdFP0X jvPg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:arc-filter:dmarc-filter:delivered-to; bh=0Og+Khk0uJsYr1UTfOJEep8i7JLlONrguADbZuUnZ0M=; fh=fNhdqjg9dY5KTxqPFtwAiCwgpnp9L8nw+Y0KZJ/3XVg=; b=pu+cRPMhEI+Ln0p+j+fauPnxDek9QFO0RSu1NQuXZ9QOy/hmFpXT76Z9EO3d4zPMRp KbnOHWUJlHLTlNb78lnN51wxS3+w7rUlbDEoT5s1jqhOqqmgN3bWwzOiS8+jLH8jJl64 6PlhEoh4tPO1HxN2VL5gmrTgfxNHXcR8Ma8PQCYs+o94qdkGbyGpD9X9edUK5fSDe2CL 4nXRI/dmXFLCeNjiFRJYoYjkLKO+Bk417DRsi7OvYV+hvKcWLG8xl42euNw1G4qvag/B OEsQnj8D2Y+egaA4kEXNCyrynK2iICDVZGGqjTFaMSWiH830mIMz6t6SZCcBAbl7H4aB h1AA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id gt14-20020a0561022a4e00b00464826d6ee0si941792vsb.146.2023.12.05.04.06.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 04:06:08 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69371384DEC0 for ; Tue, 5 Dec 2023 12:06:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by sourceware.org (Postfix) with ESMTPS id 2F5D63858C2A for ; Tue, 5 Dec 2023 12:05:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2F5D63858C2A 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 2F5D63858C2A 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=1701777939; cv=none; b=W7ETlXC6apWm2JtgwFr8IqH9YFZWt6pfz/sPxvdB/zE0MMXsPAz3jY9vxnUrjwszehF1+75yd7M7i5X4ivt2wL+mFv6oAJLVClBoooEoeDfzn5DgrlndfxNibY7GwYB9avIM6rdLN5VMD9OaIrOUWQ31k2FJAuknzdmJrCJjmb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701777939; c=relaxed/simple; bh=UDmDDgMda/6bCQQV1UdSAKpFZNJWPxcYFyyInwClac4=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=F6+jFd3ct3wAbsQb02VYfCausJIUmEziGljP/pzcZX4YW9XFZgnvS09ROf1bZS0UeXjCS84aeKja3/8GJOKEEAKS7qFnBdD0gFDwNqedZuJNhWAnkrchs3PARrMHmLocdrGTEe+dYu/Wd2EJoc8qztVKi1ynz7pjl8Iaxhcye6A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost.localdomain (unknown [122.8.183.87]) by APP-01 (Coremail) with SMTP id qwCowABnSDESEW9leKp4AQ--.30748S3; Tue, 05 Dec 2023 20:01:34 +0800 (CST) From: Liao Shihua To: gcc-patches@gcc.gnu.org Cc: christoph.muellner@vrull.eu, kito.cheng@gmail.com, shiyulong@iscas.ac.cn, jiawei@iscas.ac.cn, chenyixuan@iscas.an.cn, jeffreyalaw@gmail.com, Liao Shihua Subject: [PATCH 1/2] RISC-V: Add C intrinsics of Scalar Crypto Extension Date: Tue, 5 Dec 2023 20:03:11 +0800 Message-Id: <20231205120312.2821765-2-shihua@iscas.ac.cn> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231205120312.2821765-1-shihua@iscas.ac.cn> References: <20231205120312.2821765-1-shihua@iscas.ac.cn> MIME-Version: 1.0 X-CM-TRANSID: qwCowABnSDESEW9leKp4AQ--.30748S3 X-Coremail-Antispam: 1UD129KBjvAXoW3Cr4DGFWkCr1xAF1UCr13twb_yoW8WF15Ko WFgr4rAFyfGr13uFsIkr1UCryqqa48ZF4UZay5ZrW5KFn3Crnakr1rtr1kAF4jgrWfA3W5 ZF92qF4fAFW7Cr93n29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UjIYCTnIWjp_UUUYZ7AC8VAFwI0_Xr0_Wr1l1xkIjI8I6I8E6xAIw20EY4v20xva j40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l82xGYIkIc2x26280x7IE14v26r18M28IrcIa0x kI8VCY1x0267AKxVWUCVW8JwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK021l84AC jcxK6xIIjxv20xvE14v26r1j6r1xM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j6F4UM2 8EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_Xr1l42xK82 IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC2 0s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMI IF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF 0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87 Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfU06wZDUUUU X-Originating-IP: [122.8.183.87] X-CM-SenderInfo: xvklx33d6l2u1dvotugofq/1tbiCQoQEWVu9MZZPgAAsc X-Spam-Status: No, score=-12.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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784443535118144388 X-GMAIL-MSGID: 1784443535118144388 This patch adds C intrinsics for Scalar Crypto Extension. gcc/ChangeLog: * config.gcc: Add riscv_crypto.h. * config/riscv/riscv_crypto.h: New file. gcc/testsuite/ChangeLog: * gcc.target/riscv/scalar_crypto_intrinsic-1.c: New test. * gcc.target/riscv/scalar_crypto_intrinsic-2.c: New test. --- gcc/config.gcc | 2 +- gcc/config/riscv/riscv_crypto.h | 280 ++++++++++++++++++ .../riscv/scalar_crypto_intrinsic-1.c | 115 +++++++ .../riscv/scalar_crypto_intrinsic-2.c | 122 ++++++++ 4 files changed, 518 insertions(+), 1 deletion(-) create mode 100644 gcc/config/riscv/riscv_crypto.h create mode 100644 gcc/testsuite/gcc.target/riscv/scalar_crypto_intrinsic-1.c create mode 100644 gcc/testsuite/gcc.target/riscv/scalar_crypto_intrinsic-2.c diff --git a/gcc/config.gcc b/gcc/config.gcc index b88591b6fd8..d67fe8b6a6f 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -548,7 +548,7 @@ riscv*) extra_objs="${extra_objs} riscv-vector-builtins.o riscv-vector-builtins-shapes.o riscv-vector-builtins-bases.o" extra_objs="${extra_objs} thead.o riscv-target-attr.o" d_target_objs="riscv-d.o" - extra_headers="riscv_vector.h" + extra_headers="riscv_vector.h riscv_crypto.h" target_gtfiles="$target_gtfiles \$(srcdir)/config/riscv/riscv-vector-builtins.cc" target_gtfiles="$target_gtfiles \$(srcdir)/config/riscv/riscv-vector-builtins.h" ;; diff --git a/gcc/config/riscv/riscv_crypto.h b/gcc/config/riscv/riscv_crypto.h new file mode 100644 index 00000000000..9335ffda20d --- /dev/null +++ b/gcc/config/riscv/riscv_crypto.h @@ -0,0 +1,280 @@ +/* RISC-V 'Scalar Crypto' Extension intrinsics include file. + Copyright (C) 2023 Free Software Foundation, Inc. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC 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 General Public + License for more details. + + Under Section 7 of GPL version 3, you are granted additional + permissions described in the GCC Runtime Library Exception, version + 3.1, as published by the Free Software Foundation. + + You should have received a copy of the GNU General Public License and + a copy of the GCC Runtime Library Exception along with this program; + see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + . */ + +#ifndef __RISCV_SCALAR_CRYPTO_H +#define __RISCV_SCALAR_CRYPTO_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(__riscv_zknd) + +#if __riscv_xlen == 32 + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes32dsi (uint32_t rs1, uint32_t rs2, const int bs) +{ + return __builtin_riscv_aes32dsi (rs1,rs2,bs); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes32dsmi (uint32_t rs1, uint32_t rs2, const int bs) +{ + return __builtin_riscv_aes32dsmi (rs1,rs2,bs); +} +#endif + +#if __riscv_xlen == 64 + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes64ds (uint64_t rs1, uint64_t rs2) +{ + return __builtin_riscv_aes64ds (rs1,rs2); +} + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes64dsm (uint64_t rs1, uint64_t rs2) +{ + return __builtin_riscv_aes64dsm (rs1,rs2); +} + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes64im (uint64_t rs1) +{ + return __builtin_riscv_aes64im (rs1); +} +#endif +#endif // ZKND + +#if (defined(__riscv_zknd) || defined(__riscv_zkne)) && (__riscv_xlen == 64) + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes64ks1i(uint64_t rs1, const int rnum) +{ + return __builtin_riscv_aes64ks1i(rs1,rnum); +} + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes64ks2(uint64_t rs1, uint64_t rs2) +{ + return __builtin_riscv_aes64ks2(rs1,rs2); +} + +#endif // ZKND || ZKNE + +#if defined(__riscv_zkne) + +#if __riscv_xlen == 32 + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes32esi (uint32_t rs1, uint32_t rs2, const int bs) +{ + return __builtin_riscv_aes32esi (rs1,rs2,bs); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes32esmi (uint32_t rs1, uint32_t rs2, const int bs) +{ + return __builtin_riscv_aes32esmi (rs1,rs2,bs); +} +#endif + +#if __riscv_xlen == 64 + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes64es (uint64_t rs1,uint64_t rs2) +{ + return __builtin_riscv_aes64es (rs1,rs2); +} + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_aes64esm (uint64_t rs1,uint64_t rs2) +{ + return __builtin_riscv_aes64esm (rs1,rs2); +} +#endif +#endif // ZKNE + +#if defined(__riscv_zknh) + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha256sig0(uint32_t rs1) +{ + return __builtin_riscv_sha256sig0 (rs1); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha256sig1(uint32_t rs1) +{ + return __builtin_riscv_sha256sig1 (rs1); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha256sum0 (uint32_t rs1) +{ + return __builtin_riscv_sha256sum0 (rs1); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha256sum1 (uint32_t rs1) +{ + return __builtin_riscv_sha256sum1 (rs1); +} + +#if __riscv_xlen == 32 + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sig0h(uint32_t rs1, uint32_t rs2) +{ + return __builtin_riscv_sha512sig0h (rs1,rs2); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sig0l(uint32_t rs1, uint32_t rs2) +{ + return __builtin_riscv_sha512sig0l (rs1,rs2); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sig1h(uint32_t rs1, uint32_t rs2) +{ + return __builtin_riscv_sha512sig1h (rs1,rs2); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sig1l(uint32_t rs1, uint32_t rs2) +{ + return __builtin_riscv_sha512sig1l (rs1,rs2); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sum0r(uint32_t rs1, uint32_t rs2) +{ + return __builtin_riscv_sha512sum0r (rs1,rs2); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sum1r(uint32_t rs1, uint32_t rs2) +{ + return __builtin_riscv_sha512sum1r (rs1,rs2); +} + +#endif + +#if __riscv_xlen == 64 + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sig0 (uint64_t rs1) +{ + return __builtin_riscv_sha512sig0 (rs1); +} + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sig1 (uint64_t rs1) +{ + return __builtin_riscv_sha512sig1 (rs1); +} + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sum0 (uint64_t rs1) +{ + return __builtin_riscv_sha512sum0 (rs1); +} + +extern __inline uint64_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sha512sum1 (uint64_t rs1) +{ + return __builtin_riscv_sha512sum1 (rs1); +} +#endif +#endif // ZKNH + +#if defined(__riscv_zksh) + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sm3p0(uint32_t rs1) +{ + return __builtin_riscv_sm3p0 (rs1); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sm3p1(uint32_t rs1) +{ + return __builtin_riscv_sm3p1 (rs1); +} + +#endif // ZKSH + +#if defined(__riscv_zksed) + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sm4ed (uint32_t rs1, uint32_t rs2, const int bs) +{ + return __builtin_riscv_sm4ed (rs1,rs2,bs); +} + +extern __inline uint32_t +__attribute__((__gnu_inline__, __always_inline__, __artificial__)) +__riscv_sm4ks (uint32_t rs1, uint32_t rs2, const int bs) +{ + return __builtin_riscv_sm4ks (rs1,rs2,bs); +} + +#endif // ZKSED + +#if defined(__cplusplus) +} +#endif // __cplusplus +#endif // __RISCV_SCALAR_CRYPTO_H diff --git a/gcc/testsuite/gcc.target/riscv/scalar_crypto_intrinsic-1.c b/gcc/testsuite/gcc.target/riscv/scalar_crypto_intrinsic-1.c new file mode 100644 index 00000000000..d9d6261c0fd --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/scalar_crypto_intrinsic-1.c @@ -0,0 +1,115 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv32gc_zknd_zkne_zknh_zksed_zksh -mabi=ilp32d" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ + +#include "riscv_crypto.h" + +uint32_t foo1(uint32_t rs1, uint32_t rs2, const int bs) +{ + return __riscv_aes32dsi(rs1,rs2,bs); +} + +uint32_t foo2(uint32_t rs1, uint32_t rs2, const int bs) +{ + return __riscv_aes32dsmi(rs1,rs2,bs); +} + +uint32_t foo3(uint32_t rs1, uint32_t rs2, const int bs) +{ + return __riscv_aes32esi(rs1,rs2,bs); +} + +uint32_t foo4(uint32_t rs1, uint32_t rs2, const int bs) +{ + return __riscv_aes32esmi(rs1,rs2,bs); +} + +uint32_t foo5(uint32_t rs1) +{ + return __riscv_sha256sig0(rs1); +} + +uint32_t foo6(uint32_t rs1) +{ + return __riscv_sha256sig1(rs1); +} + +uint32_t foo7(uint32_t rs1) +{ + return __riscv_sha256sum0(rs1); +} + +uint32_t foo8(uint32_t rs1) +{ + return __riscv_sha256sum1(rs1); +} + +uint32_t foo9(uint32_t rs1, uint32_t rs2) +{ + return __riscv_sha512sig0h(rs1,rs2); +} + +uint32_t foo10(uint32_t rs1, uint32_t rs2) +{ + return __riscv_sha512sig0l(rs1,rs2); +} + +uint32_t foo11(uint32_t rs1, uint32_t rs2) +{ + return __riscv_sha512sig1h(rs1,rs2); +} + +uint32_t foo12(uint32_t rs1, uint32_t rs2) +{ + return __riscv_sha512sig1l(rs1,rs2); +} + +uint32_t foo13(uint32_t rs1, uint32_t rs2) +{ + return __riscv_sha512sum0r(rs1,rs2); +} + +uint32_t foo14(uint32_t rs1, uint32_t rs2) +{ + return __riscv_sha512sum1r(rs1,rs2); +} + +uint32_t foo15(uint32_t rs1) +{ + return __riscv_sm3p0(rs1); +} + +uint32_t foo16(uint32_t rs1) +{ + return __riscv_sm3p1(rs1); +} + +uint32_t foo17(uint32_t rs1, uint32_t rs2, const int bs) +{ + return __riscv_sm4ed(rs1,rs2,bs); +} + +uint32_t foo18(uint32_t rs1, uint32_t rs2, const int bs) +{ + return __riscv_sm4ks(rs1,rs2,bs); +} + +/* { dg-final { scan-assembler-times "aes32dsi" 1 } } */ +/* { dg-final { scan-assembler-times "aes32dsmi" 1 } } */ +/* { dg-final { scan-assembler-times "aes32esi" 1 } } */ +/* { dg-final { scan-assembler-times "aes32esmi" 1 } } */ +/* { dg-final { scan-assembler-times "sha256sig0" 1 } } */ +/* { dg-final { scan-assembler-times "sha256sig1" 1 } } */ +/* { dg-final { scan-assembler-times "sha256sum0" 1 } } */ +/* { dg-final { scan-assembler-times "sha256sum1" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sig0h" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sig0l" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sig1h" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sig1l" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sum0r" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sum1r" 1 } } */ +/* { dg-final { scan-assembler-times "sm3p0" 1 } } */ +/* { dg-final { scan-assembler-times "sm3p1" 1 } } */ +/* { dg-final { scan-assembler-times "sm4ks" 1 } } */ +/* { dg-final { scan-assembler-times "sm4ed" 1 } } */ + diff --git a/gcc/testsuite/gcc.target/riscv/scalar_crypto_intrinsic-2.c b/gcc/testsuite/gcc.target/riscv/scalar_crypto_intrinsic-2.c new file mode 100644 index 00000000000..3b7815a29e8 --- /dev/null +++ b/gcc/testsuite/gcc.target/riscv/scalar_crypto_intrinsic-2.c @@ -0,0 +1,122 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=rv64gc_zknd_zkne_zknh_zksed_zksh -mabi=lp64" } */ +/* { dg-skip-if "" { *-*-* } { "-g" "-flto"} } */ + +#include "riscv_crypto.h" + +uint64_t foo1(uint64_t rs1, uint64_t rs2) +{ + return __riscv_aes64ds(rs1,rs2); +} + +uint64_t foo2(uint64_t rs1, uint64_t rs2) +{ + return __riscv_aes64dsm(rs1,rs2); +} + +uint64_t foo3(uint64_t rs1) +{ + return __riscv_aes64im(rs1); +} + +uint64_t foo4(uint64_t rs1, const int rnum) +{ + return __riscv_aes64ks1i(rs1,rnum); +} + +uint64_t foo5(uint64_t rs1, uint64_t rs2) +{ + return __riscv_aes64ks2(rs1,rs2); +} + +uint64_t foo6(uint64_t rs1, uint64_t rs2) +{ + return __riscv_aes64es(rs1,rs2); +} + +uint64_t foo7(uint64_t rs1, uint64_t rs2) +{ + return __riscv_aes64esm(rs1,rs2); +} + +uint64_t foo8(uint64_t rs1) +{ + return __riscv_sha512sig0(rs1); +} + +uint64_t foo9(uint64_t rs1) +{ + return __riscv_sha512sig1(rs1); +} + +uint64_t foo10(uint64_t rs1) +{ + return __riscv_sha512sum0(rs1); +} + +uint64_t foo11(uint64_t rs1) +{ + return __riscv_sha512sum1(rs1); +} + +uint32_t foo12(uint32_t rs1) +{ + return __riscv_sha256sig0(rs1); +} + +uint32_t foo13(uint32_t rs1) +{ + return __riscv_sha256sig1(rs1); +} + +uint32_t foo14(uint32_t rs1) +{ + return __riscv_sha256sum0(rs1); +} + +uint32_t foo15(uint32_t rs1) +{ + return __riscv_sha256sum1(rs1); +} + +uint32_t foo16(uint32_t rs1) +{ + return __riscv_sm3p0(rs1); +} + +uint32_t foo17(uint32_t rs1) +{ + return __riscv_sm3p1(rs1); +} + +uint32_t foo18(uint32_t rs1, uint32_t rs2, const int bs) +{ + return __riscv_sm4ed(rs1,rs2,bs); +} + +uint32_t foo19(uint32_t rs1, uint32_t rs2, const int bs) +{ + return __riscv_sm4ks(rs1,rs2,bs); +} + +/* { dg-final { scan-assembler-times "aes64ds\t" 1 } } */ +/* { dg-final { scan-assembler-times "aes64dsm" 1 } } */ +/* { dg-final { scan-assembler-times "aes64ks1i" 1 } } */ +/* { dg-final { scan-assembler-times "aes64ks2" 1 } } */ +/* { dg-final { scan-assembler-times "aes64im" 1 } } */ +/* { dg-final { scan-assembler-times "aes64es\t" 1 } } */ +/* { dg-final { scan-assembler-times "aes64esm" 1 } } */ +/* { dg-final { scan-assembler-times "aes64ks1i" 1 } } */ +/* { dg-final { scan-assembler-times "aes64ks2" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sig0" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sig1" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sum0" 1 } } */ +/* { dg-final { scan-assembler-times "sha512sum1" 1 } } */ +/* { dg-final { scan-assembler-times "sha256sig0" 1 } } */ +/* { dg-final { scan-assembler-times "sha256sig1" 1 } } */ +/* { dg-final { scan-assembler-times "sha256sum0" 1 } } */ +/* { dg-final { scan-assembler-times "sha256sum1" 1 } } */ +/* { dg-final { scan-assembler-times "sm3p0" 1 } } */ +/* { dg-final { scan-assembler-times "sm3p1" 1 } } */ +/* { dg-final { scan-assembler-times "sm4ks" 1 } } */ +/* { dg-final { scan-assembler-times "sm4ed" 1 } } */