Skip to main content

RiscVFrame

Struct RiscVFrame 

Source
pub struct RiscVFrame;

Implementations§

Source§

impl RiscVFrame

Source

pub fn generate_prologue<W: Write>( writer: &mut W, stack_size: usize, callee_saved_registers: &[&str], target: RiscVTarget, ) -> Result<(), Error>

Generate function prologue

Source

pub fn generate_epilogue<W: Write>( writer: &mut W, stack_size: usize, callee_saved_registers: &[&str], target: RiscVTarget, ) -> Result<(), Error>

Generate function epilogue

Source

pub fn generate_tail_epilogue<W: Write>( writer: &mut W, stack_size: usize, callee_saved_registers: &[&str], target_sym: &str, target: RiscVTarget, ) -> Result<(), Error>

Like Self::generate_epilogue, but jump to target_sym instead of ret (tail call).

Source

pub fn adjust_sp<W: Write>(writer: &mut W, delta: i64) -> Result<(), Error>

Move sp by delta bytes. Deltas outside the 12-bit range go through t0, which the prologue, epilogue and call sequences do not hold a value in.

Source

pub fn fp_load<W: Write>( writer: &mut W, mnemonic: &str, reg: &str, offset: i32, scratch: &str, ) -> Result<(), Error>

Emit {mnemonic} {reg}, {offset}(fp), building the address in scratch when the offset does not fit the 12-bit immediate. reg is overwritten by a load, so it may serve as the scratch for one.

Source

pub fn fp_store<W: Write>( writer: &mut W, mnemonic: &str, reg: &str, offset: i32, scratch: &str, ) -> Result<(), Error>

Store reg at {offset}(fp). A store must not clobber reg, so when the offset is out of range and reg is t0, fp itself is walked to the slot and back.

Source

pub fn fp_address<W: Write>( writer: &mut W, dst: &str, offset: i32, ) -> Result<(), Error>

Materialise fp + offset into dst.

Source

pub fn load_imm<W: Write>( writer: &mut W, reg: &str, value: i64, ) -> Result<(), Error>

Load value into reg. ras only encodes li for 12-bit immediates, so larger values are built from slli and addi steps.

Source

pub fn calculate_stack_offset(slot_index: usize, target: RiscVTarget) -> i32

Offset of a local slot from fp.

The prologue leaves fp at the caller’s sp, with ra at fp-8 and the caller’s fp at fp-16. Locals start below that pair. This used to return fp-8 for slot 0 and fp-16 for slot 1, so the first local overwrote the return address and the second overwrote the saved frame pointer.

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
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.