This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gengtype & many GTY tags for same union component?


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]