This patch adds the initial attribute((target_clone(...))) support to the
PowerPC.  It looks at the HWCAP bits for ISA 2.05 (power6), ISA 2.06 (power7),
ISA 2.07 (power8) and ISA 3.0 (power9) to determine which clone function to
run.  The implementation used the existing i386/x86_64 support for target_clone
as a template.

At the moment, it has the same basic flaw that the i386/x86_64 implementation
has, which is outside of the current module, the default version of the
function is exported.  It is only in the module that the function is defined in
that supports calling the different target clones.  I hope to add support in
the future to make the exported function be the ifunc handler and not the
default version.  However, I wanted to get the basic framework into the
compiler before tackling that issue.

I have tested these patches on a little endian power8 system and there were no
regressions.  Can I install it into the trunk?

[gcc]
2017-05-24  Michael Meissner  <meiss...@linux.vnet.ibm.com>

        * config/rs6000/rs6000.c (toplevel): Include attribs.h.
        (enum clone_list): New enumeration to give the target clones
        processors we generate code for.
        (rs6000_clone_map): New array to identify which clone processors
        the current program is running on.
        (TARGET_COMPARE_VERSION_PRIORITY): Define to enable the
        target_clone attribute.
        (TARGET_GENERATE_VERSION_DISPATCHER_BODY): Likewise.
        (TARGET_GET_FUNCTION_VERSIONS_DISPATCHER): Likewise.
        (TARGET_OPTION_FUNCTION_VERSIONS): Likewise.
        (cpu_expand_builtin): Add support for target_clone attribute.
        (rs6000_valid_attribute_p): Allow "default" attribute.
        (get_decl_name): New debug function to simplify printing the
        current function name in debugging statements.
        (rs6000_clone_priority): New functions to support the target_clone
        attribute, and be able to generate code to switch between ISA 2.05
        through ISA 3.0 (power6 through power9).
        (rs6000_compare_version_priority): Likewise.
        (rs6000_get_function_versions_dispatcher): Likewise.
        (make_resolver_func): Likewise.
        (add_condition_to_bb): Likewise.
        (dispatch_function_versions): Likewise.
        (rs6000_generate_version_dispatcher_body): Likewise.
        (rs6000_can_inline_p): Call get_decl_name for debugging usage.
        * doc/extend.texi (Common Function Attributes): Document that the
        PowerPC supports the target_clone attribute.

[gcc/testsuite]
2017-05-24  Michael Meissner  <meiss...@linux.vnet.ibm.com>

        * gcc.target/powerpc/clone1.c: New test.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797

Reply via email to