Skip to content

Commit 1c6338f

Browse files
committed
fmt
1 parent e636776 commit 1c6338f

File tree

6 files changed

+63
-58
lines changed

6 files changed

+63
-58
lines changed

coresimd/mips/msa.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//! MIPS SIMD Architecture intrinsics
22
//!
3-
//! The reference is [MIPS Architecture for Programmers Volume IV-j: The MIPS32 SIMD
4-
//! Architecture Module Revision 1.12][msa_ref].
3+
//! The reference is [MIPS Architecture for Programmers Volume IV-j: The
4+
//! MIPS32 SIMD Architecture Module Revision 1.12][msa_ref].
55
//!
66
//! [msa_ref]: http://cdn2.imgtec.com/documentation/MD00866-2B-MSA32-AFP-01.12.pdf
77
88
#[cfg(test)]
99
use stdsimd_test::assert_instr;
10-
use ::coresimd::simd::*;
10+
use coresimd::simd::*;
1111

1212
#[allow(improper_ctypes)]
1313
extern "C" {

crates/assert-instr-macro/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,12 @@ pub fn assert_instr(
4040
};
4141
let name = &func.ident;
4242
use quote::ToTokens;
43-
let instr_str = instr.clone().into_tokens().to_string()
44-
.replace('.', "_").replace(|c: char| c.is_whitespace(), "");
43+
let instr_str = instr
44+
.clone()
45+
.into_tokens()
46+
.to_string()
47+
.replace('.', "_")
48+
.replace(|c: char| c.is_whitespace(), "");
4549
let assert_name = syn::Ident::from(
4650
&format!("assert_{}_{}", name.as_ref(), instr_str)[..],
4751
);
@@ -112,7 +116,8 @@ pub fn assert_instr(
112116
}
113117
}.into();
114118
// why? necessary now to get tests to work?
115-
let tts: TokenStream = tts.to_string().parse().expect("cannot parse tokenstream");
119+
let tts: TokenStream =
120+
tts.to_string().parse().expect("cannot parse tokenstream");
116121

117122
let tts: TokenStream = quote! {
118123
#item

crates/simd-test-macro/src/lib.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ pub fn simd_test(
5353
let item = TokenStream::from(item);
5454
let name = find_name(item.clone());
5555

56-
let name: TokenStream = name.as_str().parse()
56+
let name: TokenStream = name.as_str()
57+
.parse()
5758
.expect(&format!("failed to parse name: {}", name.clone().as_str()));
5859

5960
let default_target = if cfg!(target_os = "windows") {
@@ -66,28 +67,34 @@ pub fn simd_test(
6667
None
6768
};
6869

69-
let target = env::var("TARGET").unwrap_or_else(|_| default_target.expect("TARGET environment variable not set and no default target known for the current target.").to_string());
70+
let target = env::var("TARGET").unwrap_or_else(|_| {
71+
default_target.expect("TARGET environment variable not set and no default target known for the current target.").to_string()
72+
});
7073
let mut force_test = false;
71-
let macro_test = match target.split('-').next()
72-
.expect(&format!("target triple contained no \"-\": {}", target)) {
74+
let macro_test = match target
75+
.split('-')
76+
.next()
77+
.expect(&format!("target triple contained no \"-\": {}", target))
78+
{
7379
"i686" | "x86_64" | "i586" => "is_x86_feature_detected",
7480
"arm" => "is_arm_feature_detected",
7581
"aarch64" => "is_aarch64_feature_detected",
7682
"powerpc64" => "is_powerpc64_feature_detected",
7783
"mips" | "mipsel" => {
7884
// FIXME:
79-
// On MIPS CI run-time feature detection always returns false due to
80-
// this qemu bug: https://bugs.launchpad.net/qemu/+bug/1754372
85+
// On MIPS CI run-time feature detection always returns false due
86+
// to this qemu bug: https://bugs.launchpad.net/qemu/+bug/1754372
8187
//
82-
// This is a workaround to force the MIPS tests to always run on CI.
88+
// This is a workaround to force the MIPS tests to always run on
89+
// CI.
8390
force_test = true;
8491
"is_mips_feature_detected"
85-
},
92+
}
8693
"mips64" | "mips64el" => {
8794
// FIXME: see above
8895
force_test = true;
8996
"is_mips64_feature_detected"
90-
},
97+
}
9198
t => panic!("unknown target: {}", t),
9299
};
93100
let macro_test = proc_macro2::Term::intern(macro_test);

stdsimd/arch/detect/linux/auxvec.rs

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@ use _std::fs::File;
66
use _std::io::Read;
77

88
#[cfg(not(all(target_os = "linux",
9-
any(target_arch = "aarch64",
10-
target_arch = "arm",
11-
target_arch = "powerpc64",
12-
target_arch = "mips",
9+
any(target_arch = "aarch64", target_arch = "arm",
10+
target_arch = "powerpc64", target_arch = "mips",
1311
target_arch = "mips64"))))]
1412
compile_error!("ELF auxiliary vectors are not implemented for this target.");
1513

