Skip to content

Commit a5d9155

Browse files
committed
[rustfmt] reformat the whole library
1 parent bd5e92c commit a5d9155

25 files changed

+1899
-569
lines changed

examples/play.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ mod example {
2626

2727
unsafe {
2828
vendor::_mm_cmpestri(
29-
vneedle, needle_len as i32, vhaystack, hay_len as i32,
30-
vendor::_SIDD_CMP_EQUAL_ORDERED) as usize
29+
vneedle,
30+
needle_len as i32,
31+
vhaystack,
32+
hay_len as i32,
33+
vendor::_SIDD_CMP_EQUAL_ORDERED,
34+
) as usize
3135
}
3236
}
3337

rustfmt.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
max_width = 79
1+
max_width = 79
2+
wrap_comments = true
3+
error_on_line_overflow = false

src/arm/v6.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! ARMv6 intrinsics.
22
//!
33
//! The reference is [ARMv6-M Architecture Reference
4-
//! Manual](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0419c/index.html).
4+
//! Manual](http://infocenter.arm.com/help/index.jsp?topic=\
5+
//! /com.arm.doc.ddi0419c/index.html).
56
67
#[cfg(test)]
78
use stdsimd_test::assert_instr;

src/arm/v7.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! ARMv7 intrinsics.
22
//!
33
//! The reference is [ARMv7-M Architecture Reference Manual (Issue
4-
//! E.b)](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0403e.b/index.html).
4+
//! E.b)](http://infocenter.arm.com/help/index.jsp?topic=\
5+
//! /com.arm.doc.ddi0403e.b/index.html).
56
67
pub use super::v6::*;
78

@@ -39,6 +40,6 @@ pub unsafe fn _rbit_u32(x: u32) -> u32 {
3940

4041
#[allow(dead_code)]
4142
extern "C" {
42-
#[link_name="llvm.bitreverse.i32"]
43+
#[link_name = "llvm.bitreverse.i32"]
4344
fn rbit_u32(i: i32) -> i32;
4445
}

src/arm/v8.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! ARMv8 intrinsics.
22
//!
3-
//! The reference is [ARMv8-A Reference Manual](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0487a.k_10775/index.html).
3+
//! The reference is [ARMv8-A Reference Manual](http://infocenter.arm.com/\
4+
//! help/index.jsp?topic=/com.arm.doc.ddi0487a.k_10775/index.html).
45
56
pub use super::v7::*;
67

@@ -23,7 +24,7 @@ pub unsafe fn _clz_u64(x: u64) -> u64 {
2324

2425
#[allow(dead_code)]
2526
extern "C" {
26-
#[link_name="llvm.bitreverse.i64"]
27+
#[link_name = "llvm.bitreverse.i64"]
2728
fn rbit_u64(i: i64) -> i64;
2829
}
2930

src/lib.rs

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444
//! have no runtime support for whether you CPU actually supports the
4545
//! instruction.
4646
//!
47-
//! CPU target feature detection is done via the `cfg_feature_enabled!` macro at
48-
//! runtime. This macro will detect at runtime whether the specified feature is
49-
//! available or not, returning true or false depending on the current CPU.
47+
//! CPU target feature detection is done via the `cfg_feature_enabled!` macro
48+
//! at runtime. This macro will detect at runtime whether the specified feature
49+
//! is available or not, returning true or false depending on the current CPU.
5050
//!
5151
//! ```
5252
//! #![feature(cfg_target_feature)]
@@ -58,36 +58,42 @@
5858
//! if cfg_feature_enabled!("avx2") {
5959
//! println!("avx2 intrinsics will work");
6060
//! } else {
61-
//! println!("avx2 intrinsics will not work, they may generate SIGILL");
61+
//! println!("avx2 intrinsics will not work");
62+
//! // undefined behavior: may generate a `SIGILL`.
6263
//! }
6364
//! }
6465
//! ```
6566
//!
6667
//! # Status
6768
//!
68-
//! This crate is intended for eventual inclusion into the standard library, but
69-
//! some work and experimentation is needed to get there! First and foremost you
70-
//! can help out by kicking the tires on this crate and seeing if it works for
71-
//! your use case! Next up you can help us fill out the [vendor
72-
//! intrinsics][vendor] to ensure that we've got all the SIMD support necessary.
73-
//!
74-
//! The language support and status of SIMD is also still a little up in the air
75-
//! right now, you may be interested in a few issues along these lines:
76-
//!
77-
//! * [Overal tracking issue for SIMD support](https://github.com/rust-lang/rust/issues/27731)
78-
//! * [`cfg_target_feature` tracking issue](https://github.com/rust-lang/rust/issues/29717)
79-
//! * [SIMD types currently not sound](https://github.com/rust-lang/rust/issues/44367)
80-
//! * [`#[target_feature]` improvements](https://github.com/rust-lang/rust/issues/44839)
69+
//! This crate is intended for eventual inclusion into the standard library,
70+
//! but some work and experimentation is needed to get there! First and
71+
//! foremost you can help out by kicking the tires on this crate and seeing if
72+
//! it works for your use case! Next up you can help us fill out the [vendor
73+
//! intrinsics][vendor] to ensure that we've got all the SIMD support
74+
//! necessary.
75+
//!
76+
//! The language support and status of SIMD is also still a little up in the
77+
//! air right now, you may be interested in a few issues along these lines:
78+
//!
79+
//! * [Overal tracking issue for SIMD support]
80+
//! (https://github.com/rust-lang/rust/issues/27731)
81+
//! * [`cfg_target_feature` tracking issue]
82+
//! (https://github.com/rust-lang/rust/issues/29717)
83+
//! * [SIMD types currently not sound]
84+
//! (https://github.com/rust-lang/rust/issues/44367)
85+
//! * [`#[target_feature]` improvements]
86+
//! (https://github.com/rust-lang/rust/issues/44839)
8187
//!
8288
//! [vendor]: https://github.com/rust-lang-nursery/stdsimd/issues/40
8389
8490
#![allow(dead_code)]
8591
#![allow(unused_features)]
86-
#![feature(
87-
const_fn, link_llvm_intrinsics, platform_intrinsics, repr_simd, simd_ffi,
88-
target_feature, cfg_target_feature, i128_type, asm, const_atomic_usize_new
89-
)]
92+
#![feature(const_fn, link_llvm_intrinsics, platform_intrinsics, repr_simd,
93+
simd_ffi, target_feature, cfg_target_feature, i128_type, asm,
94+
const_atomic_usize_new)]
9095
#![cfg_attr(test, feature(proc_macro))]
96+
#![cfg_attr(rustfmt, feature(custom_attribute))]
9197

