Skip to content

Commit 12e80f1

Browse files
committed
auto merge of #14379 : brson/rust/simd, r=alexcrichton
Followup to #14331 and #12524
2 parents 4462687 + 02d1ce8 commit 12e80f1

File tree

19 files changed

+78
-40
lines changed

19 files changed

+78
-40
lines changed

src/libcore/finally.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ also be used. See that function for more details.
2020
# Example
2121
2222
```
23-
use std::unstable::finally::Finally;
23+
use std::finally::Finally;
2424
2525
(|| {
2626
// ...
@@ -75,7 +75,7 @@ impl<T> Finally<T> for fn() -> T {
7575
* # Example
7676
*
7777
* ```
78-
* use std::unstable::finally::try_finally;
78+
* use std::finally::try_finally;
7979
*
8080
* struct State<'a> { buffer: &'a mut [u8], len: uint }
8181
* # let mut buf = [];

src/libcore/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
html_root_url = "http://doc.rust-lang.org/")]
5454

5555
#![no_std]
56-
#![feature(globs, macro_rules, managed_boxes, phase)]
56+
#![feature(globs, macro_rules, managed_boxes, phase, simd)]
5757
#![deny(missing_doc)]
5858

5959
#[cfg(test)] extern crate realcore = "core";
@@ -124,6 +124,7 @@ pub mod iter;
124124
pub mod option;
125125
pub mod raw;
126126
pub mod result;
127+
pub mod simd;
127128
pub mod slice;
128129
pub mod str;
129130
pub mod tuple;

src/libstd/unstable/simd.rs renamed to src/libcore/simd.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,54 +8,89 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
//! SIMD vectors
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
22+
//! #[allow(experimental)];
23+
//!
24+
//! fn main() {
25+
//! use std::simd::f32x4;
26+
//! let a = f32x4(40.0, 41.0, 42.0, 43.0);
27+
//! let b = f32x4(1.0, 1.1, 3.4, 9.8);
28+
//! println!("{}", a + b);
29+
//! }
30+
//! ```
31+
//!
32+
//! ## Stability Note
33+
//!
34+
//! These are all experimental. The inferface may change entirely, without
35+
//! warning.
1236
1337
#![allow(non_camel_case_types)]
38+
#![allow(missing_doc)]
1439

1540
#[experimental]
1641
#[simd]
42+
#[deriving(Show)]
1743
pub struct i8x16(pub i8, pub i8, pub i8, pub i8,
1844
pub i8, pub i8, pub i8, pub i8,
1945
pub i8, pub i8, pub i8, pub i8,
2046
pub i8, pub i8, pub i8, pub i8);
2147

2248
#[experimental]
2349
#[simd]
50+
#[deriving(Show)]
2451
pub struct i16x8(pub i16, pub i16, pub i16, pub i16,
2552
pub i16, pub i16, pub i16, pub i16);
2653

2754
#[experimental]
2855
#[simd]
56+
#[deriving(Show)]
2957
pub struct i32x4(pub i32, pub i32, pub i32, pub i32);
3058

3159
#[experimental]
3260
#[simd]
61+
#[deriving(Show)]
3362
pub struct i64x2(pub i64, pub i64);
3463

3564
#[experimental]
3665
#[simd]
66+
#[deriving(Show)]
3767
pub struct u8x16(pub u8, pub u8, pub u8, pub u8,
3868
pub u8, pub u8, pub u8, pub u8,
3969
pub u8, pub u8, pub u8, pub u8,
4070
pub u8, pub u8, pub u8, pub u8);
4171

4272
#[experimental]
4373
#[simd]
74+
#[deriving(Show)]
4475
pub struct u16x8(pub u16, pub u16, pub u16, pub u16,
4576
pub u16, pub u16, pub u16, pub u16);
4677

4778
#[experimental]
4879
#[simd]
80+
#[deriving(Show)]
4981
pub struct u32x4(pub u32, pub u32, pub u32, pub u32);
5082

5183
#[experimental]
5284
#[simd]
85+
#[deriving(Show)]
5386
pub struct u64x2(pub u64, pub u64);
5487

5588
#[experimental]
5689
#[simd]
90+
#[deriving(Show)]
5791
pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
5892

5993
#[experimental]
6094
#[simd]
95+
#[deriving(Show)]
6196
pub struct f64x2(pub f64, pub f64);

