Skip to content

Commit 9732540

Browse files
committed
[Cranelift] add imm64 partial ops
1 parent cf66bae commit 9732540

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

cranelift/codegen/src/isle_prelude.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,12 @@ macro_rules! isle_common_prelude_methods {
153153
}
154154

155155
#[inline]
156-
fn imm64_ilog2(&mut self, ty: Type, x: Imm64) -> Imm64 {
156+
fn imm64_ilog2(&mut self, ty: Type, x: Imm64) -> Option<Imm64> {
157157
let type_width = ty.bits();
158158
assert!(type_width <= 64);
159159
let masked = (x.bits() as u64) & self.ty_mask(ty);
160-
let result = masked
161-
.checked_ilog2()
162-
.unwrap_or_else(|| panic!("ilog2 overflow: {masked}"));
163-
Imm64::new(result.into())
160+
let result = masked.checked_ilog2()?;
161+
Some(Imm64::new(result.into()))
164162
}
165163

166164
#[inline]

cranelift/codegen/src/prelude.isle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
(decl pure partial imm64_abs (Type Imm64) Imm64)
104104
(extern constructor imm64_abs imm64_abs)
105105

106-
(decl pure imm64_ilog2 (Type Imm64) Imm64)
106+
(decl pure partial imm64_ilog2 (Type Imm64) Imm64)
107107
(extern constructor imm64_ilog2 imm64_ilog2)
108108

109109
(decl pure imm64_umin (Type Imm64 Imm64) Imm64)

0 commit comments

Comments
 (0)