Skip to content

Commit 3f3c274

Browse files
committed
Remove Rust version 1.89+ constraints
I’m going to put this in another PR instead, waiting for 1.89 to hit stable first. I’ll keep this gated on the “vpclmulqdq” feature flag until then.
1 parent 0968b02 commit 3f3c274

File tree

6 files changed

+60
-42
lines changed

6 files changed

+60
-42
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ digest = { version = "0.10", features = ["alloc"] }
2424
rand = "0.9"
2525
libc = "0.2.171"
2626
regex = "1.11.1"
27-
rustversion = "1.0"
2827

2928
[dev-dependencies]
3029
criterion = "0.5"
@@ -45,8 +44,10 @@ harness = false
4544
[features]
4645
alloc = []
4746

47+
# enable experimental VPCLMULQDQ support, which landed in Rust 1.89.0-nightly, will deprecate after 1.89.0 is stable
48+
vpclmulqdq = []
49+
4850
# the features below aren't in use, are deprecated, and will be removed in the next MAJOR version
49-
vpclmulqdq = [] # deprecated, VPCLMULQDQ support landed in 1.89.0
5051
optimize_crc32_auto = [] # deprecated
5152
optimize_crc32_neon_eor3_v9s3x2e_s3 = [] # deprecated
5253
optimize_crc32_neon_v12e_v1 = [] # deprecated

src/arch/mod.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ use aarch64::AArch64Ops;
2222
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
2323
use x86::X86Ops;
2424

25-
#[cfg(target_arch = "x86_64")]
26-
#[rustversion::since(1.89)]
25+
//#[rustversion::since(1.89)]
26+
#[cfg(all(target_arch = "x86_64", feature = "vpclmulqdq"))]
2727
use vpclmulqdq::Vpclmulqdq512Ops;
2828

2929
mod aarch64;
@@ -49,25 +49,28 @@ pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64
4949
}
5050
}
5151

52-
#[rustversion::before(1.89)]
52+
//#[rustversion::before(1.89)]
5353
#[inline]
54-
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
54+
#[cfg(all(
55+
not(feature = "vpclmulqdq"),
56+
any(target_arch = "x86", target_arch = "x86_64")
57+
))]
5558
#[target_feature(enable = "sse2,sse4.1,pclmulqdq")]
5659
pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64 {
5760
update_x86_sse(state, bytes, params)
5861
}
5962

60-
#[rustversion::since(1.89)]
63+
//#[rustversion::since(1.89)]
6164
#[inline]
62-
#[cfg(target_arch = "x86")]
65+
#[cfg(all(feature = "vpclmulqdq", target_arch = "x86"))]
6366
#[target_feature(enable = "sse2,sse4.1,pclmulqdq")]
6467
pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64 {
6568
update_x86_sse(state, bytes, params)
6669
}
6770

68-
#[rustversion::since(1.89)]
71+
//#[rustversion::since(1.89)]
6972
#[inline]
70-
#[cfg(target_arch = "x86_64")]
73+
#[cfg(all(feature = "vpclmulqdq", target_arch = "x86_64"))]
7174
#[target_feature(enable = "sse2,sse4.1,pclmulqdq")]
7275
pub(crate) unsafe fn update(state: u64, bytes: &[u8], params: CrcParams) -> u64 {
7376
use std::arch::is_x86_feature_detected;
@@ -114,7 +117,8 @@ unsafe fn update_x86_sse(state: u64, bytes: &[u8], params: CrcParams) -> u64 {
114117
}
115118
}
116119

