From 6d03c953ef578eb04b4d430c9fbd4d946a3d1e06 Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 15 Aug 2024 15:11:47 +0800 Subject: [PATCH] [artiq] WIP --- nac3artiq/src/codegen.rs | 53 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index dc07c836..66a1de43 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -544,6 +544,7 @@ fn format_rpc_ret<'ctx>( let llvm_i8 = ctx.ctx.i8_type(); let llvm_i32 = ctx.ctx.i32_type(); + let llvm_i8_8 = llvm_i8.array_type(8); let llvm_pi8 = llvm_i8.ptr_type(AddressSpace::default()); let rpc_recv = ctx.module.get_function("rpc_recv").unwrap_or_else(|| { @@ -623,7 +624,7 @@ fn format_rpc_ret<'ctx>( let buffer_size = round_up(ctx, buffer_size, ctx.ctx.i64_type()); let buffer = - ctx.builder.build_array_alloca(llvm_pi8, buffer_size, "rpc.buffer").unwrap(); + ctx.builder.build_array_alloca(llvm_i8_8, buffer_size, "rpc.buffer").unwrap(); let buffer = ctx .builder .build_bitcast(buffer, llvm_pi8, "") @@ -661,17 +662,17 @@ fn format_rpc_ret<'ctx>( }, |generator, ctx| { 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), - pbuffer_data_begin, - llvm_pdata_sizeof, - llvm_i1.const_zero(), - ); + // 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), + // pbuffer_data_begin, + // llvm_pdata_sizeof, + // llvm_i1.const_zero(), + // ); let pbuffer_dims_begin = unsafe { ctx.builder.build_in_bounds_gep(phi, &[llvm_pdata_sizeof], "") } @@ -684,20 +685,20 @@ 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(), - // ); + // 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(12, false), + llvm_i1.const_zero(), + ); Ok(()) },