Skip to content

Commit b761538

Browse files
denismerigouxeddyb
authored andcommitted
Generalized SynchronisationScope for BuilderMethods
1 parent b699866 commit b761538

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

src/librustc_codegen_llvm/builder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,12 +1097,12 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>
10971097
}
10981098
}
10991099

1100-
fn atomic_fence(&self, order: traits::AtomicOrdering, scope: SynchronizationScope) {
1100+
fn atomic_fence(&self, order: traits::AtomicOrdering, scope: traits::SynchronizationScope) {
11011101
unsafe {
11021102
llvm::LLVMRustBuildAtomicFence(
11031103
self.llbuilder,
11041104
AtomicOrdering::from_generic(order),
1105-
scope
1105+
SynchronizationScope::from_generic(scope)
11061106
);
11071107
}
11081108
}

src/librustc_codegen_llvm/intrinsic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use syntax::symbol::Symbol;
3131
use builder::Builder;
3232
use value::Value;
3333

34-
use traits::{BuilderMethods, AtomicRmwBinOp};
34+
use traits::{BuilderMethods, AtomicRmwBinOp, SynchronizationScope};
3535

3636
use rustc::session::Session;
3737
use syntax_pos::Span;
@@ -521,12 +521,12 @@ pub fn codegen_intrinsic_call(
521521
}
522522

523523
"fence" => {
524-
bx.atomic_fence(order, llvm::SynchronizationScope::CrossThread);
524+
bx.atomic_fence(order, SynchronizationScope::CrossThread);
525525
return;
526526
}
527527

528528
"singlethreadfence" => {
529-
bx.atomic_fence(order, llvm::SynchronizationScope::SingleThread);
529+
bx.atomic_fence(order, SynchronizationScope::SingleThread);
530530
return;
531531
}
532532

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,16 @@ pub enum SynchronizationScope {
304304
CrossThread,
305305
}
306306

307+
impl SynchronizationScope {
308+
pub fn from_generic(sc : traits::SynchronizationScope) -> Self {
309+
match sc {
310+
traits::SynchronizationScope::Other => SynchronizationScope::Other,
311+
traits::SynchronizationScope::SingleThread => SynchronizationScope::SingleThread,
312+
traits::SynchronizationScope::CrossThread => SynchronizationScope::CrossThread,
313+
}
314+
}
315+
}
316+
307317
/// LLVMRustFileType
308318
#[derive(Copy, Clone)]
309319
#[repr(C)]

src/librustc_codegen_llvm/traits.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use llvm::{SynchronizationScope, AsmDialect};
11+
use llvm::AsmDialect;
1212
use common::*;
1313
use type_::Type;
1414
use libc::c_char;
@@ -94,6 +94,14 @@ pub enum AtomicOrdering {
9494
SequentiallyConsistent,
9595
}
9696

97+
pub enum SynchronizationScope {
98+
// FIXME: figure out if this variant is needed at all.
99+
#[allow(dead_code)]
100+
Other,
101+
SingleThread,
102+
CrossThread,
103+
}
104+
97105

98106
pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
99107
Value : ?Sized,

0 commit comments

Comments
 (0)