Compare commits

..

2 Commits

2 changed files with 8 additions and 12 deletions

View File

@ -179,10 +179,7 @@ impl<'ctx> NDArrayType<'ctx> {
// TODO: Move this into e.g. StructProxyType // TODO: Move this into e.g. StructProxyType
#[must_use] #[must_use]
fn fields( fn fields(ctx: &'ctx Context, llvm_usize: IntType<'ctx>) -> NDArrayStructFields<'ctx> {
ctx: &'ctx Context,
llvm_usize: IntType<'ctx>,
) -> NDArrayStructFields<'ctx> {
NDArrayStructFields::new(ctx, llvm_usize) NDArrayStructFields::new(ctx, llvm_usize)
} }
@ -206,10 +203,8 @@ impl<'ctx> NDArrayType<'ctx> {
// * ndims : Number of dimensions in the array // * ndims : Number of dimensions in the array
// * shape : Pointer to an array containing the shape of the NDArray // * shape : Pointer to an array containing the shape of the NDArray
// * strides : Pointer to an array indicating the number of bytes between each element at a dimension // * strides : Pointer to an array indicating the number of bytes between each element at a dimension
let field_tys = Self::fields(ctx, llvm_usize) let field_tys =
.into_iter() Self::fields(ctx, llvm_usize).into_iter().map(|field| field.1).collect_vec();
.map(|field| field.1)
.collect_vec();
ctx.struct_type(&field_tys, false).ptr_type(AddressSpace::default()) ctx.struct_type(&field_tys, false).ptr_type(AddressSpace::default())
} }

View File

@ -112,10 +112,11 @@ impl<'ctx> NDArrayValue<'ctx> {
/// Returns the pointer to the field storing the number of dimensions of this `NDArray`. /// Returns the pointer to the field storing the number of dimensions of this `NDArray`.
fn ptr_to_ndims(&self, ctx: &CodeGenContext<'ctx, '_>) -> PointerValue<'ctx> { fn ptr_to_ndims(&self, ctx: &CodeGenContext<'ctx, '_>) -> PointerValue<'ctx> {
self.get_type() self.get_type().get_fields(ctx.ctx, self.llvm_usize).ndims.ptr_by_gep(
.get_fields(ctx.ctx, self.llvm_usize) ctx,
.ndims self.as_base_value(),
.ptr_by_gep(ctx, self.as_base_value(), self.name) self.name,
)
} }
/// Stores the number of dimensions `ndims` into this instance. /// Stores the number of dimensions `ndims` into this instance.