pub struct Emitter { /* private fields */ }Implementations§
Source§impl Emitter
impl Emitter
pub fn new(dialect: AsmDialect) -> Emitter
pub fn with_span<R>( &mut self, span: &Span, f: impl FnOnce(&mut Emitter) -> R, ) -> R
pub fn without_span<R>(&mut self, f: impl FnOnce(&mut Emitter) -> R) -> R
Sourcepub fn ins_cmt(&mut self, text: &str, comment: &str)
pub fn ins_cmt(&mut self, text: &str, comment: &str)
Instruction with a trailing // comment (source snippets, slot names).
pub fn label(&mut self, name: &str)
pub fn label_cmt(&mut self, name: &str, comment: &str)
pub fn new_label(&mut self) -> String
pub fn new_function_label(&mut self) -> String
Sourcepub fn intern_string(&mut self, bytes: &[u8]) -> (String, u64)
pub fn intern_string(&mut self, bytes: &[u8]) -> (String, u64)
Interns a string literal into .rodata, deduplicated; returns
(label, byte length).
Sourcepub fn load_imm64(&mut self, reg: &str, value: u64, comment: &str)
pub fn load_imm64(&mut self, reg: &str, value: u64, comment: &str)
Materializes any 64-bit constant: one movz plus up to three movk,
skipping zero halfwords (design §6). Never assumes mov reg, #imm
encodes.
Sourcepub fn load_label_address(&mut self, reg: &str, label: &str, comment: &str)
pub fn load_label_address(&mut self, reg: &str, label: &str, comment: &str)
reg = address of label via adrp plus the low-12-bits add, spelled
:lo12: on ELF and @PAGE/@PAGEOFF on Mach-O (design §6, §9).
Sourcepub fn call_runtime(&mut self, name: &str, comment: &str)
pub fn call_runtime(&mut self, name: &str, comment: &str)
bl to an rt_* entry point by its C name; the dialect supplies the
Mach-O _ prefix (bl rt_add vs bl _rt_add). Every runtime call
must go through here so no bl hardcodes a platform spelling.
Sourcepub fn push_acc(&mut self, comment: &str)
pub fn push_acc(&mut self, comment: &str)
Pushes the accumulator, one value per 16-byte slot (design §6).
pub fn pop(&mut self, reg: &str, comment: &str)
Sourcepub fn sp_sub(&mut self, bytes: u64)
pub fn sp_sub(&mut self, bytes: u64)
Grows the stack by bytes (16-aligned by contract), splitting or
materializing when the immediate does not encode (design §6).
pub fn sp_add(&mut self, bytes: u64)
Sourcepub fn frame_store(&mut self, reg: &str, offset: u64, comment: &str)
pub fn frame_store(&mut self, reg: &str, offset: u64, comment: &str)
Stores reg at [x29, #-offset], going through x8 when the
unscaled immediate cannot encode the slot (design §6). reg must not
be x8.
pub fn frame_load(&mut self, reg: &str, offset: u64, comment: &str)
Sourcepub fn sp_store(&mut self, reg: &str, offset: u64, comment: &str)
pub fn sp_store(&mut self, reg: &str, offset: u64, comment: &str)
Stores reg at [sp, #offset] (call/scratch area fill); offsets
beyond the scaled immediate go through x8. reg must not be x8.
Sourcepub fn sp_address(&mut self, reg: &str, offset: u64, comment: &str)
pub fn sp_address(&mut self, reg: &str, offset: u64, comment: &str)
reg = sp + offset (argv base and friends).
Sourcepub fn global_load(&mut self, reg: &str, index: usize, comment: &str)
pub fn global_load(&mut self, reg: &str, index: usize, comment: &str)
Reads global slot index from the single g_globals array
(design §5.2); clobbers x8/x9.
pub fn global_store(&mut self, reg: &str, index: usize, comment: &str)
Sourcepub fn begin_function(&mut self)
pub fn begin_function(&mut self)
Opens a fresh function body buffer; instructions emitted until the
matching end_function go to it (design §6.1).
Sourcepub fn end_function(&mut self, frame: FunctionFrame)
pub fn end_function(&mut self, frame: FunctionFrame)
Closes the current function body: computes the frame from the final symbol count, splices prologue (fp/lr save, frame, spills, null initialization) and the shared epilogue, and appends the finished function (design §6, §6.1).