Skip to content

Commit

Permalink
_mm_pause does not require SSE2
Browse files Browse the repository at this point in the history
Closes #705 .
  • Loading branch information
gnzlbg committed Mar 18, 2019
1 parent 7711679 commit 12bdc2e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
14 changes: 9 additions & 5 deletions crates/core_arch/src/x86/sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ use crate::{
///
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mm_pause)
#[inline]
#[target_feature(enable = "sse2")]
#[cfg_attr(test, assert_instr(pause))]
#[cfg_attr(
all(test, target_feature = "sse2"),
assert_instr(pause)
)]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mm_pause() {
// note: `pause` is guaranteed to be interpreted as a `nop` by CPUs without
// the SSE2 target-feature - therefore it does not require any target features
pause()
}

Expand Down Expand Up @@ -3191,9 +3195,9 @@ mod tests {
use stdsimd_test::simd_test;
use test::black_box; // Used to inhibit constant-folding.

#[simd_test(enable = "sse2")]
unsafe fn test_mm_pause() {
_mm_pause();
#[test]
fn test_mm_pause() {
unsafe { _mm_pause() }
}

#[simd_test(enable = "sse2")]
Expand Down
10 changes: 5 additions & 5 deletions crates/stdsimd-verify/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn arm_functions(input: TokenStream) -> TokenStream {

fn functions(input: TokenStream, dirs: &[&str]) -> TokenStream {
let dir = Path::new(env!("CARGO_MANIFEST_DIR"));
let root = dir.parent().unwrap();
let root = dir.parent().expect("root-dir not found");

let mut files = Vec::new();
for dir in dirs {
Expand Down Expand Up @@ -199,11 +199,11 @@ fn extract_path_ident(path: &syn::Path) -> syn::Ident {
if path.segments.len() != 1 {
panic!("unsupported path that needs name resolution")
}
match path.segments.first().unwrap().value().arguments {
match path.segments.first().expect("segment not found").value().arguments {
syn::PathArguments::None => {}
_ => panic!("unsupported path that has path arguments"),
}
path.segments.first().unwrap().value().ident.clone()
path.segments.first().expect("segment not found").value().ident.clone()
}

fn walk(root: &Path, files: &mut Vec<(syn::File, String)>) {
Expand All @@ -224,9 +224,9 @@ fn walk(root: &Path, files: &mut Vec<(syn::File, String)>) {

let mut contents = String::new();
File::open(&path)
.unwrap()
.expect(&format!("can't open file at path: {}", path.display()))
.read_to_string(&mut contents)
.unwrap();
.expect("failed to read file to string");

files.push((
syn::parse_str::<syn::File>(&contents).expect("failed to parse"),
Expand Down
6 changes: 6 additions & 0 deletions crates/stdsimd-verify/tests/x86-intel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ fn matches(rust: &Function, intel: &Intrinsic) -> Result<(), String> {
}

for cpuid in &intel.cpuid {
// The pause intrinsic is in the SSE2 module, but it is backwards
// compatible with CPUs without SSE2, and it therefore does not need the
// target-feature attribute.
if rust.name == "_mm_pause" {
continue;
}
// this is needed by _xsave and probably some related intrinsics,
// but let's just skip it for now.
if *cpuid == "XSS" {
Expand Down

0 comments on commit 12bdc2e

Please sign in to comment.