From f3e21c8dcb2724a374f9570a3870be6d6f219ea8 Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 15 Aug 2024 13:44:31 +0800 Subject: [PATCH] [artiq] WIP --- nac3artiq/src/codegen.rs | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index c86766e9..008e3344 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -647,36 +647,22 @@ fn format_rpc_ret<'ctx>( .unwrap()) }, |generator, ctx| { - // let data_addr = ctx - // .builder - // .build_load( - // ctx.builder - // .build_bitcast(data_addr, llvm_ppi8, "") - // .map(BasicValueEnum::into_pointer_value) - // .unwrap(), - // "", - // ) - // .map(BasicValueEnum::into_pointer_value) - // .unwrap(); - // - // call_memcpy_generic( - // ctx, - // ndarray.ptr_to_data(ctx), - // data_addr, - // llvm_pdata_sizeof, - // llvm_i1.const_zero(), - // ); + let phi = phi.as_basic_value().into_pointer_value(); + let pbuffer_data_begin = unsafe { + ctx.builder.build_in_bounds_gep(phi, &[llvm_usize.const_int(8, false)], "") + } + .unwrap(); call_memcpy_generic( ctx, ndarray.ptr_to_data(ctx), - buffer.base_ptr(ctx, generator), + pbuffer_data_begin, llvm_pdata_sizeof, llvm_i1.const_zero(), ); - let pbuffer_dims_begin = unsafe { - buffer.ptr_offset_unchecked(ctx, generator, &llvm_pdata_sizeof, None) - }; + let pbuffer_dims_begin = + unsafe { ctx.builder.build_in_bounds_gep(phi, &[llvm_pdata_sizeof], "") } + .unwrap(); call_memcpy_generic( ctx, ndarray.dim_sizes().base_ptr(ctx, generator), @@ -760,7 +746,6 @@ fn format_rpc_ret<'ctx>( ctx.builder.build_unconditional_branch(head_bb).unwrap(); ctx.builder.position_at_end(tail_bb); - ctx.builder.build_load(slot, "rpc.result").unwrap() } };