From 405d0d0de3d6b72c44c015ff91928e687fa8659c Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 15 Aug 2024 13:18:35 +0800 Subject: [PATCH] [artiq] WIP --- nac3artiq/src/codegen.rs | 61 +++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index 4f16acf9..9b3e9a6f 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -647,26 +647,32 @@ fn format_rpc_ret<'ctx>( .unwrap()) }, |generator, ctx| { - 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, "") - .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 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(), + // ); + // call_memcpy_generic( + // ctx, + // ndarray.ptr_to_data(ctx), + // buffer.base_ptr(ctx, generator), + // llvm_pdata_sizeof, + // llvm_i1.const_zero(), + // ); let pbuffer_dims_begin = unsafe { buffer.ptr_offset_unchecked(ctx, generator, &llvm_pdata_sizeof, None) @@ -679,6 +685,21 @@ fn format_rpc_ret<'ctx>( llvm_i1.const_zero(), ); + // TODO: Testing for buffer + ndarray.create_data( + ctx, + llvm_elem_ty, + call_ndarray_calc_size(generator, ctx, &ndarray.dim_sizes(), (None, None)), + ); + + call_memcpy_generic( + ctx, + ndarray.data().base_ptr(ctx, generator), + buffer.base_ptr(ctx, generator), + llvm_usize.const_int(8, false), + llvm_i1.const_zero(), + ); + Ok(()) }, |_, _| Ok(()),