]> git.lizzy.rs Git - rust.git/commitdiff
Fix some things
authorbjorn3 <bjorn3@users.noreply.github.com>
Mon, 17 Jun 2019 19:13:02 +0000 (21:13 +0200)
committerbjorn3 <bjorn3@users.noreply.github.com>
Fri, 26 Jul 2019 09:28:04 +0000 (11:28 +0200)
src/common.rs
src/value_and_place.rs

index 30f343d02b25a786c8e8f03bf85925f48b2ac42e..810744527f94abd47b48cf5e825a1c33faac4c19 100644 (file)
@@ -88,6 +88,9 @@ pub fn clif_intcast<'a, 'tcx: 'a>(
         } else {
             fx.bcx.ins().uextend(to, val)
         }
+    } else if from == types::I128 {
+        let (lsb, msb) = fx.bcx.ins().isplit(val);
+        fx.bcx.ins().ireduce(to, lsb)
     } else {
         fx.bcx.ins().ireduce(to, val)
     }
index 6bd82265bc1b344674e91bb36666a4e5c3471400..3589d770572406176ef81cc3b19b71195e05c36d 100644 (file)
@@ -44,6 +44,21 @@ fn store_scalar<'a, 'tcx: 'a>(fx: &mut FunctionCx<'a, 'tcx, impl Backend>, value
     }
 }
 
+fn load_scalar<'a, 'tcx: 'a>(
+    fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
+    clif_ty: Type,
+    addr: Value,
+    offset: i32,
+) -> Value {
+    if clif_ty == types::I128 {
+        let a = fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset);
+        let b = fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset + 8);
+        fx.bcx.ins().iconcat(a, b)
+    } else {
+        fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, offset)
+    }
+}
+
 impl<'tcx> CValue<'tcx> {
     pub fn by_ref(value: Value, layout: TyLayout<'tcx>) -> CValue<'tcx> {
         CValue(CValueInner::ByRef(value), layout)
@@ -89,7 +104,7 @@ pub fn load_scalar<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -> Val
                     _ => unreachable!(),
                 };
                 let clif_ty = scalar_to_clif_type(fx.tcx, scalar);
-                fx.bcx.ins().load(clif_ty, MemFlags::new(), addr, 0)
+                load_scalar(fx, clif_ty, addr, 0)
             }
             CValueInner::ByVal(value) => value,
             CValueInner::ByValPair(_, _) => bug!("Please use load_scalar_pair for ByValPair"),
@@ -111,10 +126,10 @@ pub fn load_scalar_pair<'a>(self, fx: &mut FunctionCx<'a, 'tcx, impl Backend>) -
                 let b_offset = scalar_pair_calculate_b_offset(fx.tcx, a_scalar, b_scalar);
                 let clif_ty1 = scalar_to_clif_type(fx.tcx, a_scalar.clone());
                 let clif_ty2 = scalar_to_clif_type(fx.tcx, b_scalar.clone());
-                let val1 = fx.bcx.ins().load(clif_ty1, MemFlags::new(), addr, 0);
-                let val2 = fx.bcx.ins().load(
+                let val1 = load_scalar(fx, clif_ty1, addr, 0);
+                let val2 = load_scalar(
+                    fx,
                     clif_ty2,
-                    MemFlags::new(),
                     addr,
                     b_offset,
                 );