Skip to content

Commit 21d2805

Browse files
authored
Support no_std compile-time SIMD (#214)
1 parent a51172d commit 21d2805

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
//! parsing internals use an `Iterator` instead of direct indexing, while
1616
//! skipping bounds checks.
1717
//!
18-
//! With Rust 1.27.0 or later, support for SIMD is enabled automatically.
18+
//! SIMD optimizations are enabled automatically when available.
1919
//! If building an executable to be run on multiple platforms, and thus
2020
//! not passing `target_feature` or `target_cpu` flags to the compiler,
2121
//! runtime detection can still detect SSE4.2 or AVX2 support to provide

src/simd/mod.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,34 @@ mod swar;
33
#[cfg(any(
44
httparse_disable_simd,
55
miri,
6-
not(feature = "std"),
76
not(any(
87
target_arch = "x86",
98
target_arch = "x86_64",
109
all(
1110
target_arch = "aarch64",
1211
target_feature = "neon",
1312
)
14-
))
13+
)),
14+
all(
15+
not(feature = "std"),
16+
not(any(
17+
target_feature = "sse4.2",
18+
target_feature = "avx2",
19+
)),
20+
any(
21+
target_arch = "x86",
22+
target_arch = "x86_64",
23+
),
24+
)
1525
))]
1626
pub use self::swar::*;
1727

1828
#[cfg(all(
1929
not(any(httparse_disable_simd, miri)),
20-
feature = "std",
30+
any(
31+
feature = "std",
32+
target_feature = "sse4.2",
33+
),
2134
not(target_feature = "avx2"),
2235
any(
2336
target_arch = "x86",
@@ -28,10 +41,12 @@ mod sse42;
2841

2942
#[cfg(all(
3043
not(any(httparse_disable_simd, miri)),
31-
feature = "std",
3244
any(
3345
target_feature = "avx2",
34-
not(target_feature = "sse4.2"),
46+
all(
47+
feature = "std",
48+
not(target_feature = "sse4.2"),
49+
),
3550
),
3651
any(
3752
target_arch = "x86",
@@ -70,7 +85,6 @@ pub use self::runtime::*;
7085

7186
#[cfg(all(
7287
not(any(httparse_disable_simd, miri)),
73-
feature = "std",
7488
target_feature = "sse4.2",
7589
not(target_feature = "avx2"),
7690
any(
@@ -97,7 +111,6 @@ mod sse42_compile_time {
97111

98112
#[cfg(all(
99113
not(any(httparse_disable_simd, miri)),
100-
feature = "std",
101114
target_feature = "sse4.2",
102115
not(target_feature = "avx2"),
103116
any(
@@ -109,7 +122,6 @@ pub use self::sse42_compile_time::*;
109122

110123
#[cfg(all(
111124
not(any(httparse_disable_simd, miri)),
112-
feature = "std",
113125
target_feature = "avx2",
114126
any(
115127
target_arch = "x86",
@@ -135,7 +147,6 @@ mod avx2_compile_time {
135147

136148
#[cfg(all(
137149
not(any(httparse_disable_simd, miri)),
138-
feature = "std",
139150
target_feature = "avx2",
140151
any(
141152
target_arch = "x86",
@@ -146,15 +157,13 @@ pub use self::avx2_compile_time::*;
146157

147158
#[cfg(all(
148159
not(any(httparse_disable_simd, miri)),
149-
feature = "std",
150160
target_arch = "aarch64",
151161
target_feature = "neon",
152162
))]
153163
mod neon;
154164

155165
#[cfg(all(
156166
not(any(httparse_disable_simd, miri)),
157-
feature = "std",
158167
target_arch = "aarch64",
159168
target_feature = "neon",
160169
))]

0 commit comments

Comments
 (0)