]> git.proxmox.com Git - rustc.git/blame - src/libcore/simd.rs
Imported Upstream version 1.2.0+dfsg1
[rustc.git] / src / libcore / simd.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11//! SIMD vectors.
12//!
13//! These types can be used for accessing basic SIMD operations. Each of them
14//! implements the standard arithmetic operator traits (Add, Sub, Mul, Div,
15//! Rem, Shl, Shr) through compiler magic, rather than explicitly. Currently
16//! comparison operators are not implemented. To use SSE3+, you must enable
17//! the features, like `-C target-feature=sse3,sse4.1,sse4.2`, or a more
18//! specific `target-cpu`. No other SIMD intrinsics or high-level wrappers are
19//! provided beyond this module.
20//!
21//! ```rust
62682a34 22//! # #![feature(core_simd)]
1a4d82fc
JJ
23//! fn main() {
24//! use std::simd::f32x4;
25//! let a = f32x4(40.0, 41.0, 42.0, 43.0);
26//! let b = f32x4(1.0, 1.1, 3.4, 9.8);
27//! println!("{:?}", a + b);
28//! }
29//! ```
30//!
31//! # Stability Note
32//!
33//! These are all experimental. The interface may change entirely, without
34//! warning.
35
62682a34
SL
36#![unstable(feature = "core_simd",
37 reason = "needs an RFC to flesh out the design")]
38
1a4d82fc
JJ
39#![allow(non_camel_case_types)]
40#![allow(missing_docs)]
41
1a4d82fc 42#[simd]
c34b1796 43#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
44#[repr(C)]
45pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
46 pub i8, pub i8, pub i8, pub i8,
47 pub i8, pub i8, pub i8, pub i8,
48 pub i8, pub i8, pub i8, pub i8);
49
1a4d82fc 50#[simd]
c34b1796 51#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
52#[repr(C)]
53pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
54 pub i16, pub i16, pub i16, pub i16);
55
1a4d82fc 56#[simd]
c34b1796 57#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
58#[repr(C)]
59pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
60
1a4d82fc 61#[simd]
c34b1796 62#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
63#[repr(C)]
64pub struct i64x2(pub i64, pub i64);
65
1a4d82fc 66#[simd]
c34b1796 67#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
68#[repr(C)]
69pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
70 pub u8, pub u8, pub u8, pub u8,
71 pub u8, pub u8, pub u8, pub u8,
72 pub u8, pub u8, pub u8, pub u8);
73
1a4d82fc 74#[simd]
c34b1796 75#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
76#[repr(C)]
77pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
78 pub u16, pub u16, pub u16, pub u16);
79
1a4d82fc 80#[simd]
c34b1796 81#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
82#[repr(C)]
83pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
84
1a4d82fc 85#[simd]
c34b1796 86#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
87#[repr(C)]
88pub struct u64x2(pub u64, pub u64);
89
1a4d82fc 90#[simd]
c34b1796 91#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
92#[repr(C)]
93pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
94
1a4d82fc 95#[simd]
c34b1796 96#[derive(Copy, Clone, Debug)]
1a4d82fc
JJ
97#[repr(C)]
98pub struct f64x2(pub f64, pub f64);