[artiq] WIP

This commit is contained in:
David Mak 2024-08-15 12:53:33 +08:00
parent 99f7a8b4f3
commit 9f577845b2
2 changed files with 15 additions and 16 deletions

View File

@ -487,13 +487,13 @@ fn format_rpc_arg<'ctx>(
let buffer = ctx.builder.build_array_alloca(llvm_i8, buffer_size, "rpc.arg").unwrap(); let buffer = ctx.builder.build_array_alloca(llvm_i8, buffer_size, "rpc.arg").unwrap();
let buffer = ArraySliceValue::from_ptr_val(buffer, buffer_size, Some("rpc.arg")); let buffer = ArraySliceValue::from_ptr_val(buffer, buffer_size, Some("rpc.arg"));
// let ppdata = generator.gen_var_alloc(ctx, llvm_arg_ty.element_type(), None).unwrap(); let ppdata = generator.gen_var_alloc(ctx, llvm_arg_ty.element_type(), None).unwrap();
// ctx.builder.build_store(ppdata, llvm_arg.data().base_ptr(ctx, generator)).unwrap(); ctx.builder.build_store(ppdata, llvm_arg.data().base_ptr(ctx, generator)).unwrap();
call_memcpy_generic( call_memcpy_generic(
ctx, ctx,
buffer.base_ptr(ctx, generator), buffer.base_ptr(ctx, generator),
llvm_arg.ptr_to_data(ctx), ppdata,
llvm_pdata_sizeof, llvm_pdata_sizeof,
llvm_i1.const_zero(), llvm_i1.const_zero(),
); );
@ -548,7 +548,6 @@ fn format_rpc_ret<'ctx>(
let llvm_i8 = ctx.ctx.i8_type(); let llvm_i8 = ctx.ctx.i8_type();
let llvm_i32 = ctx.ctx.i32_type(); let llvm_i32 = ctx.ctx.i32_type();
let llvm_pi8 = llvm_i8.ptr_type(AddressSpace::default()); let llvm_pi8 = llvm_i8.ptr_type(AddressSpace::default());
let llvm_ppi8 = llvm_pi8.ptr_type(AddressSpace::default());
let rpc_recv = ctx.module.get_function("rpc_recv").unwrap_or_else(|| { let rpc_recv = ctx.module.get_function("rpc_recv").unwrap_or_else(|| {
ctx.module.add_function("rpc_recv", llvm_i32.fn_type(&[llvm_pi8.into()], false), None) ctx.module.add_function("rpc_recv", llvm_i32.fn_type(&[llvm_pi8.into()], false), None)
@ -672,21 +671,21 @@ fn format_rpc_ret<'ctx>(
.builder .builder
.build_load( .build_load(
ctx.builder ctx.builder
.build_bitcast(data_addr, llvm_ppi8, "") .build_bitcast(data_addr, llvm_ret_ty.element_type().ptr_type(AddressSpace::default()), "")
.unwrap() .unwrap()
.into_pointer_value(), .into_pointer_value(),
"", "",
) )
.unwrap() .unwrap()
.into_pointer_value(); .into_pointer_value();
// call_memcpy_generic(
call_memcpy_generic( // ctx,
ctx, // ndarray.ptr_to_data(ctx),
ndarray.ptr_to_data(ctx), // data_addr,
data_addr, // llvm_pdata_sizeof,
llvm_pdata_sizeof, // llvm_i1.const_zero(),
llvm_i1.const_zero(), // );
); ndarray.store_data(ctx, data_addr);
let pbuffer_dims_begin = unsafe { let pbuffer_dims_begin = unsafe {
buffer.ptr_offset_unchecked(ctx, generator, &llvm_pdata_sizeof, None) buffer.ptr_offset_unchecked(ctx, generator, &llvm_pdata_sizeof, None)

View File

@ -1330,7 +1330,7 @@ impl<'ctx> NDArrayValue<'ctx> {
} }
/// Returns the pointer to the field storing the number of dimensions of this `NDArray`. /// Returns the pointer to the field storing the number of dimensions of this `NDArray`.
pub fn ptr_to_ndims(&self, ctx: &CodeGenContext<'ctx, '_>) -> PointerValue<'ctx> { fn ptr_to_ndims(&self, ctx: &CodeGenContext<'ctx, '_>) -> PointerValue<'ctx> {
let llvm_i32 = ctx.ctx.i32_type(); let llvm_i32 = ctx.ctx.i32_type();
let var_name = self.name.map(|v| format!("{v}.ndims.addr")).unwrap_or_default(); let var_name = self.name.map(|v| format!("{v}.ndims.addr")).unwrap_or_default();
@ -1366,7 +1366,7 @@ impl<'ctx> NDArrayValue<'ctx> {
/// Returns the double-indirection pointer to the `dims` array, as if by calling `getelementptr` /// Returns the double-indirection pointer to the `dims` array, as if by calling `getelementptr`
/// on the field. /// on the field.
pub fn ptr_to_dims(&self, ctx: &CodeGenContext<'ctx, '_>) -> PointerValue<'ctx> { fn ptr_to_dims(&self, ctx: &CodeGenContext<'ctx, '_>) -> PointerValue<'ctx> {
let llvm_i32 = ctx.ctx.i32_type(); let llvm_i32 = ctx.ctx.i32_type();
let var_name = self.name.map(|v| format!("{v}.dims.addr")).unwrap_or_default(); let var_name = self.name.map(|v| format!("{v}.dims.addr")).unwrap_or_default();
@ -1404,7 +1404,7 @@ impl<'ctx> NDArrayValue<'ctx> {
/// Returns the double-indirection pointer to the `data` array, as if by calling `getelementptr` /// Returns the double-indirection pointer to the `data` array, as if by calling `getelementptr`
/// on the field. /// on the field.
pub fn ptr_to_data(&self, ctx: &CodeGenContext<'ctx, '_>) -> PointerValue<'ctx> { fn ptr_to_data(&self, ctx: &CodeGenContext<'ctx, '_>) -> PointerValue<'ctx> {
let llvm_i32 = ctx.ctx.i32_type(); let llvm_i32 = ctx.ctx.i32_type();
let var_name = self.name.map(|v| format!("{v}.data.addr")).unwrap_or_default(); let var_name = self.name.map(|v| format!("{v}.data.addr")).unwrap_or_default();