From 60c0504bdf727b6643fbd5eecff14f01cf08c64e Mon Sep 17 00:00:00 2001 From: Brandon Fish Date: Sat, 4 May 2019 12:07:21 -0500 Subject: [PATCH] Implement llvm returns in function code generator finalize --- lib/llvm-backend/src/code.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/llvm-backend/src/code.rs b/lib/llvm-backend/src/code.rs index 8745f7e38..a65cb25d1 100644 --- a/lib/llvm-backend/src/code.rs +++ b/lib/llvm-backend/src/code.rs @@ -4610,6 +4610,21 @@ impl FunctionCodeGenerator for LLVMFunctionCodeGenerator { } fn finalize(&mut self) -> Result<(), CodegenError> { + let results = self.state.popn_save(self.func_sig.returns().len())?; + + match results.as_slice() { + [] => { + self.builder.build_return(None); + } + [one_value] => { + self.builder.build_return(Some(one_value)); + } + _ => { + // let struct_ty = llvm_sig.get_return_type().as_struct_type(); + // let ret_struct = struct_ty.const_zero(); + unimplemented!("multi-value returns not yet implemented") + } + } Ok(()) } }