Browse Source

Add `Return`

pull/397/head
Jef 6 years ago
parent
commit
9decdca525
  1. 3
      src/backend.rs
  2. 12
      src/function_body.rs

3
src/backend.rs

@ -597,7 +597,8 @@ pub fn drop(ctx: &mut Context) {
);
}
StackValue::Temp(gpr) => free_value(ctx, Value::Temp(gpr)),
_ => {}
StackValue::Local(loc) => free_value(ctx, Value::Local(loc)),
StackValue::Immediate(imm) => free_value(ctx, Value::Immediate(imm)),
}
}

12
src/function_body.rs

@ -169,6 +169,18 @@ pub fn translate(
ty,
));
}
Operator::Return => {
control_frames
.last_mut()
.expect("control stack is never empty")
.mark_unreachable();
let control_frame = control_frames.get(0).expect("control stack is never empty");
return_from_block(ctx, control_frame.arity(), true);
br(ctx, control_frame.kind.branch_target());
}
Operator::Br { relative_depth } => {
control_frames
.last_mut()

Loading…
Cancel
Save