use std::container::Map;
use std::libc::c_ulonglong;
use std::option::{Option, Some, None};
+use std::num::{Bitwise};
use lib::llvm::{ValueRef, True, IntEQ, IntNE};
use middle::trans::_match;
let align = most_aligned.align;
let discr_ty = ll_inttype(cx, ity);
let discr_size = machine::llsize_of_alloc(cx, discr_ty) as u64;
+ let align_units = (size + align - 1) / align - 1;
let pad_ty = match align {
- 1 => Type::i8(),
- 2 => Type::i16(),
- 4 => Type::i32(),
- 8 if machine::llalign_of_min(cx, Type::i64()) == 8 => Type::i64(),
+ 1 => Type::array(&Type::i8(), align_units),
+ 2 => Type::array(&Type::i16(), align_units),
+ 4 => Type::array(&Type::i32(), align_units),
+ 8 if machine::llalign_of_min(cx, Type::i64()) == 8 =>
+ Type::array(&Type::i64(), align_units),
+ a if a.population_count() == 1 => Type::array(&Type::vector(&Type::i32(), a / 4),
+ align_units),
_ => fail!("Unsupported enum alignment: {:?}", align)
};
assert_eq!(machine::llalign_of_min(cx, pad_ty) as u64, align);
- let align_units = (size + align - 1) / align;
assert_eq!(align % discr_size, 0);
let fields = ~[discr_ty,
- Type::array(&discr_ty, align / discr_size - 1),
- Type::array(&pad_ty, align_units - 1)];
+ Type::array(&discr_ty, align / discr_size - 1),
+ pad_ty];
match name {
None => Type::struct_(fields, false),
Some(name) => {
--- /dev/null
+// 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.
+
+use std::ops;
+
+#[simd] struct f32x4(f32, f32, f32, f32);
+
+fn add<T: ops::Add<T, T>>(lhs: T, rhs: T) -> T {
+ lhs + rhs
+}
+
+impl ops::Add<f32x4, f32x4> for f32x4 {
+ fn add(&self, rhs: &f32x4) -> f32x4 {
+ *self + *rhs
+ }
+}
+
+fn main() {
+ let lr = f32x4(1.0f32, 2.0f32, 3.0f32, 4.0f32);
+
+ // lame-o
+ let f32x4(x, y, z, w) = add(lr, lr);
+ assert_eq!(x, 2.0f32);
+ assert_eq!(y, 4.0f32);
+ assert_eq!(z, 6.0f32);
+ assert_eq!(w, 8.0f32);
+}
--- /dev/null
+// 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.
+
+fn main() {
+ let _o = None::<std::unstable::simd::i32x4>;
+}