From f06967bbe80d5647412a4b709b1d3de0fe056627 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Fri, 13 Dec 2024 01:22:59 +0100 Subject: asm: remove EncodeMI helper * EncodeMI and EncodeM are identical after introducing explicitly sized memory operands --- src/asm.rs | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/asm.rs b/src/asm.rs index 616ba87..837e2b8 100644 --- a/src/asm.rs +++ b/src/asm.rs @@ -204,7 +204,7 @@ impl Asm { /// Encode a memory-immediate instruction. pub(crate) fn encode_mi(&mut self, opc: u8, opc_ext: u8, op1: M, op2: T) where - Self: EncodeMI, + Self: EncodeM, { // MI operand encoding. // op1 -> modrm.rm @@ -234,8 +234,8 @@ impl Asm { rm, /* rm */ ); - let prefix = >::legacy_prefix(); - let rex = >::rex(&op1); + let prefix = >::legacy_prefix(); + let rex = >::rex(&op1); self.emit_optional(&[prefix, rex]); self.emit(&[opc, modrm]); @@ -403,31 +403,7 @@ impl EncodeMR for Asm { impl EncodeMR for Asm {} impl EncodeMR for Asm {} -/// Encode helper for memory-immediate instructions. -pub(crate) trait EncodeMI { - fn legacy_prefix() -> Option { - None - } - - fn rex(op1: &M) -> Option { - if M::is_64() || op1.base().is_ext() || op1.index().is_ext() { - Some(rex(M::is_64(), 0, op1.index().idx(), op1.base().idx())) - } else { - None - } - } -} - -impl EncodeMI for Asm {} -impl EncodeMI for Asm { - fn legacy_prefix() -> Option { - Some(0x66) - } -} -impl EncodeMI for Asm {} -impl EncodeMI for Asm {} - -/// Encode helper for memory operand instructions. +/// Encode helper for memory perand instructions. pub(crate) trait EncodeM { fn legacy_prefix() -> Option { None -- cgit v1.2.3