mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
Auto merge of #97369 - tmiasko:codgen-ssa-atomic-ordering, r=michaelwoerister
rustc_codegen_ssa: cleanup `AtomicOrdering` * Remove unused `NotAtomic` ordering. * Rename `Monotonic` to `Relaxed` - a Rust specific name. * Derive copy and clone.
This commit is contained in:
commit
99c4758747
@ -61,24 +61,6 @@ enum ExtremumOperation {
|
|||||||
Min,
|
Min,
|
||||||
}
|
}
|
||||||
|
|
||||||
trait EnumClone {
|
|
||||||
fn clone(&self) -> Self;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl EnumClone for AtomicOrdering {
|
|
||||||
fn clone(&self) -> Self {
|
|
||||||
match *self {
|
|
||||||
AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
|
|
||||||
AtomicOrdering::Unordered => AtomicOrdering::Unordered,
|
|
||||||
AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
|
|
||||||
AtomicOrdering::Acquire => AtomicOrdering::Acquire,
|
|
||||||
AtomicOrdering::Release => AtomicOrdering::Release,
|
|
||||||
AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease,
|
|
||||||
AtomicOrdering::SequentiallyConsistent => AtomicOrdering::SequentiallyConsistent,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Builder<'a: 'gcc, 'gcc, 'tcx> {
|
pub struct Builder<'a: 'gcc, 'gcc, 'tcx> {
|
||||||
pub cx: &'a CodegenCx<'gcc, 'tcx>,
|
pub cx: &'a CodegenCx<'gcc, 'tcx>,
|
||||||
pub block: Block<'gcc>,
|
pub block: Block<'gcc>,
|
||||||
@ -103,9 +85,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
|
|||||||
match order {
|
match order {
|
||||||
// TODO(antoyo): does this make sense?
|
// TODO(antoyo): does this make sense?
|
||||||
AtomicOrdering::AcquireRelease | AtomicOrdering::Release => AtomicOrdering::Acquire,
|
AtomicOrdering::AcquireRelease | AtomicOrdering::Release => AtomicOrdering::Acquire,
|
||||||
_ => order.clone(),
|
_ => order,
|
||||||
};
|
};
|
||||||
let previous_value = self.atomic_load(dst.get_type(), dst, load_ordering.clone(), Size::from_bytes(size));
|
let previous_value = self.atomic_load(dst.get_type(), dst, load_ordering, Size::from_bytes(size));
|
||||||
let previous_var = func.new_local(None, previous_value.get_type(), "previous_value");
|
let previous_var = func.new_local(None, previous_value.get_type(), "previous_value");
|
||||||
let return_value = func.new_local(None, previous_value.get_type(), "return_value");
|
let return_value = func.new_local(None, previous_value.get_type(), "return_value");
|
||||||
self.llbb().add_assignment(None, previous_var, previous_value);
|
self.llbb().add_assignment(None, previous_var, previous_value);
|
||||||
@ -1384,9 +1366,8 @@ impl ToGccOrdering for AtomicOrdering {
|
|||||||
|
|
||||||
let ordering =
|
let ordering =
|
||||||
match self {
|
match self {
|
||||||
AtomicOrdering::NotAtomic => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
|
|
||||||
AtomicOrdering::Unordered => __ATOMIC_RELAXED,
|
AtomicOrdering::Unordered => __ATOMIC_RELAXED,
|
||||||
AtomicOrdering::Monotonic => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
|
AtomicOrdering::Relaxed => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
|
||||||
AtomicOrdering::Acquire => __ATOMIC_ACQUIRE,
|
AtomicOrdering::Acquire => __ATOMIC_ACQUIRE,
|
||||||
AtomicOrdering::Release => __ATOMIC_RELEASE,
|
AtomicOrdering::Release => __ATOMIC_RELEASE,
|
||||||
AtomicOrdering::AcquireRelease => __ATOMIC_ACQ_REL,
|
AtomicOrdering::AcquireRelease => __ATOMIC_ACQ_REL,
|
||||||
|
@ -381,9 +381,8 @@ pub enum AtomicOrdering {
|
|||||||
impl AtomicOrdering {
|
impl AtomicOrdering {
|
||||||
pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
|
pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
|
||||||
match ao {
|
match ao {
|
||||||
rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
|
|
||||||
rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
|
rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
|
||||||
rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
|
rustc_codegen_ssa::common::AtomicOrdering::Relaxed => AtomicOrdering::Monotonic,
|
||||||
rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
|
rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
|
||||||
rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
|
rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
|
||||||
rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
|
rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
|
||||||
|
@ -11,6 +11,7 @@ use rustc_span::Span;
|
|||||||
use crate::base;
|
use crate::base;
|
||||||
use crate::traits::*;
|
use crate::traits::*;
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub enum IntPredicate {
|
pub enum IntPredicate {
|
||||||
IntEQ,
|
IntEQ,
|
||||||
IntNE,
|
IntNE,
|
||||||
@ -24,6 +25,7 @@ pub enum IntPredicate {
|
|||||||
IntSLE,
|
IntSLE,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub enum RealPredicate {
|
pub enum RealPredicate {
|
||||||
RealPredicateFalse,
|
RealPredicateFalse,
|
||||||
RealOEQ,
|
RealOEQ,
|
||||||
@ -43,6 +45,7 @@ pub enum RealPredicate {
|
|||||||
RealPredicateTrue,
|
RealPredicateTrue,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub enum AtomicRmwBinOp {
|
pub enum AtomicRmwBinOp {
|
||||||
AtomicXchg,
|
AtomicXchg,
|
||||||
AtomicAdd,
|
AtomicAdd,
|
||||||
@ -57,17 +60,17 @@ pub enum AtomicRmwBinOp {
|
|||||||
AtomicUMin,
|
AtomicUMin,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub enum AtomicOrdering {
|
pub enum AtomicOrdering {
|
||||||
NotAtomic,
|
|
||||||
Unordered,
|
Unordered,
|
||||||
Monotonic,
|
Relaxed,
|
||||||
// Consume, // Not specified yet.
|
|
||||||
Acquire,
|
Acquire,
|
||||||
Release,
|
Release,
|
||||||
AcquireRelease,
|
AcquireRelease,
|
||||||
SequentiallyConsistent,
|
SequentiallyConsistent,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone)]
|
||||||
pub enum SynchronizationScope {
|
pub enum SynchronizationScope {
|
||||||
SingleThread,
|
SingleThread,
|
||||||
CrossThread,
|
CrossThread,
|
||||||
|
@ -388,17 +388,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
2 => (SequentiallyConsistent, SequentiallyConsistent),
|
2 => (SequentiallyConsistent, SequentiallyConsistent),
|
||||||
3 => match split[2] {
|
3 => match split[2] {
|
||||||
"unordered" => (Unordered, Unordered),
|
"unordered" => (Unordered, Unordered),
|
||||||
"relaxed" => (Monotonic, Monotonic),
|
"relaxed" => (Relaxed, Relaxed),
|
||||||
"acq" => (Acquire, Acquire),
|
"acq" => (Acquire, Acquire),
|
||||||
"rel" => (Release, Monotonic),
|
"rel" => (Release, Relaxed),
|
||||||
"acqrel" => (AcquireRelease, Acquire),
|
"acqrel" => (AcquireRelease, Acquire),
|
||||||
"failrelaxed" if is_cxchg => (SequentiallyConsistent, Monotonic),
|
"failrelaxed" if is_cxchg => (SequentiallyConsistent, Relaxed),
|
||||||
"failacq" if is_cxchg => (SequentiallyConsistent, Acquire),
|
"failacq" if is_cxchg => (SequentiallyConsistent, Acquire),
|
||||||
_ => bx.sess().fatal("unknown ordering in atomic intrinsic"),
|
_ => bx.sess().fatal("unknown ordering in atomic intrinsic"),
|
||||||
},
|
},
|
||||||
4 => match (split[2], split[3]) {
|
4 => match (split[2], split[3]) {
|
||||||
("acq", "failrelaxed") if is_cxchg => (Acquire, Monotonic),
|
("acq", "failrelaxed") if is_cxchg => (Acquire, Relaxed),
|
||||||
("acqrel", "failrelaxed") if is_cxchg => (AcquireRelease, Monotonic),
|
("acqrel", "failrelaxed") if is_cxchg => (AcquireRelease, Relaxed),
|
||||||
_ => bx.sess().fatal("unknown ordering in atomic intrinsic"),
|
_ => bx.sess().fatal("unknown ordering in atomic intrinsic"),
|
||||||
},
|
},
|
||||||
_ => bx.sess().fatal("Atomic intrinsic not in correct format"),
|
_ => bx.sess().fatal("Atomic intrinsic not in correct format"),
|
||||||
|
Loading…
Reference in New Issue
Block a user