Skip to content

Commit 11c2023

Browse files
authored
Fix/count trailing zeroes (#95)
* Fix count trailing zeroes * Fix pop count * Fix bit reverse
1 parent 63608ac commit 11c2023

File tree

2 files changed

+216
-162
lines changed

2 files changed

+216
-162
lines changed

src/common.rs

+22
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,7 @@ pub trait SignType<'gcc, 'tcx> {
302302
fn is_signed(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool;
303303
fn is_unsigned(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool;
304304
fn to_signed(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
305+
fn to_unsigned(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
305306
}
306307

307308
impl<'gcc, 'tcx> SignType<'gcc, 'tcx> for Type<'gcc> {
@@ -333,6 +334,27 @@ impl<'gcc, 'tcx> SignType<'gcc, 'tcx> for Type<'gcc> {
333334
self.clone()
334335
}
335336
}
337+
338+
fn to_unsigned(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> {
339+
if self.is_i8(cx) {
340+
cx.u8_type
341+
}
342+
else if self.is_i16(cx) {
343+
cx.u16_type
344+
}
345+
else if self.is_i32(cx) {
346+
cx.u32_type
347+
}
348+
else if self.is_i64(cx) {
349+
cx.u64_type
350+
}
351+
else if self.is_i128(cx) {
352+
cx.u128_type
353+
}
354+
else {
355+
self.clone()
356+
}
357+
}
336358
}
337359

338360
pub trait TypeReflection<'gcc, 'tcx> {

0 commit comments

Comments
 (0)