[artiq] Fix obtaining ndarray struct from NDArrayType

This commit is contained in:
David Mak 2024-11-25 14:59:10 +08:00
parent 5651e00688
commit 5f940f86d9

View File

@ -14,7 +14,10 @@ use pyo3::{
}; };
use nac3core::{ use nac3core::{
codegen::{types::NDArrayType, CodeGenContext, CodeGenerator}, codegen::{
types::{NDArrayType, ProxyType},
CodeGenContext, CodeGenerator,
},
inkwell::{ inkwell::{
module::Linkage, module::Linkage,
types::{BasicType, BasicTypeEnum}, types::{BasicType, BasicTypeEnum},
@ -1093,7 +1096,7 @@ impl InnerResolver {
if self.global_value_ids.read().contains_key(&id) { if self.global_value_ids.read().contains_key(&id) {
let global = ctx.module.get_global(&id_str).unwrap_or_else(|| { let global = ctx.module.get_global(&id_str).unwrap_or_else(|| {
ctx.module.add_global( ctx.module.add_global(
ndarray_llvm_ty.element_type().into_struct_type(), ndarray_llvm_ty.as_base_type().get_element_type().into_struct_type(),
Some(AddressSpace::default()), Some(AddressSpace::default()),
&id_str, &id_str,
) )
@ -1187,7 +1190,11 @@ impl InnerResolver {
data_global.set_initializer(&data); data_global.set_initializer(&data);
// create a global for the ndarray object and initialize it // create a global for the ndarray object and initialize it
let value = ndarray_llvm_ty.element_type().into_struct_type().const_named_struct(&[ let value = ndarray_llvm_ty
.as_base_type()
.get_element_type()
.into_struct_type()
.const_named_struct(&[
llvm_usize.const_int(ndarray_ndims, false).into(), llvm_usize.const_int(ndarray_ndims, false).into(),
shape_global shape_global
.as_pointer_value() .as_pointer_value()
@ -1200,7 +1207,7 @@ impl InnerResolver {
]); ]);
let ndarray = ctx.module.add_global( let ndarray = ctx.module.add_global(
ndarray_llvm_ty.element_type().into_struct_type(), ndarray_llvm_ty.as_base_type().get_element_type().into_struct_type(),
Some(AddressSpace::default()), Some(AddressSpace::default()),
&id_str, &id_str,
); );