184 Commits

Author SHA1 Message Date
Kajetan Puchalski
485ded6369 std_detect: Add sme-b16b16 as an explicit aarch64 target feature
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-18 12:48:54 -04:00
Taiki Endo
24b5e3c99e Use C string literal 2024-09-18 05:58:40 -04:00
Taiki Endo
9e5b3f5c8c std_detect: Fix link in mips.rs 2024-09-18 05:30:10 -04:00
Taiki Endo
720973b1b4 std_detect: Use elf_aux_info on FreeBSD 2024-09-18 05:07:32 -04:00
Mads Marquart
8a511191a0 Enable feature detection on all Apple/Darwin targets
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-09-14 04:25:01 +01:00
Kajetan Puchalski
351ec5744c std_detect: Update aarch64 feature dependencies to LLVM upstream
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-25 15:18:37 +01:00
Kajetan Puchalski
41dc17d3e5 std_detect: Sort aarch64 features
Alphabetically sort the list of aarch64 features.
The list was getting a bit too chaotic so it was worth properly
sorting.
2024-07-25 15:18:37 +01:00
Kajetan Puchalski
ef538bc614 std_detect: Add aarch64/linux/LLVM SME features
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-25 15:18:37 +01:00
Kajetan Puchalski
dfc5dfc8ef std_detect: Add aarch64/linux/LLVM features
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-25 15:18:37 +01:00
sayantn
94153c46e9 Implemented runtime detection of xop target-feature 2024-07-06 18:55:26 +02:00
sayantn
d67ca1fe09 Added runtime detection
Cannot do a `cupid` test because they don't support `amx`.
2024-07-06 18:28:25 +02:00
sayantn
268ac7fe92 Add detection for SHA512, SM3 and SM4
Cannot cross-verify with `cupid` because they do not have these features yet.
2024-07-06 11:29:28 +02:00
Jubilee Young
8b77e779cb Remove has_cpuid 2024-06-29 19:38:42 +02:00
sayantn
1f779b7b40 Added runtime detection
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-06-23 10:36:46 +02:00
Daniel Paoliello
130bc86694 Remove libc dependency on Windows by using Win32 to get env vars 2024-05-07 20:50:51 +02:00
Ben Kimock
2a21235f7a Don't depend on libc for cfg(windows) 2024-04-22 01:24:03 +02:00
Daniel Paoliello
a00a70eacb arm64ec 2024-03-13 22:30:36 +00:00
WANG Rui
1fbe4dddec std_detect: loongarch: Add runtime detectable features from LLVM
* f
* d
* frecipe
* lbt
2024-03-07 23:00:39 +00:00
WANG Rui
5fd2d04ef7 std_detect: loongarch: Remove features not supported by LLVM 2024-03-07 23:00:39 +00:00
Mingzhuo Yin
012e4ce580 check sub-leaf to detect avx512bf16
Signed-off-by: Mingzhuo Yin <yinmingzhuo@gmail.com>
2024-03-05 23:16:09 +00:00
Mingzhuo Yin
210913f1c4 fix: invalid bit for detecting avx512 feature
Signed-off-by: Mingzhuo Yin <yinmingzhuo@gmail.com>
2024-03-05 23:16:09 +00:00
usamoi
8531e289b0 feat: std_detect avx512fp16
Signed-off-by: usamoi <usamoi@outlook.com>
2024-02-24 16:07:04 +00:00
Adam Gemmell
e54a6d71bf Improve feature detect for combined aarch64 features
LLVM's `ssbs` and `mte` target_features represent two Arm features.
Linux's HWCAP also represents the same two features, so this is just a
documentation update.

LLVM's `ras` target_feature represents two Arm features - FEAT_RAS and FEAT_RASv1p1. There is no runtime detection for this, so this is a no-op in stdarch.

