Skip to main content

Nnil

Struct Nnil 

Source
pub struct Nnil { /* private fields */ }
Expand description

Owns one lifted region so its value handles and address maps stay valid together.

Implementations§

Source§

impl Nnil

Source

pub fn new() -> Self

Creates address-neutral NNIL for callers that lift a complete byte slice.

Source

pub fn with_base(address: u64) -> Self

Starts at a guest address so that branches and fault reports use process addresses.

Source

pub fn create_label(&mut self, addr: u64) -> Label

Reuses a label for each address so that all incoming branches have one identity.

Source

pub fn new_insn(&mut self)

Records a guest-instruction boundary before its NNIL operations are appended.

Source

pub fn advance_by(&mut self, amount: u64)

Advances the guest PC separately because one guest instruction can emit many operations.

Source

pub fn base(&self) -> u64

Returns the first guest address that belongs to this NNIL region.

Source

pub fn pc(&self) -> u64

Returns the next guest address that the lifter will assign.

Source

pub fn entrypoint(&self) -> Option<Address>

Returns the lowest mapped guest address, or None for an empty region.

Source

pub fn insns(&self) -> &[NnilInstruction]

Returns operations in handle order so a backend can resolve operands by index.

Source

pub fn instruction_starts(&self) -> &BTreeMap<Address, Insn>

Returns guest-instruction boundaries for basic-block collection and diagnostics.

Source

pub fn labels(&self) -> &BTreeMap<Address, Label>

Returns the address-to-label map for direct control-flow edges.

Source

pub fn label_for_address(&self, addr: Address) -> Option<Label>

Finds the stable label for a guest address when one was created.

Source

pub fn label_address(&self, label: Label) -> Option<Address>

Resolves a label back to its guest address.

Source

pub fn imm(&mut self, imm: i64) -> Insn

Appends a signed immediate bit pattern.

Signed storage represents negative sign-extended immediates without a separate flag.

Source

pub fn reg(&mut self, reg: u64) -> Insn

Appends a read of one register in the combined NNIL register namespace.

RISC-V integer registers use indices 0 through 31. The lifter adds 32 for floating-point registers so integer and floating-point state cannot have the same NNIL index.

Source

pub fn tmp_reg(&mut self, reg: u64) -> Insn

Appends a read of a translator-private temporary.

A separate variant prevents a temporary index from aliasing guest architectural state.

Source

pub fn add(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn sub(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn mul(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn mulh(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn div(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn mod(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn and(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn or(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn xor(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn sll(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn srl(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn sra(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn slt(&mut self, lhs: Insn, rhs: Insn) -> Insn

Appends this two-input value operation and returns its stable result handle.

Source

pub fn mov(&mut self, dst: Insn, src: Insn) -> Insn

Appends a value move and writes its result through dst.

Source

pub fn set(&mut self, dst: Insn, src: Insn) -> Insn

Appends a guest-state write after a pure NNIL calculation.

Source

pub fn jr(&mut self, dst: Insn) -> Insn

Appends an indirect transfer and ends linear execution.

Source

pub fn jmp(&mut self, dst: Insn) -> Insn

Appends a transfer to the address value in dst.

Source

pub fn beq(&mut self, lhs: Insn, rhs: Insn, ttgt: Label, ftgt: Label) -> Insn

Appends this comparison branch with explicit true and false targets.

Source

pub fn bne(&mut self, lhs: Insn, rhs: Insn, ttgt: Label, ftgt: Label) -> Insn

Appends this comparison branch with explicit true and false targets.

Source

pub fn blt(&mut self, lhs: Insn, rhs: Insn, ttgt: Label, ftgt: Label) -> Insn

Appends this comparison branch with explicit true and false targets.

Source

pub fn bgt(&mut self, lhs: Insn, rhs: Insn, ttgt: Label, ftgt: Label) -> Insn

Appends this comparison branch with explicit true and false targets.

Source

pub fn load(&mut self, dst: Insn, src: Insn, size: u64) -> Insn

Appends this memory operation with an explicit byte width.

Source

pub fn store(&mut self, dst: Insn, src: Insn, size: u64) -> Insn

Appends this memory operation with an explicit byte width.

Source

pub fn sext(&mut self, size: usize, dst: Insn) -> Insn

Appends this width extension so the backend does not infer a guest width.

Source

pub fn zext(&mut self, size: usize, dst: Insn) -> Insn

Appends this width extension so the backend does not infer a guest width.

Source

pub fn signed(&mut self, dst: Insn) -> Insn

Appends this arithmetic interpretation marker without changing the input bits.

Source

pub fn unsigned(&mut self, dst: Insn) -> Insn

Appends this arithmetic interpretation marker without changing the input bits.

Source

pub fn fdiv(&mut self, size: usize, lhs: Insn, rhs: Insn) -> Insn

Appends floating-point division for a value width in bytes.

Source

pub fn int_to_float( &mut self, src: Insn, src_size: usize, signed: bool, dst_size: usize, ) -> Insn

Appends an integer-to-floating-point conversion with explicit source and result widths.

Explicit widths prevent the backend host type from changing guest conversion behavior.

Source

pub fn syscall(&mut self) -> Insn

Appends this runtime exit and returns its stable operation handle.

Source

pub fn sysbreak(&mut self) -> Insn

Appends this runtime exit and returns its stable operation handle.

Source

pub fn lr(&mut self, dst: Insn, src: Insn, size: u64) -> Insn

Appends an atomic load-reserved of size bytes from address src.

Source

pub fn sc(&mut self, dst: Insn, src: Insn, addr: Insn, size: u64) -> Insn

Appends an atomic store-conditional and its architectural success result.

Source

pub fn amo( &mut self, op: AmoOp, dst: Insn, src: Insn, addr: Insn, size: u64, ) -> Insn

Appends an atomic read-modify-write operation.

dst receives the old memory value. src contributes to the new memory value.

Source

pub fn fence(&mut self, mode: u8, pred: u8, succ: u8) -> Insn

Appends a memory-order fence with the encoded four-bit mode and access masks.

Trait Implementations§

Source§

impl Debug for Nnil

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Nnil

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Nnil

§

impl RefUnwindSafe for Nnil

§

impl Send for Nnil

§

impl Sync for Nnil

§

impl Unpin for Nnil

§

impl UnsafeUnpin for Nnil

§

impl UnwindSafe for Nnil

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.