2353 Commits

Author SHA1 Message Date
sayantn
b3a7ba4607 Change test skipping logic a little, separate feature-based and function-based skipping 2025-04-20 21:39:39 +00:00
sayantn
cc6855e1e9 Remove cupid dependency and env-override-no-avx CI run 2025-04-20 21:39:39 +00:00
sayantn
f6fbd665a0 Add PowerPC64 to CI 2025-04-20 21:39:39 +00:00
sayantn
6cc17153d9 Re-enable all conditionally-disabled x86 assert_instr tests 2025-04-20 21:39:39 +00:00
sayantn
c10b7f8a26 Upgrade CI OS versions
+ Bump ubuntu to 25.04, windows to `windows-2025`, macos-arm to `macos-15` and macos-x86 to `macos-15-large`
2025-04-20 21:39:39 +00:00
Taiki Endo
4621641a49 std_detect: Remove /proc/cpuinfo-based detection 2025-04-20 14:38:01 +00:00
arshitas
9abc26fb85 Remove impl_tag from CONTRIBUTING.md file 2025-04-18 06:15:48 +00:00
bendn
3dd82b698f allow unnecessary transmutes 2025-04-17 18:27:37 +00:00
Folkert de Vries
c899659c44 add vec_extract, vec_insert, vec_promote and vec_insert_and_zero 2025-04-17 17:06:09 +00:00
sayantn
e804386587 Change void* type for gather/scatter intrinsics 2025-04-17 13:59:07 +00:00
sayantn
d6b0426127 Change void* type for cvt_storeu intrinsics 2025-04-17 13:59:07 +00:00
sayantn
376c3f33c5 Change void* type for compressstore intrinsics 2025-04-17 13:59:07 +00:00
sayantn
b10a6817d9 Change void* type for 3 intrinsics
- `_mm512_load_si512`
 - `_mm512_loadu_si512`
 - `_mm512_stream_si512`
2025-04-17 13:59:07 +00:00
sayantn
ccf36667b0 Add checks for void pointer types to ensure consistency 2025-04-17 13:59:07 +00:00
Taiki Endo
8f30830d97 Revert "std_detect: Do not use libc::getauxval on 32-bit Android"
This reverts commit 85572dc298f5222902c9b200cebf5d045e769a83.
2025-04-16 19:43:08 +00:00
Tsukasa OI
2d2390ea39 std_detect: Remove RV32E support attempt on Linux (RISC-V)
Because the current lowest requirements to run the Linux kernel on RISC-V is
RV{32,64}IMA (with 32 general purpose registers) plus some features,
RV32E (with only 16 GPRs) is not currently supported.

Since it's not sure whether current implemented method will work for future
Linux versions even if the minimum requirements are lowered, the support for
RV32E (to be more specific, an attempt to do that) is removed for now.
2025-04-16 18:30:32 +00:00
Tsukasa OI
ceaeba1760 RISC-V: Remove privileged extensions for now
Until in-kernel feature detection is implemented, runtime detection of
privileged extensions is temporally removed along with features themselves
since none of such privileged features are stable.

Co-Authored-By: Taiki Endo <te316e89@gmail.com>
Co-Authored-By: Amanieu d'Antras <amanieu@gmail.com>
2025-04-16 00:56:48 +00:00
Tsukasa OI
d5baf4da91 RISC-V: riscv_hwprobe-based feature detection on Linux / Android
This commit implements `riscv_hwprobe`-based feature detection as available
on newer versions of the Linux kernel.  It also queries whether the vector
extensions are enabled using `prctl` but this is not supported on QEMU's
userland emulator (as of version 9.2.3) and use the auxiliary vector
as a fallback.

Currently, all extensions discoverable from the Linux kernel version 6.14
and related extension groups (except "Supm", which reports the existence of
`prctl`-based pointer masking control and too OS-dependent) are implemented.

Co-Authored-By: Taiki Endo <te316e89@gmail.com>
2025-04-16 00:56:48 +00:00
Tsukasa OI
db188b33b3 RISC-V: OS-independent implication logic
This commit adds the OS-independent extension implication logic for RISC-V.
It implements:

1.  Regular implication (A → B)
    a.  "the extension A implies the extension B"
    b.  "the extension A requires the extension B"
    c.  "the extension A depends on the extension B"
2.  Extension group or shorthand (A == B1 & B2...)
    a.  "the extension A is shorthand for other extensions: B1, B2..."
    b.  "the extension A comprises instructions provided by B1, B2..."
    This is implemented as (A → B1 & B2... + B1 & B2... → A)
    where the former is a regular implication as required by specifications
    and the latter is a "reverse" implication to improve usability.

