@@ -125,15 +125,35 @@ def get_void_pointer(typingctx, arr):
125
125
Args:
126
126
typingctx: The typing context.
127
127
arr: The NumPy array to get the void pointer from.
128
+ In a multi-dimensional NumPy array, the memory is laid out in a contiguous
129
+ block of memory in either row-major (C-style) or
130
+ column-major (Fortran-style) order.
131
+ By default, NumPy uses row-major order.
128
132
129
133
Returns:
130
134
A Numba signature and a code generation function that returns a void pointer
131
- to the array's data.
135
+ to the first element of the contiguous block of memory that stores the array's
136
+ data in row-major order by default.
132
137
"""
133
138
if not isinstance (arr , numba .types .Array ):
134
139
raise TypeError ("Expected a NumPy array" )
135
140
136
141
def codegen (context , builder , signature , args ):
142
+ """Generate LLVM IR code to convert a NumPy array to a void* pointer.
143
+
144
+ This function generates the necessary LLVM IR instructions to:
145
+ 1. Allocate memory for the array on the stack.
146
+ 2. Cast the allocated memory to a void* pointer.
147
+
148
+ Args:
149
+ context: The LLVM context.
150
+ builder: The LLVM IR builder.
151
+ signature: The function signature.
152
+ args: The input arguments (NumPy array).
153
+
154
+ Returns:
155
+ A void* pointer to the array's data.
156
+ """
137
157
[arr ] = args
138
158
raw_ptr = numba .core .cgutils .alloca_once_value (builder , arr )
139
159
void_ptr = builder .bitcast (raw_ptr , context .get_value_type (numba .types .voidptr ))
0 commit comments