]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_llvm/traits.rs
Generalized SynchronisationScope for BuilderMethods
[rust.git] / src / librustc_codegen_llvm / traits.rs
index a3a90952958e61cf109179325c7fe0ffa69cbd57..d28dd0fa795a5f6a11e4fcedb0dc10ebb464f42e 100644 (file)
@@ -8,8 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
-use llvm::OperandBundleDef;
+use llvm::AsmDialect;
 use common::*;
 use type_::Type;
 use libc::c_char;
 use rustc::ty::layout::{Align, Size};
 use rustc::session::Session;
 use builder::MemFlags;
+use value::Value;
 
 use std::borrow::Cow;
 use std::ops::Range;
 
+pub struct OperandBundleDef<'a, Value : 'a> {
+    pub name: &'a str,
+    pub val: Value
+}
+
+impl OperandBundleDef<'ll, &'ll Value> {
+    pub fn new(name: &'ll str, val: &'ll Value) -> Self {
+        OperandBundleDef {
+            name,
+            val
+        }
+    }
+}
+
 pub enum IntPredicate {
     IntEQ,
     IntNE,
@@ -31,7 +45,7 @@ pub enum IntPredicate {
     IntSGT,
     IntSGE,
     IntSLT,
-    IntSLE,
+    IntSLE
 }
 
 #[allow(dead_code)]
@@ -51,9 +65,44 @@ pub enum RealPredicate {
     RealULT,
     RealULE,
     RealUNE,
-    RealPredicateTrue,
+    RealPredicateTrue
+}
+
+pub enum AtomicRmwBinOp {
+    AtomicXchg,
+    AtomicAdd,
+    AtomicSub,
+    AtomicAnd,
+    AtomicNand,
+    AtomicOr,
+    AtomicXor,
+    AtomicMax,
+    AtomicMin,
+    AtomicUMax,
+    AtomicUMin
 }
 
+pub enum AtomicOrdering {
+    #[allow(dead_code)]
+    NotAtomic,
+    Unordered,
+    Monotonic,
+    // Consume,  // Not specified yet.
+    Acquire,
+    Release,
+    AcquireRelease,
+    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,
     BasicBlock: ?Sized
@@ -97,7 +146,7 @@ fn invoke(
         args: &[&'ll Value],
         then: &'ll BasicBlock,
         catch: &'ll BasicBlock,
-        bundle: Option<&OperandBundleDef<'ll>>
+        bundle: Option<&OperandBundleDef<'ll, &'ll Value>>
     ) -> &'ll Value;
     fn unreachable(&self);
     fn add(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value;
@@ -313,6 +362,6 @@ fn check_call<'b>(
     fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: &'ll Value, size: Size);
 
     fn call(&self, llfn: &'ll Value, args: &[&'ll Value],
-                bundle: Option<&OperandBundleDef<'ll>>) -> &'ll Value;
+                bundle: Option<&OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value;
     fn zext(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value;
 }