From patchwork Mon Jun 22 07:57:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Bruel X-Patchwork-Id: 487117 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 9B6FE140310 for ; Mon, 22 Jun 2015 17:57:47 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=nvPECZq6; 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=tudOPG8u9pMfB+o5H odWrVFY0x3RgH4IjIz2W6PAEAWtaVYC+zkNipCF9vGKb48VLv000gp7J4we9TrKe 5T34qWiPzTXsyFIoO/Q1K3eP18KFRyai9Y9hk7TKmNVnuNxq5LhIgyhjZRFMYxbj YMt0nuteqU8C0GrB7RLMlzv1j4= 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=0eDIRx/XX+DPvjfhs2XYKk2 O4Z8=; b=nvPECZq677yvXQY4vZtvostD+8ybSqBGP7+cRRW+/ERmlw+08vW3kI9 VZa7dcWwv4yF2LYumWBiRNw0O9MnLJOuF9/0Pj2OLTPhOKQxszjy/t5VN3D4YMWg 86Eyor2QlQOkUhPFRvnYWHrquDSLb9MUEwtbp70OCXJ4hTlCMH/A= Received: (qmail 119984 invoked by alias); 22 Jun 2015 07:57:39 -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 119970 invoked by uid 89); 22 Jun 2015 07:57:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.1 required=5.0 tests=AWL, BAYES_00, 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; Mon, 22 Jun 2015 07:57:37 +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 t5M7moYn006594; Mon, 22 Jun 2015 09:57:30 +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 1v6ajcgxek-1 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Mon, 22 Jun 2015 09:57:30 +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 5A9A846; Mon, 22 Jun 2015 07:57:28 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas4.st.com [10.75.90.69]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 227082982; Mon, 22 Jun 2015 07:57:28 +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; Mon, 22 Jun 2015 09:57:25 +0200 Message-ID: <5587BC61.4020005@st.com> Date: Mon, 22 Jun 2015 09:57:25 +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 , "gcc-patches@gcc.gnu.org" , Ramana Radhakrishnan Subject: Re: [PATCH, ARM] (commited) attribute target (thumb, arm) [6/6] respin (5th) References: <554A253A.4080905@st.com> <5559A5B4.7050007@st.com> <5576BA3C.2020101@foss.arm.com> In-Reply-To: <5576BA3C.2020101@foss.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-22_01:2015-06-18, 2015-06-21, 1970-01-01 signatures=0 X-IsSubscribed: yes Hello, > How about adding 'Undocumented' to the properties here? > > Can we also get a test or two just to sanity check the option? > Otherwise the patch looks ok to me. > > Thanks, > Kyrill > I've committed the attached patch. Sorry for the delay sorting out the false failures. Christian Index: ChangeLog =================================================================== --- ChangeLog (revision 224720) +++ ChangeLog (revision 224722) @@ -1,3 +1,11 @@ +2015-06-22 Christian Bruel + + PR target/52144 + * config/arm/arm.c (add_attribute, arm_insert_attributes): New functions + (TARGET_INSERT_ATTRIBUTES): Define. + (thumb_flipper): New var. + * config/arm/arm.opt (-mflip-thumb): New switch. + 2015-06-22 Jan Hubicka Martin Liska Index: testsuite/gcc.target/arm/flip-thumb.c =================================================================== --- testsuite/gcc.target/arm/flip-thumb.c (revision 0) +++ testsuite/gcc.target/arm/flip-thumb.c (revision 224722) @@ -0,0 +1,24 @@ +/* Check -mflip-thumb. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mflip-thumb -mno-restrict-it" } */ +/* { dg-final { scan-assembler ".arm" } } */ +/* { dg-final { scan-assembler-times ".thumb_func" 1} } */ + +int +foo(int a) +{ + return a ? 1 : 5; +} + +int +bar(int a) +{ + return a ? 1 : 5; +} + +/* { dg-final { scan-assembler-times "ite" 1 { target { arm_thumb2_ok } } } } */ + + + + + Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 224720) +++ testsuite/ChangeLog (revision 224722) @@ -1,3 +1,8 @@ +2015-06-22 Christian Bruel + + PR target/52144 + * gcc.target/arm/flip-thumb.c: New test. + 2015-06-22 Jan Hubicka Martin Liska Index: config/arm/arm.c =================================================================== --- config/arm/arm.c (revision 224720) +++ config/arm/arm.c (revision 224722) @@ -84,6 +84,7 @@ #include "tm-constrs.h" #include "rtl-iter.h" #include "sched-int.h" +#include "tree.h" /* Forward definitions of types. */ typedef struct minipool_node Mnode; @@ -218,6 +219,7 @@ static void arm_file_end (void); static void arm_file_start (void); +static void arm_insert_attributes (tree, tree *); static void arm_setup_incoming_varargs (cumulative_args_t, machine_mode, tree, int *, int); @@ -376,6 +378,9 @@ #undef TARGET_ATTRIBUTE_TABLE #define TARGET_ATTRIBUTE_TABLE arm_attribute_table +#undef TARGET_INSERT_ATTRIBUTES +#define TARGET_INSERT_ATTRIBUTES arm_insert_attributes + #undef TARGET_ASM_FILE_START #define TARGET_ASM_FILE_START arm_file_start #undef TARGET_ASM_FILE_END @@ -2792,6 +2797,10 @@ ? 1 : current_tune->max_insns_skipped; } +/* True if -mflip-thumb should next add an attribute for the default + mode, false if it should next add an attribute for the opposite mode. */ +static GTY(()) bool thumb_flipper; + /* Options after initial target override. */ static GTY(()) tree init_optimize; @@ -3369,6 +3378,9 @@ options. */ target_option_default_node = target_option_current_node = build_target_option_node (&global_options); + + /* Init initial mode for testing. */ + thumb_flipper = TARGET_THUMB; } static void @@ -29459,6 +29471,52 @@ return build_target_option_node (opts); } +static void +add_attribute (const char * mode, tree *attributes) +{ + size_t len = strlen (mode); + tree value = build_string (len, mode); + + TREE_TYPE (value) = build_array_type (char_type_node, + build_index_type (size_int (len))); + + *attributes = tree_cons (get_identifier ("target"), + build_tree_list (NULL_TREE, value), + *attributes); +} + +/* For testing. Insert thumb or arm modes alternatively on functions. */ + +static void +arm_insert_attributes (tree fndecl, tree * attributes) +{ + const char *mode; + + if (! TARGET_FLIP_THUMB) + return; + + if (TREE_CODE (fndecl) != FUNCTION_DECL || DECL_EXTERNAL(fndecl) + || DECL_BUILT_IN (fndecl) || DECL_ARTIFICIAL (fndecl)) + return; + + /* Nested definitions must inherit mode. */ + if (current_function_decl) + { + mode = TARGET_THUMB ? "thumb" : "arm"; + add_attribute (mode, attributes); + return; + } + + /* If there is already a setting don't change it. */ + if (lookup_attribute ("target", *attributes) != NULL) + return; + + mode = thumb_flipper ? "thumb" : "arm"; + add_attribute (mode, attributes); + + thumb_flipper = !thumb_flipper; +} + /* Hook to validate attribute((target("string"))). */ static bool Index: config/arm/arm.opt =================================================================== --- config/arm/arm.opt (revision 224720) +++ config/arm/arm.opt (revision 224722) @@ -122,6 +122,10 @@ EnumValue Enum(float_abi_type) String(hard) Value(ARM_FLOAT_ABI_HARD) +mflip-thumb +Target Report Var(TARGET_FLIP_THUMB) Undocumented +Switch ARM/Thumb modes on alternating functions for compiler testing + mfp16-format= Target RejectNegative Joined Enum(arm_fp16_format_type) Var(arm_fp16_format) Init(ARM_FP16_FORMAT_NONE) Specify the __fp16 floating-point format