<div dir="ltr">Documentation's a bit stale - it'd probably be enlightening/helpful to look at some real world examples, such as:<br><br>
<p class="inbox-inbox-p1"><span class="inbox-inbox-s1">%arrayidx = getelementptr inbounds i32*, i32** %0, i64 3<br><br>So the first argument (i32*) is a type, currently it's the same type as the type that the second argument points to (or, in the case of a vector gep, it's the type of the pointee of the elements of the vector argument).<br><br>The GEP FAQ docs are a bit out of date, if you'd like to send a patch for them, that'd be great! :) Otherwise I should probably get to them myself... </span></p></div><br><div class="gmail_quote"><div dir="ltr">On Sat, Jun 17, 2017 at 6:09 AM 陳韋任 via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Hi All,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"> While reading "Arguments" section of getelementptr [1], the description is a little wired to me.</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> The first argument is always a type used as the basis for the calculations. The second argument</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> is always a pointer or a vector of pointers, and is the base address to start from.</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> ...</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> The first index always indexes the pointer value given as the first argument, ...</font><br></div><div class="gmail_default"><br></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">Here I see the paragraph says the first argument is a *type*, then says the first index always indexes</font></div><div class="gmail_default"><span style="font-family:arial,helvetica,sans-serif">*the pointer value* given as the first argument. From </span><span style="font-family:arial,helvetica,sans-serif">getelementptr FAQ [2], I feel the first arguement</span><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><span style="font-family:arial,helvetica,sans-serif">(first operand in FAQ) should be </span><font face="arial, helvetica, sans-serif">*the pointer value*, and the following sentence seems not so right to</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif">me.</font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"><br></font></div><div class="gmail_default"><font face="arial, helvetica, sans-serif"> </font><span style="font-family:arial,helvetica,sans-serif">The first argument is always a type used as the basis for the calculations.</span></div><div class="gmail_default"><span style="font-family:arial,helvetica,sans-serif"><br></span></div><div class="gmail_default"><span style="font-family:arial,helvetica,sans-serif">Am I reading it wrong, or it is wrong. Thanks.</span></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">[1] <a href="http://llvm.org/docs/LangRef.html#getelementptr-instruction" target="_blank">http://llvm.org/docs/LangRef.html#getelementptr-instruction</a></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">[2] <a href="http://llvm.org/docs/GetElementPtr.html" target="_blank">http://llvm.org/docs/GetElementPtr.html</a></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif"><br></div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Regards,</div><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">chenwj</div><div><br></div>-- <br><div class="m_-8009110647185613927gmail_signature"><div dir="ltr"><div>Wei-Ren Chen (陳韋任)<br>Homepage: <a href="https://people.cs.nctu.edu.tw/~chenwj" target="_blank">https://people.cs.nctu.edu.tw/~chenwj</a></div></div></div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>