Fixup import pathing for core
This changes simd_swizzle! to a decl_macro to give it a path, so it can be imported using a path and not the crate root. It also adds various uses that were missed and adjusts paths.
This commit is contained in:
parent
5b4282edcd
commit
ab8eec7cba
@ -2,8 +2,8 @@
|
|||||||
// Code ported from the `packed_simd` crate
|
// Code ported from the `packed_simd` crate
|
||||||
// Run this code with `cargo test --example matrix_inversion`
|
// Run this code with `cargo test --example matrix_inversion`
|
||||||
#![feature(array_chunks, portable_simd)]
|
#![feature(array_chunks, portable_simd)]
|
||||||
use core_simd::Which::*;
|
use core_simd::simd::*;
|
||||||
use core_simd::*;
|
use Which::*;
|
||||||
|
|
||||||
// Gotta define our own 4x4 matrix since Rust doesn't ship multidim arrays yet :^)
|
// Gotta define our own 4x4 matrix since Rust doesn't ship multidim arrays yet :^)
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#![cfg_attr(not(feature = "std"), no_std)]
|
#![cfg_attr(not(feature = "std"), no_std)]
|
||||||
#![feature(
|
#![feature(
|
||||||
const_fn_trait_bound,
|
const_fn_trait_bound,
|
||||||
const_panic,
|
decl_macro,
|
||||||
platform_intrinsics,
|
platform_intrinsics,
|
||||||
repr_simd,
|
repr_simd,
|
||||||
simd_ffi,
|
simd_ffi,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::simd::intrinsics;
|
use crate::simd::intrinsics;
|
||||||
use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
|
use crate::simd::{LaneCount, Simd, SimdElement, SupportedLaneCount};
|
||||||
|
|
||||||
/// Constructs a new vector by selecting values from the lanes of the source vector or vectors to use.
|
/// Constructs a new vector by selecting values from the lanes of the source vector or vectors to use.
|
||||||
///
|
///
|
||||||
@ -12,7 +12,8 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
|
|||||||
/// ## One source vector
|
/// ## One source vector
|
||||||
/// ```
|
/// ```
|
||||||
/// # #![feature(portable_simd)]
|
/// # #![feature(portable_simd)]
|
||||||
/// # use core_simd::{Simd, simd_swizzle};
|
/// # #[cfg(feature = "std")] use core_simd::{Simd, simd_swizzle};
|
||||||
|
/// # #[cfg(not(feature = "std"))] use core::simd::{Simd, simd_swizzle};
|
||||||
/// let v = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
|
/// let v = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
|
||||||
///
|
///
|
||||||
/// // Keeping the same size
|
/// // Keeping the same size
|
||||||
@ -27,7 +28,8 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
|
|||||||
/// ## Two source vectors
|
/// ## Two source vectors
|
||||||
/// ```
|
/// ```
|
||||||
/// # #![feature(portable_simd)]
|
/// # #![feature(portable_simd)]
|
||||||
/// # use core_simd::{Simd, simd_swizzle, Which};
|
/// # #[cfg(feature = "std")] use core_simd::{Simd, simd_swizzle, Which};
|
||||||
|
/// # #[cfg(not(feature = "std"))] use core::simd::{Simd, simd_swizzle, Which};
|
||||||
/// use Which::*;
|
/// use Which::*;
|
||||||
/// let a = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
|
/// let a = Simd::<f32, 4>::from_array([0., 1., 2., 3.]);
|
||||||
/// let b = Simd::<f32, 4>::from_array([4., 5., 6., 7.]);
|
/// let b = Simd::<f32, 4>::from_array([4., 5., 6., 7.]);
|
||||||
@ -40,11 +42,11 @@ use crate::{LaneCount, Simd, SimdElement, SupportedLaneCount};
|
|||||||
/// let r = simd_swizzle!(a, b, [First(0), Second(0)]);
|
/// let r = simd_swizzle!(a, b, [First(0), Second(0)]);
|
||||||
/// assert_eq!(r.to_array(), [0., 4.]);
|
/// assert_eq!(r.to_array(), [0., 4.]);
|
||||||
/// ```
|
/// ```
|
||||||
#[macro_export]
|
#[allow(unused_macros)]
|
||||||
macro_rules! simd_swizzle {
|
pub macro simd_swizzle {
|
||||||
{
|
(
|
||||||
$vector:expr, $index:expr $(,)?
|
$vector:expr, $index:expr $(,)?
|
||||||
} => {
|
) => {
|
||||||
{
|
{
|
||||||
use $crate::simd::Swizzle;
|
use $crate::simd::Swizzle;
|
||||||
struct Impl;
|
struct Impl;
|
||||||
@ -53,10 +55,10 @@ macro_rules! simd_swizzle {
|
|||||||
}
|
}
|
||||||
Impl::swizzle($vector)
|
Impl::swizzle($vector)
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
{
|
(
|
||||||
$first:expr, $second:expr, $index:expr $(,)?
|
$first:expr, $second:expr, $index:expr $(,)?
|
||||||
} => {
|
) => {
|
||||||
{
|
{
|
||||||
use $crate::simd::{Which, Swizzle2};
|
use $crate::simd::{Which, Swizzle2};
|
||||||
struct Impl;
|
struct Impl;
|
||||||
@ -262,7 +264,8 @@ where
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(portable_simd)]
|
/// #![feature(portable_simd)]
|
||||||
/// # use core_simd::Simd;
|
/// # #[cfg(feature = "std")] use core_simd::Simd;
|
||||||
|
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
|
||||||
/// let a = Simd::from_array([0, 1, 2, 3]);
|
/// let a = Simd::from_array([0, 1, 2, 3]);
|
||||||
/// let b = Simd::from_array([4, 5, 6, 7]);
|
/// let b = Simd::from_array([4, 5, 6, 7]);
|
||||||
/// let (x, y) = a.interleave(b);
|
/// let (x, y) = a.interleave(b);
|
||||||
@ -324,7 +327,8 @@ where
|
|||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #![feature(portable_simd)]
|
/// #![feature(portable_simd)]
|
||||||
/// # use core_simd::Simd;
|
/// # #[cfg(feature = "std")] use core_simd::Simd;
|
||||||
|
/// # #[cfg(not(feature = "std"))] use core::simd::Simd;
|
||||||
/// let a = Simd::from_array([0, 4, 1, 5]);
|
/// let a = Simd::from_array([0, 4, 1, 5]);
|
||||||
/// let b = Simd::from_array([2, 6, 3, 7]);
|
/// let b = Simd::from_array([2, 6, 3, 7]);
|
||||||
/// let (x, y) = a.deinterleave(b);
|
/// let (x, y) = a.deinterleave(b);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user