Hi All,

Based on RFC:
https://gcc.gnu.org/ml/gcc-patches/2015-08/msg01322.html

The patch implement an extension to Function Multiversioning that
allows to clone a function for multiple targets.
__attribute__((target_clones("avx","arch=slm","default")))
int foo ()
...

Will create 3 clones of foo(). One optimized with -mavx, one optimized
with -march=slm, and one with default optimizations.
And will create ifunc resolver that calls appropriate clone (same as
in Function Multiversioning).

Bootstrap and make check for x86 passed.

Is it ok for trunk?

2015-08-27  Evgeny Stupachenko  <evstu...@gmail.com>

gcc/
        * Makefile.in (OBJS): Add multiple_target.o.
        * multiple_target.c (make_attribute): New.
        (create_dispatcher_calls): Ditto.
        (expand_target_clones): Ditto.
        (ipa_target_clone): Ditto.
        * passes.def (pass_target_clone): New ipa pass.
        * tree-pass.h (make_pass_target_clone): Ditto.

gcc/c-family
        * c-common.c (handle_target_clones_attribute): New.
        * (c_common_attribute_table): Add handle_target_clones_attribute.
        * (handle_always_inline_attribute): Add check on target_clones
        attribute.
        * (handle_target_attribute): Ditto.

gcc/testsuite
        * gcc.dg/mvc1.c: New test for multiple targets cloning.
        * gcc.dg/mvc2.c: Ditto.
        * gcc.dg/mvc3.c: Ditto.
        * gcc.dg/mvc4.c: Ditto.
        * gcc.dg/mvc5.c: Ditto.
        * gcc.dg/mvc6.c: Ditto.
        * gcc.dg/mvc7.c: Ditto.
        * g++.dg/ext/mvc1.C: Ditto.
        * g++.dg/ext/mvc2.C: Ditto.
        * g++.dg/ext/mvc3.C: Ditto.

gcc/doc
        * doc/extend.texi (target_clones): New attribute description.

Attachment: target_clones.patch
Description: Binary data

Reply via email to