Skip to content

Add MMX _mm_empty and _m_empty intrinsics #638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions coresimd/x86/mmx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,26 @@ pub unsafe fn _mm_setr_pi8(
mem::transmute(i8x8::new(e0, e1, e2, e3, e4, e5, e6, e7))
}

/// Empty the MMX state, which marks the x87 FPU registers as available for use
/// by x87 instructions. This instruction must be used at the end of all MMX
/// technology procedures.
#[inline]
#[target_feature(enable = "mmx")]
#[cfg_attr(test, assert_instr(emms))]
pub unsafe fn _mm_empty() {
emms()
}

/// Empty the MMX state, which marks the x87 FPU registers as available for use
/// by x87 instructions. This instruction must be used at the end of all MMX
/// technology procedures.
#[inline]
#[target_feature(enable = "mmx")]
#[cfg_attr(test, assert_instr(emms))]
pub unsafe fn _m_empty() {
emms()
}

#[allow(improper_ctypes)]
extern "C" {
#[link_name = "llvm.x86.mmx.padd.b"]
Expand Down Expand Up @@ -488,6 +508,8 @@ extern "C" {
fn punpckhdq(a: __m64, b: __m64) -> __m64;
#[link_name = "llvm.x86.mmx.punpckldq"]
fn punpckldq(a: __m64, b: __m64) -> __m64;
#[link_name = "llvm.x86.mmx.emms"]
fn emms();
}

#[cfg(test)]
Expand Down Expand Up @@ -729,4 +751,14 @@ mod tests {

assert_eq_m64(r, _mm_unpacklo_pi32(a, b));
}

#[simd_test(enable = "mmx")]
unsafe fn test_mm_empty() {
_mm_empty();
}

#[simd_test(enable = "mmx")]
unsafe fn test_m_empty() {
_m_empty();
}
}