9298
#[cfg(test)]
9399
extern crate stdsimd_test;

src/macros.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,11 @@ macro_rules! define_integer_ops {
240240
i8, i16, i32, i64, isize);
241241

242242
impl ::std::fmt::LowerHex for $ty {
243-
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
243+
fn fmt(&self, f: &mut ::std::fmt::Formatter)
244+
-> ::std::fmt::Result {
244245
write!(f, "{}(", stringify!($ty))?;
245-
let n = ::std::mem::size_of_val(self) / ::std::mem::size_of::<$elem>();
246+
let n = ::std::mem::size_of_val(self)
247+
/ ::std::mem::size_of::<$elem>();
246248
for i in 0..n {
247249
if i > 0 {
248250
write!(f, ", ")?;
@@ -292,8 +294,7 @@ macro_rules! cfg_feature_enabled {
292294
/// On ARM features are only detected at compile-time using
293295
/// cfg(target_feature), so if this macro is executed the
294296
/// feature is not supported.
295-
#[cfg(any(target_arch = "arm",
296-
target_arch = "aarch64"))]
297+
#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
297298
#[macro_export]
298299
#[doc(hidden)]
299300
macro_rules! __unstable_detect_feature {
@@ -302,10 +303,8 @@ macro_rules! __unstable_detect_feature {
302303
}
303304

304305
/// In all unsupported architectures using the macro is an error
305-
#[cfg(not(any(target_arch = "x86",
306-
target_arch = "x86_64",
307-
target_arch = "arm",
308-
target_arch = "aarch64")))]
306+
#[cfg(not(any(target_arch = "x86", target_arch = "x86_64",
307+
target_arch = "arm", target_arch = "aarch64")))]
309308
#[macro_export]
310309
#[doc(hidden)]
311310
macro_rules! __unstable_detect_feature {

src/v128.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ define_from!(u8x16, u64x2, i64x2, u32x4, i32x4, u16x8, i16x8, i8x16);
5050
define_from!(i8x16, u64x2, i64x2, u32x4, i32x4, u16x8, i16x8, u8x16);
5151

5252
define_common_ops!(
53-
f64x2, f32x4, u64x2, i64x2, u32x4, i32x4, u16x8, i16x8, u8x16, i8x16);
53+
f64x2,
54+
f32x4,
55+
u64x2,
56+
i64x2,
57+
u32x4,
58+
i32x4,
59+
u16x8,
60+
i16x8,
61+
u8x16,
62+
i8x16
63+
);
5464
define_float_ops!(f64x2, f32x4);
5565
define_integer_ops!(
5666
(u64x2, u64),
@@ -60,7 +70,8 @@ define_integer_ops!(
6070
(u16x8, u16),
6171
(i16x8, i16),
6272
(u8x16, u8),
63-
(i8x16, i8));
73+
(i8x16, i8)
74+
);
6475
define_casts!(
6576
(f64x2, f32x2, as_f32x2),
6677
(f64x2, u64x2, as_u64x2),
@@ -79,4 +90,5 @@ define_casts!(
7990
(u16x8, i16x8, as_i16x8),
8091
(i16x8, u16x8, as_u16x8),
8192
(u8x16, i8x16, as_i8x16),
82-
(i8x16, u8x16, as_u8x16));
93+
(i8x16, u8x16, as_u8x16)
94+
);

