]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_trans/mir/operand.rs
New upstream version 1.14.0+dfsg1
[rustc.git] / src / librustc_trans / mir / operand.rs
index 270033be9375c20029f763de31b8da3816bc930d..62eda56e2e1ba33c1bfd01f6651945227a9850ec 100644 (file)
@@ -10,7 +10,7 @@
 
 use llvm::ValueRef;
 use rustc::ty::Ty;
-use rustc::mir::repr as mir;
+use rustc::mir;
 use rustc_data_structures::indexed_vec::Idx;
 
 use base;
@@ -143,20 +143,18 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
     {
         debug!("trans_load: {:?} @ {:?}", Value(llval), ty);
 
-        let val = if common::type_is_imm_pair(bcx.ccx(), ty) {
+        let val = if common::type_is_fat_ptr(bcx.tcx(), ty) {
+            let (lldata, llextra) = base::load_fat_ptr_builder(bcx, llval, ty);
+            OperandValue::Pair(lldata, llextra)
+        } else if common::type_is_imm_pair(bcx.ccx(), ty) {
+            let [a_ty, b_ty] = common::type_pair_fields(bcx.ccx(), ty).unwrap();
             let a_ptr = bcx.struct_gep(llval, 0);
             let b_ptr = bcx.struct_gep(llval, 1);
 
-            // This is None only for fat pointers, which don't
-            // need any special load-time behavior anyway.
-            let pair_fields = common::type_pair_fields(bcx.ccx(), ty);
-            let (a, b) = if let Some([a_ty, b_ty]) = pair_fields {
-                (base::load_ty_builder(bcx, a_ptr, a_ty),
-                 base::load_ty_builder(bcx, b_ptr, b_ty))
-            } else {
-                (bcx.load(a_ptr), bcx.load(b_ptr))
-            };
-            OperandValue::Pair(a, b)
+            OperandValue::Pair(
+                base::load_ty_builder(bcx, a_ptr, a_ty),
+                base::load_ty_builder(bcx, b_ptr, b_ty)
+            )
         } else if common::type_is_immediate(bcx.ccx(), ty) {
             OperandValue::Immediate(base::load_ty_builder(bcx, llval, ty))
         } else {
@@ -175,7 +173,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
 
         // watch out for locals that do not have an
         // alloca; they are handled somewhat differently
-        if let Some(index) = self.mir.local_index(lvalue) {
+        if let mir::Lvalue::Local(index) = *lvalue {
             match self.locals[index] {
                 LocalRef::Operand(Some(o)) => {
                     return o;
@@ -191,7 +189,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
 
         // Moves out of pair fields are trivial.
         if let &mir::Lvalue::Projection(ref proj) = lvalue {
-            if let Some(index) = self.mir.local_index(&proj.base) {
+            if let mir::Lvalue::Local(index) = proj.base {
                 if let LocalRef::Operand(Some(o)) = self.locals[index] {
                     match (o.val, &proj.elem) {
                         (OperandValue::Pair(a, b),