LLVM's `aes` feature covers both `FEAT_AES` and `FEAT_PMULL`, but Linux
exposes seperate feature bits. This patch makes the `aes` target_feature
correctly shortcut runtime `pmull` detection and also makes the `aes`
feature check for `pmull` at runtime to bring it in line with the
target_feature behaviour. In practice I think this makes the two runtime
features identical since the ID_AA64ISAR0_EL1 register does not allow
for PMULL without AES.
2024-02-16 18:21:34 +00:00
daxpedda
1e8274d34d Remove last mention of stdsimd 2024-02-14 15:08:29 +00:00
Makoto Kato
d51ea0d261 Add CPU detection for macOS/aarch64. 2024-01-16 02:57:10 +00:00
Amanieu d'Antras
76d52cdd68 Fix std_detect not being an unstable crate
More fallout from #1486
2024-01-05 11:14:38 +00:00
Amanieu d'Antras
fd973c2765 Fix std build failure on non-x86 architectures
This is more fallout from #1486
2024-01-04 13:00:34 +00:00
Amanieu d'Antras
a600c72f50 Fixes for use in the standard library 2024-01-02 17:46:10 +00:00
Amanieu d'Antras
b5406fedd4 Add #![allow(internal_features)] to a test to fix CI 2023-12-19 01:25:56 +00:00
Gijs Burghoorn
786f28dd8b Stabilize Ratified RISC-V Target Features
As shortly discussed on Zulip
(https://rust-lang.zulipchat.com/#narrow/stream/250483-t-compiler.2Frisc-v/topic/Stabilization.20of.20RISC-V.20Target.20Features/near/394793704), this commit stabilizes the ratified RISC-V instruction bases and extensions.

Specifically, this commit stabilizes the:
* Atomic Instructions (A) on v2.0
* Compressed Instructions (C) on v2.0
* Integer Multiplication and Division (M) on v2.0
* Bit Manipulations (B) on v1.0 listed as `zba`, `zbc`, `zbs`
* Scalar Cryptography (Zk) v1.0.1 listed as `zk`, `zkn`, `zknd`, `zkne`, `zknh`, `zkr`, `zks`, `zksed`, `zksh`, `zkt`, `zbkb`, `zbkc` `zkbx`
2023-11-30 22:53:04 +00:00
ZHAI Xiang
5625c8bf49 std_detect: Add support for LoongArch
Co-authored-by: WANG Rui <wangrui@loongson.cn>
2023-10-31 14:37:10 +01:00
Eduardo Sánchez Muñoz
eaa7298694 Derive Default for Initializer in std_detect 2023-10-31 02:20:17 +01:00
Eduardo Sánchez Muñoz
4bfd9935f7 Simplify a cfg 2023-10-31 02:20:17 +01:00
Eduardo Sánchez Muñoz
936583f12c Do not deny clippy::missing_inline_in_public_items in std_detect 2023-10-31 02:20:17 +01:00
Amanieu d'Antras
ea27e5cfcb Fix various compilation errors 2023-10-29 20:39:50 +01:00
Amanieu d'Antras
3e5850284a Fix more missing/incorrect feature specifications 2023-10-29 20:39:50 +01:00
Amanieu d'Antras
b8ba57f310 Cleanup last uses of the stdsimd feature 2023-10-29 20:39:50 +01:00
Amanieu d'Antras
21599975ff Add tracking issues for feature detection 2023-10-29 20:39:50 +01:00
Eduardo Sánchez Muñoz
b2c5bc9696 Remove unneeded transmutes
(or replace them with safe versions)
2023-10-11 18:11:51 +02:00
bjorn3
6f33e9c36b Remove use of auv crate from tests 2023-10-10 14:38:20 +01:00
bjorn3
d1df958a32 Remove the auxv dev dependency.
It hasn't been used since roughly 2018. The latest published version of
auxv has a less common license and doesn't specify any license in it's
Cargo.toml file.
2023-10-10 14:38:20 +01:00
Amanieu d'Antras
5161de5da4 Add #![allow(internal_unstable)]
This is required to avoid build failures when using rustc features
intended only for use by the standard library.
2023-08-29 15:21:34 +02:00
Jacob Bramley
a9fecd8456 Support AArch32 Neon dotprod intrinsics.
Note that the feature detection requires a recent Linux kernel (v6.2).
2023-06-21 18:52:21 +02:00
Taiki Endo
38c1a16190 std_detect: Do not use libc::getauxval on 32-bit Android
libc crate currently doesn't provide it.
2023-04-24 12:50:27 -07:00
Urgau
5d4192a9d6 Remove useless drop (clippy drop_ref and drop_copy lint) 2023-04-21 06:41:55 -07:00
Taiki Endo
221eb88986 std_detect: Remove support for arm crypto target feature 2023-04-01 18:42:27 +01:00
Taiki Endo
1661f06cd0 std_detect: Always avoid dlsym on *-android* targets 2023-04-01 18:41:20 +01:00
Luca Barbato
0af4d8a307 std_detect: Unbreak auxv_from_file
Discovered on powerpc64 where it crashes since it has more entries.
2023-03-25 00:33:58 +01:00
Nilstrieb
e41918d76c Allow internal_features 2023-03-19 21:31:00 +01:00
Chase Wilson
1f0116fea9 Implemented is_x86_feature_detected!(ermsb) 2023-03-12 20:20:06 +01:00