atomic intrinsics: clarify which types are supported and (if applicable) what happens with provenance
This commit is contained in:
parent
8536f201ff
commit
88b206d582
3 changed files with 190 additions and 9 deletions
|
@ -1031,7 +1031,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||
|
||||
let layout = src.layout();
|
||||
match layout.ty.kind() {
|
||||
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
|
||||
ty::Int(_) => {}
|
||||
_ => {
|
||||
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
|
||||
return Ok(());
|
||||
|
@ -1052,7 +1052,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||
|
||||
let layout = src.layout();
|
||||
match layout.ty.kind() {
|
||||
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
|
||||
ty::Uint(_) => {}
|
||||
_ => {
|
||||
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
|
||||
return Ok(());
|
||||
|
@ -1073,7 +1073,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||
|
||||
let layout = src.layout();
|
||||
match layout.ty.kind() {
|
||||
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
|
||||
ty::Int(_) => {}
|
||||
_ => {
|
||||
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
|
||||
return Ok(());
|
||||
|
@ -1094,7 +1094,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
|
|||
|
||||
let layout = src.layout();
|
||||
match layout.ty.kind() {
|
||||
ty::Uint(_) | ty::Int(_) | ty::RawPtr(..) => {}
|
||||
ty::Uint(_) => {}
|
||||
_ => {
|
||||
report_atomic_type_validation_error(fx, intrinsic, source_info.span, layout.ty);
|
||||
return Ok(());
|
||||
|
|
|
@ -441,6 +441,40 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
}
|
||||
|
||||
// These are all AtomicRMW ops
|
||||
"max" | "min" => {
|
||||
let atom_op = if instruction == "max" {
|
||||
AtomicRmwBinOp::AtomicMax
|
||||
} else {
|
||||
AtomicRmwBinOp::AtomicMin
|
||||
};
|
||||
|
||||
let ty = fn_args.type_at(0);
|
||||
if matches!(ty.kind(), ty::Int(_)) {
|
||||
let ptr = args[0].immediate();
|
||||
let val = args[1].immediate();
|
||||
bx.atomic_rmw(atom_op, ptr, val, parse_ordering(bx, ordering))
|
||||
} else {
|
||||
invalid_monomorphization(ty);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
"umax" | "umin" => {
|
||||
let atom_op = if instruction == "umax" {
|
||||
AtomicRmwBinOp::AtomicUMax
|
||||
} else {
|
||||
AtomicRmwBinOp::AtomicUMin
|
||||
};
|
||||
|
||||
let ty = fn_args.type_at(0);
|
||||
if matches!(ty.kind(), ty::Uint(_)) {
|
||||
let ptr = args[0].immediate();
|
||||
let val = args[1].immediate();
|
||||
bx.atomic_rmw(atom_op, ptr, val, parse_ordering(bx, ordering))
|
||||
} else {
|
||||
invalid_monomorphization(ty);
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
op => {
|
||||
let atom_op = match op {
|
||||
"xchg" => AtomicRmwBinOp::AtomicXchg,
|
||||
|
@ -450,10 +484,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
"nand" => AtomicRmwBinOp::AtomicNand,
|
||||
"or" => AtomicRmwBinOp::AtomicOr,
|
||||
"xor" => AtomicRmwBinOp::AtomicXor,
|
||||
"max" => AtomicRmwBinOp::AtomicMax,
|
||||
"min" => AtomicRmwBinOp::AtomicMin,
|
||||
"umax" => AtomicRmwBinOp::AtomicUMax,
|
||||
"umin" => AtomicRmwBinOp::AtomicUMin,
|
||||
_ => bx.sess().dcx().emit_fatal(errors::UnknownAtomicOperation),
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue