pub struct Instruction { /* private fields */ }
Expand description

This structure represents a RISC-V (32 or 64 bit) instruction

Implementations§

§

impl Instruction

pub fn opcode(&self) -> Opcode

The instruction opcode as defined in LLVM

Trait Implementations§

§

impl Instruction for Instruction

§

fn address(&self) -> u64

Address of the instruction
§

fn size(&self) -> u64

Size of the instruction in bytes
§

fn raw(&self) -> &[u8]

Raw bytes of the current instruction
§

fn mnemonic(&self) -> String

Instruction mnemonic (e.g. br)
§

fn to_string(&self) -> String

Representation of the current instruction in a pretty assembly way
§

fn to_string_no_address(&self) -> String

Same as Instruction::to_string but without the address as prefix
§

fn is_call(&self) -> bool

True if the instruction is a call
§

fn is_terminator(&self) -> bool

True if the instruction marks the end of a basic block
§

fn is_branch(&self) -> bool

True if the instruction is a branch
§

fn is_syscall(&self) -> bool

True if the instruction is a syscall
§

fn is_memory_access(&self) -> bool

True if the instruction performs a memory access
§

fn is_move_reg(&self) -> bool

True if the instruction is a register to register move.
§

fn is_add(&self) -> bool

True if the instruction performs an arithmetic addition.
§

fn is_trap(&self) -> bool

True if the instruction is a trap. Read more
§

fn is_barrier(&self) -> bool

True if the instruction prevents executing the instruction that immediatly follows the current. This includes return or unconditional branch instructions
§

fn is_return(&self) -> bool

True if the instruction is a return
§

fn is_indirect_branch(&self) -> bool

True if the instruction is and indirect branch. Read more
§

fn is_conditional_branch(&self) -> bool

True if the instruction is conditionally jumping to the next instruction or an instruction into some other basic block.
§

fn is_unconditional_branch(&self) -> bool

True if the instruction is jumping (unconditionally) to some other basic block.
§

fn is_compare(&self) -> bool

True if the instruction is a comparison
§

fn is_move_immediate(&self) -> bool

True if the instruction is moving an immediate
§

fn is_bitcast(&self) -> bool

True if the instruction is doing a bitcast
§

fn memory_access(&self) -> MemoryAccess

Memory access flags
§

fn branch_target(&self) -> Result<u64, Error>

Given a Instruction::is_branch instruction, try to evaluate the address of the destination.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.