src/v256.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,17 @@ define_from!(u8x32, u64x4, i64x4, u32x8, i32x8, u16x16, i16x16, i8x32);
7474
define_from!(i8x32, u64x4, i64x4, u32x8, i32x8, u16x16, i16x16, u8x32);
7575

7676
define_common_ops!(
77-
f64x4, f32x8, u64x4, i64x4, u32x8, i32x8, u16x16, i16x16, u8x32, i8x32);
77+
f64x4,
78+
f32x8,
79+
u64x4,
80+
i64x4,
81+
u32x8,
82+
i32x8,
83+
u16x16,
84+
i16x16,
85+
u8x32,
86+
i8x32
87+
);
7888
define_float_ops!(f64x4, f32x8);
7989
define_integer_ops!(
8090
(u64x4, u64),
@@ -84,7 +94,8 @@ define_integer_ops!(
8494
(u16x16, u16),
8595
(i16x16, i16),
8696
(u8x32, u8),
87-
(i8x32, i8));
97+
(i8x32, i8)
98+
);
8899
define_casts!(
89100
(f64x4, f32x4, as_f32x4),
90101
(f64x4, u64x4, as_u64x4),
@@ -102,4 +113,5 @@ define_casts!(
102113
(u16x16, i16x16, as_i16x16),
103114
(i16x16, u16x16, as_u16x16),
104115
(u8x32, i8x32, as_i8x32),
105-
(i8x32, u8x32, as_u8x32));
116+
(i8x32, u8x32, as_u8x32)
117+
);

src/v512.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,17 @@ define_from!(u8x64, u64x8, i64x8, u32x16, i32x16, u16x32, i16x32, i8x64);
120120
define_from!(i8x64, u64x8, i64x8, u32x16, i32x16, u16x32, i16x32, u8x64);
121121

122122
define_common_ops!(
123-
f64x8, f32x16, u64x8, i64x8, u32x16, i32x16, u16x32, i16x32, u8x64, i8x64);
123+
f64x8,
124+
f32x16,
125+
u64x8,
126+
i64x8,
127+
u32x16,
128+
i32x16,
129+
u16x32,
130+
i16x32,
131+
u8x64,
132+
i8x64
133+
);
124134
define_float_ops!(f64x8, f32x16);
125135
define_integer_ops!(
126136
(u64x8, u64),
@@ -130,7 +140,8 @@ define_integer_ops!(
130140
(u16x32, u16),
131141
(i16x32, i16),
132142
(u8x64, u8),
133-
(i8x64, i8));
143+
(i8x64, i8)
144+
);
134145
define_casts!(
135146
(f64x8, f32x8, as_f32x8),
136147
(f64x8, u64x8, as_u64x8),
@@ -148,5 +159,5 @@ define_casts!(
148159
(u16x32, i16x32, as_i16x32),
149160
(i16x32, u16x32, as_u16x32),
150161
(u8x64, i8x64, as_i8x64),
151-
(i8x64, u8x64, as_u8x64));
152-
162+
(i8x64, u8x64, as_u8x64)
163+
);

