mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 05:26:23 +03:00
align_offset intrinsic is now a lang item
This commit is contained in:
@@ -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), .. }) => {
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user