diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-13 01:22:59 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-13 01:22:59 +0100 |
commit | f06967bbe80d5647412a4b709b1d3de0fe056627 (patch) | |
tree | 74975082ced7e3b5cb9922de2040353c26bb00b8 | |
parent | 758f014afb8ec5c20ef2fc862fc12e80f65d3d25 (diff) | |
download | juicebox-asm-f06967bbe80d5647412a4b709b1d3de0fe056627.tar.gz juicebox-asm-f06967bbe80d5647412a4b709b1d3de0fe056627.zip |
asm: remove EncodeMI helper
* EncodeMI and EncodeM are identical after introducing explicitly
sized memory operands
-rw-r--r-- | src/asm.rs | 32 |
1 files changed, 4 insertions, 28 deletions
@@ -204,7 +204,7 @@ impl Asm { /// Encode a memory-immediate instruction. pub(crate) fn encode_mi<M: Mem, T: Imm>(&mut self, opc: u8, opc_ext: u8, op1: M, op2: T) where - Self: EncodeMI<M>, + Self: EncodeM<M>, { // MI operand encoding. // op1 -> modrm.rm @@ -234,8 +234,8 @@ impl Asm { rm, /* rm */ ); - let prefix = <Self as EncodeMI<M>>::legacy_prefix(); - let rex = <Self as EncodeMI<M>>::rex(&op1); + let prefix = <Self as EncodeM<M>>::legacy_prefix(); + let rex = <Self as EncodeM<M>>::rex(&op1); self.emit_optional(&[prefix, rex]); self.emit(&[opc, modrm]); @@ -403,31 +403,7 @@ impl EncodeMR<Mem16> for Asm { impl EncodeMR<Mem32> for Asm {} impl EncodeMR<Mem64> for Asm {} -/// Encode helper for memory-immediate instructions. -pub(crate) trait EncodeMI<M: Mem> { - fn legacy_prefix() -> Option<u8> { - None - } - - fn rex(op1: &M) -> Option<u8> { - 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<Mem8> for Asm {} -impl EncodeMI<Mem16> for Asm { - fn legacy_prefix() -> Option<u8> { - Some(0x66) - } -} -impl EncodeMI<Mem32> for Asm {} -impl EncodeMI<Mem64> for Asm {} - -/// Encode helper for memory operand instructions. +/// Encode helper for memory perand instructions. pub(crate) trait EncodeM<M: Mem> { fn legacy_prefix() -> Option<u8> { None |