and prepares for:

3.  Implication with multiple requirements (A1 & A2... → B)
    a.  "A1 + A2 implies B"
    b.  (implicitly used to implement reverse implication of case 2)

Although it uses macros and iterators, good optimizers turn the series of
implications into fast bit-manipulation operations.

In the case 2 (extension group or shorthand; where a superset extension
is just a collection of other subextensions and provides no features by
a superset itself), specifications do specify that an extension group
implies its members but not vice versa.  However, implying an extension
group from its members would improve usability on the feature detection
(especially when the feature provider does not provide existence of such
extension group but provides existence of its members).

Similar "reverse implication" on RISC-V is implemented on LLVM.

Case 3 is implicitly used to implement reverse implication of case 2 but
there's another use case: implication with multiple requirements like
"Zcf" and "Zcd" extensions (not yet implemented in this crate for now).

To handle extension groups perfectly, we need to loop implication several
times (until they converge; normally 2 times and up to 4 times when we add
most of `riscv_hwprobe`-based features).
To make implementation of that loop possible, `cache::Initializer` is
modified to implement `PartialEq` and `Eq`.
2025-04-16 00:56:48 +00:00
Tsukasa OI
de643c040d RISC-V: Add RISC-V + Linux / Android test
This is ported from Taiki Endo's branch and sorted by the `@FEATURE` order
as in `src/detect/arch/riscv.rs`.

Co-Authored-By: Taiki Endo <te316e89@gmail.com>
2025-04-16 00:56:48 +00:00
Tsukasa OI
ed2d3ee924 RISC-V: Add placeholder for the "B" extension
The "B" extension is once abandoned (instead, it is ratified as a collection
of "Zb*" extensions).  However, it is later redefined and ratified as a
superset of "Zba", "Zbb" and "Zbs" extensions (but not "Zbc" carry-less
multiplication for limited benefits and implementation cost).

Although non-functional (because feature detection is not yet implemented),
it provides the foundation to implement this extension (along with
straightforward documentation showing subsets of "B").
2025-04-16 00:56:48 +00:00
Tsukasa OI
68c54c19be RISC-V: Add two "A" extension subsets
The "A" extension comprises instructions provided by the "Zaamo" and
"Zalrsc" extensions.  To prepare for the "Zacas" extension (which provides
compare-and-swap instructions and discoverable from Linux) which depends on
the "Zaamo" extension, it would be better to support those subsets.
2025-04-16 00:56:48 +00:00
Tsukasa OI
53e89494b3 RISC-V: Use target_arch for RV(32|64) detection
As Taiki Endo pointed out, there's a problem if we continue using
`target_pointer_width` values to detect an architecture because:

*   There are separate `target_arch`s already and
*   There is an experimental ABI (not ratified though): RV64ILP32.
    cf. <https://lpc.events/event/17/contributions/1475/attachments/1186/2442/rv64ilp32_%20Run%20ILP32%20on%20RV64%20ISA.pdf>

Co-Authored-By: Taiki Endo <te316e89@gmail.com>
2025-04-16 00:56:48 +00:00
Tsukasa OI
2759545fda RISC-V: Remove enable_features
This commit prepares common infrastructure for extension implication by
removing `enable_features` closure which makes each feature test longer
(because it needs extra `value` argument each time we test a feature).

It comes with the overhead to enable each feature separately but later
mitigated by the OS-independent extension implication logic.
2025-04-16 00:56:48 +00:00
Tsukasa OI
5c0c7ac77c RISC-V: tidying: Make auxvec-based enablement a block
Because this function will be no longer auxvec-only, this commit adds a
comment to mark auxvec-based part.

It *does not* add a comment to "base ISA" part because it may also use
`riscv_hwprobe`-based results.
2025-04-16 00:56:48 +00:00
Tsukasa OI
e35bc48a60 RISC-V: tidying: Handling of base ISA
This commit makes handling of the base ISA a separate block.

Co-Authored-By: Taiki Endo <te316e89@gmail.com>
2025-04-16 00:56:48 +00:00
Tsukasa OI
c36e9de178 RISC-V: tidying: Prefer more canonical reference
1.  Use canonical kernel.org repository instead of the GitHub mirror.
2.  Refer to the fixed commit to guarantee access.
3.  Use `uapi` part to ensure that the feature detection is primarily
    intended for user-mode programs.
2025-04-16 00:56:48 +00:00
Tsukasa OI
0b0c0e47f8 RISC-V: tidying: Fix separation of I-related extensions
The author intended to split:

