From patchwork Wed May 6 14:20:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christian Bruel X-Patchwork-Id: 468971 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 863FB140295 for ; Thu, 7 May 2015 00:21:20 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=vb8RYuYl; 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:content-type; q= dns; s=default; b=W8gpNWI+L0TZs0eHSIQKFh8UNTjNYfNLFi7t84fS3ULlc0 6OVCiD9W+Vs1vHFVdS8pe+B6Lzc/fNWuzba2mCztHanWjqRARzAIxD1S4F7tyrO2 zaq1G1bWaqm/R7gANfBZ1o1D+2fEdpxGkyUHsL6aP4/NFeIBqBIsOgYHBxQTc= 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:content-type; s= default; bh=GSZhDQAtyellKRm/xz+ZdNNIua0=; b=vb8RYuYlSsmAWvD28Vis dKKyMjZfEWKdhsCRUYzNKKh6nksSfx+fq0TMZDQ0S/7Unwu03Xm2HxJLpScuvE8B nRysqcTB1dzmWvIF/i6ipkqqIw+iFCZ2qLqBmPVS5P+Yv10jJzrqYVjSKHRyqVb2 vHgq8kWJpCyEDSxBbAGRrzk= Received: (qmail 88769 invoked by alias); 6 May 2015 14:21:09 -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 88681 invoked by uid 89); 6 May 2015 14:21:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.3 required=5.0 tests=AWL, BAYES_50, 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; Wed, 06 May 2015 14:21:06 +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 t46E8OWS027294; Wed, 6 May 2015 16:20:59 +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 1u7k9rreqb-1 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 06 May 2015 16:20:59 +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 9EE203D; Wed, 6 May 2015 14:20:57 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas5.st.com [10.75.90.71]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 7805A4DFD; Wed, 6 May 2015 14:20:57 +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; Wed, 6 May 2015 16:20:57 +0200 Message-ID: <554A2348.6040205@st.com> Date: Wed, 6 May 2015 16:20:56 +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: "gcc-patches@gcc.gnu.org" , Ramana Radhakrishnan , Richard Earnshaw , Nicholas Clifton Subject: [PATCH, ARM] attribute target (thumb,arm) [2/6] respin (4th) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.14.151, 1.0.33, 0.0.0000 definitions=2015-05-06_04:2015-05-05, 2015-05-06, 1970-01-01 signatures=0 X-IsSubscribed: yes In preparation of the pragma target reorganize ÂTARGET_CPU_CPP_BUILTINSÂ to redefine mode dependent macros based on current thumb_p. Thanks, Christian 2014-09-23 Christian Bruel * config/arm/arm-c.c (cpp_def_or_undef): New functions. (arm_cpp_builtins): Likewise. * config/arm/arm.h (TARGET_CPU_CPP_BUILTINS): Move mode dependant macros to arm_cpp_builtins. * config/arm/arm-protos.h (arm_cpp_builtins): Declare. diff '--exclude=.svn' -ruN gnu_trunk.p1/gcc/gcc/config/arm/arm-c.c gnu_trunk.p2/gcc/gcc/config/arm/arm-c.c --- gnu_trunk.p1/gcc/gcc/config/arm/arm-c.c 2015-05-06 14:06:27.508142998 +0200 +++ gnu_trunk.p2/gcc/gcc/config/arm/arm-c.c 2015-05-06 14:27:45.362310057 +0200 @@ -51,3 +51,73 @@ { arm_lang_output_object_attributes_hook = arm_output_c_attributes; } + +/* Define or undefine macro. */ + +static void +cpp_def_or_undef (struct cpp_reader *in, const char *str, bool def_p) +{ + if (def_p) + cpp_define (in, str); + else + cpp_undef (in, str); +} + +/* Define or undefine macros based on the current target. If the user does + #pragma GCC target, we need to adjust the macros dynamically. */ + +void +arm_cpp_builtins (struct cpp_reader *in, bool thumb_p) +{ + bool target_32bit_p = !thumb_p || arm_arch_thumb2; + bool thumb2_p = thumb_p && arm_arch_thumb2; + bool have_ldrex_p = (arm_arch6 && !thumb_p) || arm_arch7; + bool have_ldrexbh_p = (arm_arch6k && !thumb_p) || arm_arch7; + bool have_ldrexd_p = ((arm_arch6k && !thumb_p) || arm_arch7) + && arm_arch_notm; + + int arm_feature_ldrex = (have_ldrex_p ? 4 : 0) + | (have_ldrexbh_p ? 3 : 0) | (have_ldrexd_p ? 8 : 0); + + cpp_def_or_undef (in, "__thumb__", thumb_p); + if (arm_arch_thumb2) + cpp_def_or_undef (in, "__thumb2__", thumb_p); + if (TARGET_BIG_END) + cpp_def_or_undef (in, "__THUMBEB__", thumb_p); + else + cpp_def_or_undef (in, "__THUMBEL__", thumb_p); + + cpp_def_or_undef (in, "__ARM_32BIT_STATE", target_32bit_p); /* TARGET_32BIT */ + + if (arm_arch5e && (arm_arch_notm || arm_arch7)) /* TARGET_ARM_QBIT */ + cpp_def_or_undef (in, "__ARM_FEATURE_QBIT", target_32bit_p); + + if (arm_arch6 && (arm_arch_notm || arm_arch7)) /* TARGET_ARM_SAT */ + cpp_def_or_undef (in, "__ARM_FEATURE_SAT", target_32bit_p); + + if (arm_arch5e && (arm_arch_notm || arm_arch7em)) /* TARGET_DSP_MULTIPLY */ + cpp_def_or_undef (in, "__ARM_FEATURE_DSP", target_32bit_p); + + if (arm_arch6 && (arm_arch_notm || arm_arch7em)) /* TARGET_INT_SIMD */ + cpp_def_or_undef (in, "__ARM_FEATURE_SIMD32", target_32bit_p); + + /* TARGET_IDIV */ + cpp_def_or_undef (in, "__ARM_ARCH_EXT_IDIV__", + ((!thumb_p && arm_arch_arm_hwdiv) + || (thumb2_p && arm_arch_thumb_hwdiv))); + + cpp_def_or_undef (in, "__ARM_FEATURE_IDIV", + ((!thumb_p && arm_arch_arm_hwdiv) + || (thumb2_p && arm_arch_thumb_hwdiv))); + + if (arm_feature_ldrex) + cpp_define_formatted (in, "__ARM_FEATURE_LDREX=%d", arm_feature_ldrex); + else + cpp_undef (in, "__ARM_FEATURE_LDREX"); + + cpp_def_or_undef (in, "__ARM_FEATURE_CLZ", + ((TARGET_ARM_ARCH >= 5 && !thumb_p) || TARGET_ARM_ARCH_ISA_THUMB >=2)); + + cpp_def_or_undef (in, "__ARM_ASM_SYNTAX_UNIFIED__", inline_asm_unified); +} + diff '--exclude=.svn' -ruN gnu_trunk.p1/gcc/gcc/config/arm/arm.h gnu_trunk.p2/gcc/gcc/config/arm/arm.h --- gnu_trunk.p1/gcc/gcc/config/arm/arm.h 2015-05-06 14:24:41.149994939 +0200 +++ gnu_trunk.p2/gcc/gcc/config/arm/arm.h 2015-05-06 14:27:45.362310057 +0200 @@ -48,29 +48,12 @@ #define TARGET_CPU_CPP_BUILTINS() \ do \ { \ - if (TARGET_DSP_MULTIPLY) \ - builtin_define ("__ARM_FEATURE_DSP"); \ - if (TARGET_ARM_QBIT) \ - builtin_define ("__ARM_FEATURE_QBIT"); \ - if (TARGET_ARM_SAT) \ - builtin_define ("__ARM_FEATURE_SAT"); \ if (TARGET_CRYPTO) \ builtin_define ("__ARM_FEATURE_CRYPTO"); \ if (unaligned_access) \ builtin_define ("__ARM_FEATURE_UNALIGNED"); \ if (TARGET_CRC32) \ builtin_define ("__ARM_FEATURE_CRC32"); \ - if (TARGET_32BIT) \ - builtin_define ("__ARM_32BIT_STATE"); \ - if (TARGET_ARM_FEATURE_LDREX) \ - builtin_define_with_int_value ( \ - "__ARM_FEATURE_LDREX", TARGET_ARM_FEATURE_LDREX); \ - if ((TARGET_ARM_ARCH >= 5 && !TARGET_THUMB) \ - || TARGET_ARM_ARCH_ISA_THUMB >=2) \ - builtin_define ("__ARM_FEATURE_CLZ"); \ - if (TARGET_INT_SIMD) \ - builtin_define ("__ARM_FEATURE_SIMD32"); \ - \ builtin_define_with_int_value ( \ "__ARM_SIZEOF_MINIMAL_ENUM", \ flag_short_enums ? 1 : 4); \ @@ -89,10 +72,6 @@ if (arm_arch_notm) \ builtin_define ("__ARM_ARCH_ISA_ARM"); \ builtin_define ("__APCS_32__"); \ - if (TARGET_THUMB) \ - builtin_define ("__thumb__"); \ - if (TARGET_THUMB2) \ - builtin_define ("__thumb2__"); \ if (TARGET_ARM_ARCH_ISA_THUMB) \ builtin_define_with_int_value ( \ "__ARM_ARCH_ISA_THUMB", \ @@ -102,15 +81,9 @@ { \ builtin_define ("__ARMEB__"); \ builtin_define ("__ARM_BIG_ENDIAN"); \ - if (TARGET_THUMB) \ - builtin_define ("__THUMBEB__"); \ } \ else \ - { \ builtin_define ("__ARMEL__"); \ - if (TARGET_THUMB) \ - builtin_define ("__THUMBEL__"); \ - } \ \ if (TARGET_SOFT_FLOAT) \ builtin_define ("__SOFTFP__"); \ @@ -163,13 +136,8 @@ builtin_define ("__ARM_PCS"); \ builtin_define ("__ARM_EABI__"); \ } \ - if (TARGET_IDIV) \ - { \ - builtin_define ("__ARM_ARCH_EXT_IDIV__"); \ - builtin_define ("__ARM_FEATURE_IDIV"); \ - } \ - if (inline_asm_unified) \ - builtin_define ("__ARM_ASM_SYNTAX_UNIFIED__");\ + /* Remaining macros depends on TARGET_THUMB. */\ + arm_cpp_builtins (pfile, TARGET_THUMB); \ } while (0) #include "config/arm/arm-opts.h" diff '--exclude=.svn' -ruN gnu_trunk.p1/gcc/gcc/config/arm/arm-protos.h gnu_trunk.p2/gcc/gcc/config/arm/arm-protos.h --- gnu_trunk.p1/gcc/gcc/config/arm/arm-protos.h 2015-05-06 14:06:26.324141030 +0200 +++ gnu_trunk.p2/gcc/gcc/config/arm/arm-protos.h 2015-05-06 14:27:45.362310057 +0200 @@ -218,8 +218,6 @@ extern void arm_pr_no_long_calls (struct cpp_reader *); extern void arm_pr_long_calls_off (struct cpp_reader *); -extern void arm_lang_object_attributes_init(void); - extern const char *arm_mangle_type (const_tree); extern const char *arm_mangle_builtin_type (const_tree); @@ -324,6 +322,10 @@ /* Defined in gcc/common/config/arm-common.c. */ extern const char *arm_rewrite_selected_cpu (const char *name); +/* Defined in gcc/common/config/arm-c.c. */ +extern void arm_lang_object_attributes_init(void); +extern void arm_cpp_builtins (struct cpp_reader *, bool); + extern bool arm_is_constant_pool_ref (rtx); /* Flags used to identify the presence of processor capabilities. */