RFC: Defining and using target vectors

Joern Rennecke amylaar@spamcop.net
Thu Nov 18 16:56:00 GMT 2010


What is annoying in the implementation of this patch:
http://gcc.gnu.org/ml/gcc-patches/2010-11/msg01810.html
is, that for what is essentially only a minor re-arranging of the
hook vectors, I had to create such a huge patch because all the
call sites of the moved hooks are affected, and also every target
had to get a bit of extra code to initialize the new target vector.

We also have the general annoyance in every port that you can't just
define the hooks you want, you first have to #undef their default definition.

Therefore, I'd like to propose the following changes:

1: At the end, target-def.h initalizes targetm, and whatever vectors we
    might want to split out of it nor or in the future.

    At the place where the targets currently initialize targetm, they include
    target-def.h; the previous inclusion of target-def.h is removed, and if
    necessary, hooks.h and/or targhooks.h are included directly (i.e. if
    functions from there are used directly in tm.c before the new inclusion
    point of target-def.h).
    Because target-hooks-def.h has #ifndef guard for all defined hooks,
    the #undef if previously defined hooks is no longer necessary (although
    there is no rush to remove the existing ones).

2: genhooks is changed so that is creates accessor macros for the target
    vector members, which are placed in a file included by target.h .
    For this purpose, the names of the global vector variables are specified
    in target.def .
    E.g. for targetm.calls.strict_argument_naming /
    target_internalm.calls.strict_argument_naming we'll have
    HOOK_CALLS_STRICT_ARGUMENT_NAMING .
    We can also add another wrapper using token pasting that is used like:
    HOOK(CALLS_STRICT_ARGUMENT_NAMING)
    or
    HOOK(CALLS, STRICT_ARGUMENT_NAMING)
    if you thing that'll be useful in the future for the transition to C++.

3: Hook call sites get changed to use the accessor macros, than can be
    staged split by affectde hook and/or affected files.

4: Once all call site of a hook have been converted to the accessor macros,
    the hook can be moved around painlessly.



More information about the Gcc mailing list