From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 44257 invoked by alias); 16 Jul 2015 15:21:06 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 44193 invoked by uid 89); 16 Jul 2015 15:21:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL,BAYES_00,KAM_STOCKGEN,SPF_PASS autolearn=no version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 16 Jul 2015 15:21:01 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-31-8W1ZUxpgQ8GOQ4MuS1qgpw-1; Thu, 16 Jul 2015 16:20:57 +0100 Received: from [10.2.207.50] ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 16 Jul 2015 16:20:56 +0100 Message-ID: <55A7CBD8.8000705@arm.com> Date: Thu, 16 Jul 2015 15:21:00 -0000 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Marcus Shawcroft , Richard Earnshaw , James Greenhalgh Subject: [PATCH][AArch64][7/14] Implement TARGET_SET_CURRENT_FUNCTION X-MC-Unique: 8W1ZUxpgQ8GOQ4MuS1qgpw-1 Content-Type: multipart/mixed; boundary="------------000104040306080102050804" X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg01431.txt.bz2 This is a multi-part message in MIME format. --------------000104040306080102050804 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Content-length: 1135 Hi all, This patch implements TARGET_SET_CURRENT_FUNCTION and defines SWITCHABLE_TA= RGET. With this patch in the series, we should be far enough to get LTO option sw= itching to work properly. The implementation if TARGET_SET_CURRENT_FUNCTION is pretty much a direct c= opy from the rs6000 backend, and i386 has a very similar structure as well. I tried to simplify this fo= r aarch64, but in the end this implementation was the one that worked. TARGET_SET_CURRENT_FUNCTION should take the target-specific options from DE= CL_FUNCTION_SPECIFIC_TARGET and use them to set up the backend state. Since it may be called many time= s for the same function, we keep track of the previous function this got called on in order to avoid= repeating work. Bootstrapped and tested on aarch64. Ok for trunk? Thanks, Kyrill 2015-07-16 Kyrylo Tkachov * config/aarch64/aarch64.h (SWITCHABLE_TARGET): Define. * config/aarch64/aarch64.c: Include target-globals.h (aarch64_previous_fndecl): New variable. (aarch64_set_current_function): New function. (TARGET_SET_CURRENT_FUNCTION): Define. --------------000104040306080102050804 Content-Type: text/x-patch; name=aarch64-attrs-7.patch Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="aarch64-attrs-7.patch" Content-length: 3373 commit f3c5c9df8bb5a26a7df65e7b68d9eb6f60eccb40 Author: Kyrylo Tkachov Date: Thu May 7 14:06:04 2015 +0100 [AArch64][7/N] Implement TARGET_SET_CURRENT_FUNCTION diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 2891690..ff87631 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -73,6 +73,7 @@ #include "tm-constrs.h" #include "sched-int.h" #include "cortex-a57-fma-steering.h" +#include "target-globals.h" =20 /* This file should be included last. */ #include "target-def.h" @@ -7927,6 +7928,58 @@ aarch64_option_print (FILE *file, int indent, struct= cl_target_option *ptr) aarch64_print_extension (file, isa_flags); } =20 +static GTY(()) tree aarch64_previous_fndecl; + +/* Implement TARGET_SET_CURRENT_FUNCTION. Unpack the codegen decisions + like tuning and ISA features from the DECL_FUNCTION_SPECIFIC_TARGET + of the function, if such exists. This function may be called multiple + times on a single function so use aarch64_previous_fndecl to avoid + setting up identical state. */ + +static void +aarch64_set_current_function (tree fndecl) +{ + tree old_tree =3D (aarch64_previous_fndecl + ? DECL_FUNCTION_SPECIFIC_TARGET (aarch64_previous_fndecl) + : NULL_TREE); + + tree new_tree =3D (fndecl + ? DECL_FUNCTION_SPECIFIC_TARGET (fndecl) + : NULL_TREE); + + + if (fndecl && fndecl !=3D aarch64_previous_fndecl) + { + aarch64_previous_fndecl =3D fndecl; + if (old_tree =3D=3D new_tree) + ; + + else if (new_tree && new_tree !=3D target_option_default_node) + { + cl_target_option_restore (&global_options, + TREE_TARGET_OPTION (new_tree)); + if (TREE_TARGET_GLOBALS (new_tree)) + restore_target_globals (TREE_TARGET_GLOBALS (new_tree)); + else + TREE_TARGET_GLOBALS (new_tree) + =3D save_target_globals_default_opts (); + } + + else if (old_tree && old_tree !=3D target_option_default_node) + { + new_tree =3D target_option_current_node; + cl_target_option_restore (&global_options, + TREE_TARGET_OPTION (new_tree)); + if (TREE_TARGET_GLOBALS (new_tree)) + restore_target_globals (TREE_TARGET_GLOBALS (new_tree)); + else if (new_tree =3D=3D target_option_default_node) + restore_target_globals (&default_target_globals); + else + TREE_TARGET_GLOBALS (new_tree) + =3D save_target_globals_default_opts (); + } + } +} =20 /* Return true if SYMBOL_REF X binds locally. */ =20 @@ -12399,6 +12452,9 @@ aarch64_unspec_may_trap_p (const_rtx x, unsigned fl= ags) #undef TARGET_OPTION_PRINT #define TARGET_OPTION_PRINT aarch64_option_print =20 +#undef TARGET_SET_CURRENT_FUNCTION +#define TARGET_SET_CURRENT_FUNCTION aarch64_set_current_function + #undef TARGET_PASS_BY_REFERENCE #define TARGET_PASS_BY_REFERENCE aarch64_pass_by_reference =20 diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h index 6d792c4..2c1b6ce 100644 --- a/gcc/config/aarch64/aarch64.h +++ b/gcc/config/aarch64/aarch64.h @@ -920,6 +920,9 @@ do { \ #define HARD_REGNO_CALL_PART_CLOBBERED(REGNO, MODE) \ (FP_REGNUM_P (REGNO) && GET_MODE_SIZE (MODE) > 8) =20 +#undef SWITCHABLE_TARGET +#define SWITCHABLE_TARGET 1 + /* Check TLS Descriptors mechanism is selected. */ #define TARGET_TLS_DESC (aarch64_tls_dialect =3D=3D TLS_DESCRIPTORS) =20 --------------000104040306080102050804--