1614
/// Key to access the CPU Hardware capabilities bitfield.
17-
#[cfg(any(target_arch = "aarch64",
18-
target_arch = "arm",
19-
target_arch = "powerpc64",
20-
target_arch = "mips",
15+
#[cfg(any(target_arch = "aarch64", target_arch = "arm",
16+
target_arch = "powerpc64", target_arch = "mips",
2117
target_arch = "mips64"))]
2218
pub const AT_HWCAP: usize = 16;
2319
/// Key to access the CPU Hardware capabilities 2 bitfield.
@@ -30,13 +26,9 @@ pub const AT_HWCAP2: usize = 26;
3026
/// This should be interpreted as all the features being disabled.
3127
#[derive(Debug, Copy, Clone)]
3228
pub struct AuxVec {
33-
#[cfg(any(
34-
target_arch = "aarch64",
35-
target_arch = "arm",
36-
target_arch = "powerpc64",
37-
target_arch = "mips",
38-
target_arch = "mips64",
39-
))]
29+
#[cfg(any(target_arch = "aarch64", target_arch = "arm",
30+
target_arch = "powerpc64", target_arch = "mips",
31+
target_arch = "mips64"))]
4032
pub hwcap: usize,
4133
#[cfg(any(target_arch = "arm", target_arch = "powerpc64"))]
4234
pub hwcap2: usize,
@@ -57,10 +49,10 @@ pub struct AuxVec {
5749
/// - Otherwise, try to read `/proc/self/auxv`.
5850
/// - If that fails, this function returns an error.
5951
///
60-
/// Note that run-time feature detection is not invoked for features that can be
61-
/// detected at compile-time. Also note that if this function returns an error,
62-
/// cpuinfo still can (and will) be used to try to perform run-time feature
63-
/// detecton on some platforms.
52+
/// Note that run-time feature detection is not invoked for features that can
53+
/// be detected at compile-time. Also note that if this function returns an
54+
/// error, cpuinfo still can (and will) be used to try to perform run-time
55+
/// feature detecton on some platforms.
6456
///
6557
/// For more information about when `getauxval` is available check the great
6658
/// [`auxv` crate documentation][auxv_docs].
@@ -71,23 +63,27 @@ pub fn auxv() -> Result<AuxVec, ()> {
7163
// Try to call a dynamically-linked getauxval function.
7264
if let Ok(hwcap) = getauxval(AT_HWCAP) {
7365
// Targets with only AT_HWCAP:
74-
#[cfg(any(target_arch = "aarch64", target_arch = "mips", target_arch = "mips64"))] {
66+
#[cfg(any(target_arch = "aarch64", target_arch = "mips",
67+
target_arch = "mips64"))]
68+
{
7569
if hwcap != 0 {
7670
return Ok(AuxVec { hwcap });
7771
}
7872
}
7973

