Skip to content

Commit

Permalink
Add riscv64 asm_arch to linux64-riscv64 target
Browse files Browse the repository at this point in the history
Reviewed-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Signed-off-by: Henry Brausen <henry.brausen@vrull.eu>

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from #18275)

(cherry picked from commit cb2764f)
  • Loading branch information
henrybrausen authored and t8m committed Nov 21, 2022
1 parent 45e16e9 commit 5c03d5d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
1 change: 1 addition & 0 deletions Configurations/10-main.conf
Expand Up @@ -816,6 +816,7 @@ my %targets = (
"linux64-riscv64" => {
inherit_from => [ "linux-generic64"],
perlasm_scheme => "linux64",
asm_arch => 'riscv64',
},

# loongarch64 below refers to contemporary LoongArch Architecture
Expand Down
4 changes: 2 additions & 2 deletions crypto/sha/sha256.c
Expand Up @@ -132,7 +132,7 @@ static const SHA_LONG K256[64] = {
# ifndef PEDANTIC
# if defined(__GNUC__) && __GNUC__>=2 && \
!defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
# if __riscv_zknh
# if defined(__riscv_zknh)
# define Sigma0(x) ({ MD32_REG_T ret; \
asm ("sha256sum0 %0, %1" \
: "=r"(ret) \
Expand All @@ -150,7 +150,7 @@ static const SHA_LONG K256[64] = {
: "=r"(ret) \
: "r"(x)); ret; })
# endif
# if __riscv_zbt || __riscv_zpn
# if defined(__riscv_zbt) || defined(__riscv_zpn)
# define Ch(x,y,z) ({ MD32_REG_T ret; \
asm (".insn r4 0x33, 1, 0x3, %0, %2, %1, %3"\
: "=r"(ret) \
Expand Down
12 changes: 6 additions & 6 deletions crypto/sha/sha512.c
Expand Up @@ -432,7 +432,7 @@ static const SHA_LONG64 K512[80] = {
: "=r"(ret) \
: "r"(*((const SHA_LONG64 *)(&(x))))); ret; })
# endif
# elif (__riscv_zbkb || __riscv_zbb) && __riscv_xlen == 32
# elif (defined(__riscv_zbkb) || defined(__riscv_zbb)) && __riscv_xlen == 32
# define PULL64(x) ({ SHA_LONG64 ret; \
unsigned int *r = (unsigned int *)(&(ret)); \
const unsigned int *p = (const unsigned int *)(&(x)); \
Expand All @@ -442,13 +442,13 @@ static const SHA_LONG64 K512[80] = {
asm ("rev8 %0, %1" \
: "=r"(r[1]) \
: "r" (p[0])); ret; })
# elif (__riscv_zbkb || __riscv_zbb) && __riscv_xlen == 64
# elif (defined(__riscv_zbkb) || defined(__riscv_zbb)) && __riscv_xlen == 64
# define PULL64(x) ({ SHA_LONG64 ret; \
asm ("rev8 %0, %1" \
: "=r"(ret) \
: "r"(x)); ret; })
# endif
# if __riscv_zknh && __riscv_xlen == 32
# if defined(__riscv_zknh) && __riscv_xlen == 32
# define Sigma0(x) ({ SHA_LONG64 ret; unsigned int *r = (unsigned int *)(&(ret)); \
const unsigned int *p = (const unsigned int *)(&(x)); \
asm ("sha512sum0r %0, %1, %2" \
Expand Down Expand Up @@ -481,7 +481,7 @@ static const SHA_LONG64 K512[80] = {
asm ("sha512sig1h %0, %2, %1" \
: "=r"(r[1]) \
: "r" (p[0]), "r" (p[1])); ret; })
# elif __riscv_zknh && __riscv_xlen == 64
# elif defined(__riscv_zknh) && __riscv_xlen == 64
# define Sigma0(x) ({ SHA_LONG64 ret; \
asm ("sha512sum0 %0, %1" \
: "=r"(ret) \
Expand All @@ -499,7 +499,7 @@ static const SHA_LONG64 K512[80] = {
: "=r"(ret) \
: "r"(x)); ret; })
# endif
# if (__riscv_zbt || __riscv_zpn) && __riscv_xlen == 32
# if (defined(__riscv_zbt) || defined(__riscv_zpn)) && __riscv_xlen == 32
# define Ch(x,y,z) ({ SHA_LONG64 ret; unsigned int *r = (unsigned int *)(&(ret)); \
const unsigned int *xp = (const unsigned int *)(&(x)); \
const unsigned int *yp = (const unsigned int *)(&(y)); \
Expand All @@ -520,7 +520,7 @@ static const SHA_LONG64 K512[80] = {
asm (".insn r4 0x33, 1, 0x3, %0, %2, %1, %3\n\t" \
: "=r"(r[1]) \
: "r"(xp[1]^zp[1]), "r"(yp[1]), "r"(zp[1])); ret; })
# elif (__riscv_zbt || __riscv_zpn) && __riscv_xlen == 64
# elif (defined(__riscv_zbt) || defined(__riscv_zpn)) && __riscv_xlen == 64
# define Ch(x,y,z) ({ SHA_LONG64 ret; \
asm (".insn r4 0x33, 1, 0x3, %0, %2, %1, %3"\
: "=r"(ret) \
Expand Down

0 comments on commit 5c03d5d

Please sign in to comment.