Skip to content

Feature gate #[simd] #11738

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

Merged
merged 1 commit into from
Jan 28, 2014
Merged
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
8 changes: 8 additions & 0 deletions src/librustc/front/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static KNOWN_FEATURES: &'static [(&'static str, Status)] = &[
("macro_registrar", Active),
("log_syntax", Active),
("trace_macros", Active),
("simd", Active),

// These are used to test this portion of the compiler, they don't actually
// mean anything
Expand Down Expand Up @@ -171,6 +172,13 @@ impl Visitor<()> for Context {
}
}

ast::ItemStruct(..) => {
if attr::contains_name(i.attrs, "simd") {
self.gate_feature("simd", i.span,
"SIMD types are experimental and possibly buggy");
}
}

_ => {}
}

Expand Down
3 changes: 2 additions & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,14 @@
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)];
#[feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args, simd)];

// Don't link to std. We are std.
#[no_std];

#[deny(non_camel_case_types)];
#[deny(missing_doc)];
#[allow(unknown_features)];

// When testing libstd, bring in libuv as the I/O backend so tests can print
// things and all of the std::io tests have an I/O interface to run on top
Expand Down
10 changes: 10 additions & 0 deletions src/libstd/unstable/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,42 @@
#[allow(non_camel_case_types)];

#[experimental]
#[simd]
pub struct i8x16(i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8, i8);

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

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

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

#[experimental]
#[simd]
pub struct u8x16(u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8, u8);

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

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

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

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

#[experimental]
#[simd]
pub struct f64x2(f64, f64);
14 changes: 14 additions & 0 deletions src/test/compile-fail/gated-simd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// 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.
//
// 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]
pub struct i64x2(i64, i64); //~ ERROR: SIMD types are experimental

fn main() {}
19 changes: 19 additions & 0 deletions src/test/compile-fail/simd-experimental.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// 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.
//
// 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.

// xfail-test FIXME #11741 tuple structs ignore stability attributes

#[deny(experimental)];

use std::unstable::simd;

fn main() {
let _ = simd::i64x2(0, 0); //~ ERROR: experimental
}
2 changes: 2 additions & 0 deletions src/test/compile-fail/simd-type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#[feature(simd)];

#[simd]
struct vec4<T>(T, T, T, T); //~ ERROR SIMD vector cannot be generic

Expand Down
2 changes: 2 additions & 0 deletions src/test/run-pass/simd-binop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#[allow(experimental)];

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

fn test_int(e: i32) -> i32 {
Expand Down
4 changes: 4 additions & 0 deletions src/test/run-pass/simd-type.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// xfail-fast feature doesn't work

#[feature(simd)];

#[simd]
struct RGBA {
r: f32,
Expand Down