Use u32 in Type API (#4280)

Move from passing and returning u8 and u16 values to u32 in many of
the functions. This removes a number of type conversions and gives
a small compilation time speedup, around ~0.7% on my aarch64 machine.

Copyright (c) 2022, Arm Limited.
This commit is contained in:
Sam Parker
2022-06-30 20:43:36 +01:00
committed by GitHub
parent 95836ba114
commit a2d49ebf27
13 changed files with 27 additions and 28 deletions

View File

@@ -125,9 +125,7 @@ where
let inputs = self.lower_ctx.get_value_as_source_or_const(val);
if let Some(c) = inputs.constant {
let mask = 1_u64
.checked_shl(ty.bits() as u32)
.map_or(u64::MAX, |x| x - 1);
let mask = 1_u64.checked_shl(ty.bits()).map_or(u64::MAX, |x| x - 1);
return Imm8Gpr::new(Imm8Reg::Imm8 {
imm: (c & mask) as u8,
})
@@ -218,9 +216,7 @@ where
#[inline]
fn const_to_type_masked_imm8(&mut self, c: u64, ty: Type) -> Imm8Gpr {
let mask = 1_u64
.checked_shl(ty.bits() as u32)
.map_or(u64::MAX, |x| x - 1);
let mask = 1_u64.checked_shl(ty.bits()).map_or(u64::MAX, |x| x - 1);
Imm8Gpr::new(Imm8Reg::Imm8 {
imm: (c & mask) as u8,
})