atomic_op → atomic_rmw_op
This commit is contained in:
parent
6212cc6907
commit
0b6c30a865
@ -558,8 +558,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
|
|||||||
this.buffered_atomic_write(val, dest, atomic, val)
|
this.buffered_atomic_write(val, dest, atomic, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform an atomic operation on a memory location.
|
/// Perform an atomic RMW operation on a memory location.
|
||||||
fn atomic_op_immediate(
|
fn atomic_rmw_op_immediate(
|
||||||
&mut self,
|
&mut self,
|
||||||
place: &MPlaceTy<'tcx, Provenance>,
|
place: &MPlaceTy<'tcx, Provenance>,
|
||||||
rhs: &ImmTy<'tcx, Provenance>,
|
rhs: &ImmTy<'tcx, Provenance>,
|
||||||
|
@ -77,40 +77,40 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
|
|||||||
this.atomic_compare_exchange_weak(args, dest, rw_ord(ord1)?, read_ord(ord2)?)?,
|
this.atomic_compare_exchange_weak(args, dest, rw_ord(ord1)?, read_ord(ord2)?)?,
|
||||||
|
|
||||||
["or", ord] =>
|
["or", ord] =>
|
||||||
this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), rw_ord(ord)?)?,
|
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitOr, false), rw_ord(ord)?)?,
|
||||||
["xor", ord] =>
|
["xor", ord] =>
|
||||||
this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), rw_ord(ord)?)?,
|
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitXor, false), rw_ord(ord)?)?,
|
||||||
["and", ord] =>
|
["and", ord] =>
|
||||||
this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), rw_ord(ord)?)?,
|
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, false), rw_ord(ord)?)?,
|
||||||
["nand", ord] =>
|
["nand", ord] =>
|
||||||
this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), rw_ord(ord)?)?,
|
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::BitAnd, true), rw_ord(ord)?)?,
|
||||||
["xadd", ord] =>
|
["xadd", ord] =>
|
||||||
this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), rw_ord(ord)?)?,
|
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Add, false), rw_ord(ord)?)?,
|
||||||
["xsub", ord] =>
|
["xsub", ord] =>
|
||||||
this.atomic_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), rw_ord(ord)?)?,
|
this.atomic_rmw_op(args, dest, AtomicOp::MirOp(BinOp::Sub, false), rw_ord(ord)?)?,
|
||||||
["min", ord] => {
|
["min", ord] => {
|
||||||
// Later we will use the type to indicate signed vs unsigned,
|
// Later we will use the type to indicate signed vs unsigned,
|
||||||
// so make sure it matches the intrinsic name.
|
// so make sure it matches the intrinsic name.
|
||||||
assert!(matches!(args[1].layout.ty.kind(), ty::Int(_)));
|
assert!(matches!(args[1].layout.ty.kind(), ty::Int(_)));
|
||||||
this.atomic_op(args, dest, AtomicOp::Min, rw_ord(ord)?)?;
|
this.atomic_rmw_op(args, dest, AtomicOp::Min, rw_ord(ord)?)?;
|
||||||
}
|
}
|
||||||
["umin", ord] => {
|
["umin", ord] => {
|
||||||
// Later we will use the type to indicate signed vs unsigned,
|
// Later we will use the type to indicate signed vs unsigned,
|
||||||
// so make sure it matches the intrinsic name.
|
// so make sure it matches the intrinsic name.
|
||||||
assert!(matches!(args[1].layout.ty.kind(), ty::Uint(_)));
|
assert!(matches!(args[1].layout.ty.kind(), ty::Uint(_)));
|
||||||
this.atomic_op(args, dest, AtomicOp::Min, rw_ord(ord)?)?;
|
this.atomic_rmw_op(args, dest, AtomicOp::Min, rw_ord(ord)?)?;
|
||||||
}
|
}
|
||||||
["max", ord] => {
|
["max", ord] => {
|
||||||
// Later we will use the type to indicate signed vs unsigned,
|
// Later we will use the type to indicate signed vs unsigned,
|
||||||
// so make sure it matches the intrinsic name.
|
// so make sure it matches the intrinsic name.
|
||||||
assert!(matches!(args[1].layout.ty.kind(), ty::Int(_)));
|
assert!(matches!(args[1].layout.ty.kind(), ty::Int(_)));
|
||||||
this.atomic_op(args, dest, AtomicOp::Max, rw_ord(ord)?)?;
|
this.atomic_rmw_op(args, dest, AtomicOp::Max, rw_ord(ord)?)?;
|
||||||
}
|
}
|
||||||
["umax", ord] => {
|
["umax", ord] => {
|
||||||
// Later we will use the type to indicate signed vs unsigned,
|
// Later we will use the type to indicate signed vs unsigned,
|
||||||
// so make sure it matches the intrinsic name.
|
// so make sure it matches the intrinsic name.
|
||||||
assert!(matches!(args[1].layout.ty.kind(), ty::Uint(_)));
|
assert!(matches!(args[1].layout.ty.kind(), ty::Uint(_)));
|
||||||
this.atomic_op(args, dest, AtomicOp::Max, rw_ord(ord)?)?;
|
this.atomic_rmw_op(args, dest, AtomicOp::Max, rw_ord(ord)?)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
_ => throw_unsup_format!("unimplemented intrinsic: `atomic_{intrinsic_name}`"),
|
_ => throw_unsup_format!("unimplemented intrinsic: `atomic_{intrinsic_name}`"),
|
||||||
@ -178,7 +178,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn atomic_op(
|
fn atomic_rmw_op(
|
||||||
&mut self,
|
&mut self,
|
||||||
args: &[OpTy<'tcx, Provenance>],
|
args: &[OpTy<'tcx, Provenance>],
|
||||||
dest: &PlaceTy<'tcx, Provenance>,
|
dest: &PlaceTy<'tcx, Provenance>,
|
||||||
@ -213,7 +213,7 @@ trait EvalContextPrivExt<'mir, 'tcx: 'mir>: MiriInterpCxExt<'mir, 'tcx> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
AtomicOp::MirOp(op, neg) => {
|
AtomicOp::MirOp(op, neg) => {
|
||||||
let old = this.atomic_op_immediate(&place, &rhs, op, neg, atomic)?;
|
let old = this.atomic_rmw_op_immediate(&place, &rhs, op, neg, atomic)?;
|
||||||
this.write_immediate(*old, dest)?; // old value is returned
|
this.write_immediate(*old, dest)?; // old value is returned
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user