pub struct RiscVFrame;Implementations§
Source§impl RiscVFrame
impl RiscVFrame
Sourcepub fn generate_prologue<W: Write>(
writer: &mut W,
stack_size: usize,
callee_saved_registers: &[&str],
target: RiscVTarget,
) -> Result<(), Error>
pub fn generate_prologue<W: Write>( writer: &mut W, stack_size: usize, callee_saved_registers: &[&str], target: RiscVTarget, ) -> Result<(), Error>
Generate function prologue
Sourcepub fn generate_epilogue<W: Write>(
writer: &mut W,
stack_size: usize,
callee_saved_registers: &[&str],
target: RiscVTarget,
) -> Result<(), Error>
pub fn generate_epilogue<W: Write>( writer: &mut W, stack_size: usize, callee_saved_registers: &[&str], target: RiscVTarget, ) -> Result<(), Error>
Generate function epilogue
Sourcepub fn generate_tail_epilogue<W: Write>(
writer: &mut W,
stack_size: usize,
callee_saved_registers: &[&str],
target_sym: &str,
target: RiscVTarget,
) -> Result<(), Error>
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).
Sourcepub fn adjust_sp<W: Write>(writer: &mut W, delta: i64) -> Result<(), Error>
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.
Sourcepub fn fp_load<W: Write>(
writer: &mut W,
mnemonic: &str,
reg: &str,
offset: i32,
scratch: &str,
) -> Result<(), Error>
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.
Sourcepub fn fp_store<W: Write>(
writer: &mut W,
mnemonic: &str,
reg: &str,
offset: i32,
scratch: &str,
) -> Result<(), Error>
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.
Sourcepub fn fp_address<W: Write>(
writer: &mut W,
dst: &str,
offset: i32,
) -> Result<(), Error>
pub fn fp_address<W: Write>( writer: &mut W, dst: &str, offset: i32, ) -> Result<(), Error>
Materialise fp + offset into dst.
Sourcepub fn load_imm<W: Write>(
writer: &mut W,
reg: &str,
value: i64,
) -> Result<(), Error>
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.
Sourcepub fn calculate_stack_offset(slot_index: usize, target: RiscVTarget) -> i32
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.