提交 b7615389 编写于 作者: D Denis Merigoux 提交者: Eduard-Mihai Burtescu

Generalized SynchronisationScope for BuilderMethods

上级 b6998662
......@@ -1097,12 +1097,12 @@ fn atomic_rmw(
}
}
fn atomic_fence(&self, order: traits::AtomicOrdering, scope: SynchronizationScope) {
fn atomic_fence(&self, order: traits::AtomicOrdering, scope: traits::SynchronizationScope) {
unsafe {
llvm::LLVMRustBuildAtomicFence(
self.llbuilder,
AtomicOrdering::from_generic(order),
scope
SynchronizationScope::from_generic(scope)
);
}
}
......
......@@ -31,7 +31,7 @@
use builder::Builder;
use value::Value;
use traits::{BuilderMethods, AtomicRmwBinOp};
use traits::{BuilderMethods, AtomicRmwBinOp, SynchronizationScope};
use rustc::session::Session;
use syntax_pos::Span;
......@@ -521,12 +521,12 @@ pub fn codegen_intrinsic_call(
}
"fence" => {
bx.atomic_fence(order, llvm::SynchronizationScope::CrossThread);
bx.atomic_fence(order, SynchronizationScope::CrossThread);
return;
}
"singlethreadfence" => {
bx.atomic_fence(order, llvm::SynchronizationScope::SingleThread);
bx.atomic_fence(order, SynchronizationScope::SingleThread);
return;
}
......
......@@ -304,6 +304,16 @@ pub enum SynchronizationScope {
CrossThread,
}
impl SynchronizationScope {
pub fn from_generic(sc : traits::SynchronizationScope) -> Self {
match sc {
traits::SynchronizationScope::Other => SynchronizationScope::Other,
traits::SynchronizationScope::SingleThread => SynchronizationScope::SingleThread,
traits::SynchronizationScope::CrossThread => SynchronizationScope::CrossThread,
}
}
}
/// LLVMRustFileType
#[derive(Copy, Clone)]
#[repr(C)]
......
......@@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use llvm::{SynchronizationScope, AsmDialect};
use llvm::AsmDialect;
use common::*;
use type_::Type;
use libc::c_char;
......@@ -94,6 +94,14 @@ pub enum AtomicOrdering {
SequentiallyConsistent,
}
pub enum SynchronizationScope {
// FIXME: figure out if this variant is needed at all.
#[allow(dead_code)]
Other,
SingleThread,
CrossThread,
}
pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll,
Value : ?Sized,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册