Commit Graph

98 Commits

Author SHA1 Message Date
Taiki Endo
a36f5bd7c8 std_detect: Support run-time detection on aarch64 OpenBSD 2023-01-26 23:33:52 +00:00
Taiki Endo
d3bb923c82 std_detect: Split os/aarch64.rs' detect_features into reading and parsing 2023-01-26 23:33:52 +00:00
Taiki Endo
674fd58f60 std_detect: Move aarch64 freebsd test to tests/cpu-detection.rs 2023-01-26 23:33:52 +00:00
Taiki Endo
505d4e8d48 std_detect: Support detecting lse/dotprod/jsconv/rcpc on aarch64 Windows 2023-01-23 22:26:08 +00:00
Caleb Zulawski
39c2524e1b Detect MOVBE (#1356) 2023-01-05 17:54:07 +00:00
Caleb Zulawski
0b2b195544 Rename misleading features (#1355) 2022-11-21 20:56:45 +00:00
gendx
45e3039ee9 Detect CPU features with Linux methods on Android for non-Intel CPUs. (#1351)
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
2022-11-09 18:38:48 +00:00
Mateusz Mikuła
9f7ded4282 Fix line endings to use LF (#1350) 2022-11-09 00:37:10 +00:00
Yuri Astrakhan
81c221f058 Edition 2021, apply clippy::uninlined_format_args fix (#1339) 2022-10-25 20:17:23 +01:00
Rageking8
90f618d8dd Fix dupe word typos (#1344) 2022-10-25 15:01:34 +01:00
Jacob Bramley
8a944e5a5f Add HWCAP2 support for AArch64 Linux. (#1335) 2022-09-22 05:31:46 +01:00
Tomasz Miąsko
39f73ac0b3 Allow internal use of stdsimd from detect_feature
This allows using feature detection macros, without placing a
requirement of enabled stdsimd feature gate from end users.

A follow-up to changes from #1311, which introduced the new macro.
2022-08-22 22:40:39 +02:00
Adam Gemmell
ba9ca43154 Allow mapping a runtime feature to a set of target_features (#1311) 2022-07-02 00:55:03 +01:00
Adam Gemmell
0798ac34c7 Fully qualify recursive macro calls (#1310) 2022-06-21 00:20:12 +01:00
Jane Lusby
bae054af11 Add stdsimd feature to allow_internal_unstable attribute in feature detect macros (#1303) 2022-04-29 01:30:25 +01:00
Luca Barbato
d3f6f21a26 Import the asm macro in std_detect (#1290) 2022-03-11 17:12:29 +00:00
Amanieu d'Antras
bf3a73b3e8 Avoid the use of #[cfg(doc)] in std_detect (#1283)
Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2022-02-17 12:49:50 +00:00
Adam Gemmell
3362d525c5 Split aarch64 pauth feature into paca and pacg (#1259) 2022-02-10 14:59:40 +00:00
Adam Gemmell
c52d7f5b66 Stabilise is_aarch64_feature_detected! under simd_aarch64 feature (#1239) 2022-02-09 19:33:25 +00:00
Amanieu d'Antras
3030730d04 Emit the full is_{arch}_feature_detected! macro on all arches when building docs (#1276) 2022-01-28 09:49:43 +00:00
Amanieu d'Antras
efad3ead52 Fix std_detect_file_io 2022-01-24 02:53:45 +00:00
Amanieu d'Antras
f5c59b3514 Handle stabilization of vec_spare_capacity 2022-01-18 15:11:40 +00:00
Amanieu d'Antras
59e7156f6e Remove asm feature which is now stable (#1269) 2021-12-19 14:43:19 +00:00
Frank Steffahn
df24e2a0f8 Fix a bunch of typos 2021-12-14 10:17:43 -08:00
Luo Jia
72061cb5f5 RISC-V feature and detect macro (#1263) 2021-12-08 11:41:12 +00:00
Tobias Kortkamp
972030f2b2 Support riscv64gc-unknown-freebsd (#1260) 2021-11-27 14:01:23 +00:00
Thom Chiovoloni
08a70f96fe Work-around buggy Intel chips erroneously reporting BMI1/BMI2 support (#1249) 2021-11-19 01:29:04 +00:00
Sparrow Li
be5e1be224 Add remaining insturctions (#1250)
* add vmmla vusmmla vsm4e vsm3 vrax1 vxar vsha512 vbcax veor3 neon instructions

* update runtime feature detect

* correct tests

* add `vrnd32x` `vrnd64x`

* add MISSING.md
2021-11-10 15:19:59 +00:00
Taiki Endo
42ae943ab4 Fix error message of is_*_feature_detected on nort_feature (#1232) 2021-10-16 22:22:47 +01:00
Hans Kratz
26cce19427 Make dedup guard optional (#1215) 2021-09-20 17:19:05 +01:00
Frank Steffahn
870cf5751d Fix typos “an”→“a” 2021-08-22 18:55:49 +01:00
Adam Gemmell
1069e66439 Update aarch64 linux feature detection (#1146) 2021-05-28 01:37:20 +01:00
Amanieu d'Antras
63daa088fd Move cfg!(target_feature) directly into is_*_feature_detected!() (#1141)
Fixes #1135
2021-04-24 08:02:24 +01:00
Ralf Jung
03e109a2f3 remove unused const_fn feature (#1140) 2021-04-23 16:46:38 +01:00
Joshua Nelson
7bab2c0695 Deny 2018 idiom lints (#1108)
This lint is allow by default, which is why this wasn't spotted earlier.
It's denied by rust-lang/rust, so it's good to warn about it here so it
can be fixed more quickly.
2021-04-07 05:46:39 +01:00
Amanieu d'Antras
72dda3aae0 Fix building std_detect as a dependency of std (#1089) 2021-03-18 20:36:40 +00:00
Amanieu d'Antras
a1e151e838 Convert all uses of llvm_asm! to asm! (#1052) 2021-03-17 01:44:35 +00:00
Aaron Hill
41bfaf89bf Remove trailing semicolon from macro expression (#1080)
Unblocks https://github.com/rust-lang/rust/pull/83089
2021-03-13 19:51:54 +00:00
Amanieu d'Antras
f32f7cb899 Turn std_detect into a no_std crate (#1005) 2021-02-14 22:14:37 +00:00
Carlos Pérez
390ce8dca5 Fix false rustdoc broken_intra_link detection (#984)
I saw in https://github.com/rust-lang/rust/issues/81037
that when you document private items with rustdoc the
`x86 AVX-512 BITALG` feature comment does not contain
scape characters in the message and therefore rustdoc
was emiting warnings.

This fixes it.
2021-01-18 23:56:58 +00:00
Thom Chiovoloni
6a0969d12f Optimize std_detect's caching (#908) 2020-09-17 02:43:25 +01:00
Alex Crichton
770964adac Update and revamp wasm32 SIMD intrinsics (#874)
Lots of time and lots of things have happened since the simd128 support
was first added to this crate. Things are starting to settle down now so
this commit syncs the Rust intrinsic definitions with the current
specification (https://github.com/WebAssembly/simd). Unfortuantely not
everything can be enabled just yet but everything is in the pipeline for
getting enabled soon.

This commit also applies a major revamp to how intrinsics are tested.
The intention is that the setup should be much more lightweight and/or
easy to work with after this commit.

At a high-level, the changes here are:

* Testing with node.js and `#[wasm_bindgen]` has been removed. Instead
  intrinsics are tested with Wasmtime which has a nearly complete
  implementation of the SIMD spec (and soon fully complete!)

* Testing is switched to `wasm32-wasi` to make idiomatic Rust bits a bit
  easier to work with (e.g. `panic!)`

* Testing of this crate's simd128 feature for wasm is re-enabled. This
  will run on CI and both compile and execute intrinsics. This should
  bring wasm intrinsics to the same level of parity as x86 intrinsics,
  for example.

* New wasm intrinsics have been added:
  * `iNNxMM_loadAxA_{s,u}`
  * `vNNxMM_load_splat`
  * `v8x16_swizzle`
  * `v128_andnot`
  * `iNNxMM_abs`
  * `iNNxMM_narrow_*_{u,s}`
  * `iNNxMM_bitmask` - commented out until LLVM is updated to LLVM 11
  * `iNNxMM_widen_*_{u,s}` - commented out until
    bytecodealliance/wasmtime#1994 lands
  * `iNNxMM_{max,min}_{u,s}`
  * `iNNxMM_avgr_u`

* Some wasm intrinsics have been removed:
  * `i64x2_trunc_*`
  * `f64x2_convert_*`
  * `i8x16_mul`

* The `v8x16.shuffle` instruction is exposed. This is done through a
  `macro` (not `macro_rules!`, but `macro`). This is intended to be
  somewhat experimental and unstable until we decide otherwise. This
  instruction has 16 immediate-mode expressions and is as a result
  unsuited to the existing `constify_*` logic of this crate. I'm hoping
  that we can game out over time what a macro might look like and/or
  look for better solutions. For now, though, what's implemented is the
  first of its kind in this crate (an architecture-specific macro), so
  some extra scrutiny looking at it would be appreciated.

* Lots of `assert_instr` annotations have been fixed for wasm.

* All wasm simd128 tests are uncommented and passing now.

This is still missing tests for new intrinsics and it's also missing
tests for various corner cases. I hope to get to those later as the
upstream spec itself gets closer to stabilization.

In the meantime, however, I went ahead and updated the `hex.rs` example
with a wasm implementation using intrinsics. With it I got some very
impressive speedups using Wasmtime:

    test benches::large_default  ... bench:     213,961 ns/iter (+/- 5,108) = 4900 MB/s
    test benches::large_fallback ... bench:   3,108,434 ns/iter (+/- 75,730) = 337 MB/s
    test benches::small_default  ... bench:          52 ns/iter (+/- 0) = 2250 MB/s
    test benches::small_fallback ... bench:         358 ns/iter (+/- 0) = 326 MB/s

or otherwise using Wasmtime hex encoding using SIMD is 15x faster on 1MB
chunks or 7x faster on small <128byte chunks.

All of these intrinsics are still unstable and will continue to be so
presumably until the simd proposal in wasm itself progresses to a later
stage. Additionaly we'll still want to sync with clang on intrinsic
names (or decide not to) at some point in the future.

* wasm: Unconditionally expose SIMD functions

This commit unconditionally exposes SIMD functions from the `wasm32`
module. This is done in such a way that the standard library does not
need to be recompiled to access SIMD intrinsics and use them. This,
hopefully, is the long-term story for SIMD in WebAssembly in Rust.

It's unlikely that all WebAssembly runtimes will end up implementing
SIMD so the standard library is unlikely to use SIMD any time soon, but
we want to make sure it's easily available to folks! This commit enables
all this by ensuring that SIMD is available to the standard library,
regardless of compilation flags.

This'll come with the same caveats as x86 support, where it doesn't make
sense to call these functions unless you're enabling simd support one
way or another locally. Additionally, as with x86, if you don't call
these functions then the instructions won't show up in your binary.

While I was here I went ahead and expanded the WebAssembly-specific
documentation for the wasm32 module as well, ensuring that the current
state of SIMD/Atomics are documented.
2020-07-18 13:32:52 +01:00
Mahmut Bulut
4541757677 feature detection 2020-05-29 19:05:48 +01:00
Tobias Kortkamp
a69b5ec7ae Unbreak non-x86 build on FreeBSD
error[E0432]: unresolved import `self::arm::check_for`
  --> src/libstd/../stdarch/crates/std_detect/src/detect/os/freebsd/mod.rs:11:17
   |
11 |         pub use self::arm::check_for;
   |                 ^^^^^^^^^^^^^^^^^^^^ no `check_for` in `std_detect::detect::os::arm`

error[E0425]: cannot find value `detect_features` in module `self::os`
   --> src/libstd/../stdarch/crates/std_detect/src/detect/mod.rs:121:37
    |
121 |     cache::test(x as u32, self::os::detect_features)
    |                                     ^^^^^^^^^^^^^^^ not found in `self::os`
    |
help: possible candidate is found in another module, you can import it into scope
    |
20  | use crate::std_detect::detect::os::arm::detect_features;
2020-04-24 12:45:05 +01:00
Amanieu d'Antras
39fc893f6b Stabilize all remaining x86 features for feature detection 2020-04-24 00:36:01 +01:00
Amanieu d'Antras
04c1a9a9e9 Use llvm_asm! instead of asm! (#846) 2020-04-09 00:05:10 +01:00
Linus Färnstrand
f14b746319 Replace all max/min_value() with MAX/MIN 2020-04-04 09:51:11 -07:00
Linus Färnstrand
b852344de5 Replace module MIN/MAX and min/max_value() with assoc consts (#843) 2020-03-29 17:08:21 +01:00
Makoto Kato
09ef01ade1 Add crypto target feature detection to arm32 (#833) 2020-03-29 12:28:17 +01:00
Jack O'Connor
e367bcd7f9 re-stabilize the AVX-512 features that were stabilized in Rust 1.27.0 (#842)
* re-stabilize the AVX-512 features that were stabilized in Rust 1.27.0

https://github.com/rust-lang/stdarch/pull/739 added per-feature
stabilization of runtime CPU feature detection. In so doing, it
de-stabilized some detection features that had been stable since Rust
1.27.0, breaking some published crates (on nightly). This commit
re-stabilizes the subset of AVX-512 detection features that were
included in 1.27.0 (that is, the pre-Ice-Lake subset). Other instruction
sets (MMX in particular) remain de-stabilized, pending a decision about
whether should ever stabilize them.

See https://github.com/rust-lang/rust/issues/68905.

* add a comment explaining feature detection stability

* adjust stabilizations to match most recent proposal

https://github.com/rust-lang/rust/issues/68905#issuecomment-595376319
2020-03-19 14:29:50 +00:00