Merge pull request #1999 from bnjbvr/fix-aarch64-ishl-by-zero

machinst aarch64: fix encoding generation of left-shift by 0
This commit is contained in:
Chris Fallin
2020-07-13 09:25:21 -07:00
committed by GitHub
2 changed files with 30 additions and 2 deletions

View File

@@ -534,8 +534,16 @@ impl MachInstEmit for Inst {
ALUOp::Lsr64 => (0b1101001101, u32::from(amt), 0b111111),
ALUOp::Asr32 => (0b0001001100, u32::from(amt), 0b011111),
ALUOp::Asr64 => (0b1001001101, u32::from(amt), 0b111111),
ALUOp::Lsl32 => (0b0101001100, u32::from(32 - amt), u32::from(31 - amt)),
ALUOp::Lsl64 => (0b1101001101, u32::from(64 - amt), u32::from(63 - amt)),
ALUOp::Lsl32 => (
0b0101001100,
u32::from((32 - amt) % 32),
u32::from(31 - amt),
),
ALUOp::Lsl64 => (
0b1101001101,
u32::from((64 - amt) % 64),
u32::from(63 - amt),
),
_ => unimplemented!("{:?}", alu_op),
};
sink.put4(

View File

@@ -934,6 +934,26 @@ fn test_aarch64_binemit() {
"280141D3",
"lsl x8, x9, #63",
));
insns.push((
Inst::AluRRImmShift {
alu_op: ALUOp::Lsl32,
rd: writable_xreg(10),
rn: xreg(11),
immshift: ImmShift::maybe_from_u64(0).unwrap(),
},
"6A7D0053",
"lsl w10, w11, #0",
));
insns.push((
Inst::AluRRImmShift {
alu_op: ALUOp::Lsl64,
rd: writable_xreg(10),
rn: xreg(11),
immshift: ImmShift::maybe_from_u64(0).unwrap(),
},
"6AFD40D3",
"lsl x10, x11, #0",
));
insns.push((
Inst::AluRRImmLogic {