machinst x64: revamp integer immediate emission;
In particular: - try to optimize the integer emission into a 32-bit emission, when the high bits are all zero, and stop relying on the caller of `imm_r` to ensure this. - rename `Inst::imm_r`/`Inst::Imm_R` to `Inst::imm`/`Inst::Imm`. - generate a sign-extending mov 32-bit immediate to 64-bits, whenever possible. - fix a few places where the previous commit did introduce the generation of zero-constants with xor, when calling `put_input_to_reg`, thus clobbering the flags before they were read.
This commit is contained in:
@@ -1001,6 +1001,14 @@ pub enum OperandSize {
|
||||
}
|
||||
|
||||
impl OperandSize {
|
||||
pub(crate) fn from_bytes(num_bytes: u32) -> Self {
|
||||
match num_bytes {
|
||||
1 | 2 | 4 => OperandSize::Size32,
|
||||
8 => OperandSize::Size64,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn to_bytes(&self) -> u8 {
|
||||
match self {
|
||||
Self::Size32 => 4,
|
||||
|
||||
Reference in New Issue
Block a user