I want to get the Value of an array at an variable index. The Index is computed by the program and not known at parse time. So it is stored in an Value and converted to an Int like this:
Value *IndexV = Index->Codegen();
Value *IntV = Builder.CreateFPToUI( IndexV, Type::getInt32Ty( getGlobalContext() ) );
If I know the index, I can use:
Value *VV = Builder.CreateExtractValue( Builder.CreateLoad( V ), 0 );
This gives me the first element of the array. And works correctly. But how can I use IntV as the index? CreateExtractValue only takes an ArrayRef and there is no way of casting the IntV to an ArrayRef, or am I wrong? How would one do such a thing?
Thanks!