1.  Former "I" extensions
2.  Other "I"-related extensions

but incorrectly separated between "Zihpm" (a supplement of "Zicntr" which is
a former "I" extension) and "Zifencei" (a former "I" extension) while the
author intended making a separation between "Zifencei" and "Zihintpause"
(not a part of "I").

This commit fixes the separation.
2025-04-12 07:51:56 +00:00
Tsukasa OI
217fdb9d89 RISC-V: doc: tidying: Move link to the ISA Manual
Not only moving the link to the end of the section, this commit changes
the link so that we can reach to the *ratified* ISA manuals (note that,
while the original URL (GitHub) is a good place to browse the latest
draft, it's not easy to know which is the ratified version; even
"Releases" page is not helpful since it's regularly updated).
2025-04-12 07:51:56 +00:00
Tsukasa OI
333882ada3 RISC-V: doc: Updated status and clarification
Some extensions are ratified at least on the ISA specification version
20240411.  This commit moves such extensions.

This commit also changes that:

1.  Lower indentation of "Zk*" and "Zbk*" extensions to avoid extension
    groups from being misleading inside this section.
2.  Raise indentation of "Zfhmin" and "Zhinxmin" extensions to show that
    they are a strict subset of "Zfh" and "Zhinx" (respectively).
3.  Clarify that "s" is not an extension but a feature notifying
    the existence of the supervisor-level ISA.
4.  Clarify that "h" is not just an existence of the hypervisor-level ISA
    but is also an extension name ("H").
2025-04-12 07:51:56 +00:00
Tsukasa OI
897188c1d0 RISC-V: doc: Capitalize some words for consistency
RISC-V extension names are capitalized for consistency.
2025-04-12 07:51:56 +00:00
bendn
2f742148e1 hmm 2025-04-11 11:30:32 +00:00
bendn
b5046525d5 fix broken intra doc links 2025-04-11 11:30:32 +00:00
sayantn
a721b3ec29 Disable cfg check for the recently-merged target features to allow stdarch update 2025-04-10 11:47:18 +00:00
sayantn
fbd13bd08c Add feature detection for new amx variants and movrs 2025-04-07 21:29:15 +00:00
sayantn
97606212ea Update SDE to 9.53.0 2025-04-07 21:29:15 +00:00
Tsukasa OI
6e4ad9cc18 RISC-V: check cfg (batch 1)
rust-lang/rust#138823 added five new extensions as compiler target features.
This commit reflects that fact and now checks static target features on
`std::arch::is_riscv_feature_detected!` as well.

*   "Zicsr"
*   "Zicntr"
*   "Zihpm"
*   "Zifencei"
*   "Zihintpause"
2025-04-06 13:27:52 +00:00
bendn
3ea2e5600f allow unnecessary transmutes 2025-03-27 21:36:07 +00:00
Taiki Endo
5b9cdf26df std_detect: Move cfgs into getauxval helper function 2025-03-26 13:55:33 +00:00
Taiki Endo
0965a880c2 std_detect: Always avoid dlsym on *-linux-{musl,ohos}* targets 2025-03-26 13:55:33 +00:00
Folkert de Vries
9c8f736849 make documentation headers consistent
this now always uses the name as specified by the official docs
2025-03-26 13:50:38 +00:00
Folkert de Vries
69a7cb8be3 add s390x to the module docs 2025-03-26 13:50:38 +00:00
James Barford-Evans
2099eccb2e pr feedback - remove the commented out vcombine_f16 2025-03-25 10:53:54 +00:00
James Barford-Evans
08b9752ee1 refactor - arm_shared intrinsics are now YAML, where possible use anchor
tags
2025-03-25 10:53:54 +00:00
Tsukasa OI
55fbe86255 tentatively remove the "B" RISC-V extension from the documentation
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-24 23:47:00 +00:00
Tsukasa OI
1c6d764b0b reword RISC-V feature documentation
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-24 23:47:00 +00:00
Tsukasa OI
14fc81b85f reorder all RISC-V features for maintenance
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-24 23:47:00 +00:00
Tsukasa OI
5feb3c989e resolve clippy::doc_lazy_continuation
This commit adds indentation as suggested by the Clippy warning.
2025-03-24 23:27:46 +00:00
Tsukasa OI
be20f62a20 silence clippy::eq_op while checking
This error occurs when the RISC-V "A" Extension is being tested.
2025-03-24 23:27:31 +00:00
Vadim Petrochenkov
ebe8804680 sse42: Add unsafe blocks around unsafe function calls
to fix the `unsafe_op_in_unsafe_fn` lint
2025-03-24 23:26:29 +00:00