Message ID | cover.1694134824.git.research_trasio@irq.a4lg.com |
---|---|
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ab0a:0:b0:3f2:4152:657d with SMTP id m10csp247148vqo; Thu, 7 Sep 2023 18:04:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/q5JV0BOXb/7v+94qdkk/RmqvbA6aBhzmUUeVstPjrpV5+YLHp2glbVKK6EGvtvqba8tn X-Received: by 2002:a19:6703:0:b0:501:bae0:36 with SMTP id b3-20020a196703000000b00501bae00036mr645918lfc.16.1694135073554; Thu, 07 Sep 2023 18:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694135073; cv=none; d=google.com; s=arc-20160816; b=vtsU1NuTuW/Hz7ExiW9vjeFfUfxug29oajB1ztC7UsDNS5n/AS1Et2TAWH01PTJhTT FJXx21NYhbSNsTN0u+ry2AHtE4om6EkeU9VuN9UQJ0dP0aTKFIZ4TEdbsVLqY+OA01sg xd4Tj6+F/Bb3Pi9ud0Nc/pVF1Mi2XJWqqcqkp1DXX4SIIaJ0RrCkswZbwLvUnJb2bHWJ g0XPHNRPX2nGsFn4dlmxxL9lHyqR50sCTWXppNSIXRUYjB5lDtjk3C5GTcHzVsHIve03 lP7kdPqEeoPbll70x6LWnPQXkDL2kQvATeRXcVdvYTIU3RdjxDQ7LcPBMXAgw/0k5IN7 jLIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=GmvYkgKwn/hHFatfSxllc8ySeU+0DvHxhrDLpwvy6/c=; fh=HKgiOHUFLyfVG2npWMLYE8/3Ecp4EiEdadhQOzpm3aI=; b=WpocnUVvOxr4+lTC050uaev6dOIcctdUNUhV1iku453g5yq2ayxMTVV3aUefeoPOTm nRg54lh61O7ETNQpAoR0OQjHuwix86siYQnIRR1r2mzN+YpI/WDIyNngG4ndE+/KUeuj +deQptkjRSITjJD1LS1snO5WbN3EryyivSf2xPbWY7cQzm3eIudn+81LDZ70sgf2D8Xh 5Vkf5741SnMXdhKWgdllx4ClSKuK5T2Dtht5Z3tQLxNYlOPASJ+jMEBwoiH7ckkHUXPa Cc6HAh23Qk2c607KOGiya3Z1Na8c3WHZ7racjSXtOvxgwwZeDDNsKwAKas+ymu0UKH/3 Ma9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vN9PdtVE; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id m8-20020aa7c488000000b0052569cb9936si484378edq.572.2023.09.07.18.04.33 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Sep 2023 18:04:33 -0700 (PDT) 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; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=vN9PdtVE; 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"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0E5C2385696A for <ouuuleilei@gmail.com>; Fri, 8 Sep 2023 01:04:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E5C2385696A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694135059; bh=GmvYkgKwn/hHFatfSxllc8ySeU+0DvHxhrDLpwvy6/c=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=vN9PdtVEC3EqfXvr88vqs9/SmKvuPK4pCJYo7zQQWm7Gdjl1ged0UAVC9cipR1SF8 D+iyfsjEYSF3cGwTDSgyXnG3C2BdieqEEZozPl5J4yGwtgoisnMZSqUBbbA1bEi/Wf pMdC9jWHLeO7i61qIvfmCdJAe/ClzfJGcHGUE2U8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-sender-0.a4lg.com (mail-sender-0.a4lg.com [IPv6:2401:2500:203:30b:4000:6bfe:4757:0]) by sourceware.org (Postfix) with ESMTPS id C5BD03858D1E for <gcc-patches@gcc.gnu.org>; Fri, 8 Sep 2023 01:03:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C5BD03858D1E Received: from [127.0.0.1] (localhost [127.0.0.1]) by mail-sender-0.a4lg.com (Postfix) with ESMTPSA id EA0C5300089; Fri, 8 Sep 2023 01:03:25 +0000 (UTC) To: Tsukasa OI <research_trasio@irq.a4lg.com>, Kito Cheng <kito.cheng@gmail.com>, Palmer Dabbelt <palmer@dabbelt.com>, Andrew Waterman <andrew@sifive.com>, Jim Wilson <jim.wilson.gcc@gmail.com>, Jeff Law <jeffreyalaw@gmail.com> Cc: gcc-patches@gcc.gnu.org Subject: [RFC PATCH 0/1] RISC-V: Make SHA-256, SM3 and SM4 builtins operate on uint32_t Date: Fri, 8 Sep 2023 01:03:12 +0000 Message-ID: <cover.1694134824.git.research_trasio@irq.a4lg.com> In-Reply-To: <cover.1694053004.git.research_trasio@irq.a4lg.com> References: <cover.1694053004.git.research_trasio@irq.a4lg.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KAM_MANYTO, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no 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 <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Tsukasa OI via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Tsukasa OI <research_trasio@irq.a4lg.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1776429378737821762 X-GMAIL-MSGID: 1776429378737821762 |
Series |
RISC-V: Make SHA-256, SM3 and SM4 builtins operate on uint32_t
|
|
Message
Tsukasa OI
Sept. 8, 2023, 1:03 a.m. UTC
Hi, This is built on another RFC PATCH "RISC-V: Change RISC-V bit manipulation / scalar crypto builtin types" and changes SHA-256, SM3 and SM4 intrinsics operate on uint32_t, not on XLEN-bit wide integers. This is in parity with the LLVM commit 599421ae36c3 ("[RISCV] Re-define sha256, Zksed, and Zksh intrinsics to use i32 types.") by Craig Topper. Because we had to refine the base instruction definitions, it was way harder than that of LLVM. Thankfully, we have a similar example: 32-bit integer instructions on RV64 such as ADDW. Before: riscv_<op>_si: For RV32, fully operate on uint32_t riscv_<op>_di: For RV64, fully operate on uint64_t After: *riscv_<op>_si: For RV32, fully operate on uint32_t riscv_<op>_di_extended: For RV64, input is uint32_t and output is int64_t, sign-extended from the int32_t result (represents a part of <op> behavior). riscv_<op>_si: Common (fully operate on uint32_t). On RV32, expands to *riscv_<op>_si. On RV64, initially expands to riscv_<op>_di_extended *and* extracts lower 32-bits from the int64_t result. Sincerely, Tsukasa Tsukasa OI (1): RISC-V: Make SHA-256, SM3 and SM4 builtins operate on uint32_t gcc/config/riscv/crypto.md | 161 ++++++++++++------ gcc/config/riscv/riscv-builtins.cc | 7 +- gcc/config/riscv/riscv-ftypes.def | 1 - gcc/config/riscv/riscv-scalar-crypto.def | 24 +-- .../gcc.target/riscv/zknh-sha256-32.c | 10 ++ .../riscv/{zknh-sha256.c => zknh-sha256-64.c} | 8 +- gcc/testsuite/gcc.target/riscv/zksed64.c | 4 +- gcc/testsuite/gcc.target/riscv/zksh64.c | 4 +- 8 files changed, 139 insertions(+), 80 deletions(-) create mode 100644 gcc/testsuite/gcc.target/riscv/zknh-sha256-32.c rename gcc/testsuite/gcc.target/riscv/{zknh-sha256.c => zknh-sha256-64.c} (78%) base-commit: daaed758517c81fc8f8bc6502be648aca51ab278 prerequisite-patch-id: 4f4a84ebc0c33ea159db4dcd70fa8894f27c638a prerequisite-patch-id: d2b85f777b042d349c5e232979ee219c8147c154