Skip to content

Commit a91d1a1

Browse files
committed
---
yaml --- r: 233487 b: refs/heads/beta c: d792925 h: refs/heads/master i: 233485: 0bd627f 233483: 5f6e382 233479: c74a3c5 233471: 1bfa0b2 v: v3
1 parent e4a8ec8 commit a91d1a1

File tree

4 files changed

+57
-17
lines changed

4 files changed

+57
-17
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
2323
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
2424
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26-
refs/heads/beta: 62ba85b7aaf4ac1dbbf8b89605ff24d40f93969f
26+
refs/heads/beta: d792925b4d838ca6d15c2d86b0e3dc85f6a393fe
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
2828
refs/heads/tmp: 370fe2786109360f7c35b8ba552b83b773dd71d6
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/beta/src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
#![feature(reflect)]
8080
#![feature(rustc_attrs)]
8181
#![cfg_attr(stage0, feature(simd))]
82-
#![cfg_attr(not(stage0), feature(repr_simd))]
82+
#![cfg_attr(not(stage0), feature(repr_simd, platform_intrinsics))]
8383
#![feature(staged_api)]
8484
#![feature(unboxed_closures)]
8585

branches/beta/src/libcore/simd.rs

Lines changed: 54 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,12 @@
1010

1111
//! SIMD vectors.
1212
//!
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
13+
//! These types can be used for accessing basic SIMD operations. Currently
1614
//! comparison operators are not implemented. To use SSE3+, you must enable
1715
//! the features, like `-C target-feature=sse3,sse4.1,sse4.2`, or a more
1816
//! specific `target-cpu`. No other SIMD intrinsics or high-level wrappers are
1917
//! provided beyond this module.
2018
//!
21-
//! ```rust
22-
//! #![feature(core_simd)]
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-
//!
3219
//! # Stability Note
3320
//!
3421
//! These are all experimental. The interface may change entirely, without
@@ -44,6 +31,30 @@
4431
#![allow(missing_docs)]
4532
#![allow(deprecated)]
4633

34+
use ops::{Add, Sub, Mul, Div, Shl, Shr, BitAnd, BitOr, BitXor};
35+
36+
// FIXME(stage0): the contents of macro can be inlined.
37+
// ABIs are verified as valid as soon as they are parsed, i.e. before
38+
// `cfg` stripping. The `platform-intrinsic` ABI is new, so stage0
39+
// doesn't know about it, but it still errors out when it hits it
40+
// (despite this being in a `cfg(not(stage0))` module).
41+
macro_rules! argh {
42+
() => {
43+
extern "platform-intrinsic" {
44+
fn simd_add<T>(x: T, y: T) -> T;
45+
fn simd_sub<T>(x: T, y: T) -> T;
46+
fn simd_mul<T>(x: T, y: T) -> T;
47+
fn simd_div<T>(x: T, y: T) -> T;
48+
fn simd_shl<T>(x: T, y: T) -> T;
49+
fn simd_shr<T>(x: T, y: T) -> T;
50+
fn simd_and<T>(x: T, y: T) -> T;
51+
fn simd_or<T>(x: T, y: T) -> T;
52+
fn simd_xor<T>(x: T, y: T) -> T;
53+
}
54+
}
55+
}
56+
argh!();
57+
4758
#[repr(simd)]
4859
#[derive(Copy, Clone, Debug)]
4960
#[repr(C)]
@@ -101,3 +112,32 @@ pub struct f32x4(pub f32, pub f32, pub f32, pub f32);
101112
#[derive(Copy, Clone, Debug)]
102113
#[repr(C)]
103114
pub struct f64x2(pub f64, pub f64);
115+
116+
macro_rules! impl_traits {
117+
($($trayt: ident, $method: ident, $func: ident: $($ty: ty),*;)*) => {
118+
$($(
119+
impl $trayt<$ty> for $ty {
120+
type Output = Self;
121+
fn $method(self, other: Self) -> Self {
122+
unsafe {
123+
$func(self, other)
124+
}
125+
}
126+
}
127+
)*)*
128+
}
129+
}
130+
131+
impl_traits! {
132+
Add, add, simd_add: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2;
133+
Sub, sub, simd_sub: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2;
134+
Mul, mul, simd_mul: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2, f32x4, f64x2;
135+
136+
Div, div, simd_div: f32x4, f64x2;
137+
138+
Shl, shl, simd_shl: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
139+
Shr, shr, simd_shr: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
140+
BitAnd, bitand, simd_and: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
141+
BitOr, bitor, simd_or: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
142+
BitXor, bitxor, simd_xor: u8x16, u16x8, u32x4, u64x2, i8x16, i16x8, i32x4, i64x2;
143+
}

branches/beta/src/test/bench/shootout-spectralnorm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn mult<F>(v: &[f64], out: &mut [f64], start: usize, a: F)
9191
for (j, chunk) in v.chunks(2).enumerate().map(|(j, s)| (2 * j, s)) {
9292
let top = f64x2(chunk[0], chunk[1]);
9393
let bot = f64x2(a(i, j), a(i, j + 1));
94-
sum += top / bot;
94+
sum = sum + top / bot;
9595
}
9696
let f64x2(a, b) = sum;
9797
*slot = a + b;

0 commit comments

Comments
 (0)