To protect your data, the CISO officer has suggested users to enable GitLab 2FA as soon as possible.

Commit d1a1434e authored by qinsoon's avatar qinsoon
Browse files

correct logic on deciding whether a const is x86 immediate

parent e31c8105
......@@ -3934,6 +3934,8 @@ impl <'a> InstructionSelection {
debug!("tmp's ty: {}", tmp.ty);
self.backend.emit_mov_r_imm(&tmp, val)
} else {
assert!(tmp.ty.get_int_length().is_some());
assert!(tmp.ty.get_int_length().unwrap() == 64);
self.backend.emit_mov_r64_imm64(&tmp, val as i64);
}
},
......
......@@ -518,12 +518,17 @@ pub fn is_callee_saved(reg_id: MuID) -> bool {
}
pub fn is_valid_x86_imm(op: &P<Value>) -> bool {
use std::u32;
match op.v {
Value_::Constant(Constant::Int(val)) if val <= u32::MAX as u64 => {
true
},
_ => false
use std::i32;
if op.ty.get_int_length().is_some() && op.ty.get_int_length().unwrap() <= 32 {
match op.v {
Value_::Constant(Constant::Int(val)) if val as i32 >= i32::MIN && val as i32 <= i32::MAX => {
true
},
_ => false
}
} else {
false
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment