Closed ptitSeb closed 2 years ago
Thanks for the report. Looks like the logical immediate code accidentally overflows a left shift when the element size is the word size. Should be a simple question of replacing it by .checked_shl().unwrap_or(0)
. I'll get to it tomorrow probably.
Aside of that, was this the actual code? Or was the 255 actually an expression. I would expect this error to be raised at compile time if it was a literal.
the 255 wasn't a direct litteral. I have a fn emit_and(&mut self, sz: Size, src1: Location, src2: Location, dst: Location)
to handle the different cases of immediate or regs and different size of regs, using
match (sz, src1, src2, dst)
and things like
(Size::S32, Location::GPR(src1), Location::Imm32(src2), Location::GPR(dst)) => {
let src1 = src1.into_index() as u32;
let src2 = src2 as u32;
let dst = dst.into_index() as u32;
if !encode_logical_immediate_32bit(src2).is_some() {
unreachable!();
}
dynasm!(self ; and W(dst), W(src1), src2);
}
Makes sense, I couldn't reproduce the same error from your testcase, working on it now.
Should be fixed in 1.2.1
Yes, it fixed the issue, thanks!
trying to use
dynasm!(self ; and w0, w0, 255);
Will lead tothread '<unnamed>' panicked at 'attempt to shift left with overflow', /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/dynasmrt-1.2.0/src/aarch64.rs:208:27
(the element_size is 32)
0xff can be converted to Logical Immediate. It should lead to immr==0 and imms==7