-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add missing rotates for cranelift #11723
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,42 @@ macro_rules! isle_common_prelude_methods { | |
self.checked_add_with_type(ty, a, b).is_none() | ||
} | ||
|
||
#[inline] | ||
fn imm64_rotl(&mut self, ty: Type, x: Imm64, k: Imm64) -> Imm64 { | ||
let bw: u32 = ty.bits().min(64); | ||
let amt: u32 = if bw == 0 { 0 } else { (k.bits() as u32) % bw }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's ok to not test for 0 here because a 0-size integral type should cause a panic (which |
||
|
||
let xv = x.bits() as u64; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd recommend using |
||
let v = match bw { | ||
8 => (xv as u8).rotate_left(amt) as u64, | ||
16 => (xv as u16).rotate_left(amt) as u64, | ||
32 => (xv as u32).rotate_left(amt) as u64, | ||
Comment on lines
+37
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For promotion back up to u64 I'd recommend using |
||
64 => xv.rotate_left(amt), | ||
_ => xv, | ||
}; | ||
|
||
let masked = v & self.ty_mask(ty); | ||
Imm64::new(masked as i64) | ||
} | ||
|
||
#[inline] | ||
fn imm64_rotr(&mut self, ty: Type, x: Imm64, k: Imm64) -> Imm64 { | ||
let bw: u32 = ty.bits().min(64); | ||
let amt: u32 = if bw == 0 { 0 } else { (k.bits() as u32) % bw }; | ||
|
||
let xv = x.bits() as u64; | ||
let v = match bw { | ||
8 => (xv as u8).rotate_right(amt) as u64, | ||
16 => (xv as u16).rotate_right(amt) as u64, | ||
32 => (xv as u32).rotate_right(amt) as u64, | ||
64 => xv.rotate_right(amt), | ||
_ => xv, | ||
}; | ||
|
||
let masked = v & self.ty_mask(ty); | ||
Imm64::new(masked as i64) | ||
} | ||
|
||
#[inline] | ||
fn imm64_sdiv(&mut self, ty: Type, x: Imm64, y: Imm64) -> Option<Imm64> { | ||
// Sign extend `x` and `y`. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
min
here should be an assert of some form because ifty.bits()
is>=64
then that's an invalid state for this function to be in and it should panic.