]> 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 308677fcb7329ef361fe28225f7864f2ed125fea..d28dd0fa795a5f6a11e4fcedb0dc10ebb464f42e 100644 (file)
@@ -8,9 +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::{IntPredicate, RealPredicate, OperandBundleDef};
-use llvm;
+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,
+    IntUGT,
+    IntUGE,
+    IntULT,
+    IntULE,
+    IntSGT,
+    IntSGE,
+    IntSLT,
+    IntSLE
+}
+
+#[allow(dead_code)]
+pub enum RealPredicate {
+    RealPredicateFalse,
+    RealOEQ,
+    RealOGT,
+    RealOGE,
+    RealOLT,
+    RealOLE,
+    RealONE,
+    RealORD,
+    RealUNO,
+    RealUEQ,
+    RealUGT,
+    RealUGE,
+    RealULT,
+    RealULE,
+    RealUNE,
+    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,
@@ -66,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;
@@ -251,7 +331,7 @@ fn atomic_cmpxchg(
         src: &'ll Value,
         order: AtomicOrdering,
         failure_order: AtomicOrdering,
-        weak: llvm::Bool,
+        weak: bool,
     ) -> &'ll Value;
     fn atomic_rmw(
         &self,
@@ -282,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;
 }