1
votes

Hi, I'm currently working on LLVM IR and have a question.

I'm creating function using following code.

Function::Create(Ty, Linkage, "tile_load", mod);

In doing so, my function type Ty is represented as:

FunctionType *Ty = FunctionType::get(Builder.getVoidTy(), params, false);

One of my params is an array, which is currently pointed with int32*.

params.push_back(Type::getInt32PtrTy(mod->getContext()));

I want to change this part with ArrayType like [10 * i32*] but with varying array size.

I know that array type is defined like:

Type* I = IntegerType::getInt32Ty(mod->getContext());
auto num = 6;
ArrayType* arrayType = ArrayType::get(I, num);

But have no idea how to make an array type with size varying.

Does any body know how can it be done?

Thank you in advance.

jwlee

1
You can cast pointer types with bitcast instruction. - arrowd

1 Answers

1
votes

Arrays are having fixed size. Array with "varying array size" is essentially a piece of memory. So, you'd need to use pointers for this. If at some point the size become compile-time constant you could bitcast to array type.