From d91fae90d0e73d3ed3146a765b6fb9d9d2d1f721 Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 15 Aug 2024 12:08:10 +0800 Subject: [PATCH] WIP - [artiq] Double indirection? --- nac3artiq/src/codegen.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index 0b76860a..6d2d9e42 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -549,6 +549,7 @@ fn format_rpc_ret<'ctx>( let llvm_i8 = ctx.ctx.i8_type(); let llvm_i32 = ctx.ctx.i32_type(); let llvm_pi8 = llvm_i8.ptr_type(AddressSpace::default()); + let llvm_ppi8 = llvm_pi8.ptr_type(AddressSpace::default()); let rpc_recv = ctx.module.get_function("rpc_recv").unwrap_or_else(|| { ctx.module.add_function("rpc_recv", llvm_i32.fn_type(&[llvm_pi8.into()], false), None) @@ -667,10 +668,23 @@ fn format_rpc_ret<'ctx>( // .unwrap() // .into_pointer_value(); // ndarray.store_data(ctx, data_ptr); + let data_addr = phi.as_basic_value().into_pointer_value(); + let data_addr = ctx + .builder + .build_load( + ctx.builder + .build_bitcast(data_addr, llvm_ppi8, "") + .unwrap() + .into_pointer_value(), + "", + ) + .unwrap() + .into_pointer_value(); + call_memcpy_generic( ctx, ndarray.ptr_to_data(ctx), - phi.as_basic_value().into_pointer_value(), + data_addr, llvm_pdata_sizeof, llvm_i1.const_zero(), );