Merge pull request #47 from jarys/uninline-portable

Add `uninline-portable` feature
This commit is contained in:
str4d 2022-10-13 21:47:44 +01:00 committed by GitHub
commit ede7f88784
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 12 deletions

View File

@ -6,6 +6,10 @@ and this project adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- `uninline-portable` feature flag, which disables inlining of some functions.
This is useful for tiny microchips (such as ARM Cortex-M0), where inlining
can hurt performance and blow up binary size.
## [0.4.0] - 2022-05-05
### Changed

View File

@ -64,3 +64,4 @@ bits = ["ff/bits"]
gpu = ["alloc", "ec-gpu"]
sqrt-table = ["alloc", "lazy_static"]
repr-c = []
uninline-portable = []

View File

@ -293,7 +293,7 @@ impl Fp {
}
/// Squares this element.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn square(&self) -> Fp {
let (r1, carry) = mac(0, self.0[0], self.0[1], 0);
let (r2, carry) = mac(0, self.0[0], self.0[2], carry);
@ -325,7 +325,7 @@ impl Fp {
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
#[cfg_attr(not(feature = "uninline-portable"), inline(always))]
const fn montgomery_reduce(
r0: u64,
r1: u64,
@ -373,7 +373,7 @@ impl Fp {
}
/// Multiplies `rhs` by `self`, returning the result.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn mul(&self, rhs: &Self) -> Self {
// Schoolbook multiplication
@ -401,7 +401,7 @@ impl Fp {
}
/// Subtracts `rhs` from `self`, returning the result.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn sub(&self, rhs: &Self) -> Self {
let (d0, borrow) = sbb(self.0[0], rhs.0[0], 0);
let (d1, borrow) = sbb(self.0[1], rhs.0[1], borrow);
@ -419,7 +419,7 @@ impl Fp {
}
/// Adds `rhs` to `self`, returning the result.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn add(&self, rhs: &Self) -> Self {
let (d0, carry) = adc(self.0[0], rhs.0[0], 0);
let (d1, carry) = adc(self.0[1], rhs.0[1], carry);
@ -432,7 +432,7 @@ impl Fp {
}
/// Negates `self`.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn neg(&self) -> Self {
// Subtract `self` from `MODULUS` to negate. Ignore the final
// borrow because it cannot underflow; self is guaranteed to

View File

@ -293,7 +293,7 @@ impl Fq {
}
/// Squares this element.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn square(&self) -> Fq {
let (r1, carry) = mac(0, self.0[0], self.0[1], 0);
let (r2, carry) = mac(0, self.0[0], self.0[2], carry);
@ -325,7 +325,7 @@ impl Fq {
}
#[allow(clippy::too_many_arguments)]
#[inline(always)]
#[cfg_attr(not(feature = "uninline-portable"), inline(always))]
const fn montgomery_reduce(
r0: u64,
r1: u64,
@ -373,7 +373,7 @@ impl Fq {
}
/// Multiplies `rhs` by `self`, returning the result.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn mul(&self, rhs: &Self) -> Self {
// Schoolbook multiplication
@ -401,7 +401,7 @@ impl Fq {
}
/// Subtracts `rhs` from `self`, returning the result.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn sub(&self, rhs: &Self) -> Self {
let (d0, borrow) = sbb(self.0[0], rhs.0[0], 0);
let (d1, borrow) = sbb(self.0[1], rhs.0[1], borrow);
@ -419,7 +419,7 @@ impl Fq {
}
/// Adds `rhs` to `self`, returning the result.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn add(&self, rhs: &Self) -> Self {
let (d0, carry) = adc(self.0[0], rhs.0[0], 0);
let (d1, carry) = adc(self.0[1], rhs.0[1], carry);
@ -432,7 +432,7 @@ impl Fq {
}
/// Negates `self`.
#[inline]
#[cfg_attr(not(feature = "uninline-portable"), inline)]
pub const fn neg(&self) -> Self {
// Subtract `self` from `MODULUS` to negate. Ignore the final
// borrow because it cannot underflow; self is guaranteed to