WIP - Constants

This commit is contained in:
David Mak 2024-08-13 17:51:26 +08:00
parent 07faed6779
commit 75ac769df4
1 changed files with 31 additions and 16 deletions

View File

@ -581,23 +581,38 @@ fn rpc_codegen_callback_fn<'ctx>(
let buffer = ctx.builder.build_array_alloca(int8, buffer_size, "").unwrap();
let buffer = ArraySliceValue::from_ptr_val(buffer, buffer_size, None);
llvm_intrinsics::call_memcpy_generic(
for (offset, byte) in
[0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 0u8, 1u8].into_iter().enumerate()
{
let pbuffer = unsafe {
buffer.ptr_offset_unchecked(
ctx,
buffer.base_ptr(ctx, generator),
llvm_arg.dim_sizes().base_ptr(ctx, generator),
dims_buf_sz,
int1.const_zero(),
);
generator,
&size_type.const_int(offset as u64, false),
None,
)
};
let pbuffer_data_begin =
unsafe { buffer.ptr_offset_unchecked(ctx, generator, &dims_buf_sz, None) };
llvm_intrinsics::call_memcpy_generic(
ctx,
pbuffer_data_begin,
llvm_arg.data().base_ptr(ctx, generator),
data_buf_sz,
int1.const_zero(),
);
ctx.builder.build_store(pbuffer, int8.const_int(byte as u64, false)).unwrap();
}
// llvm_intrinsics::call_memcpy_generic(
// ctx,
// buffer.base_ptr(ctx, generator),
// llvm_arg.dim_sizes().base_ptr(ctx, generator),
// dims_buf_sz,
// int1.const_zero(),
// );
//
// let pbuffer_data_begin =
// unsafe { buffer.ptr_offset_unchecked(ctx, generator, &dims_buf_sz, None) };
// llvm_intrinsics::call_memcpy_generic(
// ctx,
// pbuffer_data_begin,
// llvm_arg.data().base_ptr(ctx, generator),
// data_buf_sz,
// int1.const_zero(),
// );
buffer.base_ptr(ctx, generator)
} else {