Fix tests for a future nightly (#297)
In rust-lang/rust#47743 the SIMD types in the Rust ABI are being switched to getting passed through memory unconditionally rather than through LLVM's immediate registers. This means that a bunch of our assert_instr invocations started breaking as LLVM has more efficient methods of dealing with memory than the instructions themselves. This switches `assert_instr` to unconditionally use a shim that is an `extern` function which should revert back to the previous behavior, using the simd types as immediates and testing the same.
This commit is contained in:
parent
73794e5035
commit
e0aed0fffc
1 changed files with 43 additions and 50 deletions
|
|
@ -43,55 +43,48 @@ pub fn assert_instr(
|
|||
&format!("assert_{}_{}", name.as_ref(), instr.as_ref())[..],
|
||||
);
|
||||
let shim_name = syn::Ident::from(format!("{}_shim", name.as_ref()));
|
||||
let (to_test, test_name) = if invoc.args.len() == 0 {
|
||||
(TokenStream::empty(), &func.ident)
|
||||
} else {
|
||||
let mut inputs = Vec::new();
|
||||
let mut input_vals = Vec::new();
|
||||
let ret = &func.decl.output;
|
||||
for arg in func.decl.inputs.iter() {
|
||||
let capture = match *arg {
|
||||
syn::FnArg::Captured(ref c) => c,
|
||||
_ => panic!("arguments must not have patterns"),
|
||||
};
|
||||
let ident = match capture.pat {
|
||||
syn::Pat::Ident(ref i) => &i.ident,
|
||||
_ => panic!("must have bare arguments"),
|
||||
};
|
||||
match invoc.args.iter().find(|a| a.0 == ident.as_ref()) {
|
||||
Some(&(_, ref tts)) => {
|
||||
input_vals.push(quote! { #tts });
|
||||
}
|
||||
None => {
|
||||
inputs.push(capture);
|
||||
input_vals.push(quote! { #ident });
|
||||
}
|
||||
};
|
||||
}
|
||||
let mut inputs = Vec::new();
|
||||
let mut input_vals = Vec::new();
|
||||
let ret = &func.decl.output;
|
||||
for arg in func.decl.inputs.iter() {
|
||||
let capture = match *arg {
|
||||
syn::FnArg::Captured(ref c) => c,
|
||||
_ => panic!("arguments must not have patterns"),
|
||||
};
|
||||
let ident = match capture.pat {
|
||||
syn::Pat::Ident(ref i) => &i.ident,
|
||||
_ => panic!("must have bare arguments"),
|
||||
};
|
||||
match invoc.args.iter().find(|a| a.0 == ident.as_ref()) {
|
||||
Some(&(_, ref tts)) => {
|
||||
input_vals.push(quote! { #tts });
|
||||
}
|
||||
None => {
|
||||
inputs.push(capture);
|
||||
input_vals.push(quote! { #ident });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let attrs = func.attrs
|
||||
.iter()
|
||||
.filter(|attr| {
|
||||
attr.path
|
||||
.segments
|
||||
.first()
|
||||
.unwrap()
|
||||
.value()
|
||||
.ident
|
||||
.as_ref()
|
||||
.starts_with("target")
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let attrs = Append(&attrs);
|
||||
(
|
||||
quote! {
|
||||
#attrs
|
||||
unsafe fn #shim_name(#(#inputs),*) #ret {
|
||||
#name(#(#input_vals),*)
|
||||
}
|
||||
}.into(),
|
||||
&shim_name,
|
||||
)
|
||||
let attrs = func.attrs
|
||||
.iter()
|
||||
.filter(|attr| {
|
||||
attr.path
|
||||
.segments
|
||||
.first()
|
||||
.unwrap()
|
||||
.value()
|
||||
.ident
|
||||
.as_ref()
|
||||
.starts_with("target")
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let attrs = Append(&attrs);
|
||||
let to_test = quote! {
|
||||
#attrs
|
||||
unsafe extern fn #shim_name(#(#inputs),*) #ret {
|
||||
#name(#(#input_vals),*)
|
||||
}
|
||||
};
|
||||
|
||||
let tts: TokenStream = quote_spanned! {
|
||||
|
|
@ -102,8 +95,8 @@ pub fn assert_instr(
|
|||
fn #assert_name() {
|
||||
#to_test
|
||||
|
||||
::stdsimd_test::assert(#test_name as usize,
|
||||
stringify!(#test_name),
|
||||
::stdsimd_test::assert(#shim_name as usize,
|
||||
stringify!(#shim_name),
|
||||
stringify!(#instr));
|
||||
}
|
||||
}.into();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue