implement a bunch of intrinsics
This commit is contained in:
parent
e406099348
commit
1e0d5b817d
2 changed files with 47 additions and 0 deletions
|
@ -69,6 +69,26 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||
self.write_value_to_ptr(arg_vals[1], dest, ty)?;
|
||||
}
|
||||
|
||||
"atomic_fence_acq" => {
|
||||
// we are inherently singlethreaded and singlecored, this is a nop
|
||||
}
|
||||
|
||||
"atomic_xsub_rel" => {
|
||||
let ty = substs.type_at(0);
|
||||
let ptr = arg_vals[0].read_ptr(&self.memory)?;
|
||||
let change = self.value_to_primval(arg_vals[1], ty)?;
|
||||
let old = self.read_value(ptr, ty)?;
|
||||
let old = match old {
|
||||
Value::ByVal(val) => val,
|
||||
Value::ByRef(_) => bug!("just read the value, can't be byref"),
|
||||
Value::ByValPair(..) => bug!("atomic_xsub_rel doesn't work with nonprimitives"),
|
||||
};
|
||||
self.write_primval(dest, old)?;
|
||||
// FIXME: what do atomics do on overflow?
|
||||
let (val, _) = primval::binary_op(mir::BinOp::Sub, old, change)?;
|
||||
self.write_primval(Lvalue::from_ptr(ptr), val)?;
|
||||
}
|
||||
|
||||
"breakpoint" => unimplemented!(), // halt miri
|
||||
|
||||
"copy" |
|
||||
|
@ -101,6 +121,14 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||
self.write_primval(dest, PrimVal::new(discr_val, PrimValKind::U64))?;
|
||||
}
|
||||
|
||||
"drop_in_place" => {
|
||||
let ty = substs.type_at(0);
|
||||
let ptr = arg_vals[0].read_ptr(&self.memory)?;
|
||||
let mut drops = Vec::new();
|
||||
self.drop(Lvalue::from_ptr(ptr), ty, &mut drops)?;
|
||||
self.eval_drop_impls(drops)?;
|
||||
}
|
||||
|
||||
"fabsf32" => {
|
||||
let f = self.value_to_primval(arg_vals[2], f32)?
|
||||
.expect_f32("fabsf32 read non f32");
|
||||
|
@ -248,6 +276,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||
let size_val = self.usize_primval(size);
|
||||
self.write_primval(dest, size_val)?;
|
||||
}
|
||||
|
||||
"min_align_of_val" |
|
||||
"align_of_val" => {
|
||||
let ty = substs.type_at(0);
|
||||
let (_, align) = self.size_and_align_of_dst(ty, arg_vals[0])?;
|
||||
let align_val = self.usize_primval(align);
|
||||
self.write_primval(dest, align_val)?;
|
||||
}
|
||||
|
||||
"type_name" => {
|
||||
let ty = substs.type_at(0);
|
||||
let ty_name = ty.to_string();
|
||||
|
|
|
@ -291,6 +291,16 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
|||
self.write_primval(dest, PrimVal::from_ptr(ptr))?;
|
||||
}
|
||||
|
||||
"__rust_deallocate" => {
|
||||
let ptr = args[0].read_ptr(&self.memory)?;
|
||||
// FIXME: insert sanity check for size and align?
|
||||
let _old_size = self.value_to_primval(args[1], usize)?
|
||||
.expect_uint("__rust_deallocate second arg not usize");
|
||||
let _align = self.value_to_primval(args[2], usize)?
|
||||
.expect_uint("__rust_deallocate third arg not usize");
|
||||
self.memory.deallocate(ptr)?;
|
||||
},
|
||||
|
||||
"__rust_reallocate" => {
|
||||
let ptr = args[0].read_ptr(&self.memory)?;
|
||||
let size = self.value_to_primval(args[2], usize)?.expect_uint("__rust_reallocate third arg not usize");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue