From 93c53657c2289e979672ee6c4612af7e9eac109c Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 13 Mar 2021 14:19:55 -0800 Subject: split ffi crate to support distinct 16, 32, and 64-bit builds initial work to optionally discard any instruction printing support when using `-Z build-std` to fully remove .eh_frame, a stripped long_mode_no_fmt .so is 61kb! --- src/long_mode/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/long_mode/mod.rs') diff --git a/src/long_mode/mod.rs b/src/long_mode/mod.rs index 909157b..ff5e43b 100644 --- a/src/long_mode/mod.rs +++ b/src/long_mode/mod.rs @@ -1,4 +1,5 @@ mod vex; +#[cfg(feature = "fmt")] mod display; pub mod uarch; @@ -6,6 +7,20 @@ use core::hint::unreachable_unchecked; use yaxpeax_arch::{AddressDiff, Decoder, LengthedInstruction}; +use core::fmt; +impl fmt::Display for DecodeError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + DecodeError::ExhaustedInput => { write!(f, "exhausted input") }, + DecodeError::InvalidOpcode => { write!(f, "invalid opcode") }, + DecodeError::InvalidOperand => { write!(f, "invalid operand") }, + DecodeError::InvalidPrefixes => { write!(f, "invalid prefixes") }, + DecodeError::TooLong => { write!(f, "too long") }, + DecodeError::IncompleteDecoder => { write!(f, "the decoder is incomplete") }, + } + } +} + #[cfg(feature="use-serde")] #[derive(Copy, Clone, Debug, PartialOrd, Ord, Eq, PartialEq, Serialize, Deserialize)] pub struct RegSpec { @@ -71,6 +86,7 @@ impl RegSpec { RegisterClass { kind: self.bank } } + #[cfg(feature = "fmt")] /// return a human-friendly name for this register. the returned name is the same as would be /// used to render this register in an instruction. pub fn name(&self) -> &'static str { -- cgit v1.1