A newbie question about the class hierarchy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

A newbie question about the class hierarchy

Nai XIA
Hi,
I apologize if it is a rather stupid question, I am a newbie to LLVM.
I notice a inconsistency between the current llvm1.6 doc and its source code.
The doc states that the superclasses of GlobalVariable are GlobalValue, User, Value,
however in the source code GlobalVariable has Constant as its super.
I am just curious that why "variable" should be a subclass of "constant"?

Regards,
Nai

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: A newbie question about the class hierarchy

Reid Spencer
Hi Nai,

The hierarchy is like this:

GlobalVariable : GlobalValue: Constant: User: Value

So, GlobalVariable is a Constant indirectly through GlobalValue. This
change was made sometime after LLVM 1.5 and reflects the fact that all
GlobalValue's are, essentially, a constant address.  Only after
derefercing with getelementptr is something obtained that is
(poentially) variable. Note that "Function" is a GlobalValue as well,
but you can't dereference it or modify what it points to.  So, the
notion of a GlobalVariable being constant makes sense if you look at it
as a constant memory address.  This hierarchy reduced a bunch of time-
consuming checks in LLVM passes, etc.

As for the documentation, I'll take a look. If its erroneous, it'll get
fixed with the 1.7 release.

Thanks for pointing it out.

Reid.

On Fri, 2006-04-14 at 18:19 +0800, Nai Xia wrote:

> Hi,
> I apologize if it is a rather stupid question, I am a newbie to LLVM.
> I notice a inconsistency between the current llvm1.6 doc and its source code.
> The doc states that the superclasses of GlobalVariable are GlobalValue, User, Value,
> however in the source code GlobalVariable has Constant as its super.
> I am just curious that why "variable" should be a subclass of "constant"?
>
> Regards,
> Nai
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: A newbie question about the class hierarchy

Reid Spencer
In reply to this post by Nai XIA
Nia,

I improved the documentation with this patch:
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-
Mon-20060410/034012.html
You can read it online, here:
http://llvm.org/docs/ProgrammersManual.html#GlobalVariable

Please let me if you need further explanation in the documentation.

Reid.

On Fri, 2006-04-14 at 18:19 +0800, Nai Xia wrote:

> Hi,
> I apologize if it is a rather stupid question, I am a newbie to LLVM.
> I notice a inconsistency between the current llvm1.6 doc and its source code.
> The doc states that the superclasses of GlobalVariable are GlobalValue, User, Value,
> however in the source code GlobalVariable has Constant as its super.
> I am just curious that why "variable" should be a subclass of "constant"?
>
> Regards,
> Nai
>
> _______________________________________________
> LLVM Developers mailing list
> [hidden email]         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

signature.asc (196 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: A newbie question about the class hierarchy

xia_nai@yahoo.com.cn
Reid,

Thanks a lot for your clear explanation and update for the doc.
I think this design is neat. :)


On Friday 14 April 2006 22:15, you wrote:

> Nia,
>
> I improved the documentation with this patch:
> http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-
> Mon-20060410/034012.html
> You can read it online, here:
> http://llvm.org/docs/ProgrammersManual.html#GlobalVariable
>
> Please let me if you need further explanation in the documentation.
>
> Reid.
>
> On Fri, 2006-04-14 at 18:19 +0800, Nai Xia wrote:
> > Hi,
> > I apologize if it is a rather stupid question, I am a newbie to LLVM.
> > I notice a inconsistency between the current llvm1.6 doc and its source code.
> > The doc states that the superclasses of GlobalVariable are GlobalValue, User, Value,
> > however in the source code GlobalVariable has Constant as its super.
> > I am just curious that why "variable" should be a subclass of "constant"?
> >
> > Regards,
> > Nai
> >
> > _______________________________________________
> > LLVM Developers mailing list
> > [hidden email]         http://llvm.cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
--
Regards,
Nai

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

attachment0 (316 bytes) Download Attachment