Skip to main content

core/stdarch/crates/core_arch/src/x86_64/
movrs.rs

1//! Read-shared Move instructions
2
3#[cfg(test)]
4use stdarch_test::assert_instr;
5
6unsafe extern "unadjusted" {
7    #[link_name = "llvm.x86.movrsqi"]
8    fn movrsqi(src: *const i8) -> i8;
9    #[link_name = "llvm.x86.movrshi"]
10    fn movrshi(src: *const i16) -> i16;
11    #[link_name = "llvm.x86.movrssi"]
12    fn movrssi(src: *const i32) -> i32;
13    #[link_name = "llvm.x86.movrsdi"]
14    fn movrsdi(src: *const i64) -> i64;
15}
16
17/// Moves a byte from the source to the destination, with an indication that the source memory
18/// location is likely to become read-shared by multiple processors, i.e., read in the future by at
19/// least one other processor before it is written, assuming it is ever written in the future.
20#[inline]
21#[target_feature(enable = "movrs")]
22#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(movrs))]
23#[unstable(feature = "movrs_target_feature", issue = "137976")]
24pub unsafe fn _movrs_i8(src: *const i8) -> i8 {
25    movrsqi(src)
26}
27
28/// Moves a 16-bit word from the source to the destination, with an indication that the source memory
29/// location is likely to become read-shared by multiple processors, i.e., read in the future by at
30/// least one other processor before it is written, assuming it is ever written in the future.
31#[inline]
32#[target_feature(enable = "movrs")]
33#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(movrs))]
34#[unstable(feature = "movrs_target_feature", issue = "137976")]
35pub unsafe fn _movrs_i16(src: *const i16) -> i16 {
36    movrshi(src)
37}
38
39/// Moves a 32-bit doubleword from the source to the destination, with an indication that the source
40/// memory location is likely to become read-shared by multiple processors, i.e., read in the future
41/// by at least one other processor before it is written, assuming it is ever written in the future.
42#[inline]
43#[target_feature(enable = "movrs")]
44#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(movrs))]
45#[unstable(feature = "movrs_target_feature", issue = "137976")]
46pub unsafe fn _movrs_i32(src: *const i32) -> i32 {
47    movrssi(src)
48}
49
50/// Moves a 64-bit quadword from the source to the destination, with an indication that the source
51/// memory location is likely to become read-shared by multiple processors, i.e., read in the future
52/// by at least one other processor before it is written, assuming it is ever written in the future.
53#[inline]
54#[target_feature(enable = "movrs")]
55#[cfg_attr(all(test, not(target_vendor = "apple")), assert_instr(movrs))]
56#[unstable(feature = "movrs_target_feature", issue = "137976")]
57pub unsafe fn _movrs_i64(src: *const i64) -> i64 {
58    movrsdi(src)
59}
60
61#[cfg(test)]
62mod tests {
63    use stdarch_test::simd_test;
64
65    use super::*;
66
67    #[simd_test(enable = "movrs")]
68    fn test_movrs_i8() {
69        let x: i8 = 42;
70        let y = unsafe { _movrs_i8(&x) };
71        assert_eq!(x, y);
72    }
73
74    #[simd_test(enable = "movrs")]
75    fn test_movrs_i16() {
76        let x: i16 = 42;
77        let y = unsafe { _movrs_i16(&x) };
78        assert_eq!(x, y);
79    }
80
81    #[simd_test(enable = "movrs")]
82    fn test_movrs_i32() {
83        let x: i32 = 42;
84        let y = unsafe { _movrs_i32(&x) };
85        assert_eq!(x, y);
86    }
87
88    #[simd_test(enable = "movrs")]
89    fn test_movrs_i64() {
90        let x: i64 = 42;
91        let y = unsafe { _movrs_i64(&x) };
92        assert_eq!(x, y);
93    }
94}