Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented rdrand and rdseed intrinsics #326

Merged
merged 4 commits into from
Feb 27, 2018

Conversation

newpavlov
Copy link
Contributor

Fixes: #325
Depends on rust-lang/rust#48369.

fn x86_rdseed16_step() -> (u16, i32);
fn x86_rdseed32_step() -> (u32, i32);
fn x86_rdseed64_step() -> (u64, i32);
}
Copy link
Member

Choose a reason for hiding this comment

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

We don't use platform-intrinsic in this crate. Can you link to the LLVM intrinsics directly?

Copy link
Contributor Author

@newpavlov newpavlov Feb 21, 2018

Choose a reason for hiding this comment

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

No, as was discussed in the issue LLVM type {I<width>, i32} can not be currently represented by Rust.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that means we want to start using platform-intrinsics here.

We should probably wait for @alexcrichton to review this and help decide how to proceed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

He suggested to use asm! block as a temporary solution, so I think platform-intrinsics will be an ok temporary solution as well.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah the platform intrinsic ABI here is the way to go for now. This may change in the future, but we can always just update the crate!

In any case this PR looks good to me, just waiting on the rust-lang/rust PR!

@alexcrichton
Copy link
Member

@newpavlov there's a failure on CI related to the verification of intrinsics, but I think it's benign and mostly just means there's a missing case here. Mind fixing that in this PR as well?

@newpavlov
Copy link
Contributor Author

@alexcrichton
Done!

@alexcrichton
Copy link
Member

Ok! I reran the builds with the new nightly, but it looks like there may be some errors?

@newpavlov
Copy link
Contributor Author

Not sure how to debug this error:

LLVM ERROR: Cannot select: 0x13893f8f0: ch = store<ST4[%9]> 0x13893fb60, 0x13893f208:1, 0x13893f068, undef:i32
  0x13893f068: i32 = add nuw FrameIndex:i32<0>, Constant:i32<8>
    0x13893f958: i32 = FrameIndex<0>
    0x13893f3a8: i32 = Constant<8>
  0x13893f680: i32 = undef
In function: _ZN8coresimd8coresimd3x864i6866rdrand14_rdrand64_step17hd58a2bbfbca06dcdE

Maybe it's a bug in the current nigthly? Can you please try to restart test for master and see if it will pass tests?

@alexcrichton
Copy link
Member

Looks like rdrand64 is only available on x86_64 targets

@alexcrichton
Copy link
Member

Oh I think it's just rdrand64, the other functions should be available on x86

@alexcrichton alexcrichton merged commit dacb3c2 into rust-lang:master Feb 27, 2018
@alexcrichton
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants