diff options
| author | Denis Merigoux <denis.merigoux@gmail.com> | 2018-08-21 18:15:29 +0200 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2018-11-16 14:11:09 +0200 |
| commit | b7615389978eae2ae9f3cba9a776fd8da3f743ca (patch) | |
| tree | 16b5b6da384a12abc0016a389b5d295d66fe999c | |
| parent | b6998662900290db23974e8a7ba3c3864330c368 (diff) | |
| download | rust-b7615389978eae2ae9f3cba9a776fd8da3f743ca.tar.gz rust-b7615389978eae2ae9f3cba9a776fd8da3f743ca.zip | |
Generalized SynchronisationScope for BuilderMethods
| -rw-r--r-- | src/librustc_codegen_llvm/builder.rs | 4 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/intrinsic.rs | 6 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/llvm/ffi.rs | 10 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/traits.rs | 10 |
4 files changed, 24 insertions, 6 deletions
diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index e09f22b4e69..61142d7fde3 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -1097,12 +1097,12 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - 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) ); } } diff --git a/src/librustc_codegen_llvm/intrinsic.rs b/src/librustc_codegen_llvm/intrinsic.rs index 7db8fa4bd2e..e9568761ac2 100644 --- a/src/librustc_codegen_llvm/intrinsic.rs +++ b/src/librustc_codegen_llvm/intrinsic.rs @@ -31,7 +31,7 @@ use syntax::symbol::Symbol; 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; } diff --git a/src/librustc_codegen_llvm/llvm/ffi.rs b/src/librustc_codegen_llvm/llvm/ffi.rs index 677c108edc3..8ac6e218d86 100644 --- a/src/librustc_codegen_llvm/llvm/ffi.rs +++ b/src/librustc_codegen_llvm/llvm/ffi.rs @@ -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)] diff --git a/src/librustc_codegen_llvm/traits.rs b/src/librustc_codegen_llvm/traits.rs index 315c273dd2d..d28dd0fa795 100644 --- a/src/librustc_codegen_llvm/traits.rs +++ b/src/librustc_codegen_llvm/traits.rs @@ -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, |
