Skip to content

loongarch: Mark partial intrinsics as safe #1874

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

heiher
Copy link
Contributor

@heiher heiher commented Jul 15, 2025

No description provided.

@rustbot
Copy link
Collaborator

rustbot commented Jul 15, 2025

r? @folkertdev

rustbot has assigned @folkertdev.
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

Copy link
Contributor

@folkertdev folkertdev left a comment

Choose a reason for hiding this comment

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

Overall this looks good, I added some nits and questions inline

Comment on lines +126 to +128
unsafe {
__dbar(IMM15);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this would save 2 lines

Suggested change
unsafe {
__dbar(IMM15);
}
unsafe { __dbar(IMM15) };

Comment on lines 21 to 22
let val: i32;
let tid: isize;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this would also work

Suggested change
let val: i32;
let tid: isize;
let (val, tid): (i32, isize);

Comment on lines +460 to +463
format!(
"pub {}fn {current_name}{fn_inputs} {fn_output}",
if is_mem { "unsafe " } else { "" }
)
Copy link
Contributor

@folkertdev folkertdev Jul 16, 2025

Choose a reason for hiding this comment

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

I understand this as a heuristic, but is it truly the case that only pointer reads/writes cause unsafety for these intrinsics?

__lasx_xvslei_b(a, IMM_S5)
pub fn lasx_xvslei_b<const IMM_S5: i32>(a: v32i8) -> v32i8 {
unsafe {
static_assert_simm_bits!(IMM_S5, 5);
Copy link
Contributor

Choose a reason for hiding this comment

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

can the assert be lifted out of the unsafe block?

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