From 72968a35438e5284a0ba63c947e70f8880b3abb5 Mon Sep 17 00:00:00 2001 From: iximeow Date: Sun, 1 Jun 2025 08:46:23 +0000 Subject: DecodeEverything wasn't useful, no better than InstDecoder::default()?? --- src/long_mode/mod.rs | 50 +++++++++----------------------------------------- 1 file changed, 9 insertions(+), 41 deletions(-) (limited to 'src/long_mode/mod.rs') diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index 0045236..e471391 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -5,8 +5,6 @@ mod display; pub mod uarch; mod isa_settings; -pub use isa_settings::IsaSettings; - pub use crate::MemoryAccessSize; #[cfg(feature = "fmt")] @@ -2818,33 +2816,6 @@ impl InstDecoder { } } -pub struct DecodeEverything {} - -impl Decoder for DecodeEverything { - fn decode::Address, ::Word>>(&self, words: &mut T) -> Result::DecodeError> { - let mut instr = Instruction::invalid(); - self.decode_into(&mut instr, words)?; - - Ok(instr) - } - #[inline(always)] - fn decode_into::Address, ::Word>>(&self, instr: &mut Instruction, words: &mut T) -> Result<(), ::DecodeError> { - self.decode_with_annotation(instr, words, &mut NullSink) - } -} - -impl AnnotatingDecoder for DecodeEverything { - type FieldDescription = FieldDescription; - - #[inline(always)] - fn decode_with_annotation< - T: Reader<::Address, ::Word>, - S: DescriptionSink - >(&self, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), ::DecodeError> { - decode_with_annotation(self, instr, words, sink) - } -} - impl Default for InstDecoder { /// Instantiates an x86_64 decoder that probably decodes what you want. /// @@ -2884,18 +2855,17 @@ impl AnnotatingDecoder for InstDecoder { #[inline(always)] fn decode_with_annotation< - D: IsaSettings, T: Reader<::Address, ::Word>, S: DescriptionSink ->(isa_settings: &D, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), ::DecodeError> { - DecodeCtx::new().read_with_annotations(isa_settings, words, instr, sink)?; +>(decoder: &InstDecoder, instr: &mut Instruction, words: &mut T, sink: &mut S) -> Result<(), ::DecodeError> { + DecodeCtx::new().read_with_annotations(decoder, words, instr, sink)?; instr.length = words.offset() as u8; if words.offset() > 15 { return Err(DecodeError::TooLong); } - isa_settings.revise_instruction(instr)?; + isa_settings::revise_instruction(decoder, instr)?; Ok(()) } @@ -5381,10 +5351,9 @@ fn read_opc_hotpath< #[cfg_attr(feature="profiling", inline(never))] #[cfg_attr(not(feature="profiling"), inline(always))] fn read_with_annotations< - D: IsaSettings, T: Reader<::Address, ::Word>, S: DescriptionSink, ->(mut self, isa_settings: &D, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<(), DecodeError> { +>(mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, sink: &mut S) -> Result<(), DecodeError> { words.mark(); let mut nextb = words.next().ok().ok_or(DecodeError::ExhaustedInput)?; let mut next_rec = OPCODES[nextb as usize]; @@ -5532,7 +5501,7 @@ fn read_with_annotations< record.operand() }; - self.read_operands(isa_settings, words, instruction, record, sink)?; + self.read_operands(decoder, words, instruction, record, sink)?; if self.check_lock { if !instruction.opcode.can_lock() || !instruction.operands[0].is_memory() { @@ -5601,10 +5570,9 @@ fn read_avx_prefixed< #[cfg_attr(feature="profiling", inline(never))] #[cfg_attr(not(feature="profiling"), inline(always))] fn read_operands< - D: IsaSettings, T: Reader<::Address, ::Word>, S: DescriptionSink ->(&mut self, isa_settings: &D, words: &mut T, instruction: &mut Instruction, operand_code: OperandCode, sink: &mut S) -> Result<(), DecodeError> { +>(&mut self, decoder: &InstDecoder, words: &mut T, instruction: &mut Instruction, operand_code: OperandCode, sink: &mut S) -> Result<(), DecodeError> { sink.record( words.offset() as u32 * 8 - 1, words.offset() as u32 * 8 - 1, InnerDescription::Boundary("opcode ends/operands begin (typically)") @@ -8728,7 +8696,7 @@ fn read_operands< instruction.opcode = Opcode::LFENCE; // Intel's manual accepts m != 0, AMD supports m != 0 though the manual // doesn't say (tested on threadripper) - if !isa_settings.amd_quirks() && !isa_settings.intel_quirks() { + if !decoder.amd_quirks() && !decoder.intel_quirks() { if m != 0 { return Err(DecodeError::InvalidOperand); } @@ -8738,7 +8706,7 @@ fn read_operands< instruction.opcode = Opcode::MFENCE; // Intel's manual accepts m != 0, AMD supports m != 0 though the manual // doesn't say (tested on threadripper) - if !isa_settings.amd_quirks() && !isa_settings.intel_quirks() { + if !decoder.amd_quirks() && !decoder.intel_quirks() { if m != 0 { return Err(DecodeError::InvalidOperand); } @@ -8748,7 +8716,7 @@ fn read_operands< instruction.opcode = Opcode::SFENCE; // Intel's manual accepts m != 0, AMD supports m != 0 though the manual // doesn't say (tested on threadripper) - if !isa_settings.amd_quirks() && !isa_settings.intel_quirks() { + if !decoder.amd_quirks() && !decoder.intel_quirks() { if m != 0 { return Err(DecodeError::InvalidOperand); } -- cgit v1.1