src/v64.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ define_integer_ops!(
4242
(u16x4, u16),
4343
(i16x4, i16),
4444
(u8x8, u8),
45-
(i8x8, i8));
45+
(i8x8, i8)
46+
);
4647
define_casts!(
4748
(f32x2, f64x2, as_f64x2),
4849
(f32x2, u32x2, as_u32x2),
@@ -54,4 +55,5 @@ define_casts!(
5455
(u16x4, i16x4, as_i16x4),
5556
(i16x4, u16x4, as_u16x4),
5657
(u8x8, i8x8, as_i8x8),
57-
(i8x8, u8x8, as_u8x8));
58+
(i8x8, u8x8, as_u8x8)
59+
);

src/x86/abm.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@
44
//!
55
//! The references are:
66
//!
7-
//! - [Intel 64 and IA-32 Architectures Software Developer's Manual Volume 2: Instruction Set Reference, A-Z](http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf).
8-
//! - [AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and System Instructions](http://support.amd.com/TechDocs/24594.pdf).
7+
//! - [Intel 64 and IA-32 Architectures Software Developer's Manual Volume 2:
8+
//! Instruction Set Reference, A-Z](http://www.intel.de/content/dam/www/public\
9+
//! /us/en/documents/manuals/64-ia-32-architectures-software-developer-\
10+
//! instruction-set-reference-manual-325383.pdf).
11+
//! - [AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and
12+
//! System Instructions](http://support.amd.com/TechDocs/24594.pdf).
913
//!
10-
//! [Wikipedia](https://en.wikipedia.org/wiki/Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29)
14+
//! [Wikipedia](https://en.wikipedia.org/wiki/\
15+
//! Bit_Manipulation_Instruction_Sets#ABM_.28Advanced_Bit_Manipulation.29)
1116
//! provides a quick overview of the instructions available.
1217
1318
#[cfg(test)]
@@ -19,27 +24,35 @@ use stdsimd_test::assert_instr;
1924
#[inline(always)]
2025
#[target_feature = "+lzcnt"]
2126
#[cfg_attr(test, assert_instr(lzcnt))]
22-
pub unsafe fn _lzcnt_u32(x: u32) -> u32 { x.leading_zeros() }
27+
pub unsafe fn _lzcnt_u32(x: u32) -> u32 {
28+
x.leading_zeros()
29+
}
2330

2431
/// Counts the leading most significant zero bits.
2532
///
2633
/// When the operand is zero, it returns its size in bits.
2734
#[inline(always)]
2835
#[target_feature = "+lzcnt"]
2936
#[cfg_attr(test, assert_instr(lzcnt))]
30-
pub unsafe fn _lzcnt_u64(x: u64) -> u64 { x.leading_zeros() as u64 }
37+
pub unsafe fn _lzcnt_u64(x: u64) -> u64 {
38+
x.leading_zeros() as u64
39+
}
3140

3241
/// Counts the bits that are set.
3342
#[inline(always)]
3443
#[target_feature = "+popcnt"]
3544
#[cfg_attr(test, assert_instr(popcnt))]
36-
pub unsafe fn _popcnt32(x: u32) -> u32 { x.count_ones() }
45+
pub unsafe fn _popcnt32(x: u32) -> u32 {
46+
x.count_ones()
47+
}
3748

3849
/// Counts the bits that are set.
3950
#[inline(always)]
4051
#[target_feature = "+popcnt"]
4152
#[cfg_attr(test, assert_instr(popcnt))]
42-
pub unsafe fn _popcnt64(x: u64) -> u64 { x.count_ones() as u64 }
53+
pub unsafe fn _popcnt64(x: u64) -> u64 {
54+
x.count_ones() as u64
55+
}
4356

4457
#[cfg(test)]
4558
mod tests {

0 commit comments

Comments
 (0)