8074
// Targets with AT_HWCAP and AT_HWCAP2:
81-
#[cfg(any(target_arch = "arm", target_arch = "powerpc64"))] {
75+
#[cfg(any(target_arch = "arm", target_arch = "powerpc64"))]
76+
{
8277
if let Ok(hwcap2) = getauxval(AT_HWCAP2) {
8378
if hwcap != 0 && hwcap2 != 0 {
8479
return Ok(AuxVec { hwcap, hwcap2 });
8580
}
8681
}
8782
}
88-
#[cfg(not(any(target_arch = "aarch64", target_arch = "mips", target_arch = "mips64",
89-
target_arch = "arm", target_arch = "powerpc64"
90-
)))] {
83+
#[cfg(not(any(target_arch = "aarch64", target_arch = "mips",
84+
target_arch = "mips64", target_arch = "arm",
85+
target_arch = "powerpc64")))]
86+
{
9187
compile_error!("function not implemented for this target");
9288
}
9389
}
@@ -97,8 +93,8 @@ pub fn auxv() -> Result<AuxVec, ()> {
9793
}
9894

9995
/// Tries to read the `key` from the auxiliary vector by calling the
100-
/// dynamically-linked `getauxval` function. If the function is not linked, this
101-
/// function return `Err`.
96+
/// dynamically-linked `getauxval` function. If the function is not linked,
97+
/// this function return `Err`.
10298
fn getauxval(key: usize) -> Result<usize, ()> {
10399
use libc;
104100
pub type F = unsafe extern "C" fn(usize) -> usize;
@@ -139,7 +135,8 @@ fn auxv_from_file(file: &str) -> Result<AuxVec, ()> {
139135
/// function returns `Err`.
140136
fn auxv_from_buf(buf: &[usize; 64]) -> Result<AuxVec, ()> {
141137
// Targets with only AT_HWCAP:
142-
#[cfg(any(target_arch = "aarch64", target_arch = "mips", target_arch = "mips64"))]
138+
#[cfg(any(target_arch = "aarch64", target_arch = "mips",
139+
target_arch = "mips64"))]
143140
{
144141
for el in buf.chunks(2) {
145142
match el[0] {
@@ -167,8 +164,9 @@ fn auxv_from_buf(buf: &[usize; 64]) -> Result<AuxVec, ()> {
167164
}
168165

169166
#[cfg(not(any(target_arch = "aarch64", target_arch = "mips",
170-
target_arch = "mips64",
171-
target_arch = "arm", target_arch = "powerpc64")))] {
167+
target_arch = "mips64", target_arch = "arm",
168+
target_arch = "powerpc64")))]
169+
{
172170
compile_error!("this function is not implemented for this target");
173171
}
174172

stdsimd/arch/detect/linux/mod.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
#[cfg(not(any(target_arch = "mips", target_arch = "mips64")))]
44
pub mod cpuinfo;
55

6-
#[cfg(any(target_arch = "aarch64",
7-
target_arch = "arm",
8-
target_arch = "powerpc64",
9-
target_arch = "mips",
6+
#[cfg(any(target_arch = "aarch64", target_arch = "arm",
7+
target_arch = "powerpc64", target_arch = "mips",
108
target_arch = "mips64"))]
119
pub mod auxvec;

stdsimd/arch/detect/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@ cfg_if! {
3535
}
3636

3737
#[cfg(all(target_os = "linux",
38-
any(target_arch = "arm",
39-
target_arch = "aarch64",
40-
target_arch = "powerpc64",
41-
target_arch = "mips",
42-
target_arch = "mips64"
43-
)))]
38+
any(target_arch = "arm", target_arch = "aarch64",
39+
target_arch = "powerpc64", target_arch = "mips",
40+
target_arch = "mips64")))]
4441
mod linux;
4542

4643
pub use self::arch::Feature;
@@ -135,10 +132,10 @@ guarding it behind a cfg(target_arch) as follows:
135132
};
136133
}
137134

138-
#[cfg(not(target_arch = "mips64"))]
139-
#[macro_export]
140-
#[unstable(feature = "stdsimd", issue = "0")]
141-
macro_rules! is_mips64_feature_detected {
135+
#[cfg(not(target_arch = "mips64"))]
136+
#[macro_export]
137+
#[unstable(feature = "stdsimd", issue = "0")]
138+
macro_rules! is_mips64_feature_detected {
142139
($t:tt) => {
143140
compile_error!(r#"
144141
is_mips64_feature_detected can only be used on MIPS64 targets.

0 commit comments

Comments
 (0)