WIP - [artiq] Test

This commit is contained in:
David Mak 2024-08-15 05:13:17 +08:00
parent 4b6e5e488e
commit 1e5b68fc04
1 changed files with 6 additions and 32 deletions

View File

@ -606,24 +606,11 @@ fn format_rpc_ret<'ctx>(
// let buffer_size = // let buffer_size =
// ctx.builder.build_int_add(dims_buf_sz, llvm_pdata_sizeof, "").unwrap(); // ctx.builder.build_int_add(dims_buf_sz, llvm_pdata_sizeof, "").unwrap();
let buffer_size = llvm_usize.const_int(32, false); let buffer_size = llvm_usize.const_int(32, false);
// let buffer_size = ctx.builder.build_left_shift(
// ctx.builder.build_int_add(
// ctx.builder.build_right_shift(
// buffer_size,
// llvm_usize.const_int(2, false),
// false,
// "",
// ).unwrap(),
// llvm_usize.const_int(1, false),
// "",
// ).unwrap(),
// llvm_usize.const_int(2, false),
// "",
// ).unwrap();
let buffer = let buffer =
ctx.builder.build_array_alloca(llvm_i8, buffer_size, "rpc.buffer").unwrap(); ctx.builder.build_array_alloca(llvm_pi8, buffer_size, "rpc.buffer").unwrap();
let buffer = ArraySliceValue::from_ptr_val(buffer, buffer_size, Some("rpc.buffer")); let buffer = ctx.builder.build_bitcast(buffer, llvm_pi8, "").map(BasicValueEnum::into_pointer_value).unwrap();
let buffer = ArraySliceValue::from_ptr_val(buffer, buffer_size, Some("rpc.buffer.ptr"));
let i_addr = ctx.builder.build_alloca(llvm_usize, "i.addr").unwrap(); let i_addr = ctx.builder.build_alloca(llvm_usize, "i.addr").unwrap();
ctx.builder.build_unconditional_branch(head_bb).unwrap(); ctx.builder.build_unconditional_branch(head_bb).unwrap();
@ -692,7 +679,7 @@ fn format_rpc_ret<'ctx>(
// dims_buf_sz, // dims_buf_sz,
// llvm_i1.const_zero(), // llvm_i1.const_zero(),
// ); // );
// dims=(10): bufsize = 32 // dims=(10): bufsize = 32
let sz = call_ndarray_calc_size(generator, ctx, &ndarray.dim_sizes(), (None, None)); let sz = call_ndarray_calc_size(generator, ctx, &ndarray.dim_sizes(), (None, None));
@ -755,22 +742,9 @@ fn format_rpc_ret<'ctx>(
ctx.builder.build_conditional_branch(is_done, tail_bb, alloc_bb).unwrap(); ctx.builder.build_conditional_branch(is_done, tail_bb, alloc_bb).unwrap();
ctx.builder.position_at_end(alloc_bb); ctx.builder.position_at_end(alloc_bb);
let alloc_size = ctx.builder.build_left_shift(
ctx.builder.build_int_add(
ctx.builder.build_right_shift(
alloc_size,
llvm_usize.const_int(2, false),
false,
"",
).unwrap(),
llvm_usize.const_int(1, false),
"",
).unwrap(),
llvm_usize.const_int(2, false),
"",
).unwrap();
let alloc_ptr = let alloc_ptr =
ctx.builder.build_array_alloca(llvm_i8, alloc_size, "rpc.alloc").unwrap(); ctx.builder.build_array_alloca(llvm_pi8, alloc_size, "rpc.alloc").unwrap();
let alloc_ptr = ctx.builder.build_bitcast(alloc_ptr, llvm_pi8, "").map(BasicValueEnum::into_pointer_value).unwrap();
phi.add_incoming(&[(&alloc_ptr, alloc_bb)]); phi.add_incoming(&[(&alloc_ptr, alloc_bb)]);
let i = let i =
ctx.builder.build_load(i_addr, "i").map(BasicValueEnum::into_int_value).unwrap(); ctx.builder.build_load(i_addr, "i").map(BasicValueEnum::into_int_value).unwrap();