[LLVMdev] GetElementPtr

Eli Friedman eli.friedman at gmail.com
Thu Dec 8 15:45:29 PST 2011


On Thu, Dec 8, 2011 at 3:29 PM, Ryan Taylor <ryta1203 at gmail.com> wrote:
> Ok, thanks, this makes sense. But there is no way to get the SelectionDAG to
> do it for me via something like visitGetElementrPtr?

SelectionDAGBuilder::visitGetElementPtr uses the same algorithm you
want to use, but it is specialized for building a SelectionDAG, which
is lower level than LLVM IR.

-Eli

>
>
> On Thu, Dec 8, 2011 at 2:54 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
>>
>> > On Thu, Dec 8, 2011 at 2:37 PM, Ryan Taylor <ryta1203 at gmail.com> wrote:
>> >>
>> >> Thanks.
>> >>
>> >> So basically then this operation is not target-independent like the
>> >> docs
>> >> suggest?
>>
>> It is target-independent in the sense that a frontend can generate
>> code using GEP's without worrying about how a given target actually
>> lays out structures.  It isn't target-independent in the sense that
>> the actual computed offset in bytes isn't the same for every target.
>> See also
>> http://nondot.org/sabre/LLVMNotes/SizeOf-OffsetOf-VariableSizedStructs.txt
>> .
>>
>> -Eli
>
>




More information about the llvm-dev mailing list