pub struct RiscVBackend {
pub is_64bit: bool,
}Expand description
RISC-V code-generation backend.
Supports both RV32I (is_64bit = false) and RV64I (is_64bit = true).
Fields§
§is_64bit: boolImplementations§
Source§impl RiscVBackend
impl RiscVBackend
pub fn new(is_64bit: bool) -> Self
Sourcepub fn emit_instr(&self, instr: &RiscVInstr) -> String
pub fn emit_instr(&self, instr: &RiscVInstr) -> String
Emit a single instruction as a text line (GNU assembler syntax).
Sourcepub fn emit_function(&self, func: &RiscVFunction) -> String
pub fn emit_function(&self, func: &RiscVFunction) -> String
Emit a complete function (with .globl / .type directives and label).
Sourcepub fn prologue(&self, frame_size: u32) -> Vec<RiscVInstr>
pub fn prologue(&self, frame_size: u32) -> Vec<RiscVInstr>
Standard RISC-V function prologue.
Saves ra and s0 (frame pointer), sets up a stack frame of
frame_size bytes (rounded up to 16-byte alignment).
Sourcepub fn epilogue(&self) -> Vec<RiscVInstr>
pub fn epilogue(&self) -> Vec<RiscVInstr>
Standard RISC-V function epilogue (restores ra/s0, deallocates frame).
Sourcepub fn calling_convention_args() -> Vec<RiscVReg>
pub fn calling_convention_args() -> Vec<RiscVReg>
Argument registers per the RISC-V calling convention (a0 .. a7).
Sourcepub fn caller_saved() -> Vec<RiscVReg>
pub fn caller_saved() -> Vec<RiscVReg>
Caller-saved (temporary) registers: t0 .. t6.
Sourcepub fn callee_saved() -> Vec<RiscVReg>
pub fn callee_saved() -> Vec<RiscVReg>
Callee-saved registers: s0 .. s11.
Trait Implementations§
Source§impl Clone for RiscVBackend
impl Clone for RiscVBackend
Source§fn clone(&self) -> RiscVBackend
fn clone(&self) -> RiscVBackend
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RiscVBackend
impl RefUnwindSafe for RiscVBackend
impl Send for RiscVBackend
impl Sync for RiscVBackend
impl Unpin for RiscVBackend
impl UnsafeUnpin for RiscVBackend
impl UnwindSafe for RiscVBackend
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more