Skip to content

Commit

Permalink
remove op_access from OpCodeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
susitsm authored and Matyas Susits committed Sep 29, 2024
1 parent c8a0969 commit a7a17ac
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 77 deletions.
6 changes: 5 additions & 1 deletion src/rust/iced-x86/src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45194,7 +45194,11 @@ impl Code {
self.info_flags1().op4_access()
}

/// Gets an operand's [`OpAccess`]. Returns `OpAccess::None` if the operand does not exist.
/// Gets an operand's [`OpAccess`]
/// # Arguments
///
/// * `operand`: Operand number. If the operand does not exist the function will return
/// `OpAccess::None`
#[must_use]
#[inline]
pub const fn op_access(&self, operand: u32) -> OpAccess {
Expand Down
76 changes: 0 additions & 76 deletions src/rust/iced-x86/src/encoder/op_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ pub struct OpCodeInfo {
group_index: i8,
rm_group_index: i8,
op_kinds: [OpCodeOperandKind; IcedConstants::MAX_OP_COUNT],
#[cfg(feature = "instr_info")]
op_accesses: [OpAccess; IcedConstants::MAX_OP_COUNT],
}

impl OpCodeInfo {
Expand Down Expand Up @@ -360,8 +358,6 @@ impl OpCodeInfo {
group_index,
rm_group_index,
op_kinds: [op0_kind, op1_kind, op2_kind, op3_kind, op4_kind],
#[cfg(feature = "instr_info")]
op_accesses: [code.op0_access(), code.op1_access(), code.op2_access(), code.op3_access(), code.op4_access()],
};

if string_format {
Expand Down Expand Up @@ -1426,78 +1422,6 @@ impl OpCodeInfo {
}
}

#[cfg(feature = "instr_info")]
impl OpCodeInfo {
/// Gets operand #0's OpAccess
#[must_use]
#[inline]
pub const fn op0_access(&self) -> OpAccess {
self.op_accesses[0]
}

/// Gets operand #1's OpAccess
#[must_use]
#[inline]
pub const fn op1_access(&self) -> OpAccess {
self.op_accesses[1]
}

/// Gets operand #2's OpAccess
#[must_use]
#[inline]
pub const fn op2_access(&self) -> OpAccess {
self.op_accesses[2]
}

/// Gets operand #3's OpAccess
#[must_use]
#[inline]
pub const fn op3_access(&self) -> OpAccess {
self.op_accesses[3]
}

/// Gets operand #4's OpAccess
#[must_use]
#[inline]
pub const fn op4_access(&self) -> OpAccess {
self.op_accesses[4]
}

/// Gets an operand's opaccess
///
/// # Arguments
///
/// * `operand`: Operand number, 0-4
#[must_use]
#[inline]
pub fn op_access(&self, operand: u32) -> OpAccess {
match self.op_accesses.get(operand as usize) {
Some(&op_access) => op_access,
None => {
debug_assert!(false, "Invalid operand: {}", operand);
OpAccess::None
}
}
}

#[inline]
#[allow(clippy::missing_inline_in_public_items)]
#[doc(hidden)]
pub fn try_op_access(&self, operand: u32) -> Result<OpAccess, IcedError> {
match self.op_accesses.get(operand as usize) {
Some(&op_access) => Ok(op_access),
None => Err(IcedError::new("Invalid operand")),
}
}

/// Gets all operand accesses
#[must_use]
#[inline]
pub fn op_accesses(&self) -> &[OpAccess] {
&self.op_accesses[0..self.op_count() as usize]
}
}

impl fmt::Display for OpCodeInfo {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
Expand Down

0 comments on commit a7a17ac

Please sign in to comment.