Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Move simd out of unstable #12524

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
html_root_url = "http://static.rust-lang.org/doc/master")]

#![no_std]
#![feature(globs, macro_rules, managed_boxes, phase)]
#![feature(globs, macro_rules, managed_boxes, phase, simd)]
#![deny(missing_doc)]

#[cfg(test)] extern crate realcore = "core";
Expand Down Expand Up @@ -117,6 +117,11 @@ pub mod slice;
pub mod str;
pub mod tuple;
pub mod fmt;
#[experimental]
pub mod simd;

#[cfg(stage0, not(test))]
pub mod owned;

// FIXME: this module should not exist. Once owned allocations are no longer a
// language type, this module can move outside to the owned allocation
Expand Down
60 changes: 47 additions & 13 deletions src/libstd/unstable/simd.rs → src/libcore/simd.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
Expand All @@ -8,54 +8,88 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

//! SIMD vectors
//! 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
//! #[allow(experimental)];
//!
//! 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);
//! println!("{}", a + b);
//! }
//! ```
//!
//! ## Stability Note
//!
//! These are all experimental. The inferface may change entirely, without
//! warning.

#![allow(non_camel_case_types)]
#![allow(missing_doc)]

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
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);

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
pub i16, pub i16, pub i16, pub i16);

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
pub struct i32x4(pub i32, pub i32, pub i32, pub i32);

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
pub struct i64x2(pub i64, pub i64);

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
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);

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
pub u16, pub u16, pub u16, pub u16);

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
pub struct u32x4(pub u32, pub u32, pub u32, pub u32);

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
pub struct u64x2(pub u64, pub u64);

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);

#[experimental]
#[simd]
#[experimental]
#[deriving(Show)]
pub struct f64x2(pub f64, pub f64);
3 changes: 2 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://static.rust-lang.org/doc/master")]
#![feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
simd, linkage, default_type_params, phase, concat_idents, quad_precision_float)]
linkage, default_type_params, phase, concat_idents, quad_precision_float)]

// Don't link to std. We are std.
#![no_std]
Expand Down Expand Up @@ -154,6 +154,7 @@ pub use core::ptr;
pub use core::raw;
pub use core::tuple;
pub use core::result;
pub use core::simd;

// Run tests with libgreen instead of libnative.
//
Expand Down
1 change: 0 additions & 1 deletion src/libstd/unstable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub use core::finally;

pub mod dynamic_lib;

pub mod simd;
pub mod sync;
pub mod mutex;

Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/simd-experimental.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#![deny(experimental)]

use std::unstable::simd;
use std::simd;

fn main() {
let _ = simd::i64x2(0, 0); //~ ERROR: experimental
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/simd-binop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

#![allow(experimental)]

use std::unstable::simd::{i32x4, f32x4, u32x4};
use std::simd::{i32x4, f32x4, u32x4};

fn eq_u32x4(u32x4(x0, x1, x2, x3): u32x4, u32x4(y0, y1, y2, y3): u32x4) -> bool {
(x0 == y0) && (x1 == y1) && (x2 == y2) && (x3 == y3)
Expand Down
2 changes: 1 addition & 1 deletion src/test/run-pass/simd-issue-10604.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
#![feature(simd)]

pub fn main() {
let _o = None::<std::unstable::simd::i32x4>;
let _o = None::<std::simd::i32x4>;
}