mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-04 04:27:34 +00:00
reduce binary burden of backup SHA implementations
When the hardware engine is unavailable, the implementation falls back to a software SHA. This code path is actually rarely used, but it is the top object code consumer according to our bloat analysis tool (40kiB for each instance of the compress function alone). This patch annotates the SHA functions with `#[inline(never)]` to reduce the size of these rarely-used functions. ...it might actually be that on our small-cache system, reducing the in-lining could improve performance as well because it helps the whole routine fit inside L2 cache. Anyways, it's a rarely-used path (I've never seen the code used once tbh) so let's reduce its overhead and keep Xous trim.
This commit is contained in:
parent
ebc8fd90f3
commit
e288286bda
2 changed files with 7 additions and 3 deletions
|
|
@ -39,7 +39,7 @@ fn sha256load(v2: [u32; 4], v3: [u32; 4]) -> [u32; 4] {
|
|||
fn sha256swap(v0: [u32; 4]) -> [u32; 4] {
|
||||
[v0[2], v0[3], v0[0], v0[1]]
|
||||
}
|
||||
|
||||
#[inline(never)] // bunnie: reduce binary size
|
||||
fn sha256msg1(v0: [u32; 4], v1: [u32; 4]) -> [u32; 4] {
|
||||
// sigma 0 on vectors
|
||||
#[inline]
|
||||
|
|
@ -52,7 +52,7 @@ fn sha256msg1(v0: [u32; 4], v1: [u32; 4]) -> [u32; 4] {
|
|||
|
||||
add(v0, sigma0x4(sha256load(v0, v1)))
|
||||
}
|
||||
|
||||
#[inline(never)] // bunnie: reduce binary size
|
||||
fn sha256msg2(v4: [u32; 4], v3: [u32; 4]) -> [u32; 4] {
|
||||
macro_rules! sigma1 {
|
||||
($a:expr) => {
|
||||
|
|
@ -70,7 +70,7 @@ fn sha256msg2(v4: [u32; 4], v3: [u32; 4]) -> [u32; 4] {
|
|||
|
||||
[w19, w18, w17, w16]
|
||||
}
|
||||
|
||||
#[inline(never)] // bunnie: reduce binary size
|
||||
fn sha256_digest_round_x2(cdgh: [u32; 4], abef: [u32; 4], wk: [u32; 4]) -> [u32; 4] {
|
||||
macro_rules! big_sigma0 {
|
||||
($a:expr) => {
|
||||
|
|
@ -162,6 +162,7 @@ macro_rules! schedule_rounds4 {
|
|||
}
|
||||
|
||||
/// Process a block with the SHA-256 algorithm.
|
||||
#[inline(never)] // bunnie: reduce binary size
|
||||
fn sha256_digest_block_u32(state: &mut [u32; 8], block: &[u32; 16]) {
|
||||
let mut abef = [state[0], state[1], state[4], state[5]];
|
||||
let mut cdgh = [state[2], state[3], state[6], state[7]];
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ fn sha512load(v0: [u64; 2], v1: [u64; 2]) -> [u64; 2] {
|
|||
}
|
||||
|
||||
/// Performs 2 rounds of the SHA-512 message schedule update.
|
||||
#[inline(never)] // bunnie: reduce binary size
|
||||
pub fn sha512_schedule_x2(v0: [u64; 2], v1: [u64; 2], v4to5: [u64; 2], v7: [u64; 2]) -> [u64; 2] {
|
||||
// sigma 0
|
||||
fn sigma0(x: u64) -> u64 {
|
||||
|
|
@ -46,6 +47,7 @@ pub fn sha512_schedule_x2(v0: [u64; 2], v1: [u64; 2], v4to5: [u64; 2], v7: [u64;
|
|||
}
|
||||
|
||||
/// Performs one round of the SHA-512 message block digest.
|
||||
#[inline(never)] // bunnie: reduce binary size
|
||||
pub fn sha512_digest_round(
|
||||
ae: [u64; 2],
|
||||
bf: [u64; 2],
|
||||
|
|
@ -100,6 +102,7 @@ pub fn sha512_digest_round(
|
|||
}
|
||||
|
||||
/// Process a block with the SHA-512 algorithm.
|
||||
#[inline(never)] // bunnie: reduce binary size
|
||||
pub fn sha512_digest_block_u64(state: &mut [u64; 8], block: &[u64; 16]) {
|
||||
let k = &K64X2;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue