This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Thoughts on Gengtype and Single Inheritance
- From: Laurynas Biveinis <laurynas dot biveinis at gmail dot com>
- To: Lawrence Crowl <crowl at googlers dot com>
- Cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
- Date: Mon, 27 Aug 2012 10:45:31 +0300
- Subject: Re: Thoughts on Gengtype and Single Inheritance
- References: <CAGqM8fZMUPo7pUUF7_RrLYm+fkrukjZenE=UyZu7FrC7BTU9bQ@mail.gmail.com>
Lawrence -
I don't have an opinion from the rest of compiler point of view, but
gengtype implementation-wise, it certainly looks doable. One minor
comment below -
> GRAMMAR
>
> Support adding a second discriminator. This support is not for
> multiple inheritance, but for single inheritance when a second
> discriminator is used to further refine it. Look at struct
> tree_omp_clause. It contains a sub union. We can represent the
> hierarchy like:
>
> struct tree_omp_clause : tree_common {
> location_t locus;
> enum omp_clause_code code;
> };
>
> struct tree_omp_default_clause : tree_omp_clause {
> enum omp_clause_default_kind default_kind;
> };
>
> struct tree_omp_schedule_clause : tree_omp_clause {
> enum omp_clause_schedule_kind schedule_kind;
> };
>
> struct tree_omp_reduction_clause : tree_omp_clause {
> enum tree_code reduction_code;
> };
>
> We use TREE_CODE to understand that we have at least a tree_omp_clause
> and then we use tree_common.code to to distinguish these last three.
>
> Another possible case is tree_type_symtab inside tree_type_common.
>
> The syntax would be something like the following.
>
> enum F { F1, F2, F3, F4, F5 };
>
> class CTYPE GTY ((desc ("%h.kind"), tag ("F1")))
> : GTY ((tag ("EC"))) public BTYPE
> { public: enum F kind; something *pq; ... };
>
> class FTYPE : GTY ((tag ("F2"))) public CTYPE { ... };
I wonder if the second discriminator support is easily generalizable
to enabling any derived class being a root class on it own with its
own subtree? If I understand correctly, the GTY syntax would be the
same.
--
Laurynas