|
| 1 | +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT |
| 2 | +// file at the top-level directory of this distribution and at |
| 3 | +// http://rust-lang.org/COPYRIGHT. |
| 4 | +// |
| 5 | +// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 6 | +// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 7 | +// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 8 | +// option. This file may not be copied, modified, or distributed |
| 9 | +// except according to those terms. |
| 10 | + |
| 11 | +#![feature(simd)] |
| 12 | +#![allow(non_camel_case_types)] |
| 13 | + |
| 14 | +use std::mem; |
| 15 | + |
| 16 | +/// `T` should satisfy `size_of T (mod min_align_of T) === 0` to be stored at `Vec<T>` properly |
| 17 | +/// Please consult the issue #20460 |
| 18 | +fn check<T>() { |
| 19 | + assert_eq!(mem::size_of::<T>() % mem::min_align_of::<T>(), 0) |
| 20 | +} |
| 21 | + |
| 22 | +fn main() { |
| 23 | + check::<u8x2>(); |
| 24 | + check::<u8x3>(); |
| 25 | + check::<u8x4>(); |
| 26 | + check::<u8x5>(); |
| 27 | + check::<u8x6>(); |
| 28 | + check::<u8x7>(); |
| 29 | + check::<u8x8>(); |
| 30 | + |
| 31 | + check::<i16x2>(); |
| 32 | + check::<i16x3>(); |
| 33 | + check::<i16x4>(); |
| 34 | + check::<i16x5>(); |
| 35 | + check::<i16x6>(); |
| 36 | + check::<i16x7>(); |
| 37 | + check::<i16x8>(); |
| 38 | + |
| 39 | + check::<f32x2>(); |
| 40 | + check::<f32x3>(); |
| 41 | + check::<f32x4>(); |
| 42 | + check::<f32x5>(); |
| 43 | + check::<f32x6>(); |
| 44 | + check::<f32x7>(); |
| 45 | + check::<f32x8>(); |
| 46 | +} |
| 47 | + |
| 48 | +#[simd] struct u8x2(u8, u8); |
| 49 | +#[simd] struct u8x3(u8, u8, u8); |
| 50 | +#[simd] struct u8x4(u8, u8, u8, u8); |
| 51 | +#[simd] struct u8x5(u8, u8, u8, u8, u8); |
| 52 | +#[simd] struct u8x6(u8, u8, u8, u8, u8, u8); |
| 53 | +#[simd] struct u8x7(u8, u8, u8, u8, u8, u8, u8); |
| 54 | +#[simd] struct u8x8(u8, u8, u8, u8, u8, u8, u8, u8); |
| 55 | + |
| 56 | +#[simd] struct i16x2(i16, i16); |
| 57 | +#[simd] struct i16x3(i16, i16, i16); |
| 58 | +#[simd] struct i16x4(i16, i16, i16, i16); |
| 59 | +#[simd] struct i16x5(i16, i16, i16, i16, i16); |
| 60 | +#[simd] struct i16x6(i16, i16, i16, i16, i16, i16); |
| 61 | +#[simd] struct i16x7(i16, i16, i16, i16, i16, i16, i16); |
| 62 | +#[simd] struct i16x8(i16, i16, i16, i16, i16, i16, i16, i16); |
| 63 | + |
| 64 | +#[simd] struct f32x2(f32, f32); |
| 65 | +#[simd] struct f32x3(f32, f32, f32); |
| 66 | +#[simd] struct f32x4(f32, f32, f32, f32); |
| 67 | +#[simd] struct f32x5(f32, f32, f32, f32, f32); |
| 68 | +#[simd] struct f32x6(f32, f32, f32, f32, f32, f32); |
| 69 | +#[simd] struct f32x7(f32, f32, f32, f32, f32, f32, f32); |
| 70 | +#[simd] struct f32x8(f32, f32, f32, f32, f32, f32, f32, f32); |
0 commit comments