From patchwork Thu Jun 11 09:10:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Bruel X-Patchwork-Id: 483020 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BF17014029E for ; Thu, 11 Jun 2015 19:10:37 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=gCOO0ubS; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; q=dns; s=default; b=wX80VRMkaG8YFvTm9 XJ0j2mcZo7Ys3MkRDfKT81G1OHA/+iTCuBLlTTdAJuNqIGnXo6/TA6GFhr1ywYXL iYsHwOvLw38rd5zoiNwjHpFoA+uS5s7/qbnVzHeDAx9sjiePcWInVo/R+A0D4Flh S1B+irhP0BPRLUMmpovWb1LSUc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:subject:references :in-reply-to:content-type; s=default; bh=QR9dxLLVJuRiq22DEua1hH7 qMPs=; b=gCOO0ubSKbJugmoG5z+LwzPl2dixk90gWVi2ZP67ODenMuo5r+6OuCH ZwvEMk4xyHLHTmRuFhKwXNm7gOh7bl2mmus2eK17Xy484vIwlISE5qJQT+jpHNUh Wh+32o187aDIjN3rad01wj0C9kB87do3l5zUm+vEK4PWuSeRNiDc= Received: (qmail 31664 invoked by alias); 11 Jun 2015 09:10:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31651 invoked by uid 89); 11 Jun 2015 09:10:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL, BAYES_50, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 X-HELO: mx07-00178001.pphosted.com Received: from mx07-00178001.pphosted.com (HELO mx07-00178001.pphosted.com) (62.209.51.94) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 11 Jun 2015 09:10:27 +0000 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.14.5/8.14.5) with SMTP id t5B8jvSU008456; Thu, 11 Jun 2015 11:10:22 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 1uxtw82uj8-1 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 11 Jun 2015 11:10:21 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2CA0842; Thu, 11 Jun 2015 09:10:18 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas1.st.com [10.75.90.14]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EE1A22C4C; Thu, 11 Jun 2015 09:10:17 +0000 (GMT) Received: from [164.129.122.197] (164.129.122.197) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.342.0; Thu, 11 Jun 2015 11:10:17 +0200 Message-ID: <55794CE3.6050404@st.com> Date: Thu, 11 Jun 2015 11:10:16 +0200 From: Christian Bruel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Kyrill Tkachov , Ramana Radhakrishnan , "gcc-patches@gcc.gnu.org" , Richard Earnshaw , "nickc@redhat.com" Subject: Re: [PATCH, ARM] (commited) attribute target (thumb, arm) [5.2/6] respin (5th) References: <554A24D0.8020407@st.com> <554C7F50.4090705@arm.com> <5559A23B.9030705@st.com> <5559C2CD.4010701@st.com> <556C51F8.2000200@arm.com> In-Reply-To: <556C51F8.2000200@arm.com> X-No-Archive: yes X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151, 1.0.33, 0.0.0000 definitions=2015-06-11_04:2015-06-10, 2015-06-11, 1970-01-01 signatures=0 X-IsSubscribed: yes hi, commited attached patch rev#224365 many thanks, Christian On 06/01/2015 02:37 PM, Kyrill Tkachov wrote: > Hi Christian, > > On 18/05/15 11:45, Christian Bruel wrote: >> + additional chunks needed to redefine the macros for #pragma GCC target >> >> Applies on top of [5/6] >> >> thanks, >> >> Christian >> >> >> p5.2.patch >> >> >> 2014-09-23 Christian Bruel >> >> * config/arm/arm-c.c (arm_cpu_cpp_builtins): Conditionally define >> macros in ... >> (arm_cpu_builtins): New function. >> (arm_pragma_target_parse): Call arm_cpu_builtins. >> * config/arm/arm-protos.h (arm_cpu_builtins): New function. > > This is ok once the previous patches in the series approved. > > Thanks, > Kyrill > Index: gcc/ChangeLog =================================================================== --- gcc/ChangeLog (revision 224364) +++ gcc/ChangeLog (revision 224365) @@ -1,3 +1,17 @@ +2015-06-11 Christian Bruel + + PR target/52144 + * config/arm/arm-c.c (arm_cpu_cpp_builtins): Conditionally define + macros in ... + (arm_cpu_builtins): New function. + (arm_pragma_target_parse): Call arm_cpu_builtins. + * config/arm/arm-protos.h (arm_cpu_builtins): Declare. + (arm_register_target_pragmas): Likewise. + * config/arm/arm.h (REGISTER_TARGET_PRAGMAS): + Call arm_register_target_pragmas. + * config/arm/arm-c.c (arm_register_target_pragmas): New function. + (arm_pragma_target_parse): Likewise. + 2015-06-10 Kaz Kojima * config/sh/sh.md (tstsi_t): Add '?' modifier to 'r' alternative Index: gcc/testsuite/gcc.target/arm/pragma_attribute.c =================================================================== --- gcc/testsuite/gcc.target/arm/pragma_attribute.c (revision 0) +++ gcc/testsuite/gcc.target/arm/pragma_attribute.c (revision 224365) @@ -0,0 +1,35 @@ +/* Test for #prama target macros. */ +/* { dg-do compile } */ +/* { dg-require-effective-target arm_thumb1_ok } */ + +#pragma GCC target ("thumb") + +#ifndef __thumb__ +#error "__thumb__ is not defined" +#endif + +#ifdef __thumb2__ +#ifndef __ARM_32BIT_STATE +#error "__ARM_32BIT_STATE is not defined" +#endif +#else /* thumb1 */ +#ifdef __ARM_32BIT_STATE +#error "__ARM_32BIT_STATE is defined" +#endif +#endif /* thumb1 */ + +#pragma GCC target ("arm") + +#ifdef __thumb__ +#error "__thumb__ is defined" +#endif + +#if defined (__thumb2__) || defined (__thumb1__) +#error "thumb is defined" +#endif + +#ifndef __ARM_32BIT_STATE +#error "__ARM_32BIT_STATE is not defined" +#endif + +#pragma GCC reset_options Index: gcc/testsuite/ChangeLog =================================================================== --- gcc/testsuite/ChangeLog (revision 224364) +++ gcc/testsuite/ChangeLog (revision 224365) @@ -1,3 +1,8 @@ +2015-06-11 Christian Bruel + + PR target/52144 + * gcc.target/arm/pragma_attribute.c: New test. + 2015-06-10 Uros Bizjak * g++.dg/abi/mangle-regparm.C (dg-optiond): Add -save-temps. @@ -13,7 +18,7 @@ * gcc.dg/tls/pr66470.c: New test. * gcc.target/i386/pr66470.c: New test. -2015-06-09 Christian Bruel +2015-06-10 Christian Bruel PR target/52144 * gcc.target/arm/attr_arm.c: New test Index: gcc/config/arm/arm.h =================================================================== --- gcc/config/arm/arm.h (revision 224364) +++ gcc/config/arm/arm.h (revision 224365) @@ -1991,7 +1991,8 @@ c_register_pragma (0, "long_calls", arm_pr_long_calls); \ c_register_pragma (0, "no_long_calls", arm_pr_no_long_calls); \ c_register_pragma (0, "long_calls_off", arm_pr_long_calls_off); \ - arm_lang_object_attributes_init(); \ + arm_lang_object_attributes_init(); \ + arm_register_target_pragmas(); \ } while (0) /* Condition code information. */ Index: gcc/config/arm/arm-protos.h =================================================================== --- gcc/config/arm/arm-protos.h (revision 224364) +++ gcc/config/arm/arm-protos.h (revision 224365) @@ -211,10 +211,10 @@ extern void arm_mark_dllexport (tree); extern void arm_mark_dllimport (tree); extern bool arm_change_mode_p (tree); +#endif + extern tree arm_valid_target_attribute_tree (tree, struct gcc_options *, struct gcc_options *); -#endif - extern void arm_pr_long_calls (struct cpp_reader *); extern void arm_pr_no_long_calls (struct cpp_reader *); extern void arm_pr_long_calls_off (struct cpp_reader *); @@ -336,7 +336,9 @@ /* Defined in gcc/common/config/arm-c.c. */ extern void arm_lang_object_attributes_init (void); +extern void arm_register_target_pragmas (void); extern void arm_cpu_cpp_builtins (struct cpp_reader *); +extern void arm_cpu_builtins (struct cpp_reader *, int); extern bool arm_is_constant_pool_ref (rtx); Index: gcc/config/arm/arm-c.c =================================================================== --- gcc/config/arm/arm-c.c (revision 224364) +++ gcc/config/arm/arm-c.c (revision 224365) @@ -25,7 +25,11 @@ #include "alias.h" #include "symtab.h" #include "tree.h" +#include "tm_p.h" #include "c-family/c-common.h" +#include "target.h" +#include "target-def.h" +#include "c-family/c-pragma.h" /* Output C specific EABI object attributes. These can not be done in arm.c because they require information from the C frontend. */ @@ -62,10 +66,8 @@ } void -arm_cpu_cpp_builtins (struct cpp_reader * pfile) +arm_cpu_builtins (struct cpp_reader* pfile, int flags) { - int flags = target_flags; - def_or_undef_macro (pfile, "__ARM_FEATURE_DSP", TARGET_DSP_MULTIPLY_P (flags)); def_or_undef_macro (pfile, "__ARM_FEATURE_QBIT", @@ -157,8 +159,6 @@ if (arm_cpp_interwork) builtin_define ("__THUMB_INTERWORK__"); - builtin_assert ("cpu=arm"); - builtin_assert ("machine=arm"); builtin_define (arm_arch_name); if (arm_arch_xscale) @@ -179,10 +179,90 @@ builtin_define ("__ARM_EABI__"); } - - def_or_undef_macro (pfile, "__ARM_ARCH_EXT_IDIV__", TARGET_IDIV_P (flags)); def_or_undef_macro (pfile, "__ARM_FEATURE_IDIV", TARGET_IDIV_P (flags)); def_or_undef_macro (pfile, "__ARM_ASM_SYNTAX_UNIFIED__", inline_asm_unified); } + +void +arm_cpu_cpp_builtins (struct cpp_reader * pfile) +{ + builtin_assert ("cpu=arm"); + builtin_assert ("machine=arm"); + + arm_cpu_builtins (pfile, target_flags); +} + +/* Hook to validate the current #pragma GCC target and set the arch custom + mode state. If ARGS is NULL, then POP_TARGET is used to reset + the options. */ +static bool +arm_pragma_target_parse (tree args, tree pop_target) +{ + tree prev_tree = build_target_option_node (&global_options); + tree cur_tree; + struct cl_target_option *prev_opt; + struct cl_target_option *cur_opt; + + if (! args) + { + cur_tree = ((pop_target) ? pop_target : target_option_default_node); + cl_target_option_restore (&global_options, + TREE_TARGET_OPTION (cur_tree)); + } + else + { + cur_tree = arm_valid_target_attribute_tree (args, &global_options, + &global_options_set); + if (cur_tree == NULL_TREE) + { + cl_target_option_restore (&global_options, + TREE_TARGET_OPTION (prev_tree)); + return false; + } + } + + target_option_current_node = cur_tree; + arm_reset_previous_fndecl (); + + /* Figure out the previous mode. */ + prev_opt = TREE_TARGET_OPTION (prev_tree); + cur_opt = TREE_TARGET_OPTION (cur_tree); + + gcc_assert (prev_opt); + gcc_assert (cur_opt); + + if (cur_opt->x_target_flags != prev_opt->x_target_flags) + { + /* For the definitions, ensure all newly defined macros are considered + as used for -Wunused-macros. There is no point warning about the + compiler predefined macros. */ + cpp_options *cpp_opts = cpp_get_options (parse_in); + unsigned char saved_warn_unused_macros = cpp_opts->warn_unused_macros; + cpp_opts->warn_unused_macros = 0; + + /* Update macros. */ + arm_cpu_builtins (parse_in, cur_opt->x_target_flags); + + cpp_opts->warn_unused_macros = saved_warn_unused_macros; + } + + return true; +} + +/* Register target pragmas. We need to add the hook for parsing #pragma GCC + option here rather than in arm.c since it will pull in various preprocessor + functions, and those are not present in languages like fortran without a + preprocessor. */ + +void +arm_register_target_pragmas (void) +{ + /* Update pragma hook to allow parsing #pragma GCC target. */ + targetm.target_option.pragma_parse = arm_pragma_target_parse; + +#ifdef REGISTER_SUBTARGET_PRAGMAS + REGISTER_SUBTARGET_PRAGMAS (); +#endif +}