Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/Cargo.toml +26 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/README.md +69 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/aarch64.rs +264 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/arm.rs +32 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/loongarch.rs +58 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/mips.rs +15 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/mips64.rs +15 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/mod.rs +83 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/powerpc.rs +33 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/powerpc64.rs +33 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/riscv.rs +380 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/s390x.rs +61 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/x86.rs +280 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/bit.rs +9 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/cache.rs +203 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/macros.rs +203 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/mod.rs +125 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/aarch64.rs +127 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/darwin/aarch64.rs +166 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/aarch64.rs +3 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/arm.rs +36 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/auxvec.rs +63 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/mod.rs +25 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/powerpc.rs +21 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/aarch64.rs +409 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/aarch64/tests.rs +70 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/arm.rs +34 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/auxvec.rs +221 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/auxvec/tests.rs +108 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/loongarch.rs +60 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/mips.rs +23 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/mod.rs +74 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/powerpc.rs +35 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/riscv.rs +323 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/s390x.rs +152 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/openbsd/aarch64.rs +57 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/openbsd/auxvec.rs +54 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/openbsd/mod.rs +21 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/openbsd/powerpc.rs +21 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/other.rs +8 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/riscv.rs +159 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/riscv/tests.rs +64 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/windows/aarch64.rs +125 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/x86.rs +330 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-artificial-aarch64.auxv +0 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-empty-hwcap2-aarch64.auxv +0 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-hwcap2-aarch64.auxv +0 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-no-hwcap2-aarch64.auxv +0 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-rpi3.auxv +0 -0
- rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv +0 -0
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/Cargo.toml
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "std_detect"
|
| 3 |
+
version = "0.1.5"
|
| 4 |
+
authors = [
|
| 5 |
+
"Alex Crichton <alex@alexcrichton.com>",
|
| 6 |
+
"Andrew Gallant <jamslam@gmail.com>",
|
| 7 |
+
"Gonzalo Brito Gadeschi <gonzalobg88@gmail.com>",
|
| 8 |
+
]
|
| 9 |
+
description = "`std::detect` - Rust's standard library run-time CPU feature detection."
|
| 10 |
+
license = "MIT OR Apache-2.0"
|
| 11 |
+
edition = "2024"
|
| 12 |
+
|
| 13 |
+
[badges]
|
| 14 |
+
is-it-maintained-issue-resolution = { repository = "rust-lang/stdarch" }
|
| 15 |
+
is-it-maintained-open-issues = { repository = "rust-lang/stdarch" }
|
| 16 |
+
maintenance = { status = "experimental" }
|
| 17 |
+
|
| 18 |
+
[dependencies]
|
| 19 |
+
core = { version = "1.0.0", package = 'rustc-std-workspace-core' }
|
| 20 |
+
alloc = { version = "1.0.0", package = 'rustc-std-workspace-alloc' }
|
| 21 |
+
|
| 22 |
+
[target.'cfg(not(windows))'.dependencies]
|
| 23 |
+
libc = { version = "0.2.0", default-features = false }
|
| 24 |
+
|
| 25 |
+
[features]
|
| 26 |
+
std_detect_env_override = []
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
`std::detect` - Rust's standard library run-time CPU feature detection
|
| 2 |
+
=======
|
| 3 |
+
|
| 4 |
+
The private `std::detect` module implements run-time feature detection in Rust's
|
| 5 |
+
standard library. This allows detecting whether the CPU the binary runs on
|
| 6 |
+
supports certain features, like SIMD instructions.
|
| 7 |
+
|
| 8 |
+
# Usage
|
| 9 |
+
|
| 10 |
+
`std::detect` APIs are available as part of `libstd`. Prefer using it via the
|
| 11 |
+
standard library than through this crate. Unstable features of `std::detect` are
|
| 12 |
+
available on nightly Rust behind various feature-gates.
|
| 13 |
+
|
| 14 |
+
If you need run-time feature detection in `#[no_std]` environments, Rust `core`
|
| 15 |
+
library cannot help you. By design, Rust `core` is platform independent, but
|
| 16 |
+
performing run-time feature detection requires a certain level of cooperation
|
| 17 |
+
from the platform.
|
| 18 |
+
|
| 19 |
+
You can then manually include `std_detect` as a dependency to get similar
|
| 20 |
+
run-time feature detection support than the one offered by Rust's standard
|
| 21 |
+
library. We intend to make `std_detect` more flexible and configurable in this
|
| 22 |
+
regard to better serve the needs of `#[no_std]` targets.
|
| 23 |
+
|
| 24 |
+
# Platform support
|
| 25 |
+
|
| 26 |
+
* All `x86`/`x86_64` targets are supported on all platforms by querying the
|
| 27 |
+
`cpuid` instruction directly for the features supported by the hardware and
|
| 28 |
+
the operating system. `std_detect` assumes that the binary is an user-space
|
| 29 |
+
application.
|
| 30 |
+
|
| 31 |
+
* Linux/Android:
|
| 32 |
+
* `arm{32, 64}`, `mips{32,64}{,el}`, `powerpc{32,64}{,le}`, `loongarch{32,64}`, `s390x`:
|
| 33 |
+
`std_detect` supports these on Linux by querying ELF auxiliary vectors (using `getauxval`
|
| 34 |
+
when available), and if that fails, by querying `/proc/self/auxv`.
|
| 35 |
+
* `arm64`: partial support for doing run-time feature detection by directly
|
| 36 |
+
querying `mrs` is implemented for Linux >= 4.11, but not enabled by default.
|
| 37 |
+
* `riscv{32,64}`:
|
| 38 |
+
`std_detect` supports these on Linux by querying `riscv_hwprobe`, and
|
| 39 |
+
by querying ELF auxiliary vectors (using `getauxval` when available).
|
| 40 |
+
|
| 41 |
+
* FreeBSD:
|
| 42 |
+
* `arm32`, `powerpc64`: `std_detect` supports these on FreeBSD by querying ELF
|
| 43 |
+
auxiliary vectors using `elf_aux_info`.
|
| 44 |
+
* `arm64`: run-time feature detection is implemented by directly querying `mrs`.
|
| 45 |
+
|
| 46 |
+
* OpenBSD:
|
| 47 |
+
* `powerpc64`: `std_detect` supports these on OpenBSD by querying ELF auxiliary
|
| 48 |
+
vectors using `elf_aux_info`.
|
| 49 |
+
* `arm64`: run-time feature detection is implemented by querying `sysctl`.
|
| 50 |
+
|
| 51 |
+
* Windows:
|
| 52 |
+
* `arm64`: run-time feature detection is implemented by querying `IsProcessorFeaturePresent`.
|
| 53 |
+
|
| 54 |
+
# License
|
| 55 |
+
|
| 56 |
+
This project is licensed under either of
|
| 57 |
+
|
| 58 |
+
* Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
| 59 |
+
http://www.apache.org/licenses/LICENSE-2.0)
|
| 60 |
+
* MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
| 61 |
+
http://opensource.org/licenses/MIT)
|
| 62 |
+
|
| 63 |
+
at your option.
|
| 64 |
+
|
| 65 |
+
# Contribution
|
| 66 |
+
|
| 67 |
+
Unless you explicitly state otherwise, any contribution intentionally submitted
|
| 68 |
+
for inclusion in `std_detect` by you, as defined in the Apache-2.0 license,
|
| 69 |
+
shall be dual licensed as above, without any additional terms or conditions.
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/aarch64.rs
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Aarch64 run-time features.
|
| 2 |
+
|
| 3 |
+
features! {
|
| 4 |
+
@TARGET: aarch64;
|
| 5 |
+
@CFG: any(target_arch = "aarch64", target_arch = "arm64ec");
|
| 6 |
+
@MACRO_NAME: is_aarch64_feature_detected;
|
| 7 |
+
@MACRO_ATTRS:
|
| 8 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 9 |
+
///
|
| 10 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 11 |
+
/// the macro expands to `true`.
|
| 12 |
+
///
|
| 13 |
+
/// This macro takes one argument which is a string literal of the feature being tested for.
|
| 14 |
+
/// The feature names are mostly taken from their FEAT_* definitions in the [ARM Architecture
|
| 15 |
+
/// Reference Manual][docs].
|
| 16 |
+
///
|
| 17 |
+
/// Currently most features are only supported on linux-based platforms: on other platforms the
|
| 18 |
+
/// runtime check will always return `false`.
|
| 19 |
+
///
|
| 20 |
+
/// ## Supported arguments
|
| 21 |
+
///
|
| 22 |
+
/// * `"aes"` - FEAT_AES & FEAT_PMULL
|
| 23 |
+
/// * `"asimd"` or "neon" - FEAT_AdvSIMD
|
| 24 |
+
/// * `"bf16"` - FEAT_BF16
|
| 25 |
+
/// * `"bti"` - FEAT_BTI
|
| 26 |
+
/// * `"crc"` - FEAT_CRC
|
| 27 |
+
/// * `"cssc"` - FEAT_CSSC
|
| 28 |
+
/// * `"dit"` - FEAT_DIT
|
| 29 |
+
/// * `"dotprod"` - FEAT_DotProd
|
| 30 |
+
/// * `"dpb"` - FEAT_DPB
|
| 31 |
+
/// * `"dpb2"` - FEAT_DPB2
|
| 32 |
+
/// * `"ecv"` - FEAT_ECV
|
| 33 |
+
/// * `"f32mm"` - FEAT_F32MM
|
| 34 |
+
/// * `"f64mm"` - FEAT_F64MM
|
| 35 |
+
/// * `"faminmax"` - FEAT_FAMINMAX
|
| 36 |
+
/// * `"fcma"` - FEAT_FCMA
|
| 37 |
+
/// * `"fhm"` - FEAT_FHM
|
| 38 |
+
/// * `"flagm"` - FEAT_FLAGM
|
| 39 |
+
/// * `"flagm2"` - FEAT_FLAGM2
|
| 40 |
+
/// * `"fp"` - FEAT_FP
|
| 41 |
+
/// * `"fp16"` - FEAT_FP16
|
| 42 |
+
/// * `"fp8"` - FEAT_FP8
|
| 43 |
+
/// * `"fp8dot2"` - FEAT_FP8DOT2
|
| 44 |
+
/// * `"fp8dot4"` - FEAT_FP8DOT4
|
| 45 |
+
/// * `"fp8fma"` - FEAT_FP8FMA
|
| 46 |
+
/// * `"fpmr"` - FEAT_FPMR
|
| 47 |
+
/// * `"frintts"` - FEAT_FRINTTS
|
| 48 |
+
/// * `"hbc"` - FEAT_HBC
|
| 49 |
+
/// * `"i8mm"` - FEAT_I8MM
|
| 50 |
+
/// * `"jsconv"` - FEAT_JSCVT
|
| 51 |
+
/// * `"lse"` - FEAT_LSE
|
| 52 |
+
/// * `"lse128"` - FEAT_LSE128
|
| 53 |
+
/// * `"lse2"` - FEAT_LSE2
|
| 54 |
+
/// * `"lut"` - FEAT_LUT
|
| 55 |
+
/// * `"mops"` - FEAT_MOPS
|
| 56 |
+
/// * `"mte"` - FEAT_MTE & FEAT_MTE2
|
| 57 |
+
/// * `"paca"` - FEAT_PAuth (address authentication)
|
| 58 |
+
/// * `"pacg"` - FEAT_Pauth (generic authentication)
|
| 59 |
+
/// * `"pauth-lr"` - FEAT_PAuth_LR
|
| 60 |
+
/// * `"pmull"` - FEAT_PMULL
|
| 61 |
+
/// * `"rand"` - FEAT_RNG
|
| 62 |
+
/// * `"rcpc"` - FEAT_LRCPC
|
| 63 |
+
/// * `"rcpc2"` - FEAT_LRCPC2
|
| 64 |
+
/// * `"rcpc3"` - FEAT_LRCPC3
|
| 65 |
+
/// * `"rdm"` - FEAT_RDM
|
| 66 |
+
/// * `"sb"` - FEAT_SB
|
| 67 |
+
/// * `"sha2"` - FEAT_SHA1 & FEAT_SHA256
|
| 68 |
+
/// * `"sha3"` - FEAT_SHA512 & FEAT_SHA3
|
| 69 |
+
/// * `"sm4"` - FEAT_SM3 & FEAT_SM4
|
| 70 |
+
/// * `"sme"` - FEAT_SME
|
| 71 |
+
/// * `"sme-b16b16"` - FEAT_SME_B16B16
|
| 72 |
+
/// * `"sme-f16f16"` - FEAT_SME_F16F16
|
| 73 |
+
/// * `"sme-f64f64"` - FEAT_SME_F64F64
|
| 74 |
+
/// * `"sme-f8f16"` - FEAT_SME_F8F16
|
| 75 |
+
/// * `"sme-f8f32"` - FEAT_SME_F8F32
|
| 76 |
+
/// * `"sme-fa64"` - FEAT_SME_FA64
|
| 77 |
+
/// * `"sme-i16i64"` - FEAT_SME_I16I64
|
| 78 |
+
/// * `"sme-lutv2"` - FEAT_SME_LUTv2
|
| 79 |
+
/// * `"sme2"` - FEAT_SME2
|
| 80 |
+
/// * `"sme2p1"` - FEAT_SME2p1
|
| 81 |
+
/// * `"ssbs"` - FEAT_SSBS & FEAT_SSBS2
|
| 82 |
+
/// * `"ssve-fp8dot2"` - FEAT_SSVE_FP8DOT2
|
| 83 |
+
/// * `"ssve-fp8dot4"` - FEAT_SSVE_FP8DOT4
|
| 84 |
+
/// * `"ssve-fp8fma"` - FEAT_SSVE_FP8FMA
|
| 85 |
+
/// * `"sve"` - FEAT_SVE
|
| 86 |
+
/// * `"sve-b16b16"` - FEAT_SVE_B16B16 (SVE or SME Z-targeting instructions)
|
| 87 |
+
/// * `"sve2"` - FEAT_SVE2
|
| 88 |
+
/// * `"sve2-aes"` - FEAT_SVE_AES & FEAT_SVE_PMULL128 (SVE2 AES crypto)
|
| 89 |
+
/// * `"sve2-bitperm"` - FEAT_SVE2_BitPerm
|
| 90 |
+
/// * `"sve2-sha3"` - FEAT_SVE2_SHA3
|
| 91 |
+
/// * `"sve2-sm4"` - FEAT_SVE2_SM4
|
| 92 |
+
/// * `"sve2p1"` - FEAT_SVE2p1
|
| 93 |
+
/// * `"tme"` - FEAT_TME
|
| 94 |
+
/// * `"wfxt"` - FEAT_WFxT
|
| 95 |
+
///
|
| 96 |
+
/// [docs]: https://developer.arm.com/documentation/ddi0487/latest
|
| 97 |
+
#[stable(feature = "simd_aarch64", since = "1.60.0")]
|
| 98 |
+
@BIND_FEATURE_NAME: "asimd"; "neon";
|
| 99 |
+
@NO_RUNTIME_DETECTION: "ras";
|
| 100 |
+
@NO_RUNTIME_DETECTION: "v8.1a";
|
| 101 |
+
@NO_RUNTIME_DETECTION: "v8.2a";
|
| 102 |
+
@NO_RUNTIME_DETECTION: "v8.3a";
|
| 103 |
+
@NO_RUNTIME_DETECTION: "v8.4a";
|
| 104 |
+
@NO_RUNTIME_DETECTION: "v8.5a";
|
| 105 |
+
@NO_RUNTIME_DETECTION: "v8.6a";
|
| 106 |
+
@NO_RUNTIME_DETECTION: "v8.7a";
|
| 107 |
+
@NO_RUNTIME_DETECTION: "v8.8a";
|
| 108 |
+
@NO_RUNTIME_DETECTION: "v8.9a";
|
| 109 |
+
@NO_RUNTIME_DETECTION: "v9.1a";
|
| 110 |
+
@NO_RUNTIME_DETECTION: "v9.2a";
|
| 111 |
+
@NO_RUNTIME_DETECTION: "v9.3a";
|
| 112 |
+
@NO_RUNTIME_DETECTION: "v9.4a";
|
| 113 |
+
@NO_RUNTIME_DETECTION: "v9.5a";
|
| 114 |
+
@NO_RUNTIME_DETECTION: "v9a";
|
| 115 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] asimd: "neon";
|
| 116 |
+
/// FEAT_AdvSIMD (Advanced SIMD/NEON)
|
| 117 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] pmull: "pmull";
|
| 118 |
+
implied by target_features: ["aes"];
|
| 119 |
+
/// FEAT_PMULL (Polynomial Multiply) - Implied by `aes` target_feature
|
| 120 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fp: "fp";
|
| 121 |
+
implied by target_features: ["neon"];
|
| 122 |
+
/// FEAT_FP (Floating point support) - Implied by `neon` target_feature
|
| 123 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] aes: "aes";
|
| 124 |
+
/// FEAT_AES (AES SIMD instructions) & FEAT_PMULL (PMULL{2}, 64-bit operand variants)
|
| 125 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] bf16: "bf16";
|
| 126 |
+
/// FEAT_BF16 (BFloat16 type, plus MM instructions, plus ASIMD support)
|
| 127 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] bti: "bti";
|
| 128 |
+
/// FEAT_BTI (Branch Target Identification)
|
| 129 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] crc: "crc";
|
| 130 |
+
/// FEAT_CRC32 (Cyclic Redundancy Check)
|
| 131 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] cssc: "cssc";
|
| 132 |
+
/// FEAT_CSSC (Common Short Sequence Compression instructions)
|
| 133 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dit: "dit";
|
| 134 |
+
/// FEAT_DIT (Data Independent Timing instructions)
|
| 135 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dpb: "dpb";
|
| 136 |
+
/// FEAT_DPB (aka dcpop - data cache clean to point of persistence)
|
| 137 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dpb2: "dpb2";
|
| 138 |
+
/// FEAT_DPB2 (aka dcpodp - data cache clean to point of deep persistence)
|
| 139 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] dotprod: "dotprod";
|
| 140 |
+
/// FEAT_DotProd (Vector Dot-Product - ASIMDDP)
|
| 141 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] ecv: "ecv";
|
| 142 |
+
/// FEAT_ECV (Enhanced Counter Virtualization)
|
| 143 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] f32mm: "f32mm";
|
| 144 |
+
/// FEAT_F32MM (single-precision matrix multiplication)
|
| 145 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] f64mm: "f64mm";
|
| 146 |
+
/// FEAT_F64MM (double-precision matrix multiplication)
|
| 147 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] faminmax: "faminmax";
|
| 148 |
+
/// FEAT_FAMINMAX (FAMIN and FAMAX SIMD/SVE/SME instructions)
|
| 149 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fcma: "fcma";
|
| 150 |
+
/// FEAT_FCMA (float complex number operations)
|
| 151 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fhm: "fhm";
|
| 152 |
+
/// FEAT_FHM (fp16 multiplication instructions)
|
| 153 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] flagm: "flagm";
|
| 154 |
+
/// FEAT_FLAGM (flag manipulation instructions)
|
| 155 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] flagm2: "flagm2";
|
| 156 |
+
/// FEAT_FLAGM2 (flag manipulation instructions)
|
| 157 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] fp16: "fp16";
|
| 158 |
+
/// FEAT_FP16 (Half-float support)
|
| 159 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] fp8: "fp8";
|
| 160 |
+
/// FEAT_FP8 (F8CVT Instructions)
|
| 161 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] fp8dot2: "fp8dot2";
|
| 162 |
+
/// FEAT_FP8DOT2 (F8DP2 Instructions)
|
| 163 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] fp8dot4: "fp8dot4";
|
| 164 |
+
/// FEAT_FP8DOT4 (F8DP4 Instructions)
|
| 165 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] fp8fma: "fp8fma";
|
| 166 |
+
/// FEAT_FP8FMA (F8FMA Instructions)
|
| 167 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] fpmr: "fpmr";
|
| 168 |
+
without cfg check: true;
|
| 169 |
+
/// FEAT_FPMR (Special-purpose AArch64-FPMR register)
|
| 170 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] frintts: "frintts";
|
| 171 |
+
/// FEAT_FRINTTS (float to integer rounding instructions)
|
| 172 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] hbc: "hbc";
|
| 173 |
+
/// FEAT_HBC (Hinted conditional branches)
|
| 174 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] i8mm: "i8mm";
|
| 175 |
+
/// FEAT_I8MM (integer matrix multiplication, plus ASIMD support)
|
| 176 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] jsconv: "jsconv";
|
| 177 |
+
/// FEAT_JSCVT (JavaScript float conversion instructions)
|
| 178 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] lse: "lse";
|
| 179 |
+
/// FEAT_LSE (Large System Extension - atomics)
|
| 180 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] lse128: "lse128";
|
| 181 |
+
/// FEAT_LSE128 (128-bit atomics)
|
| 182 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] lse2: "lse2";
|
| 183 |
+
/// FEAT_LSE2 (unaligned and register-pair atomics)
|
| 184 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] lut: "lut";
|
| 185 |
+
/// FEAT_LUT (Lookup Table Instructions)
|
| 186 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] mops: "mops";
|
| 187 |
+
/// FEAT_MOPS (Standardization of memory operations)
|
| 188 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] mte: "mte";
|
| 189 |
+
/// FEAT_MTE & FEAT_MTE2 (Memory Tagging Extension)
|
| 190 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] paca: "paca";
|
| 191 |
+
/// FEAT_PAuth (address authentication)
|
| 192 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] pacg: "pacg";
|
| 193 |
+
/// FEAT_PAuth (generic authentication)
|
| 194 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] pauth_lr: "pauth-lr";
|
| 195 |
+
/// FEAT_PAuth_LR
|
| 196 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] rand: "rand";
|
| 197 |
+
/// FEAT_RNG (Random Number Generator)
|
| 198 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] rcpc: "rcpc";
|
| 199 |
+
/// FEAT_LRCPC (Release consistent Processor consistent)
|
| 200 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] rcpc2: "rcpc2";
|
| 201 |
+
/// FEAT_LRCPC2 (RCPC with immediate offsets)
|
| 202 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] rcpc3: "rcpc3";
|
| 203 |
+
/// FEAT_LRCPC3 (RCPC Instructions v3)
|
| 204 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] rdm: "rdm";
|
| 205 |
+
/// FEAT_RDM (Rounding Doubling Multiply - ASIMDRDM)
|
| 206 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sb: "sb";
|
| 207 |
+
/// FEAT_SB (speculation barrier)
|
| 208 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sha2: "sha2";
|
| 209 |
+
/// FEAT_SHA1 & FEAT_SHA256 (SHA1 & SHA2-256 instructions)
|
| 210 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sha3: "sha3";
|
| 211 |
+
/// FEAT_SHA512 & FEAT_SHA3 (SHA2-512 & SHA3 instructions)
|
| 212 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sm4: "sm4";
|
| 213 |
+
/// FEAT_SM3 & FEAT_SM4 (SM3 & SM4 instructions)
|
| 214 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme: "sme";
|
| 215 |
+
/// FEAT_SME (Scalable Matrix Extension)
|
| 216 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme2: "sme2";
|
| 217 |
+
/// FEAT_SME2 (SME Version 2)
|
| 218 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme2p1: "sme2p1";
|
| 219 |
+
/// FEAT_SME2p1 (SME Version 2.1)
|
| 220 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme_b16b16: "sme-b16b16";
|
| 221 |
+
/// FEAT_SME_B16B16
|
| 222 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme_f16f16: "sme-f16f16";
|
| 223 |
+
/// FEAT_SME_F16F16 (Non-widening half-precision FP16 to FP16 arithmetic for SME2)
|
| 224 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme_f64f64: "sme-f64f64";
|
| 225 |
+
/// FEAT_SME_F64F64 (Double-precision floating-point outer product instructions)
|
| 226 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme_f8f16: "sme-f8f16";
|
| 227 |
+
/// FEAT_SME_F8F16
|
| 228 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme_f8f32: "sme-f8f32";
|
| 229 |
+
/// FEAT_SME_F8F32
|
| 230 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme_fa64: "sme-fa64";
|
| 231 |
+
/// FEAT_SME_FA64 (Full A64 instruction set support in Streaming SVE mode)
|
| 232 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme_i16i64: "sme-i16i64";
|
| 233 |
+
/// FEAT_SME_I16I64 (16-bit to 64-bit integer widening outer product instructions)
|
| 234 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sme_lutv2: "sme-lutv2";
|
| 235 |
+
/// FEAT_SME_LUTv2 (LUTI4 Instruction)
|
| 236 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] ssbs: "ssbs";
|
| 237 |
+
/// FEAT_SSBS & FEAT_SSBS2 (speculative store bypass safe)
|
| 238 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] ssve_fp8dot2: "ssve-fp8dot2";
|
| 239 |
+
/// FEAT_SSVE_FP8DOT2
|
| 240 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] ssve_fp8dot4: "ssve-fp8dot4";
|
| 241 |
+
/// FEAT_SSVE_FP8DOT4
|
| 242 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] ssve_fp8fma: "ssve-fp8fma";
|
| 243 |
+
/// FEAT_SSVE_FP8FMA
|
| 244 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve: "sve";
|
| 245 |
+
/// FEAT_SVE (Scalable Vector Extension)
|
| 246 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2: "sve2";
|
| 247 |
+
/// FEAT_SVE2 (Scalable Vector Extension 2)
|
| 248 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sve2p1: "sve2p1";
|
| 249 |
+
/// FEAT_SVE2p1 (Scalable Vector Extension 2.1)
|
| 250 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2_aes: "sve2-aes";
|
| 251 |
+
/// FEAT_SVE_AES & FEAT_SVE_PMULL128 (SVE2 AES crypto)
|
| 252 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] sve_b16b16: "sve-b16b16";
|
| 253 |
+
/// FEAT_SVE_B16B16 (SVE or SME Z-targeting instructions)
|
| 254 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2_bitperm: "sve2-bitperm";
|
| 255 |
+
/// FEAT_SVE_BitPerm (SVE2 bit permutation instructions)
|
| 256 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2_sha3: "sve2-sha3";
|
| 257 |
+
/// FEAT_SVE_SHA3 (SVE2 SHA3 crypto)
|
| 258 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] sve2_sm4: "sve2-sm4";
|
| 259 |
+
/// FEAT_SVE_SM4 (SVE2 SM4 crypto)
|
| 260 |
+
@FEATURE: #[stable(feature = "simd_aarch64", since = "1.60.0")] tme: "tme";
|
| 261 |
+
/// FEAT_TME (Transactional Memory Extensions)
|
| 262 |
+
@FEATURE: #[unstable(feature = "stdarch_aarch64_feature_detection", issue = "127764")] wfxt: "wfxt";
|
| 263 |
+
/// FEAT_WFxT (WFET and WFIT Instructions)
|
| 264 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/arm.rs
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on ARM Aarch32.
|
| 2 |
+
|
| 3 |
+
features! {
|
| 4 |
+
@TARGET: arm;
|
| 5 |
+
@CFG: target_arch = "arm";
|
| 6 |
+
@MACRO_NAME: is_arm_feature_detected;
|
| 7 |
+
@MACRO_ATTRS:
|
| 8 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 9 |
+
///
|
| 10 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 11 |
+
/// the macro expands to `true`.
|
| 12 |
+
#[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")]
|
| 13 |
+
@NO_RUNTIME_DETECTION: "v7";
|
| 14 |
+
@NO_RUNTIME_DETECTION: "vfp2";
|
| 15 |
+
@NO_RUNTIME_DETECTION: "vfp3";
|
| 16 |
+
@NO_RUNTIME_DETECTION: "vfp4";
|
| 17 |
+
@FEATURE: #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")] neon: "neon";
|
| 18 |
+
/// ARM Advanced SIMD (NEON) - Aarch32
|
| 19 |
+
@FEATURE: #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")] pmull: "pmull";
|
| 20 |
+
without cfg check: true;
|
| 21 |
+
/// Polynomial Multiply
|
| 22 |
+
@FEATURE: #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")] crc: "crc";
|
| 23 |
+
/// CRC32 (Cyclic Redundancy Check)
|
| 24 |
+
@FEATURE: #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")] aes: "aes";
|
| 25 |
+
/// FEAT_AES (AES instructions)
|
| 26 |
+
@FEATURE: #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")] sha2: "sha2";
|
| 27 |
+
/// FEAT_SHA1 & FEAT_SHA256 (SHA1 & SHA2-256 instructions)
|
| 28 |
+
@FEATURE: #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")] i8mm: "i8mm";
|
| 29 |
+
/// FEAT_I8MM (integer matrix multiplication, plus ASIMD support)
|
| 30 |
+
@FEATURE: #[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")] dotprod: "dotprod";
|
| 31 |
+
/// FEAT_DotProd (Vector Dot-Product - ASIMDDP)
|
| 32 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/loongarch.rs
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on LoongArch.
|
| 2 |
+
|
| 3 |
+
features! {
|
| 4 |
+
@TARGET: loongarch;
|
| 5 |
+
@CFG: any(target_arch = "loongarch32", target_arch = "loongarch64");
|
| 6 |
+
@MACRO_NAME: is_loongarch_feature_detected;
|
| 7 |
+
@MACRO_ATTRS:
|
| 8 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 9 |
+
///
|
| 10 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 11 |
+
/// the macro expands to `true`.
|
| 12 |
+
///
|
| 13 |
+
/// Supported arguments are:
|
| 14 |
+
///
|
| 15 |
+
/// * `"32s"`
|
| 16 |
+
/// * `"f"`
|
| 17 |
+
/// * `"d"`
|
| 18 |
+
/// * `"frecipe"`
|
| 19 |
+
/// * `"div32"`
|
| 20 |
+
/// * `"lsx"`
|
| 21 |
+
/// * `"lasx"`
|
| 22 |
+
/// * `"lam-bh"`
|
| 23 |
+
/// * `"lamcas"`
|
| 24 |
+
/// * `"ld-seq-sa"`
|
| 25 |
+
/// * `"scq"`
|
| 26 |
+
/// * `"lbt"`
|
| 27 |
+
/// * `"lvz"`
|
| 28 |
+
/// * `"ual"`
|
| 29 |
+
#[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")]
|
| 30 |
+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] _32s: "32s";
|
| 31 |
+
/// 32S
|
| 32 |
+
@FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] f: "f";
|
| 33 |
+
/// F
|
| 34 |
+
@FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] d: "d";
|
| 35 |
+
/// D
|
| 36 |
+
@FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] frecipe: "frecipe";
|
| 37 |
+
/// Frecipe
|
| 38 |
+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] div32: "div32";
|
| 39 |
+
/// Div32
|
| 40 |
+
@FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] lsx: "lsx";
|
| 41 |
+
/// LSX
|
| 42 |
+
@FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] lasx: "lasx";
|
| 43 |
+
/// LASX
|
| 44 |
+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lam_bh: "lam-bh";
|
| 45 |
+
/// LAM-BH
|
| 46 |
+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] lamcas: "lamcas";
|
| 47 |
+
/// LAM-CAS
|
| 48 |
+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] ld_seq_sa: "ld-seq-sa";
|
| 49 |
+
/// LD-SEQ-SA
|
| 50 |
+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] scq: "scq";
|
| 51 |
+
/// SCQ
|
| 52 |
+
@FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] lbt: "lbt";
|
| 53 |
+
/// LBT
|
| 54 |
+
@FEATURE: #[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")] lvz: "lvz";
|
| 55 |
+
/// LVZ
|
| 56 |
+
@FEATURE: #[unstable(feature = "stdarch_loongarch_feature_detection", issue = "117425")] ual: "ual";
|
| 57 |
+
/// UAL
|
| 58 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/mips.rs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on MIPS.
|
| 2 |
+
|
| 3 |
+
features! {
|
| 4 |
+
@TARGET: mips;
|
| 5 |
+
@CFG: target_arch = "mips";
|
| 6 |
+
@MACRO_NAME: is_mips_feature_detected;
|
| 7 |
+
@MACRO_ATTRS:
|
| 8 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 9 |
+
///
|
| 10 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 11 |
+
/// the macro expands to `true`.
|
| 12 |
+
#[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
|
| 13 |
+
@FEATURE: #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] msa: "msa";
|
| 14 |
+
/// MIPS SIMD Architecture (MSA)
|
| 15 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/mips64.rs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on MIPS64.
|
| 2 |
+
|
| 3 |
+
features! {
|
| 4 |
+
@TARGET: mips64;
|
| 5 |
+
@CFG: target_arch = "mips64";
|
| 6 |
+
@MACRO_NAME: is_mips64_feature_detected;
|
| 7 |
+
@MACRO_ATTRS:
|
| 8 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 9 |
+
///
|
| 10 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 11 |
+
/// the macro expands to `true`.
|
| 12 |
+
#[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
|
| 13 |
+
@FEATURE: #[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")] msa: "msa";
|
| 14 |
+
/// MIPS SIMD Architecture (MSA)
|
| 15 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/mod.rs
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#![allow(dead_code)]
|
| 2 |
+
|
| 3 |
+
// Export the macros for all supported architectures.
|
| 4 |
+
#[macro_use]
|
| 5 |
+
mod x86;
|
| 6 |
+
#[macro_use]
|
| 7 |
+
mod arm;
|
| 8 |
+
#[macro_use]
|
| 9 |
+
mod aarch64;
|
| 10 |
+
#[macro_use]
|
| 11 |
+
mod riscv;
|
| 12 |
+
#[macro_use]
|
| 13 |
+
mod powerpc;
|
| 14 |
+
#[macro_use]
|
| 15 |
+
mod powerpc64;
|
| 16 |
+
#[macro_use]
|
| 17 |
+
mod mips;
|
| 18 |
+
#[macro_use]
|
| 19 |
+
mod mips64;
|
| 20 |
+
#[macro_use]
|
| 21 |
+
mod loongarch;
|
| 22 |
+
#[macro_use]
|
| 23 |
+
mod s390x;
|
| 24 |
+
|
| 25 |
+
cfg_select! {
|
| 26 |
+
any(target_arch = "x86", target_arch = "x86_64") => {
|
| 27 |
+
#[stable(feature = "simd_x86", since = "1.27.0")]
|
| 28 |
+
pub use x86::*;
|
| 29 |
+
}
|
| 30 |
+
target_arch = "arm" => {
|
| 31 |
+
#[unstable(feature = "stdarch_arm_feature_detection", issue = "111190")]
|
| 32 |
+
pub use arm::*;
|
| 33 |
+
}
|
| 34 |
+
any(target_arch = "aarch64", target_arch = "arm64ec") => {
|
| 35 |
+
#[stable(feature = "simd_aarch64", since = "1.60.0")]
|
| 36 |
+
pub use aarch64::*;
|
| 37 |
+
}
|
| 38 |
+
any(target_arch = "riscv32", target_arch = "riscv64") => {
|
| 39 |
+
#[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")]
|
| 40 |
+
pub use riscv::*;
|
| 41 |
+
}
|
| 42 |
+
target_arch = "powerpc" => {
|
| 43 |
+
#[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
|
| 44 |
+
pub use powerpc::*;
|
| 45 |
+
}
|
| 46 |
+
target_arch = "powerpc64" => {
|
| 47 |
+
#[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
|
| 48 |
+
pub use powerpc64::*;
|
| 49 |
+
}
|
| 50 |
+
target_arch = "mips" => {
|
| 51 |
+
#[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
|
| 52 |
+
pub use mips::*;
|
| 53 |
+
}
|
| 54 |
+
target_arch = "mips64" => {
|
| 55 |
+
#[unstable(feature = "stdarch_mips_feature_detection", issue = "111188")]
|
| 56 |
+
pub use mips64::*;
|
| 57 |
+
}
|
| 58 |
+
any(target_arch = "loongarch32", target_arch = "loongarch64") => {
|
| 59 |
+
#[stable(feature = "stdarch_loongarch_feature", since = "1.89.0")]
|
| 60 |
+
pub use loongarch::*;
|
| 61 |
+
}
|
| 62 |
+
target_arch = "s390x" => {
|
| 63 |
+
#[stable(feature = "stdarch_s390x_feature_detection", since = "1.93.0")]
|
| 64 |
+
pub use s390x::*;
|
| 65 |
+
}
|
| 66 |
+
_ => {
|
| 67 |
+
// Unimplemented architecture:
|
| 68 |
+
#[doc(hidden)]
|
| 69 |
+
pub(crate) enum Feature {
|
| 70 |
+
Null
|
| 71 |
+
}
|
| 72 |
+
#[doc(hidden)]
|
| 73 |
+
#[unstable(feature = "stdarch_internal", issue = "none")]
|
| 74 |
+
pub mod __is_feature_detected {}
|
| 75 |
+
|
| 76 |
+
impl Feature {
|
| 77 |
+
#[doc(hidden)]
|
| 78 |
+
pub(crate) fn from_str(_s: &str) -> Result<Feature, ()> { Err(()) }
|
| 79 |
+
#[doc(hidden)]
|
| 80 |
+
pub(crate) fn to_str(self) -> &'static str { "" }
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/powerpc.rs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on PowerPC.
|
| 2 |
+
|
| 3 |
+
features! {
|
| 4 |
+
@TARGET: powerpc;
|
| 5 |
+
@CFG: target_arch = "powerpc";
|
| 6 |
+
@MACRO_NAME: is_powerpc_feature_detected;
|
| 7 |
+
@MACRO_ATTRS:
|
| 8 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 9 |
+
///
|
| 10 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 11 |
+
/// the macro expands to `true`.
|
| 12 |
+
#[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
|
| 13 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] altivec: "altivec";
|
| 14 |
+
/// Altivec
|
| 15 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] vsx: "vsx";
|
| 16 |
+
/// VSX
|
| 17 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power8: "power8";
|
| 18 |
+
without cfg check: true;
|
| 19 |
+
/// Power8
|
| 20 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power8_altivec: "power8-altivec";
|
| 21 |
+
/// Power8 altivec
|
| 22 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power8_vector: "power8-vector";
|
| 23 |
+
/// Power8 vector
|
| 24 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power8_crypto: "power8-crypto";
|
| 25 |
+
/// Power8 crypto
|
| 26 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power9: "power9";
|
| 27 |
+
without cfg check: true;
|
| 28 |
+
/// Power9
|
| 29 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power9_altivec: "power9-altivec";
|
| 30 |
+
/// Power9 altivec
|
| 31 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power9_vector: "power9-vector";
|
| 32 |
+
/// Power9 vector
|
| 33 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/powerpc64.rs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on PowerPC64.
|
| 2 |
+
|
| 3 |
+
features! {
|
| 4 |
+
@TARGET: powerpc64;
|
| 5 |
+
@CFG: target_arch = "powerpc64";
|
| 6 |
+
@MACRO_NAME: is_powerpc64_feature_detected;
|
| 7 |
+
@MACRO_ATTRS:
|
| 8 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 9 |
+
///
|
| 10 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 11 |
+
/// the macro expands to `true`.
|
| 12 |
+
#[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")]
|
| 13 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] altivec: "altivec";
|
| 14 |
+
/// Altivec
|
| 15 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] vsx: "vsx";
|
| 16 |
+
/// VSX
|
| 17 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power8: "power8";
|
| 18 |
+
without cfg check: true;
|
| 19 |
+
/// Power8
|
| 20 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power8_altivec: "power8-altivec";
|
| 21 |
+
/// Power8 altivec
|
| 22 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power8_vector: "power8-vector";
|
| 23 |
+
/// Power8 vector
|
| 24 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power8_crypto: "power8-crypto";
|
| 25 |
+
/// Power8 crypto
|
| 26 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power9: "power9";
|
| 27 |
+
without cfg check: true;
|
| 28 |
+
/// Power9
|
| 29 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power9_altivec: "power9-altivec";
|
| 30 |
+
/// Power9 altivec
|
| 31 |
+
@FEATURE: #[unstable(feature = "stdarch_powerpc_feature_detection", issue = "111191")] power9_vector: "power9-vector";
|
| 32 |
+
/// Power9 vector
|
| 33 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/riscv.rs
ADDED
|
@@ -0,0 +1,380 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on RISC-V.
|
| 2 |
+
|
| 3 |
+
features! {
|
| 4 |
+
@TARGET: riscv;
|
| 5 |
+
@CFG: any(target_arch = "riscv32", target_arch = "riscv64");
|
| 6 |
+
@MACRO_NAME: is_riscv_feature_detected;
|
| 7 |
+
@MACRO_ATTRS:
|
| 8 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 9 |
+
///
|
| 10 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 11 |
+
/// the macro expands to `true`.
|
| 12 |
+
///
|
| 13 |
+
/// RISC-V standard defined the base sets and the extension sets.
|
| 14 |
+
/// The base sets are RV32I, RV64I, RV32E or RV128I. Any RISC-V platform
|
| 15 |
+
/// must support one base set and/or multiple extension sets.
|
| 16 |
+
///
|
| 17 |
+
/// Any RISC-V standard instruction sets can be in state of either ratified,
|
| 18 |
+
/// frozen or draft. The version and status of current standard instruction
|
| 19 |
+
/// sets can be checked out from preface section of the [ISA manual].
|
| 20 |
+
///
|
| 21 |
+
/// Platform may define and support their own custom instruction sets with
|
| 22 |
+
/// ISA prefix X. These sets are highly platform specific and should be
|
| 23 |
+
/// detected with their own platform support crates.
|
| 24 |
+
///
|
| 25 |
+
/// [ISA manual]: https://riscv.org/specifications/ratified/
|
| 26 |
+
///
|
| 27 |
+
/// # Platform-specific/agnostic Behavior and Availability
|
| 28 |
+
///
|
| 29 |
+
/// Runtime detection depends on the platform-specific feature detection
|
| 30 |
+
/// facility and its availability per feature is
|
| 31 |
+
/// highly platform/version-specific.
|
| 32 |
+
///
|
| 33 |
+
/// Still, a best-effort attempt is performed to enable subset/dependent
|
| 34 |
+
/// features if a superset feature is enabled regardless of the platform.
|
| 35 |
+
/// For instance, if the A extension (`"a"`) is enabled, its subsets (the
|
| 36 |
+
/// Zalrsc and Zaamo extensions; `"zalrsc"` and `"zaamo"`) are also enabled.
|
| 37 |
+
/// Likewise, if the F extension (`"f"`) is enabled, one of its dependencies
|
| 38 |
+
/// (the Zicsr extension `"zicsr"`) is also enabled.
|
| 39 |
+
///
|
| 40 |
+
/// # Unprivileged Specification
|
| 41 |
+
///
|
| 42 |
+
/// The supported ratified RISC-V instruction sets are as follows (OS
|
| 43 |
+
/// columns denote runtime feature detection support with or without the
|
| 44 |
+
/// minimum supported version):
|
| 45 |
+
///
|
| 46 |
+
/// | Literal | Base | Linux |
|
| 47 |
+
/// |:---------- |:------- |:---------- |
|
| 48 |
+
/// | `"rv32e"` | RV32E | No |
|
| 49 |
+
/// | `"rv32i"` | RV32I | Yes [^ima] |
|
| 50 |
+
/// | `"rv64i"` | RV64I | Yes [^ima] |
|
| 51 |
+
///
|
| 52 |
+
/// | Literal | Extension | Linux |
|
| 53 |
+
/// |:--------------- |:----------- |:------------------- |
|
| 54 |
+
/// | `"a"` | A | Yes [^ima] |
|
| 55 |
+
/// | `"b"` | B | 6.5 |
|
| 56 |
+
/// | `"c"` | C | Yes |
|
| 57 |
+
/// | `"d"` | D | Yes |
|
| 58 |
+
/// | `"f"` | F | Yes |
|
| 59 |
+
/// | `"m"` | M | Yes [^ima] |
|
| 60 |
+
/// | `"q"` | Q | No |
|
| 61 |
+
/// | `"v"` | V | 6.5 |
|
| 62 |
+
/// | `"zaamo"` | Zaamo | 6.15 [^ima] [^dep] |
|
| 63 |
+
/// | `"zabha"` | Zabha | 6.16 |
|
| 64 |
+
/// | `"zacas"` | Zacas | 6.8 |
|
| 65 |
+
/// | `"zalrsc"` | Zalrsc | 6.15 [^ima] [^dep] |
|
| 66 |
+
/// | `"zawrs"` | Zawrs | 6.11 |
|
| 67 |
+
/// | `"zba"` | Zba | 6.5 |
|
| 68 |
+
/// | `"zbb"` | Zbb | 6.5 |
|
| 69 |
+
/// | `"zbc"` | Zbc | 6.8 |
|
| 70 |
+
/// | `"zbkb"` | Zbkb | 6.8 |
|
| 71 |
+
/// | `"zbkc"` | Zbkc | 6.8 |
|
| 72 |
+
/// | `"zbkx"` | Zbkx | 6.8 |
|
| 73 |
+
/// | `"zbs"` | Zbs | 6.5 |
|
| 74 |
+
/// | `"zca"` | Zca | 6.11 [^dep] |
|
| 75 |
+
/// | `"zcb"` | Zcb | 6.11 |
|
| 76 |
+
/// | `"zcd"` | Zcd | 6.11 [^dep] |
|
| 77 |
+
/// | `"zcf"` | Zcf | 6.11 [^dep] |
|
| 78 |
+
/// | `"zcmop"` | Zcmop | 6.11 |
|
| 79 |
+
/// | `"zdinx"` | Zdinx | No |
|
| 80 |
+
/// | `"zfa"` | Zfa | 6.8 |
|
| 81 |
+
/// | `"zfbfmin"` | Zfbfmin | 6.15 |
|
| 82 |
+
/// | `"zfh"` | Zfh | 6.8 |
|
| 83 |
+
/// | `"zfhmin"` | Zfhmin | 6.8 |
|
| 84 |
+
/// | `"zfinx"` | Zfinx | No |
|
| 85 |
+
/// | `"zhinx"` | Zhinx | No |
|
| 86 |
+
/// | `"zhinxmin"` | Zhinxmin | No |
|
| 87 |
+
/// | `"zicbom"` | Zicbom | 6.15 |
|
| 88 |
+
/// | `"zicboz"` | Zicboz | 6.7 |
|
| 89 |
+
/// | `"zicntr"` | Zicntr | 6.15 [^ima] [^cntr] |
|
| 90 |
+
/// | `"zicond"` | Zicond | 6.8 |
|
| 91 |
+
/// | `"zicsr"` | Zicsr | No [^ima] [^dep] |
|
| 92 |
+
/// | `"zifencei"` | Zifencei | No [^ima] |
|
| 93 |
+
/// | `"zihintntl"` | Zihintntl | 6.8 |
|
| 94 |
+
/// | `"zihintpause"` | Zihintpause | 6.10 |
|
| 95 |
+
/// | `"zihpm"` | Zihpm | 6.15 [^cntr] |
|
| 96 |
+
/// | `"zimop"` | Zimop | 6.11 |
|
| 97 |
+
/// | `"zk"` | Zk | No [^zkr] |
|
| 98 |
+
/// | `"zkn"` | Zkn | 6.8 |
|
| 99 |
+
/// | `"zknd"` | Zknd | 6.8 |
|
| 100 |
+
/// | `"zkne"` | Zkne | 6.8 |
|
| 101 |
+
/// | `"zknh"` | Zknh | 6.8 |
|
| 102 |
+
/// | `"zkr"` | Zkr | No [^zkr] |
|
| 103 |
+
/// | `"zks"` | Zks | 6.8 |
|
| 104 |
+
/// | `"zksed"` | Zksed | 6.8 |
|
| 105 |
+
/// | `"zksh"` | Zksh | 6.8 |
|
| 106 |
+
/// | `"zkt"` | Zkt | 6.8 |
|
| 107 |
+
/// | `"ztso"` | Ztso | 6.8 |
|
| 108 |
+
/// | `"zvbb"` | Zvbb | 6.8 |
|
| 109 |
+
/// | `"zvbc"` | Zvbc | 6.8 |
|
| 110 |
+
/// | `"zve32f"` | Zve32f | 6.11 [^dep] |
|
| 111 |
+
/// | `"zve32x"` | Zve32x | 6.11 [^dep] |
|
| 112 |
+
/// | `"zve64d"` | Zve64d | 6.11 [^dep] |
|
| 113 |
+
/// | `"zve64f"` | Zve64f | 6.11 [^dep] |
|
| 114 |
+
/// | `"zve64x"` | Zve64x | 6.11 [^dep] |
|
| 115 |
+
/// | `"zvfbfmin"` | Zvfbfmin | 6.15 |
|
| 116 |
+
/// | `"zvfbfwma"` | Zvfbfwma | 6.15 |
|
| 117 |
+
/// | `"zvfh"` | Zvfh | 6.8 |
|
| 118 |
+
/// | `"zvfhmin"` | Zvfhmin | 6.8 |
|
| 119 |
+
/// | `"zvkb"` | Zvkb | 6.8 |
|
| 120 |
+
/// | `"zvkg"` | Zvkg | 6.8 |
|
| 121 |
+
/// | `"zvkn"` | Zvkn | 6.8 |
|
| 122 |
+
/// | `"zvknc"` | Zvknc | 6.8 |
|
| 123 |
+
/// | `"zvkned"` | Zvkned | 6.8 |
|
| 124 |
+
/// | `"zvkng"` | Zvkng | 6.8 |
|
| 125 |
+
/// | `"zvknha"` | Zvknha | 6.8 |
|
| 126 |
+
/// | `"zvknhb"` | Zvknhb | 6.8 |
|
| 127 |
+
/// | `"zvks"` | Zvks | 6.8 |
|
| 128 |
+
/// | `"zvksc"` | Zvksc | 6.8 |
|
| 129 |
+
/// | `"zvksed"` | Zvksed | 6.8 |
|
| 130 |
+
/// | `"zvksg"` | Zvksg | 6.8 |
|
| 131 |
+
/// | `"zvksh"` | Zvksh | 6.8 |
|
| 132 |
+
/// | `"zvkt"` | Zvkt | 6.8 |
|
| 133 |
+
///
|
| 134 |
+
/// [^ima]: Or enabled when the IMA base behavior is detected on the Linux
|
| 135 |
+
/// kernel version 6.4 or later (for bases, the only matching one -- either
|
| 136 |
+
/// `"rv32i"` or `"rv64i"` -- is enabled).
|
| 137 |
+
///
|
| 138 |
+
/// [^cntr]: Even if this extension is available, it does not necessarily
|
| 139 |
+
/// mean all performance counters are accessible.
|
| 140 |
+
/// For example, accesses to all performance counters except `time`
|
| 141 |
+
/// (wall-clock) are blocked by default on the Linux kernel
|
| 142 |
+
/// version 6.6 or later.
|
| 143 |
+
/// Also beware that, even if performance counters like `cycle` and
|
| 144 |
+
/// `instret` are accessible, their value can be unreliable (e.g. returning
|
| 145 |
+
/// the constant value) under certain circumstances.
|
| 146 |
+
///
|
| 147 |
+
/// [^dep]: Or enabled as a dependency of another extension (a superset)
|
| 148 |
+
/// even if runtime detection of this feature itself is not supported (as
|
| 149 |
+
/// long as the runtime detection of the superset is supported).
|
| 150 |
+
///
|
| 151 |
+
/// [^zkr]: Linux does not report existence of this extension even if
|
| 152 |
+
/// supported by the hardware mainly because the `seed` CSR on the Zkr
|
| 153 |
+
/// extension (which provides hardware-based randomness) is normally
|
| 154 |
+
/// inaccessible from the user mode.
|
| 155 |
+
/// For the Zk extension features except this CSR, check existence of both
|
| 156 |
+
/// `"zkn"` and `"zkt"` features instead.
|
| 157 |
+
///
|
| 158 |
+
/// There's also bases and extensions marked as standard instruction set,
|
| 159 |
+
/// but they are in frozen or draft state. These instruction sets are also
|
| 160 |
+
/// reserved by this macro and can be detected in the future platforms.
|
| 161 |
+
///
|
| 162 |
+
/// Draft RISC-V instruction sets:
|
| 163 |
+
///
|
| 164 |
+
/// * RV128I: `"rv128i"`
|
| 165 |
+
/// * J: `"j"`
|
| 166 |
+
/// * P: `"p"`
|
| 167 |
+
/// * Zam: `"zam"`
|
| 168 |
+
///
|
| 169 |
+
/// # Performance Hints
|
| 170 |
+
///
|
| 171 |
+
/// The two features below define performance hints for unaligned
|
| 172 |
+
/// scalar/vector memory accesses, respectively. If enabled, it denotes that
|
| 173 |
+
/// corresponding unaligned memory access is reasonably fast.
|
| 174 |
+
///
|
| 175 |
+
/// * `"unaligned-scalar-mem"`
|
| 176 |
+
/// * Runtime detection requires Linux kernel version 6.4 or later.
|
| 177 |
+
/// * `"unaligned-vector-mem"`
|
| 178 |
+
/// * Runtime detection requires Linux kernel version 6.13 or later.
|
| 179 |
+
#[stable(feature = "riscv_ratified", since = "1.78.0")]
|
| 180 |
+
|
| 181 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] rv32i: "rv32i";
|
| 182 |
+
without cfg check: true;
|
| 183 |
+
/// RV32I Base Integer Instruction Set
|
| 184 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] rv32e: "rv32e";
|
| 185 |
+
without cfg check: true;
|
| 186 |
+
/// RV32E Base Integer Instruction Set
|
| 187 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] rv64i: "rv64i";
|
| 188 |
+
without cfg check: true;
|
| 189 |
+
/// RV64I Base Integer Instruction Set
|
| 190 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] rv128i: "rv128i";
|
| 191 |
+
without cfg check: true;
|
| 192 |
+
/// RV128I Base Integer Instruction Set
|
| 193 |
+
|
| 194 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] unaligned_scalar_mem: "unaligned-scalar-mem";
|
| 195 |
+
/// Has reasonably performant unaligned scalar
|
| 196 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] unaligned_vector_mem: "unaligned-vector-mem";
|
| 197 |
+
/// Has reasonably performant unaligned vector
|
| 198 |
+
|
| 199 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zicsr: "zicsr";
|
| 200 |
+
/// "Zicsr" Extension for Control and Status Register (CSR) Instructions
|
| 201 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zicntr: "zicntr";
|
| 202 |
+
/// "Zicntr" Extension for Base Counters and Timers
|
| 203 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zihpm: "zihpm";
|
| 204 |
+
/// "Zihpm" Extension for Hardware Performance Counters
|
| 205 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zifencei: "zifencei";
|
| 206 |
+
/// "Zifencei" Extension for Instruction-Fetch Fence
|
| 207 |
+
|
| 208 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zihintntl: "zihintntl";
|
| 209 |
+
/// "Zihintntl" Extension for Non-Temporal Locality Hints
|
| 210 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zihintpause: "zihintpause";
|
| 211 |
+
/// "Zihintpause" Extension for Pause Hint
|
| 212 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zimop: "zimop";
|
| 213 |
+
/// "Zimop" Extension for May-Be-Operations
|
| 214 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zicbom: "zicbom";
|
| 215 |
+
/// "Zicbom" Extension for Cache-Block Management Instructions
|
| 216 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zicboz: "zicboz";
|
| 217 |
+
/// "Zicboz" Extension for Cache-Block Zero Instruction
|
| 218 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zicond: "zicond";
|
| 219 |
+
/// "Zicond" Extension for Integer Conditional Operations
|
| 220 |
+
|
| 221 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] m: "m";
|
| 222 |
+
/// "M" Extension for Integer Multiplication and Division
|
| 223 |
+
|
| 224 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] a: "a";
|
| 225 |
+
/// "A" Extension for Atomic Instructions
|
| 226 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zalrsc: "zalrsc";
|
| 227 |
+
/// "Zalrsc" Extension for Load-Reserved/Store-Conditional Instructions
|
| 228 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zaamo: "zaamo";
|
| 229 |
+
/// "Zaamo" Extension for Atomic Memory Operations
|
| 230 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zawrs: "zawrs";
|
| 231 |
+
/// "Zawrs" Extension for Wait-on-Reservation-Set Instructions
|
| 232 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zabha: "zabha";
|
| 233 |
+
/// "Zabha" Extension for Byte and Halfword Atomic Memory Operations
|
| 234 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zacas: "zacas";
|
| 235 |
+
/// "Zacas" Extension for Atomic Compare-and-Swap (CAS) Instructions
|
| 236 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zam: "zam";
|
| 237 |
+
without cfg check: true;
|
| 238 |
+
/// "Zam" Extension for Misaligned Atomics
|
| 239 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] ztso: "ztso";
|
| 240 |
+
/// "Ztso" Extension for Total Store Ordering
|
| 241 |
+
|
| 242 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] f: "f";
|
| 243 |
+
/// "F" Extension for Single-Precision Floating-Point
|
| 244 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] d: "d";
|
| 245 |
+
/// "D" Extension for Double-Precision Floating-Point
|
| 246 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] q: "q";
|
| 247 |
+
without cfg check: true;
|
| 248 |
+
/// "Q" Extension for Quad-Precision Floating-Point
|
| 249 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zfh: "zfh";
|
| 250 |
+
/// "Zfh" Extension for Half-Precision Floating-Point
|
| 251 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zfhmin: "zfhmin";
|
| 252 |
+
/// "Zfhmin" Extension for Minimal Half-Precision Floating-Point
|
| 253 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zfa: "zfa";
|
| 254 |
+
/// "Zfa" Extension for Additional Floating-Point Instructions
|
| 255 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zfbfmin: "zfbfmin";
|
| 256 |
+
/// "Zfbfmin" Extension for Scalar BF16 Converts
|
| 257 |
+
|
| 258 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zfinx: "zfinx";
|
| 259 |
+
/// "Zfinx" Extension for Single-Precision Floating-Point in Integer Registers
|
| 260 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zdinx: "zdinx";
|
| 261 |
+
/// "Zdinx" Extension for Double-Precision Floating-Point in Integer Registers
|
| 262 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zhinx: "zhinx";
|
| 263 |
+
/// "Zhinx" Extension for Half-Precision Floating-Point in Integer Registers
|
| 264 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zhinxmin: "zhinxmin";
|
| 265 |
+
/// "Zhinxmin" Extension for Minimal Half-Precision Floating-Point in Integer Registers
|
| 266 |
+
|
| 267 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] c: "c";
|
| 268 |
+
/// "C" Extension for Compressed Instructions
|
| 269 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zca: "zca";
|
| 270 |
+
/// "Zca" Compressed Instructions excluding Floating-Point Loads/Stores
|
| 271 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zcf: "zcf";
|
| 272 |
+
without cfg check: true;
|
| 273 |
+
/// "Zcf" Compressed Instructions for Single-Precision Floating-Point Loads/Stores on RV32
|
| 274 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zcd: "zcd";
|
| 275 |
+
without cfg check: true;
|
| 276 |
+
/// "Zcd" Compressed Instructions for Double-Precision Floating-Point Loads/Stores
|
| 277 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zcb: "zcb";
|
| 278 |
+
/// "Zcb" Simple Code-size Saving Compressed Instructions
|
| 279 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] zcmop: "zcmop";
|
| 280 |
+
/// "Zcmop" Extension for Compressed May-Be-Operations
|
| 281 |
+
|
| 282 |
+
@FEATURE: #[stable(feature = "riscv_ratified_v2", since = "1.94.0")] b: "b";
|
| 283 |
+
/// "B" Extension for Bit Manipulation
|
| 284 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zba: "zba";
|
| 285 |
+
/// "Zba" Extension for Address Generation
|
| 286 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zbb: "zbb";
|
| 287 |
+
/// "Zbb" Extension for Basic Bit-Manipulation
|
| 288 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zbc: "zbc";
|
| 289 |
+
/// "Zbc" Extension for Carry-less Multiplication
|
| 290 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zbs: "zbs";
|
| 291 |
+
/// "Zbs" Extension for Single-Bit Instructions
|
| 292 |
+
|
| 293 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zbkb: "zbkb";
|
| 294 |
+
/// "Zbkb" Extension for Bit-Manipulation for Cryptography
|
| 295 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zbkc: "zbkc";
|
| 296 |
+
/// "Zbkc" Extension for Carry-less Multiplication for Cryptography
|
| 297 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zbkx: "zbkx";
|
| 298 |
+
/// "Zbkx" Extension for Crossbar Permutations
|
| 299 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zknd: "zknd";
|
| 300 |
+
/// "Zknd" Cryptography Extension for NIST Suite: AES Decryption
|
| 301 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zkne: "zkne";
|
| 302 |
+
/// "Zkne" Cryptography Extension for NIST Suite: AES Encryption
|
| 303 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zknh: "zknh";
|
| 304 |
+
/// "Zknh" Cryptography Extension for NIST Suite: Hash Function Instructions
|
| 305 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zksed: "zksed";
|
| 306 |
+
/// "Zksed" Cryptography Extension for ShangMi Suite: SM4 Block Cipher Instructions
|
| 307 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zksh: "zksh";
|
| 308 |
+
/// "Zksh" Cryptography Extension for ShangMi Suite: SM3 Hash Function Instructions
|
| 309 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zkr: "zkr";
|
| 310 |
+
/// "Zkr" Entropy Source Extension
|
| 311 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zkn: "zkn";
|
| 312 |
+
/// "Zkn" Cryptography Extension for NIST Algorithm Suite
|
| 313 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zks: "zks";
|
| 314 |
+
/// "Zks" Cryptography Extension for ShangMi Algorithm Suite
|
| 315 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zk: "zk";
|
| 316 |
+
/// "Zk" Cryptography Extension for Standard Scalar Cryptography
|
| 317 |
+
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] zkt: "zkt";
|
| 318 |
+
/// "Zkt" Cryptography Extension for Data Independent Execution Latency
|
| 319 |
+
|
| 320 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] v: "v";
|
| 321 |
+
/// "V" Extension for Vector Operations
|
| 322 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zve32x: "zve32x";
|
| 323 |
+
/// "Zve32x" Vector Extension for Embedded Processors (32-bit+; Integer)
|
| 324 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zve32f: "zve32f";
|
| 325 |
+
/// "Zve32f" Vector Extension for Embedded Processors (32-bit+; with Single-Precision Floating-Point)
|
| 326 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zve64x: "zve64x";
|
| 327 |
+
/// "Zve64x" Vector Extension for Embedded Processors (64-bit+; Integer)
|
| 328 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zve64f: "zve64f";
|
| 329 |
+
/// "Zve64f" Vector Extension for Embedded Processors (64-bit+; with Single-Precision Floating-Point)
|
| 330 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zve64d: "zve64d";
|
| 331 |
+
/// "Zve64d" Vector Extension for Embedded Processors (64-bit+; with Double-Precision Floating-Point)
|
| 332 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvfh: "zvfh";
|
| 333 |
+
/// "Zvfh" Vector Extension for Half-Precision Floating-Point
|
| 334 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvfhmin: "zvfhmin";
|
| 335 |
+
/// "Zvfhmin" Vector Extension for Minimal Half-Precision Floating-Point
|
| 336 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvfbfmin: "zvfbfmin";
|
| 337 |
+
/// "Zvfbfmin" Vector Extension for BF16 Converts
|
| 338 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvfbfwma: "zvfbfwma";
|
| 339 |
+
/// "Zvfbfwma" Vector Extension for BF16 Widening Multiply-Add
|
| 340 |
+
|
| 341 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvbb: "zvbb";
|
| 342 |
+
/// "Zvbb" Extension for Vector Basic Bit-Manipulation
|
| 343 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvbc: "zvbc";
|
| 344 |
+
/// "Zvbc" Extension for Vector Carryless Multiplication
|
| 345 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvkb: "zvkb";
|
| 346 |
+
/// "Zvkb" Extension for Vector Cryptography Bit-Manipulation
|
| 347 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvkg: "zvkg";
|
| 348 |
+
/// "Zvkg" Cryptography Extension for Vector GCM/GMAC
|
| 349 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvkned: "zvkned";
|
| 350 |
+
/// "Zvkned" Cryptography Extension for NIST Suite: Vector AES Block Cipher
|
| 351 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvknha: "zvknha";
|
| 352 |
+
/// "Zvknha" Cryptography Extension for Vector SHA-2 Secure Hash (SHA-256)
|
| 353 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvknhb: "zvknhb";
|
| 354 |
+
/// "Zvknhb" Cryptography Extension for Vector SHA-2 Secure Hash (SHA-256/512)
|
| 355 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvksed: "zvksed";
|
| 356 |
+
/// "Zvksed" Cryptography Extension for ShangMi Suite: Vector SM4 Block Cipher
|
| 357 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvksh: "zvksh";
|
| 358 |
+
/// "Zvksh" Cryptography Extension for ShangMi Suite: Vector SM3 Secure Hash
|
| 359 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvkn: "zvkn";
|
| 360 |
+
/// "Zvkn" Cryptography Extension for NIST Algorithm Suite
|
| 361 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvknc: "zvknc";
|
| 362 |
+
/// "Zvknc" Cryptography Extension for NIST Algorithm Suite with Carryless Multiply
|
| 363 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvkng: "zvkng";
|
| 364 |
+
/// "Zvkng" Cryptography Extension for NIST Algorithm Suite with GCM
|
| 365 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvks: "zvks";
|
| 366 |
+
/// "Zvks" Cryptography Extension for ShangMi Algorithm Suite
|
| 367 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvksc: "zvksc";
|
| 368 |
+
/// "Zvksc" Cryptography Extension for ShangMi Algorithm Suite with Carryless Multiply
|
| 369 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvksg: "zvksg";
|
| 370 |
+
/// "Zvksg" Cryptography Extension for ShangMi Algorithm Suite with GCM
|
| 371 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zvkt: "zvkt";
|
| 372 |
+
/// "Zvkt" Extension for Vector Data-Independent Execution Latency
|
| 373 |
+
|
| 374 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] j: "j";
|
| 375 |
+
without cfg check: true;
|
| 376 |
+
/// "J" Extension for Dynamically Translated Languages
|
| 377 |
+
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] p: "p";
|
| 378 |
+
without cfg check: true;
|
| 379 |
+
/// "P" Extension for Packed-SIMD Instructions
|
| 380 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/s390x.rs
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on s390x.
|
| 2 |
+
|
| 3 |
+
features! {
|
| 4 |
+
@TARGET: s390x;
|
| 5 |
+
@CFG: target_arch = "s390x";
|
| 6 |
+
@MACRO_NAME: is_s390x_feature_detected;
|
| 7 |
+
@MACRO_ATTRS:
|
| 8 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 9 |
+
///
|
| 10 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 11 |
+
/// the macro expands to `true`.
|
| 12 |
+
#[stable(feature = "stdarch_s390x_feature_detection", since = "1.93.0")]
|
| 13 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] concurrent_functions: "concurrent-functions";
|
| 14 |
+
/// s390x concurrent-functions facility
|
| 15 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] deflate_conversion: "deflate-conversion";
|
| 16 |
+
/// s390x deflate-conversion facility
|
| 17 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] enhanced_sort: "enhanced-sort";
|
| 18 |
+
/// s390x enhanced-sort facility
|
| 19 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] guarded_storage: "guarded-storage";
|
| 20 |
+
/// s390x guarded-storage facility
|
| 21 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] high_word: "high-word";
|
| 22 |
+
/// s390x high-word facility
|
| 23 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] message_security_assist_extension3: "message-security-assist-extension3";
|
| 24 |
+
/// s390x message-security-assist-extension3 facility
|
| 25 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] message_security_assist_extension4: "message-security-assist-extension4";
|
| 26 |
+
/// s390x message-security-assist-extension4 facility
|
| 27 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] message_security_assist_extension5: "message-security-assist-extension5";
|
| 28 |
+
/// s390x message-security-assist-extension5 facility
|
| 29 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] message_security_assist_extension8: "message-security-assist-extension8";
|
| 30 |
+
/// s390x message-security-assist-extension8 facility
|
| 31 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] message_security_assist_extension9: "message-security-assist-extension9";
|
| 32 |
+
/// s390x message-security-assist-extension9 facility
|
| 33 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] message_security_assist_extension12: "message-security-assist-extension12";
|
| 34 |
+
/// s390x message-security-assist-extension12 facility
|
| 35 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] miscellaneous_extensions_2: "miscellaneous-extensions-2";
|
| 36 |
+
/// s390x miscellaneous-extensions-2 facility
|
| 37 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] miscellaneous_extensions_3: "miscellaneous-extensions-3";
|
| 38 |
+
/// s390x miscellaneous-extensions-3 facility
|
| 39 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] miscellaneous_extensions_4: "miscellaneous-extensions-4";
|
| 40 |
+
/// s390x miscellaneous-extensions-4 facility
|
| 41 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] nnp_assist: "nnp-assist";
|
| 42 |
+
/// s390x nnp-assist facility
|
| 43 |
+
@FEATURE: #[unstable(feature = "s390x_target_feature", issue = "150259")] transactional_execution: "transactional-execution";
|
| 44 |
+
/// s390x transactional-execution facility
|
| 45 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector: "vector";
|
| 46 |
+
/// s390x vector facility
|
| 47 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_enhancements_1: "vector-enhancements-1";
|
| 48 |
+
/// s390x vector-enhancements-1 facility
|
| 49 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_enhancements_2: "vector-enhancements-2";
|
| 50 |
+
/// s390x vector-enhancements-2 facility
|
| 51 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_enhancements_3: "vector-enhancements-3";
|
| 52 |
+
/// s390x vector-enhancements-3 facility
|
| 53 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_packed_decimal: "vector-packed-decimal";
|
| 54 |
+
/// s390x vector-packed-decimal facility
|
| 55 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_packed_decimal_enhancement: "vector-packed-decimal-enhancement";
|
| 56 |
+
/// s390x vector-packed-decimal-enhancement facility
|
| 57 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_packed_decimal_enhancement_2: "vector-packed-decimal-enhancement-2";
|
| 58 |
+
/// s390x vector-packed-decimal-enhancement-2 facility
|
| 59 |
+
@FEATURE: #[stable(feature = "s390x_target_feature_vector", since = "1.93.0")] vector_packed_decimal_enhancement_3: "vector-packed-decimal-enhancement-3";
|
| 60 |
+
/// s390x vector-packed-decimal-enhancement-3 facility
|
| 61 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/arch/x86.rs
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! This module implements minimal run-time feature detection for x86.
|
| 2 |
+
//!
|
| 3 |
+
//! The features are detected using the `detect_features` function below.
|
| 4 |
+
//! This function uses the CPUID instruction to read the feature flags from the
|
| 5 |
+
//! CPU and encodes them in a `usize` where each bit position represents
|
| 6 |
+
//! whether a feature is available (bit is set) or unavailable (bit is cleared).
|
| 7 |
+
//!
|
| 8 |
+
//! The enum `Feature` is used to map bit positions to feature names, and the
|
| 9 |
+
//! the `__crate::detect::check_for!` macro is used to map string literals (e.g.,
|
| 10 |
+
//! "avx") to these bit positions (e.g., `Feature::avx`).
|
| 11 |
+
//!
|
| 12 |
+
//! The run-time feature detection is performed by the
|
| 13 |
+
//! `__crate::detect::check_for(Feature) -> bool` function. On its first call,
|
| 14 |
+
//! this functions queries the CPU for the available features and stores them
|
| 15 |
+
//! in a global `AtomicUsize` variable. The query is performed by just checking
|
| 16 |
+
//! whether the feature bit in this global variable is set or cleared.
|
| 17 |
+
|
| 18 |
+
features! {
|
| 19 |
+
@TARGET: x86;
|
| 20 |
+
@CFG: any(target_arch = "x86", target_arch = "x86_64");
|
| 21 |
+
@MACRO_NAME: is_x86_feature_detected;
|
| 22 |
+
@MACRO_ATTRS:
|
| 23 |
+
/// Check for the presence of a CPU feature at runtime.
|
| 24 |
+
///
|
| 25 |
+
/// When the feature is known to be enabled at compile time (e.g. via `-Ctarget-feature`)
|
| 26 |
+
/// the macro expands to `true`.
|
| 27 |
+
///
|
| 28 |
+
/// Runtime detection currently relies mostly on the `cpuid` instruction.
|
| 29 |
+
///
|
| 30 |
+
/// This macro only takes one argument which is a string literal of the feature
|
| 31 |
+
/// being tested for. The feature names supported are the lowercase versions of
|
| 32 |
+
/// the ones defined by Intel in [their documentation][docs].
|
| 33 |
+
///
|
| 34 |
+
/// ## Supported arguments
|
| 35 |
+
///
|
| 36 |
+
/// This macro supports the same names that `#[target_feature]` supports. Unlike
|
| 37 |
+
/// `#[target_feature]`, however, this macro does not support names separated
|
| 38 |
+
/// with a comma. Instead testing for multiple features must be done through
|
| 39 |
+
/// separate macro invocations for now.
|
| 40 |
+
///
|
| 41 |
+
/// Supported arguments are:
|
| 42 |
+
///
|
| 43 |
+
/// * `"aes"`
|
| 44 |
+
/// * `"pclmulqdq"`
|
| 45 |
+
/// * `"rdrand"`
|
| 46 |
+
/// * `"rdseed"`
|
| 47 |
+
/// * `"tsc"`
|
| 48 |
+
/// * `"mmx"`
|
| 49 |
+
/// * `"sse"`
|
| 50 |
+
/// * `"sse2"`
|
| 51 |
+
/// * `"sse3"`
|
| 52 |
+
/// * `"ssse3"`
|
| 53 |
+
/// * `"sse4.1"`
|
| 54 |
+
/// * `"sse4.2"`
|
| 55 |
+
/// * `"sse4a"`
|
| 56 |
+
/// * `"sha"`
|
| 57 |
+
/// * `"avx"`
|
| 58 |
+
/// * `"avx2"`
|
| 59 |
+
/// * `"sha512"`
|
| 60 |
+
/// * `"sm3"`
|
| 61 |
+
/// * `"sm4"`
|
| 62 |
+
/// * `"avx512f"`
|
| 63 |
+
/// * `"avx512cd"`
|
| 64 |
+
/// * `"avx512er"`
|
| 65 |
+
/// * `"avx512pf"`
|
| 66 |
+
/// * `"avx512bw"`
|
| 67 |
+
/// * `"avx512dq"`
|
| 68 |
+
/// * `"avx512vl"`
|
| 69 |
+
/// * `"avx512ifma"`
|
| 70 |
+
/// * `"avx512vbmi"`
|
| 71 |
+
/// * `"avx512vpopcntdq"`
|
| 72 |
+
/// * `"avx512vbmi2"`
|
| 73 |
+
/// * `"gfni"`
|
| 74 |
+
/// * `"vaes"`
|
| 75 |
+
/// * `"vpclmulqdq"`
|
| 76 |
+
/// * `"avx512vnni"`
|
| 77 |
+
/// * `"avx512bitalg"`
|
| 78 |
+
/// * `"avx512bf16"`
|
| 79 |
+
/// * `"avx512vp2intersect"`
|
| 80 |
+
/// * `"avx512fp16"`
|
| 81 |
+
/// * `"avxvnni"`
|
| 82 |
+
/// * `"avxifma"`
|
| 83 |
+
/// * `"avxneconvert"`
|
| 84 |
+
/// * `"avxvnniint8"`
|
| 85 |
+
/// * `"avxvnniint16"`
|
| 86 |
+
/// * `"amx-tile"`
|
| 87 |
+
/// * `"amx-int8"`
|
| 88 |
+
/// * `"amx-bf16"`
|
| 89 |
+
/// * `"amx-fp16"`
|
| 90 |
+
/// * `"amx-complex"`
|
| 91 |
+
/// * `"amx-avx512"`
|
| 92 |
+
/// * `"amx-fp8"`
|
| 93 |
+
/// * `"amx-movrs"`
|
| 94 |
+
/// * `"amx-tf32"`
|
| 95 |
+
/// * `"f16c"`
|
| 96 |
+
/// * `"fma"`
|
| 97 |
+
/// * `"bmi1"`
|
| 98 |
+
/// * `"bmi2"`
|
| 99 |
+
/// * `"abm"`
|
| 100 |
+
/// * `"lzcnt"`
|
| 101 |
+
/// * `"tbm"`
|
| 102 |
+
/// * `"popcnt"`
|
| 103 |
+
/// * `"fxsr"`
|
| 104 |
+
/// * `"xsave"`
|
| 105 |
+
/// * `"xsaveopt"`
|
| 106 |
+
/// * `"xsaves"`
|
| 107 |
+
/// * `"xsavec"`
|
| 108 |
+
/// * `"cmpxchg16b"`
|
| 109 |
+
/// * `"kl"`
|
| 110 |
+
/// * `"widekl"`
|
| 111 |
+
/// * `"adx"`
|
| 112 |
+
/// * `"rtm"`
|
| 113 |
+
/// * `"movbe"`
|
| 114 |
+
/// * `"ermsb"`
|
| 115 |
+
/// * `"movrs"`
|
| 116 |
+
/// * `"xop"`
|
| 117 |
+
///
|
| 118 |
+
/// [docs]: https://software.intel.com/sites/landingpage/IntrinsicsGuide
|
| 119 |
+
#[stable(feature = "simd_x86", since = "1.27.0")]
|
| 120 |
+
@BIND_FEATURE_NAME: "abm"; "lzcnt"; // abm is a synonym for lzcnt
|
| 121 |
+
@BIND_FEATURE_NAME: "avx512gfni"; "gfni"; #[deprecated(since = "1.67.0", note = "the `avx512gfni` feature has been renamed to `gfni`")];
|
| 122 |
+
@BIND_FEATURE_NAME: "avx512vaes"; "vaes"; #[deprecated(since = "1.67.0", note = "the `avx512vaes` feature has been renamed to `vaes`")];
|
| 123 |
+
@BIND_FEATURE_NAME: "avx512vpclmulqdq"; "vpclmulqdq"; #[deprecated(since = "1.67.0", note = "the `avx512vpclmulqdq` feature has been renamed to `vpclmulqdq`")];
|
| 124 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] aes: "aes";
|
| 125 |
+
/// AES (Advanced Encryption Standard New Instructions AES-NI)
|
| 126 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] pclmulqdq: "pclmulqdq";
|
| 127 |
+
/// CLMUL (Carry-less Multiplication)
|
| 128 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rdrand: "rdrand";
|
| 129 |
+
/// RDRAND
|
| 130 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rdseed: "rdseed";
|
| 131 |
+
/// RDSEED
|
| 132 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] tsc: "tsc";
|
| 133 |
+
without cfg check: true;
|
| 134 |
+
/// TSC (Time Stamp Counter)
|
| 135 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] mmx: "mmx";
|
| 136 |
+
without cfg check: true;
|
| 137 |
+
/// MMX (MultiMedia eXtensions)
|
| 138 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse: "sse";
|
| 139 |
+
/// SSE (Streaming SIMD Extensions)
|
| 140 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse2: "sse2";
|
| 141 |
+
/// SSE2 (Streaming SIMD Extensions 2)
|
| 142 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse3: "sse3";
|
| 143 |
+
/// SSE3 (Streaming SIMD Extensions 3)
|
| 144 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] ssse3: "ssse3";
|
| 145 |
+
/// SSSE3 (Supplemental Streaming SIMD Extensions 3)
|
| 146 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4_1: "sse4.1";
|
| 147 |
+
/// SSE4.1 (Streaming SIMD Extensions 4.1)
|
| 148 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4_2: "sse4.2";
|
| 149 |
+
/// SSE4.2 (Streaming SIMD Extensions 4.2)
|
| 150 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sse4a: "sse4a";
|
| 151 |
+
/// SSE4a (Streaming SIMD Extensions 4a)
|
| 152 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] sha: "sha";
|
| 153 |
+
/// SHA
|
| 154 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx: "avx";
|
| 155 |
+
/// AVX (Advanced Vector Extensions)
|
| 156 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx2: "avx2";
|
| 157 |
+
/// AVX2 (Advanced Vector Extensions 2)
|
| 158 |
+
@FEATURE: #[stable(feature = "sha512_sm_x86", since = "1.89.0")] sha512: "sha512";
|
| 159 |
+
/// SHA512
|
| 160 |
+
@FEATURE: #[stable(feature = "sha512_sm_x86", since = "1.89.0")] sm3: "sm3";
|
| 161 |
+
/// SM3
|
| 162 |
+
@FEATURE: #[stable(feature = "sha512_sm_x86", since = "1.89.0")] sm4: "sm4";
|
| 163 |
+
/// SM4
|
| 164 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512f: "avx512f" ;
|
| 165 |
+
/// AVX-512 F (Foundation)
|
| 166 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512cd: "avx512cd" ;
|
| 167 |
+
/// AVX-512 CD (Conflict Detection Instructions)
|
| 168 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512er: "avx512er";
|
| 169 |
+
without cfg check: true;
|
| 170 |
+
/// AVX-512 ER (Expo nential and Reciprocal Instructions)
|
| 171 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512pf: "avx512pf";
|
| 172 |
+
without cfg check: true;
|
| 173 |
+
/// AVX-512 PF (Prefetch Instructions)
|
| 174 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512bw: "avx512bw";
|
| 175 |
+
/// AVX-512 BW (Byte and Word Instructions)
|
| 176 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512dq: "avx512dq";
|
| 177 |
+
/// AVX-512 DQ (Doubleword and Quadword)
|
| 178 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vl: "avx512vl";
|
| 179 |
+
/// AVX-512 VL (Vector Length Extensions)
|
| 180 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512ifma: "avx512ifma";
|
| 181 |
+
/// AVX-512 IFMA (Integer Fused Multiply Add)
|
| 182 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vbmi: "avx512vbmi";
|
| 183 |
+
/// AVX-512 VBMI (Vector Byte Manipulation Instructions)
|
| 184 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vpopcntdq: "avx512vpopcntdq";
|
| 185 |
+
/// AVX-512 VPOPCNTDQ (Vector Population Count Doubleword and Quadword)
|
| 186 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vbmi2: "avx512vbmi2";
|
| 187 |
+
/// AVX-512 VBMI2 (Additional byte, word, dword and qword capabilities)
|
| 188 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] gfni: "gfni";
|
| 189 |
+
/// AVX-512 GFNI (Galois Field New Instruction)
|
| 190 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] vaes: "vaes";
|
| 191 |
+
/// AVX-512 VAES (Vector AES instruction)
|
| 192 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] vpclmulqdq: "vpclmulqdq";
|
| 193 |
+
/// AVX-512 VPCLMULQDQ (Vector PCLMULQDQ instructions)
|
| 194 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vnni: "avx512vnni";
|
| 195 |
+
/// AVX-512 VNNI (Vector Neural Network Instructions)
|
| 196 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512bitalg: "avx512bitalg";
|
| 197 |
+
/// AVX-512 BITALG (Support for VPOPCNT\[B,W\] and VPSHUFBITQMB)
|
| 198 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512bf16: "avx512bf16";
|
| 199 |
+
/// AVX-512 BF16 (BFLOAT16 instructions)
|
| 200 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512vp2intersect: "avx512vp2intersect";
|
| 201 |
+
/// AVX-512 P2INTERSECT
|
| 202 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] avx512fp16: "avx512fp16";
|
| 203 |
+
/// AVX-512 FP16 (FLOAT16 instructions)
|
| 204 |
+
@FEATURE: #[stable(feature = "avx512_target_feature", since = "1.89.0")] avxifma: "avxifma";
|
| 205 |
+
/// AVX-IFMA (Integer Fused Multiply Add)
|
| 206 |
+
@FEATURE: #[stable(feature = "avx512_target_feature", since = "1.89.0")] avxneconvert: "avxneconvert";
|
| 207 |
+
/// AVX-NE-CONVERT (Exceptionless Convert)
|
| 208 |
+
@FEATURE: #[stable(feature = "avx512_target_feature", since = "1.89.0")] avxvnni: "avxvnni";
|
| 209 |
+
/// AVX-VNNI (Vector Neural Network Instructions)
|
| 210 |
+
@FEATURE: #[stable(feature = "avx512_target_feature", since = "1.89.0")] avxvnniint16: "avxvnniint16";
|
| 211 |
+
/// AVX-VNNI_INT8 (VNNI with 16-bit Integers)
|
| 212 |
+
@FEATURE: #[stable(feature = "avx512_target_feature", since = "1.89.0")] avxvnniint8: "avxvnniint8";
|
| 213 |
+
/// AVX-VNNI_INT16 (VNNI with 8-bit integers)
|
| 214 |
+
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_tile: "amx-tile";
|
| 215 |
+
/// AMX (Advanced Matrix Extensions) - Tile load/store
|
| 216 |
+
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_int8: "amx-int8";
|
| 217 |
+
/// AMX-INT8 (Operations on 8-bit integers)
|
| 218 |
+
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_bf16: "amx-bf16";
|
| 219 |
+
/// AMX-BF16 (BFloat16 Operations)
|
| 220 |
+
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_fp16: "amx-fp16";
|
| 221 |
+
/// AMX-FP16 (Float16 Operations)
|
| 222 |
+
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_complex: "amx-complex";
|
| 223 |
+
/// AMX-COMPLEX (Complex number Operations)
|
| 224 |
+
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_avx512: "amx-avx512";
|
| 225 |
+
/// AMX-AVX512 (AVX512 operations extended to matrices)
|
| 226 |
+
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_fp8: "amx-fp8";
|
| 227 |
+
/// AMX-FP8 (Float8 Operations)
|
| 228 |
+
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_movrs: "amx-movrs";
|
| 229 |
+
/// AMX-MOVRS (Matrix MOVERS operations)
|
| 230 |
+
@FEATURE: #[unstable(feature = "x86_amx_intrinsics", issue = "126622")] amx_tf32: "amx-tf32";
|
| 231 |
+
/// AMX-TF32 (TensorFloat32 Operations)
|
| 232 |
+
@FEATURE: #[unstable(feature = "apx_target_feature", issue = "139284")] apxf: "apxf";
|
| 233 |
+
/// APX-F (Advanced Performance Extensions - Foundation)
|
| 234 |
+
@FEATURE: #[unstable(feature = "avx10_target_feature", issue = "138843")] avx10_1: "avx10.1";
|
| 235 |
+
/// AVX10.1
|
| 236 |
+
@FEATURE: #[unstable(feature = "avx10_target_feature", issue = "138843")] avx10_2: "avx10.2";
|
| 237 |
+
/// AVX10.2
|
| 238 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] f16c: "f16c";
|
| 239 |
+
/// F16C (Conversions between IEEE-754 `binary16` and `binary32` formats)
|
| 240 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] fma: "fma";
|
| 241 |
+
/// FMA (Fused Multiply Add)
|
| 242 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] bmi1: "bmi1" ;
|
| 243 |
+
/// BMI1 (Bit Manipulation Instructions 1)
|
| 244 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] bmi2: "bmi2" ;
|
| 245 |
+
/// BMI2 (Bit Manipulation Instructions 2)
|
| 246 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] lzcnt: "lzcnt";
|
| 247 |
+
/// ABM (Advanced Bit Manipulation) / LZCNT (Leading Zero Count)
|
| 248 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] tbm: "tbm";
|
| 249 |
+
/// TBM (Trailing Bit Manipulation)
|
| 250 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] popcnt: "popcnt";
|
| 251 |
+
/// POPCNT (Population Count)
|
| 252 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] fxsr: "fxsr";
|
| 253 |
+
/// FXSR (Floating-point context fast save and restore)
|
| 254 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsave: "xsave";
|
| 255 |
+
/// XSAVE (Save Processor Extended States)
|
| 256 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsaveopt: "xsaveopt";
|
| 257 |
+
/// XSAVEOPT (Save Processor Extended States Optimized)
|
| 258 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsaves: "xsaves";
|
| 259 |
+
/// XSAVES (Save Processor Extended States Supervisor)
|
| 260 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] xsavec: "xsavec";
|
| 261 |
+
/// XSAVEC (Save Processor Extended States Compacted)
|
| 262 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] cmpxchg16b: "cmpxchg16b";
|
| 263 |
+
/// CMPXCH16B (16-byte compare-and-swap instruction)
|
| 264 |
+
@FEATURE: #[stable(feature = "keylocker_x86", since = "1.89.0")] kl: "kl";
|
| 265 |
+
/// Intel Key Locker
|
| 266 |
+
@FEATURE: #[stable(feature = "keylocker_x86", since = "1.89.0")] widekl: "widekl";
|
| 267 |
+
/// Intel Key Locker Wide
|
| 268 |
+
@FEATURE: #[stable(feature = "simd_x86_adx", since = "1.33.0")] adx: "adx";
|
| 269 |
+
/// ADX, Intel ADX (Multi-Precision Add-Carry Instruction Extensions)
|
| 270 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] rtm: "rtm";
|
| 271 |
+
/// RTM, Intel (Restricted Transactional Memory)
|
| 272 |
+
@FEATURE: #[stable(feature = "movbe_target_feature", since = "1.67.0")] movbe: "movbe";
|
| 273 |
+
/// MOVBE (Move Data After Swapping Bytes)
|
| 274 |
+
@FEATURE: #[unstable(feature = "movrs_target_feature", issue = "137976")] movrs: "movrs";
|
| 275 |
+
/// MOVRS (Move data with the read-shared hint)
|
| 276 |
+
@FEATURE: #[stable(feature = "simd_x86", since = "1.27.0")] ermsb: "ermsb";
|
| 277 |
+
/// ERMSB, Enhanced REP MOVSB and STOSB
|
| 278 |
+
@FEATURE: #[unstable(feature = "xop_target_feature", issue = "127208")] xop: "xop";
|
| 279 |
+
/// XOP: eXtended Operations (AMD)
|
| 280 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/bit.rs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Bit manipulation utilities.
|
| 2 |
+
|
| 3 |
+
/// Tests the `bit` of `x`.
|
| 4 |
+
#[allow(dead_code)]
|
| 5 |
+
#[inline]
|
| 6 |
+
pub(crate) fn test(x: usize, bit: u32) -> bool {
|
| 7 |
+
debug_assert!(bit < usize::BITS, "bit index out-of-bounds");
|
| 8 |
+
x & (1 << bit) != 0
|
| 9 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/cache.rs
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Caches run-time feature detection so that it only needs to be computed
|
| 2 |
+
//! once.
|
| 3 |
+
|
| 4 |
+
#![allow(dead_code)] // not used on all platforms
|
| 5 |
+
|
| 6 |
+
use core::sync::atomic::{AtomicUsize, Ordering};
|
| 7 |
+
|
| 8 |
+
/// Sets the `bit` of `x`.
|
| 9 |
+
#[inline]
|
| 10 |
+
const fn set_bit(x: u128, bit: u32) -> u128 {
|
| 11 |
+
x | 1 << bit
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
/// Tests the `bit` of `x`.
|
| 15 |
+
#[inline]
|
| 16 |
+
const fn test_bit(x: u128, bit: u32) -> bool {
|
| 17 |
+
x & (1 << bit) != 0
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
/// Unset the `bit of `x`.
|
| 21 |
+
#[inline]
|
| 22 |
+
const fn unset_bit(x: u128, bit: u32) -> u128 {
|
| 23 |
+
x & !(1 << bit)
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
/// Maximum number of features that can be cached.
|
| 27 |
+
const CACHE_CAPACITY: u32 = 93;
|
| 28 |
+
|
| 29 |
+
/// This type is used to initialize the cache
|
| 30 |
+
// The derived `Default` implementation will initialize the field to zero,
|
| 31 |
+
// which is what we want.
|
| 32 |
+
#[derive(Copy, Clone, Default, PartialEq, Eq)]
|
| 33 |
+
pub(crate) struct Initializer(u128);
|
| 34 |
+
|
| 35 |
+
// NOTE: the `debug_assert!` would catch that we do not add more Features than
|
| 36 |
+
// the one fitting our cache.
|
| 37 |
+
impl Initializer {
|
| 38 |
+
/// Tests the `bit` of the cache.
|
| 39 |
+
#[inline]
|
| 40 |
+
pub(crate) fn test(self, bit: u32) -> bool {
|
| 41 |
+
debug_assert!(bit < CACHE_CAPACITY, "too many features, time to increase the cache size!");
|
| 42 |
+
test_bit(self.0, bit)
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
/// Sets the `bit` of the cache.
|
| 46 |
+
#[inline]
|
| 47 |
+
pub(crate) fn set(&mut self, bit: u32) {
|
| 48 |
+
debug_assert!(bit < CACHE_CAPACITY, "too many features, time to increase the cache size!");
|
| 49 |
+
let v = self.0;
|
| 50 |
+
self.0 = set_bit(v, bit);
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
/// Unsets the `bit` of the cache.
|
| 54 |
+
#[inline]
|
| 55 |
+
pub(crate) fn unset(&mut self, bit: u32) {
|
| 56 |
+
debug_assert!(bit < CACHE_CAPACITY, "too many features, time to increase the cache size!");
|
| 57 |
+
let v = self.0;
|
| 58 |
+
self.0 = unset_bit(v, bit);
|
| 59 |
+
}
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
/// This global variable is a cache of the features supported by the CPU.
|
| 63 |
+
// Note: the third slot is only used in x86
|
| 64 |
+
// Another Slot can be added if needed without any change to `Initializer`
|
| 65 |
+
static CACHE: [Cache; 3] = [Cache::uninitialized(), Cache::uninitialized(), Cache::uninitialized()];
|
| 66 |
+
|
| 67 |
+
/// Feature cache with capacity for `size_of::<usize>() * 8 - 1` features.
|
| 68 |
+
///
|
| 69 |
+
/// Note: 0 is used to represent an uninitialized cache, and (at least) the most
|
| 70 |
+
/// significant bit is set on any cache which has been initialized.
|
| 71 |
+
///
|
| 72 |
+
/// Note: we use `Relaxed` atomic operations, because we are only interested in
|
| 73 |
+
/// the effects of operations on a single memory location. That is, we only need
|
| 74 |
+
/// "modification order", and not the full-blown "happens before".
|
| 75 |
+
struct Cache(AtomicUsize);
|
| 76 |
+
|
| 77 |
+
impl Cache {
|
| 78 |
+
const CAPACITY: u32 = (core::mem::size_of::<usize>() * 8 - 1) as u32;
|
| 79 |
+
const MASK: usize = (1 << Cache::CAPACITY) - 1;
|
| 80 |
+
const INITIALIZED_BIT: usize = 1usize << Cache::CAPACITY;
|
| 81 |
+
|
| 82 |
+
/// Creates an uninitialized cache.
|
| 83 |
+
#[allow(clippy::declare_interior_mutable_const)]
|
| 84 |
+
const fn uninitialized() -> Self {
|
| 85 |
+
Cache(AtomicUsize::new(0))
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
/// Is the `bit` in the cache set? Returns `None` if the cache has not been initialized.
|
| 89 |
+
#[inline]
|
| 90 |
+
pub(crate) fn test(&self, bit: u32) -> Option<bool> {
|
| 91 |
+
let cached = self.0.load(Ordering::Relaxed);
|
| 92 |
+
if cached == 0 { None } else { Some(test_bit(cached as u128, bit)) }
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/// Initializes the cache.
|
| 96 |
+
#[inline]
|
| 97 |
+
fn initialize(&self, value: usize) -> usize {
|
| 98 |
+
debug_assert_eq!((value & !Cache::MASK), 0);
|
| 99 |
+
self.0.store(value | Cache::INITIALIZED_BIT, Ordering::Relaxed);
|
| 100 |
+
value
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
+
|
| 104 |
+
cfg_select! {
|
| 105 |
+
feature = "std_detect_env_override" => {
|
| 106 |
+
#[inline]
|
| 107 |
+
fn disable_features(disable: &[u8], value: &mut Initializer) {
|
| 108 |
+
if let Ok(disable) = core::str::from_utf8(disable) {
|
| 109 |
+
for v in disable.split(" ") {
|
| 110 |
+
let _ = super::Feature::from_str(v).map(|v| value.unset(v as u32));
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
#[inline]
|
| 116 |
+
fn initialize(mut value: Initializer) -> Initializer {
|
| 117 |
+
use core::ffi::CStr;
|
| 118 |
+
const RUST_STD_DETECT_UNSTABLE: &CStr = c"RUST_STD_DETECT_UNSTABLE";
|
| 119 |
+
cfg_select! {
|
| 120 |
+
windows => {
|
| 121 |
+
use alloc::vec;
|
| 122 |
+
#[link(name = "kernel32")]
|
| 123 |
+
unsafe extern "system" {
|
| 124 |
+
fn GetEnvironmentVariableA(name: *const u8, buffer: *mut u8, size: u32) -> u32;
|
| 125 |
+
}
|
| 126 |
+
let len = unsafe { GetEnvironmentVariableA(RUST_STD_DETECT_UNSTABLE.as_ptr().cast::<u8>(), core::ptr::null_mut(), 0) };
|
| 127 |
+
if len > 0 {
|
| 128 |
+
// +1 to include the null terminator.
|
| 129 |
+
let mut env = vec![0; len as usize + 1];
|
| 130 |
+
let len = unsafe { GetEnvironmentVariableA(RUST_STD_DETECT_UNSTABLE.as_ptr().cast::<u8>(), env.as_mut_ptr(), len + 1) };
|
| 131 |
+
if len > 0 {
|
| 132 |
+
disable_features(&env[..len as usize], &mut value);
|
| 133 |
+
}
|
| 134 |
+
}
|
| 135 |
+
}
|
| 136 |
+
_ => {
|
| 137 |
+
let env = unsafe {
|
| 138 |
+
libc::getenv(RUST_STD_DETECT_UNSTABLE.as_ptr())
|
| 139 |
+
};
|
| 140 |
+
if !env.is_null() {
|
| 141 |
+
let len = unsafe { libc::strlen(env) };
|
| 142 |
+
let env = unsafe { core::slice::from_raw_parts(env as *const u8, len) };
|
| 143 |
+
disable_features(env, &mut value);
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
do_initialize(value);
|
| 148 |
+
value
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
_ => {
|
| 152 |
+
#[inline]
|
| 153 |
+
fn initialize(value: Initializer) -> Initializer {
|
| 154 |
+
do_initialize(value);
|
| 155 |
+
value
|
| 156 |
+
}
|
| 157 |
+
}
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
#[inline]
|
| 161 |
+
fn do_initialize(value: Initializer) {
|
| 162 |
+
CACHE[0].initialize((value.0) as usize & Cache::MASK);
|
| 163 |
+
CACHE[1].initialize((value.0 >> Cache::CAPACITY) as usize & Cache::MASK);
|
| 164 |
+
CACHE[2].initialize((value.0 >> (2 * Cache::CAPACITY)) as usize & Cache::MASK);
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
// We only have to detect features once, and it's fairly costly, so hint to LLVM
|
| 168 |
+
// that it should assume that cache hits are more common than misses (which is
|
| 169 |
+
// the point of caching). It's possibly unfortunate that this function needs to
|
| 170 |
+
// reach across modules like this to call `os::detect_features`, but it produces
|
| 171 |
+
// the best code out of several attempted variants.
|
| 172 |
+
//
|
| 173 |
+
// The `Initializer` that the cache was initialized with is returned, so that
|
| 174 |
+
// the caller can call `test()` on it without having to load the value from the
|
| 175 |
+
// cache again.
|
| 176 |
+
#[cold]
|
| 177 |
+
fn detect_and_initialize() -> Initializer {
|
| 178 |
+
initialize(super::os::detect_features())
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
/// Tests the `bit` of the storage. If the storage has not been initialized,
|
| 182 |
+
/// initializes it with the result of `os::detect_features()`.
|
| 183 |
+
///
|
| 184 |
+
/// On its first invocation, it detects the CPU features and caches them in the
|
| 185 |
+
/// `CACHE` global variable as an `AtomicU64`.
|
| 186 |
+
///
|
| 187 |
+
/// It uses the `Feature` variant to index into this variable as a bitset. If
|
| 188 |
+
/// the bit is set, the feature is enabled, and otherwise it is disabled.
|
| 189 |
+
///
|
| 190 |
+
/// If the feature `std_detect_env_override` is enabled looks for the env
|
| 191 |
+
/// variable `RUST_STD_DETECT_UNSTABLE` and uses its content to disable
|
| 192 |
+
/// Features that would had been otherwise detected.
|
| 193 |
+
#[inline]
|
| 194 |
+
pub(crate) fn test(bit: u32) -> bool {
|
| 195 |
+
let (relative_bit, idx) = if bit < Cache::CAPACITY {
|
| 196 |
+
(bit, 0)
|
| 197 |
+
} else if bit < 2 * Cache::CAPACITY {
|
| 198 |
+
(bit - Cache::CAPACITY, 1)
|
| 199 |
+
} else {
|
| 200 |
+
(bit - 2 * Cache::CAPACITY, 2)
|
| 201 |
+
};
|
| 202 |
+
CACHE[idx].test(relative_bit).unwrap_or_else(|| detect_and_initialize().test(bit))
|
| 203 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/macros.rs
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#[macro_export]
|
| 2 |
+
#[allow_internal_unstable(stdarch_internal)]
|
| 3 |
+
#[unstable(feature = "stdarch_internal", issue = "none")]
|
| 4 |
+
macro_rules! detect_feature {
|
| 5 |
+
($feature:tt, $feature_lit:tt) => {
|
| 6 |
+
$crate::detect_feature!($feature, $feature_lit : $feature_lit)
|
| 7 |
+
};
|
| 8 |
+
($feature:tt, $feature_lit:tt : $($target_feature_lit:tt),*) => {
|
| 9 |
+
$(cfg!(target_feature = $target_feature_lit) ||)*
|
| 10 |
+
$crate::detect::__is_feature_detected::$feature()
|
| 11 |
+
};
|
| 12 |
+
($feature:tt, $feature_lit:tt, without cfg check: true) => {
|
| 13 |
+
$crate::detect::__is_feature_detected::$feature()
|
| 14 |
+
};
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
#[allow(unused_macros, reason = "it's used in the features! macro below")]
|
| 18 |
+
macro_rules! check_cfg_feature {
|
| 19 |
+
($feature:tt, $feature_lit:tt) => {
|
| 20 |
+
check_cfg_feature!($feature, $feature_lit : $feature_lit)
|
| 21 |
+
};
|
| 22 |
+
($feature:tt, $feature_lit:tt : $($target_feature_lit:tt),*) => {
|
| 23 |
+
$(cfg!(target_feature = $target_feature_lit);)*
|
| 24 |
+
};
|
| 25 |
+
($feature:tt, $feature_lit:tt, without cfg check: $feature_cfg_check:literal) => {
|
| 26 |
+
#[allow(unexpected_cfgs, reason = $feature_lit)]
|
| 27 |
+
{ cfg!(target_feature = $feature_lit) }
|
| 28 |
+
};
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
#[allow(unused)]
|
| 32 |
+
macro_rules! features {
|
| 33 |
+
(
|
| 34 |
+
@TARGET: $target:ident;
|
| 35 |
+
@CFG: $cfg:meta;
|
| 36 |
+
@MACRO_NAME: $macro_name:ident;
|
| 37 |
+
@MACRO_ATTRS: $(#[$macro_attrs:meta])*
|
| 38 |
+
$(@BIND_FEATURE_NAME: $bind_feature:tt; $feature_impl:tt; $(#[$deprecate_attr:meta];)?)*
|
| 39 |
+
$(@NO_RUNTIME_DETECTION: $nort_feature:tt; )*
|
| 40 |
+
$(@FEATURE: #[$stability_attr:meta] $feature:ident: $feature_lit:tt;
|
| 41 |
+
$(without cfg check: $feature_cfg_check:tt;)?
|
| 42 |
+
$(implied by target_features: [$($target_feature_lit:tt),*];)?
|
| 43 |
+
$(#[$feature_comment:meta])*)*
|
| 44 |
+
) => {
|
| 45 |
+
#[macro_export]
|
| 46 |
+
$(#[$macro_attrs])*
|
| 47 |
+
#[allow_internal_unstable(stdarch_internal)]
|
| 48 |
+
#[cfg($cfg)]
|
| 49 |
+
#[doc(cfg($cfg))]
|
| 50 |
+
macro_rules! $macro_name {
|
| 51 |
+
$(
|
| 52 |
+
($feature_lit) => {
|
| 53 |
+
$crate::detect_feature!($feature, $feature_lit $(, without cfg check: $feature_cfg_check)? $(: $($target_feature_lit),*)?)
|
| 54 |
+
};
|
| 55 |
+
)*
|
| 56 |
+
$(
|
| 57 |
+
($bind_feature) => {
|
| 58 |
+
{
|
| 59 |
+
$(
|
| 60 |
+
#[$deprecate_attr] macro_rules! deprecated_feature { {} => {}; }
|
| 61 |
+
deprecated_feature! {};
|
| 62 |
+
)?
|
| 63 |
+
$crate::$macro_name!($feature_impl)
|
| 64 |
+
}
|
| 65 |
+
};
|
| 66 |
+
)*
|
| 67 |
+
$(
|
| 68 |
+
($nort_feature) => {
|
| 69 |
+
compile_error!(
|
| 70 |
+
concat!(
|
| 71 |
+
stringify!($nort_feature),
|
| 72 |
+
" feature cannot be detected at run-time"
|
| 73 |
+
)
|
| 74 |
+
)
|
| 75 |
+
};
|
| 76 |
+
)*
|
| 77 |
+
($t:tt,) => {
|
| 78 |
+
$crate::$macro_name!($t);
|
| 79 |
+
};
|
| 80 |
+
($t:tt) => {
|
| 81 |
+
compile_error!(
|
| 82 |
+
concat!(
|
| 83 |
+
concat!("unknown ", stringify!($target)),
|
| 84 |
+
concat!(" target feature: ", $t)
|
| 85 |
+
)
|
| 86 |
+
)
|
| 87 |
+
};
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
$(#[$macro_attrs])*
|
| 91 |
+
#[macro_export]
|
| 92 |
+
#[cfg(not($cfg))]
|
| 93 |
+
#[doc(cfg($cfg))]
|
| 94 |
+
macro_rules! $macro_name {
|
| 95 |
+
$(
|
| 96 |
+
($feature_lit) => {
|
| 97 |
+
compile_error!(
|
| 98 |
+
concat!(
|
| 99 |
+
r#"This macro cannot be used on the current target.
|
| 100 |
+
You can prevent it from being used in other architectures by
|
| 101 |
+
guarding it behind a cfg("#,
|
| 102 |
+
stringify!($cfg),
|
| 103 |
+
")."
|
| 104 |
+
)
|
| 105 |
+
)
|
| 106 |
+
};
|
| 107 |
+
)*
|
| 108 |
+
$(
|
| 109 |
+
($bind_feature) => { $crate::$macro_name!($feature_impl) };
|
| 110 |
+
)*
|
| 111 |
+
$(
|
| 112 |
+
($nort_feature) => {
|
| 113 |
+
compile_error!(
|
| 114 |
+
concat!(
|
| 115 |
+
stringify!($nort_feature),
|
| 116 |
+
" feature cannot be detected at run-time"
|
| 117 |
+
)
|
| 118 |
+
)
|
| 119 |
+
};
|
| 120 |
+
)*
|
| 121 |
+
($t:tt,) => {
|
| 122 |
+
$crate::$macro_name!($t);
|
| 123 |
+
};
|
| 124 |
+
($t:tt) => {
|
| 125 |
+
compile_error!(
|
| 126 |
+
concat!(
|
| 127 |
+
concat!("unknown ", stringify!($target)),
|
| 128 |
+
concat!(" target feature: ", $t)
|
| 129 |
+
)
|
| 130 |
+
)
|
| 131 |
+
};
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
#[deny(unexpected_cfgs)]
|
| 135 |
+
#[deny(unfulfilled_lint_expectations)]
|
| 136 |
+
const _: () = {
|
| 137 |
+
$(
|
| 138 |
+
check_cfg_feature!($feature, $feature_lit $(, without cfg check: $feature_cfg_check)? $(: $($target_feature_lit),*)?);
|
| 139 |
+
)*
|
| 140 |
+
};
|
| 141 |
+
|
| 142 |
+
/// Each variant denotes a position in a bitset for a particular feature.
|
| 143 |
+
///
|
| 144 |
+
/// PLEASE: do not use this, it is an implementation detail subject
|
| 145 |
+
/// to change.
|
| 146 |
+
#[doc(hidden)]
|
| 147 |
+
#[allow(non_camel_case_types)]
|
| 148 |
+
#[derive(Copy, Clone)]
|
| 149 |
+
#[repr(u8)]
|
| 150 |
+
#[unstable(feature = "stdarch_internal", issue = "none")]
|
| 151 |
+
#[cfg($cfg)]
|
| 152 |
+
pub(crate) enum Feature {
|
| 153 |
+
$(
|
| 154 |
+
$(#[$feature_comment])*
|
| 155 |
+
$feature,
|
| 156 |
+
)*
|
| 157 |
+
|
| 158 |
+
// Do not add variants after last:
|
| 159 |
+
_last
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
#[cfg($cfg)]
|
| 163 |
+
impl Feature {
|
| 164 |
+
pub(crate) fn to_str(self) -> &'static str {
|
| 165 |
+
match self {
|
| 166 |
+
$(Feature::$feature => $feature_lit,)*
|
| 167 |
+
Feature::_last => unreachable!(),
|
| 168 |
+
}
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
+
#[cfg(feature = "std_detect_env_override")]
|
| 172 |
+
pub(crate) fn from_str(s: &str) -> Result<Feature, ()> {
|
| 173 |
+
match s {
|
| 174 |
+
$($feature_lit => Ok(Feature::$feature),)*
|
| 175 |
+
_ => Err(())
|
| 176 |
+
}
|
| 177 |
+
}
|
| 178 |
+
}
|
| 179 |
+
|
| 180 |
+
/// Each function performs run-time feature detection for a single
|
| 181 |
+
/// feature. This allow us to use stability attributes on a per feature
|
| 182 |
+
/// basis.
|
| 183 |
+
///
|
| 184 |
+
/// PLEASE: do not use this, it is an implementation detail subject
|
| 185 |
+
/// to change.
|
| 186 |
+
#[doc(hidden)]
|
| 187 |
+
#[cfg($cfg)]
|
| 188 |
+
#[unstable(feature = "stdarch_internal", issue = "none")]
|
| 189 |
+
pub mod __is_feature_detected {
|
| 190 |
+
$(
|
| 191 |
+
|
| 192 |
+
/// PLEASE: do not use this, it is an implementation detail
|
| 193 |
+
/// subject to change.
|
| 194 |
+
#[inline]
|
| 195 |
+
#[doc(hidden)]
|
| 196 |
+
#[$stability_attr]
|
| 197 |
+
pub fn $feature() -> bool {
|
| 198 |
+
$crate::detect::check_for($crate::detect::Feature::$feature)
|
| 199 |
+
}
|
| 200 |
+
)*
|
| 201 |
+
}
|
| 202 |
+
};
|
| 203 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/mod.rs
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! This module implements run-time feature detection.
|
| 2 |
+
//!
|
| 3 |
+
//! The `is_{arch}_feature_detected!("feature-name")` macros take the name of a
|
| 4 |
+
//! feature as a string-literal, and return a boolean indicating whether the
|
| 5 |
+
//! feature is enabled at run-time or not.
|
| 6 |
+
//!
|
| 7 |
+
//! These macros do two things:
|
| 8 |
+
//! * map the string-literal into an integer stored as a `Feature` enum,
|
| 9 |
+
//! * call a `os::check_for(x: Feature)` function that returns `true` if the
|
| 10 |
+
//! feature is enabled.
|
| 11 |
+
//!
|
| 12 |
+
//! The `Feature` enums are also implemented in the `arch/{target_arch}.rs`
|
| 13 |
+
//! modules.
|
| 14 |
+
//!
|
| 15 |
+
//! The `check_for` functions are, in general, Operating System dependent. Most
|
| 16 |
+
//! architectures do not allow user-space programs to query the feature bits
|
| 17 |
+
//! due to security concerns (x86 is the big exception). These functions are
|
| 18 |
+
//! implemented in the `os/{target_os}.rs` modules.
|
| 19 |
+
|
| 20 |
+
#[macro_use]
|
| 21 |
+
mod macros;
|
| 22 |
+
|
| 23 |
+
mod arch;
|
| 24 |
+
|
| 25 |
+
// This module needs to be public because the `is_{arch}_feature_detected!`
|
| 26 |
+
// macros expand calls to items within it in user crates.
|
| 27 |
+
#[doc(hidden)]
|
| 28 |
+
#[unstable(feature = "stdarch_internal", issue = "none")]
|
| 29 |
+
pub use self::arch::__is_feature_detected;
|
| 30 |
+
pub(crate) use self::arch::Feature;
|
| 31 |
+
|
| 32 |
+
mod bit;
|
| 33 |
+
mod cache;
|
| 34 |
+
|
| 35 |
+
cfg_select! {
|
| 36 |
+
miri => {
|
| 37 |
+
// When running under miri all target-features that are not enabled at
|
| 38 |
+
// compile-time are reported as disabled at run-time.
|
| 39 |
+
//
|
| 40 |
+
// For features for which `cfg(target_feature)` returns true,
|
| 41 |
+
// this run-time detection logic is never called.
|
| 42 |
+
#[path = "os/other.rs"]
|
| 43 |
+
mod os;
|
| 44 |
+
}
|
| 45 |
+
any(target_arch = "x86", target_arch = "x86_64") => {
|
| 46 |
+
// On x86/x86_64 no OS specific functionality is required.
|
| 47 |
+
#[path = "os/x86.rs"]
|
| 48 |
+
mod os;
|
| 49 |
+
}
|
| 50 |
+
any(target_os = "linux", target_os = "android") => {
|
| 51 |
+
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
|
| 52 |
+
#[path = "os/riscv.rs"]
|
| 53 |
+
mod riscv;
|
| 54 |
+
#[path = "os/linux/mod.rs"]
|
| 55 |
+
mod os;
|
| 56 |
+
}
|
| 57 |
+
target_os = "freebsd" => {
|
| 58 |
+
#[cfg(target_arch = "aarch64")]
|
| 59 |
+
#[path = "os/aarch64.rs"]
|
| 60 |
+
mod aarch64;
|
| 61 |
+
#[path = "os/freebsd/mod.rs"]
|
| 62 |
+
mod os;
|
| 63 |
+
}
|
| 64 |
+
target_os = "openbsd" => {
|
| 65 |
+
#[allow(dead_code)] // we don't use code that calls the mrs instruction.
|
| 66 |
+
#[cfg(target_arch = "aarch64")]
|
| 67 |
+
#[path = "os/aarch64.rs"]
|
| 68 |
+
mod aarch64;
|
| 69 |
+
#[path = "os/openbsd/mod.rs"]
|
| 70 |
+
mod os;
|
| 71 |
+
}
|
| 72 |
+
all(target_os = "windows", any(target_arch = "aarch64", target_arch = "arm64ec")) => {
|
| 73 |
+
#[path = "os/windows/aarch64.rs"]
|
| 74 |
+
mod os;
|
| 75 |
+
}
|
| 76 |
+
all(target_vendor = "apple", target_arch = "aarch64") => {
|
| 77 |
+
#[path = "os/darwin/aarch64.rs"]
|
| 78 |
+
mod os;
|
| 79 |
+
}
|
| 80 |
+
_ => {
|
| 81 |
+
#[path = "os/other.rs"]
|
| 82 |
+
mod os;
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
/// Performs run-time feature detection.
|
| 87 |
+
#[inline]
|
| 88 |
+
#[allow(dead_code)]
|
| 89 |
+
fn check_for(x: Feature) -> bool {
|
| 90 |
+
cache::test(x as u32)
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
/// Returns an `Iterator<Item=(&'static str, bool)>` where
|
| 94 |
+
/// `Item.0` is the feature name, and `Item.1` is a `bool` which
|
| 95 |
+
/// is `true` if the feature is supported by the host and `false` otherwise.
|
| 96 |
+
#[unstable(feature = "stdarch_internal", issue = "none")]
|
| 97 |
+
pub fn features() -> impl Iterator<Item = (&'static str, bool)> {
|
| 98 |
+
cfg_select! {
|
| 99 |
+
any(
|
| 100 |
+
target_arch = "x86",
|
| 101 |
+
target_arch = "x86_64",
|
| 102 |
+
target_arch = "arm",
|
| 103 |
+
target_arch = "aarch64",
|
| 104 |
+
target_arch = "arm64ec",
|
| 105 |
+
target_arch = "riscv32",
|
| 106 |
+
target_arch = "riscv64",
|
| 107 |
+
target_arch = "powerpc",
|
| 108 |
+
target_arch = "powerpc64",
|
| 109 |
+
target_arch = "mips",
|
| 110 |
+
target_arch = "mips64",
|
| 111 |
+
target_arch = "loongarch32",
|
| 112 |
+
target_arch = "loongarch64",
|
| 113 |
+
target_arch = "s390x",
|
| 114 |
+
) => {
|
| 115 |
+
(0_u8..Feature::_last as u8).map(|discriminant: u8| {
|
| 116 |
+
#[allow(bindings_with_variant_name)] // RISC-V has Feature::f
|
| 117 |
+
let f: Feature = unsafe { core::mem::transmute(discriminant) };
|
| 118 |
+
let name: &'static str = f.to_str();
|
| 119 |
+
let enabled: bool = check_for(f);
|
| 120 |
+
(name, enabled)
|
| 121 |
+
})
|
| 122 |
+
}
|
| 123 |
+
_ => None.into_iter(),
|
| 124 |
+
}
|
| 125 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/aarch64.rs
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for Aarch64 on any OS that emulates the mrs instruction.
|
| 2 |
+
//!
|
| 3 |
+
//! On FreeBSD >= 12.0, Linux >= 4.11 and other operating systems, it is possible to use
|
| 4 |
+
//! privileged system registers from userspace to check CPU feature support.
|
| 5 |
+
//!
|
| 6 |
+
//! AArch64 system registers ID_AA64ISAR0_EL1, ID_AA64PFR0_EL1, ID_AA64ISAR1_EL1
|
| 7 |
+
//! have bits dedicated to features like AdvSIMD, CRC32, AES, atomics (LSE), etc.
|
| 8 |
+
//! Each part of the register indicates the level of support for a certain feature, e.g.
|
| 9 |
+
//! when ID_AA64ISAR0_EL1\[7:4\] is >= 1, AES is supported; when it's >= 2, PMULL is supported.
|
| 10 |
+
//!
|
| 11 |
+
//! For proper support of [SoCs where different cores have different capabilities](https://medium.com/@jadr2ddude/a-big-little-problem-a-tale-of-big-little-gone-wrong-e7778ce744bb),
|
| 12 |
+
//! the OS has to always report only the features supported by all cores, like [FreeBSD does](https://reviews.freebsd.org/D17137#393947).
|
| 13 |
+
//!
|
| 14 |
+
//! References:
|
| 15 |
+
//!
|
| 16 |
+
//! - [Zircon implementation](https://fuchsia.googlesource.com/zircon/+/master/kernel/arch/arm64/feature.cpp)
|
| 17 |
+
//! - [Linux documentation](https://www.kernel.org/doc/Documentation/arm64/cpu-feature-registers.txt)
|
| 18 |
+
//! - [ARM documentation](https://developer.arm.com/documentation/ddi0601/2022-12/AArch64-Registers?lang=en)
|
| 19 |
+
|
| 20 |
+
use core::arch::asm;
|
| 21 |
+
|
| 22 |
+
use crate::detect::{Feature, cache};
|
| 23 |
+
|
| 24 |
+
/// Try to read the features from the system registers.
|
| 25 |
+
///
|
| 26 |
+
/// This will cause SIGILL if the current OS is not trapping the mrs instruction.
|
| 27 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 28 |
+
// ID_AA64ISAR0_EL1 - Instruction Set Attribute Register 0
|
| 29 |
+
let aa64isar0: u64;
|
| 30 |
+
unsafe {
|
| 31 |
+
asm!(
|
| 32 |
+
"mrs {}, ID_AA64ISAR0_EL1",
|
| 33 |
+
out(reg) aa64isar0,
|
| 34 |
+
options(pure, nomem, preserves_flags, nostack)
|
| 35 |
+
);
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
// ID_AA64ISAR1_EL1 - Instruction Set Attribute Register 1
|
| 39 |
+
let aa64isar1: u64;
|
| 40 |
+
unsafe {
|
| 41 |
+
asm!(
|
| 42 |
+
"mrs {}, ID_AA64ISAR1_EL1",
|
| 43 |
+
out(reg) aa64isar1,
|
| 44 |
+
options(pure, nomem, preserves_flags, nostack)
|
| 45 |
+
);
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
// ID_AA64MMFR2_EL1 - AArch64 Memory Model Feature Register 2
|
| 49 |
+
let aa64mmfr2: u64;
|
| 50 |
+
unsafe {
|
| 51 |
+
asm!(
|
| 52 |
+
"mrs {}, ID_AA64MMFR2_EL1",
|
| 53 |
+
out(reg) aa64mmfr2,
|
| 54 |
+
options(pure, nomem, preserves_flags, nostack)
|
| 55 |
+
);
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// ID_AA64PFR0_EL1 - Processor Feature Register 0
|
| 59 |
+
let aa64pfr0: u64;
|
| 60 |
+
unsafe {
|
| 61 |
+
asm!(
|
| 62 |
+
"mrs {}, ID_AA64PFR0_EL1",
|
| 63 |
+
out(reg) aa64pfr0,
|
| 64 |
+
options(pure, nomem, preserves_flags, nostack)
|
| 65 |
+
);
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
parse_system_registers(aa64isar0, aa64isar1, aa64mmfr2, Some(aa64pfr0))
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
pub(crate) fn parse_system_registers(
|
| 72 |
+
aa64isar0: u64,
|
| 73 |
+
aa64isar1: u64,
|
| 74 |
+
aa64mmfr2: u64,
|
| 75 |
+
aa64pfr0: Option<u64>,
|
| 76 |
+
) -> cache::Initializer {
|
| 77 |
+
let mut value = cache::Initializer::default();
|
| 78 |
+
|
| 79 |
+
let mut enable_feature = |f, enable| {
|
| 80 |
+
if enable {
|
| 81 |
+
value.set(f as u32);
|
| 82 |
+
}
|
| 83 |
+
};
|
| 84 |
+
|
| 85 |
+
// ID_AA64ISAR0_EL1 - Instruction Set Attribute Register 0
|
| 86 |
+
enable_feature(Feature::pmull, bits_shift(aa64isar0, 7, 4) >= 2);
|
| 87 |
+
enable_feature(Feature::lse, bits_shift(aa64isar0, 23, 20) >= 2);
|
| 88 |
+
enable_feature(Feature::crc, bits_shift(aa64isar0, 19, 16) >= 1);
|
| 89 |
+
|
| 90 |
+
// ID_AA64PFR0_EL1 - Processor Feature Register 0
|
| 91 |
+
if let Some(aa64pfr0) = aa64pfr0 {
|
| 92 |
+
let fp = bits_shift(aa64pfr0, 19, 16) < 0xF;
|
| 93 |
+
let fphp = bits_shift(aa64pfr0, 19, 16) >= 1;
|
| 94 |
+
let asimd = bits_shift(aa64pfr0, 23, 20) < 0xF;
|
| 95 |
+
let asimdhp = bits_shift(aa64pfr0, 23, 20) >= 1;
|
| 96 |
+
enable_feature(Feature::fp, fp);
|
| 97 |
+
enable_feature(Feature::fp16, fphp);
|
| 98 |
+
// SIMD support requires float support - if half-floats are
|
| 99 |
+
// supported, it also requires half-float support:
|
| 100 |
+
enable_feature(Feature::asimd, fp && asimd && (!fphp | asimdhp));
|
| 101 |
+
// SIMD extensions require SIMD support:
|
| 102 |
+
enable_feature(Feature::aes, asimd && bits_shift(aa64isar0, 7, 4) >= 2);
|
| 103 |
+
let sha1 = bits_shift(aa64isar0, 11, 8) >= 1;
|
| 104 |
+
let sha2 = bits_shift(aa64isar0, 15, 12) >= 1;
|
| 105 |
+
enable_feature(Feature::sha2, asimd && sha1 && sha2);
|
| 106 |
+
enable_feature(Feature::rdm, asimd && bits_shift(aa64isar0, 31, 28) >= 1);
|
| 107 |
+
enable_feature(Feature::dotprod, asimd && bits_shift(aa64isar0, 47, 44) >= 1);
|
| 108 |
+
enable_feature(Feature::sve, asimd && bits_shift(aa64pfr0, 35, 32) >= 1);
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
// ID_AA64ISAR1_EL1 - Instruction Set Attribute Register 1
|
| 112 |
+
// Check for either APA or API field
|
| 113 |
+
enable_feature(Feature::paca, bits_shift(aa64isar1, 11, 4) >= 1);
|
| 114 |
+
enable_feature(Feature::rcpc, bits_shift(aa64isar1, 23, 20) >= 1);
|
| 115 |
+
// Check for either GPA or GPI field
|
| 116 |
+
enable_feature(Feature::pacg, bits_shift(aa64isar1, 31, 24) >= 1);
|
| 117 |
+
|
| 118 |
+
// ID_AA64MMFR2_EL1 - AArch64 Memory Model Feature Register 2
|
| 119 |
+
enable_feature(Feature::lse2, bits_shift(aa64mmfr2, 35, 32) >= 1);
|
| 120 |
+
|
| 121 |
+
value
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
#[inline]
|
| 125 |
+
fn bits_shift(x: u64, high: usize, low: usize) -> u64 {
|
| 126 |
+
(x >> low) & ((1 << (high - low + 1)) - 1)
|
| 127 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/darwin/aarch64.rs
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for aarch64 on Darwin (macOS/iOS/tvOS/watchOS/visionOS).
|
| 2 |
+
//!
|
| 3 |
+
//! <https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics>
|
| 4 |
+
|
| 5 |
+
use core::ffi::CStr;
|
| 6 |
+
|
| 7 |
+
use crate::detect::{Feature, cache};
|
| 8 |
+
|
| 9 |
+
#[inline]
|
| 10 |
+
fn _sysctlbyname(name: &CStr) -> bool {
|
| 11 |
+
use libc;
|
| 12 |
+
|
| 13 |
+
let mut enabled: i32 = 0;
|
| 14 |
+
let mut enabled_len: usize = 4;
|
| 15 |
+
let enabled_ptr = &mut enabled as *mut i32 as *mut libc::c_void;
|
| 16 |
+
|
| 17 |
+
let ret = unsafe {
|
| 18 |
+
libc::sysctlbyname(name.as_ptr(), enabled_ptr, &mut enabled_len, core::ptr::null_mut(), 0)
|
| 19 |
+
};
|
| 20 |
+
|
| 21 |
+
match ret {
|
| 22 |
+
0 => enabled != 0,
|
| 23 |
+
_ => false,
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/// Try to read the features using sysctlbyname.
|
| 28 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 29 |
+
let mut value = cache::Initializer::default();
|
| 30 |
+
|
| 31 |
+
let mut enable_feature = |f, enable| {
|
| 32 |
+
if enable {
|
| 33 |
+
value.set(f as u32);
|
| 34 |
+
}
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
// Armv8.0 features not using the standard identifiers
|
| 38 |
+
let fp = _sysctlbyname(c"hw.optional.floatingpoint");
|
| 39 |
+
let asimd = _sysctlbyname(c"hw.optional.AdvSIMD");
|
| 40 |
+
let crc_old = _sysctlbyname(c"hw.optional.armv8_crc32");
|
| 41 |
+
|
| 42 |
+
// Armv8 and Armv9 features using the standard identifiers
|
| 43 |
+
let aes = _sysctlbyname(c"hw.optional.arm.FEAT_AES");
|
| 44 |
+
let bf16 = _sysctlbyname(c"hw.optional.arm.FEAT_BF16");
|
| 45 |
+
let bti = _sysctlbyname(c"hw.optional.arm.FEAT_BTI");
|
| 46 |
+
let crc = _sysctlbyname(c"hw.optional.arm.FEAT_CRC32");
|
| 47 |
+
let cssc = _sysctlbyname(c"hw.optional.arm.FEAT_CSSC");
|
| 48 |
+
let dit = _sysctlbyname(c"hw.optional.arm.FEAT_DIT");
|
| 49 |
+
let dotprod = _sysctlbyname(c"hw.optional.arm.FEAT_DotProd");
|
| 50 |
+
let dpb = _sysctlbyname(c"hw.optional.arm.FEAT_DPB");
|
| 51 |
+
let dpb2 = _sysctlbyname(c"hw.optional.arm.FEAT_DPB2");
|
| 52 |
+
let ecv = _sysctlbyname(c"hw.optional.arm.FEAT_ECV");
|
| 53 |
+
let fcma = _sysctlbyname(c"hw.optional.arm.FEAT_FCMA");
|
| 54 |
+
let fhm = _sysctlbyname(c"hw.optional.arm.FEAT_FHM");
|
| 55 |
+
let flagm = _sysctlbyname(c"hw.optional.arm.FEAT_FlagM");
|
| 56 |
+
let flagm2 = _sysctlbyname(c"hw.optional.arm.FEAT_FlagM2");
|
| 57 |
+
let fp16 = _sysctlbyname(c"hw.optional.arm.FEAT_FP16");
|
| 58 |
+
let frintts = _sysctlbyname(c"hw.optional.arm.FEAT_FRINTTS");
|
| 59 |
+
let hbc = _sysctlbyname(c"hw.optional.arm.FEAT_HBC");
|
| 60 |
+
let i8mm = _sysctlbyname(c"hw.optional.arm.FEAT_I8MM");
|
| 61 |
+
let jsconv = _sysctlbyname(c"hw.optional.arm.FEAT_JSCVT");
|
| 62 |
+
let rcpc = _sysctlbyname(c"hw.optional.arm.FEAT_LRCPC");
|
| 63 |
+
let rcpc2 = _sysctlbyname(c"hw.optional.arm.FEAT_LRCPC2");
|
| 64 |
+
let lse = _sysctlbyname(c"hw.optional.arm.FEAT_LSE");
|
| 65 |
+
let lse2 = _sysctlbyname(c"hw.optional.arm.FEAT_LSE2");
|
| 66 |
+
let mte = _sysctlbyname(c"hw.optional.arm.FEAT_MTE");
|
| 67 |
+
let mte2 = _sysctlbyname(c"hw.optional.arm.FEAT_MTE2");
|
| 68 |
+
let pauth = _sysctlbyname(c"hw.optional.arm.FEAT_PAuth");
|
| 69 |
+
let pmull = _sysctlbyname(c"hw.optional.arm.FEAT_PMULL");
|
| 70 |
+
let rdm = _sysctlbyname(c"hw.optional.arm.FEAT_RDM");
|
| 71 |
+
let sb = _sysctlbyname(c"hw.optional.arm.FEAT_SB");
|
| 72 |
+
let sha1 = _sysctlbyname(c"hw.optional.arm.FEAT_SHA1");
|
| 73 |
+
let sha256 = _sysctlbyname(c"hw.optional.arm.FEAT_SHA256");
|
| 74 |
+
let sha3 = _sysctlbyname(c"hw.optional.arm.FEAT_SHA3");
|
| 75 |
+
let sha512 = _sysctlbyname(c"hw.optional.arm.FEAT_SHA512");
|
| 76 |
+
let sme = _sysctlbyname(c"hw.optional.arm.FEAT_SME");
|
| 77 |
+
let sme2 = _sysctlbyname(c"hw.optional.arm.FEAT_SME2");
|
| 78 |
+
let sme2p1 = _sysctlbyname(c"hw.optional.arm.FEAT_SME2p1");
|
| 79 |
+
let sme_b16b16 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_B16B16");
|
| 80 |
+
let sme_f16f16 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_F16F16");
|
| 81 |
+
let sme_f64f64 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_F64F64");
|
| 82 |
+
let sme_i16i64 = _sysctlbyname(c"hw.optional.arm.FEAT_SME_I16I64");
|
| 83 |
+
let ssbs = _sysctlbyname(c"hw.optional.arm.FEAT_SSBS");
|
| 84 |
+
let wfxt = _sysctlbyname(c"hw.optional.arm.FEAT_WFxT");
|
| 85 |
+
|
| 86 |
+
// The following features are not exposed by `is_aarch64_feature_detected`,
|
| 87 |
+
// but *are* reported by `sysctl`. They are here as documentation that they
|
| 88 |
+
// exist, and may potentially be exposed later.
|
| 89 |
+
/*
|
| 90 |
+
let afp = _sysctlbyname(c"hw.optional.arm.FEAT_AFP");
|
| 91 |
+
let csv2 = _sysctlbyname(c"hw.optional.arm.FEAT_CSV2");
|
| 92 |
+
let csv3 = _sysctlbyname(c"hw.optional.arm.FEAT_CSV3");
|
| 93 |
+
let ebf16 = _sysctlbyname(c"hw.optional.arm.FEAT_EBF16");
|
| 94 |
+
let fpac = _sysctlbyname(c"hw.optional.arm.FEAT_FPAC");
|
| 95 |
+
let fpaccombine = _sysctlbyname(c"hw.optional.arm.FEAT_FPACCOMBINE");
|
| 96 |
+
let mte_async = _sysctlbyname(c"hw.optional.arm.FEAT_MTE_ASYNC");
|
| 97 |
+
let mte_canonical_tags = _sysctlbyname(c"hw.optional.arm.FEAT_MTE_CANONICAL_TAGS");
|
| 98 |
+
let mte_no_address_tags = _sysctlbyname(c"hw.optional.arm.FEAT_MTE_NO_ADDRESS_TAGS");
|
| 99 |
+
let mte_store_only = _sysctlbyname(c"hw.optional.arm.FEAT_MTE_STORE_ONLY");
|
| 100 |
+
let mte3 = _sysctlbyname(c"hw.optional.arm.FEAT_MTE3");
|
| 101 |
+
let mte4 = _sysctlbyname(c"hw.optional.arm.FEAT_MTE4");
|
| 102 |
+
let pacimp = _sysctlbyname(c"hw.optional.arm.FEAT_PACIMP");
|
| 103 |
+
let pauth2 = _sysctlbyname(c"hw.optional.arm.FEAT_PAuth2");
|
| 104 |
+
let rpres = _sysctlbyname(c"hw.optional.arm.FEAT_RPRES");
|
| 105 |
+
let specres = _sysctlbyname(c"hw.optional.arm.FEAT_SPECRES");
|
| 106 |
+
let specres2 = _sysctlbyname(c"hw.optional.arm.FEAT_SPECRES2");
|
| 107 |
+
*/
|
| 108 |
+
|
| 109 |
+
// The following "features" are reported by `sysctl` but are mandatory parts
|
| 110 |
+
// of SME or SME2, and so are not exposed separately by
|
| 111 |
+
// `is_aarch64_feature_detected`. They are here to document their
|
| 112 |
+
// existence, in case they're needed in the future.
|
| 113 |
+
/*
|
| 114 |
+
let sme_b16f32 = _sysctlbyname(c"hw.optional.arm.SME_B16F32");
|
| 115 |
+
let sme_bi32i32 = _sysctlbyname(c"hw.optional.arm.SME_BI32I32");
|
| 116 |
+
let sme_f16f32 = _sysctlbyname(c"hw.optional.arm.SME_F16F32");
|
| 117 |
+
let sme_f32f32 = _sysctlbyname(c"hw.optional.arm.SME_F32F32");
|
| 118 |
+
let sme_i16i32 = _sysctlbyname(c"hw.optional.arm.SME_I16I32");
|
| 119 |
+
let sme_i8i32 = _sysctlbyname(c"hw.optional.arm.SME_I8I32");
|
| 120 |
+
*/
|
| 121 |
+
|
| 122 |
+
enable_feature(Feature::aes, aes && pmull);
|
| 123 |
+
enable_feature(Feature::asimd, asimd);
|
| 124 |
+
enable_feature(Feature::bf16, bf16);
|
| 125 |
+
enable_feature(Feature::bti, bti);
|
| 126 |
+
enable_feature(Feature::crc, crc_old || crc);
|
| 127 |
+
enable_feature(Feature::cssc, cssc);
|
| 128 |
+
enable_feature(Feature::dit, dit);
|
| 129 |
+
enable_feature(Feature::dotprod, dotprod);
|
| 130 |
+
enable_feature(Feature::dpb, dpb);
|
| 131 |
+
enable_feature(Feature::dpb2, dpb2);
|
| 132 |
+
enable_feature(Feature::ecv, ecv);
|
| 133 |
+
enable_feature(Feature::fcma, fcma);
|
| 134 |
+
enable_feature(Feature::fhm, fhm);
|
| 135 |
+
enable_feature(Feature::flagm, flagm);
|
| 136 |
+
enable_feature(Feature::flagm2, flagm2);
|
| 137 |
+
enable_feature(Feature::fp, fp);
|
| 138 |
+
enable_feature(Feature::fp16, fp16);
|
| 139 |
+
enable_feature(Feature::frintts, frintts);
|
| 140 |
+
enable_feature(Feature::hbc, hbc);
|
| 141 |
+
enable_feature(Feature::i8mm, i8mm);
|
| 142 |
+
enable_feature(Feature::jsconv, jsconv);
|
| 143 |
+
enable_feature(Feature::lse, lse);
|
| 144 |
+
enable_feature(Feature::lse2, lse2);
|
| 145 |
+
enable_feature(Feature::mte, mte && mte2);
|
| 146 |
+
enable_feature(Feature::paca, pauth);
|
| 147 |
+
enable_feature(Feature::pacg, pauth);
|
| 148 |
+
enable_feature(Feature::pmull, aes && pmull);
|
| 149 |
+
enable_feature(Feature::rcpc, rcpc);
|
| 150 |
+
enable_feature(Feature::rcpc2, rcpc2);
|
| 151 |
+
enable_feature(Feature::rdm, rdm);
|
| 152 |
+
enable_feature(Feature::sb, sb);
|
| 153 |
+
enable_feature(Feature::sha2, sha1 && sha256 && asimd);
|
| 154 |
+
enable_feature(Feature::sha3, sha512 && sha3 && asimd);
|
| 155 |
+
enable_feature(Feature::sme, sme);
|
| 156 |
+
enable_feature(Feature::sme2, sme2);
|
| 157 |
+
enable_feature(Feature::sme2p1, sme2p1);
|
| 158 |
+
enable_feature(Feature::sme_b16b16, sme_b16b16);
|
| 159 |
+
enable_feature(Feature::sme_f16f16, sme_f16f16);
|
| 160 |
+
enable_feature(Feature::sme_f64f64, sme_f64f64);
|
| 161 |
+
enable_feature(Feature::sme_i16i64, sme_i16i64);
|
| 162 |
+
enable_feature(Feature::ssbs, ssbs);
|
| 163 |
+
enable_feature(Feature::wfxt, wfxt);
|
| 164 |
+
|
| 165 |
+
value
|
| 166 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/aarch64.rs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for Aarch64 on FreeBSD.
|
| 2 |
+
|
| 3 |
+
pub(crate) use super::super::aarch64::detect_features;
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/arm.rs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for ARM on FreeBSD
|
| 2 |
+
|
| 3 |
+
use super::auxvec;
|
| 4 |
+
use crate::detect::{Feature, cache};
|
| 5 |
+
|
| 6 |
+
// Defined in machine/elf.h.
|
| 7 |
+
// https://github.com/freebsd/freebsd-src/blob/deb63adf945d446ed91a9d84124c71f15ae571d1/sys/arm/include/elf.h
|
| 8 |
+
const HWCAP_NEON: usize = 0x00001000;
|
| 9 |
+
const HWCAP2_AES: usize = 0x00000001;
|
| 10 |
+
const HWCAP2_PMULL: usize = 0x00000002;
|
| 11 |
+
const HWCAP2_SHA1: usize = 0x00000004;
|
| 12 |
+
const HWCAP2_SHA2: usize = 0x00000008;
|
| 13 |
+
const HWCAP2_CRC32: usize = 0x00000010;
|
| 14 |
+
|
| 15 |
+
/// Try to read the features from the auxiliary vector
|
| 16 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 17 |
+
let mut value = cache::Initializer::default();
|
| 18 |
+
let enable_feature = |value: &mut cache::Initializer, f, enable| {
|
| 19 |
+
if enable {
|
| 20 |
+
value.set(f as u32);
|
| 21 |
+
}
|
| 22 |
+
};
|
| 23 |
+
|
| 24 |
+
if let Ok(auxv) = auxvec::auxv() {
|
| 25 |
+
enable_feature(&mut value, Feature::neon, auxv.hwcap & HWCAP_NEON != 0);
|
| 26 |
+
enable_feature(&mut value, Feature::pmull, auxv.hwcap2 & HWCAP2_PMULL != 0);
|
| 27 |
+
enable_feature(&mut value, Feature::crc, auxv.hwcap2 & HWCAP2_CRC32 != 0);
|
| 28 |
+
enable_feature(&mut value, Feature::aes, auxv.hwcap2 & HWCAP2_AES != 0);
|
| 29 |
+
// SHA2 requires SHA1 & SHA2 features
|
| 30 |
+
let sha1 = auxv.hwcap2 & HWCAP2_SHA1 != 0;
|
| 31 |
+
let sha2 = auxv.hwcap2 & HWCAP2_SHA2 != 0;
|
| 32 |
+
enable_feature(&mut value, Feature::sha2, sha1 && sha2);
|
| 33 |
+
return value;
|
| 34 |
+
}
|
| 35 |
+
value
|
| 36 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/auxvec.rs
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Parses ELF auxiliary vectors.
|
| 2 |
+
#![cfg_attr(
|
| 3 |
+
any(
|
| 4 |
+
target_arch = "aarch64",
|
| 5 |
+
target_arch = "arm",
|
| 6 |
+
target_arch = "powerpc64",
|
| 7 |
+
target_arch = "riscv64"
|
| 8 |
+
),
|
| 9 |
+
allow(dead_code)
|
| 10 |
+
)]
|
| 11 |
+
|
| 12 |
+
/// Cache HWCAP bitfields of the ELF Auxiliary Vector.
|
| 13 |
+
///
|
| 14 |
+
/// If an entry cannot be read all the bits in the bitfield are set to zero.
|
| 15 |
+
/// This should be interpreted as all the features being disabled.
|
| 16 |
+
#[derive(Debug, Copy, Clone)]
|
| 17 |
+
pub(crate) struct AuxVec {
|
| 18 |
+
pub hwcap: usize,
|
| 19 |
+
pub hwcap2: usize,
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
/// ELF Auxiliary Vector
|
| 23 |
+
///
|
| 24 |
+
/// The auxiliary vector is a memory region in a running ELF program's stack
|
| 25 |
+
/// composed of (key: usize, value: usize) pairs.
|
| 26 |
+
///
|
| 27 |
+
/// The keys used in the aux vector are platform dependent. For FreeBSD, they are
|
| 28 |
+
/// defined in [sys/elf_common.h][elf_common_h]. The hardware capabilities of a given
|
| 29 |
+
/// CPU can be queried with the `AT_HWCAP` and `AT_HWCAP2` keys.
|
| 30 |
+
///
|
| 31 |
+
/// Note that run-time feature detection is not invoked for features that can
|
| 32 |
+
/// be detected at compile-time.
|
| 33 |
+
///
|
| 34 |
+
/// [elf_common.h]: https://svnweb.freebsd.org/base/release/12.0.0/sys/sys/elf_common.h?revision=341707
|
| 35 |
+
pub(crate) fn auxv() -> Result<AuxVec, ()> {
|
| 36 |
+
let hwcap = archauxv(libc::AT_HWCAP);
|
| 37 |
+
let hwcap2 = archauxv(libc::AT_HWCAP2);
|
| 38 |
+
// Zero could indicate that no features were detected, but it's also used to
|
| 39 |
+
// indicate an error. In particular, on many platforms AT_HWCAP2 will be
|
| 40 |
+
// legitimately zero, since it contains the most recent feature flags.
|
| 41 |
+
if hwcap != 0 || hwcap2 != 0 {
|
| 42 |
+
return Ok(AuxVec { hwcap, hwcap2 });
|
| 43 |
+
}
|
| 44 |
+
Err(())
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
/// Tries to read the `key` from the auxiliary vector.
|
| 48 |
+
fn archauxv(key: libc::c_int) -> usize {
|
| 49 |
+
const OUT_LEN: libc::c_int = core::mem::size_of::<libc::c_ulong>() as libc::c_int;
|
| 50 |
+
let mut out: libc::c_ulong = 0;
|
| 51 |
+
unsafe {
|
| 52 |
+
// elf_aux_info is available on FreeBSD 12.0+ and 11.4+:
|
| 53 |
+
// https://github.com/freebsd/freebsd-src/commit/0b08ae2120cdd08c20a2b806e2fcef4d0a36c470
|
| 54 |
+
// https://github.com/freebsd/freebsd-src/blob/release/11.4.0/sys/sys/auxv.h
|
| 55 |
+
// FreeBSD 11 support in std has been removed in Rust 1.75 (https://github.com/rust-lang/rust/pull/114521),
|
| 56 |
+
// so we can safely use this function.
|
| 57 |
+
let res =
|
| 58 |
+
libc::elf_aux_info(key, &mut out as *mut libc::c_ulong as *mut libc::c_void, OUT_LEN);
|
| 59 |
+
// If elf_aux_info fails, `out` will be left at zero (which is the proper default value).
|
| 60 |
+
debug_assert!(res == 0 || out == 0);
|
| 61 |
+
}
|
| 62 |
+
out as usize
|
| 63 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/mod.rs
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on FreeBSD
|
| 2 |
+
|
| 3 |
+
mod auxvec;
|
| 4 |
+
|
| 5 |
+
cfg_select! {
|
| 6 |
+
target_arch = "aarch64" => {
|
| 7 |
+
mod aarch64;
|
| 8 |
+
pub(crate) use self::aarch64::detect_features;
|
| 9 |
+
}
|
| 10 |
+
target_arch = "arm" => {
|
| 11 |
+
mod arm;
|
| 12 |
+
pub(crate) use self::arm::detect_features;
|
| 13 |
+
}
|
| 14 |
+
target_arch = "powerpc64" => {
|
| 15 |
+
mod powerpc;
|
| 16 |
+
pub(crate) use self::powerpc::detect_features;
|
| 17 |
+
}
|
| 18 |
+
_ => {
|
| 19 |
+
use crate::detect::cache;
|
| 20 |
+
/// Performs run-time feature detection.
|
| 21 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 22 |
+
cache::Initializer::default()
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/freebsd/powerpc.rs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for PowerPC on FreeBSD.
|
| 2 |
+
|
| 3 |
+
use super::auxvec;
|
| 4 |
+
use crate::detect::{Feature, cache};
|
| 5 |
+
|
| 6 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 7 |
+
let mut value = cache::Initializer::default();
|
| 8 |
+
let enable_feature = |value: &mut cache::Initializer, f, enable| {
|
| 9 |
+
if enable {
|
| 10 |
+
value.set(f as u32);
|
| 11 |
+
}
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
if let Ok(auxv) = auxvec::auxv() {
|
| 15 |
+
enable_feature(&mut value, Feature::altivec, auxv.hwcap & 0x10000000 != 0);
|
| 16 |
+
enable_feature(&mut value, Feature::vsx, auxv.hwcap & 0x00000080 != 0);
|
| 17 |
+
enable_feature(&mut value, Feature::power8, auxv.hwcap2 & 0x80000000 != 0);
|
| 18 |
+
return value;
|
| 19 |
+
}
|
| 20 |
+
value
|
| 21 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/aarch64.rs
ADDED
|
@@ -0,0 +1,409 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for Aarch64 on Linux.
|
| 2 |
+
|
| 3 |
+
use super::auxvec;
|
| 4 |
+
use crate::detect::{Feature, bit, cache};
|
| 5 |
+
|
| 6 |
+
/// Try to read the features from the auxiliary vector.
|
| 7 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 8 |
+
#[cfg(target_os = "android")]
|
| 9 |
+
let is_exynos9810 = {
|
| 10 |
+
// Samsung Exynos 9810 has a bug that big and little cores have different
|
| 11 |
+
// ISAs. And on older Android (pre-9), the kernel incorrectly reports
|
| 12 |
+
// that features available only on some cores are available on all cores.
|
| 13 |
+
// https://reviews.llvm.org/D114523
|
| 14 |
+
let mut arch = [0_u8; libc::PROP_VALUE_MAX as usize];
|
| 15 |
+
let len = unsafe {
|
| 16 |
+
libc::__system_property_get(c"ro.arch".as_ptr(), arch.as_mut_ptr() as *mut libc::c_char)
|
| 17 |
+
};
|
| 18 |
+
// On Exynos, ro.arch is not available on Android 12+, but it is fine
|
| 19 |
+
// because Android 9+ includes the fix.
|
| 20 |
+
len > 0 && arch.starts_with(b"exynos9810")
|
| 21 |
+
};
|
| 22 |
+
#[cfg(not(target_os = "android"))]
|
| 23 |
+
let is_exynos9810 = false;
|
| 24 |
+
|
| 25 |
+
if let Ok(auxv) = auxvec::auxv() {
|
| 26 |
+
let hwcap: AtHwcap = auxv.into();
|
| 27 |
+
return hwcap.cache(is_exynos9810);
|
| 28 |
+
}
|
| 29 |
+
cache::Initializer::default()
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
/// These values are part of the platform-specific [asm/hwcap.h][hwcap] .
|
| 33 |
+
///
|
| 34 |
+
/// The names match those used for cpuinfo.
|
| 35 |
+
///
|
| 36 |
+
/// [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/hwcap.h
|
| 37 |
+
#[derive(Debug, Default, PartialEq)]
|
| 38 |
+
struct AtHwcap {
|
| 39 |
+
// AT_HWCAP
|
| 40 |
+
fp: bool,
|
| 41 |
+
asimd: bool,
|
| 42 |
+
// evtstrm: No LLVM support.
|
| 43 |
+
aes: bool,
|
| 44 |
+
pmull: bool,
|
| 45 |
+
sha1: bool,
|
| 46 |
+
sha2: bool,
|
| 47 |
+
crc32: bool,
|
| 48 |
+
atomics: bool,
|
| 49 |
+
fphp: bool,
|
| 50 |
+
asimdhp: bool,
|
| 51 |
+
// cpuid: No LLVM support.
|
| 52 |
+
asimdrdm: bool,
|
| 53 |
+
jscvt: bool,
|
| 54 |
+
fcma: bool,
|
| 55 |
+
lrcpc: bool,
|
| 56 |
+
dcpop: bool,
|
| 57 |
+
sha3: bool,
|
| 58 |
+
sm3: bool,
|
| 59 |
+
sm4: bool,
|
| 60 |
+
asimddp: bool,
|
| 61 |
+
sha512: bool,
|
| 62 |
+
sve: bool,
|
| 63 |
+
fhm: bool,
|
| 64 |
+
dit: bool,
|
| 65 |
+
uscat: bool,
|
| 66 |
+
ilrcpc: bool,
|
| 67 |
+
flagm: bool,
|
| 68 |
+
ssbs: bool,
|
| 69 |
+
sb: bool,
|
| 70 |
+
paca: bool,
|
| 71 |
+
pacg: bool,
|
| 72 |
+
|
| 73 |
+
// AT_HWCAP2
|
| 74 |
+
dcpodp: bool,
|
| 75 |
+
sve2: bool,
|
| 76 |
+
sveaes: bool,
|
| 77 |
+
svepmull: bool,
|
| 78 |
+
svebitperm: bool,
|
| 79 |
+
svesha3: bool,
|
| 80 |
+
svesm4: bool,
|
| 81 |
+
flagm2: bool,
|
| 82 |
+
frint: bool,
|
| 83 |
+
// svei8mm: See i8mm feature.
|
| 84 |
+
svef32mm: bool,
|
| 85 |
+
svef64mm: bool,
|
| 86 |
+
// svebf16: See bf16 feature.
|
| 87 |
+
i8mm: bool,
|
| 88 |
+
bf16: bool,
|
| 89 |
+
// dgh: No LLVM support.
|
| 90 |
+
rng: bool,
|
| 91 |
+
bti: bool,
|
| 92 |
+
mte: bool,
|
| 93 |
+
ecv: bool,
|
| 94 |
+
// afp: bool,
|
| 95 |
+
// rpres: bool,
|
| 96 |
+
// mte3: bool,
|
| 97 |
+
sme: bool,
|
| 98 |
+
smei16i64: bool,
|
| 99 |
+
smef64f64: bool,
|
| 100 |
+
// smei8i32: bool,
|
| 101 |
+
// smef16f32: bool,
|
| 102 |
+
// smeb16f32: bool,
|
| 103 |
+
// smef32f32: bool,
|
| 104 |
+
smefa64: bool,
|
| 105 |
+
wfxt: bool,
|
| 106 |
+
// ebf16: bool,
|
| 107 |
+
// sveebf16: bool,
|
| 108 |
+
cssc: bool,
|
| 109 |
+
// rprfm: bool,
|
| 110 |
+
sve2p1: bool,
|
| 111 |
+
sme2: bool,
|
| 112 |
+
sme2p1: bool,
|
| 113 |
+
// smei16i32: bool,
|
| 114 |
+
// smebi32i32: bool,
|
| 115 |
+
smeb16b16: bool,
|
| 116 |
+
smef16f16: bool,
|
| 117 |
+
mops: bool,
|
| 118 |
+
hbc: bool,
|
| 119 |
+
sveb16b16: bool,
|
| 120 |
+
lrcpc3: bool,
|
| 121 |
+
lse128: bool,
|
| 122 |
+
fpmr: bool,
|
| 123 |
+
lut: bool,
|
| 124 |
+
faminmax: bool,
|
| 125 |
+
f8cvt: bool,
|
| 126 |
+
f8fma: bool,
|
| 127 |
+
f8dp4: bool,
|
| 128 |
+
f8dp2: bool,
|
| 129 |
+
f8e4m3: bool,
|
| 130 |
+
f8e5m2: bool,
|
| 131 |
+
smelutv2: bool,
|
| 132 |
+
smef8f16: bool,
|
| 133 |
+
smef8f32: bool,
|
| 134 |
+
smesf8fma: bool,
|
| 135 |
+
smesf8dp4: bool,
|
| 136 |
+
smesf8dp2: bool,
|
| 137 |
+
// pauthlr: bool,
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
impl From<auxvec::AuxVec> for AtHwcap {
|
| 141 |
+
/// Reads AtHwcap from the auxiliary vector.
|
| 142 |
+
fn from(auxv: auxvec::AuxVec) -> Self {
|
| 143 |
+
let mut cap = AtHwcap {
|
| 144 |
+
fp: bit::test(auxv.hwcap, 0),
|
| 145 |
+
asimd: bit::test(auxv.hwcap, 1),
|
| 146 |
+
// evtstrm: bit::test(auxv.hwcap, 2),
|
| 147 |
+
aes: bit::test(auxv.hwcap, 3),
|
| 148 |
+
pmull: bit::test(auxv.hwcap, 4),
|
| 149 |
+
sha1: bit::test(auxv.hwcap, 5),
|
| 150 |
+
sha2: bit::test(auxv.hwcap, 6),
|
| 151 |
+
crc32: bit::test(auxv.hwcap, 7),
|
| 152 |
+
atomics: bit::test(auxv.hwcap, 8),
|
| 153 |
+
fphp: bit::test(auxv.hwcap, 9),
|
| 154 |
+
asimdhp: bit::test(auxv.hwcap, 10),
|
| 155 |
+
// cpuid: bit::test(auxv.hwcap, 11),
|
| 156 |
+
asimdrdm: bit::test(auxv.hwcap, 12),
|
| 157 |
+
jscvt: bit::test(auxv.hwcap, 13),
|
| 158 |
+
fcma: bit::test(auxv.hwcap, 14),
|
| 159 |
+
lrcpc: bit::test(auxv.hwcap, 15),
|
| 160 |
+
dcpop: bit::test(auxv.hwcap, 16),
|
| 161 |
+
sha3: bit::test(auxv.hwcap, 17),
|
| 162 |
+
sm3: bit::test(auxv.hwcap, 18),
|
| 163 |
+
sm4: bit::test(auxv.hwcap, 19),
|
| 164 |
+
asimddp: bit::test(auxv.hwcap, 20),
|
| 165 |
+
sha512: bit::test(auxv.hwcap, 21),
|
| 166 |
+
sve: bit::test(auxv.hwcap, 22),
|
| 167 |
+
fhm: bit::test(auxv.hwcap, 23),
|
| 168 |
+
dit: bit::test(auxv.hwcap, 24),
|
| 169 |
+
uscat: bit::test(auxv.hwcap, 25),
|
| 170 |
+
ilrcpc: bit::test(auxv.hwcap, 26),
|
| 171 |
+
flagm: bit::test(auxv.hwcap, 27),
|
| 172 |
+
ssbs: bit::test(auxv.hwcap, 28),
|
| 173 |
+
sb: bit::test(auxv.hwcap, 29),
|
| 174 |
+
paca: bit::test(auxv.hwcap, 30),
|
| 175 |
+
pacg: bit::test(auxv.hwcap, 31),
|
| 176 |
+
|
| 177 |
+
// AT_HWCAP2
|
| 178 |
+
dcpodp: bit::test(auxv.hwcap2, 0),
|
| 179 |
+
sve2: bit::test(auxv.hwcap2, 1),
|
| 180 |
+
sveaes: bit::test(auxv.hwcap2, 2),
|
| 181 |
+
svepmull: bit::test(auxv.hwcap2, 3),
|
| 182 |
+
svebitperm: bit::test(auxv.hwcap2, 4),
|
| 183 |
+
svesha3: bit::test(auxv.hwcap2, 5),
|
| 184 |
+
svesm4: bit::test(auxv.hwcap2, 6),
|
| 185 |
+
flagm2: bit::test(auxv.hwcap2, 7),
|
| 186 |
+
frint: bit::test(auxv.hwcap2, 8),
|
| 187 |
+
// svei8mm: bit::test(auxv.hwcap2, 9),
|
| 188 |
+
svef32mm: bit::test(auxv.hwcap2, 10),
|
| 189 |
+
svef64mm: bit::test(auxv.hwcap2, 11),
|
| 190 |
+
// svebf16: bit::test(auxv.hwcap2, 12),
|
| 191 |
+
i8mm: bit::test(auxv.hwcap2, 13),
|
| 192 |
+
bf16: bit::test(auxv.hwcap2, 14),
|
| 193 |
+
// dgh: bit::test(auxv.hwcap2, 15),
|
| 194 |
+
rng: bit::test(auxv.hwcap2, 16),
|
| 195 |
+
bti: bit::test(auxv.hwcap2, 17),
|
| 196 |
+
mte: bit::test(auxv.hwcap2, 18),
|
| 197 |
+
ecv: bit::test(auxv.hwcap2, 19),
|
| 198 |
+
// afp: bit::test(auxv.hwcap2, 20),
|
| 199 |
+
// rpres: bit::test(auxv.hwcap2, 21),
|
| 200 |
+
// mte3: bit::test(auxv.hwcap2, 22),
|
| 201 |
+
sme: bit::test(auxv.hwcap2, 23),
|
| 202 |
+
smei16i64: bit::test(auxv.hwcap2, 24),
|
| 203 |
+
smef64f64: bit::test(auxv.hwcap2, 25),
|
| 204 |
+
// smei8i32: bit::test(auxv.hwcap2, 26),
|
| 205 |
+
// smef16f32: bit::test(auxv.hwcap2, 27),
|
| 206 |
+
// smeb16f32: bit::test(auxv.hwcap2, 28),
|
| 207 |
+
// smef32f32: bit::test(auxv.hwcap2, 29),
|
| 208 |
+
smefa64: bit::test(auxv.hwcap2, 30),
|
| 209 |
+
wfxt: bit::test(auxv.hwcap2, 31),
|
| 210 |
+
..Default::default()
|
| 211 |
+
};
|
| 212 |
+
|
| 213 |
+
// Hardware capabilities from bits 32 to 63 should only
|
| 214 |
+
// be tested on LP64 targets with 64 bits `usize`.
|
| 215 |
+
// On ILP32 targets like `aarch64-unknown-linux-gnu_ilp32`,
|
| 216 |
+
// these hardware capabilities will default to `false`.
|
| 217 |
+
// https://github.com/rust-lang/rust/issues/146230
|
| 218 |
+
#[cfg(target_pointer_width = "64")]
|
| 219 |
+
{
|
| 220 |
+
// cap.ebf16: bit::test(auxv.hwcap2, 32);
|
| 221 |
+
// cap.sveebf16: bit::test(auxv.hwcap2, 33);
|
| 222 |
+
cap.cssc = bit::test(auxv.hwcap2, 34);
|
| 223 |
+
// cap.rprfm: bit::test(auxv.hwcap2, 35);
|
| 224 |
+
cap.sve2p1 = bit::test(auxv.hwcap2, 36);
|
| 225 |
+
cap.sme2 = bit::test(auxv.hwcap2, 37);
|
| 226 |
+
cap.sme2p1 = bit::test(auxv.hwcap2, 38);
|
| 227 |
+
// cap.smei16i32 = bit::test(auxv.hwcap2, 39);
|
| 228 |
+
// cap.smebi32i32 = bit::test(auxv.hwcap2, 40);
|
| 229 |
+
cap.smeb16b16 = bit::test(auxv.hwcap2, 41);
|
| 230 |
+
cap.smef16f16 = bit::test(auxv.hwcap2, 42);
|
| 231 |
+
cap.mops = bit::test(auxv.hwcap2, 43);
|
| 232 |
+
cap.hbc = bit::test(auxv.hwcap2, 44);
|
| 233 |
+
cap.sveb16b16 = bit::test(auxv.hwcap2, 45);
|
| 234 |
+
cap.lrcpc3 = bit::test(auxv.hwcap2, 46);
|
| 235 |
+
cap.lse128 = bit::test(auxv.hwcap2, 47);
|
| 236 |
+
cap.fpmr = bit::test(auxv.hwcap2, 48);
|
| 237 |
+
cap.lut = bit::test(auxv.hwcap2, 49);
|
| 238 |
+
cap.faminmax = bit::test(auxv.hwcap2, 50);
|
| 239 |
+
cap.f8cvt = bit::test(auxv.hwcap2, 51);
|
| 240 |
+
cap.f8fma = bit::test(auxv.hwcap2, 52);
|
| 241 |
+
cap.f8dp4 = bit::test(auxv.hwcap2, 53);
|
| 242 |
+
cap.f8dp2 = bit::test(auxv.hwcap2, 54);
|
| 243 |
+
cap.f8e4m3 = bit::test(auxv.hwcap2, 55);
|
| 244 |
+
cap.f8e5m2 = bit::test(auxv.hwcap2, 56);
|
| 245 |
+
cap.smelutv2 = bit::test(auxv.hwcap2, 57);
|
| 246 |
+
cap.smef8f16 = bit::test(auxv.hwcap2, 58);
|
| 247 |
+
cap.smef8f32 = bit::test(auxv.hwcap2, 59);
|
| 248 |
+
cap.smesf8fma = bit::test(auxv.hwcap2, 60);
|
| 249 |
+
cap.smesf8dp4 = bit::test(auxv.hwcap2, 61);
|
| 250 |
+
cap.smesf8dp2 = bit::test(auxv.hwcap2, 62);
|
| 251 |
+
// cap.pauthlr = bit::test(auxv.hwcap2, ??);
|
| 252 |
+
}
|
| 253 |
+
cap
|
| 254 |
+
}
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
impl AtHwcap {
|
| 258 |
+
/// Initializes the cache from the feature -bits.
|
| 259 |
+
///
|
| 260 |
+
/// The feature dependencies here come directly from LLVM's feature definitions:
|
| 261 |
+
/// https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AArch64/AArch64.td
|
| 262 |
+
fn cache(self, is_exynos9810: bool) -> cache::Initializer {
|
| 263 |
+
let mut value = cache::Initializer::default();
|
| 264 |
+
{
|
| 265 |
+
let mut enable_feature = |f, enable| {
|
| 266 |
+
if enable {
|
| 267 |
+
value.set(f as u32);
|
| 268 |
+
}
|
| 269 |
+
};
|
| 270 |
+
|
| 271 |
+
// Samsung Exynos 9810 has a bug that big and little cores have different
|
| 272 |
+
// ISAs. And on older Android (pre-9), the kernel incorrectly reports
|
| 273 |
+
// that features available only on some cores are available on all cores.
|
| 274 |
+
// So, only check features that are known to be available on exynos-m3:
|
| 275 |
+
// $ rustc --print cfg --target aarch64-linux-android -C target-cpu=exynos-m3 | grep target_feature
|
| 276 |
+
// See also https://github.com/rust-lang/stdarch/pull/1378#discussion_r1103748342.
|
| 277 |
+
if is_exynos9810 {
|
| 278 |
+
enable_feature(Feature::fp, self.fp);
|
| 279 |
+
enable_feature(Feature::crc, self.crc32);
|
| 280 |
+
// ASIMD support requires float support - if half-floats are
|
| 281 |
+
// supported, it also requires half-float support:
|
| 282 |
+
let asimd = self.fp && self.asimd && (!self.fphp | self.asimdhp);
|
| 283 |
+
enable_feature(Feature::asimd, asimd);
|
| 284 |
+
// Cryptographic extensions require ASIMD
|
| 285 |
+
// AES also covers FEAT_PMULL
|
| 286 |
+
enable_feature(Feature::aes, self.aes && self.pmull && asimd);
|
| 287 |
+
enable_feature(Feature::sha2, self.sha1 && self.sha2 && asimd);
|
| 288 |
+
return value;
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
enable_feature(Feature::fp, self.fp);
|
| 292 |
+
// Half-float support requires float support
|
| 293 |
+
enable_feature(Feature::fp16, self.fp && self.fphp);
|
| 294 |
+
// FHM (fp16fml in LLVM) requires half float support
|
| 295 |
+
enable_feature(Feature::fhm, self.fphp && self.fhm);
|
| 296 |
+
enable_feature(Feature::pmull, self.pmull);
|
| 297 |
+
enable_feature(Feature::crc, self.crc32);
|
| 298 |
+
enable_feature(Feature::lse, self.atomics);
|
| 299 |
+
enable_feature(Feature::lse2, self.uscat);
|
| 300 |
+
enable_feature(Feature::lse128, self.lse128 && self.atomics);
|
| 301 |
+
enable_feature(Feature::rcpc, self.lrcpc);
|
| 302 |
+
// RCPC2 (rcpc-immo in LLVM) requires RCPC support
|
| 303 |
+
let rcpc2 = self.ilrcpc && self.lrcpc;
|
| 304 |
+
enable_feature(Feature::rcpc2, rcpc2);
|
| 305 |
+
enable_feature(Feature::rcpc3, self.lrcpc3 && rcpc2);
|
| 306 |
+
enable_feature(Feature::dit, self.dit);
|
| 307 |
+
enable_feature(Feature::flagm, self.flagm);
|
| 308 |
+
enable_feature(Feature::flagm2, self.flagm2);
|
| 309 |
+
enable_feature(Feature::ssbs, self.ssbs);
|
| 310 |
+
enable_feature(Feature::sb, self.sb);
|
| 311 |
+
enable_feature(Feature::paca, self.paca);
|
| 312 |
+
enable_feature(Feature::pacg, self.pacg);
|
| 313 |
+
// enable_feature(Feature::pauth_lr, self.pauthlr);
|
| 314 |
+
enable_feature(Feature::dpb, self.dcpop);
|
| 315 |
+
enable_feature(Feature::dpb2, self.dcpodp);
|
| 316 |
+
enable_feature(Feature::rand, self.rng);
|
| 317 |
+
enable_feature(Feature::bti, self.bti);
|
| 318 |
+
enable_feature(Feature::mte, self.mte);
|
| 319 |
+
// jsconv requires float support
|
| 320 |
+
enable_feature(Feature::jsconv, self.jscvt && self.fp);
|
| 321 |
+
enable_feature(Feature::rdm, self.asimdrdm);
|
| 322 |
+
enable_feature(Feature::dotprod, self.asimddp);
|
| 323 |
+
enable_feature(Feature::frintts, self.frint);
|
| 324 |
+
|
| 325 |
+
// FEAT_I8MM & FEAT_BF16 also include optional SVE components which linux exposes
|
| 326 |
+
// separately. We ignore that distinction here.
|
| 327 |
+
enable_feature(Feature::i8mm, self.i8mm);
|
| 328 |
+
enable_feature(Feature::bf16, self.bf16);
|
| 329 |
+
|
| 330 |
+
// ASIMD support requires float support - if half-floats are
|
| 331 |
+
// supported, it also requires half-float support:
|
| 332 |
+
let asimd = self.fp && self.asimd && (!self.fphp | self.asimdhp);
|
| 333 |
+
enable_feature(Feature::asimd, asimd);
|
| 334 |
+
// ASIMD extensions require ASIMD support:
|
| 335 |
+
enable_feature(Feature::fcma, self.fcma && asimd);
|
| 336 |
+
enable_feature(Feature::sve, self.sve && asimd);
|
| 337 |
+
|
| 338 |
+
// SVE extensions require SVE & ASIMD
|
| 339 |
+
enable_feature(Feature::f32mm, self.svef32mm && self.sve && asimd);
|
| 340 |
+
enable_feature(Feature::f64mm, self.svef64mm && self.sve && asimd);
|
| 341 |
+
|
| 342 |
+
// Cryptographic extensions require ASIMD
|
| 343 |
+
enable_feature(Feature::aes, self.aes && asimd);
|
| 344 |
+
enable_feature(Feature::sha2, self.sha1 && self.sha2 && asimd);
|
| 345 |
+
// SHA512/SHA3 require SHA1 & SHA256
|
| 346 |
+
enable_feature(
|
| 347 |
+
Feature::sha3,
|
| 348 |
+
self.sha512 && self.sha3 && self.sha1 && self.sha2 && asimd,
|
| 349 |
+
);
|
| 350 |
+
enable_feature(Feature::sm4, self.sm3 && self.sm4 && asimd);
|
| 351 |
+
|
| 352 |
+
// SVE2 requires SVE
|
| 353 |
+
let sve2 = self.sve2 && self.sve && asimd;
|
| 354 |
+
enable_feature(Feature::sve2, sve2);
|
| 355 |
+
enable_feature(Feature::sve2p1, self.sve2p1 && sve2);
|
| 356 |
+
// SVE2 extensions require SVE2 and crypto features
|
| 357 |
+
enable_feature(Feature::sve2_aes, self.sveaes && self.svepmull && sve2 && self.aes);
|
| 358 |
+
enable_feature(Feature::sve2_sm4, self.svesm4 && sve2 && self.sm3 && self.sm4);
|
| 359 |
+
enable_feature(
|
| 360 |
+
Feature::sve2_sha3,
|
| 361 |
+
self.svesha3 && sve2 && self.sha512 && self.sha3 && self.sha1 && self.sha2,
|
| 362 |
+
);
|
| 363 |
+
enable_feature(Feature::sve2_bitperm, self.svebitperm && self.sve2);
|
| 364 |
+
enable_feature(Feature::sve_b16b16, self.bf16 && self.sveb16b16);
|
| 365 |
+
enable_feature(Feature::hbc, self.hbc);
|
| 366 |
+
enable_feature(Feature::mops, self.mops);
|
| 367 |
+
enable_feature(Feature::ecv, self.ecv);
|
| 368 |
+
enable_feature(Feature::lut, self.lut);
|
| 369 |
+
enable_feature(Feature::cssc, self.cssc);
|
| 370 |
+
enable_feature(Feature::fpmr, self.fpmr);
|
| 371 |
+
enable_feature(Feature::faminmax, self.faminmax);
|
| 372 |
+
let fp8 = self.f8cvt && self.faminmax && self.lut && self.bf16;
|
| 373 |
+
enable_feature(Feature::fp8, fp8);
|
| 374 |
+
let fp8fma = self.f8fma && fp8;
|
| 375 |
+
enable_feature(Feature::fp8fma, fp8fma);
|
| 376 |
+
let fp8dot4 = self.f8dp4 && fp8fma;
|
| 377 |
+
enable_feature(Feature::fp8dot4, fp8dot4);
|
| 378 |
+
enable_feature(Feature::fp8dot2, self.f8dp2 && fp8dot4);
|
| 379 |
+
enable_feature(Feature::wfxt, self.wfxt);
|
| 380 |
+
let sme = self.sme && self.bf16;
|
| 381 |
+
enable_feature(Feature::sme, sme);
|
| 382 |
+
enable_feature(Feature::sme_i16i64, self.smei16i64 && sme);
|
| 383 |
+
enable_feature(Feature::sme_f64f64, self.smef64f64 && sme);
|
| 384 |
+
enable_feature(Feature::sme_fa64, self.smefa64 && sme && sve2);
|
| 385 |
+
let sme2 = self.sme2 && sme;
|
| 386 |
+
enable_feature(Feature::sme2, sme2);
|
| 387 |
+
enable_feature(Feature::sme2p1, self.sme2p1 && sme2);
|
| 388 |
+
enable_feature(
|
| 389 |
+
Feature::sme_b16b16,
|
| 390 |
+
sme2 && self.bf16 && self.sveb16b16 && self.smeb16b16,
|
| 391 |
+
);
|
| 392 |
+
enable_feature(Feature::sme_f16f16, self.smef16f16 && sme2);
|
| 393 |
+
enable_feature(Feature::sme_lutv2, self.smelutv2);
|
| 394 |
+
let sme_f8f32 = self.smef8f32 && sme2 && fp8;
|
| 395 |
+
enable_feature(Feature::sme_f8f32, sme_f8f32);
|
| 396 |
+
enable_feature(Feature::sme_f8f16, self.smef8f16 && sme_f8f32);
|
| 397 |
+
let ssve_fp8fma = self.smesf8fma && sme2 && fp8;
|
| 398 |
+
enable_feature(Feature::ssve_fp8fma, ssve_fp8fma);
|
| 399 |
+
let ssve_fp8dot4 = self.smesf8dp4 && ssve_fp8fma;
|
| 400 |
+
enable_feature(Feature::ssve_fp8dot4, ssve_fp8dot4);
|
| 401 |
+
enable_feature(Feature::ssve_fp8dot2, self.smesf8dp2 && ssve_fp8dot4);
|
| 402 |
+
}
|
| 403 |
+
value
|
| 404 |
+
}
|
| 405 |
+
}
|
| 406 |
+
|
| 407 |
+
#[cfg(target_endian = "little")]
|
| 408 |
+
#[cfg(test)]
|
| 409 |
+
mod tests;
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/aarch64/tests.rs
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use super::auxvec::auxv_from_file;
|
| 2 |
+
use super::*;
|
| 3 |
+
// The baseline hwcaps used in the (artificial) auxv test files.
|
| 4 |
+
fn baseline_hwcaps() -> AtHwcap {
|
| 5 |
+
AtHwcap {
|
| 6 |
+
fp: true,
|
| 7 |
+
asimd: true,
|
| 8 |
+
aes: true,
|
| 9 |
+
pmull: true,
|
| 10 |
+
sha1: true,
|
| 11 |
+
sha2: true,
|
| 12 |
+
crc32: true,
|
| 13 |
+
atomics: true,
|
| 14 |
+
fphp: true,
|
| 15 |
+
asimdhp: true,
|
| 16 |
+
asimdrdm: true,
|
| 17 |
+
lrcpc: true,
|
| 18 |
+
dcpop: true,
|
| 19 |
+
asimddp: true,
|
| 20 |
+
ssbs: true,
|
| 21 |
+
..AtHwcap::default()
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
#[test]
|
| 26 |
+
fn linux_empty_hwcap2_aarch64() {
|
| 27 |
+
let file = concat!(
|
| 28 |
+
env!("CARGO_MANIFEST_DIR"),
|
| 29 |
+
"/src/detect/test_data/linux-empty-hwcap2-aarch64.auxv"
|
| 30 |
+
);
|
| 31 |
+
println!("file: {file}");
|
| 32 |
+
let v = auxv_from_file(file).unwrap();
|
| 33 |
+
println!("HWCAP : 0x{:0x}", v.hwcap);
|
| 34 |
+
println!("HWCAP2: 0x{:0x}", v.hwcap2);
|
| 35 |
+
assert_eq!(AtHwcap::from(v), baseline_hwcaps());
|
| 36 |
+
}
|
| 37 |
+
#[test]
|
| 38 |
+
fn linux_no_hwcap2_aarch64() {
|
| 39 |
+
let file =
|
| 40 |
+
concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-no-hwcap2-aarch64.auxv");
|
| 41 |
+
println!("file: {file}");
|
| 42 |
+
let v = auxv_from_file(file).unwrap();
|
| 43 |
+
println!("HWCAP : 0x{:0x}", v.hwcap);
|
| 44 |
+
println!("HWCAP2: 0x{:0x}", v.hwcap2);
|
| 45 |
+
assert_eq!(AtHwcap::from(v), baseline_hwcaps());
|
| 46 |
+
}
|
| 47 |
+
#[test]
|
| 48 |
+
fn linux_hwcap2_aarch64() {
|
| 49 |
+
let file =
|
| 50 |
+
concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-hwcap2-aarch64.auxv");
|
| 51 |
+
println!("file: {file}");
|
| 52 |
+
let v = auxv_from_file(file).unwrap();
|
| 53 |
+
println!("HWCAP : 0x{:0x}", v.hwcap);
|
| 54 |
+
println!("HWCAP2: 0x{:0x}", v.hwcap2);
|
| 55 |
+
assert_eq!(
|
| 56 |
+
AtHwcap::from(v),
|
| 57 |
+
AtHwcap {
|
| 58 |
+
// Some other HWCAP bits.
|
| 59 |
+
paca: true,
|
| 60 |
+
pacg: true,
|
| 61 |
+
// HWCAP2-only bits.
|
| 62 |
+
dcpodp: true,
|
| 63 |
+
frint: true,
|
| 64 |
+
rng: true,
|
| 65 |
+
bti: true,
|
| 66 |
+
mte: true,
|
| 67 |
+
..baseline_hwcaps()
|
| 68 |
+
}
|
| 69 |
+
);
|
| 70 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/arm.rs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for ARM on Linux.
|
| 2 |
+
|
| 3 |
+
use super::auxvec;
|
| 4 |
+
use crate::detect::{Feature, bit, cache};
|
| 5 |
+
|
| 6 |
+
/// Try to read the features from the auxiliary vector.
|
| 7 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 8 |
+
let mut value = cache::Initializer::default();
|
| 9 |
+
let enable_feature = |value: &mut cache::Initializer, f, enable| {
|
| 10 |
+
if enable {
|
| 11 |
+
value.set(f as u32);
|
| 12 |
+
}
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
// The values are part of the platform-specific [asm/hwcap.h][hwcap]
|
| 16 |
+
//
|
| 17 |
+
// [hwcap]: https://github.com/torvalds/linux/blob/master/arch/arm/include/uapi/asm/hwcap.h
|
| 18 |
+
if let Ok(auxv) = auxvec::auxv() {
|
| 19 |
+
enable_feature(&mut value, Feature::i8mm, bit::test(auxv.hwcap, 27));
|
| 20 |
+
enable_feature(&mut value, Feature::dotprod, bit::test(auxv.hwcap, 24));
|
| 21 |
+
enable_feature(&mut value, Feature::neon, bit::test(auxv.hwcap, 12));
|
| 22 |
+
enable_feature(&mut value, Feature::pmull, bit::test(auxv.hwcap2, 1));
|
| 23 |
+
enable_feature(&mut value, Feature::crc, bit::test(auxv.hwcap2, 4));
|
| 24 |
+
enable_feature(&mut value, Feature::aes, bit::test(auxv.hwcap2, 0));
|
| 25 |
+
// SHA2 requires SHA1 & SHA2 features
|
| 26 |
+
enable_feature(
|
| 27 |
+
&mut value,
|
| 28 |
+
Feature::sha2,
|
| 29 |
+
bit::test(auxv.hwcap2, 2) && bit::test(auxv.hwcap2, 3),
|
| 30 |
+
);
|
| 31 |
+
return value;
|
| 32 |
+
}
|
| 33 |
+
value
|
| 34 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/auxvec.rs
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Parses ELF auxiliary vectors.
|
| 2 |
+
#![allow(dead_code)]
|
| 3 |
+
|
| 4 |
+
pub(crate) const AT_NULL: usize = 0;
|
| 5 |
+
|
| 6 |
+
/// Key to access the CPU Hardware capabilities bitfield.
|
| 7 |
+
pub(crate) const AT_HWCAP: usize = 16;
|
| 8 |
+
/// Key to access the CPU Hardware capabilities 2 bitfield.
|
| 9 |
+
#[cfg(any(
|
| 10 |
+
target_arch = "aarch64",
|
| 11 |
+
target_arch = "arm",
|
| 12 |
+
target_arch = "powerpc",
|
| 13 |
+
target_arch = "powerpc64",
|
| 14 |
+
target_arch = "s390x",
|
| 15 |
+
))]
|
| 16 |
+
pub(crate) const AT_HWCAP2: usize = 26;
|
| 17 |
+
|
| 18 |
+
/// Cache HWCAP bitfields of the ELF Auxiliary Vector.
|
| 19 |
+
///
|
| 20 |
+
/// If an entry cannot be read all the bits in the bitfield are set to zero.
|
| 21 |
+
/// This should be interpreted as all the features being disabled.
|
| 22 |
+
#[derive(Debug, Copy, Clone)]
|
| 23 |
+
#[cfg_attr(test, derive(PartialEq))]
|
| 24 |
+
pub(crate) struct AuxVec {
|
| 25 |
+
pub hwcap: usize,
|
| 26 |
+
#[cfg(any(
|
| 27 |
+
target_arch = "aarch64",
|
| 28 |
+
target_arch = "arm",
|
| 29 |
+
target_arch = "powerpc",
|
| 30 |
+
target_arch = "powerpc64",
|
| 31 |
+
target_arch = "s390x",
|
| 32 |
+
))]
|
| 33 |
+
pub hwcap2: usize,
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
/// ELF Auxiliary Vector
|
| 37 |
+
///
|
| 38 |
+
/// The auxiliary vector is a memory region in a running ELF program's stack
|
| 39 |
+
/// composed of (key: usize, value: usize) pairs.
|
| 40 |
+
///
|
| 41 |
+
/// The keys used in the aux vector are platform dependent. For Linux, they are
|
| 42 |
+
/// defined in [linux/auxvec.h][auxvec_h]. The hardware capabilities of a given
|
| 43 |
+
/// CPU can be queried with the `AT_HWCAP` and `AT_HWCAP2` keys.
|
| 44 |
+
///
|
| 45 |
+
/// There is no perfect way of reading the auxiliary vector.
|
| 46 |
+
///
|
| 47 |
+
/// - If [`getauxval`] is linked to the binary we use it, and otherwise it will
|
| 48 |
+
/// try to read `/proc/self/auxv`.
|
| 49 |
+
/// - If that fails, this function returns an error.
|
| 50 |
+
///
|
| 51 |
+
/// Note that run-time feature detection is not invoked for features that can
|
| 52 |
+
/// be detected at compile-time.
|
| 53 |
+
///
|
| 54 |
+
/// Note: We always directly use `getauxval` on `*-linux-{gnu,musl,ohos}*` and
|
| 55 |
+
/// `*-android*` targets rather than `dlsym` it because we can safely assume
|
| 56 |
+
/// `getauxval` is linked to the binary.
|
| 57 |
+
/// - `*-linux-gnu*` targets ([since Rust 1.64](https://blog.rust-lang.org/2022/08/01/Increasing-glibc-kernel-requirements.html))
|
| 58 |
+
/// have glibc requirements higher than [glibc 2.16 that added `getauxval`](https://sourceware.org/legacy-ml/libc-announce/2012/msg00000.html).
|
| 59 |
+
/// - `*-linux-musl*` targets ([at least since Rust 1.15](https://github.com/rust-lang/rust/blob/1.15.0/src/ci/docker/x86_64-musl/build-musl.sh#L15))
|
| 60 |
+
/// use musl newer than [musl 1.1.0 that added `getauxval`](https://git.musl-libc.org/cgit/musl/tree/WHATSNEW?h=v1.1.0#n1197)
|
| 61 |
+
/// - `*-linux-ohos*` targets use a [fork of musl 1.2](https://gitee.com/openharmony/docs/blob/master/en/application-dev/reference/native-lib/musl.md)
|
| 62 |
+
/// - `*-android*` targets ([since Rust 1.68](https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html))
|
| 63 |
+
/// have the minimum supported API level higher than [Android 4.3 (API level 18) that added `getauxval`](https://github.com/aosp-mirror/platform_bionic/blob/d3ebc2f7c49a9893b114124d4a6b315f3a328764/libc/include/sys/auxv.h#L49).
|
| 64 |
+
///
|
| 65 |
+
/// For more information about when `getauxval` is available check the great
|
| 66 |
+
/// [`auxv` crate documentation][auxv_docs].
|
| 67 |
+
///
|
| 68 |
+
/// [auxvec_h]: https://github.com/torvalds/linux/blob/master/include/uapi/linux/auxvec.h
|
| 69 |
+
/// [auxv_docs]: https://docs.rs/auxv/0.3.3/auxv/
|
| 70 |
+
/// [`getauxval`]: https://man7.org/linux/man-pages/man3/getauxval.3.html
|
| 71 |
+
pub(crate) fn auxv() -> Result<AuxVec, ()> {
|
| 72 |
+
// Try to call a getauxval function.
|
| 73 |
+
if let Ok(hwcap) = getauxval(AT_HWCAP) {
|
| 74 |
+
// Targets with only AT_HWCAP:
|
| 75 |
+
#[cfg(any(
|
| 76 |
+
target_arch = "riscv32",
|
| 77 |
+
target_arch = "riscv64",
|
| 78 |
+
target_arch = "mips",
|
| 79 |
+
target_arch = "mips64",
|
| 80 |
+
target_arch = "loongarch32",
|
| 81 |
+
target_arch = "loongarch64",
|
| 82 |
+
))]
|
| 83 |
+
{
|
| 84 |
+
// Zero could indicate that no features were detected, but it's also used to indicate
|
| 85 |
+
// an error. In either case, try the fallback.
|
| 86 |
+
if hwcap != 0 {
|
| 87 |
+
return Ok(AuxVec { hwcap });
|
| 88 |
+
}
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
// Targets with AT_HWCAP and AT_HWCAP2:
|
| 92 |
+
#[cfg(any(
|
| 93 |
+
target_arch = "aarch64",
|
| 94 |
+
target_arch = "arm",
|
| 95 |
+
target_arch = "powerpc",
|
| 96 |
+
target_arch = "powerpc64",
|
| 97 |
+
target_arch = "s390x",
|
| 98 |
+
))]
|
| 99 |
+
{
|
| 100 |
+
if let Ok(hwcap2) = getauxval(AT_HWCAP2) {
|
| 101 |
+
// Zero could indicate that no features were detected, but it's also used to indicate
|
| 102 |
+
// an error. In particular, on many platforms AT_HWCAP2 will be legitimately zero,
|
| 103 |
+
// since it contains the most recent feature flags. Use the fallback only if no
|
| 104 |
+
// features were detected at all.
|
| 105 |
+
if hwcap != 0 || hwcap2 != 0 {
|
| 106 |
+
return Ok(AuxVec { hwcap, hwcap2 });
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
// Intentionnaly not used
|
| 112 |
+
let _ = hwcap;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
// If calling getauxval fails, try to read the auxiliary vector from
|
| 116 |
+
// its file:
|
| 117 |
+
auxv_from_file("/proc/self/auxv").map_err(|_| ())
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
/// Tries to read the `key` from the auxiliary vector by calling the
|
| 121 |
+
/// `getauxval` function. If the function is not linked, this function return `Err`.
|
| 122 |
+
fn getauxval(key: usize) -> Result<usize, ()> {
|
| 123 |
+
type F = unsafe extern "C" fn(libc::c_ulong) -> libc::c_ulong;
|
| 124 |
+
cfg_select! {
|
| 125 |
+
any(
|
| 126 |
+
all(
|
| 127 |
+
target_os = "linux",
|
| 128 |
+
any(target_env = "gnu", target_env = "musl", target_env = "ohos"),
|
| 129 |
+
),
|
| 130 |
+
target_os = "android",
|
| 131 |
+
) => {
|
| 132 |
+
let ffi_getauxval: F = libc::getauxval;
|
| 133 |
+
}
|
| 134 |
+
_ => {
|
| 135 |
+
let ffi_getauxval: F = unsafe {
|
| 136 |
+
let ptr = libc::dlsym(libc::RTLD_DEFAULT, c"getauxval".as_ptr());
|
| 137 |
+
if ptr.is_null() {
|
| 138 |
+
return Err(());
|
| 139 |
+
}
|
| 140 |
+
core::mem::transmute(ptr)
|
| 141 |
+
};
|
| 142 |
+
}
|
| 143 |
+
}
|
| 144 |
+
Ok(unsafe { ffi_getauxval(key as libc::c_ulong) as usize })
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
/// Tries to read the auxiliary vector from the `file`. If this fails, this
|
| 148 |
+
/// function returns `Err`.
|
| 149 |
+
pub(super) fn auxv_from_file(file: &str) -> Result<AuxVec, alloc::string::String> {
|
| 150 |
+
let file = super::read_file(file)?;
|
| 151 |
+
auxv_from_file_bytes(&file)
|
| 152 |
+
}
|
| 153 |
+
|
| 154 |
+
/// Read auxiliary vector from a slice of bytes.
|
| 155 |
+
pub(super) fn auxv_from_file_bytes(bytes: &[u8]) -> Result<AuxVec, alloc::string::String> {
|
| 156 |
+
// See <https://github.com/torvalds/linux/blob/v5.15/include/uapi/linux/auxvec.h>.
|
| 157 |
+
//
|
| 158 |
+
// The auxiliary vector contains at most 34 (key,value) fields: from
|
| 159 |
+
// `AT_MINSIGSTKSZ` to `AT_NULL`, but its number may increase.
|
| 160 |
+
let len = bytes.len();
|
| 161 |
+
let mut buf = alloc::vec![0_usize; 1 + len / core::mem::size_of::<usize>()];
|
| 162 |
+
unsafe {
|
| 163 |
+
core::ptr::copy_nonoverlapping(bytes.as_ptr(), buf.as_mut_ptr() as *mut u8, len);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
auxv_from_buf(&buf)
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/// Tries to interpret the `buffer` as an auxiliary vector. If that fails, this
|
| 170 |
+
/// function returns `Err`.
|
| 171 |
+
fn auxv_from_buf(buf: &[usize]) -> Result<AuxVec, alloc::string::String> {
|
| 172 |
+
// Targets with only AT_HWCAP:
|
| 173 |
+
#[cfg(any(
|
| 174 |
+
target_arch = "riscv32",
|
| 175 |
+
target_arch = "riscv64",
|
| 176 |
+
target_arch = "mips",
|
| 177 |
+
target_arch = "mips64",
|
| 178 |
+
target_arch = "loongarch32",
|
| 179 |
+
target_arch = "loongarch64",
|
| 180 |
+
))]
|
| 181 |
+
{
|
| 182 |
+
for el in buf.chunks(2) {
|
| 183 |
+
match el[0] {
|
| 184 |
+
AT_NULL => break,
|
| 185 |
+
AT_HWCAP => return Ok(AuxVec { hwcap: el[1] }),
|
| 186 |
+
_ => (),
|
| 187 |
+
}
|
| 188 |
+
}
|
| 189 |
+
}
|
| 190 |
+
// Targets with AT_HWCAP and AT_HWCAP2:
|
| 191 |
+
#[cfg(any(
|
| 192 |
+
target_arch = "aarch64",
|
| 193 |
+
target_arch = "arm",
|
| 194 |
+
target_arch = "powerpc",
|
| 195 |
+
target_arch = "powerpc64",
|
| 196 |
+
target_arch = "s390x",
|
| 197 |
+
))]
|
| 198 |
+
{
|
| 199 |
+
let mut hwcap = None;
|
| 200 |
+
// For some platforms, AT_HWCAP2 was added recently, so let it default to zero.
|
| 201 |
+
let mut hwcap2 = 0;
|
| 202 |
+
for el in buf.chunks(2) {
|
| 203 |
+
match el[0] {
|
| 204 |
+
AT_NULL => break,
|
| 205 |
+
AT_HWCAP => hwcap = Some(el[1]),
|
| 206 |
+
AT_HWCAP2 => hwcap2 = el[1],
|
| 207 |
+
_ => (),
|
| 208 |
+
}
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
if let Some(hwcap) = hwcap {
|
| 212 |
+
return Ok(AuxVec { hwcap, hwcap2 });
|
| 213 |
+
}
|
| 214 |
+
}
|
| 215 |
+
// Suppress unused variable
|
| 216 |
+
let _ = buf;
|
| 217 |
+
Err(alloc::string::String::from("hwcap not found"))
|
| 218 |
+
}
|
| 219 |
+
|
| 220 |
+
#[cfg(test)]
|
| 221 |
+
mod tests;
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/auxvec/tests.rs
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use super::*;
|
| 2 |
+
|
| 3 |
+
// FIXME: on mips/mips64 getauxval returns 0, and /proc/self/auxv
|
| 4 |
+
// does not always contain the AT_HWCAP key under qemu.
|
| 5 |
+
#[cfg(any(
|
| 6 |
+
target_arch = "arm",
|
| 7 |
+
target_arch = "powerpc",
|
| 8 |
+
target_arch = "powerpc64",
|
| 9 |
+
target_arch = "s390x",
|
| 10 |
+
))]
|
| 11 |
+
#[test]
|
| 12 |
+
fn auxv_crate() {
|
| 13 |
+
let v = auxv();
|
| 14 |
+
if let Ok(hwcap) = getauxval(AT_HWCAP) {
|
| 15 |
+
let rt_hwcap = v.expect("failed to find hwcap key").hwcap;
|
| 16 |
+
assert_eq!(rt_hwcap, hwcap);
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
// Targets with AT_HWCAP and AT_HWCAP2:
|
| 20 |
+
#[cfg(any(
|
| 21 |
+
target_arch = "aarch64",
|
| 22 |
+
target_arch = "arm",
|
| 23 |
+
target_arch = "powerpc",
|
| 24 |
+
target_arch = "powerpc64",
|
| 25 |
+
target_arch = "s390x",
|
| 26 |
+
))]
|
| 27 |
+
{
|
| 28 |
+
if let Ok(hwcap2) = getauxval(AT_HWCAP2) {
|
| 29 |
+
let rt_hwcap2 = v.expect("failed to find hwcap2 key").hwcap2;
|
| 30 |
+
assert_eq!(rt_hwcap2, hwcap2);
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
#[test]
|
| 36 |
+
fn auxv_dump() {
|
| 37 |
+
if let Ok(auxvec) = auxv() {
|
| 38 |
+
println!("{:?}", auxvec);
|
| 39 |
+
} else {
|
| 40 |
+
println!("both getauxval() and reading /proc/self/auxv failed!");
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
cfg_select! {
|
| 45 |
+
target_arch = "arm" => {
|
| 46 |
+
// The tests below can be executed under qemu, where we do not have access to the test
|
| 47 |
+
// files on disk, so we need to embed them with `include_bytes!`.
|
| 48 |
+
#[test]
|
| 49 |
+
fn linux_rpi3() {
|
| 50 |
+
let auxv = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-rpi3.auxv"));
|
| 51 |
+
let v = auxv_from_file_bytes(auxv).unwrap();
|
| 52 |
+
assert_eq!(v.hwcap, 4174038);
|
| 53 |
+
assert_eq!(v.hwcap2, 16);
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
#[test]
|
| 57 |
+
fn linux_macos_vb() {
|
| 58 |
+
let auxv = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv"));
|
| 59 |
+
// The file contains HWCAP but not HWCAP2. In that case, we treat HWCAP2 as zero.
|
| 60 |
+
let v = auxv_from_file_bytes(auxv).unwrap();
|
| 61 |
+
assert_eq!(v.hwcap, 126614527);
|
| 62 |
+
assert_eq!(v.hwcap2, 0);
|
| 63 |
+
}
|
| 64 |
+
}
|
| 65 |
+
target_arch = "aarch64" => {
|
| 66 |
+
#[cfg(target_endian = "little")]
|
| 67 |
+
#[test]
|
| 68 |
+
fn linux_artificial_aarch64() {
|
| 69 |
+
let auxv = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-artificial-aarch64.auxv"));
|
| 70 |
+
let v = auxv_from_file_bytes(auxv).unwrap();
|
| 71 |
+
assert_eq!(v.hwcap, 0x0123456789abcdef);
|
| 72 |
+
assert_eq!(v.hwcap2, 0x02468ace13579bdf);
|
| 73 |
+
}
|
| 74 |
+
#[cfg(target_endian = "little")]
|
| 75 |
+
#[test]
|
| 76 |
+
fn linux_no_hwcap2_aarch64() {
|
| 77 |
+
let auxv = include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/src/detect/test_data/linux-no-hwcap2-aarch64.auxv"));
|
| 78 |
+
let v = auxv_from_file_bytes(auxv).unwrap();
|
| 79 |
+
// An absent HWCAP2 is treated as zero, and does not prevent acceptance of HWCAP.
|
| 80 |
+
assert_ne!(v.hwcap, 0);
|
| 81 |
+
assert_eq!(v.hwcap2, 0);
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
_ => {}
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
#[test]
|
| 88 |
+
fn auxv_dump_procfs() {
|
| 89 |
+
if let Ok(auxvec) = auxv_from_file("/proc/self/auxv") {
|
| 90 |
+
println!("{:?}", auxvec);
|
| 91 |
+
} else {
|
| 92 |
+
println!("reading /proc/self/auxv failed!");
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
#[cfg(any(
|
| 97 |
+
target_arch = "aarch64",
|
| 98 |
+
target_arch = "arm",
|
| 99 |
+
target_arch = "powerpc",
|
| 100 |
+
target_arch = "powerpc64",
|
| 101 |
+
target_arch = "s390x",
|
| 102 |
+
))]
|
| 103 |
+
#[test]
|
| 104 |
+
fn auxv_crate_procfs() {
|
| 105 |
+
if let Ok(procfs_auxv) = auxv_from_file("/proc/self/auxv") {
|
| 106 |
+
assert_eq!(auxv().unwrap(), procfs_auxv);
|
| 107 |
+
}
|
| 108 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/loongarch.rs
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for LoongArch on Linux.
|
| 2 |
+
|
| 3 |
+
use core::arch::asm;
|
| 4 |
+
|
| 5 |
+
use super::auxvec;
|
| 6 |
+
use crate::detect::{Feature, bit, cache};
|
| 7 |
+
|
| 8 |
+
/// Try to read the features from the auxiliary vector.
|
| 9 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 10 |
+
let mut value = cache::Initializer::default();
|
| 11 |
+
let enable_feature = |value: &mut cache::Initializer, feature, enable| {
|
| 12 |
+
if enable {
|
| 13 |
+
value.set(feature as u32);
|
| 14 |
+
}
|
| 15 |
+
};
|
| 16 |
+
|
| 17 |
+
// The values are part of the platform-specific [cpucfg]
|
| 18 |
+
//
|
| 19 |
+
// [cpucfg]: LoongArch Reference Manual Volume 1: Basic Architecture v1.1
|
| 20 |
+
let cpucfg1: usize;
|
| 21 |
+
let cpucfg2: usize;
|
| 22 |
+
let cpucfg3: usize;
|
| 23 |
+
unsafe {
|
| 24 |
+
asm!(
|
| 25 |
+
"cpucfg {}, {}",
|
| 26 |
+
"cpucfg {}, {}",
|
| 27 |
+
"cpucfg {}, {}",
|
| 28 |
+
out(reg) cpucfg1, in(reg) 1,
|
| 29 |
+
out(reg) cpucfg2, in(reg) 2,
|
| 30 |
+
out(reg) cpucfg3, in(reg) 3,
|
| 31 |
+
options(pure, nomem, preserves_flags, nostack)
|
| 32 |
+
);
|
| 33 |
+
}
|
| 34 |
+
enable_feature(&mut value, Feature::_32s, bit::test(cpucfg1, 0) || bit::test(cpucfg1, 1));
|
| 35 |
+
enable_feature(&mut value, Feature::frecipe, bit::test(cpucfg2, 25));
|
| 36 |
+
enable_feature(&mut value, Feature::div32, bit::test(cpucfg2, 26));
|
| 37 |
+
enable_feature(&mut value, Feature::lam_bh, bit::test(cpucfg2, 27));
|
| 38 |
+
enable_feature(&mut value, Feature::lamcas, bit::test(cpucfg2, 28));
|
| 39 |
+
enable_feature(&mut value, Feature::scq, bit::test(cpucfg2, 30));
|
| 40 |
+
enable_feature(&mut value, Feature::ld_seq_sa, bit::test(cpucfg3, 23));
|
| 41 |
+
|
| 42 |
+
// The values are part of the platform-specific [asm/hwcap.h][hwcap]
|
| 43 |
+
//
|
| 44 |
+
// [hwcap]: https://github.com/torvalds/linux/blob/master/arch/loongarch/include/uapi/asm/hwcap.h
|
| 45 |
+
if let Ok(auxv) = auxvec::auxv() {
|
| 46 |
+
enable_feature(&mut value, Feature::f, bit::test(cpucfg2, 1) && bit::test(auxv.hwcap, 3));
|
| 47 |
+
enable_feature(&mut value, Feature::d, bit::test(cpucfg2, 2) && bit::test(auxv.hwcap, 3));
|
| 48 |
+
enable_feature(&mut value, Feature::lsx, bit::test(auxv.hwcap, 4));
|
| 49 |
+
enable_feature(&mut value, Feature::lasx, bit::test(auxv.hwcap, 5));
|
| 50 |
+
enable_feature(
|
| 51 |
+
&mut value,
|
| 52 |
+
Feature::lbt,
|
| 53 |
+
bit::test(auxv.hwcap, 10) && bit::test(auxv.hwcap, 11) && bit::test(auxv.hwcap, 12),
|
| 54 |
+
);
|
| 55 |
+
enable_feature(&mut value, Feature::lvz, bit::test(auxv.hwcap, 9));
|
| 56 |
+
enable_feature(&mut value, Feature::ual, bit::test(auxv.hwcap, 2));
|
| 57 |
+
return value;
|
| 58 |
+
}
|
| 59 |
+
value
|
| 60 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/mips.rs
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for MIPS on Linux.
|
| 2 |
+
|
| 3 |
+
use super::auxvec;
|
| 4 |
+
use crate::detect::{Feature, bit, cache};
|
| 5 |
+
|
| 6 |
+
/// Try to read the features from the auxiliary vector.
|
| 7 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 8 |
+
let mut value = cache::Initializer::default();
|
| 9 |
+
let enable_feature = |value: &mut cache::Initializer, f, enable| {
|
| 10 |
+
if enable {
|
| 11 |
+
value.set(f as u32);
|
| 12 |
+
}
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
// The values are part of the platform-specific [asm/hwcap.h][hwcap]
|
| 16 |
+
//
|
| 17 |
+
// [hwcap]: https://github.com/torvalds/linux/blob/master/arch/mips/include/uapi/asm/hwcap.h
|
| 18 |
+
if let Ok(auxv) = auxvec::auxv() {
|
| 19 |
+
enable_feature(&mut value, Feature::msa, bit::test(auxv.hwcap, 1));
|
| 20 |
+
return value;
|
| 21 |
+
}
|
| 22 |
+
value
|
| 23 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/mod.rs
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on Linux
|
| 2 |
+
|
| 3 |
+
use alloc::vec::Vec;
|
| 4 |
+
|
| 5 |
+
mod auxvec;
|
| 6 |
+
|
| 7 |
+
fn read_file(orig_path: &str) -> Result<Vec<u8>, alloc::string::String> {
|
| 8 |
+
use alloc::format;
|
| 9 |
+
|
| 10 |
+
let mut path = Vec::from(orig_path.as_bytes());
|
| 11 |
+
path.push(0);
|
| 12 |
+
|
| 13 |
+
unsafe {
|
| 14 |
+
let file = libc::open(path.as_ptr() as *const libc::c_char, libc::O_RDONLY);
|
| 15 |
+
if file == -1 {
|
| 16 |
+
return Err(format!("Cannot open file at {orig_path}"));
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
let mut data = Vec::new();
|
| 20 |
+
loop {
|
| 21 |
+
data.reserve(4096);
|
| 22 |
+
let spare = data.spare_capacity_mut();
|
| 23 |
+
match libc::read(file, spare.as_mut_ptr() as *mut _, spare.len()) {
|
| 24 |
+
-1 => {
|
| 25 |
+
libc::close(file);
|
| 26 |
+
return Err(format!("Error while reading from file at {orig_path}"));
|
| 27 |
+
}
|
| 28 |
+
0 => break,
|
| 29 |
+
n => data.set_len(data.len() + n as usize),
|
| 30 |
+
}
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
libc::close(file);
|
| 34 |
+
Ok(data)
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
cfg_select! {
|
| 39 |
+
target_arch = "aarch64" => {
|
| 40 |
+
mod aarch64;
|
| 41 |
+
pub(crate) use self::aarch64::detect_features;
|
| 42 |
+
}
|
| 43 |
+
target_arch = "arm" => {
|
| 44 |
+
mod arm;
|
| 45 |
+
pub(crate) use self::arm::detect_features;
|
| 46 |
+
}
|
| 47 |
+
any(target_arch = "riscv32", target_arch = "riscv64") => {
|
| 48 |
+
mod riscv;
|
| 49 |
+
pub(crate) use self::riscv::detect_features;
|
| 50 |
+
}
|
| 51 |
+
any(target_arch = "mips", target_arch = "mips64") => {
|
| 52 |
+
mod mips;
|
| 53 |
+
pub(crate) use self::mips::detect_features;
|
| 54 |
+
}
|
| 55 |
+
any(target_arch = "powerpc", target_arch = "powerpc64") => {
|
| 56 |
+
mod powerpc;
|
| 57 |
+
pub(crate) use self::powerpc::detect_features;
|
| 58 |
+
}
|
| 59 |
+
any(target_arch = "loongarch32", target_arch = "loongarch64") => {
|
| 60 |
+
mod loongarch;
|
| 61 |
+
pub(crate) use self::loongarch::detect_features;
|
| 62 |
+
}
|
| 63 |
+
target_arch = "s390x" => {
|
| 64 |
+
mod s390x;
|
| 65 |
+
pub(crate) use self::s390x::detect_features;
|
| 66 |
+
}
|
| 67 |
+
_ => {
|
| 68 |
+
use crate::detect::cache;
|
| 69 |
+
/// Performs run-time feature detection.
|
| 70 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 71 |
+
cache::Initializer::default()
|
| 72 |
+
}
|
| 73 |
+
}
|
| 74 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/powerpc.rs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for PowerPC on Linux.
|
| 2 |
+
|
| 3 |
+
use super::auxvec;
|
| 4 |
+
use crate::detect::{Feature, cache};
|
| 5 |
+
|
| 6 |
+
/// Try to read the features from the auxiliary vector.
|
| 7 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 8 |
+
let mut value = cache::Initializer::default();
|
| 9 |
+
let enable_feature = |value: &mut cache::Initializer, f, enable| {
|
| 10 |
+
if enable {
|
| 11 |
+
value.set(f as u32);
|
| 12 |
+
}
|
| 13 |
+
};
|
| 14 |
+
|
| 15 |
+
// The values are part of the platform-specific [asm/cputable.h][cputable]
|
| 16 |
+
//
|
| 17 |
+
// [cputable]: https://github.com/torvalds/linux/blob/master/arch/powerpc/include/uapi/asm/cputable.h
|
| 18 |
+
if let Ok(auxv) = auxvec::auxv() {
|
| 19 |
+
// note: the PowerPC values are the mask to do the test (instead of the
|
| 20 |
+
// index of the bit to test like in ARM and Aarch64)
|
| 21 |
+
enable_feature(&mut value, Feature::altivec, auxv.hwcap & 0x10000000 != 0);
|
| 22 |
+
enable_feature(&mut value, Feature::vsx, auxv.hwcap & 0x00000080 != 0);
|
| 23 |
+
let power8_features = auxv.hwcap2 & 0x80000000 != 0;
|
| 24 |
+
enable_feature(&mut value, Feature::power8, power8_features);
|
| 25 |
+
enable_feature(&mut value, Feature::power8_altivec, power8_features);
|
| 26 |
+
enable_feature(&mut value, Feature::power8_crypto, power8_features);
|
| 27 |
+
enable_feature(&mut value, Feature::power8_vector, power8_features);
|
| 28 |
+
let power9_features = auxv.hwcap2 & 0x00800000 != 0;
|
| 29 |
+
enable_feature(&mut value, Feature::power9, power9_features);
|
| 30 |
+
enable_feature(&mut value, Feature::power9_altivec, power9_features);
|
| 31 |
+
enable_feature(&mut value, Feature::power9_vector, power9_features);
|
| 32 |
+
return value;
|
| 33 |
+
}
|
| 34 |
+
value
|
| 35 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/riscv.rs
ADDED
|
@@ -0,0 +1,323 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for RISC-V on Linux.
|
| 2 |
+
//!
|
| 3 |
+
//! On RISC-V, detection using auxv only supports single-letter extensions.
|
| 4 |
+
//! So, we use riscv_hwprobe that supports multi-letter extensions if available.
|
| 5 |
+
//! <https://www.kernel.org/doc/html/latest/arch/riscv/hwprobe.html>
|
| 6 |
+
|
| 7 |
+
use core::ptr;
|
| 8 |
+
|
| 9 |
+
use super::super::riscv::imply_features;
|
| 10 |
+
use super::auxvec;
|
| 11 |
+
use crate::detect::{Feature, bit, cache};
|
| 12 |
+
|
| 13 |
+
// See <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/prctl.h?h=v6.16>
|
| 14 |
+
// for runtime status query constants.
|
| 15 |
+
const PR_RISCV_V_GET_CONTROL: libc::c_int = 70;
|
| 16 |
+
const PR_RISCV_V_VSTATE_CTRL_ON: libc::c_int = 2;
|
| 17 |
+
const PR_RISCV_V_VSTATE_CTRL_CUR_MASK: libc::c_int = 3;
|
| 18 |
+
|
| 19 |
+
// See <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/include/uapi/asm/hwprobe.h?h=v6.16>
|
| 20 |
+
// for riscv_hwprobe struct and hardware probing constants.
|
| 21 |
+
|
| 22 |
+
#[repr(C)]
|
| 23 |
+
struct riscv_hwprobe {
|
| 24 |
+
key: i64,
|
| 25 |
+
value: u64,
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
impl riscv_hwprobe {
|
| 29 |
+
// key is overwritten to -1 if not supported by riscv_hwprobe syscall.
|
| 30 |
+
pub fn get(&self) -> Option<u64> {
|
| 31 |
+
(self.key != -1).then_some(self.value)
|
| 32 |
+
}
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
#[allow(non_upper_case_globals)]
|
| 36 |
+
const __NR_riscv_hwprobe: libc::c_long = 258;
|
| 37 |
+
|
| 38 |
+
const RISCV_HWPROBE_KEY_BASE_BEHAVIOR: i64 = 3;
|
| 39 |
+
const RISCV_HWPROBE_BASE_BEHAVIOR_IMA: u64 = 1 << 0;
|
| 40 |
+
|
| 41 |
+
const RISCV_HWPROBE_KEY_IMA_EXT_0: i64 = 4;
|
| 42 |
+
const RISCV_HWPROBE_IMA_FD: u64 = 1 << 0;
|
| 43 |
+
const RISCV_HWPROBE_IMA_C: u64 = 1 << 1;
|
| 44 |
+
const RISCV_HWPROBE_IMA_V: u64 = 1 << 2;
|
| 45 |
+
const RISCV_HWPROBE_EXT_ZBA: u64 = 1 << 3;
|
| 46 |
+
const RISCV_HWPROBE_EXT_ZBB: u64 = 1 << 4;
|
| 47 |
+
const RISCV_HWPROBE_EXT_ZBS: u64 = 1 << 5;
|
| 48 |
+
const RISCV_HWPROBE_EXT_ZICBOZ: u64 = 1 << 6;
|
| 49 |
+
const RISCV_HWPROBE_EXT_ZBC: u64 = 1 << 7;
|
| 50 |
+
const RISCV_HWPROBE_EXT_ZBKB: u64 = 1 << 8;
|
| 51 |
+
const RISCV_HWPROBE_EXT_ZBKC: u64 = 1 << 9;
|
| 52 |
+
const RISCV_HWPROBE_EXT_ZBKX: u64 = 1 << 10;
|
| 53 |
+
const RISCV_HWPROBE_EXT_ZKND: u64 = 1 << 11;
|
| 54 |
+
const RISCV_HWPROBE_EXT_ZKNE: u64 = 1 << 12;
|
| 55 |
+
const RISCV_HWPROBE_EXT_ZKNH: u64 = 1 << 13;
|
| 56 |
+
const RISCV_HWPROBE_EXT_ZKSED: u64 = 1 << 14;
|
| 57 |
+
const RISCV_HWPROBE_EXT_ZKSH: u64 = 1 << 15;
|
| 58 |
+
const RISCV_HWPROBE_EXT_ZKT: u64 = 1 << 16;
|
| 59 |
+
const RISCV_HWPROBE_EXT_ZVBB: u64 = 1 << 17;
|
| 60 |
+
const RISCV_HWPROBE_EXT_ZVBC: u64 = 1 << 18;
|
| 61 |
+
const RISCV_HWPROBE_EXT_ZVKB: u64 = 1 << 19;
|
| 62 |
+
const RISCV_HWPROBE_EXT_ZVKG: u64 = 1 << 20;
|
| 63 |
+
const RISCV_HWPROBE_EXT_ZVKNED: u64 = 1 << 21;
|
| 64 |
+
const RISCV_HWPROBE_EXT_ZVKNHA: u64 = 1 << 22;
|
| 65 |
+
const RISCV_HWPROBE_EXT_ZVKNHB: u64 = 1 << 23;
|
| 66 |
+
const RISCV_HWPROBE_EXT_ZVKSED: u64 = 1 << 24;
|
| 67 |
+
const RISCV_HWPROBE_EXT_ZVKSH: u64 = 1 << 25;
|
| 68 |
+
const RISCV_HWPROBE_EXT_ZVKT: u64 = 1 << 26;
|
| 69 |
+
const RISCV_HWPROBE_EXT_ZFH: u64 = 1 << 27;
|
| 70 |
+
const RISCV_HWPROBE_EXT_ZFHMIN: u64 = 1 << 28;
|
| 71 |
+
const RISCV_HWPROBE_EXT_ZIHINTNTL: u64 = 1 << 29;
|
| 72 |
+
const RISCV_HWPROBE_EXT_ZVFH: u64 = 1 << 30;
|
| 73 |
+
const RISCV_HWPROBE_EXT_ZVFHMIN: u64 = 1 << 31;
|
| 74 |
+
const RISCV_HWPROBE_EXT_ZFA: u64 = 1 << 32;
|
| 75 |
+
const RISCV_HWPROBE_EXT_ZTSO: u64 = 1 << 33;
|
| 76 |
+
const RISCV_HWPROBE_EXT_ZACAS: u64 = 1 << 34;
|
| 77 |
+
const RISCV_HWPROBE_EXT_ZICOND: u64 = 1 << 35;
|
| 78 |
+
const RISCV_HWPROBE_EXT_ZIHINTPAUSE: u64 = 1 << 36;
|
| 79 |
+
const RISCV_HWPROBE_EXT_ZVE32X: u64 = 1 << 37;
|
| 80 |
+
const RISCV_HWPROBE_EXT_ZVE32F: u64 = 1 << 38;
|
| 81 |
+
const RISCV_HWPROBE_EXT_ZVE64X: u64 = 1 << 39;
|
| 82 |
+
const RISCV_HWPROBE_EXT_ZVE64F: u64 = 1 << 40;
|
| 83 |
+
const RISCV_HWPROBE_EXT_ZVE64D: u64 = 1 << 41;
|
| 84 |
+
const RISCV_HWPROBE_EXT_ZIMOP: u64 = 1 << 42;
|
| 85 |
+
const RISCV_HWPROBE_EXT_ZCA: u64 = 1 << 43;
|
| 86 |
+
const RISCV_HWPROBE_EXT_ZCB: u64 = 1 << 44;
|
| 87 |
+
const RISCV_HWPROBE_EXT_ZCD: u64 = 1 << 45;
|
| 88 |
+
const RISCV_HWPROBE_EXT_ZCF: u64 = 1 << 46;
|
| 89 |
+
const RISCV_HWPROBE_EXT_ZCMOP: u64 = 1 << 47;
|
| 90 |
+
const RISCV_HWPROBE_EXT_ZAWRS: u64 = 1 << 48;
|
| 91 |
+
// Excluded because it only reports the existence of `prctl`-based pointer masking control.
|
| 92 |
+
// const RISCV_HWPROBE_EXT_SUPM: u64 = 1 << 49;
|
| 93 |
+
const RISCV_HWPROBE_EXT_ZICNTR: u64 = 1 << 50;
|
| 94 |
+
const RISCV_HWPROBE_EXT_ZIHPM: u64 = 1 << 51;
|
| 95 |
+
const RISCV_HWPROBE_EXT_ZFBFMIN: u64 = 1 << 52;
|
| 96 |
+
const RISCV_HWPROBE_EXT_ZVFBFMIN: u64 = 1 << 53;
|
| 97 |
+
const RISCV_HWPROBE_EXT_ZVFBFWMA: u64 = 1 << 54;
|
| 98 |
+
const RISCV_HWPROBE_EXT_ZICBOM: u64 = 1 << 55;
|
| 99 |
+
const RISCV_HWPROBE_EXT_ZAAMO: u64 = 1 << 56;
|
| 100 |
+
const RISCV_HWPROBE_EXT_ZALRSC: u64 = 1 << 57;
|
| 101 |
+
const RISCV_HWPROBE_EXT_ZABHA: u64 = 1 << 58;
|
| 102 |
+
|
| 103 |
+
const RISCV_HWPROBE_KEY_CPUPERF_0: i64 = 5;
|
| 104 |
+
const RISCV_HWPROBE_MISALIGNED_FAST: u64 = 3;
|
| 105 |
+
const RISCV_HWPROBE_MISALIGNED_MASK: u64 = 7;
|
| 106 |
+
|
| 107 |
+
const RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF: i64 = 9;
|
| 108 |
+
const RISCV_HWPROBE_MISALIGNED_SCALAR_FAST: u64 = 3;
|
| 109 |
+
|
| 110 |
+
const RISCV_HWPROBE_KEY_MISALIGNED_VECTOR_PERF: i64 = 10;
|
| 111 |
+
const RISCV_HWPROBE_MISALIGNED_VECTOR_FAST: u64 = 3;
|
| 112 |
+
|
| 113 |
+
// syscall returns an unsupported error if riscv_hwprobe is not supported,
|
| 114 |
+
// so we can safely use this function on older versions of Linux.
|
| 115 |
+
fn _riscv_hwprobe(out: &mut [riscv_hwprobe]) -> bool {
|
| 116 |
+
unsafe fn __riscv_hwprobe(
|
| 117 |
+
pairs: *mut riscv_hwprobe,
|
| 118 |
+
pair_count: libc::size_t,
|
| 119 |
+
cpu_set_size: libc::size_t,
|
| 120 |
+
cpus: *mut libc::c_ulong,
|
| 121 |
+
flags: libc::c_uint,
|
| 122 |
+
) -> libc::c_long {
|
| 123 |
+
unsafe { libc::syscall(__NR_riscv_hwprobe, pairs, pair_count, cpu_set_size, cpus, flags) }
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
unsafe { __riscv_hwprobe(out.as_mut_ptr(), out.len(), 0, ptr::null_mut(), 0) == 0 }
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
/// Read list of supported features from (1) the auxiliary vector
|
| 130 |
+
/// and (2) the results of `riscv_hwprobe` and `prctl` system calls.
|
| 131 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 132 |
+
let mut value = cache::Initializer::default();
|
| 133 |
+
let mut enable_feature = |feature, enable| {
|
| 134 |
+
if enable {
|
| 135 |
+
value.set(feature as u32);
|
| 136 |
+
}
|
| 137 |
+
};
|
| 138 |
+
|
| 139 |
+
// Use auxiliary vector to enable single-letter ISA extensions.
|
| 140 |
+
// The values are part of the platform-specific [asm/hwcap.h][hwcap]
|
| 141 |
+
//
|
| 142 |
+
// [hwcap]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/riscv/include/uapi/asm/hwcap.h?h=v6.16
|
| 143 |
+
let auxv = auxvec::auxv().expect("read auxvec"); // should not fail on RISC-V platform
|
| 144 |
+
let mut has_i = bit::test(auxv.hwcap, (b'i' - b'a').into());
|
| 145 |
+
#[allow(clippy::eq_op)]
|
| 146 |
+
enable_feature(Feature::a, bit::test(auxv.hwcap, (b'a' - b'a').into()));
|
| 147 |
+
enable_feature(Feature::c, bit::test(auxv.hwcap, (b'c' - b'a').into()));
|
| 148 |
+
enable_feature(Feature::d, bit::test(auxv.hwcap, (b'd' - b'a').into()));
|
| 149 |
+
enable_feature(Feature::f, bit::test(auxv.hwcap, (b'f' - b'a').into()));
|
| 150 |
+
enable_feature(Feature::m, bit::test(auxv.hwcap, (b'm' - b'a').into()));
|
| 151 |
+
let has_v = bit::test(auxv.hwcap, (b'v' - b'a').into());
|
| 152 |
+
let mut is_v_set = false;
|
| 153 |
+
|
| 154 |
+
// Use riscv_hwprobe syscall to query more extensions and
|
| 155 |
+
// performance-related capabilities.
|
| 156 |
+
'hwprobe: {
|
| 157 |
+
macro_rules! init {
|
| 158 |
+
{ $($name: ident : $key: expr),* $(,)? } => {
|
| 159 |
+
#[repr(usize)]
|
| 160 |
+
enum Indices { $($name),* }
|
| 161 |
+
let mut t = [$(riscv_hwprobe { key: $key, value: 0 }),*];
|
| 162 |
+
macro_rules! data_mut { () => { &mut t } }
|
| 163 |
+
macro_rules! query { [$idx: ident] => { t[Indices::$idx as usize].get() } }
|
| 164 |
+
}
|
| 165 |
+
}
|
| 166 |
+
init! {
|
| 167 |
+
BaseBehavior: RISCV_HWPROBE_KEY_BASE_BEHAVIOR,
|
| 168 |
+
Extensions: RISCV_HWPROBE_KEY_IMA_EXT_0,
|
| 169 |
+
MisalignedScalarPerf: RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF,
|
| 170 |
+
MisalignedVectorPerf: RISCV_HWPROBE_KEY_MISALIGNED_VECTOR_PERF,
|
| 171 |
+
MisalignedScalarPerfFallback: RISCV_HWPROBE_KEY_CPUPERF_0,
|
| 172 |
+
};
|
| 173 |
+
if !_riscv_hwprobe(data_mut!()) {
|
| 174 |
+
break 'hwprobe;
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
// Query scalar misaligned behavior.
|
| 178 |
+
if let Some(value) = query![MisalignedScalarPerf] {
|
| 179 |
+
enable_feature(
|
| 180 |
+
Feature::unaligned_scalar_mem,
|
| 181 |
+
value == RISCV_HWPROBE_MISALIGNED_SCALAR_FAST,
|
| 182 |
+
);
|
| 183 |
+
} else if let Some(value) = query![MisalignedScalarPerfFallback] {
|
| 184 |
+
// Deprecated method for fallback
|
| 185 |
+
enable_feature(
|
| 186 |
+
Feature::unaligned_scalar_mem,
|
| 187 |
+
value & RISCV_HWPROBE_MISALIGNED_MASK == RISCV_HWPROBE_MISALIGNED_FAST,
|
| 188 |
+
);
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
// Query vector misaligned behavior.
|
| 192 |
+
if let Some(value) = query![MisalignedVectorPerf] {
|
| 193 |
+
enable_feature(
|
| 194 |
+
Feature::unaligned_vector_mem,
|
| 195 |
+
value == RISCV_HWPROBE_MISALIGNED_VECTOR_FAST,
|
| 196 |
+
);
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
// Query whether "I" base and extensions "M" and "A" (as in the ISA
|
| 200 |
+
// manual version 2.2) are enabled. "I" base at that time corresponds
|
| 201 |
+
// to "I", "Zicsr", "Zicntr" and "Zifencei" (as in the ISA manual version
|
| 202 |
+
// 20240411).
|
| 203 |
+
// This is a current requirement of
|
| 204 |
+
// `RISCV_HWPROBE_KEY_IMA_EXT_0`-based tests.
|
| 205 |
+
if query![BaseBehavior].is_none_or(|value| value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA == 0) {
|
| 206 |
+
break 'hwprobe;
|
| 207 |
+
}
|
| 208 |
+
has_i = true;
|
| 209 |
+
enable_feature(Feature::zicsr, true);
|
| 210 |
+
enable_feature(Feature::zicntr, true);
|
| 211 |
+
enable_feature(Feature::zifencei, true);
|
| 212 |
+
enable_feature(Feature::m, true);
|
| 213 |
+
enable_feature(Feature::a, true);
|
| 214 |
+
|
| 215 |
+
// Enable features based on `RISCV_HWPROBE_KEY_IMA_EXT_0`.
|
| 216 |
+
let Some(ima_ext_0) = query![Extensions] else {
|
| 217 |
+
break 'hwprobe;
|
| 218 |
+
};
|
| 219 |
+
let test = |mask| (ima_ext_0 & mask) != 0;
|
| 220 |
+
|
| 221 |
+
enable_feature(Feature::d, test(RISCV_HWPROBE_IMA_FD)); // F is implied.
|
| 222 |
+
enable_feature(Feature::c, test(RISCV_HWPROBE_IMA_C));
|
| 223 |
+
|
| 224 |
+
enable_feature(Feature::zicntr, test(RISCV_HWPROBE_EXT_ZICNTR));
|
| 225 |
+
enable_feature(Feature::zihpm, test(RISCV_HWPROBE_EXT_ZIHPM));
|
| 226 |
+
|
| 227 |
+
enable_feature(Feature::zihintntl, test(RISCV_HWPROBE_EXT_ZIHINTNTL));
|
| 228 |
+
enable_feature(Feature::zihintpause, test(RISCV_HWPROBE_EXT_ZIHINTPAUSE));
|
| 229 |
+
enable_feature(Feature::zimop, test(RISCV_HWPROBE_EXT_ZIMOP));
|
| 230 |
+
enable_feature(Feature::zicbom, test(RISCV_HWPROBE_EXT_ZICBOM));
|
| 231 |
+
enable_feature(Feature::zicboz, test(RISCV_HWPROBE_EXT_ZICBOZ));
|
| 232 |
+
enable_feature(Feature::zicond, test(RISCV_HWPROBE_EXT_ZICOND));
|
| 233 |
+
|
| 234 |
+
enable_feature(Feature::zalrsc, test(RISCV_HWPROBE_EXT_ZALRSC));
|
| 235 |
+
enable_feature(Feature::zaamo, test(RISCV_HWPROBE_EXT_ZAAMO));
|
| 236 |
+
enable_feature(Feature::zawrs, test(RISCV_HWPROBE_EXT_ZAWRS));
|
| 237 |
+
enable_feature(Feature::zabha, test(RISCV_HWPROBE_EXT_ZABHA));
|
| 238 |
+
enable_feature(Feature::zacas, test(RISCV_HWPROBE_EXT_ZACAS));
|
| 239 |
+
enable_feature(Feature::ztso, test(RISCV_HWPROBE_EXT_ZTSO));
|
| 240 |
+
|
| 241 |
+
enable_feature(Feature::zba, test(RISCV_HWPROBE_EXT_ZBA));
|
| 242 |
+
enable_feature(Feature::zbb, test(RISCV_HWPROBE_EXT_ZBB));
|
| 243 |
+
enable_feature(Feature::zbs, test(RISCV_HWPROBE_EXT_ZBS));
|
| 244 |
+
enable_feature(Feature::zbc, test(RISCV_HWPROBE_EXT_ZBC));
|
| 245 |
+
|
| 246 |
+
enable_feature(Feature::zbkb, test(RISCV_HWPROBE_EXT_ZBKB));
|
| 247 |
+
enable_feature(Feature::zbkc, test(RISCV_HWPROBE_EXT_ZBKC));
|
| 248 |
+
enable_feature(Feature::zbkx, test(RISCV_HWPROBE_EXT_ZBKX));
|
| 249 |
+
enable_feature(Feature::zknd, test(RISCV_HWPROBE_EXT_ZKND));
|
| 250 |
+
enable_feature(Feature::zkne, test(RISCV_HWPROBE_EXT_ZKNE));
|
| 251 |
+
enable_feature(Feature::zknh, test(RISCV_HWPROBE_EXT_ZKNH));
|
| 252 |
+
enable_feature(Feature::zksed, test(RISCV_HWPROBE_EXT_ZKSED));
|
| 253 |
+
enable_feature(Feature::zksh, test(RISCV_HWPROBE_EXT_ZKSH));
|
| 254 |
+
enable_feature(Feature::zkt, test(RISCV_HWPROBE_EXT_ZKT));
|
| 255 |
+
|
| 256 |
+
enable_feature(Feature::zcmop, test(RISCV_HWPROBE_EXT_ZCMOP));
|
| 257 |
+
enable_feature(Feature::zca, test(RISCV_HWPROBE_EXT_ZCA));
|
| 258 |
+
enable_feature(Feature::zcf, test(RISCV_HWPROBE_EXT_ZCF));
|
| 259 |
+
enable_feature(Feature::zcd, test(RISCV_HWPROBE_EXT_ZCD));
|
| 260 |
+
enable_feature(Feature::zcb, test(RISCV_HWPROBE_EXT_ZCB));
|
| 261 |
+
|
| 262 |
+
enable_feature(Feature::zfh, test(RISCV_HWPROBE_EXT_ZFH));
|
| 263 |
+
enable_feature(Feature::zfhmin, test(RISCV_HWPROBE_EXT_ZFHMIN));
|
| 264 |
+
enable_feature(Feature::zfa, test(RISCV_HWPROBE_EXT_ZFA));
|
| 265 |
+
enable_feature(Feature::zfbfmin, test(RISCV_HWPROBE_EXT_ZFBFMIN));
|
| 266 |
+
|
| 267 |
+
// Use prctl (if any) to determine whether the vector extension
|
| 268 |
+
// is enabled on the current thread (assuming the entire process
|
| 269 |
+
// share the same status). If prctl fails (e.g. QEMU userland emulator
|
| 270 |
+
// as of version 9.2.3), use auxiliary vector to retrieve the default
|
| 271 |
+
// vector status on the process startup.
|
| 272 |
+
let has_vectors = {
|
| 273 |
+
let v_status = unsafe { libc::prctl(PR_RISCV_V_GET_CONTROL) };
|
| 274 |
+
if v_status >= 0 {
|
| 275 |
+
(v_status & PR_RISCV_V_VSTATE_CTRL_CUR_MASK) == PR_RISCV_V_VSTATE_CTRL_ON
|
| 276 |
+
} else {
|
| 277 |
+
has_v
|
| 278 |
+
}
|
| 279 |
+
};
|
| 280 |
+
if has_vectors {
|
| 281 |
+
enable_feature(Feature::v, test(RISCV_HWPROBE_IMA_V));
|
| 282 |
+
enable_feature(Feature::zve32x, test(RISCV_HWPROBE_EXT_ZVE32X));
|
| 283 |
+
enable_feature(Feature::zve32f, test(RISCV_HWPROBE_EXT_ZVE32F));
|
| 284 |
+
enable_feature(Feature::zve64x, test(RISCV_HWPROBE_EXT_ZVE64X));
|
| 285 |
+
enable_feature(Feature::zve64f, test(RISCV_HWPROBE_EXT_ZVE64F));
|
| 286 |
+
enable_feature(Feature::zve64d, test(RISCV_HWPROBE_EXT_ZVE64D));
|
| 287 |
+
|
| 288 |
+
enable_feature(Feature::zvbb, test(RISCV_HWPROBE_EXT_ZVBB));
|
| 289 |
+
enable_feature(Feature::zvbc, test(RISCV_HWPROBE_EXT_ZVBC));
|
| 290 |
+
enable_feature(Feature::zvkb, test(RISCV_HWPROBE_EXT_ZVKB));
|
| 291 |
+
enable_feature(Feature::zvkg, test(RISCV_HWPROBE_EXT_ZVKG));
|
| 292 |
+
enable_feature(Feature::zvkned, test(RISCV_HWPROBE_EXT_ZVKNED));
|
| 293 |
+
enable_feature(Feature::zvknha, test(RISCV_HWPROBE_EXT_ZVKNHA));
|
| 294 |
+
enable_feature(Feature::zvknhb, test(RISCV_HWPROBE_EXT_ZVKNHB));
|
| 295 |
+
enable_feature(Feature::zvksed, test(RISCV_HWPROBE_EXT_ZVKSED));
|
| 296 |
+
enable_feature(Feature::zvksh, test(RISCV_HWPROBE_EXT_ZVKSH));
|
| 297 |
+
enable_feature(Feature::zvkt, test(RISCV_HWPROBE_EXT_ZVKT));
|
| 298 |
+
|
| 299 |
+
enable_feature(Feature::zvfh, test(RISCV_HWPROBE_EXT_ZVFH));
|
| 300 |
+
enable_feature(Feature::zvfhmin, test(RISCV_HWPROBE_EXT_ZVFHMIN));
|
| 301 |
+
enable_feature(Feature::zvfbfmin, test(RISCV_HWPROBE_EXT_ZVFBFMIN));
|
| 302 |
+
enable_feature(Feature::zvfbfwma, test(RISCV_HWPROBE_EXT_ZVFBFWMA));
|
| 303 |
+
}
|
| 304 |
+
is_v_set = true;
|
| 305 |
+
};
|
| 306 |
+
|
| 307 |
+
// Set V purely depending on the auxiliary vector
|
| 308 |
+
// only if no fine-grained vector extension detection is available.
|
| 309 |
+
if !is_v_set {
|
| 310 |
+
enable_feature(Feature::v, has_v);
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
// Handle base ISA.
|
| 314 |
+
// If future RV128I is supported, implement with `enable_feature` here.
|
| 315 |
+
// Note that we should use `target_arch` instead of `target_pointer_width`
|
| 316 |
+
// to avoid misdetection caused by experimental ABIs such as RV64ILP32.
|
| 317 |
+
#[cfg(target_arch = "riscv64")]
|
| 318 |
+
enable_feature(Feature::rv64i, has_i);
|
| 319 |
+
#[cfg(target_arch = "riscv32")]
|
| 320 |
+
enable_feature(Feature::rv32i, has_i);
|
| 321 |
+
|
| 322 |
+
imply_features(value)
|
| 323 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/linux/s390x.rs
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for s390x on Linux.
|
| 2 |
+
|
| 3 |
+
use super::auxvec;
|
| 4 |
+
use crate::detect::{Feature, bit, cache};
|
| 5 |
+
|
| 6 |
+
/// Try to read the features from the auxiliary vector
|
| 7 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 8 |
+
let opt_hwcap: Option<AtHwcap> = auxvec::auxv().ok().map(Into::into);
|
| 9 |
+
let facilities = ExtendedFacilityList::new();
|
| 10 |
+
cache(opt_hwcap, facilities)
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
#[derive(Debug, Default, PartialEq)]
|
| 14 |
+
struct AtHwcap {
|
| 15 |
+
esan3: bool,
|
| 16 |
+
zarch: bool,
|
| 17 |
+
stfle: bool,
|
| 18 |
+
msa: bool,
|
| 19 |
+
ldisp: bool,
|
| 20 |
+
eimm: bool,
|
| 21 |
+
dfp: bool,
|
| 22 |
+
hpage: bool,
|
| 23 |
+
etf3eh: bool,
|
| 24 |
+
high_gprs: bool,
|
| 25 |
+
te: bool,
|
| 26 |
+
vxrs: bool,
|
| 27 |
+
vxrs_bcd: bool,
|
| 28 |
+
vxrs_ext: bool,
|
| 29 |
+
gs: bool,
|
| 30 |
+
vxrs_ext2: bool,
|
| 31 |
+
vxrs_pde: bool,
|
| 32 |
+
sort: bool,
|
| 33 |
+
dflt: bool,
|
| 34 |
+
vxrs_pde2: bool,
|
| 35 |
+
nnpa: bool,
|
| 36 |
+
pci_mio: bool,
|
| 37 |
+
sie: bool,
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
impl From<auxvec::AuxVec> for AtHwcap {
|
| 41 |
+
/// Reads AtHwcap from the auxiliary vector.
|
| 42 |
+
fn from(auxv: auxvec::AuxVec) -> Self {
|
| 43 |
+
AtHwcap {
|
| 44 |
+
esan3: bit::test(auxv.hwcap, 0),
|
| 45 |
+
zarch: bit::test(auxv.hwcap, 1),
|
| 46 |
+
stfle: bit::test(auxv.hwcap, 2),
|
| 47 |
+
msa: bit::test(auxv.hwcap, 3),
|
| 48 |
+
ldisp: bit::test(auxv.hwcap, 4),
|
| 49 |
+
eimm: bit::test(auxv.hwcap, 5),
|
| 50 |
+
dfp: bit::test(auxv.hwcap, 6),
|
| 51 |
+
hpage: bit::test(auxv.hwcap, 7),
|
| 52 |
+
etf3eh: bit::test(auxv.hwcap, 8),
|
| 53 |
+
high_gprs: bit::test(auxv.hwcap, 9),
|
| 54 |
+
te: bit::test(auxv.hwcap, 10),
|
| 55 |
+
vxrs: bit::test(auxv.hwcap, 11),
|
| 56 |
+
vxrs_bcd: bit::test(auxv.hwcap, 12),
|
| 57 |
+
vxrs_ext: bit::test(auxv.hwcap, 13),
|
| 58 |
+
gs: bit::test(auxv.hwcap, 14),
|
| 59 |
+
vxrs_ext2: bit::test(auxv.hwcap, 15),
|
| 60 |
+
vxrs_pde: bit::test(auxv.hwcap, 16),
|
| 61 |
+
sort: bit::test(auxv.hwcap, 17),
|
| 62 |
+
dflt: bit::test(auxv.hwcap, 18),
|
| 63 |
+
vxrs_pde2: bit::test(auxv.hwcap, 19),
|
| 64 |
+
nnpa: bit::test(auxv.hwcap, 20),
|
| 65 |
+
pci_mio: bit::test(auxv.hwcap, 21),
|
| 66 |
+
sie: bit::test(auxv.hwcap, 22),
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
struct ExtendedFacilityList([u64; 4]);
|
| 72 |
+
|
| 73 |
+
impl ExtendedFacilityList {
|
| 74 |
+
fn new() -> Self {
|
| 75 |
+
let mut result: [u64; 4] = [0; 4];
|
| 76 |
+
// SAFETY: rust/llvm only support s390x version with the `stfle` instruction.
|
| 77 |
+
unsafe {
|
| 78 |
+
core::arch::asm!(
|
| 79 |
+
// equivalently ".insn s, 0xb2b00000, 0({1})",
|
| 80 |
+
"stfle 0({})",
|
| 81 |
+
in(reg_addr) result.as_mut_ptr() ,
|
| 82 |
+
inout("r0") result.len() as u64 - 1 => _,
|
| 83 |
+
options(nostack)
|
| 84 |
+
);
|
| 85 |
+
}
|
| 86 |
+
Self(result)
|
| 87 |
+
}
|
| 88 |
+
|
| 89 |
+
const fn get_bit(&self, n: usize) -> bool {
|
| 90 |
+
// NOTE: bits are numbered from the left.
|
| 91 |
+
self.0[n / 64] & (1 << (63 - (n % 64))) != 0
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/// Initializes the cache from the feature bits.
|
| 96 |
+
///
|
| 97 |
+
/// These values are part of the platform-specific [asm/elf.h][kernel], and are a selection of the
|
| 98 |
+
/// fields found in the [Facility Indications].
|
| 99 |
+
///
|
| 100 |
+
/// [Facility Indications]: https://www.ibm.com/support/pages/sites/default/files/2021-05/SA22-7871-10.pdf#page=63
|
| 101 |
+
/// [kernel]: https://github.com/torvalds/linux/blob/b62cef9a5c673f1b8083159f5dc03c1c5daced2f/arch/s390/include/asm/elf.h#L129
|
| 102 |
+
fn cache(hwcap: Option<AtHwcap>, facilities: ExtendedFacilityList) -> cache::Initializer {
|
| 103 |
+
let mut value = cache::Initializer::default();
|
| 104 |
+
|
| 105 |
+
{
|
| 106 |
+
let mut enable_if_set = |bit_index, f| {
|
| 107 |
+
if facilities.get_bit(bit_index) {
|
| 108 |
+
value.set(f as u32);
|
| 109 |
+
}
|
| 110 |
+
};
|
| 111 |
+
|
| 112 |
+
// We use HWCAP for `vector` because it requires both hardware and kernel support.
|
| 113 |
+
if let Some(AtHwcap { vxrs: true, .. }) = hwcap {
|
| 114 |
+
// vector and related
|
| 115 |
+
|
| 116 |
+
enable_if_set(129, Feature::vector);
|
| 117 |
+
|
| 118 |
+
enable_if_set(135, Feature::vector_enhancements_1);
|
| 119 |
+
enable_if_set(148, Feature::vector_enhancements_2);
|
| 120 |
+
enable_if_set(198, Feature::vector_enhancements_3);
|
| 121 |
+
|
| 122 |
+
enable_if_set(134, Feature::vector_packed_decimal);
|
| 123 |
+
enable_if_set(152, Feature::vector_packed_decimal_enhancement);
|
| 124 |
+
enable_if_set(192, Feature::vector_packed_decimal_enhancement_2);
|
| 125 |
+
enable_if_set(199, Feature::vector_packed_decimal_enhancement_3);
|
| 126 |
+
|
| 127 |
+
enable_if_set(165, Feature::nnp_assist);
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
// others
|
| 131 |
+
|
| 132 |
+
enable_if_set(76, Feature::message_security_assist_extension3);
|
| 133 |
+
enable_if_set(77, Feature::message_security_assist_extension4);
|
| 134 |
+
enable_if_set(57, Feature::message_security_assist_extension5);
|
| 135 |
+
enable_if_set(146, Feature::message_security_assist_extension8);
|
| 136 |
+
enable_if_set(155, Feature::message_security_assist_extension9);
|
| 137 |
+
enable_if_set(86, Feature::message_security_assist_extension12);
|
| 138 |
+
|
| 139 |
+
enable_if_set(58, Feature::miscellaneous_extensions_2);
|
| 140 |
+
enable_if_set(61, Feature::miscellaneous_extensions_3);
|
| 141 |
+
enable_if_set(84, Feature::miscellaneous_extensions_4);
|
| 142 |
+
|
| 143 |
+
enable_if_set(45, Feature::high_word);
|
| 144 |
+
enable_if_set(73, Feature::transactional_execution);
|
| 145 |
+
enable_if_set(133, Feature::guarded_storage);
|
| 146 |
+
enable_if_set(150, Feature::enhanced_sort);
|
| 147 |
+
enable_if_set(151, Feature::deflate_conversion);
|
| 148 |
+
enable_if_set(201, Feature::concurrent_functions);
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
value
|
| 152 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/openbsd/aarch64.rs
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for Aarch64 on OpenBSD.
|
| 2 |
+
//!
|
| 3 |
+
//! OpenBSD doesn't trap the mrs instruction, but exposes the system registers through sysctl.
|
| 4 |
+
//! https://github.com/openbsd/src/commit/d335af936b9d7dd9cf655cae1ce19560c45de6c8
|
| 5 |
+
//! https://github.com/golang/go/commit/cd54ef1f61945459486e9eea2f016d99ef1da925
|
| 6 |
+
|
| 7 |
+
use core::mem::MaybeUninit;
|
| 8 |
+
use core::ptr;
|
| 9 |
+
|
| 10 |
+
use crate::detect::cache;
|
| 11 |
+
|
| 12 |
+
// Defined in machine/cpu.h.
|
| 13 |
+
// https://github.com/openbsd/src/blob/72ccc03bd11da614f31f7ff76e3f6fce99bc1c79/sys/arch/arm64/include/cpu.h#L25-L40
|
| 14 |
+
const CPU_ID_AA64ISAR0: libc::c_int = 2;
|
| 15 |
+
const CPU_ID_AA64ISAR1: libc::c_int = 3;
|
| 16 |
+
const CPU_ID_AA64MMFR2: libc::c_int = 7;
|
| 17 |
+
const CPU_ID_AA64PFR0: libc::c_int = 8;
|
| 18 |
+
|
| 19 |
+
/// Try to read the features from the system registers.
|
| 20 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 21 |
+
// ID_AA64ISAR0_EL1 and ID_AA64ISAR1_EL1 are supported on OpenBSD 7.1+.
|
| 22 |
+
// https://github.com/openbsd/src/commit/d335af936b9d7dd9cf655cae1ce19560c45de6c8
|
| 23 |
+
// Others are supported on OpenBSD 7.3+.
|
| 24 |
+
// https://github.com/openbsd/src/commit/c7654cd65262d532212f65123ee3905ba200365c
|
| 25 |
+
// sysctl returns an unsupported error if operation is not supported,
|
| 26 |
+
// so we can safely use this function on older versions of OpenBSD.
|
| 27 |
+
let aa64isar0 = sysctl64(&[libc::CTL_MACHDEP, CPU_ID_AA64ISAR0]).unwrap_or(0);
|
| 28 |
+
let aa64isar1 = sysctl64(&[libc::CTL_MACHDEP, CPU_ID_AA64ISAR1]).unwrap_or(0);
|
| 29 |
+
let aa64mmfr2 = sysctl64(&[libc::CTL_MACHDEP, CPU_ID_AA64MMFR2]).unwrap_or(0);
|
| 30 |
+
// Do not use unwrap_or(0) because in fp and asimd fields, 0 indicates that
|
| 31 |
+
// the feature is available.
|
| 32 |
+
let aa64pfr0 = sysctl64(&[libc::CTL_MACHDEP, CPU_ID_AA64PFR0]);
|
| 33 |
+
|
| 34 |
+
crate::detect::aarch64::parse_system_registers(aa64isar0, aa64isar1, aa64mmfr2, aa64pfr0)
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
#[inline]
|
| 38 |
+
fn sysctl64(mib: &[libc::c_int]) -> Option<u64> {
|
| 39 |
+
const OUT_LEN: libc::size_t = core::mem::size_of::<u64>();
|
| 40 |
+
let mut out = MaybeUninit::<u64>::uninit();
|
| 41 |
+
let mut out_len = OUT_LEN;
|
| 42 |
+
let res = unsafe {
|
| 43 |
+
libc::sysctl(
|
| 44 |
+
mib.as_ptr(),
|
| 45 |
+
mib.len() as libc::c_uint,
|
| 46 |
+
out.as_mut_ptr() as *mut libc::c_void,
|
| 47 |
+
&mut out_len,
|
| 48 |
+
ptr::null_mut(),
|
| 49 |
+
0,
|
| 50 |
+
)
|
| 51 |
+
};
|
| 52 |
+
if res == -1 || out_len != OUT_LEN {
|
| 53 |
+
return None;
|
| 54 |
+
}
|
| 55 |
+
// SAFETY: we've checked that sysctl was successful and `out` was filled.
|
| 56 |
+
Some(unsafe { out.assume_init() })
|
| 57 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/openbsd/auxvec.rs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Parses ELF auxiliary vectors.
|
| 2 |
+
#![cfg_attr(
|
| 3 |
+
any(target_arch = "aarch64", target_arch = "powerpc64", target_arch = "riscv64"),
|
| 4 |
+
allow(dead_code)
|
| 5 |
+
)]
|
| 6 |
+
|
| 7 |
+
/// Cache HWCAP bitfields of the ELF Auxiliary Vector.
|
| 8 |
+
///
|
| 9 |
+
/// If an entry cannot be read all the bits in the bitfield are set to zero.
|
| 10 |
+
/// This should be interpreted as all the features being disabled.
|
| 11 |
+
#[derive(Debug, Copy, Clone)]
|
| 12 |
+
pub(crate) struct AuxVec {
|
| 13 |
+
pub hwcap: usize,
|
| 14 |
+
pub hwcap2: usize,
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
/// ELF Auxiliary Vector
|
| 18 |
+
///
|
| 19 |
+
/// The auxiliary vector is a memory region in a running ELF program's stack
|
| 20 |
+
/// composed of (key: usize, value: usize) pairs.
|
| 21 |
+
///
|
| 22 |
+
/// The keys used in the aux vector are platform dependent. For OpenBSD, they are
|
| 23 |
+
/// defined in [machine/elf.h][elfh]. The hardware capabilities of a given CPU
|
| 24 |
+
/// can be queried with the `AT_HWCAP` and `AT_HWCAP2` keys.
|
| 25 |
+
///
|
| 26 |
+
/// Note that run-time feature detection is not invoked for features that can
|
| 27 |
+
/// be detected at compile-time.
|
| 28 |
+
///
|
| 29 |
+
/// [elf.h]: https://github.com/openbsd/src/blob/master/sys/arch/arm64/include/elf.h
|
| 30 |
+
/// [elf.h]: https://github.com/openbsd/src/blob/master/sys/arch/powerpc64/include/elf.h
|
| 31 |
+
pub(crate) fn auxv() -> Result<AuxVec, ()> {
|
| 32 |
+
let hwcap = archauxv(libc::AT_HWCAP);
|
| 33 |
+
let hwcap2 = archauxv(libc::AT_HWCAP2);
|
| 34 |
+
// Zero could indicate that no features were detected, but it's also used to
|
| 35 |
+
// indicate an error. In particular, on many platforms AT_HWCAP2 will be
|
| 36 |
+
// legitimately zero, since it contains the most recent feature flags.
|
| 37 |
+
if hwcap != 0 || hwcap2 != 0 {
|
| 38 |
+
return Ok(AuxVec { hwcap, hwcap2 });
|
| 39 |
+
}
|
| 40 |
+
Err(())
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
/// Tries to read the `key` from the auxiliary vector.
|
| 44 |
+
fn archauxv(key: libc::c_int) -> usize {
|
| 45 |
+
const OUT_LEN: libc::c_int = core::mem::size_of::<libc::c_ulong>() as libc::c_int;
|
| 46 |
+
let mut out: libc::c_ulong = 0;
|
| 47 |
+
unsafe {
|
| 48 |
+
let res =
|
| 49 |
+
libc::elf_aux_info(key, &mut out as *mut libc::c_ulong as *mut libc::c_void, OUT_LEN);
|
| 50 |
+
// If elf_aux_info fails, `out` will be left at zero (which is the proper default value).
|
| 51 |
+
debug_assert!(res == 0 || out == 0);
|
| 52 |
+
}
|
| 53 |
+
out as usize
|
| 54 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/openbsd/mod.rs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection on OpenBSD
|
| 2 |
+
|
| 3 |
+
mod auxvec;
|
| 4 |
+
|
| 5 |
+
cfg_select! {
|
| 6 |
+
target_arch = "aarch64" => {
|
| 7 |
+
mod aarch64;
|
| 8 |
+
pub(crate) use self::aarch64::detect_features;
|
| 9 |
+
}
|
| 10 |
+
target_arch = "powerpc64" => {
|
| 11 |
+
mod powerpc;
|
| 12 |
+
pub(crate) use self::powerpc::detect_features;
|
| 13 |
+
}
|
| 14 |
+
_ => {
|
| 15 |
+
use crate::detect::cache;
|
| 16 |
+
/// Performs run-time feature detection.
|
| 17 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 18 |
+
cache::Initializer::default()
|
| 19 |
+
}
|
| 20 |
+
}
|
| 21 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/openbsd/powerpc.rs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for PowerPC on OpenBSD.
|
| 2 |
+
|
| 3 |
+
use super::auxvec;
|
| 4 |
+
use crate::detect::{Feature, cache};
|
| 5 |
+
|
| 6 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 7 |
+
let mut value = cache::Initializer::default();
|
| 8 |
+
let enable_feature = |value: &mut cache::Initializer, f, enable| {
|
| 9 |
+
if enable {
|
| 10 |
+
value.set(f as u32);
|
| 11 |
+
}
|
| 12 |
+
};
|
| 13 |
+
|
| 14 |
+
if let Ok(auxv) = auxvec::auxv() {
|
| 15 |
+
enable_feature(&mut value, Feature::altivec, auxv.hwcap & 0x10000000 != 0);
|
| 16 |
+
enable_feature(&mut value, Feature::vsx, auxv.hwcap & 0x00000080 != 0);
|
| 17 |
+
enable_feature(&mut value, Feature::power8, auxv.hwcap2 & 0x80000000 != 0);
|
| 18 |
+
return value;
|
| 19 |
+
}
|
| 20 |
+
value
|
| 21 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/other.rs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Other operating systems
|
| 2 |
+
|
| 3 |
+
use crate::detect::cache;
|
| 4 |
+
|
| 5 |
+
#[allow(dead_code)]
|
| 6 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 7 |
+
cache::Initializer::default()
|
| 8 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/riscv.rs
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection utility for RISC-V.
|
| 2 |
+
//!
|
| 3 |
+
//! On RISC-V, full feature detection needs a help of one or more
|
| 4 |
+
//! feature detection mechanisms (usually provided by the operating system).
|
| 5 |
+
//!
|
| 6 |
+
//! RISC-V architecture defines many extensions and some have dependency to others.
|
| 7 |
+
//! More importantly, some of them cannot be enabled without resolving such
|
| 8 |
+
//! dependencies due to limited set of features that such mechanisms provide.
|
| 9 |
+
//!
|
| 10 |
+
//! This module provides an OS-independent utility to process such relations
|
| 11 |
+
//! between RISC-V extensions.
|
| 12 |
+
|
| 13 |
+
use crate::detect::{Feature, cache};
|
| 14 |
+
|
| 15 |
+
/// Imply features by the given set of enabled features.
|
| 16 |
+
///
|
| 17 |
+
/// Note that it does not perform any consistency checks including existence of
|
| 18 |
+
/// conflicting extensions and/or complicated requirements. Eliminating such
|
| 19 |
+
/// inconsistencies is the responsibility of the feature detection logic and
|
| 20 |
+
/// its provider(s).
|
| 21 |
+
pub(crate) fn imply_features(mut value: cache::Initializer) -> cache::Initializer {
|
| 22 |
+
loop {
|
| 23 |
+
// Check convergence of the feature flags later.
|
| 24 |
+
let prev = value;
|
| 25 |
+
|
| 26 |
+
// Expect that the optimizer turns repeated operations into
|
| 27 |
+
// a fewer number of bit-manipulation operations.
|
| 28 |
+
macro_rules! imply {
|
| 29 |
+
// Regular implication:
|
| 30 |
+
// A1 => (B1[, B2...]), A2 => (B1[, B2...]) and so on.
|
| 31 |
+
($($from: ident)|+ => $($to: ident)&+) => {
|
| 32 |
+
if [$(Feature::$from as u32),+].iter().any(|&x| value.test(x)) {
|
| 33 |
+
$(
|
| 34 |
+
value.set(Feature::$to as u32);
|
| 35 |
+
)+
|
| 36 |
+
}
|
| 37 |
+
};
|
| 38 |
+
// Implication with multiple requirements:
|
| 39 |
+
// A1 && A2 ... => (B1[, B2...]).
|
| 40 |
+
($($from: ident)&+ => $($to: ident)&+) => {
|
| 41 |
+
if [$(Feature::$from as u32),+].iter().all(|&x| value.test(x)) {
|
| 42 |
+
$(
|
| 43 |
+
value.set(Feature::$to as u32);
|
| 44 |
+
)+
|
| 45 |
+
}
|
| 46 |
+
};
|
| 47 |
+
}
|
| 48 |
+
macro_rules! group {
|
| 49 |
+
($group: ident == $($member: ident)&+) => {
|
| 50 |
+
// Forward implication as defined in the specifications.
|
| 51 |
+
imply!($group => $($member)&+);
|
| 52 |
+
// Reverse implication to "group extension" from its members.
|
| 53 |
+
// This is not a part of specifications but convenient for
|
| 54 |
+
// feature detection and implemented in e.g. LLVM.
|
| 55 |
+
imply!($($member)&+ => $group);
|
| 56 |
+
};
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
/*
|
| 60 |
+
If a dependency/implication is not explicitly stated in the
|
| 61 |
+
specification, it is denoted as a comment as follows:
|
| 62 |
+
"defined as subset":
|
| 63 |
+
The latter extension is described as a subset of the former
|
| 64 |
+
(but the evidence is weak).
|
| 65 |
+
"functional":
|
| 66 |
+
The former extension is functionally a superset of the latter
|
| 67 |
+
(no direct references though).
|
| 68 |
+
*/
|
| 69 |
+
|
| 70 |
+
imply!(zvbb => zvkb);
|
| 71 |
+
|
| 72 |
+
// Certain set of vector cryptography extensions form a group.
|
| 73 |
+
group!(zvkn == zvkned & zvknhb & zvkb & zvkt);
|
| 74 |
+
group!(zvknc == zvkn & zvbc);
|
| 75 |
+
group!(zvkng == zvkn & zvkg);
|
| 76 |
+
group!(zvks == zvksed & zvksh & zvkb & zvkt);
|
| 77 |
+
group!(zvksc == zvks & zvbc);
|
| 78 |
+
group!(zvksg == zvks & zvkg);
|
| 79 |
+
|
| 80 |
+
imply!(zvknhb => zvknha); // functional
|
| 81 |
+
|
| 82 |
+
// For vector cryptography, Zvknhb and Zvbc require integer arithmetic
|
| 83 |
+
// with EEW=64 (Zve64x) while others not depending on them
|
| 84 |
+
// require EEW=32 (Zve32x).
|
| 85 |
+
imply!(zvknhb | zvbc => zve64x);
|
| 86 |
+
imply!(zvbb | zvkb | zvkg | zvkned | zvknha | zvksed | zvksh => zve32x);
|
| 87 |
+
|
| 88 |
+
imply!(zbc => zbkc); // defined as subset
|
| 89 |
+
group!(zkn == zbkb & zbkc & zbkx & zkne & zknd & zknh);
|
| 90 |
+
group!(zks == zbkb & zbkc & zbkx & zksed & zksh);
|
| 91 |
+
group!(zk == zkn & zkr & zkt);
|
| 92 |
+
|
| 93 |
+
imply!(zabha | zacas => zaamo);
|
| 94 |
+
group!(a == zalrsc & zaamo);
|
| 95 |
+
|
| 96 |
+
group!(b == zba & zbb & zbs);
|
| 97 |
+
|
| 98 |
+
imply!(zcf => zca & f);
|
| 99 |
+
imply!(zcd => zca & d);
|
| 100 |
+
imply!(zcmop | zcb => zca);
|
| 101 |
+
|
| 102 |
+
imply!(zhinx => zhinxmin);
|
| 103 |
+
imply!(zdinx | zhinxmin => zfinx);
|
| 104 |
+
|
| 105 |
+
imply!(zvfh => zvfhmin); // functional
|
| 106 |
+
imply!(zvfh => zve32f & zfhmin);
|
| 107 |
+
imply!(zvfhmin => zve32f);
|
| 108 |
+
imply!(zvfbfwma => zvfbfmin & zfbfmin);
|
| 109 |
+
imply!(zvfbfmin => zve32f);
|
| 110 |
+
|
| 111 |
+
imply!(v => zve64d);
|
| 112 |
+
imply!(zve64d => zve64f & d);
|
| 113 |
+
imply!(zve64f => zve64x & zve32f);
|
| 114 |
+
imply!(zve64x => zve32x);
|
| 115 |
+
imply!(zve32f => zve32x & f);
|
| 116 |
+
|
| 117 |
+
imply!(zfh => zfhmin);
|
| 118 |
+
imply!(q => d);
|
| 119 |
+
imply!(d | zfhmin | zfa => f);
|
| 120 |
+
imply!(zfbfmin => f); // and some of (not all) "Zfh" instructions.
|
| 121 |
+
|
| 122 |
+
// Relatively complex implication rules around the "C" extension.
|
| 123 |
+
// (from "C" and some others)
|
| 124 |
+
imply!(c => zca);
|
| 125 |
+
imply!(c & d => zcd);
|
| 126 |
+
#[cfg(target_arch = "riscv32")]
|
| 127 |
+
imply!(c & f => zcf);
|
| 128 |
+
// (to "C"; defined as superset)
|
| 129 |
+
cfg_select! {
|
| 130 |
+
target_arch = "riscv32" => {
|
| 131 |
+
if value.test(Feature::d as u32) {
|
| 132 |
+
imply!(zcf & zcd => c);
|
| 133 |
+
} else if value.test(Feature::f as u32) {
|
| 134 |
+
imply!(zcf => c);
|
| 135 |
+
} else {
|
| 136 |
+
imply!(zca => c);
|
| 137 |
+
}
|
| 138 |
+
}
|
| 139 |
+
_ => {
|
| 140 |
+
if value.test(Feature::d as u32) {
|
| 141 |
+
imply!(zcd => c);
|
| 142 |
+
} else {
|
| 143 |
+
imply!(zca => c);
|
| 144 |
+
}
|
| 145 |
+
}
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
imply!(zicntr | zihpm | f | zfinx | zve32x => zicsr);
|
| 149 |
+
|
| 150 |
+
// Loop until the feature flags converge.
|
| 151 |
+
if prev == value {
|
| 152 |
+
return value;
|
| 153 |
+
}
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
+
#[cfg(test)]
|
| 158 |
+
#[path = "riscv/tests.rs"]
|
| 159 |
+
mod tests;
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/riscv/tests.rs
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use super::*;
|
| 2 |
+
|
| 3 |
+
#[test]
|
| 4 |
+
fn simple_direct() {
|
| 5 |
+
let mut value = cache::Initializer::default();
|
| 6 |
+
value.set(Feature::f as u32);
|
| 7 |
+
// F (and other extensions with CSRs) -> Zicsr
|
| 8 |
+
assert!(imply_features(value).test(Feature::zicsr as u32));
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
#[test]
|
| 12 |
+
fn simple_indirect() {
|
| 13 |
+
let mut value = cache::Initializer::default();
|
| 14 |
+
value.set(Feature::q as u32);
|
| 15 |
+
// Q -> D, D -> F, F -> Zicsr
|
| 16 |
+
assert!(imply_features(value).test(Feature::zicsr as u32));
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
#[test]
|
| 20 |
+
fn complex_zcd() {
|
| 21 |
+
let mut value = cache::Initializer::default();
|
| 22 |
+
// C & D -> Zcd
|
| 23 |
+
value.set(Feature::c as u32);
|
| 24 |
+
assert!(!imply_features(value).test(Feature::zcd as u32));
|
| 25 |
+
value.set(Feature::d as u32);
|
| 26 |
+
assert!(imply_features(value).test(Feature::zcd as u32));
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
#[test]
|
| 30 |
+
fn group_simple_forward() {
|
| 31 |
+
let mut value = cache::Initializer::default();
|
| 32 |
+
// A -> Zalrsc & Zaamo (forward implication)
|
| 33 |
+
value.set(Feature::a as u32);
|
| 34 |
+
let value = imply_features(value);
|
| 35 |
+
assert!(value.test(Feature::zalrsc as u32));
|
| 36 |
+
assert!(value.test(Feature::zaamo as u32));
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
#[test]
|
| 40 |
+
fn group_simple_backward() {
|
| 41 |
+
let mut value = cache::Initializer::default();
|
| 42 |
+
// Zalrsc & Zaamo -> A (reverse implication)
|
| 43 |
+
value.set(Feature::zalrsc as u32);
|
| 44 |
+
value.set(Feature::zaamo as u32);
|
| 45 |
+
assert!(imply_features(value).test(Feature::a as u32));
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
#[test]
|
| 49 |
+
fn group_complex_convergence() {
|
| 50 |
+
let mut value = cache::Initializer::default();
|
| 51 |
+
// Needs 3 iterations to converge
|
| 52 |
+
// (and 4th iteration for convergence checking):
|
| 53 |
+
// 1. [Zvksc] -> Zvks & Zvbc
|
| 54 |
+
// 2. Zvks -> Zvksed & Zvksh & Zvkb & Zvkt
|
| 55 |
+
// 3a. [Zvkned] & [Zvknhb] & [Zvkb] & Zvkt -> {Zvkn}
|
| 56 |
+
// 3b. Zvkn & Zvbc -> {Zvknc}
|
| 57 |
+
value.set(Feature::zvksc as u32);
|
| 58 |
+
value.set(Feature::zvkned as u32);
|
| 59 |
+
value.set(Feature::zvknhb as u32);
|
| 60 |
+
value.set(Feature::zvkb as u32);
|
| 61 |
+
let value = imply_features(value);
|
| 62 |
+
assert!(value.test(Feature::zvkn as u32));
|
| 63 |
+
assert!(value.test(Feature::zvknc as u32));
|
| 64 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/windows/aarch64.rs
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! Run-time feature detection for Aarch64 on Windows.
|
| 2 |
+
|
| 3 |
+
use crate::detect::{Feature, cache};
|
| 4 |
+
|
| 5 |
+
/// Try to read the features using IsProcessorFeaturePresent.
|
| 6 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 7 |
+
type DWORD = u32;
|
| 8 |
+
type BOOL = i32;
|
| 9 |
+
|
| 10 |
+
const FALSE: BOOL = 0;
|
| 11 |
+
// The following Microsoft documents isn't updated for aarch64.
|
| 12 |
+
// https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-isprocessorfeaturepresent
|
| 13 |
+
// These are defined in winnt.h of Windows SDK
|
| 14 |
+
const PF_ARM_VFP_32_REGISTERS_AVAILABLE: u32 = 18;
|
| 15 |
+
const PF_ARM_NEON_INSTRUCTIONS_AVAILABLE: u32 = 19;
|
| 16 |
+
const PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE: u32 = 30;
|
| 17 |
+
const PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE: u32 = 31;
|
| 18 |
+
const PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE: u32 = 34;
|
| 19 |
+
const PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE: u32 = 43;
|
| 20 |
+
const PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE: u32 = 44;
|
| 21 |
+
const PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE: u32 = 45;
|
| 22 |
+
const PF_ARM_SVE_INSTRUCTIONS_AVAILABLE: u32 = 46;
|
| 23 |
+
const PF_ARM_SVE2_INSTRUCTIONS_AVAILABLE: u32 = 47;
|
| 24 |
+
const PF_ARM_SVE2_1_INSTRUCTIONS_AVAILABLE: u32 = 48;
|
| 25 |
+
const PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE: u32 = 49;
|
| 26 |
+
const PF_ARM_SVE_PMULL128_INSTRUCTIONS_AVAILABLE: u32 = 50;
|
| 27 |
+
const PF_ARM_SVE_BITPERM_INSTRUCTIONS_AVAILABLE: u32 = 51;
|
| 28 |
+
// const PF_ARM_SVE_BF16_INSTRUCTIONS_AVAILABLE: u32 = 52;
|
| 29 |
+
// const PF_ARM_SVE_EBF16_INSTRUCTIONS_AVAILABLE: u32 = 53;
|
| 30 |
+
const PF_ARM_SVE_B16B16_INSTRUCTIONS_AVAILABLE: u32 = 54;
|
| 31 |
+
const PF_ARM_SVE_SHA3_INSTRUCTIONS_AVAILABLE: u32 = 55;
|
| 32 |
+
const PF_ARM_SVE_SM4_INSTRUCTIONS_AVAILABLE: u32 = 56;
|
| 33 |
+
// const PF_ARM_SVE_I8MM_INSTRUCTIONS_AVAILABLE: u32 = 57;
|
| 34 |
+
// const PF_ARM_SVE_F32MM_INSTRUCTIONS_AVAILABLE: u32 = 58;
|
| 35 |
+
// const PF_ARM_SVE_F64MM_INSTRUCTIONS_AVAILABLE: u32 = 59;
|
| 36 |
+
|
| 37 |
+
unsafe extern "system" {
|
| 38 |
+
fn IsProcessorFeaturePresent(ProcessorFeature: DWORD) -> BOOL;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
let mut value = cache::Initializer::default();
|
| 42 |
+
{
|
| 43 |
+
let mut enable_feature = |f, enable| {
|
| 44 |
+
if enable {
|
| 45 |
+
value.set(f as u32);
|
| 46 |
+
}
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
// Some features may be supported on current CPU,
|
| 50 |
+
// but no way to detect it by OS API.
|
| 51 |
+
// Also, we require unsafe block for the extern "system" calls.
|
| 52 |
+
unsafe {
|
| 53 |
+
enable_feature(
|
| 54 |
+
Feature::fp,
|
| 55 |
+
IsProcessorFeaturePresent(PF_ARM_VFP_32_REGISTERS_AVAILABLE) != FALSE,
|
| 56 |
+
);
|
| 57 |
+
enable_feature(
|
| 58 |
+
Feature::asimd,
|
| 59 |
+
IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 60 |
+
);
|
| 61 |
+
enable_feature(
|
| 62 |
+
Feature::crc,
|
| 63 |
+
IsProcessorFeaturePresent(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 64 |
+
);
|
| 65 |
+
enable_feature(
|
| 66 |
+
Feature::lse,
|
| 67 |
+
IsProcessorFeaturePresent(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 68 |
+
);
|
| 69 |
+
enable_feature(
|
| 70 |
+
Feature::dotprod,
|
| 71 |
+
IsProcessorFeaturePresent(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 72 |
+
);
|
| 73 |
+
enable_feature(
|
| 74 |
+
Feature::jsconv,
|
| 75 |
+
IsProcessorFeaturePresent(PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 76 |
+
);
|
| 77 |
+
enable_feature(
|
| 78 |
+
Feature::rcpc,
|
| 79 |
+
IsProcessorFeaturePresent(PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 80 |
+
);
|
| 81 |
+
enable_feature(
|
| 82 |
+
Feature::sve,
|
| 83 |
+
IsProcessorFeaturePresent(PF_ARM_SVE_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 84 |
+
);
|
| 85 |
+
enable_feature(
|
| 86 |
+
Feature::sve2,
|
| 87 |
+
IsProcessorFeaturePresent(PF_ARM_SVE2_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 88 |
+
);
|
| 89 |
+
enable_feature(
|
| 90 |
+
Feature::sve2p1,
|
| 91 |
+
IsProcessorFeaturePresent(PF_ARM_SVE2_1_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 92 |
+
);
|
| 93 |
+
enable_feature(
|
| 94 |
+
Feature::sve2_aes,
|
| 95 |
+
IsProcessorFeaturePresent(PF_ARM_SVE_AES_INSTRUCTIONS_AVAILABLE) != FALSE
|
| 96 |
+
&& IsProcessorFeaturePresent(PF_ARM_SVE_PMULL128_INSTRUCTIONS_AVAILABLE)
|
| 97 |
+
!= FALSE,
|
| 98 |
+
);
|
| 99 |
+
enable_feature(
|
| 100 |
+
Feature::sve2_bitperm,
|
| 101 |
+
IsProcessorFeaturePresent(PF_ARM_SVE_BITPERM_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 102 |
+
);
|
| 103 |
+
enable_feature(
|
| 104 |
+
Feature::sve_b16b16,
|
| 105 |
+
IsProcessorFeaturePresent(PF_ARM_SVE_B16B16_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 106 |
+
);
|
| 107 |
+
enable_feature(
|
| 108 |
+
Feature::sve2_sha3,
|
| 109 |
+
IsProcessorFeaturePresent(PF_ARM_SVE_SHA3_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 110 |
+
);
|
| 111 |
+
enable_feature(
|
| 112 |
+
Feature::sve2_sm4,
|
| 113 |
+
IsProcessorFeaturePresent(PF_ARM_SVE_SM4_INSTRUCTIONS_AVAILABLE) != FALSE,
|
| 114 |
+
);
|
| 115 |
+
// PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE means aes, sha1, sha2 and
|
| 116 |
+
// pmull support
|
| 117 |
+
let crypto =
|
| 118 |
+
IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE) != FALSE;
|
| 119 |
+
enable_feature(Feature::aes, crypto);
|
| 120 |
+
enable_feature(Feature::pmull, crypto);
|
| 121 |
+
enable_feature(Feature::sha2, crypto);
|
| 122 |
+
}
|
| 123 |
+
}
|
| 124 |
+
value
|
| 125 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/os/x86.rs
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
//! x86 run-time feature detection is OS independent.
|
| 2 |
+
|
| 3 |
+
#[cfg(target_arch = "x86")]
|
| 4 |
+
use core::arch::x86::*;
|
| 5 |
+
#[cfg(target_arch = "x86_64")]
|
| 6 |
+
use core::arch::x86_64::*;
|
| 7 |
+
use core::mem;
|
| 8 |
+
|
| 9 |
+
use crate::detect::{Feature, bit, cache};
|
| 10 |
+
|
| 11 |
+
/// Run-time feature detection on x86 works by using the CPUID instruction.
|
| 12 |
+
///
|
| 13 |
+
/// The [CPUID Wikipedia page][wiki_cpuid] contains
|
| 14 |
+
/// all the information about which flags to set to query which values, and in
|
| 15 |
+
/// which registers these are reported.
|
| 16 |
+
///
|
| 17 |
+
/// The definitive references are:
|
| 18 |
+
/// - [Intel 64 and IA-32 Architectures Software Developer's Manual Volume 2:
|
| 19 |
+
/// Instruction Set Reference, A-Z][intel64_ref].
|
| 20 |
+
/// - [AMD64 Architecture Programmer's Manual, Volume 3: General-Purpose and
|
| 21 |
+
/// System Instructions][amd64_ref].
|
| 22 |
+
///
|
| 23 |
+
/// [wiki_cpuid]: https://en.wikipedia.org/wiki/CPUID
|
| 24 |
+
/// [intel64_ref]: http://www.intel.de/content/dam/www/public/us/en/documents/manuals/64-ia-32-architectures-software-developer-instruction-set-reference-manual-325383.pdf
|
| 25 |
+
/// [amd64_ref]: http://support.amd.com/TechDocs/24594.pdf
|
| 26 |
+
#[allow(clippy::similar_names)]
|
| 27 |
+
pub(crate) fn detect_features() -> cache::Initializer {
|
| 28 |
+
let mut value = cache::Initializer::default();
|
| 29 |
+
|
| 30 |
+
if cfg!(target_env = "sgx") {
|
| 31 |
+
// doesn't support this because it is untrusted data
|
| 32 |
+
return value;
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
// Calling `__cpuid`/`__cpuid_count` from here on is safe because the CPU
|
| 36 |
+
// has `cpuid` support.
|
| 37 |
+
|
| 38 |
+
// 0. EAX = 0: Basic Information:
|
| 39 |
+
// - EAX returns the "Highest Function Parameter", that is, the maximum
|
| 40 |
+
// leaf value for subsequent calls of `cpuinfo` in range [0,
|
| 41 |
+
// 0x8000_0000]. - The vendor ID is stored in 12 u8 ascii chars,
|
| 42 |
+
// returned in EBX, EDX, and ECX (in that order):
|
| 43 |
+
let (max_basic_leaf, vendor_id) = {
|
| 44 |
+
let CpuidResult { eax: max_basic_leaf, ebx, ecx, edx } = __cpuid(0);
|
| 45 |
+
let vendor_id: [[u8; 4]; 3] = [ebx.to_ne_bytes(), edx.to_ne_bytes(), ecx.to_ne_bytes()];
|
| 46 |
+
let vendor_id: [u8; 12] = unsafe { mem::transmute(vendor_id) };
|
| 47 |
+
(max_basic_leaf, vendor_id)
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
if max_basic_leaf < 1 {
|
| 51 |
+
// Earlier Intel 486, CPUID not implemented
|
| 52 |
+
return value;
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
// EAX = 1, ECX = 0: Queries "Processor Info and Feature Bits";
|
| 56 |
+
// Contains information about most x86 features.
|
| 57 |
+
let CpuidResult { ecx: proc_info_ecx, edx: proc_info_edx, .. } = __cpuid(0x0000_0001_u32);
|
| 58 |
+
|
| 59 |
+
// EAX = 7: Queries "Extended Features";
|
| 60 |
+
// Contains information about bmi,bmi2, and avx2 support.
|
| 61 |
+
let (
|
| 62 |
+
extended_features_ebx,
|
| 63 |
+
extended_features_ecx,
|
| 64 |
+
extended_features_edx,
|
| 65 |
+
extended_features_eax_leaf_1,
|
| 66 |
+
extended_features_edx_leaf_1,
|
| 67 |
+
) = if max_basic_leaf >= 7 {
|
| 68 |
+
let CpuidResult { ebx, ecx, edx, .. } = __cpuid(0x0000_0007_u32);
|
| 69 |
+
let CpuidResult { eax: eax_1, edx: edx_1, .. } =
|
| 70 |
+
__cpuid_count(0x0000_0007_u32, 0x0000_0001_u32);
|
| 71 |
+
(ebx, ecx, edx, eax_1, edx_1)
|
| 72 |
+
} else {
|
| 73 |
+
(0, 0, 0, 0, 0) // CPUID does not support "Extended Features"
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
// EAX = 0x8000_0000, ECX = 0: Get Highest Extended Function Supported
|
| 77 |
+
// - EAX returns the max leaf value for extended information, that is,
|
| 78 |
+
// `cpuid` calls in range [0x8000_0000; u32::MAX]:
|
| 79 |
+
let CpuidResult { eax: extended_max_basic_leaf, .. } = __cpuid(0x8000_0000_u32);
|
| 80 |
+
|
| 81 |
+
// EAX = 0x8000_0001, ECX=0: Queries "Extended Processor Info and Feature
|
| 82 |
+
// Bits"
|
| 83 |
+
let extended_proc_info_ecx = if extended_max_basic_leaf >= 1 {
|
| 84 |
+
let CpuidResult { ecx, .. } = __cpuid(0x8000_0001_u32);
|
| 85 |
+
ecx
|
| 86 |
+
} else {
|
| 87 |
+
0
|
| 88 |
+
};
|
| 89 |
+
|
| 90 |
+
{
|
| 91 |
+
// borrows value till the end of this scope:
|
| 92 |
+
let mut enable = |r, rb, f| {
|
| 93 |
+
let present = bit::test(r as usize, rb);
|
| 94 |
+
if present {
|
| 95 |
+
value.set(f as u32);
|
| 96 |
+
}
|
| 97 |
+
present
|
| 98 |
+
};
|
| 99 |
+
|
| 100 |
+
enable(proc_info_ecx, 0, Feature::sse3);
|
| 101 |
+
enable(proc_info_ecx, 1, Feature::pclmulqdq);
|
| 102 |
+
enable(proc_info_ecx, 9, Feature::ssse3);
|
| 103 |
+
enable(proc_info_ecx, 13, Feature::cmpxchg16b);
|
| 104 |
+
enable(proc_info_ecx, 19, Feature::sse4_1);
|
| 105 |
+
enable(proc_info_ecx, 20, Feature::sse4_2);
|
| 106 |
+
enable(proc_info_ecx, 22, Feature::movbe);
|
| 107 |
+
enable(proc_info_ecx, 23, Feature::popcnt);
|
| 108 |
+
enable(proc_info_ecx, 25, Feature::aes);
|
| 109 |
+
let f16c = enable(proc_info_ecx, 29, Feature::f16c);
|
| 110 |
+
enable(proc_info_ecx, 30, Feature::rdrand);
|
| 111 |
+
enable(extended_features_ebx, 18, Feature::rdseed);
|
| 112 |
+
enable(extended_features_ebx, 19, Feature::adx);
|
| 113 |
+
enable(extended_features_ebx, 11, Feature::rtm);
|
| 114 |
+
enable(proc_info_edx, 4, Feature::tsc);
|
| 115 |
+
enable(proc_info_edx, 23, Feature::mmx);
|
| 116 |
+
enable(proc_info_edx, 24, Feature::fxsr);
|
| 117 |
+
enable(proc_info_edx, 25, Feature::sse);
|
| 118 |
+
enable(proc_info_edx, 26, Feature::sse2);
|
| 119 |
+
enable(extended_features_ebx, 29, Feature::sha);
|
| 120 |
+
|
| 121 |
+
enable(extended_features_ecx, 8, Feature::gfni);
|
| 122 |
+
enable(extended_features_ecx, 9, Feature::vaes);
|
| 123 |
+
enable(extended_features_ecx, 10, Feature::vpclmulqdq);
|
| 124 |
+
|
| 125 |
+
enable(extended_features_ebx, 3, Feature::bmi1);
|
| 126 |
+
enable(extended_features_ebx, 8, Feature::bmi2);
|
| 127 |
+
|
| 128 |
+
enable(extended_features_ebx, 9, Feature::ermsb);
|
| 129 |
+
|
| 130 |
+
enable(extended_features_eax_leaf_1, 31, Feature::movrs);
|
| 131 |
+
|
| 132 |
+
// Detect if CPUID.19h available
|
| 133 |
+
if bit::test(extended_features_ecx as usize, 23) {
|
| 134 |
+
let CpuidResult { ebx, .. } = __cpuid(0x19);
|
| 135 |
+
enable(ebx, 0, Feature::kl);
|
| 136 |
+
enable(ebx, 2, Feature::widekl);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
// This detects ABM on AMD CPUs and LZCNT on Intel CPUs.
|
| 140 |
+
// On intel CPUs with popcnt, lzcnt implements the
|
| 141 |
+
// "missing part" of ABM, so we map both to the same
|
| 142 |
+
// internal feature.
|
| 143 |
+
//
|
| 144 |
+
// The `is_x86_feature_detected!("lzcnt")` macro then
|
| 145 |
+
// internally maps to Feature::abm.
|
| 146 |
+
enable(extended_proc_info_ecx, 5, Feature::lzcnt);
|
| 147 |
+
|
| 148 |
+
// As Hygon Dhyana originates from AMD technology and shares most of the architecture with
|
| 149 |
+
// AMD's family 17h, but with different CPU Vendor ID("HygonGenuine")/Family series
|
| 150 |
+
// number(Family 18h).
|
| 151 |
+
//
|
| 152 |
+
// For CPUID feature bits, Hygon Dhyana(family 18h) share the same definition with AMD
|
| 153 |
+
// family 17h.
|
| 154 |
+
//
|
| 155 |
+
// Related AMD CPUID specification is https://www.amd.com/system/files/TechDocs/25481.pdf.
|
| 156 |
+
// Related Hygon kernel patch can be found on
|
| 157 |
+
// http://lkml.kernel.org/r/5ce86123a7b9dad925ac583d88d2f921040e859b.1538583282.git.puwen@hygon.cn
|
| 158 |
+
if vendor_id == *b"AuthenticAMD" || vendor_id == *b"HygonGenuine" {
|
| 159 |
+
// These features are available on AMD arch CPUs:
|
| 160 |
+
enable(extended_proc_info_ecx, 6, Feature::sse4a);
|
| 161 |
+
enable(extended_proc_info_ecx, 21, Feature::tbm);
|
| 162 |
+
enable(extended_proc_info_ecx, 11, Feature::xop);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
// `XSAVE` and `AVX` support:
|
| 166 |
+
let cpu_xsave = bit::test(proc_info_ecx as usize, 26);
|
| 167 |
+
if cpu_xsave {
|
| 168 |
+
// 0. Here the CPU supports `XSAVE`.
|
| 169 |
+
|
| 170 |
+
// 1. Detect `OSXSAVE`, that is, whether the OS is AVX enabled and
|
| 171 |
+
// supports saving the state of the AVX/AVX2 vector registers on
|
| 172 |
+
// context-switches, see:
|
| 173 |
+
//
|
| 174 |
+
// - [intel: is avx enabled?][is_avx_enabled],
|
| 175 |
+
// - [mozilla: sse.cpp][mozilla_sse_cpp].
|
| 176 |
+
//
|
| 177 |
+
// [is_avx_enabled]: https://software.intel.com/en-us/blogs/2011/04/14/is-avx-enabled
|
| 178 |
+
// [mozilla_sse_cpp]: https://hg.mozilla.org/mozilla-central/file/64bab5cbb9b6/mozglue/build/SSE.cpp#l190
|
| 179 |
+
let cpu_osxsave = bit::test(proc_info_ecx as usize, 27);
|
| 180 |
+
|
| 181 |
+
if cpu_osxsave {
|
| 182 |
+
// 2. The OS must have signaled the CPU that it supports saving and
|
| 183 |
+
// restoring the:
|
| 184 |
+
//
|
| 185 |
+
// * SSE -> `XCR0.SSE[1]`
|
| 186 |
+
// * AVX -> `XCR0.AVX[2]`
|
| 187 |
+
// * AVX-512 -> `XCR0.AVX-512[7:5]`.
|
| 188 |
+
// * AMX -> `XCR0.AMX[18:17]`
|
| 189 |
+
// * APX -> `XCR0.APX[19]`
|
| 190 |
+
//
|
| 191 |
+
// by setting the corresponding bits of `XCR0` to `1`.
|
| 192 |
+
//
|
| 193 |
+
// This is safe because the CPU supports `xsave`
|
| 194 |
+
// and the OS has set `osxsave`.
|
| 195 |
+
let xcr0 = unsafe { _xgetbv(0) };
|
| 196 |
+
// Test `XCR0.SSE[1]` and `XCR0.AVX[2]` with the mask `0b110 == 6`:
|
| 197 |
+
let os_avx_support = xcr0 & 6 == 6;
|
| 198 |
+
// Test `XCR0.AVX-512[7:5]` with the mask `0b1110_0000 == 0xe0`:
|
| 199 |
+
let os_avx512_support = xcr0 & 0xe0 == 0xe0;
|
| 200 |
+
// Test `XCR0.AMX[18:17]` with the mask `0b110_0000_0000_0000_0000 == 0x60000`
|
| 201 |
+
let os_amx_support = xcr0 & 0x60000 == 0x60000;
|
| 202 |
+
// Test `XCR0.APX[19]` with the mask `0b1000_0000_0000_0000_0000 == 0x80000`
|
| 203 |
+
let os_apx_support = xcr0 & 0x80000 == 0x80000;
|
| 204 |
+
|
| 205 |
+
// Only if the OS and the CPU support saving/restoring the AVX
|
| 206 |
+
// registers we enable `xsave` support:
|
| 207 |
+
if os_avx_support {
|
| 208 |
+
// See "13.3 ENABLING THE XSAVE FEATURE SET AND XSAVE-ENABLED
|
| 209 |
+
// FEATURES" in the "Intel® 64 and IA-32 Architectures Software
|
| 210 |
+
// Developer’s Manual, Volume 1: Basic Architecture":
|
| 211 |
+
//
|
| 212 |
+
// "Software enables the XSAVE feature set by setting
|
| 213 |
+
// CR4.OSXSAVE[bit 18] to 1 (e.g., with the MOV to CR4
|
| 214 |
+
// instruction). If this bit is 0, execution of any of XGETBV,
|
| 215 |
+
// XRSTOR, XRSTORS, XSAVE, XSAVEC, XSAVEOPT, XSAVES, and XSETBV
|
| 216 |
+
// causes an invalid-opcode exception (#UD)"
|
| 217 |
+
//
|
| 218 |
+
enable(proc_info_ecx, 26, Feature::xsave);
|
| 219 |
+
|
| 220 |
+
// For `xsaveopt`, `xsavec`, and `xsaves` we need to query:
|
| 221 |
+
// Processor Extended State Enumeration Sub-leaf (EAX = 0DH,
|
| 222 |
+
// ECX = 1):
|
| 223 |
+
if max_basic_leaf >= 0xd {
|
| 224 |
+
let CpuidResult { eax: proc_extended_state1_eax, .. } =
|
| 225 |
+
__cpuid_count(0xd_u32, 1);
|
| 226 |
+
enable(proc_extended_state1_eax, 0, Feature::xsaveopt);
|
| 227 |
+
enable(proc_extended_state1_eax, 1, Feature::xsavec);
|
| 228 |
+
enable(proc_extended_state1_eax, 3, Feature::xsaves);
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
// FMA (uses 256-bit wide registers):
|
| 232 |
+
let fma = enable(proc_info_ecx, 12, Feature::fma);
|
| 233 |
+
|
| 234 |
+
// And AVX/AVX2:
|
| 235 |
+
enable(proc_info_ecx, 28, Feature::avx);
|
| 236 |
+
enable(extended_features_ebx, 5, Feature::avx2);
|
| 237 |
+
|
| 238 |
+
// "Short" versions of AVX512 instructions
|
| 239 |
+
enable(extended_features_eax_leaf_1, 4, Feature::avxvnni);
|
| 240 |
+
enable(extended_features_eax_leaf_1, 23, Feature::avxifma);
|
| 241 |
+
enable(extended_features_edx_leaf_1, 4, Feature::avxvnniint8);
|
| 242 |
+
enable(extended_features_edx_leaf_1, 5, Feature::avxneconvert);
|
| 243 |
+
enable(extended_features_edx_leaf_1, 10, Feature::avxvnniint16);
|
| 244 |
+
|
| 245 |
+
enable(extended_features_eax_leaf_1, 0, Feature::sha512);
|
| 246 |
+
enable(extended_features_eax_leaf_1, 1, Feature::sm3);
|
| 247 |
+
enable(extended_features_eax_leaf_1, 2, Feature::sm4);
|
| 248 |
+
|
| 249 |
+
// For AVX-512 the OS also needs to support saving/restoring
|
| 250 |
+
// the extended state, only then we enable AVX-512 support:
|
| 251 |
+
// Also, Rust makes `avx512f` imply `fma` and `f16c`, because
|
| 252 |
+
// otherwise the assembler is broken. But Intel doesn't guarantee
|
| 253 |
+
// that `fma` and `f16c` are available with `avx512f`, so we
|
| 254 |
+
// need to check for them separately.
|
| 255 |
+
if os_avx512_support && f16c && fma {
|
| 256 |
+
enable(extended_features_ebx, 16, Feature::avx512f);
|
| 257 |
+
enable(extended_features_ebx, 17, Feature::avx512dq);
|
| 258 |
+
enable(extended_features_ebx, 21, Feature::avx512ifma);
|
| 259 |
+
enable(extended_features_ebx, 26, Feature::avx512pf);
|
| 260 |
+
enable(extended_features_ebx, 27, Feature::avx512er);
|
| 261 |
+
enable(extended_features_ebx, 28, Feature::avx512cd);
|
| 262 |
+
enable(extended_features_ebx, 30, Feature::avx512bw);
|
| 263 |
+
enable(extended_features_ebx, 31, Feature::avx512vl);
|
| 264 |
+
enable(extended_features_ecx, 1, Feature::avx512vbmi);
|
| 265 |
+
enable(extended_features_ecx, 6, Feature::avx512vbmi2);
|
| 266 |
+
enable(extended_features_ecx, 11, Feature::avx512vnni);
|
| 267 |
+
enable(extended_features_ecx, 12, Feature::avx512bitalg);
|
| 268 |
+
enable(extended_features_ecx, 14, Feature::avx512vpopcntdq);
|
| 269 |
+
enable(extended_features_edx, 8, Feature::avx512vp2intersect);
|
| 270 |
+
enable(extended_features_edx, 23, Feature::avx512fp16);
|
| 271 |
+
enable(extended_features_eax_leaf_1, 5, Feature::avx512bf16);
|
| 272 |
+
}
|
| 273 |
+
}
|
| 274 |
+
|
| 275 |
+
if os_amx_support {
|
| 276 |
+
enable(extended_features_edx, 24, Feature::amx_tile);
|
| 277 |
+
enable(extended_features_edx, 25, Feature::amx_int8);
|
| 278 |
+
enable(extended_features_edx, 22, Feature::amx_bf16);
|
| 279 |
+
enable(extended_features_eax_leaf_1, 21, Feature::amx_fp16);
|
| 280 |
+
enable(extended_features_edx_leaf_1, 8, Feature::amx_complex);
|
| 281 |
+
|
| 282 |
+
if max_basic_leaf >= 0x1e {
|
| 283 |
+
let CpuidResult { eax: amx_feature_flags_eax, .. } =
|
| 284 |
+
__cpuid_count(0x1e_u32, 1);
|
| 285 |
+
|
| 286 |
+
enable(amx_feature_flags_eax, 4, Feature::amx_fp8);
|
| 287 |
+
enable(amx_feature_flags_eax, 6, Feature::amx_tf32);
|
| 288 |
+
enable(amx_feature_flags_eax, 7, Feature::amx_avx512);
|
| 289 |
+
enable(amx_feature_flags_eax, 8, Feature::amx_movrs);
|
| 290 |
+
}
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
if os_apx_support {
|
| 294 |
+
enable(extended_features_edx_leaf_1, 21, Feature::apxf);
|
| 295 |
+
}
|
| 296 |
+
|
| 297 |
+
let avx10_1 = enable(extended_features_edx_leaf_1, 19, Feature::avx10_1);
|
| 298 |
+
if avx10_1 {
|
| 299 |
+
let CpuidResult { ebx, .. } = __cpuid(0x24);
|
| 300 |
+
let avx10_version = ebx & 0xff;
|
| 301 |
+
if avx10_version >= 2 {
|
| 302 |
+
value.set(Feature::avx10_2 as u32);
|
| 303 |
+
}
|
| 304 |
+
}
|
| 305 |
+
}
|
| 306 |
+
}
|
| 307 |
+
}
|
| 308 |
+
|
| 309 |
+
// Unfortunately, some Skylake chips erroneously report support for BMI1 and
|
| 310 |
+
// BMI2 without actual support. These chips don't support AVX, and it seems
|
| 311 |
+
// that all Intel chips with non-erroneous support BMI do (I didn't check
|
| 312 |
+
// other vendors), so we can disable these flags for chips that don't also
|
| 313 |
+
// report support for AVX.
|
| 314 |
+
//
|
| 315 |
+
// It's possible this will pessimize future chips that do support BMI and
|
| 316 |
+
// not AVX, but this seems minor compared to a hard crash you get when
|
| 317 |
+
// executing an unsupported instruction (to put it another way, it's safe
|
| 318 |
+
// for us to under-report CPU features, but not to over-report them). Still,
|
| 319 |
+
// to limit any impact this may have in the future, we only do this for
|
| 320 |
+
// Intel chips, as it's a bug only present in their chips.
|
| 321 |
+
//
|
| 322 |
+
// This bug is documented as `SKL052` in the errata section of this document:
|
| 323 |
+
// http://www.intel.com/content/dam/www/public/us/en/documents/specification-updates/desktop-6th-gen-core-family-spec-update.pdf
|
| 324 |
+
if vendor_id == *b"GenuineIntel" && !value.test(Feature::avx as u32) {
|
| 325 |
+
value.unset(Feature::bmi1 as u32);
|
| 326 |
+
value.unset(Feature::bmi2 as u32);
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
value
|
| 330 |
+
}
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-artificial-aarch64.auxv
ADDED
|
Binary file (336 Bytes). View file
|
|
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-empty-hwcap2-aarch64.auxv
ADDED
|
Binary file (336 Bytes). View file
|
|
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-hwcap2-aarch64.auxv
ADDED
|
Binary file (336 Bytes). View file
|
|
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-no-hwcap2-aarch64.auxv
ADDED
|
Binary file (320 Bytes). View file
|
|
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/linux-rpi3.auxv
ADDED
|
Binary file (160 Bytes). View file
|
|
|
rust/.rustup/toolchains/stable-x86_64-pc-windows-msvc/lib/rustlib/src/rust/library/std_detect/src/detect/test_data/macos-virtualbox-linux-x86-4850HQ.auxv
ADDED
|
Binary file (160 Bytes). View file
|
|
|