From fbea04750bd7d2f758e32e398e0b92d6cf2cca15 Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 15 Aug 2024 10:52:50 +0800 Subject: [PATCH] WIP - [artiq] create data first --- nac3artiq/src/codegen.rs | 27 ++++++--------------------- nac3core/src/codegen/classes.rs | 2 +- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index 7eac21fe..3e70a446 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -642,17 +642,12 @@ fn format_rpc_ret<'ctx>( .unwrap()) }, |generator, ctx| { - // call_memset( - // ctx, - // ctx.builder.build_bitcast( - // ndarray.data().base_ptr(ctx, generator), - // llvm_pi8, - // "", - // ).unwrap().into_pointer_value(), - // llvm_i8.const_zero(), - // llvm_usize.const_int(4, false), - // llvm_i1.const_zero(), - // ); + let data_ptr = ctx.builder.build_bitcast( + buffer.base_ptr(ctx, generator), + llvm_ret_ty.element_type(), + "", + ).unwrap().into_pointer_value(); + ndarray.store_data(ctx, data_ptr); let pbuffer_dims_begin = unsafe { buffer.ptr_offset_unchecked(ctx, generator, &llvm_pdata_sizeof, None) @@ -665,16 +660,6 @@ fn format_rpc_ret<'ctx>( llvm_i1.const_zero(), ); - ndarray.create_data(ctx, llvm_elem_ty, call_ndarray_calc_size(generator, ctx, &ndarray.dim_sizes(), (None, None))); - - call_memcpy_generic( - ctx, - ndarray.ptr_to_data(ctx), - buffer.base_ptr(ctx, generator), - llvm_pdata_sizeof, - llvm_i1.const_zero(), - ); - Ok(()) }, |_, _| Ok(()), diff --git a/nac3core/src/codegen/classes.rs b/nac3core/src/codegen/classes.rs index e52b3505..b6d3f2fa 100644 --- a/nac3core/src/codegen/classes.rs +++ b/nac3core/src/codegen/classes.rs @@ -1420,7 +1420,7 @@ impl<'ctx> NDArrayValue<'ctx> { } /// Stores the array of data elements `data` into this instance. - fn store_data(&self, ctx: &CodeGenContext<'ctx, '_>, data: PointerValue<'ctx>) { + pub fn store_data(&self, ctx: &CodeGenContext<'ctx, '_>, data: PointerValue<'ctx>) { ctx.builder.build_store(self.ptr_to_data(ctx), data).unwrap(); }