mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-28 20:16:58 +03:00
Enable multiple #[assert_instr] attributes (#96)
* Enable multiple #[assert_instr] attributes Looks like all we needed to do was generate new function names! * Uncomment assertions for `_mm_prefetch`
This commit is contained in:
@@ -574,9 +574,9 @@ pub unsafe fn _MM_SET_ROUNDING_MODE(x: u32) {
|
||||
#[inline(always)]
|
||||
#[target_feature = "+sse"]
|
||||
#[cfg_attr(test, assert_instr(prefetcht0, strategy = _MM_HINT_T0))]
|
||||
// #[cfg_attr(test, assert_instr(prefetcht1, strategy = _MM_HINT_T1))]
|
||||
// #[cfg_attr(test, assert_instr(prefetcht2, strategy = _MM_HINT_T2))]
|
||||
// #[cfg_attr(test, assert_instr(prefetchnta, strategy = _MM_HINT_NTA))]
|
||||
#[cfg_attr(test, assert_instr(prefetcht1, strategy = _MM_HINT_T1))]
|
||||
#[cfg_attr(test, assert_instr(prefetcht2, strategy = _MM_HINT_T2))]
|
||||
#[cfg_attr(test, assert_instr(prefetchnta, strategy = _MM_HINT_NTA))]
|
||||
pub unsafe fn _mm_prefetch(p: *const c_void, strategy: i8) {
|
||||
// The `strategy` must be a compile-time constant, so we use a short form of
|
||||
// `constify_imm8!` for now.
|
||||
|
||||
@@ -40,7 +40,9 @@ pub fn assert_instr(attr: proc_macro::TokenStream,
|
||||
(quote! { #[ignore] }).into()
|
||||
};
|
||||
let name = &func.ident;
|
||||
let assert_name = syn::Ident::from(&format!("assert_{}", name.sym.as_str())[..]);
|
||||
let assert_name = syn::Ident::from(&format!("assert_{}_{}",
|
||||
name.sym.as_str(),
|
||||
instr.sym.as_str())[..]);
|
||||
let shim_name = syn::Ident::from(&format!("{}_shim", name.sym.as_str())[..]);
|
||||
let (to_test, test_name) = if invoc.args.len() == 0 {
|
||||
(TokenStream::empty(), &func.ident)
|
||||
@@ -67,7 +69,10 @@ pub fn assert_instr(attr: proc_macro::TokenStream,
|
||||
}
|
||||
};
|
||||
}
|
||||
let attrs = Append(&item.attrs);
|
||||
let attrs = item.attrs.iter().filter(|attr| {
|
||||
attr.path.segments.get(0).item().ident.sym.as_str().starts_with("target")
|
||||
}).collect::<Vec<_>>();
|
||||
let attrs = Append(&attrs);
|
||||
(quote! {
|
||||
#attrs
|
||||
unsafe fn #shim_name(#(#inputs),*) #ret {
|
||||
|
||||
Reference in New Issue
Block a user