Skip to content

Commit 0f837a9

Browse files
committed
Add docs
1 parent 011aafe commit 0f837a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+232
-70
lines changed

crates/core_simd/src/macros.rs

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ macro_rules! from_unaligned {
2828
}
2929

3030
macro_rules! define_type {
31-
{ struct $name:ident([$type:ty; $lanes:tt]); } => {
32-
define_type! { @impl $name [$type; $lanes] }
31+
{ $(#[$attr:meta])* struct $name:ident([$type:ty; $lanes:tt]); } => {
32+
define_type! { @impl $(#[$attr])* | $name [$type; $lanes] }
3333

3434
// array references
3535
impl AsRef<[$type; $lanes]> for $name {
@@ -74,40 +74,40 @@ macro_rules! define_type {
7474
}
7575
}
7676
};
77-
{ @impl $name:ident [$type:ty; 1] } => {
78-
define_type! { @impl $name | $type | $type, | v0, }
77+
{ @impl $(#[$attr:meta])* | $name:ident [$type:ty; 1] } => {
78+
define_type! { @def $(#[$attr])* | $name | $type | $type, | v0, }
7979
};
80-
{ @impl $name:ident [$type:ty; 2] } => {
81-
define_type! { @impl $name | $type | $type, $type, | v0, v1, }
80+
{ @impl $(#[$attr:meta])* | $name:ident [$type:ty; 2] } => {
81+
define_type! { @def $(#[$attr])* | $name | $type | $type, $type, | v0, v1, }
8282
};
83-
{ @impl $name:ident [$type:ty; 4] } => {
84-
define_type! { @impl $name | $type |
83+
{ @impl $(#[$attr:meta])* | $name:ident [$type:ty; 4] } => {
84+
define_type! { @def $(#[$attr])* | $name | $type |
8585
$type, $type, $type, $type, |
8686
v0, v1, v2, v3,
8787
}
8888
};
89-
{ @impl $name:ident [$type:ty; 8] } => {
90-
define_type! { @impl $name | $type |
89+
{ @impl $(#[$attr:meta])* | $name:ident [$type:ty; 8] } => {
90+
define_type! { @def $(#[$attr])* | $name | $type |
9191
$type, $type, $type, $type, $type, $type, $type, $type, |
9292
v0, v1, v2, v3, v4, v5, v6, v7,
9393
}
9494
};
95-
{ @impl $name:ident [$type:ty; 16] } => {
96-
define_type! { @impl $name | $type |
95+
{ @impl $(#[$attr:meta])* | $name:ident [$type:ty; 16] } => {
96+
define_type! { @def $(#[$attr])* | $name | $type |
9797
$type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, |
9898
v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
9999
}
100100
};
101-
{ @impl $name:ident [$type:ty; 32] } => {
102-
define_type! { @impl $name | $type |
101+
{ @impl $(#[$attr:meta])* | $name:ident [$type:ty; 32] } => {
102+
define_type! { @def $(#[$attr])* | $name | $type |
103103
$type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type,
104104
$type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, |
105105
v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15,
106106
v16, v17, v18, v19, v20, v21, v22, v23, v24, v25, v26, v27, v28, v29, v30, v31,
107107
}
108108
};
109-
{ @impl $name:ident [$type:ty; 64] } => {
110-
define_type! { @impl $name | $type |
109+
{ @impl $(#[$attr:meta])* | $name:ident [$type:ty; 64] } => {
110+
define_type! { @def $(#[$attr])* | $name | $type |
111111
$type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type,
112112
$type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type,
113113
$type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type, $type,
@@ -118,18 +118,21 @@ macro_rules! define_type {
118118
v48, v49, v50, v51, v52, v53, v54, v55, v56, v57, v58, v59, v60, v61, v62, v63,
119119
}
120120
};
121-
{ @impl $name:ident | $type:ty | $($itype:ty,)* | $($ivar:ident,)* } => {
121+
{ @def $(#[$attr:meta])* | $name:ident | $type:ty | $($itype:ty,)* | $($ivar:ident,)* } => {
122+
$(#[$attr])*
122123
#[allow(non_camel_case_types)]
123124
#[derive(Copy, Clone, Debug, Default, PartialEq, PartialOrd)]
124125
#[repr(simd)]
125126
pub struct $name($($itype),*);
126127

127128
impl $name {
129+
/// Construct a vector by setting each lane to a single value.
128130
#[inline]
129131
pub fn splat(value: $type) -> Self {
130132
Self($(value as $itype),*)
131133
}
132134

135+
/// Construct a vector by setting each lane.
133136
#[allow(clippy::too_many_arguments)]
134137
#[inline]
135138
pub fn new($($ivar: $itype),*) -> Self {

crates/core_simd/src/type_f32x16.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
define_type! { struct f32x16([f32; 16]); }
1+
define_type! {
2+
#[doc = "Vector of 16 `f32` types"]
3+
struct f32x16([f32; 16]);
4+
}
25

36
/*
47
#[cfg(target_arch = "x86")]

crates/core_simd/src/type_f32x2.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
define_type! { struct f32x2([f32; 2]); }
1+
define_type! {
2+
#[doc = "Vector of two `f32` types"]
3+
struct f32x2([f32; 2]);
4+
}

crates/core_simd/src/type_f32x4.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
define_type! { struct f32x4([f32; 4]); }
1+
define_type! {
2+
#[doc = "Vector of four `f32` types"]
3+
struct f32x4([f32; 4]);
4+
}
25

36
#[cfg(target_arch = "x86")]
47
from_aligned! { unsafe f32x4 |bidirectional| core::arch::x86::__m128 }

crates/core_simd/src/type_f32x8.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
define_type! { struct f32x8([f32; 8]); }
1+
define_type! {
2+
#[doc = "Vector of eight `f32` types"]
3+
struct f32x8([f32; 8]);
4+
}
25

36
#[cfg(target_arch = "x86")]
47
from_aligned! { unsafe f32x8 |bidirectional| core::arch::x86::__m256 }

crates/core_simd/src/type_f64x2.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
define_type! { struct f64x2([f64; 2]); }
1+
define_type! {
2+
#[doc = "Vector of two `f64` types"]
3+
struct f64x2([f64; 2]);
4+
}
25

36
#[cfg(target_arch = "x86")]
47
from_aligned! { unsafe f64x2 |bidirectional| core::arch::x86::__m128d }

crates/core_simd/src/type_f64x4.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
define_type! { struct f64x4([f64; 4]); }
1+
define_type! {
2+
#[doc = "Vector of four `f64` types"]
3+
struct f64x4([f64; 4]);
4+
}
25

36
#[cfg(target_arch = "x86")]
47
from_aligned! { unsafe f64x4 |bidirectional| core::arch::x86::__m256d }

crates/core_simd/src/type_f64x8.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
define_type! { struct f64x8([f64; 8]); }
1+
define_type! {
2+
#[doc = "Vector of eight `f64` types"]
3+
struct f64x8([f64; 8]);
4+
}
25

36
/*
47
#[cfg(target_arch = "x86")]

crates/core_simd/src/type_i128x2.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
define_type! { struct i128x2([i128; 2]); }
1+
define_type! {
2+
#[doc = "Vector of two `i128` types"]
3+
struct i128x2([i128; 2]);
4+
}
25

36
#[cfg(target_arch = "x86")]
47
from_aligned! { unsafe i128x2 |bidirectional| core::arch::x86::__m256i }

crates/core_simd/src/type_i128x4.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
define_type! { struct i128x4([i128; 4]); }
1+
define_type! {
2+
#[doc = "Vector of four `i128` types"]
3+
struct i128x4([i128; 4]);
4+
}
25

36
/*
47
#[cfg(target_arch = "x86")]

0 commit comments

Comments
 (0)