Merge pull request #2042 from cfallin/aarch64-fix-regshift-mask
Aarch64: mask shift-amounts incorporated into reg-reg-shift ALU insts.
This commit is contained in:
@@ -52,6 +52,11 @@ impl ShiftOpShiftImm {
|
||||
pub fn value(self) -> u8 {
|
||||
self.0
|
||||
}
|
||||
|
||||
/// Mask down to a given number of bits.
|
||||
pub fn mask(self, bits: u8) -> ShiftOpShiftImm {
|
||||
ShiftOpShiftImm(self.0 & (bits - 1))
|
||||
}
|
||||
}
|
||||
|
||||
/// A shift operator with an amount, guaranteed to be within range.
|
||||
|
||||
@@ -321,8 +321,12 @@ fn put_input_in_rs<C: LowerCtx<I = Inst>>(
|
||||
|
||||
// Can we get the shift amount as an immediate?
|
||||
if let Some(shiftimm) = input_to_shiftimm(ctx, shift_amt) {
|
||||
let reg = put_input_in_reg(ctx, shiftee, narrow_mode);
|
||||
return ResultRS::RegShift(reg, ShiftOpAndAmt::new(ShiftOp::LSL, shiftimm));
|
||||
let shiftee_bits = ty_bits(ctx.input_ty(insn, 0));
|
||||
if shiftee_bits <= u8::MAX as usize {
|
||||
let shiftimm = shiftimm.mask(shiftee_bits as u8);
|
||||
let reg = put_input_in_reg(ctx, shiftee, narrow_mode);
|
||||
return ResultRS::RegShift(reg, ShiftOpAndAmt::new(ShiftOp::LSL, shiftimm));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user