WIP - [artiq] create data first

This commit is contained in:
David Mak 2024-08-15 10:52:50 +08:00
parent 685f1849b1
commit fbea04750b
2 changed files with 7 additions and 22 deletions

View File

@ -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(()),

View File

@ -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();
}