117-
#[rustversion::before(1.89)]
120+
//#[rustversion::before(1.89)]
121+
#[cfg(not(feature = "vpclmulqdq"))]
118122
pub fn get_target() -> String {
119123
#[cfg(target_arch = "aarch64")]
120124
{
@@ -133,7 +137,8 @@ pub fn get_target() -> String {
133137
return "software-fallback-tables".to_string();
134138
}
135139

136-
#[rustversion::since(1.89)]
140+
//#[rustversion::since(1.89)]
141+
#[cfg(feature = "vpclmulqdq")]
137142
pub fn get_target() -> String {
138143
#[cfg(target_arch = "aarch64")]
139144
{

src/arch/vpclmulqdq.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
//!
55
//! It performs folding using 4 x ZMM registers of 512-bits each.
66
7-
#![cfg(target_arch = "x86_64")]
7+
#![cfg(all(target_arch = "x86_64", feature = "vpclmulqdq"))]
88

9-
#[rustversion::since(1.89)]
9+
//#[rustversion::since(1.89)]
1010
use crate::arch::x86::X86Ops;
1111

12-
#[rustversion::since(1.89)]
12+
//#[rustversion::since(1.89)]
1313
use crate::enums::Reflector;
1414

15-
#[rustversion::since(1.89)]
15+
//#[rustversion::since(1.89)]
1616
use crate::structs::CrcState;
1717

18-
#[rustversion::since(1.89)]
18+
//#[rustversion::since(1.89)]
1919
use crate::traits::{ArchOps, EnhancedCrcWidth};
2020

21-
#[rustversion::since(1.89)]
21+
//#[rustversion::since(1.89)]
2222
use std::arch::x86_64::*;
2323

24-
#[rustversion::since(1.89)]
24+
//#[rustversion::since(1.89)]
2525
use std::ops::BitXor;
2626

2727
/// Implements the ArchOps trait using 512-bit AVX-512 and VPCLMULQDQ instructions at 512 bits.
2828
/// Delegates to X86Ops for standard 128-bit operations
29-
#[rustversion::since(1.89)]
29+
//#[rustversion::since(1.89)]
3030
#[derive(Debug, Copy, Clone)]
3131
pub struct Vpclmulqdq512Ops(X86Ops);
3232

33-
#[rustversion::since(1.89)]
33+
//#[rustversion::since(1.89)]
3434
impl Vpclmulqdq512Ops {
3535
#[inline(always)]
3636
pub fn new() -> Self {
@@ -39,11 +39,11 @@ impl Vpclmulqdq512Ops {
3939
}
4040

4141
// Wrapper for __m512i to make it easier to work with
42-
#[rustversion::since(1.89)]
42+
//#[rustversion::since(1.89)]
4343
#[derive(Debug, Copy, Clone)]
4444
struct Simd512(__m512i);
4545

46-
#[rustversion::since(1.89)]
46+
//#[rustversion::since(1.89)]
4747
impl Simd512 {
4848
#[inline]
4949
#[target_feature(enable = "avx512f")]
@@ -112,7 +112,7 @@ impl Simd512 {
112112
}
113113
}
114114

115-
#[rustversion::since(1.89)]
115+
//#[rustversion::since(1.89)]
116116
impl Vpclmulqdq512Ops {
117117
/// Process aligned blocks using VPCLMULQDQ with 4 x 512-bit registers
118118
///
@@ -341,15 +341,15 @@ impl Vpclmulqdq512Ops {
341341
}
342342

343343
// 512-bit version of the Reflector
344-
#[rustversion::since(1.89)]
344+
//#[rustversion::since(1.89)]
345345
#[derive(Clone, Copy)]
346346
enum Reflector512 {
347347
NoReflector,
348348
ForwardReflector { smask: Simd512 },
349349
}
350350

351351
// Function to create the appropriate reflector based on CRC parameters
352-
#[rustversion::since(1.89)]
352+
//#[rustversion::since(1.89)]
353353
#[inline(always)]
354354
unsafe fn create_reflector512(reflected: bool) -> Reflector512 {
355355
if reflected {
@@ -371,7 +371,7 @@ unsafe fn create_reflector512(reflected: bool) -> Reflector512 {
371371
}
372372

373373
// Function to apply reflection to a 512-bit vector
374-
#[rustversion::since(1.89)]
374+
//#[rustversion::since(1.89)]
375375
#[inline(always)]
376376
unsafe fn reflect_bytes512(reflector: &Reflector512, data: Simd512) -> Simd512 {
377377
match reflector {
@@ -381,12 +381,12 @@ unsafe fn reflect_bytes512(reflector: &Reflector512, data: Simd512) -> Simd512 {
381381
}
382382

383383
// pre-compute the reverse indices for 512-bit shuffling
384-
#[rustversion::since(1.89)]
384+
//#[rustversion::since(1.89)]
385385
static REVERSE_INDICES_512: __m512i =
386386
unsafe { std::mem::transmute([7u64, 6u64, 5u64, 4u64, 3u64, 2u64, 1u64, 0u64]) };
387387

388388
// Implement a 512-bit byte shuffle function
389-
#[rustversion::since(1.89)]
389+
//#[rustversion::since(1.89)]
390390
#[inline]
391391
#[target_feature(enable = "avx512f,avx512bw")]
392392
unsafe fn shuffle_bytes512(data: Simd512, mask: Simd512) -> Simd512 {
@@ -398,7 +398,7 @@ unsafe fn shuffle_bytes512(data: Simd512, mask: Simd512) -> Simd512 {
398398
}
399399

400400
// Delegate all ArchOps methods to the inner X86Ops instance
401-
#[rustversion::since(1.89)]
401+
//#[rustversion::since(1.89)]
402402
impl ArchOps for Vpclmulqdq512Ops {
403403
type Vector = __m128i;
404404

src/arch/x86.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,10 @@ impl ArchOps for X86Ops {
227227
_mm_clmulepi64_si128(a, b, 0x11)
228228
}
229229

230-
#[rustversion::since(1.89)]
230+
//#[rustversion::since(1.89)]
231231
#[inline]
232+
#[cfg(feature = "vpclmulqdq")]
233+
#[target_feature(enable = "avx512f,avx512vl")]
232234
unsafe fn xor3_vectors(
233235
&self,
234236
a: Self::Vector,
@@ -242,8 +244,10 @@ impl ArchOps for X86Ops {
242244
self.xor3_vectors_sse(a, b, c)
243245
}
244246

245-
#[rustversion::before(1.89)]
247+
//#[rustversion::before(1.89)]
246248
#[inline]
249+
#[cfg(not(feature = "vpclmulqdq"))]
250+
#[target_feature(enable = "sse4.1")]
247251
unsafe fn xor3_vectors(
248252
&self,
249253
a: Self::Vector,
@@ -317,8 +321,9 @@ impl X86Ops {
317321
}
318322
}
319323

320-
#[rustversion::since(1.89)]
324+
//#[rustversion::since(1.89)]
321325
#[inline]
326+
#[cfg(feature = "vpclmulqdq")]
322327
#[target_feature(enable = "avx512f,avx512vl")]
323328
unsafe fn xor3_vectors_avx512(&self, a: __m128i, b: __m128i, c: __m128i) -> __m128i {
324329
_mm_ternarylogic_epi64(

src/crc32/fusion/x86.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@
2020
use std::arch::x86_64::*;
2121

2222
/// Safe wrapper for CRC32 iSCSI calculation using AVX-512
23-
#[rustversion::before(1.89)]
23+
//#[rustversion::before(1.89)]
2424
#[inline(always)]
25+
#[cfg(not(feature = "vpclmulqdq"))]
2526
pub fn crc32_iscsi(crc: u32, data: &[u8]) -> u32 {
2627
unsafe { crc32_iscsi_sse_v4s3x3(crc, data.as_ptr(), data.len()) }
2728
}
2829

29-
#[rustversion::since(1.89)]
30+
//#[rustversion::since(1.89)]
3031
#[inline(always)]
32+
#[cfg(feature = "vpclmulqdq")]
3133
pub fn crc32_iscsi(crc: u32, data: &[u8]) -> u32 {
3234
if is_x86_feature_detected!("vpclmulqdq")
3335
&& is_x86_feature_detected!("avx512f")
@@ -47,15 +49,17 @@ pub fn crc32_iscsi(crc: u32, data: &[u8]) -> u32 {
4749
unsafe { crc32_iscsi_sse_v4s3x3(crc, data.as_ptr(), data.len()) }
4850
}
4951

50-
#[rustversion::since(1.89)]
52+
//#[rustversion::since(1.89)]
5153
#[inline]
54+
#[cfg(feature = "vpclmulqdq")]
5255
#[target_feature(enable = "avx512f,avx512vl,vpclmulqdq")]
5356
unsafe fn clmul_lo_avx512_vpclmulqdq(a: __m512i, b: __m512i) -> __m512i {
5457
_mm512_clmulepi64_epi128(a, b, 0)
5558
}
5659

57-
#[rustversion::since(1.89)]
60+
//#[rustversion::since(1.89)]
5861
#[inline]
62+
#[cfg(feature = "vpclmulqdq")]
5963
#[target_feature(enable = "avx512f,avx512vl,vpclmulqdq")]
6064
unsafe fn clmul_hi_avx512_vpclmulqdq(a: __m512i, b: __m512i) -> __m512i {
6165
_mm512_clmulepi64_epi128(a, b, 17)
@@ -138,8 +142,9 @@ unsafe fn mm_crc32_u64(crc: u32, val: u64) -> u32 {
138142
/// using:
139143
///
140144
/// ./generate -i avx512_vpclmulqdq -p crc32c -a v3x2
141-
#[rustversion::since(1.89)]
145+
//#[rustversion::since(1.89)]
142146
#[inline]
147+
#[cfg(feature = "vpclmulqdq")]
143148
#[target_feature(enable = "avx512f,avx512vl,vpclmulqdq,sse4.2")]
144149
pub unsafe fn crc32_iscsi_avx512_vpclmulqdq_v3x2(
145150
mut crc0: u32,
@@ -336,8 +341,9 @@ pub unsafe fn crc32_iscsi_avx512_vpclmulqdq_v3x2(
336341
/// using:
337342
///
338343
/// ./generate -i avx512 -p crc32c -a v4s3x3
339-
#[rustversion::since(1.89)]
344+
//#[rustversion::since(1.89)]
340345
#[inline]
346+
#[cfg(feature = "vpclmulqdq")]
341347
#[target_feature(enable = "avx512f,avx512vl,sse4.2,pclmulqdq,sse2,sse4.1")]
342348
pub unsafe fn crc32_iscsi_avx512_v4s3x3(mut crc0: u32, mut buf: *const u8, mut len: usize) -> u32 {
343349
// Align to 8-byte boundary using hardware CRC32C instructions
@@ -683,7 +689,8 @@ mod tests {
683689
}
684690
}
685691

686-
#[rustversion::since(1.89)]
692+
//#[rustversion::since(1.89)]
693+
#[cfg(feature = "vpclmulqdq")]
687694
fn test_crc32_iscsi_random(len: usize) {
688695
let mut data = vec![0u8; len];
689696
rng().fill(&mut data[..]);
@@ -721,7 +728,8 @@ mod tests {
721728
}
722729
}
723730

724-
#[rustversion::before(1.89)]
731+
//#[rustversion::before(1.89)]
732+
#[cfg(not(feature = "vpclmulqdq"))]
725733
fn test_crc32_iscsi_random(len: usize) {
726734
let mut data = vec![0u8; len];
727735
rng().fill(&mut data[..]);

0 commit comments

Comments
 (0)