[artiq] WIP
This commit is contained in:
parent
1cd5439f87
commit
c19e3afe26
|
@ -32,6 +32,7 @@ use pyo3::{
|
||||||
|
|
||||||
use crate::{symbol_resolver::InnerResolver, timeline::TimeFns};
|
use crate::{symbol_resolver::InnerResolver, timeline::TimeFns};
|
||||||
|
|
||||||
|
use inkwell::values::IntValue;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{hash_map::DefaultHasher, HashMap},
|
collections::{hash_map::DefaultHasher, HashMap},
|
||||||
|
@ -544,7 +545,6 @@ fn format_rpc_ret<'ctx>(
|
||||||
let llvm_i8 = ctx.ctx.i8_type();
|
let llvm_i8 = ctx.ctx.i8_type();
|
||||||
let llvm_i32 = ctx.ctx.i32_type();
|
let llvm_i32 = ctx.ctx.i32_type();
|
||||||
let llvm_pi8 = llvm_i8.ptr_type(AddressSpace::default());
|
let llvm_pi8 = llvm_i8.ptr_type(AddressSpace::default());
|
||||||
let llvm_ppi8 = llvm_pi8.ptr_type(AddressSpace::default());
|
|
||||||
|
|
||||||
let rpc_recv = ctx.module.get_function("rpc_recv").unwrap_or_else(|| {
|
let rpc_recv = ctx.module.get_function("rpc_recv").unwrap_or_else(|| {
|
||||||
ctx.module.add_function("rpc_recv", llvm_i32.fn_type(&[llvm_pi8.into()], false), None)
|
ctx.module.add_function("rpc_recv", llvm_i32.fn_type(&[llvm_pi8.into()], false), None)
|
||||||
|
@ -568,6 +568,24 @@ fn format_rpc_ret<'ctx>(
|
||||||
let llvm_i1 = ctx.ctx.bool_type();
|
let llvm_i1 = ctx.ctx.bool_type();
|
||||||
let llvm_usize = generator.get_size_type(ctx.ctx);
|
let llvm_usize = generator.get_size_type(ctx.ctx);
|
||||||
|
|
||||||
|
let round_up = |ctx: &mut CodeGenContext<'ctx, '_>,
|
||||||
|
val: IntValue<'ctx>,
|
||||||
|
power_of_two: IntType<'ctx>| {
|
||||||
|
debug_assert!((power_of_two.get_bit_width() / 8).is_power_of_two());
|
||||||
|
|
||||||
|
let llvm_val_t = val.get_type();
|
||||||
|
|
||||||
|
let max_rem = (power_of_two.get_bit_width() / 8) - 1;
|
||||||
|
let max_rem = llvm_val_t.const_int(max_rem as u64, false);
|
||||||
|
ctx.builder
|
||||||
|
.build_and(
|
||||||
|
ctx.builder.build_int_add(val, max_rem, "").unwrap(),
|
||||||
|
ctx.builder.build_not(max_rem, "").unwrap(),
|
||||||
|
"",
|
||||||
|
)
|
||||||
|
.unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
let (elem_ty, ndims) = unpack_ndarray_var_tys(&mut ctx.unifier, ret_ty);
|
let (elem_ty, ndims) = unpack_ndarray_var_tys(&mut ctx.unifier, ret_ty);
|
||||||
let llvm_elem_ty = ctx.get_llvm_type(generator, elem_ty);
|
let llvm_elem_ty = ctx.get_llvm_type(generator, elem_ty);
|
||||||
let llvm_ret_ty = NDArrayType::new(generator, ctx.ctx, llvm_elem_ty);
|
let llvm_ret_ty = NDArrayType::new(generator, ctx.ctx, llvm_elem_ty);
|
||||||
|
@ -602,6 +620,8 @@ 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 = round_up(ctx, buffer_size, ctx.ctx.i64_type());a
|
||||||
|
let buffer_size = llvm_usize.const_int(16, false);
|
||||||
|
|
||||||
let buffer =
|
let buffer =
|
||||||
ctx.builder.build_array_alloca(llvm_pi8, buffer_size, "rpc.buffer").unwrap();
|
ctx.builder.build_array_alloca(llvm_pi8, buffer_size, "rpc.buffer").unwrap();
|
||||||
|
|
Loading…
Reference in New Issue