Add riscv64 asm_arch to linux64-riscv64 target
authorHenry Brausen <henry.brausen@vrull.eu>
Fri, 28 Jan 2022 08:12:38 +0000 (01:12 -0700)
committerPauli <pauli@openssl.org>
Wed, 11 May 2022 08:02:03 +0000 (18:02 +1000)
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 https://github.com/openssl/openssl/pull/18275)

Configurations/10-main.conf
crypto/sha/sha256.c
crypto/sha/sha512.c

index 305cc0daec3bba522de60bbd1d7af1ee4fcf983a..7735c9491124a659ea27772996e5b18c86040ae9 100644 (file)
@@ -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
index 89beaf14799db3fd0f62e4989bb8bdb3f849662f..649d25d6c6d0fe738a67d90fc5ef617649f315f7 100644 (file)
@@ -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)                 \
@@ -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)                                 \
index db135653326028debf96d3be389dee491d147428..ee00b55de89927525221a733c1ead9b7c07710ff 100644 (file)
@@ -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));   \
@@ -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"                                   \
@@ -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)                 \
@@ -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));          \
@@ -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)                                 \