about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/tests
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-12-31 16:26:32 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2021-12-31 16:26:32 +0100
commitb799d6e0a5c46faf16b0dcbd5ff4932a7cb3e54f (patch)
treedc0ec811eb7a9793c3cfa17b7715aa5eae5e3ca4 /compiler/rustc_codegen_gcc/tests
parente670844012c2e26442d7a70f2f4236e390d91647 (diff)
parent1411a98352ba6bee8ba3b0131c9243e5db1e6a2e (diff)
downloadrust-b799d6e0a5c46faf16b0dcbd5ff4932a7cb3e54f.tar.gz
rust-b799d6e0a5c46faf16b0dcbd5ff4932a7cb3e54f.zip
Merge commit '1411a98352ba6bee8ba3b0131c9243e5db1e6a2e' into sync_cg_clif-2021-12-31
Diffstat (limited to 'compiler/rustc_codegen_gcc/tests')
-rw-r--r--compiler/rustc_codegen_gcc/tests/run/asm.rs31
1 files changed, 26 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_gcc/tests/run/asm.rs b/compiler/rustc_codegen_gcc/tests/run/asm.rs
index 48c0203d594..46abbb553bf 100644
--- a/compiler/rustc_codegen_gcc/tests/run/asm.rs
+++ b/compiler/rustc_codegen_gcc/tests/run/asm.rs
@@ -3,6 +3,10 @@
 // Run-time:
 //   status: 0
 
+#![feature(asm_const, asm_sym)]
+
+use std::arch::{asm, global_asm};
+
 global_asm!("
     .global add_asm
 add_asm:
@@ -15,6 +19,16 @@ extern "C" {
     fn add_asm(a: i64, b: i64) -> i64;
 }
 
+pub unsafe fn mem_cpy(dst: *mut u8, src: *const u8, len: usize) {
+    asm!(
+        "rep movsb",
+        inout("rdi") dst => _,
+        inout("rsi") src => _,
+        inout("rcx") len => _,
+        options(preserves_flags, nostack)
+    );
+}
+
 fn main() {
     unsafe {
         asm!("nop");
@@ -60,11 +74,11 @@ fn main() {
     }
     assert_eq!(x, 43);
 
-    // check inout(reg_class) x 
+    // check inout(reg_class) x
     let mut x: u64 = 42;
     unsafe {
         asm!("add {0}, {0}",
-            inout(reg) x 
+            inout(reg) x
         );
     }
     assert_eq!(x, 84);
@@ -73,7 +87,7 @@ fn main() {
     let mut x: u64 = 42;
     unsafe {
         asm!("add r11, r11",
-            inout("r11") x 
+            inout("r11") x
         );
     }
     assert_eq!(x, 84);
@@ -96,12 +110,12 @@ fn main() {
     assert_eq!(res, 7);
     assert_eq!(rem, 2);
 
-    // check const 
+    // check const
     let mut x: u64 = 42;
     unsafe {
         asm!("add {}, {}",
             inout(reg) x,
-            const 1 
+            const 1
         );
     }
     assert_eq!(x, 43);
@@ -148,4 +162,11 @@ fn main() {
     assert_eq!(x, 42);
 
     assert_eq!(unsafe { add_asm(40, 2) }, 42);
+
+    let array1 = [1u8, 2, 3];
+    let mut array2 = [0u8, 0, 0];
+    unsafe {
+        mem_cpy(array2.as_mut_ptr(), array1.as_ptr(), 3);
+    }
+    assert_eq!(array1, array2);
 }