diff options
| author | gnzlbg <gnzlbg@users.noreply.github.com> | 2018-08-15 18:20:33 +0200 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2018-08-15 09:20:33 -0700 |
| commit | 3daebfbc0b4654dba164500bdd1e96a2b814173e (patch) | |
| tree | 6a6687269d154de3b638a0c2b5cb3472d41ceab1 /library/stdarch/crates/assert-instr-macro/src/lib.rs | |
| parent | dafc8d9fbd7f16a141c55873f53df4d376d55a5e (diff) | |
| download | rust-3daebfbc0b4654dba164500bdd1e96a2b814173e.tar.gz rust-3daebfbc0b4654dba164500bdd1e96a2b814173e.zip | |
Add wasm32 simd128 intrinsics (#549)
* Add wasm32 simd128 intrinsics * test wasm32 simd128 instructions * Run wasm tests like all other tests * use modules instead of types to access wasm simd128 interpretations * generate docs for wasm32-unknown-unknown * fix typo * Enable #[assert_instr] on wasm32 * Shell out to Node's `execSync` to execute `wasm2wat` over our wasm file * Parse the wasm file line-by-line, looking for various function markers and such * Use the `elem` section to build a function pointer table, allowing us to map exactly from function pointer to a function * Avoid losing debug info (the names section) in release mode by stripping `--strip-debug` from `rust-lld`. * remove exclude list from Cargo.toml * fix assert_instr for non-wasm targets * re-format assert-instr changes * add crate that uses assert_instr * Fix instructions having extra quotes * Add assert_instr for wasm memory intrinsics * Remove hacks for git wasm-bindgen * add wasm_simd128 feature * make wasm32 build correctly * run simd128 tests on ci * remove wasm-assert-instr-tests
Diffstat (limited to 'library/stdarch/crates/assert-instr-macro/src/lib.rs')
| -rw-r--r-- | library/stdarch/crates/assert-instr-macro/src/lib.rs | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/library/stdarch/crates/assert-instr-macro/src/lib.rs b/library/stdarch/crates/assert-instr-macro/src/lib.rs index 25b5572ad8e..e5575e85a3a 100644 --- a/library/stdarch/crates/assert-instr-macro/src/lib.rs +++ b/library/stdarch/crates/assert-instr-macro/src/lib.rs @@ -38,17 +38,9 @@ pub fn assert_instr( // testing for. let disable_assert_instr = std::env::var("STDSIMD_DISABLE_ASSERT_INSTR").is_ok(); - let maybe_ignore = if cfg!(optimized) && !disable_assert_instr { - TokenStream::new() - } else { - (quote! { #[ignore] }).into() - }; use quote::ToTokens; let instr_str = instr - .clone() - .into_token_stream() - .to_string() .replace('.', "_") .replace(|c: char| c.is_whitespace(), ""); let assert_name = syn::Ident::new( @@ -124,16 +116,22 @@ pub fn assert_instr( } }; + // If instruction tests are disabled avoid emitting this shim at all, just + // return the original item without our attribute. + if !cfg!(optimized) || disable_assert_instr { + return (quote! { #item }).into(); + } + let tts: TokenStream = quote! { - #[test] + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test)] + #[cfg_attr(not(target_arch = "wasm32"), test)] #[allow(non_snake_case)] - #maybe_ignore fn #assert_name() { #to_test ::stdsimd_test::assert(#shim_name as usize, stringify!(#shim_name), - stringify!(#instr)); + #instr); } }.into(); // why? necessary now to get tests to work? @@ -148,13 +146,17 @@ pub fn assert_instr( } struct Invoc { - instr: syn::Expr, + instr: String, args: Vec<(syn::Ident, syn::Expr)>, } impl syn::synom::Synom for Invoc { named!(parse -> Self, do_parse!( - instr: syn!(syn::Expr) >> + instr: alt!( + map!(syn!(syn::Ident), |s| s.to_string()) + | + map!(syn!(syn::LitStr), |s| s.value()) + ) >> args: many0!(do_parse!( syn!(syn::token::Comma) >> name: syn!(syn::Ident) >> |
