[LLVMdev] newbi to llvm - how to get array size
Surinder
surifilms at gmail.com
Wed Jan 12 01:02:40 PST 2011
Hi,
I am new to llvm to so please be kind to me if I am asking something that is
too simple. I want to get the bounds of an array when I have a handle to
getelementptr or insertelement or extractvalue instructions. I am writing a
translation routine from llvm to a non-deterministic language and want to
include array bounds check in it.
The array size gets printed as part of the type of the value <pty>
<result> = getelementptr inbounds <pty>* <ptrval> (ty idx)
I am wrongly expecting I.getOperand(0)->getType()->getNumElements() to
give me the array size (after casting ptrval to array type)
I am not getting the array size, I am getting a value of zero.
Can someone point out to me how to get array size (number of elements in the
array) from the type object. What about multi-dimension arrays too.
Thanks.
Surinder Kumar Jain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110112/5c38c29d/attachment.html>
More information about the llvm-dev
mailing list