Skip to content

add ACLE random number generation intrinsics#2050

Open
folkertdev wants to merge 3 commits intorust-lang:mainfrom
folkertdev:aarch64-rand
Open

add ACLE random number generation intrinsics#2050
folkertdev wants to merge 3 commits intorust-lang:mainfrom
folkertdev:aarch64-rand

Conversation

@folkertdev
Copy link
Contributor

tracking issue: rust-lang/rust#153514

@folkertdev
Copy link
Contributor Author

cc @adamgemmell to check that this makes sense.

Internally the feature appears to be called rng, but LLVM uses rand as the target feature name. The rand target feature is already stable, it just looks like the intrinsics for it were never added.

@folkertdev folkertdev marked this pull request as ready for review March 6, 2026 20:47
@rustbot
Copy link
Collaborator

rustbot commented Mar 6, 2026

r? @sayantn

rustbot has assigned @sayantn.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @Amanieu, @folkertdev, @sayantn
  • @Amanieu, @folkertdev, @sayantn expanded to Amanieu, folkertdev, sayantn
  • Random selection from Amanieu, sayantn

Copy link
Contributor

@sayantn sayantn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly lgtm, just some nits

View changes since this review


unsafe extern "unadjusted" {
#[cfg_attr(
any(target_arch = "aarch64", target_arch = "arm64ec"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need these cfg_attrs here, as this is the aarch64 module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. I based this off of mte.rs so I've removed the cfg_attrs there too.

/// is returned.
#[inline]
#[target_feature(enable = "rand")]
#[unstable(feature = "stdarch_aarch64_rand", issue = "153514")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to have some assert_instrs if possible

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

those are in the test module below. Unfortunately that tests only the instruction, not the arguments, so the coverage is kind of limited.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can have them as inline assert_instrs right? Does stdarch-verify check for existence of tests for these functions? In that case we should disable the checks as we do for rdrand in x86

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I guess mte.rs is just very dated. These files are ignored for stdarch-verify below

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants