This commit is contained in:
David Mak 2024-08-13 17:43:44 +08:00
parent 3e666af206
commit 07faed6779
1 changed files with 15 additions and 5 deletions

View File

@ -31,7 +31,7 @@ use crate::{symbol_resolver::InnerResolver, timeline::TimeFns};
use inkwell::types::BasicType; use inkwell::types::BasicType;
use itertools::Itertools; use itertools::Itertools;
use nac3core::codegen::classes::{ArrayLikeIndexer, ArrayLikeValue, NDArrayType}; use nac3core::codegen::classes::{ArrayLikeIndexer, ArrayLikeValue, ArraySliceValue, NDArrayType};
use nac3core::codegen::llvm_intrinsics; use nac3core::codegen::llvm_intrinsics;
use std::{ use std::{
collections::{hash_map::DefaultHasher, HashMap}, collections::{hash_map::DefaultHasher, HashMap},
@ -552,8 +552,18 @@ fn rpc_codegen_callback_fn<'ctx>(
NDArrayType::new(generator, ctx.ctx, ctx.get_llvm_type(generator, elem_ty)); NDArrayType::new(generator, ctx.ctx, ctx.get_llvm_type(generator, elem_ty));
let llvm_arg = NDArrayValue::from_ptr_val(arg.into_pointer_value(), size_type, None); let llvm_arg = NDArrayValue::from_ptr_val(arg.into_pointer_value(), size_type, None);
let llvm_usize_sizeof = llvm_arg_ty.size_type().size_of(); let llvm_usize_sizeof = ctx
let llvm_elem_sizeof = llvm_arg_ty.element_type().size_of().unwrap(); .builder
.build_int_truncate_or_bit_cast(llvm_arg_ty.size_type().size_of(), int32, "")
.unwrap();
let llvm_elem_sizeof = ctx
.builder
.build_int_truncate_or_bit_cast(
llvm_arg_ty.element_type().size_of().unwrap(),
int32,
"",
)
.unwrap();
let dims_buf_sz = let dims_buf_sz =
ctx.builder.build_int_mul(llvm_arg.load_ndims(ctx), llvm_usize_sizeof, "").unwrap(); ctx.builder.build_int_mul(llvm_arg.load_ndims(ctx), llvm_usize_sizeof, "").unwrap();
@ -568,8 +578,8 @@ fn rpc_codegen_callback_fn<'ctx>(
let buffer_size = ctx.builder.build_int_add(dims_buf_sz, data_buf_sz, "").unwrap(); let buffer_size = ctx.builder.build_int_add(dims_buf_sz, data_buf_sz, "").unwrap();
let buffer = let buffer = ctx.builder.build_array_alloca(int8, buffer_size, "").unwrap();
generator.gen_array_var_alloc(ctx, int8.into(), buffer_size, None).unwrap(); let buffer = ArraySliceValue::from_ptr_val(buffer, buffer_size, None);
llvm_intrinsics::call_memcpy_generic( llvm_intrinsics::call_memcpy_generic(
ctx, ctx,