From: jsing Date: Sun, 9 Jul 2023 10:36:53 +0000 (+0000) Subject: Provide optimised bn_addw() for riscv64. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5c3ff247b467a603a236c0a9fdbc5afa1eac5688;p=openbsd Provide optimised bn_addw() for riscv64. --- diff --git a/lib/libcrypto/bn/arch/riscv64/bn_arch.h b/lib/libcrypto/bn/arch/riscv64/bn_arch.h index 66256acad09..a8c50eb06d2 100644 --- a/lib/libcrypto/bn/arch/riscv64/bn_arch.h +++ b/lib/libcrypto/bn/arch/riscv64/bn_arch.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_arch.h,v 1.5 2023/07/07 16:10:32 jsing Exp $ */ +/* $OpenBSD: bn_arch.h,v 1.6 2023/07/09 10:36:53 jsing Exp $ */ /* * Copyright (c) 2023 Joel Sing * @@ -24,6 +24,23 @@ #if defined(__GNUC__) +#define HAVE_BN_ADDW + +static inline void +bn_addw(BN_ULONG a, BN_ULONG b, BN_ULONG *out_r1, BN_ULONG *out_r0) +{ + BN_ULONG carry, r0; + + __asm__ ( + "add %[r0], %[a], %[b] \n" + "sltu %[carry], %[r0], %[a] \n" + : [carry]"=r"(carry), [r0]"=&r"(r0) + : [a]"r"(a), [b]"r"(b)); + + *out_r1 = carry; + *out_r0 = r0; +} + #define HAVE_BN_MULW static inline void