Skip to content

Feature/const generics #49

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 13 commits into from
Jan 19, 2021
38 changes: 9 additions & 29 deletions crates/core_simd/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ debug_wrapper! {
}

macro_rules! impl_fmt_trait {
{ $($type:ty => $(($trait:ident, $format:ident)),*;)* } => {
{ $($type:ident => $(($trait:ident, $format:ident)),*;)* } => {
$( // repeat type
$( // repeat trait
impl core::fmt::$trait for $type {
impl<const LANES: usize> core::fmt::$trait for crate::$type<LANES> {
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
$format(self.as_ref(), f)
}
}
)*
)*
};
{ integers: $($type:ty,)* } => {
{ integers: $($type:ident,)* } => {
impl_fmt_trait! {
$($type =>
(Debug, format),
Expand All @@ -54,7 +54,7 @@ macro_rules! impl_fmt_trait {
)*
}
};
{ floats: $($type:ty,)* } => {
{ floats: $($type:ident,)* } => {
impl_fmt_trait! {
$($type =>
(Debug, format),
Expand All @@ -63,7 +63,7 @@ macro_rules! impl_fmt_trait {
)*
}
};
{ masks: $($type:ty,)* } => {
{ masks: $($type:ident,)* } => {
impl_fmt_trait! {
$($type =>
(Debug, format);
Expand All @@ -74,32 +74,12 @@ macro_rules! impl_fmt_trait {

impl_fmt_trait! {
integers:
crate::u8x8, crate::u8x16, crate::u8x32, crate::u8x64,
crate::i8x8, crate::i8x16, crate::i8x32, crate::i8x64,
crate::u16x4, crate::u16x8, crate::u16x16, crate::u16x32,
crate::i16x4, crate::i16x8, crate::i16x16, crate::i16x32,
crate::u32x2, crate::u32x4, crate::u32x8, crate::u32x16,
crate::i32x2, crate::i32x4, crate::i32x8, crate::i32x16,
crate::u64x2, crate::u64x4, crate::u64x8,
crate::i64x2, crate::i64x4, crate::i64x8,
crate::u128x2, crate::u128x4,
crate::i128x2, crate::i128x4,
crate::usizex2, crate::usizex4, crate::usizex8,
crate::isizex2, crate::isizex4, crate::isizex8,
SimdU8, SimdU16, SimdU32, SimdU64, SimdU128,
SimdI8, SimdI16, SimdI32, SimdI64, SimdI128,
SimdUsize, SimdIsize,
}

impl_fmt_trait! {
floats:
crate::f32x2, crate::f32x4, crate::f32x8, crate::f32x16,
crate::f64x2, crate::f64x4, crate::f64x8,
}

impl_fmt_trait! {
masks:
crate::mask8x8, crate::mask8x16, crate::mask8x32, crate::mask8x64,
crate::mask16x4, crate::mask16x8, crate::mask16x16, crate::mask16x32,
crate::mask32x2, crate::mask32x4, crate::mask32x8, crate::mask32x16,
crate::mask64x2, crate::mask64x4, crate::mask64x8,
crate::mask128x2, crate::mask128x4,
crate::masksizex2, crate::masksizex4, crate::masksizex8,
SimdF32, SimdF64,
}
9 changes: 8 additions & 1 deletion crates/core_simd/src/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! This module contains the LLVM intrinsics bindings that provide the functionality for this
//! crate.
//!
//! The LLVM assembly language is documented here: https://llvm.org/docs/LangRef.html
//! The LLVM assembly language is documented here: <https://llvm.org/docs/LangRef.html>

/// These intrinsics aren't linked directly from LLVM and are mostly undocumented, however they are
/// simply lowered to the matching LLVM instructions by the compiler. The associated instruction
Expand Down Expand Up @@ -45,4 +45,11 @@ extern "platform-intrinsic" {

// ceil
pub(crate) fn simd_ceil<T>(x: T) -> T;

pub(crate) fn simd_eq<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_ne<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_lt<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_le<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_gt<T, U>(x: T, y: T) -> U;
pub(crate) fn simd_ge<T, U>(x: T, y: T) -> U;
}
18 changes: 2 additions & 16 deletions crates/core_simd/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![no_std]
#![feature(repr_simd, platform_intrinsics, link_llvm_intrinsics, simd_ffi)]
#![feature(repr_simd, platform_intrinsics, link_llvm_intrinsics, simd_ffi, min_const_generics)]
#![warn(missing_docs)]
//! Portable SIMD module.

Expand All @@ -9,6 +9,7 @@ mod macros;
mod fmt;
mod intrinsics;
mod ops;
mod round;

mod masks;
pub use masks::*;
Expand Down Expand Up @@ -43,18 +44,3 @@ mod vectors_f32;
pub use vectors_f32::*;
mod vectors_f64;
pub use vectors_f64::*;

mod vectors_mask8;
pub use vectors_mask8::*;
mod vectors_mask16;
pub use vectors_mask16::*;
mod vectors_mask32;
pub use vectors_mask32::*;
mod vectors_mask64;
pub use vectors_mask64::*;
mod vectors_mask128;
pub use vectors_mask128::*;
mod vectors_masksize;
pub use vectors_masksize::*;

mod round;
Loading