This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gengtype & many GTY tags for same union component?
- From: Tom Tromey <tromey at redhat dot com>
- To: Basile Starynkevitch <basile at starynkevitch dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 06 Jul 2010 09:58:42 -0600
- Subject: Re: gengtype & many GTY tags for same union component?
- References: <20100702211653.GA21045@hector.lesours>
>>>>> "Basile" == Basile Starynkevitch <basile@starynkevitch.net> writes:
Basile> My understanding of the description of the tag GTY option in
Basile> http://gcc.gnu.org/onlinedocs/gccint/GTY-Options.html#GTY-Options
Basile> is that a given discriminated union case can have several
Basile> tags.
It seems like a reasonable feature, but I didn't see any text there
indicating that this is already supported.
Basile> struct meltspecial_st
Basile> GTY ((tag ("OBMAG_SPEC_FILE"),
Basile> tag ("OBMAG_SPEC_RAWFILE"),
Basile> tag ("OBMAG_SPEC_MPFR"),
Basile> tag ("OBMAG_SPECPPL_COEFFICIENT"),
Basile> tag ("OBMAG_SPECPPL_LINEAR_EXPRESSION"),
Basile> tag ("OBMAG_SPECPPL_CONSTRAINT"),
Basile> tag ("OBMAG_SPECPPL_CONSTRAINT_SYSTEM"),
Basile> tag ("OBMAG_SPECPPL_GENERATOR"),
Basile> tag ("OBMAG_SPECPPL_GENERATOR_SYSTEM"),
Basile> tag ("OBMAG_SPECPPL_POLYHEDRON"))
Basile> ) u_special;
One thing you can do here is provide a "desc" tag for the union that
collapses all these tags to a single tag.
Instead of:
GTY ((desc ("%0.u_discr->object_magic")))
You would have:
int
magic_for_ggc (int magic)
{
if (magic == OBMAG_SPEC_FILE
|| magic == OBMAG_SPEC_RAWFILE
|| ...)
return OBMAG_SPEC_RAWFILE;
return magic;
}
.. and
GTY ((desc ("magic_for_ggc (%0.u_discr->object_magic)")))
Tom