From: Gleb Popov <6yearold@gmail.com> Date: Thu, 28 Aug 2025 11:11:26 +0000 (+0300) Subject: sha512.c: Tweaks for Elbrus2000 architecture X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=19a09e714a0785dc2f23d6f14e9be1fb0d44095a;p=thirdparty%2Fopenssl.git sha512.c: Tweaks for Elbrus2000 architecture Reviewed-by: Andrew Dinh Reviewed-by: Igor Ustinov MergeDate: Fri Jul 31 16:49:24 2026 (Merged from https://github.com/openssl/openssl/pull/31269) --- diff --git a/crypto/sha/sha512.c b/crypto/sha/sha512.c index 9ba32f29264..637eac146fe 100644 --- a/crypto/sha/sha512.c +++ b/crypto/sha/sha512.c @@ -60,7 +60,7 @@ #include "internal/cryptlib.h" #include "crypto/sha.h" -#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(__s390__) || defined(__s390x__) || defined(__aarch64__) || defined(SHA512_ASM) +#if defined(__i386) || defined(__i386__) || defined(_M_IX86) || defined(__x86_64) || defined(_M_AMD64) || defined(_M_X64) || defined(__s390__) || defined(__s390x__) || defined(__aarch64__) || defined(__e2k__) || defined(SHA512_ASM) #define SHA512_BLOCK_CAN_MANAGE_UNALIGNED_DATA #endif @@ -405,6 +405,11 @@ static const SHA_LONG64 K512[80] = { asm ("rev8 %0, %1" \ : "=r"(ret) \ : "r"(x)); ret; }) +#elif defined(__e2k__) +#include +#define PULL64(x) __builtin_bswap64(x) +#define ROTR(x, s) ((s) > 48 ? __rolq((x), 64 - (s)) \ + : __rorq((x), (s))) #endif #if defined(__riscv_zknh) && __riscv_xlen == 32 #define Sigma0(x) ({ SHA_LONG64 ret; unsigned int *r = (unsigned int *)(&(ret)); \ @@ -487,6 +492,9 @@ static const SHA_LONG64 K512[80] = { asm (".insn r4 0x33, 1, 0x3, %0, %2, %1, %3"\ : "=r"(ret) \ : "r"(x^z), "r"(y), "r"(x)); ret; }) +#elif defined(__e2k__) && __iset__ >= 5 +#define sigma0(x) (__builtin_e2k_plog(0x96, ROTR((x), 1), ROTR((x), 8), ((x) >> 7))) +#define sigma1(x) (__builtin_e2k_plog(0x96, ROTR((x), 19), ROTR((x), 61), ((x) >> 6))) #endif #elif defined(_MSC_VER) #if defined(_WIN64) /* applies to both IA-64 and AMD64 */