added returning & more asm instructions
This commit is contained in:
@@ -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)>,
|
||||
},
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user