src/libstd/io/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ macro_rules! iotest (
3737
use io::net::unix::*;
3838
use io::timer::*;
3939
use io::process::*;
40-
use unstable::running_on_valgrind;
40+
use rt::running_on_valgrind;
4141
use str;
4242

4343
fn f() $b

src/libstd/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
104104
html_root_url = "http://doc.rust-lang.org/")]
105105
#![feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args,
106-
simd, linkage, default_type_params, phase, concat_idents, quad_precision_float)]
106+
linkage, default_type_params, phase, concat_idents, quad_precision_float)]
107107

108108
// Don't link to std. We are std.
109109
#![no_std]
@@ -144,13 +144,15 @@ pub use core::clone;
144144
#[cfg(not(test))] pub use core::cmp;
145145
pub use core::container;
146146
pub use core::default;
147+
pub use core::finally;
147148
pub use core::intrinsics;
148149
pub use core::iter;
149150
#[cfg(not(test))] pub use core::kinds;
150151
pub use core::mem;
151152
#[cfg(not(test))] pub use core::ops;
152153
pub use core::ptr;
153154
pub use core::raw;
155+
pub use core::simd;
154156
pub use core::tuple;
155157
#[cfg(not(test))] pub use core::ty;
156158
pub use core::result;

src/libstd/rt/args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ mod imp {
144144
mod tests {
145145
use prelude::*;
146146
use super::*;
147-
use unstable::finally::Finally;
147+
use finally::Finally;
148148

149149
#[test]
150150
fn smoke_test() {

src/libstd/rt/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ pub use self::util::{Stdio, Stdout, Stderr};
7676

7777
pub use alloc::{heap, libc_heap};
7878

79+
// Used by I/O tests
80+
#[experimental]
81+
pub use self::util::running_on_valgrind;
82+
7983
// FIXME: these probably shouldn't be public...
8084
#[doc(hidden)]
8185
pub mod shouldnt_be_public {

src/libstd/rt/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use rt::unwind::Unwinder;
3636
use str::SendStr;
3737
use sync::atomics::{AtomicUint, SeqCst};
3838
use task::{TaskResult, TaskOpts};
39-
use unstable::finally::Finally;
39+
use finally::Finally;
4040

4141
/// The Task struct represents all state associated with a rust
4242
/// task. There are at this point two primary "subtypes" of task,

src/libstd/rt/util.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ use io::IoResult;
1515
use io;
1616
use iter::Iterator;
1717
use libc;
18+
use libc::uintptr_t;
1819
use option::{Some, None, Option};
1920
use os;
2021
use result::Ok;
2122
use str::{Str, StrSlice};
22-
use unstable::running_on_valgrind;
2323
use slice::ImmutableVector;
2424

2525
// Indicates whether we should perform expensive sanity checks, including rtassert!
@@ -162,3 +162,15 @@ memory and partly incapable of presentation to others.",
162162
unsafe { intrinsics::abort() }
163163
}
164164
}
165+
166+
/// Dynamically inquire about whether we're running under V.
167+
/// You should usually not use this unless your test definitely
168+
/// can't run correctly un-altered. Valgrind is there to help
169+
/// you notice weirdness in normal, un-doctored code paths!
170+
pub fn running_on_valgrind() -> bool {
171+
unsafe { rust_running_on_valgrind() != 0 }
172+
}
173+
174+
extern {
175+
fn rust_running_on_valgrind() -> uintptr_t;
176+
}

src/libstd/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ use option::{None, Option, Some};
110110
use ptr::RawPtr;
111111
use ptr;
112112
use rt::heap::{allocate, deallocate};
113-
use unstable::finally::try_finally;
113+
use finally::try_finally;
114114
use vec::Vec;
115115

116116
pub use core::slice::{ref_slice, mut_ref_slice, Splits, Windows};

src/libstd/unstable/mod.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,8 @@
1010

1111
#![doc(hidden)]
1212

13-
use libc::uintptr_t;
14-
15-
pub use core::finally;
16-
1713
pub mod dynamic_lib;
1814

19-
pub mod simd;
2015
pub mod sync;
2116
pub mod mutex;
2217

23-
/// Dynamically inquire about whether we're running under V.
24-
/// You should usually not use this unless your test definitely
25-
/// can't run correctly un-altered. Valgrind is there to help
26-
/// you notice weirdness in normal, un-doctored code paths!
27-
pub fn running_on_valgrind() -> bool {
28-
unsafe { rust_running_on_valgrind() != 0 }
29-
}
30-
31-
extern {
32-
fn rust_running_on_valgrind() -> uintptr_t;
33-
}

src/libsync/raw.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use std::kinds::marker;
1919
use std::mem;
2020
use std::sync::atomics;
21-
use std::unstable::finally::Finally;
21+
use std::finally::Finally;
2222

2323
use mutex;
2424

src/test/bench/shootout-mandelbrot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extern crate sync;
1717

1818
use std::io;
1919
use std::os;
20-
use std::unstable::simd::f64x2;
20+
use std::simd::f64x2;
2121
use sync::Future;
2222
use sync::Arc;
2323

src/test/compile-fail/simd-binop.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@
1212

1313
#![allow(experimental)]
1414

15-
use std::unstable::simd::f32x4;
15+
use std::simd::f32x4;
1616

1717
fn main() {
1818

1919
let _ = f32x4(0.0, 0.0, 0.0, 0.0) == f32x4(0.0, 0.0, 0.0, 0.0);
20-
//~^ ERROR binary comparison operation `==` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
20+
//~^ ERROR binary comparison operation `==` not supported for floating point SIMD vector `core::simd::f32x4`
2121

2222
let _ = f32x4(0.0, 0.0, 0.0, 0.0) != f32x4(0.0, 0.0, 0.0, 0.0);
23-
//~^ ERROR binary comparison operation `!=` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
23+
//~^ ERROR binary comparison operation `!=` not supported for floating point SIMD vector `core::simd::f32x4`
2424

2525
let _ = f32x4(0.0, 0.0, 0.0, 0.0) < f32x4(0.0, 0.0, 0.0, 0.0);
26-
//~^ ERROR binary comparison operation `<` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
26+
//~^ ERROR binary comparison operation `<` not supported for floating point SIMD vector `core::simd::f32x4`
2727

2828
let _ = f32x4(0.0, 0.0, 0.0, 0.0) <= f32x4(0.0, 0.0, 0.0, 0.0);
29-
//~^ ERROR binary comparison operation `<=` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
29+
//~^ ERROR binary comparison operation `<=` not supported for floating point SIMD vector `core::simd::f32x4`
3030

3131
let _ = f32x4(0.0, 0.0, 0.0, 0.0) >= f32x4(0.0, 0.0, 0.0, 0.0);
32-
//~^ ERROR binary comparison operation `>=` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
32+
//~^ ERROR binary comparison operation `>=` not supported for floating point SIMD vector `core::simd::f32x4`
3333

3434
let _ = f32x4(0.0, 0.0, 0.0, 0.0) > f32x4(0.0, 0.0, 0.0, 0.0);
35-
//~^ ERROR binary comparison operation `>` not supported for floating point SIMD vector `std::unstable::simd::f32x4`
35+
//~^ ERROR binary comparison operation `>` not supported for floating point SIMD vector `core::simd::f32x4`
3636

3737
}

src/test/compile-fail/simd-experimental.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#![deny(experimental)]
1212

13-
use std::unstable::simd;
13+
use std::simd;
1414

1515
fn main() {
1616
let _ = simd::i64x2(0, 0); //~ ERROR: experimental

src/test/debuginfo/simd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#![allow(experimental)]
4444
#![allow(unused_variable)]
4545

46-
use std::unstable::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2};
46+
use std::simd::{i8x16, i16x8,i32x4,i64x2,u8x16,u16x8,u32x4,u64x2,f32x4,f64x2};
4747

4848
fn main() {
4949

src/test/run-pass/backtrace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extern crate native;
1515

1616
use std::os;
1717
use std::io::process::Command;
18-
use std::unstable::finally::Finally;
18+
use std::finally::Finally;
1919
use std::str;
2020

2121
#[start]

src/test/run-pass/simd-binop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#![allow(experimental)]
1212

13-
use std::unstable::simd::{i32x4, f32x4, u32x4};
13+
use std::simd::{i32x4, f32x4, u32x4};
1414

1515
fn eq_u32x4(u32x4(x0, x1, x2, x3): u32x4, u32x4(y0, y1, y2, y3): u32x4) -> bool {
1616
(x0 == y0) && (x1 == y1) && (x2 == y2) && (x3 == y3)

src/test/run-pass/simd-issue-10604.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@
1313
#![feature(simd)]
1414

1515
pub fn main() {
16-
let _o = None::<std::unstable::simd::i32x4>;
16+
let _o = None::<std::simd::i32x4>;
1717
}

0 commit comments

Comments
 (0)