]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #14379 : brson/rust/simd, r=alexcrichton
authorbors <bors@rust-lang.org>
Sat, 24 May 2014 01:06:19 +0000 (18:06 -0700)
committerbors <bors@rust-lang.org>
Sat, 24 May 2014 01:06:19 +0000 (18:06 -0700)
Followup to https://github.com/mozilla/rust/pull/14331 and https://github.com/mozilla/rust/pull/12524

20 files changed:
src/libcore/finally.rs
src/libcore/lib.rs
src/libcore/simd.rs [new file with mode: 0644]
src/libstd/io/test.rs
src/libstd/lib.rs
src/libstd/rt/args.rs
src/libstd/rt/mod.rs
src/libstd/rt/task.rs
src/libstd/rt/util.rs
src/libstd/slice.rs
src/libstd/unstable/mod.rs
src/libstd/unstable/simd.rs [deleted file]
src/libsync/raw.rs
src/test/bench/shootout-mandelbrot.rs
src/test/compile-fail/simd-binop.rs
src/test/compile-fail/simd-experimental.rs
src/test/debuginfo/simd.rs
src/test/run-pass/backtrace.rs
src/test/run-pass/simd-binop.rs
src/test/run-pass/simd-issue-10604.rs

index a4d261f539a5005a8761a049a22b628a059ed5b0..9f7592a80bd180621d923635455c0e5226281517 100644 (file)
@@ -20,7 +20,7 @@
 # Example
 
 ```
-use std::unstable::finally::Finally;
+use std::finally::Finally;
 
 (|| {
     // ...
@@ -75,7 +75,7 @@ fn finally(&mut self, dtor: ||) -> T {
  * # Example
  *
  * ```
- * use std::unstable::finally::try_finally;
+ * use std::finally::try_finally;
  *
  * struct State<'a> { buffer: &'a mut [u8], len: uint }
  * # let mut buf = [];
index 0ddd3d8fd56e51f6a758f60ad81c24713ff9d3a2..56cbe2e2a30d187ec32bea4f82fc34ed6f1febe0 100644 (file)
@@ -53,7 +53,7 @@
        html_root_url = "http://doc.rust-lang.org/")]
 
 #![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";
 pub mod option;
 pub mod raw;
 pub mod result;
+pub mod simd;
 pub mod slice;
 pub mod str;
 pub mod tuple;
