On 06/23/2015 12:41 PM, Richard Sandiford wrote:
[A fair bit later than promised, sorry...]

Mikhail posted a patch to make genflags generate the default HAVE_foo
and gen_foo definitions that have recently been added to defaults.h:

   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00723.html

I agree it'd be a good idea to generate this kind of thing automatically,
but I think we should take the opportunity to move the interface to the
target structure.  I.e.:

   HAVE_foo -> targetm.have_foo ()
   gen_foo -> targetm.gen_foo ()

This should move us closer to the pipedream goal of supporting multiple
targets at once.  It should also mean that only the target code depends
on insn-flags.h.

The patch just moves return and simple_return as an example.  I have more
locally (in order to test other code paths), but they're just an obvious
extension of this one.

The patch relies on the hashing changes in:

   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01066.html
   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01564.html

and on this trivial patch:

   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01604.html

It seems a bit heavyweight when you just look at these two instructions,
but I think it'll be a saving in the end.

Bootstrapped & regression-tested on x86_64-linux-gnu.  Also tested
via config-list.mk.  OK to install?

Thanks,
Richard


gcc/
        * Makefile.in (TARGET_DEF): Add target-insns.def.
        (.PRECIOUS, simple_rtl_generated_h): Add insn-target-def.h.
        (build/gentarget-def.o): New rule.
        (genprogrtl): Add target-def.
        * target-insns.def, gentarget-def.c: New files.
        * target.def: Add targetm.have_* and targetm.gen_* hooks,
        based on the contents of target-insns.def.
        * defaults.h (HAVE_simple_return, gen_simple_return): Delete.
        (HAVE_return, gen_return): Delete.
        * target-def.h: Include insn-target-def.h.
        * cfgrtl.c (force_nonfallthru_and_redirect): Use targetm interface
        instead of direct calls.  Rely on them to do the appropriate assertions.
        * function.c (gen_return_pattern): Likewise.  Return an rtx_insn *.
        (convert_jumps_to_returns): Use targetm interface instead of
        direct calls.
        (thread_prologue_and_epilogue_insns): Likewise.
        * reorg.c (find_end_label, dbr_schedule): Likewise.
        * shrink-wrap.h (SHRINK_WRAPPING_ENABLED): Likewise.
        * shrink-wrap.c (convert_to_simple_return): Likewise.
        (try_shrink_wrapping): Use SHRINK_WRAPPING_ENABLED.
As you're the gen* maintainer, I'm going to assume you got those bits right and if there's a problem you'll address them :-)

This is fine once the prereqs are installed. Follow-ups to move more insns to this style are pre-approved assuming their of a similar mechanical nature.

jeff


Reply via email to