From 1e5b68fc045f8ba0e98db044b1d7613aa47d7c71 Mon Sep 17 00:00:00 2001 From: David Mak Date: Thu, 15 Aug 2024 05:13:17 +0800 Subject: [PATCH] WIP - [artiq] Test --- nac3artiq/src/codegen.rs | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/nac3artiq/src/codegen.rs b/nac3artiq/src/codegen.rs index 897b3748..f8ef5fae 100644 --- a/nac3artiq/src/codegen.rs +++ b/nac3artiq/src/codegen.rs @@ -606,24 +606,11 @@ fn format_rpc_ret<'ctx>( // let buffer_size = // ctx.builder.build_int_add(dims_buf_sz, llvm_pdata_sizeof, "").unwrap(); 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 = - ctx.builder.build_array_alloca(llvm_i8, buffer_size, "rpc.buffer").unwrap(); - let buffer = ArraySliceValue::from_ptr_val(buffer, buffer_size, Some("rpc.buffer")); + ctx.builder.build_array_alloca(llvm_pi8, buffer_size, "rpc.buffer").unwrap(); + 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(); ctx.builder.build_unconditional_branch(head_bb).unwrap(); @@ -692,7 +679,7 @@ fn format_rpc_ret<'ctx>( // dims_buf_sz, // llvm_i1.const_zero(), // ); - + // dims=(10): bufsize = 32 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.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 = - 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)]); let i = ctx.builder.build_load(i_addr, "i").map(BasicValueEnum::into_int_value).unwrap();