WIP - [artiq] More test

This commit is contained in:
David Mak 2024-08-15 11:52:26 +08:00
parent f09eb1bd98
commit 4ac60b4fc9
1 changed files with 28 additions and 90 deletions

View File

@ -652,101 +652,39 @@ fn format_rpc_ret<'ctx>(
Ok(ctx
.builder
// .build_int_compare(IntPredicate::EQ, i, llvm_usize.const_zero(), "")
.build_int_compare(IntPredicate::ULT, i, llvm_usize.const_int(2, false), "")
.build_int_compare(IntPredicate::EQ, i, llvm_usize.const_zero(), "")
// .build_int_compare(IntPredicate::ULT, i, llvm_usize.const_int(2, false), "")
.unwrap())
},
|generator, ctx| {
gen_if_callback(
generator,
// let data_ptr = ctx
// .builder
// .build_bitcast(
// phi.as_basic_value().into_pointer_value(),
// llvm_ret_ty.element_type(),
// "",
// )
// .unwrap()
// .into_pointer_value();
// ndarray.store_data(ctx, data_ptr);
call_memcpy_generic(
ctx,
|_, ctx| {
let i = ctx
.builder
.build_load(i_addr, "")
.map(BasicValueEnum::into_int_value)
.unwrap();
ndarray.ptr_to_data(ctx),
phi.as_basic_value().into_pointer_value(),
llvm_pdata_sizeof,
llvm_i1.const_zero(),
);
Ok(ctx
.builder
.build_int_compare(IntPredicate::EQ, i, llvm_usize.const_zero(), "")
.unwrap())
},
|generator, ctx| {
// 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,
)
};
call_memcpy_generic(
ctx,
ndarray.dim_sizes().base_ptr(ctx, generator),
pbuffer_dims_begin,
dims_buf_sz,
llvm_i1.const_zero(),
);
ndarray.create_data(
ctx,
llvm_elem_ty,
call_ndarray_calc_size(
generator,
ctx,
&ndarray.dim_sizes(),
(None, None),
),
);
Ok(())
},
|generator, ctx| {
let cpy_size = ctx
.builder
.build_int_mul(
call_ndarray_calc_size(
generator,
ctx,
&ndarray.dim_sizes(),
(None, None),
),
llvm_elem_sizeof,
"",
)
.unwrap();
// call_memset(
// ctx,
// ctx.builder.build_bitcast(
// ndarray.data().base_ptr(ctx, generator),
// llvm_pi8,
// "",
// ).map(BasicValueEnum::into_pointer_value).unwrap(),
// llvm_i8.const_zero(),
// cpy_size,
// llvm_i1.const_zero(),
// );
call_memcpy_generic(
ctx,
ndarray.data().base_ptr(ctx, generator),
buffer.base_ptr(ctx, generator),
cpy_size,
llvm_i1.const_zero(),
);
Ok(())
},
)
.unwrap();
let pbuffer_dims_begin = unsafe {
buffer.ptr_offset_unchecked(ctx, generator, &llvm_pdata_sizeof, None)
};
call_memcpy_generic(
ctx,
ndarray.dim_sizes().base_ptr(ctx, generator),
pbuffer_dims_begin,
dims_buf_sz,
llvm_i1.const_zero(),
);
Ok(())
},