aboutsummaryrefslogtreecommitdiff
path: root/rust/guts/src/lib.rs
diff options
context:
space:
mode:
authorJack O'Connor <[email protected]>2024-01-21 22:16:02 -0800
committerJack O'Connor <[email protected]>2024-01-21 22:16:02 -0800
commitf4ffbbca2f35e8341760c70c51e49ae6dd53f2be (patch)
treebf247720c4d98063e8884f6f6ba4a7063067b533 /rust/guts/src/lib.rs
parent5558fa46239742720d84c46edb0544732adf4db8 (diff)
factor out RISCV support from the guts_api branchguts_riscv
TODO: figure out what environment variable should enable this
Diffstat (limited to 'rust/guts/src/lib.rs')
-rw-r--r--rust/guts/src/lib.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/rust/guts/src/lib.rs b/rust/guts/src/lib.rs
index e9b4914..a363952 100644
--- a/rust/guts/src/lib.rs
+++ b/rust/guts/src/lib.rs
@@ -49,6 +49,8 @@ use core::ptr;
use core::sync::atomic::{AtomicPtr, Ordering::Relaxed};
pub mod portable;
+#[cfg(any(target_arch = "riscv64"))]
+pub mod riscv_rva23u64;
#[cfg(test)]
mod test;
@@ -82,8 +84,14 @@ pub const MSG_SCHEDULE: [[usize; 16]; 7] = [
[11, 15, 5, 0, 1, 9, 8, 6, 14, 10, 2, 12, 3, 4, 7, 13],
];
-// never less than 2
-pub const MAX_SIMD_DEGREE: usize = 2;
+cfg_if::cfg_if! {
+ if #[cfg(target_arch = "riscv64")] {
+ pub const MAX_SIMD_DEGREE: usize = riscv_rva23u64::MAX_SIMD_DEGREE;
+ } else {
+ // never less than 2
+ pub const MAX_SIMD_DEGREE: usize = 2;
+ }
+}
pub type CVBytes = [u8; 32];
pub type CVWords = [u32; 8];
@@ -101,6 +109,11 @@ pub static DETECTED_IMPL: Implementation = Implementation::new(
);
fn detect() -> Implementation {
+ #[cfg(target_arch = "riscv64")]
+ {
+ return riscv_rva23u64::implementation();
+ }
+ #[allow(unreachable_code)]
portable::implementation()
}