diff --git a/src/libcore/simd.rs b/src/libcore/simd.rs
new file mode 100644 (file)
index 0000000..99b802f
--- /dev/null
@@ -0,0 +1,96 @@
+// 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.
+
+//! 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]
+#[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]
+#[deriving(Show)]
+pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
+                 pub i16, pub i16, pub i16, pub i16);
+
+#[experimental]
+#[simd]
+#[deriving(Show)]
+pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
+
+#[experimental]
+#[simd]
+#[deriving(Show)]
+pub struct i64x2(pub i64, pub i64);
+
+#[experimental]
+#[simd]
+#[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]
+#[deriving(Show)]
+pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
+                 pub u16, pub u16, pub u16, pub u16);
+
+#[experimental]
+#[simd]
+#[deriving(Show)]
+pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
+
+#[experimental]
+#[simd]
+#[deriving(Show)]
+pub struct u64x2(pub u64, pub u64);
+
+#[experimental]
+#[simd]
+#[deriving(Show)]
+pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
+
+#[experimental]
+#[simd]
+#[deriving(Show)]
+pub struct f64x2(pub f64, pub f64);
index de8a6f4beb5ea3102bad955d034d578bbe409cb0..bc52bc9946c087c15fafe4ed8fb6538dcad7c2f4 100644 (file)
@@ -37,7 +37,7 @@ mod $name {
             use io::net::unix::*;
             use io::timer::*;
             use io::process::*;
-            use unstable::running_on_valgrind;
+            use rt::running_on_valgrind;
             use str;
 
             fn f() $b
index 8a7d3f394725500339eb43ec02c2cbeb749493e9..ca70fd162b7d8f7d3fb417075cd66dc56f2bdd61 100644 (file)
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/")]
 #![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]
 #[cfg(not(test))] pub use core::cmp;
 pub use core::container;
 pub use core::default;
+pub use core::finally;
 pub use core::intrinsics;
 pub use core::iter;
 #[cfg(not(test))] pub use core::kinds;
 #[cfg(not(test))] pub use core::ops;
 pub use core::ptr;
 pub use core::raw;
+pub use core::simd;
 pub use core::tuple;
 #[cfg(not(test))] pub use core::ty;
 pub use core::result;
index cde20521c2f66bda09b1486bfa368ffa9f338da1..4316fb21d415047ecbef2d5a04107dbb4061718f 100644 (file)
@@ -144,7 +144,7 @@ unsafe fn load_argc_and_argv(argc: int, argv: **u8) -> Vec<Vec<u8>> {
     mod tests {
         use prelude::*;
         use super::*;
-        use unstable::finally::Finally;
+        use finally::Finally;
 
         #[test]
         fn smoke_test() {
index daf18346fee2afcfcf0f261e84d7c2ea078e16bf..d2131ad44fb301cabf0e674d45b6935aa74739f2 100644 (file)
 
 pub use alloc::{heap, libc_heap};
 
+// Used by I/O tests
+#[experimental]
+pub use self::util::running_on_valgrind;
+
 // FIXME: these probably shouldn't be public...
 #[doc(hidden)]
 pub mod shouldnt_be_public {
index 749f44d1c9d2c0e37837a0d64527c86b0426f8bc..3e61f3ff23624050614b0570ab0ec863b9aad0e0 100644 (file)
@@ -36,7 +36,7 @@
 use str::SendStr;
 use sync::atomics::{AtomicUint, SeqCst};
 use task::{TaskResult, TaskOpts};
-use unstable::finally::Finally;
+use finally::Finally;
 
 /// The Task struct represents all state associated with a rust
 /// task. There are at this point two primary "subtypes" of task,
index 1ab9ac1b11edca81f18d34c48acc4d7b3d92c4bb..103fbdc0bc93d2f58ce9f1e51595a375f4826757 100644 (file)
 use io;
 use iter::Iterator;
 use libc;
+use libc::uintptr_t;
 use option::{Some, None, Option};
 use os;
 use result::Ok;
 use str::{Str, StrSlice};
-use unstable::running_on_valgrind;
 use slice::ImmutableVector;
 
 // Indicates whether we should perform expensive sanity checks, including rtassert!
@@ -162,3 +162,15 @@ fn abort() -> ! {
         unsafe { intrinsics::abort() }
     }
 }
+
+/// Dynamically inquire about whether we're running under V.
+/// You should usually not use this unless your test definitely
+/// can't run correctly un-altered. Valgrind is there to help
+/// you notice weirdness in normal, un-doctored code paths!
+pub fn running_on_valgrind() -> bool {
+    unsafe { rust_running_on_valgrind() != 0 }
+}
+
+extern {
+    fn rust_running_on_valgrind() -> uintptr_t;
+}
index 18dc871fb27102ead4937f74a9a2bc5d327acd08..e1242e24537572d4d4c183d2d8bb2212ce4ab25a 100644 (file)
 use ptr::RawPtr;
 use ptr;
 use rt::heap::{allocate, deallocate};
-use unstable::finally::try_finally;
+use finally::try_finally;
 use vec::Vec;
 
 pub use core::slice::{ref_slice, mut_ref_slice, Splits, Windows};
index f464f70772d9412e6616f21c4f3b9bf70931f9d4..d8de6463fabbd73c7feb9da30b987f5daec9b4c2 100644 (file)
 
 #![doc(hidden)]
 
-use libc::uintptr_t;
-
-pub use core::finally;
-
 pub mod dynamic_lib;
 
-pub mod simd;
 pub mod sync;
 pub mod mutex;
 
-/// Dynamically inquire about whether we're running under V.
-/// You should usually not use this unless your test definitely
-/// can't run correctly un-altered. Valgrind is there to help
-/// you notice weirdness in normal, un-doctored code paths!
-pub fn running_on_valgrind() -> bool {
-    unsafe { rust_running_on_valgrind() != 0 }
-}
-
-extern {
-    fn rust_running_on_valgrind() -> uintptr_t;
-}
diff --git a/src/libstd/unstable/simd.rs b/src/libstd/unstable/simd.rs
deleted file mode 100644 (file)
index a7a314d..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-// 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.
-
-//! SIMD vectors
-
-#![allow(non_camel_case_types)]
-
-#[experimental]
-#[simd]
-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]
-pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
-                 pub i16, pub i16, pub i16, pub i16);
-
-#[experimental]
-#[simd]
-pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
-
-#[experimental]
-#[simd]
-pub struct i64x2(pub i64, pub i64);
-
-#[experimental]
-#[simd]
-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]
-pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
-                 pub u16, pub u16, pub u16, pub u16);
-
-#[experimental]
-#[simd]
-pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
-
-#[experimental]
-#[simd]
-pub struct u64x2(pub u64, pub u64);
-
-#[experimental]
-#[simd]
-pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
-
-#[experimental]
-#[simd]
-pub struct f64x2(pub f64, pub f64);
index 591318d24b23c45c7af18de9131c0d8293521166..aae790f887a61caf4f1a595f0ae4cf740ec026a5 100644 (file)
@@ -18,7 +18,7 @@
 use std::kinds::marker;
 use std::mem;
 use std::sync::atomics;
