From 3f14376778a3ddab715e56e58fa5d9d0a39cd21b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 4 Apr 2026 09:02:19 +0100 Subject: Implement resume in patio-to-cranelift --- patio-to-cranelift/src/lib.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/patio-to-cranelift/src/lib.rs b/patio-to-cranelift/src/lib.rs index 430df6ff..128fd459 100644 --- a/patio-to-cranelift/src/lib.rs +++ b/patio-to-cranelift/src/lib.rs @@ -11,7 +11,7 @@ use crate::{ PatioCompilationUnitElementValue, PatioFunctionDefinition, PatioIf, PatioInstruction, PatioInstructionValue, PatioIntAdd, PatioIntEquals, PatioIntNotEqual, PatioIntSub, PatioIntToBool, PatioIntValue, PatioIntValueValue, PatioLocal, PatioLocalRef, - PatioLocalStore, PatioLocalType, PatioOperand, PatioOperandValue, PatioReturn, + PatioLocalStore, PatioLocalType, PatioOperand, PatioOperandValue, PatioResume, PatioReturn, PatioReturnVoid, PatioVarLoad, PatioVarStore, PatioVisibility, }, }; @@ -244,6 +244,11 @@ fn compile_instruction( compile_local_store(local_store, context); } + PatioInstructionValue::PatioResume => { + let resume = instruction.value_as_patio_resume().unwrap(); + compile_resume(resume, context); + } + PatioInstructionValue::PatioReturn => { let return_ = instruction.value_as_patio_return().unwrap(); compile_return(return_, context); @@ -434,6 +439,12 @@ fn compile_local_store( def_destination(local_store.destination(), cranelift_value, context); } +fn compile_resume(resume: PatioResume<'_>, context: &mut CompilerFunctionContext<'_>) { + let cranelift_value = compile_operand(resume.value(), context); + + context.function_builder.ins().return_(&[cranelift_value]); +} + fn compile_return(return_: PatioReturn<'_>, context: &mut CompilerFunctionContext<'_>) { let cranelift_value = compile_operand(return_.value(), context); -- cgit v1.2.3