aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/asm.rs
diff options
context:
space:
mode:
authorJohannes Stoelp <johannes.stoelp@gmail.com>2024-12-13 01:22:59 +0100
committerJohannes Stoelp <johannes.stoelp@gmail.com>2024-12-13 01:22:59 +0100
commitf06967bbe80d5647412a4b709b1d3de0fe056627 (patch)
tree74975082ced7e3b5cb9922de2040353c26bb00b8 /src/asm.rs
parent758f014afb8ec5c20ef2fc862fc12e80f65d3d25 (diff)
downloadjuicebox-asm-f06967bbe80d5647412a4b709b1d3de0fe056627.tar.gz
juicebox-asm-f06967bbe80d5647412a4b709b1d3de0fe056627.zip
asm: remove EncodeMI helper
* EncodeMI and EncodeM are identical after introducing explicitly sized memory operands
Diffstat (limited to 'src/asm.rs')
-rw-r--r--src/asm.rs32
1 files changed, 4 insertions, 28 deletions
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<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