-use std::unstable::finally::Finally;
+use std::finally::Finally;
 
 use mutex;
 
index 6b3079b8fc8d1246761b77f490cea9609d707352..70abebd321a94862215e0bc867f8cb381751f610 100644 (file)
@@ -17,7 +17,7 @@
 
 use std::io;
 use std::os;
-use std::unstable::simd::f64x2;
+use std::simd::f64x2;
 use sync::Future;
 use sync::Arc;
 
index 281e879592dde592a5b5ce0ba4e1c87cc4a6dd86..9fbb7364054d51c6b0d13020c1a7c6f8a7b38a37 100644 (file)
 
 #![allow(experimental)]
 
-use std::unstable::simd::f32x4;
+use std::simd::f32x4;
 
 fn main() {
 
     let _ = f32x4(0.0, 0.0, 0.0, 0.0) == f32x4(0.0, 0.0, 0.0, 0.0);
-    //~^ ERROR binary comparison operation `==` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
+    //~^ ERROR binary comparison operation `==` not supported for floating point SIMD vector `core::simd::f32x4`
 
     let _ = f32x4(0.0, 0.0, 0.0, 0.0) != f32x4(0.0, 0.0, 0.0, 0.0);
-    //~^ ERROR binary comparison operation `!=` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
+    //~^ ERROR binary comparison operation `!=` not supported for floating point SIMD vector `core::simd::f32x4`
 
     let _ = f32x4(0.0, 0.0, 0.0, 0.0) < f32x4(0.0, 0.0, 0.0, 0.0);
-    //~^ ERROR binary comparison operation `<` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
+    //~^ ERROR binary comparison operation `<` not supported for floating point SIMD vector `core::simd::f32x4`
 
     let _ = f32x4(0.0, 0.0, 0.0, 0.0) <= f32x4(0.0, 0.0, 0.0, 0.0);
-    //~^ ERROR binary comparison operation `<=` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
+    //~^ ERROR binary comparison operation `<=` not supported for floating point SIMD vector `core::simd::f32x4`
 
     let _ = f32x4(0.0, 0.0, 0.0, 0.0) >= f32x4(0.0, 0.0, 0.0, 0.0);
-    //~^ ERROR binary comparison operation `>=` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
+    //~^ ERROR binary comparison operation `>=` not supported for floating point SIMD vector `core::simd::f32x4`
 
     let _ = f32x4(0.0, 0.0, 0.0, 0.0) > f32x4(0.0, 0.0, 0.0, 0.0);
-    //~^ ERROR binary comparison operation `>` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
+    //~^ ERROR binary comparison operation `>` not supported for floating point SIMD vector `core::simd::f32x4`
 
 }
index f9cc4d0d8c372f1658dc1eed65a325e1d07c3e91..5f9f56bf3c0f4800e52d8ed641a87a445d127a6d 100644 (file)
@@ -10,7 +10,7 @@
 
 #![deny(experimental)]
 
-use std::unstable::simd;
+use std::simd;
 
 fn main() {
     let _ = simd::i64x2(0, 0); //~ ERROR: experimental
index ff9618aa1f1eb08a6fc363e96ba133e525b4a73a..b84405ee7270e76271bd289cb26dfc27cedd923c 100644 (file)
@@ -43,7 +43,7 @@
 #![allow(experimental)]
 #![allow(unused_variable)]
 
-use std::unstable::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2};
+use std::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2};
 
 fn main() {
 
index 5e7b9d9560e381794df09e73205090b79d22cee2..7f2c9e14af10d747728660012a1b616c79548566 100644 (file)
@@ -15,7 +15,7 @@
 
 use std::os;
 use std::io::process::Command;
-use std::unstable::finally::Finally;
+use std::finally::Finally;
 use std::str;
 
 #[start]
index efcd99a04cedd86534ddb475e9dee433b831cc9a..7f9be78d5832db8aac58f5f06f2c57aa029a1e6a 100644 (file)
@@ -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)
index 2e533e3b263a0186ad3815941464b2c23c0568ee..966db25a128a797849065b9f8a3d8350ac3cfc3b 100644 (file)
@@ -13,5 +13,5 @@
 #![feature(simd)]
 
 pub fn main() {
-    let _o = None::<std::unstable::simd::i32x4>;
+    let _o = None::<std::simd::i32x4>;
 }