Skip to main content

Assembler

Struct Assembler 

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

PVM program assembler.

Implementations§

Source§

impl Assembler

Source

pub fn new() -> Self

Source

pub fn add_jump_entry(&mut self) -> usize

Add a jump table entry pointing to the current code offset. Returns the jump table index.

Source

pub fn add_jump_entry_at(&mut self, offset: u32) -> usize

Add a jump table entry pointing to a specific code offset.

Source

pub fn current_offset(&self) -> u32

Get the current code offset.

Source

pub fn label(&mut self, name: &str) -> &mut Self

Define a label at the current code position.

Source

pub fn trap(&mut self) -> &mut Self

Opcode 0: Trap (halt with error)

Source

pub fn fallthrough(&mut self) -> &mut Self

Opcode 1: Fallthrough (nop, continue to next instruction)

Source

pub fn ecalli(&mut self, id: u32) -> &mut Self

Opcode 10: ecalli (host call with immediate ID)

Source

pub fn load_imm_64(&mut self, rd: Reg, imm: u64) -> &mut Self

Opcode 20: load_imm_64 (load 64-bit immediate into register)

Source

pub fn jump(&mut self, target: u32) -> &mut Self

Opcode 40: jump (unconditional jump to offset)

Source

pub fn jump_ind(&mut self, rd: Reg, imm: u32) -> &mut Self

Opcode 50: jump_ind (indirect jump through register + immediate)

Source

pub fn load_imm(&mut self, rd: Reg, imm: i32) -> &mut Self

Opcode 51: load_imm (load sign-extended immediate into register)

Source

pub fn load_u8(&mut self, rd: Reg, addr: u32) -> &mut Self

Opcode 52: load_u8 (load u8 from address in immediate)

Source

pub fn load_u64(&mut self, rd: Reg, addr: u32) -> &mut Self

Opcode 58: load_u64 (load u64 from address in immediate)

Source

pub fn store_u8(&mut self, rd: Reg, addr: u32) -> &mut Self

Opcode 59: store_u8 (store u8 from register to address)

Source

pub fn store_u64(&mut self, rd: Reg, addr: u32) -> &mut Self

Opcode 62: store_u64 (store u64 from register to address)

Source

pub fn load_imm_jump(&mut self, rd: Reg, imm: i32, target: u32) -> &mut Self

Opcode 80: load_imm_jump (load immediate into register and jump)

Source

pub fn branch_eq_imm(&mut self, rd: Reg, imm: i32, target: u32) -> &mut Self

Opcode 81: branch_eq_imm (branch if register == immediate)

Source

pub fn branch_ne_imm(&mut self, rd: Reg, imm: i32, target: u32) -> &mut Self

Opcode 82: branch_ne_imm (branch if register != immediate)

Source

pub fn branch_lt_u_imm(&mut self, rd: Reg, imm: i32, target: u32) -> &mut Self

Opcode 83: branch_lt_u_imm (branch if register < unsigned immediate)

Source

pub fn move_reg(&mut self, rd: Reg, ra: Reg) -> &mut Self

Opcode 100: move_reg (copy register)

Source

pub fn load_ind_u8(&mut self, rd: Reg, ra: Reg, imm: i32) -> &mut Self

Opcode 124: load_ind_u8 (load u8 from [rA + imm] into rD)

Source

pub fn load_ind_u32(&mut self, rd: Reg, ra: Reg, imm: i32) -> &mut Self

Opcode 128: load_ind_u32 (load u32 from [rA + imm] into rD)

Source

pub fn load_ind_u64(&mut self, rd: Reg, ra: Reg, imm: i32) -> &mut Self

Opcode 130: load_ind_u64 (load u64 from [rA + imm] into rD)

Source

pub fn store_ind_u8(&mut self, rd: Reg, ra: Reg, imm: i32) -> &mut Self

Opcode 120: store_ind_u8 (store u8 from rD to [rA + imm])

Source

pub fn store_ind_u32(&mut self, rd: Reg, ra: Reg, imm: i32) -> &mut Self

Opcode 122: store_ind_u32 (store u32 from rD to [rA + imm])

Source

pub fn store_ind_u64(&mut self, rd: Reg, ra: Reg, imm: i32) -> &mut Self

Opcode 123: store_ind_u64 (store u64 from rD to [rA + imm])

Source

pub fn add_imm_32(&mut self, rd: Reg, ra: Reg, imm: i32) -> &mut Self

Opcode 131: add_imm_32 (rD = rA + imm, 32-bit)

Source

pub fn add_imm_64(&mut self, rd: Reg, ra: Reg, imm: i32) -> &mut Self

Opcode 149: add_imm_64 (rD = rA + imm, 64-bit)

Source

pub fn add_64(&mut self, rd: Reg, ra: Reg, rb: Reg) -> &mut Self

Opcode 200: add_64 (rD = rA + rB)

Source

pub fn sub_64(&mut self, rd: Reg, ra: Reg, rb: Reg) -> &mut Self

Opcode 201: sub_64 (rD = rA - rB)

Source

pub fn emit_raw(&mut self, byte: u8, is_instruction_start: bool)

Emit a raw byte with bitmask control.

Trait Implementations§

Source§

impl Default for Assembler

Source§

fn default() -> Self

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

Auto Trait Implementations§

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
§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> LayoutRaw for T

§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
§

impl<T> Pointee for T

§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more