Based on llvmlite docs I can create static array like in a code snippet bellow.
ir.Constant(ir.ArrayType(ir.ArrayType(i8, STR_SIZE), ARR_SIZE), elements)
But can I create dynamic array in llvmlite or convert variable above to i8.as_pointer().as_pointer() type?
char**
isn't an array, it's a pointer to pointer to char
. C programs often use such a pointer and pretend that the type pointed to is something else.
LLVM lets you do the same, and in a fairly similar way. If you look closely at the getelementptr instruction, you'll notice that it takes both a pointer argument and a type argument. The type is the type pointed to. If you pass gep an array type, a pointer and an index, it pretends that the pointer points to that type and returns a pointer to an array entry with the specified index, which you can then load and treat as a Value.