[LLVMdev] GetElementPtr

Eli Friedman eli.friedman at gmail.com
Mon Dec 12 16:43:13 PST 2011


On Mon, Dec 12, 2011 at 4:38 PM, Ryan Taylor <ryta1203 at gmail.com> wrote:
> By LLVM do you mean the backend? I'm not using the backend, so is that i32
> on the 0 index the type of the index value or the type of the value to which
> exists at that index?
>
> it seems the pointer itself has no width, it's arbitrary and is handled in
> the lowering and is target dependent on the bus width.
>
> Basically, when I am computing offset I need to know the sizes for add. The
> size of the pointer (dedicated by bus width) and the size of the index.

The size of the index is simply its type.  You would normally
sign-extend or truncate to the width of a pointer to do arithmetic,
though.

You can grab the pointer size from TargetData::getPointerSizeInBits().

-Eli



More information about the llvm-dev mailing list