From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by sourceware.org (Postfix) with ESMTPS id 82BE5385843F for ; Mon, 28 Feb 2022 15:34:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 82BE5385843F Received: by mail-ej1-x62f.google.com with SMTP id bg10so25579080ejb.4 for ; Mon, 28 Feb 2022 07:34:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fP7kf4HOrA7oMrwQKy/VOo04Eg5SRMCP3m5SZEH4fsw=; b=xEk450rMV8Bvn8QGa696jlSMEiLbv3v67gvi9rlxvsDC1Jv43pgs+5WjUVLuFAXUMM GoFrDtHByfpQMPU8FgzKc9k8PYI33GDZSsNEvLE9n+mrjDm6WiMeoWBYS7o5F++wQKgI duSxkkB+ugt4IYX5h2q2cDyNOFT/i9YHo2xHfUbLRwzABO+IuCWx05iBokzdw6nWdCKu Ud7VEyn0tXwOBfX1nwg6QfTvFF6jiDqmg+DAlP61AsQA2UQfz2stEZGMmJUT4sKQhq4J 2kJGWXOK+JaYB8wpnYT2jjGjCeYGIRmWp9EhdlUBgZPcQy7ow6gDYylNPVIRXFTe3LZI bp+g== X-Gm-Message-State: AOAM530khEb4qsD0gajz0dGT5FILY/StSCInaOw79/ZjdFP9QLrnlVhx W3Vk82faTZPzxFz6prwMNzmnCHU9ERO61u4Iy/g= X-Google-Smtp-Source: ABdhPJyOr3Ed0JZG6Yy8NIdKlolXNTuAlPIsX8tD+vEKejUVJTG2c8Xvn2pd34bGmSZVjn4d207EFQy2kgKXgNNeHOg= X-Received: by 2002:a17:906:24cb:b0:6ce:b0a2:db5a with SMTP id f11-20020a17090624cb00b006ceb0a2db5amr15303675ejb.260.1646062462307; Mon, 28 Feb 2022 07:34:22 -0800 (PST) MIME-Version: 1.0 References: <20220223094418.3518-1-shihua@iscas.ac.cn> <20220223094418.3518-4-shihua@iscas.ac.cn> In-Reply-To: <20220223094418.3518-4-shihua@iscas.ac.cn> From: Kito Cheng Date: Mon, 28 Feb 2022 23:34:10 +0800 Message-ID: Subject: Re: [PATCH 3/5 V1] RISC-V:Implement intrinsics for Crypto extension To: shihua@iscas.ac.cn Cc: GCC Patches , ben.marshall@pqshield.com, Christoph Muellner , Andrew Waterman , jiawei , mjos@iki.fi, Kito Cheng Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Feb 2022 15:34:24 -0000 Those header files have license issues that should relicinced to GPL, and don't put rvk_asm_intrin.h rvk_emu_intrin.h, since they are not too meaningful when we have compiler support. General comment: - Use /* */ rather than //, that gives much more compatibility, that is illegal for c89. - Add a new line at the end of file, that prevents something like "\ No newline at end of file" in the diff. > --- /dev/null > +++ b/gcc/config/riscv/riscv_crypto_scalar.h > @@ -0,0 +1,247 @@ > +// riscv_crypto_scalar.h > +// 2021-11-08 Markku-Juhani O. Saarinen > +// Copyright (c) 2021, PQShield Ltd. All rights reserved. > + > +// === Scalar crypto: General mapping from intrinsics to compiler builtins, > +// inline assembler, or to an (insecure) porting / emulation layer. > + > +/* > + * _rv_*(...) > + * RV32/64 intrinsics that return the "long" data type > + * > + * _rv32_*(...) > + * RV32/64 intrinsics that return the "int32_t" data type > + * > + * _rv64_*(...) > + * RV64-only intrinsics that return the "int64_t" data type > + * > + */ > + > +#ifndef _RISCV_CRYPTO_SCALAR_H > +#define _RISCV_CRYPTO_SCALAR_H > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +#if !defined(__riscv_xlen) && !defined(RVKINTRIN_EMULATE) > +#warning "Target is not RISC-V. Enabling insecure emulation." > +#define RVKINTRIN_EMULATE 1 > +#endif > + > +#if defined(RVKINTRIN_EMULATE) > + > +// intrinsics via emulation (insecure -- porting / debug option) > +#include "rvk_emu_intrin.h" > +#define _RVK_INTRIN_IMPL(s) _rvk_emu_##s > + > +#elif defined(RVKINTRIN_ASSEMBLER) > + > +// intrinsics via inline assembler (builtins not available) > +#include "rvk_asm_intrin.h" > +#define _RVK_INTRIN_IMPL(s) _rvk_asm_##s > +#else > + > +// intrinsics via compiler builtins > +#include > +#define _RVK_INTRIN_IMPL(s) __builtin_riscv_##s > + > +#endif Drop rvk_emu_intrin.h and rvk_asm_intrin.h here. > + > +// set type if not already set > +#if !defined(RVKINTRIN_RV32) && !defined(RVKINTRIN_RV64) ... > +static inline long _rv_sm3p0(long rs1) > + { return _RVK_INTRIN_IMPL(sm3p0)(rs1); } // SM3P0 > + > +static inline long _rv_sm3p1(long rs1) > + { return _RVK_INTRIN_IMPL(sm3p1)(rs1); } // SM3P1 > + > +#ifdef __cplusplus > +} > +#endif > + #undef _RVK_INTRIN_IMPL before end of this header to prevent introducing unexpected symbols. > +#endif // _RISCV_CRYPTO_SCALAR_H > \ No newline at end of file