[LLVMdev] GetElementPtr

Eli Friedman eli.friedman at gmail.com
Mon Dec 12 15:58:46 PST 2011

On Mon, Dec 12, 2011 at 3:54 PM, Ryan Taylor <ryta1203 at gmail.com> wrote:
> For the gep:
> %idx1 = getelementptr i32* %MyVar, i32 0
> i32* is the type that MyVar is pointing to and i32 is the type of the offset
> value, or what? If it's the type of offset value, then
> the size of the pointer shouldn't be less than i32, correct?
> The index is 0, so in this example, the address computation is idx1 =
> &MyVar+0.
> What I want to know is the size in bits of the values above, it looks like 0
> is 32 bits in size, which would make the pointer size also 32?

LLVM will sign-extend or truncate the index to the size of the
pointer; the pointer type could have any width.


More information about the llvm-dev mailing list