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 <m...@pqshield.com> > +// 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 <stdint.h> > +#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