Skip to content

Commit 99c4758

Browse files
committed
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.
2 parents 464ec64 + ef83e68 commit 99c4758

File tree

4 files changed

+15
-32
lines changed

4 files changed

+15
-32
lines changed

compiler/rustc_codegen_gcc/src/builder.rs

+3-22
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,6 @@ enum ExtremumOperation {
6161
Min,
6262
}
6363

64-
trait EnumClone {
65-
fn clone(&self) -> Self;
66-
}
67-
68-
impl EnumClone for AtomicOrdering {
69-
fn clone(&self) -> Self {
70-
match *self {
71-
AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
72-
AtomicOrdering::Unordered => AtomicOrdering::Unordered,
73-
AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
74-
AtomicOrdering::Acquire => AtomicOrdering::Acquire,
75-
AtomicOrdering::Release => AtomicOrdering::Release,
76-
AtomicOrdering::AcquireRelease => AtomicOrdering::AcquireRelease,
77-
AtomicOrdering::SequentiallyConsistent => AtomicOrdering::SequentiallyConsistent,
78-
}
79-
}
80-
}
81-
8264
pub struct Builder<'a: 'gcc, 'gcc, 'tcx> {
8365
pub cx: &'a CodegenCx<'gcc, 'tcx>,
8466
pub block: Block<'gcc>,
@@ -103,9 +85,9 @@ impl<'a, 'gcc, 'tcx> Builder<'a, 'gcc, 'tcx> {
10385
match order {
10486
// TODO(antoyo): does this make sense?
10587
AtomicOrdering::AcquireRelease | AtomicOrdering::Release => AtomicOrdering::Acquire,
106-
_ => order.clone(),
88+
_ => order,
10789
};
108-
let previous_value = self.atomic_load(dst.get_type(), dst, load_ordering.clone(), Size::from_bytes(size));
90+
let previous_value = self.atomic_load(dst.get_type(), dst, load_ordering, Size::from_bytes(size));
10991
let previous_var = func.new_local(None, previous_value.get_type(), "previous_value");
11092
let return_value = func.new_local(None, previous_value.get_type(), "return_value");
11193
self.llbb().add_assignment(None, previous_var, previous_value);
@@ -1384,9 +1366,8 @@ impl ToGccOrdering for AtomicOrdering {
13841366

13851367
let ordering =
13861368
match self {
1387-
AtomicOrdering::NotAtomic => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
13881369
AtomicOrdering::Unordered => __ATOMIC_RELAXED,
1389-
AtomicOrdering::Monotonic => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
1370+
AtomicOrdering::Relaxed => __ATOMIC_RELAXED, // TODO(antoyo): check if that's the same.
13901371
AtomicOrdering::Acquire => __ATOMIC_ACQUIRE,
13911372
AtomicOrdering::Release => __ATOMIC_RELEASE,
13921373
AtomicOrdering::AcquireRelease => __ATOMIC_ACQ_REL,

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -381,9 +381,8 @@ pub enum AtomicOrdering {
381381
impl AtomicOrdering {
382382
pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
383383
match ao {
384-
rustc_codegen_ssa::common::AtomicOrdering::NotAtomic => AtomicOrdering::NotAtomic,
385384
rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
386-
rustc_codegen_ssa::common::AtomicOrdering::Monotonic => AtomicOrdering::Monotonic,
385+
rustc_codegen_ssa::common::AtomicOrdering::Relaxed => AtomicOrdering::Monotonic,
387386
rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
388387
rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
389388
rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {

compiler/rustc_codegen_ssa/src/common.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use rustc_span::Span;
1111
use crate::base;
1212
use crate::traits::*;
1313

14+
#[derive(Copy, Clone)]
1415
pub enum IntPredicate {
1516
IntEQ,
1617
IntNE,
@@ -24,6 +25,7 @@ pub enum IntPredicate {
2425
IntSLE,
2526
}
2627

28+
#[derive(Copy, Clone)]
2729
pub enum RealPredicate {
2830
RealPredicateFalse,
2931
RealOEQ,
@@ -43,6 +45,7 @@ pub enum RealPredicate {
4345
RealPredicateTrue,
4446
}
4547

48+
#[derive(Copy, Clone)]
4649
pub enum AtomicRmwBinOp {
4750
AtomicXchg,
4851
AtomicAdd,
@@ -57,17 +60,17 @@ pub enum AtomicRmwBinOp {
5760
AtomicUMin,
5861
}
5962

63+
#[derive(Copy, Clone)]
6064
pub enum AtomicOrdering {
61-
NotAtomic,
6265
Unordered,
63-
Monotonic,
64-
// Consume, // Not specified yet.
66+
Relaxed,
6567
Acquire,
6668
Release,
6769
AcquireRelease,
6870
SequentiallyConsistent,
6971
}
7072

73+
#[derive(Copy, Clone)]
7174
pub enum SynchronizationScope {
7275
SingleThread,
7376
CrossThread,

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
388388
2 => (SequentiallyConsistent, SequentiallyConsistent),
389389
3 => match split[2] {
390390
"unordered" => (Unordered, Unordered),
391-
"relaxed" => (Monotonic, Monotonic),
391+
"relaxed" => (Relaxed, Relaxed),
392392
"acq" => (Acquire, Acquire),
393-
"rel" => (Release, Monotonic),
393+
"rel" => (Release, Relaxed),
394394
"acqrel" => (AcquireRelease, Acquire),
395-
"failrelaxed" if is_cxchg => (SequentiallyConsistent, Monotonic),
395+
"failrelaxed" if is_cxchg => (SequentiallyConsistent, Relaxed),
396396
"failacq" if is_cxchg => (SequentiallyConsistent, Acquire),
397397
_ => bx.sess().fatal("unknown ordering in atomic intrinsic"),
398398
},
399399
4 => match (split[2], split[3]) {
400-
("acq", "failrelaxed") if is_cxchg => (Acquire, Monotonic),
401-
("acqrel", "failrelaxed") if is_cxchg => (AcquireRelease, Monotonic),
400+
("acq", "failrelaxed") if is_cxchg => (Acquire, Relaxed),
401+
("acqrel", "failrelaxed") if is_cxchg => (AcquireRelease, Relaxed),
402402
_ => bx.sess().fatal("unknown ordering in atomic intrinsic"),
403403
},
404404
_ => bx.sess().fatal("Atomic intrinsic not in correct format"),

0 commit comments

Comments
 (0)