]> git.lizzy.rs Git - rust.git/commitdiff
`align_offset` intrinsic is now a lang item
authorOliver Schneider <github35764891676564198441@oli-obk.de>
Wed, 30 May 2018 15:43:27 +0000 (17:43 +0200)
committerOliver Schneider <github35764891676564198441@oli-obk.de>
Sun, 3 Jun 2018 11:08:51 +0000 (13:08 +0200)
src/fn_call.rs
src/intrinsic.rs

index d1a483d2e80437d28e20f04017b68154a0eaf200..fdaa819c08f7ad456a4cc0ed51d1560524e79a94 100644 (file)
@@ -135,6 +135,18 @@ fn eval_fn_call(
             _ => {}
         }
 
+        if self.tcx.lang_items().align_offset_fn() == Some(instance.def.def_id()) {
+            // FIXME: return a real value in case the target allocation has an
+            // alignment bigger than the one requested
+            let n = u128::max_value();
+            let amt = 128 - self.memory.pointer_size().bytes() * 8;
+            let (dest, return_to_block) = destination.unwrap();
+            let ty = self.tcx.types.usize;
+            self.write_scalar(dest, Scalar::from_u128((n << amt) >> amt), ty)?;
+            self.goto_block(return_to_block);
+            return Ok(true);
+        }
+
         let mir = match self.load_mir(instance.def) {
             Ok(mir) => mir,
             Err(EvalError { kind: EvalErrorKind::NoMirFor(path), .. }) => {
index 1e8090dc1897624284a7b22d00107668a5042429..cee2f1ab7682fb9e0cc7e71ffa76f7a51dce2966 100644 (file)
@@ -33,14 +33,6 @@ fn call_intrinsic(
 
         let intrinsic_name = &self.tcx.item_name(instance.def_id()).as_str()[..];
         match intrinsic_name {
-            "align_offset" => {
-                // FIXME: return a real value in case the target allocation has an
-                // alignment bigger than the one requested
-                let n = u128::max_value();
-                let amt = 128 - self.memory.pointer_size().bytes() * 8;
-                self.write_scalar(dest, Scalar::from_u128((n << amt) >> amt), dest_layout.ty)?;
-            },
-
             "add_with_overflow" => {
                 self.intrinsic_with_overflow(
                     mir::BinOp::Add,