From 9f88282aab105a829cae9987a99bb5aca7b04eff Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 28 Jan 2023 14:08:52 -0800 Subject: OperandCode as a u16 caused gross movzwl, this seems just a bit better --- src/long_mode/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index c75ad0b..723b669 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -4833,8 +4833,8 @@ impl OperandCodeBuilder { OperandCodeBuilder { bits: 0 } } - const fn bits(&self) -> u16 { - self.bits + const fn bits(&self) -> u32 { + self.bits as u32 } const fn from_bits(bits: u16) -> Self { @@ -4997,7 +4997,7 @@ pub struct OperandCodeWrapper { code: OperandCode } // | // | // ---------------------------> read modr/m? -#[repr(u16)] +#[repr(u32)] #[derive(Copy, Clone, Debug, PartialEq, Eq)] enum OperandCode { Ivs = OperandCodeBuilder::new().special_case(25).bits(), @@ -6897,7 +6897,7 @@ fn read_operands< // reversed-operands `movbe` and fairly unlikely. that case is handled in // `unlikely_operands`. TODO: maybe this could just be a bit in `operand_code` for // "memory-only mmm"? - if operand_code.bits() == (OperandCode::Gv_M as u16) { + if operand_code.bits() == (OperandCode::Gv_M as u32) { return Err(DecodeError::InvalidOperand); } read_modrm_reg(instruction, words, modrm, bank, sink)? @@ -6942,7 +6942,7 @@ fn read_operands< instruction.regs[0].num = ((modrm >> 3) & 7) + if instruction.prefixes.rex_unchecked().r() { 0b1000 } else { 0 }; // for some encodings, the rrr field selects an opcode, not an operand - if operand_code.bits() != OperandCode::ModRM_0xc1_Ev_Ib as u16 && operand_code.bits() != OperandCode::ModRM_0xff_Ev as u16 { + if operand_code.bits() != OperandCode::ModRM_0xc1_Ev_Ib as u32 && operand_code.bits() != OperandCode::ModRM_0xff_Ev as u32 { sink.record( modrm_start + 3, modrm_start + 5, -- cgit v1.1