[PATCH] gengtype: Support explicit pointers in template arguments

Jeff Law law@redhat.com
Mon May 5 16:18:00 GMT 2014


On 04/30/14 21:07, David Malcolm wrote:
> Currently, gengtype does not support template arguments that are
> explicitly pointers, such as:
>    static GTY(()) vec<gimple_statement_base *> test_gimple; giving this
> error:
>    ../../src/gcc/gimple-expr.c:902: parse error: expected a string constant or ',', have '*' instead
> requiring them to be typedefs.
>
> This patch removes this restriction, supporting up to a single pointer
> in each template argument.
>
> It also adds support for inheritance, allowing:
>    static GTY(()) vec<gimple_statement_phi *, va_gc> *test_phis;
> where the generated gt-FOO.c file contains:
>
>    void
>    gt_ggc_mx (struct gimple_statement_phi *& x)
>    {
>      if (x)
>        gt_ggc_mx_gimple_statement_base ((void *) x);
>    }
>
> i.e. handling the subclass by calling the marking function for the base
> class.
>
> Doing so uncovered an issue within write_user_func_for_structure_ptr,
> which would unconditionally write out a func.  This would lead to
> gt-FOO.c containing duplicate functions e.g.:
> gtype-desc.c:280: multiple definition of `gt_ggc_mx(gimple_statement_base*&)'
> if more than one GTY template type referenced such a type; for example like this:
>
>    static GTY(()) vec<gimple, va_gc> *test_old_style_gimple;
>    static GTY(()) vec<gimple_statement_base *, va_gc> *test_new_style_gimple;
>
> where "gimple" is just an alias for "gimple_statement_base *".  This
> could be worked around by ensuring that the source tree consistently
> uses vec<> of just one kind, but for robustness the patch also makes
> write_user_func_for_structure_ptr idempotent, so it only writes out the
> func once for each (struct, which-of-ggc/pch) combination.
>
> Motivation:
> In the "Compile-time gimple-checking" discussion, Richi asked me to look
> at eliminating the const_gimple typedef in favor of having "gimple" be
> the struct, thus making the pointer to a gimple be explicit in the type:
>    http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01520.html
> as in:
>    http://gcc.gnu.org/ml/gcc-patches/2014-04/msg01632.html
>> [...] And I never liked the
>> const_ typedef variants that were introduced.  The main reason for
>> them was probably to avoid all the churn of replacing the tree pointer
>> typedef with a tree (non-pointer) typedef.  The mistake was to
>> repeat that for 'gimple' ...
>
> I'm attempting a patch for that, but in the meantime, this patch adds
> the needed support to gengtype.
>
> Successfully bootstrapped&regtested on x86_64-unknown-linux-gnu (Fedora
> 20).
>
> OK for trunk?
Basically OK.  Per the wide-int folks request, please hold off until the 
wide-int merge is done.

If after wide-int, the only changes are trivial, then consider the patch 
pre-approved (post the final version here so that its archived).

If after wide-int merges the changes to this patch are non-trivial, then 
repost the RFA.

Obviously, you get to exercise some judgement as to what constitutes 
trivial vs non-trivial.

Jeff



More information about the Gcc-patches mailing list