[LLVMdev] A question about getElementPtr

Chris Lattner sabre at nondot.org
Tue Nov 7 16:30:52 PST 2006


On Tue, 7 Nov 2006, Robert Mykland wrote:
> I'm busy writing the code that translates the LLVM construct
> GetElementPtr into my virtual circuit representation.  Since
> GetElementPtr handles structures, I can end up at the end with a pointer
> to some literal type, and know the literal type, but not know the
> pointer type of what I have, at least not explicitly from the bytecode.
>
> This has made me think I have to massage my context table so that
> literal types can find their pointer types just so I can properly put
> this resulting pointer into the correct type/value slot.
>
> Am I missing something here?  Sure would be nice if the resulting type
> were explicit in the instruction.

In our in-memory IR, the type of the result is explicitly represented in 
memory (just use GEP->getType()).  In the .bc file, this information is 
100% redundant with the information about the operands to the GEP, so we 
don't bother encoding the destination type.  Doing so would just be a 
waste of space.

-Chris

-- 
http://nondot.org/sabre/
http://llvm.org/



More information about the llvm-dev mailing list