From f4c92cc4d1c521ac5f7d8e6dbb55bf0fafcb880c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Tue, 24 May 2022 00:00:00 +0000 Subject: [PATCH] rustc_codegen_ssa: cleanup `AtomicOrdering` * Remove unused `NotAtomic` ordering. * Rename `Monotonic` to `Relaxed` - a Rust specific name. --- compiler/rustc_codegen_gcc/src/builder.rs | 6 ++---- compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 3 +-- compiler/rustc_codegen_ssa/src/common.rs | 4 +--- compiler/rustc_codegen_ssa/src/mir/intrinsic.rs | 10 +++++----- 4 files changed, 9 insertions(+), 14 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/builder.rs b/compiler/rustc_codegen_gcc/src/builder.rs index 41f88f119e2..62eeb373821 100644 --- a/compiler/rustc_codegen_gcc/src/builder.rs +++ b/compiler/rustc_codegen_gcc/src/builder.rs @@ -68,9 +68,8 @@ trait EnumClone { impl EnumClone for AtomicOrdering { fn clone(&self) -> Self { match *self { - AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic, AtomicOrdering::Unordered => AtomicOrdering::Unordered, - AtomicOrdering::Monotonic => AtomicOrdering::Monotonic, + AtomicOrdering::Relaxed => AtomicOrdering::Relaxed, AtomicOrdering::Acquire => AtomicOrdering::Acquire, AtomicOrdering::Release => AtomicOrdering::Release, AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease, @@ -1384,9 +1383,8 @@ impl ToGccOrdering for AtomicOrdering { let ordering = match self { - AtomicOrdering::NotAtomic => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same. 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::Release => __ATOMIC_RELEASE, AtomicOrdering::AcquireRelease => __ATOMIC_ACQ_REL, diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 37409dbb447..1d9a4655db6 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -381,9 +381,8 @@ pub enum AtomicOrdering { impl AtomicOrdering { pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self { match ao { - rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic, 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::Release => AtomicOrdering::Release, rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => { diff --git a/compiler/rustc_codegen_ssa/src/common.rs b/compiler/rustc_codegen_ssa/src/common.rs index 1574b30497b..517cdd1e8de 100644 --- a/compiler/rustc_codegen_ssa/src/common.rs +++ b/compiler/rustc_codegen_ssa/src/common.rs @@ -58,10 +58,8 @@ pub enum AtomicRmwBinOp { } pub enum AtomicOrdering { - NotAtomic, Unordered, - Monotonic, - // Consume, // Not specified yet. + Relaxed, Acquire, Release, AcquireRelease, diff --git a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs index 6d6d3ae01f4..0ed4c3f1d94 100644 --- a/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs +++ b/compiler/rustc_codegen_ssa/src/mir/intrinsic.rs @@ -388,17 +388,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { 2 => (SequentiallyConsistent, SequentiallyConsistent), 3 => match split[2] { "unordered" => (Unordered, Unordered), - "relaxed" => (Monotonic, Monotonic), + "relaxed" => (Relaxed, Relaxed), "acq" => (Acquire, Acquire), - "rel" => (Release, Monotonic), + "rel" => (Release, Relaxed), "acqrel" => (AcquireRelease, Acquire), - "failrelaxed" if is_cxchg => (SequentiallyConsistent, Monotonic), + "failrelaxed" if is_cxchg => (SequentiallyConsistent, Relaxed), "failacq" if is_cxchg => (SequentiallyConsistent, Acquire), _ => bx.sess().fatal("unknown ordering in atomic intrinsic"), }, 4 => match (split[2], split[3]) { - ("acq", "failrelaxed") if is_cxchg => (Acquire, Monotonic), - ("acqrel", "failrelaxed") if is_cxchg => (AcquireRelease, Monotonic), + ("acq", "failrelaxed") if is_cxchg => (Acquire, Relaxed), + ("acqrel", "failrelaxed") if is_cxchg => (AcquireRelease, Relaxed), _ => bx.sess().fatal("unknown ordering in atomic intrinsic"), }, _ => bx.sess().fatal("Atomic intrinsic not in correct format"),