Compare commits

..

2 Commits

2 changed files with 12 additions and 8 deletions

View File

@ -179,7 +179,10 @@ impl<'ctx> NDArrayType<'ctx> {
// TODO: Move this into e.g. StructProxyType // TODO: Move this into e.g. StructProxyType
#[must_use] #[must_use]
fn fields(ctx: &'ctx Context, llvm_usize: IntType<'ctx>) -> NDArrayStructFields<'ctx> { fn fields(
ctx: &'ctx Context,
llvm_usize: IntType<'ctx>,
) -> NDArrayStructFields<'ctx> {
NDArrayStructFields::new(ctx, llvm_usize) NDArrayStructFields::new(ctx, llvm_usize)
} }
@ -203,8 +206,10 @@ 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 = let field_tys = Self::fields(ctx, llvm_usize)
Self::fields(ctx, llvm_usize).into_iter().map(|field| field.1).collect_vec(); .into_iter()
.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,11 +112,10 @@ 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().get_fields(ctx.ctx, self.llvm_usize).ndims.ptr_by_gep( self.get_type()
ctx, .get_fields(ctx.ctx, self.llvm_usize)
self.as_base_value(), .ndims
self.name, .ptr_by_gep(ctx, self.as_base_value(), self.name)
)
} }
/// Stores the number of dimensions `ndims` into this instance. /// Stores the number of dimensions `ndims` into this instance.