]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/builder.rs
rustc: Add support for some more x86 SIMD ops
[rust.git] / src / librustc_trans / builder.rs
index 50e673bdbfdd77a068b33bb00a2525b7a1c84821..e40311af595cdc993c81006c0d720e51856e72aa 100644 (file)
@@ -612,6 +612,29 @@ pub fn atomic_store(&self, val: ValueRef, ptr: ValueRef,
         }
     }
 
+    pub fn nontemporal_store(&self, val: ValueRef, ptr: ValueRef) -> ValueRef {
+        debug!("Store {:?} -> {:?}", Value(val), Value(ptr));
+        assert!(!self.llbuilder.is_null());
+        self.count_insn("store.nontemporal");
+        let ptr = self.check_store(val, ptr);
+        unsafe {
+            let insn = llvm::LLVMBuildStore(self.llbuilder, val, ptr);
+
+            // According to LLVM [1] building a nontemporal store must *always*
+            // point to a metadata value of the integer 1. Who knew?
+            //
+            // [1]: http://llvm.org/docs/LangRef.html#store-instruction
+            let one = C_i32(self.ccx, 1);
+            let node = llvm::LLVMMDNodeInContext(self.ccx.llcx(),
+                                                 &one,
+                                                 1);
+            llvm::LLVMSetMetadata(insn,
+                                  llvm::MD_nontemporal as c_uint,
+                                  node);
+            insn
+        }
+    }
+
     pub fn gep(&self, ptr: ValueRef, indices: &[ValueRef]) -> ValueRef {
         self.count_insn("gep");
         unsafe {