WIP - Constants
This commit is contained in:
parent
07faed6779
commit
e996e1f4d2
|
@ -32,7 +32,6 @@ 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, ArraySliceValue, NDArrayType};
|
use nac3core::codegen::classes::{ArrayLikeIndexer, ArrayLikeValue, ArraySliceValue, NDArrayType};
|
||||||
use nac3core::codegen::llvm_intrinsics;
|
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map::DefaultHasher, HashMap},
|
collections::{hash_map::DefaultHasher, HashMap},
|
||||||
hash::{Hash, Hasher},
|
hash::{Hash, Hasher},
|
||||||
|
@ -431,7 +430,8 @@ fn gen_rpc_tag(
|
||||||
);
|
);
|
||||||
|
|
||||||
buffer.push(b'a');
|
buffer.push(b'a');
|
||||||
buffer.push((ndarray_ndims & 0xFF) as u8);
|
buffer.push(1u8);
|
||||||
|
// buffer.push((ndarray_ndims & 0xFF) as u8);
|
||||||
gen_rpc_tag(ctx, ndarray_dtype, buffer)?;
|
gen_rpc_tag(ctx, ndarray_dtype, buffer)?;
|
||||||
}
|
}
|
||||||
_ => return Err(format!("Unsupported type: {:?}", ctx.unifier.stringify(ty))),
|
_ => return Err(format!("Unsupported type: {:?}", ctx.unifier.stringify(ty))),
|
||||||
|
@ -578,26 +578,50 @@ 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 = ctx.builder.build_array_alloca(int8, buffer_size, "").unwrap();
|
// let buffer = ctx.builder.build_array_alloca(int8, buffer_size, "").unwrap();
|
||||||
|
let buffer = ctx.builder.build_array_alloca(int8, size_type.const_int(28, false), "").unwrap();
|
||||||
let buffer = ArraySliceValue::from_ptr_val(buffer, buffer_size, None);
|
let buffer = ArraySliceValue::from_ptr_val(buffer, buffer_size, None);
|
||||||
|
|
||||||
llvm_intrinsics::call_memcpy_generic(
|
for (offset, byte) in [
|
||||||
|
/* LSB <-> MSB */
|
||||||
|
/* buffer[0] */ 0x01u8, 0x00u8, 0x00u8, 0x00u8,
|
||||||
|
/* buffer[4] */ 0x04u8, 0x00u8, 0x00u8, 0x00u8,
|
||||||
|
/* buffer[8] */ 0x00u8, 0x00u8, 0x00u8, 0x00u8,
|
||||||
|
/* buffer[12] */ 0x00u8, 0x00u8, 0x00u8, 0x00u8,
|
||||||
|
/* buffer[16] */ 0x00u8, 0x00u8, 0x00u8, 0x00u8,
|
||||||
|
/* buffer[20] */ 0x00u8, 0x00u8, 0x00u8, 0x00u8,
|
||||||
|
/* buffer[24] */ 0x00u8, 0x00u8, 0x00u8, 0x00u8,
|
||||||
|
].into_iter().enumerate()
|
||||||
|
{
|
||||||
|
let pbuffer = unsafe {
|
||||||
|
buffer.ptr_offset_unchecked(
|
||||||
ctx,
|
ctx,
|
||||||
buffer.base_ptr(ctx, generator),
|
generator,
|
||||||
llvm_arg.dim_sizes().base_ptr(ctx, generator),
|
&size_type.const_int(offset as u64, false),
|
||||||
dims_buf_sz,
|
None,
|
||||||
int1.const_zero(),
|
)
|
||||||
);
|
};
|
||||||
|
|
||||||
let pbuffer_data_begin =
|
ctx.builder.build_store(pbuffer, int8.const_int(byte as u64, false)).unwrap();
|
||||||
unsafe { buffer.ptr_offset_unchecked(ctx, generator, &dims_buf_sz, None) };
|
}
|
||||||
llvm_intrinsics::call_memcpy_generic(
|
|
||||||
ctx,
|
// llvm_intrinsics::call_memcpy_generic(
|
||||||
pbuffer_data_begin,
|
// ctx,
|
||||||
llvm_arg.data().base_ptr(ctx, generator),
|
// buffer.base_ptr(ctx, generator),
|
||||||
data_buf_sz,
|
// llvm_arg.dim_sizes().base_ptr(ctx, generator),
|
||||||
int1.const_zero(),
|
// 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)
|
buffer.base_ptr(ctx, generator)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue