about summary refs log tree commit diff
path: root/library/stdarch/crates/std_detect
AgeCommit message (Collapse)AuthorLines
2025-03-26std_detect: Move cfgs into getauxval helper functionTaiki Endo-94/+35
2025-03-26std_detect: Always avoid dlsym on *-linux-{musl,ohos}* targetsTaiki Endo-11/+28
2025-03-24tentatively remove the "B" RISC-V extension from the documentationTsukasa OI-1/+1
Although the "B" extension is redefined and ratified, keeping this in the documentation as-is have two issues: * "B" extension is not added to `riscv.rs` yet (to be added later). * "B" extension is ratified as a combination of "Zba", "Zbb" and "Zbs" extensions and "Zbc" is *not* a part of "B" itself (despite that it is listed under "B"), which makes the documentation misleading. This commit tentatively removes the reference to the "B" extension and replaced with "Bit Manipulation Extensions" without an extension name.
2025-03-24reword RISC-V feature documentationTsukasa OI-43/+43
As the version 20240411 of the RISC-V ISA Manual changed wording to describe many of the standard extensions, this commit largely follows this scheme in general. In many cases, words "Standard Extension" are replaced with "Extension" following the latest ratified ISA Manual. Some RISC-V extensions had tentative summary but it also fixes that (e.g. "Zihintpause"). Following extensions are described in parity with corresponding extensions using floating-point registers: * "Zfinx" Extension for Single-Precision Floating-Point in Integer Registers * "Zdinx" Extension for Double-Precision Floating-Point in Integer Registers * "Zhinx" Extension for Half-Precision Floating-Point in Integer Registers * "Zhinxmin" Extension for Minimal Half-Precision Floating-Point in Integer Registers Following extensions are named against the ISA Manual naming but considered inconsistency inside the ISA manual: * "Zfhmin" Extension for Minimal Half-Precision Floating-Point ISA Manual: "Zfhmin" Standard Extension for Minimal Half-Precision Floating-Point * "V" Extension for Vector Operations ISA Manual: "V" Standard Extension for Vector Operations Following extension is removed from the latest ratified ISA Manual but named like others: * "Zam" Extension for Misaligned Atomics "Zb*" extensions are described like "Extension for ..." using partial summary per extension (including cryptography-related "Zbk*" extensions). "Zk*" extensions are described like "Cryptography Extension for ..." using partial summary per extension (e.g. 'Zkne - NIST Suite: AES Encryption' in the ISA Manual to '"Zkne" Cryptography Extension for NIST Suite: AES Encryption') except following extensions: * "Zkr" Entropy Source Extension Following the general rule will make the description redundant. * "Zk" Cryptography Extension for Standard scalar cryptography The last word "extension" is removed as seemed redundant. Link: <https://lf-riscv.atlassian.net/wiki/spaces/HOME/pages/16154769/RISC-V+Technical+Specifications> (ISA Specifications, Version 20240411; published in May 2024)
2025-03-24reorder all RISC-V features for maintenanceTsukasa OI-51/+59
All RISC-V Features are reordered for better maintainability. The author has a plan to add many RISC-V ratified extensions (mainly discoverable from Linux) and this is a part of preparation. Sections are divided as follows: * Base ISAs * "I"-related * Extensions formerly a part of the base "I" extension but divided later (now all of them are ratified). * Other user-mode extensions "Zi*". * "M"-related (currently "M" only) * "A"-related "A", "Za*" and "Ztso" which is named differently but absolutely related to memory operations. * Base FP extensions * Base FP extensions using integer registers * "C"-related (currently "C" only) * "B"-related (except cryptography-related "Zbk*") * Scalar cryptography extensions (including "Zbk*") * Base Vector extensions (currently "V" only) * Ratified privileged extensions * Non-extensions and non-ratified extensions which is *not* going to be ratified, at least in the draft form The last section needs some explanation. "S" is not an extension (although some buggy implementations such as QEMU up to 7.0 emitted this character as well as "U" as an extension) and the DeviceTree parser in the Linux kernel explicitly workarounds this issue. There's no plan for ratification of the single-letter "J" extension (there's a room for redefinition like the "B" extension but unlikely). Instead, pointer masking extensions including "Supm" is one of the results of the task group discussing J extension*s*. There's also an instruction in the "Zfa" extension which accelerates FP-to-int conversion matching JavaScript semantics. "P" is being actively discussed (and will result in a single-letter "P" extension and various "Zp*" extensions) but it seems there needs some time until ratification. And there's one Rust-specific issue: Rust implements Packed-SIMD intrinsics based on an early draft of the "P" extension and they are *very unlikely* kept as-is. For instance, `add16` does not follow standard RISC-V instruction naming (ADD16 is the name from the Andes' proposal) and going to be renamed. Before moving "P" to above, we have to clearly understand what the final "P" extension will be and resolve existing intrinsics.
2025-03-24resolve `clippy::doc_lazy_continuation`Tsukasa OI-3/+3
This commit adds indentation as suggested by the Clippy warning.
2025-03-24silence `clippy::eq_op` while checkingTsukasa OI-0/+1
This error occurs when the RISC-V "A" Extension is being tested.
2025-03-24std_detect: Support detecting more features on AArch64 WindowsTaiki Endo-1/+49
2025-03-24Temporary fix: change the feature gate of VEX variantssayantn-5/+5
2025-03-20std_detect: Add target features for LoongArch v1.1WANG Rui-0/+28
2025-03-20Fix: stabilized version of RISC-V feature macroTsukasa OI-21/+21
RISC-V runtime feature detection macro is stabilized on Rust 1.78.0, not Rust 1.76.0.
2025-02-25Remove some `allow(unsafe_op_in_unsafe_fn)`s and use target_feature 1.1 in ↵Eduardo Sánchez Muñoz-1/+0
examples
2025-02-23add newly-added s390x features to `is_s390x_feature_detected`Folkert de Vries-0/+70
2025-02-13Add runtime feature detection for keylockersayantn-1/+17
2025-02-09Format with style edition 2024Eric Huss-13/+13
2025-02-09Update all crates to Rust 2024Eric Huss-1/+1
2025-02-09Allow unsafe_op_in_unsafe_fnEric Huss-0/+1
Because stdarch has a really large number of unsafe functions with single-line calls, `unsafe_op_in_unsafe_fn` would end up adding a lot of noise, so for now we will allow it to migrate to 2024.
2025-02-09Apply missing_unsafe_on_externEric Huss-2/+2
2025-02-07Move all x86 std_detect tests to `x86-specific.rs` to reduce duplicationsayantn-91/+15
2025-01-16add `is_s390x_feature_detected`Folkert de Vries-15/+158
2024-12-23Expand feature detection on AArch64 DarwinLaine Taffin Altman-38/+84
This reflects the currently available set of sysctl values as of macOS 15, on 2024-12-21. Features not (yet) exposed by `is_aarch64_feature_detected` have been left in comments to document their existence for the future.
2024-11-30Fix the `features` macro.Nicholas Nethercote-1/+1
The first rule of the `features` macro looks like this: ``` macro_rules! features { ( @TARGET: $target:ident; @CFG: $cfg:meta; @MACRO_NAME: $macro_name:ident; @MACRO_ATTRS: $(#[$macro_attrs:meta])* $(@BIND_FEATURE_NAME: $bind_feature:tt; $feature_impl:tt; $(#[$deprecate_attr:meta];)?)* $(@NO_RUNTIME_DETECTION: $nort_feature:tt; )* $(@FEATURE: #[$stability_attr:meta] $feature:ident: $feature_lit:tt; $(without cfg check: $feature_cfg_check:literal;)? $(implied by target_features: [$($target_feature_lit:tt),*];)? $(#[$feature_comment:meta])*)* ) => { ``` Notice all the `tt` specifiers. They are used because they are forwarded to another macro. Only `ident`, `lifetime`, and `tt` specifiers can be forwarded this way. But there is an exception: `$feature_lit:tt`, which was added recently. In theory it should cause an error like this: ``` error: no rules expected `literal` metavariable --> /home/njn/dev/rust3/library/stdarch/crates/std_detect/src/detect/macros.rs:54:91 | 51 | / macro_rules! $macro_name { 52 | | $( 53 | | ($feature_lit) => { 54 | | $crate::detect_feature!($feature, $feature_lit $(, without cfg check: $feature_cfg_check)? ... | | ^^^^^^^^^^^^^^^^^^ no rules expected this token in macro call ... | 88 | | }; 89 | | } | |_________- in this expansion of `is_x86_feature_detected!` | ::: std/tests/run-time-detect.rs:145:27 | 145 | println!("tsc: {:?}", is_x86_feature_detected!("tsc")); | ------------------------------- in this macro invocation | note: while trying to match keyword `true` --> /home/njn/dev/rust3/library/stdarch/crates/std_detect/src/detect/macros.rs:12:55 | 12 | ($feature:tt, $feature_lit:tt, without cfg check: true) => { | ^^^^ = note: captured metavariables except for `:tt`, `:ident` and `:lifetime` cannot be compared to other tokens = note: see <https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment> for more information ``` (The URL at the end of the error has more details about this forwarding limitation.) In practice it doesn't cause this error. I'm not sure why, but the existing macro implementation in rustc is far from perfect, so it's believable that it does the wrong thing here. Why does this matter? Because https://github.com/rust-lang/rust/pull/124141 is modifying the macro implementation, and when that PR is applied the error *does* occur. (It's one of several cases I have found where the existing compiler accepts code it shouldn't, but #124141 causes that code to be rejected.) Fortunately the fix is simple: replace the `literal` specifier with `tt`.
2024-11-30Enable `without cfg check` test in `std_detect`Urgau-3/+2
2024-11-08Add compile-time tests against unexpected target features cfgsUrgau-0/+24
2024-11-08Mark feature with missing corresponding target feature cfgs as suchUrgau-0/+27
Computed by diffing of: $ rg "[ ]+@FEATURE: .*: \"(.*)\";" -r '$1' --no-filename \ crates/std_detect/src/detect/ | sort | uniq With (from the main Rust repo[^1]): $ rg "target_feature" tests/ui/check-cfg/well-known-values.stderr [^1]: https://github.com/rust-lang/rust/blob/e8c698bb3bdc121ac7f65919bd16d22f6567a3f1/tests/ui/check-cfg/well-known-values.stderr#L177
2024-11-08Add ability to declare a feature without cfg checkingUrgau-1/+5
This is necessary to avoid `unexpected_cfgs` warnings for unexpected/ missing target features, in user code.
2024-10-27std_detect: Add pauth-lr aarch64 target featureKajetan Puchalski-0/+8
Add feature detection for aarch64 FEAT_PAuth_LR. There is currently no Linux cpuinfo support so the OS-specific lines are commented out.
2024-09-30Minor lintingYuri Astrakhan-1/+1
2024-09-18std_detect: Add sme-b16b16 as an explicit aarch64 target featureKajetan Puchalski-7/+11
LLVM 20 split out what used to be called b16b16 and correspond to aarch64 FEAT_SVE_B16B16 into sve-b16b16 and sme-b16b16. Add sme-b16b16 as an explicit feature and update the detection accordingly.
2024-09-18Use C string literalTaiki Endo-40/+39
2024-09-18std_detect: Fix link in mips.rsTaiki Endo-1/+1
2024-09-18std_detect: Use elf_aux_info on FreeBSDTaiki Endo-60/+27
2024-09-14Enable feature detection on all Apple/Darwin targetsMads Marquart-5/+7
Tested in the simulator and on the device I had lying around, a 1st generation iPad Mini (which isn't Aarch64, but shows that the `sysctlbyname` calls still work even there, even if they return false). `sysctlbyname` _should_ be safe to use without causing rejections from the app store, as its usage is documented in: https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics Also, the standard library will use these soon anyhow, so this shouldn't affect the situation: https://github.com/rust-lang/rust/pull/129019
2024-07-25std_detect: Update aarch64 feature dependencies to LLVM upstreamKajetan Puchalski-26/+29
Feature dependencies for newer aarch64 fetaures differ between LLVM 18 in the Rust tree and upstream LLVM 19. This commit updates those dependencies to reflect new LLVM upstream changes.
2024-07-25std_detect: Sort aarch64 featuresKajetan Puchalski-153/+153
Alphabetically sort the list of aarch64 features. The list was getting a bit too chaotic so it was worth properly sorting.
2024-07-25std_detect: Add aarch64/linux/LLVM SME featuresKajetan Puchalski-0/+137
Add detection for SME features supported by LLVM and the Linux Kernel. Include commented-out hwcap fields for features supported by Linux but not by LLVM. This commit adds feature detection for the following features: - FEAT_SME - FEAT_SME_F16F16 - FEAT_SME_F64F64 - FEAT_SME_F8F16 - FEAT_SME_F8F32 - FEAT_SME_FA64 - FEAT_SME_I16I64 - FEAT_SME_LUTv2 - FEAT_SME2 - FEAT_SME2p1 - FEAT_SSVE_FP8DOT2 - FEAT_SSVE_FP8DOT4 - FEAT_SSVE_FP8FMA Linux features: https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/hwcap.h LLVM features: llvm-project/llvm/lib/Target/AArch64/AArch64.td
2024-07-25std_detect: Add aarch64/linux/LLVM featuresKajetan Puchalski-9/+190
Add detection for various aarch64 CPU features already supported by LLVM and Linux. This commit adds feature detection for the following features: - FEAT_CSSC - FEAT_ECV - FEAT_FAMINMAX - FEAT_FLAGM2 - FEAT_FP8 - FEAT_FP8DOT2 - FEAT_FP8DOT4 - FEAT_FP8FMA - FEAT_HBC - FEAT_LSE128 - FEAT_LUT - FEAT_MOPS - FEAT_LRCPC3 - FEAT_SVE_B16B16 - FEAT_SVE2p1 - FEAT_WFxT It also adds feature detection for FEAT_FPMR. It is somewhat of a special case because FPMR only exists as a feature in LLVM 18, it has been removed from the LLVM upstream. On that account the intention is for it to be detectable at runtime through stdarch but not have a corresponding compile-time Rust target feature. Linux features: https://github.com/torvalds/linux/blob/master/arch/arm64/include/uapi/asm/hwcap.h LLVM features: llvm-project/llvm/lib/Target/AArch64/AArch64.td
2024-07-06Implemented runtime detection of `xop` target-featuresayantn-2/+8
2024-07-06Added runtime detectionsayantn-20/+61
Cannot do a `cupid` test because they don't support `amx`.
2024-07-06Add detection for SHA512, SM3 and SM4sayantn-1/+24
Cannot cross-verify with `cupid` because they do not have these features yet.
2024-06-29Remove `has_cpuid`Jubilee Young-7/+2
2024-06-23Added runtime detectionsayantn-21/+67
Expanded the cache size to 93 (we will need this in near future) Fixed detection of VAES, GFNI and VPCLMULQDQ Could not test with `cupid` because they do not support these yet
2024-05-07Remove libc dependency on Windows by using Win32 to get env varsDaniel Paoliello-9/+34
2024-04-22Don't depend on libc for cfg(windows)Ben Kimock-1/+3
2024-03-13arm64ecDaniel Paoliello-4/+11
2024-03-07std_detect: loongarch: Add runtime detectable features from LLVMWANG Rui-4/+45
* f * d * frecipe * lbt
2024-03-07std_detect: loongarch: Remove features not supported by LLVMWANG Rui-32/+0
2024-03-05check sub-leaf to detect avx512bf16Mingzhuo Yin-7/+7
Signed-off-by: Mingzhuo Yin <yinmingzhuo@gmail.com>
2024-03-05fix: invalid bit for detecting avx512 featureMingzhuo Yin-9/+15
Signed-off-by: Mingzhuo Yin <yinmingzhuo@gmail.com>
2024-02-24feat: std_detect avx512fp16usamoi-6/+13
Signed-off-by: usamoi <usamoi@outlook.com>