2013-05-02 21:33:41 +09:00
|
|
|
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
2014-05-23 11:02:04 -07:00
|
|
|
//! SIMD vectors.
|
|
|
|
//!
|
|
|
|
//! These types can be used for accessing basic SIMD operations. Each of them
|
|
|
|
//! implements the standard arithmetic operator traits (Add, Sub, Mul, Div,
|
|
|
|
//! Rem, Shl, Shr) through compiler magic, rather than explicitly. Currently
|
|
|
|
//! comparison operators are not implemented. To use SSE3+, you must enable
|
|
|
|
//! the features, like `-C target-feature=sse3,sse4.1,sse4.2`, or a more
|
|
|
|
//! specific `target-cpu`. No other SIMD intrinsics or high-level wrappers are
|
|
|
|
//! provided beyond this module.
|
|
|
|
//!
|
|
|
|
//! ```rust
|
2015-03-13 15:28:35 -07:00
|
|
|
//! # #![feature(core)]
|
2014-05-23 11:02:04 -07:00
|
|
|
//! fn main() {
|
|
|
|
//! use std::simd::f32x4;
|
|
|
|
//! let a = f32x4(40.0, 41.0, 42.0, 43.0);
|
|
|
|
//! let b = f32x4(1.0, 1.1, 3.4, 9.8);
|
2015-01-06 16:16:35 -08:00
|
|
|
//! println!("{:?}", a + b);
|
2014-05-23 11:02:04 -07:00
|
|
|
//! }
|
|
|
|
//! ```
|
|
|
|
//!
|
2014-12-10 13:54:56 -05:00
|
|
|
//! # Stability Note
|
2014-05-23 11:02:04 -07:00
|
|
|
//!
|
2014-06-08 13:22:49 -04:00
|
|
|
//! These are all experimental. The interface may change entirely, without
|
2014-05-23 11:02:04 -07:00
|
|
|
//! warning.
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2014-03-21 18:05:05 -07:00
|
|
|
#![allow(non_camel_case_types)]
|
2014-10-27 15:37:07 -07:00
|
|
|
#![allow(missing_docs)]
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
|
|
|
|
pub i8, pub i8, pub i8, pub i8,
|
|
|
|
pub i8, pub i8, pub i8, pub i8,
|
|
|
|
pub i8, pub i8, pub i8, pub i8);
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
|
|
|
|
pub i16, pub i16, pub i16, pub i16);
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct i64x2(pub i64, pub i64);
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
|
|
|
|
pub u8, pub u8, pub u8, pub u8,
|
|
|
|
pub u8, pub u8, pub u8, pub u8,
|
|
|
|
pub u8, pub u8, pub u8, pub u8);
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
|
|
|
|
pub u16, pub u16, pub u16, pub u16);
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct u64x2(pub u64, pub u64);
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
|
2013-05-02 21:33:41 +09:00
|
|
|
|
2015-01-22 18:22:03 -08:00
|
|
|
#[unstable(feature = "core")]
|
2013-05-02 21:33:41 +09:00
|
|
|
#[simd]
|
2015-03-30 09:40:52 -04:00
|
|
|
#[derive(Copy, Clone, Debug)]
|
2014-08-14 15:49:26 -04:00
|
|
|
#[repr(C)]
|
2014-03-31 19:01:01 -07:00
|
|
|
pub struct f64x2(pub f64, pub f64);
|