| 1 |
# [RustCrypto]: CPU Feature Detection |
| 2 |
|
| 3 |
[![crate][crate-image]][crate-link] |
| 4 |
[![Docs][docs-image]][docs-link] |
| 5 |
![Apache2/MIT licensed][license-image] |
| 6 |
![Rust Version][rustc-image] |
| 7 |
[![Project Chat][chat-image]][chat-link] |
| 8 |
[![Build Status][build-image]][build-link] |
| 9 |
|
| 10 |
Lightweight and efficient runtime CPU feature detection for `aarch64`, `loongarch64`, and |
| 11 |
`x86`/`x86_64` targets. |
| 12 |
|
| 13 |
Supports `no_std` as well as mobile targets including iOS and Android, |
| 14 |
providing an alternative to the `std`-dependent `is_x86_feature_detected!` |
| 15 |
macro. |
| 16 |
|
| 17 |
[Documentation][docs-link] |
| 18 |
|
| 19 |
# Supported target architectures |
| 20 |
|
| 21 |
*NOTE: target features with an asterisk are unstable (nightly-only) and subject |
| 22 |
to change to match upstream name changes in the Rust standard library. |
| 23 |
|
| 24 |
## `aarch64` |
| 25 |
|
| 26 |
Linux, iOS, and macOS/ARM only (ARM64 does not support OS-independent feature detection) |
| 27 |
|
| 28 |
Target features: |
| 29 |
|
| 30 |
- `aes`* |
| 31 |
- `sha2`* |
| 32 |
- `sha3`* |
| 33 |
|
| 34 |
## `loongarch64` |
| 35 |
|
| 36 |
Linux only (LoongArch64 does not support OS-independent feature detection) |
| 37 |
|
| 38 |
Target features: |
| 39 |
|
| 40 |
- `lam`* |
| 41 |
- `ual`* |
| 42 |
- `fpu`* |
| 43 |
- `lsx`* |
| 44 |
- `lasx`* |
| 45 |
- `crc32`* |
| 46 |
- `complex`* |
| 47 |
- `crypto`* |
| 48 |
- `lvz`* |
| 49 |
- `lbt.x86`* |
| 50 |
- `lbt.arm`* |
| 51 |
- `lbt.mips`* |
| 52 |
- `ptw`* |
| 53 |
|
| 54 |
## `x86`/`x86_64` |
| 55 |
|
| 56 |
OS independent and `no_std`-friendly |
| 57 |
|
| 58 |
Target features: |
| 59 |
|
| 60 |
- `adx` |
| 61 |
- `aes` |
| 62 |
- `avx` |
| 63 |
- `avx2` |
| 64 |
- `avx512bw`* |
| 65 |
- `avx512cd`* |
| 66 |
- `avx512dq`* |
| 67 |
- `avx512er`* |
| 68 |
- `avx512f`* |
| 69 |
- `avx512ifma`* |
| 70 |
- `avx512pf`* |
| 71 |
- `avx512vl`* |
| 72 |
- `avx512vbmi`* |
| 73 |
- `avx512vbmi2`* |
| 74 |
- `bmi1` |
| 75 |
- `bmi2` |
| 76 |
- `fma`, |
| 77 |
- `mmx` |
| 78 |
- `pclmulqdq` |
| 79 |
- `popcnt` |
| 80 |
- `rdrand` |
| 81 |
- `rdseed` |
| 82 |
- `sgx` |
| 83 |
- `sha` |
| 84 |
- `sse` |
| 85 |
- `sse2` |
| 86 |
- `sse3` |
| 87 |
- `sse4.1` |
| 88 |
- `sse4.2` |
| 89 |
- `ssse3` |
| 90 |
|
| 91 |
If you would like detection support for a target feature which is not on |
| 92 |
this list, please [open a GitHub issue]. |
| 93 |
|
| 94 |
## License |
| 95 |
|
| 96 |
Licensed under either of: |
| 97 |
|
| 98 |
* [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0) |
| 99 |
* [MIT license](http://opensource.org/licenses/MIT) |
| 100 |
|
| 101 |
at your option. |
| 102 |
|
| 103 |
### Contribution |
| 104 |
|
| 105 |
Unless you explicitly state otherwise, any contribution intentionally submitted |
| 106 |
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be |
| 107 |
dual licensed as above, without any additional terms or conditions. |
| 108 |
|
| 109 |
[//]: # (badges) |
| 110 |
|
| 111 |
[crate-image]: https://img.shields.io/crates/v/cpufeatures.svg |
| 112 |
[crate-link]: https://crates.io/crates/cpufeatures |
| 113 |
[docs-image]: https://docs.rs/cpufeatures/badge.svg |
| 114 |
[docs-link]: https://docs.rs/cpufeatures/ |
| 115 |
[license-image]: https://img.shields.io/badge/license-Apache2.0/MIT-blue.svg |
| 116 |
[rustc-image]: https://img.shields.io/badge/rustc-1.40+-blue.svg |
| 117 |
[chat-image]: https://img.shields.io/badge/zulip-join_chat-blue.svg |
| 118 |
[chat-link]: https://rustcrypto.zulipchat.com/#narrow/stream/260052-utils |
| 119 |
[build-image]: https://github.com/RustCrypto/utils/workflows/cpufeatures/badge.svg?branch=master&event=push |
| 120 |
[build-link]: https://github.com/RustCrypto/utils/actions/workflows/cpufeatures.yml |
| 121 |
|
| 122 |
[//]: # (general links) |
| 123 |
|
| 124 |
[RustCrypto]: https://github.com/rustcrypto |
| 125 |
[RustCrypto/utils#378]: https://github.com/RustCrypto/utils/issues/378 |
| 126 |
[open a GitHub issue]: https://github.com/RustCrypto/utils/issues/new?title=cpufeatures:%20requesting%20support%20for%20CHANGEME%20target%20feature |