From patchwork Tue Oct 21 09:18:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Terry Guo X-Patchwork-Id: 401389 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 7DA2B140077 for ; Tue, 21 Oct 2014 20:19:15 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=Zd7YnclJxXbauI8X492REaso6SEIaGjhag3rSjREQe3GzH7JNI KP9iCD/7Z5VXVRF/GTYzRUOLR4lFVnupap+qdfzFLB1iznYu/oh+gy1UvBALViA7 XlXGmAuuPhovjl3E+evpvYJ8ZpX24d+FqYslwYlg4WEWnii4kh1aFtKtA= 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:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=AKrFY3VF+HXhUPNZPdF7SOBVzDU=; b=WrCro981mQVKh0fYYGTV Oae+Yxhq4zgpNYEwVd6v5AKykule9BhHe7XrFVZQyrnpqmtXIg00Dd0g0uZJ1oIj SB74pGJFyjp2Gk1bkc4apI6s78+1X5oEnZ/zpLI04CMvK4dfqknTWH5MgnANAxei 3DTlLV/Pt6850hb7cLkOEqU= Received: (qmail 8785 invoked by alias); 21 Oct 2014 09:19:08 -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 8772 invoked by uid 89); 21 Oct 2014 09:19:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Oct 2014 09:19:06 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Tue, 21 Oct 2014 10:19:03 +0100 Received: from shawin252 ([10.164.2.44]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 21 Oct 2014 10:19:01 +0100 From: "Terry Guo" To: Cc: "Ramana Radhakrishnan" Subject: [1/2][PATCH,ARM]Generate UAL assembly code for Thumb-1 target Date: Tue, 21 Oct 2014 17:18:55 +0800 Message-ID: <000001cfed10$0a84aac0$1f8e0040$@arm.com> MIME-Version: 1.0 X-MC-Unique: 114102110190308401 X-IsSubscribed: yes Hi There, This is the first patch to enable GCC generate UAL assembly code for Thumb1 target. This new option enables user to specify which syntax is used in their inline assembly code. If the inline assembly code uses UAL format, then gcc does nothing because gcc generates UAL code as well. If the inline assembly code uses non-UAL, then gcc will insert some directives in final assembly code. Is it ok to trunk? BR, Terry 2014-10-21 Terry Guo * config/arm/arm.h (TARGET_UNIFIED_ASM): Also include thumb1. (ASM_APP_ON): Redefined. * config/arm/arm.c (arm_option_override): Thumb2 always uses UAL for inline assembly code. * config/arm/arm.opt (masm-syntax-unified): New option. * doc/invoke.texi (-masm-syntax-unified): Document new option. diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index 3623c70..e654e22 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -165,6 +165,8 @@ extern char arm_arch_name[]; } \ if (TARGET_IDIV) \ builtin_define ("__ARM_ARCH_EXT_IDIV__"); \ + if (inline_asm_unified) \ + builtin_define ("__ARM_ASM_SYNTAX_UNIFIED__");\ } while (0) #include "config/arm/arm-opts.h" @@ -348,8 +350,8 @@ extern void (*arm_lang_output_object_attributes_hook)(void); || (!optimize_size && !current_tune->prefer_constant_pool))) /* We could use unified syntax for arm mode, but for now we just use it - for Thumb-2. */ -#define TARGET_UNIFIED_ASM TARGET_THUMB2 + for thumb mode. */ +#define TARGET_UNIFIED_ASM (TARGET_THUMB) /* Nonzero if this chip provides the DMB instruction. */ #define TARGET_HAVE_DMB (arm_arch6m || arm_arch7) @@ -2144,8 +2146,13 @@ extern int making_const_table; #define CC_STATUS_INIT \ do { cfun->machine->thumb1_cc_insn = NULL_RTX; } while (0) +#undef ASM_APP_ON +#define ASM_APP_ON (inline_asm_unified ? "\t.syntax unified" : \ + "\t.syntax divided\n") + #undef ASM_APP_OFF -#define ASM_APP_OFF (TARGET_ARM ? "" : "\t.thumb\n") +#define ASM_APP_OFF (TARGET_ARM ? "\t.arm\n\t.syntax divided\n" : \ + "\t.thumb\n\t.syntax unified\n") /* Output a push or a pop instruction (only used when profiling). We can't push STATIC_CHAIN_REGNUM (r12) directly with Thumb-1. We know diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 1ee0eb3..9ccf73c 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -3121,6 +3121,11 @@ arm_option_override (void) if (target_slow_flash_data) arm_disable_literal_pool = true; + /* Thumb2 inline assembly code should always use unified syntax. + This will apply to ARM and Thumb1 eventually. */ + if (TARGET_THUMB2) + inline_asm_unified = 1; + /* Register global variables with the garbage collector. */ arm_add_gc_roots (); } diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt index 0a80513..50f4c7d 100644 --- a/gcc/config/arm/arm.opt +++ b/gcc/config/arm/arm.opt @@ -271,3 +271,7 @@ Use Neon to perform 64-bits operations rather than core registers. mslow-flash-data Target Report Var(target_slow_flash_data) Init(0) Assume loading data from flash is slower than fetching instructions. + +masm-syntax-unified +Target Report Var(inline_asm_unified) Init(0) +Assume unified syntax for Thumb inline assembly code. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 23f272f..c30c858 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -545,6 +545,7 @@ Objective-C and Objective-C++ Dialects}. -munaligned-access @gol -mneon-for-64bits @gol -mslow-flash-data @gol +-masm-syntax-unified @gol -mrestrict-it} @emph{AVR Options} @@ -12954,6 +12955,14 @@ Therefore literal load is minimized for better performance. This option is only supported when compiling for ARMv7 M-profile and off by default. +@item -masm-syntax-unified +@opindex masm-syntax-unified +Assume the Thumb1 inline assembly code are using unified syntax. +The default is currently off, which means divided syntax is assumed. +However, this may change in future releases of GCC. Divided syntax +should be considered deprecated. This option has no effect when +generating Thumb2 code. Thumb2 assembly code always uses unified syntax. + @item -mrestrict-it @opindex mrestrict-it Restricts generation of IT blocks to conform to the rules of ARMv8.