[llvm-dev] Wrong description about getelementptr arguments?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[llvm-dev] Wrong description about getelementptr arguments?

Tim Northover via llvm-dev
Hi All,

  While reading "Arguments" section of getelementptr [1], the description is a little wired to me.

    The first argument is always a type used as the basis for the calculations. The second argument
    is always a pointer or a vector of pointers, and is the base address to start from.

    ...

    The first index always indexes the pointer value given as the first argument, ...

Here I see the paragraph says the first argument is a *type*, then says the first index always indexes
*the pointer value* given as the first argument. From getelementptr FAQ [2], I feel the first arguement
(first operand in FAQ) should be *the pointer value*, and the following sentence seems not so right to
me.

    The first argument is always a type used as the basis for the calculations.

Am I reading it wrong, or it is wrong. Thanks.


Regards,
chenwj

--
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Wrong description about getelementptr arguments?

Tim Northover via llvm-dev
Documentation's a bit stale - it'd probably be enlightening/helpful to look at some real world examples, such as:

%arrayidx = getelementptr inbounds i32*, i32** %0, i64 3

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).

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... 


On Sat, Jun 17, 2017 at 6:09 AM 陳韋任 via llvm-dev <[hidden email]> wrote:
Hi All,

  While reading "Arguments" section of getelementptr [1], the description is a little wired to me.

    The first argument is always a type used as the basis for the calculations. The second argument
    is always a pointer or a vector of pointers, and is the base address to start from.

    ...

    The first index always indexes the pointer value given as the first argument, ...

Here I see the paragraph says the first argument is a *type*, then says the first index always indexes
*the pointer value* given as the first argument. From getelementptr FAQ [2], I feel the first arguement
(first operand in FAQ) should be *the pointer value*, and the following sentence seems not so right to
me.

    The first argument is always a type used as the basis for the calculations.

Am I reading it wrong, or it is wrong. Thanks.


Regards,
chenwj

--
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj
_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Wrong description about getelementptr arguments?

Tim Northover via llvm-dev

Documentation's a bit stale - it'd probably be enlightening/helpful to look at some real world examples, such as:

%arrayidx = getelementptr inbounds i32*, i32** %0, i64 3

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).

​So you mean we actually have three arguments here, ​i32*, i32** %0 and i64 3? The how about the following statement

    The first index always indexes the pointer value given as the first argument

it should be

    The first index always indexes the pointer value given as the second argument

​right?

I am okay sending patch to fix the document, btw. :)

Regards,
chenwj​


--
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Wrong description about getelementptr arguments?

Tim Northover via llvm-dev


On Sat, Jun 17, 2017 at 11:20 AM 陳韋任 <[hidden email]> wrote:
Documentation's a bit stale - it'd probably be enlightening/helpful to look at some real world examples, such as:

%arrayidx = getelementptr inbounds i32*, i32** %0, i64 3

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).

​So you mean we actually have three arguments here, ​i32*, i32** %0 and i64 3?

Right, though I can see how that could be a bit unclear/uncertain. Is the first thing ('i32*') an argument, since it's only a type and no value? Dunno - I could see using a few different phrasings... but probably as good as any to refer to it as the first argument.
 
The how about the following statement

    The first index always indexes the pointer value given as the first argument

it should be

    The first index always indexes the pointer value given as the second argument

​right?

Yep, sounds right to me.
 

I am okay sending patch to fix the document, btw. :)

Cool, thanks a bunch!
 

Regards,
chenwj​


--
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [llvm-dev] Wrong description about getelementptr arguments?

Tim Northover via llvm-dev
​Hi David,​

 
I am okay sending patch to fix the document, btw. :)

Cool, thanks a bunch!

​Here it is https://reviews.llvm.org/D34325 , please have a look, thanks.​

​Regards,
chenwj​

--
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj

_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Loading...