added returning & more asm instructions

This commit is contained in:
2025-03-22 16:54:28 -04:00
parent 7f809d797c
commit 6c2f4e814f
11 changed files with 176 additions and 43 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ pub struct IRLFunction {
pub instructions: Vec<IRLInstruction>,
pub stack: HashMap<VarID, Size>,
pub args: Vec<(VarID, Size)>,
pub ret_size: Size,
pub makes_call: bool,
}
@@ -34,7 +35,7 @@ pub enum IRLInstruction {
len: Len,
},
Call {
dest: VarID,
dest: Option<(VarID, Size)>,
f: Symbol,
args: Vec<(VarID, Size)>,
},
+8 -1
View File
@@ -106,8 +106,14 @@ impl IRLProgram {
makes_call = true;
let fid = &p.fn_map[&f.id];
let sym = builder.func(fid);
let ret_size = p.size_of_var(dest.id).expect("unsized type");
let dest = if ret_size > 0 {
Some((dest.id, ret_size))
} else {
None
};
instrs.push(IRLInstruction::Call {
dest: dest.id,
dest,
f: sym,
args: args
.iter()
@@ -135,6 +141,7 @@ impl IRLProgram {
.iter()
.map(|a| (*a, p.size_of_var(*a).expect("unsized type")))
.collect(),
ret_size: p.size_of_type(&f.ret).expect("unsized type"),
stack,
},
);