Re: [Patch ARM] Switch ARM to unified asm.

2015-11-12 Thread Ramana Radhakrishnan
On Thu, Nov 12, 2015 at 9:21 AM, Christian Bruel  wrote:
> Hi Ramana,
>
> On 11/10/2015 12:48 PM, Ramana Radhakrishnan wrote:
>>
>> [Resending as I managed to muck this up with my mail client]
>>
>> Hi,
>>
>> I held off committing a previous version of this patch that I posted in
>> July to be nice to folks backporting fixes and to watch for any objections
>> to move the ARM backend completely over into the unified assembler.
>>
>> The patch does the following.
>>
>> * The compiler now generates code in all ISA modes in unified asm.
>> * We've had unified asm only for the last 10 years, ever since the first
>> Thumb2 support was put in, the disassembler generates output in unified
>> assembler, while the compiler output is always in divided syntax for ARM
>> state.
>> * This means patterns get simpler not having to worry about the position
>> of the condition in a conditional instruction. For example we now
>> consistently use
>> a. ldrbeq rather than ldreqb
>> b. movseq rather than moveqs
>> c. Or indeed the appropriate push / pop instructions whereever
>> appropriate.
>>
>>
>> The compiler behaviour has not changed in terms of what it does with
>> inline assembler, that still remains in divided syntax and over time we need
>> to move all of this over to unified syntax if we can do so as all the
>> official documentation is now in terms of unified asm. I've been carrying
>> this in my tree for quite a while and am reasonably happy that it is stable.
>> I will watch out for any fallout in the coming weeks with this but it is
>> better to take this now rather than later given we are hitting the end of
>> stage1.
>>
>> Tested on arm-none-eabi - applied to trunk.
>>
>>
>
> I see a failure with an outdated check for the unified assembly. OK to fix ?
>

OK thanks.

Ramana
>
>


[Patch ARM] Switch ARM to unified asm.

2015-11-10 Thread Ramana Radhakrishnan
[Resending as I managed to muck this up with my mail client]

Hi,

I held off committing a previous version of this patch that I posted in July to 
be nice to folks backporting fixes and to watch for any objections to move the 
ARM backend completely over into the unified assembler.

The patch does the following.

* The compiler now generates code in all ISA modes in unified asm.
* We've had unified asm only for the last 10 years, ever since the first Thumb2 
support was put in, the disassembler generates output in unified assembler, 
while the compiler output is always in divided syntax for ARM state.
* This means patterns get simpler not having to worry about the position of the 
condition in a conditional instruction. For example we now consistently use 
   a. ldrbeq rather than ldreqb 
   b. movseq rather than moveqs 
   c. Or indeed the appropriate push / pop instructions whereever appropriate.


The compiler behaviour has not changed in terms of what it does with inline 
assembler, that still remains in divided syntax and over time we need to move 
all of this over to unified syntax if we can do so as all the official 
documentation is now in terms of unified asm. I've been carrying this in my 
tree for quite a while and am reasonably happy that it is stable. I will watch 
out for any fallout in the coming weeks with this but it is better to take this 
now rather than later given we are hitting the end of stage1.

Tested on arm-none-eabi - applied to trunk.

regards
Ramana

gcc/ChangeLog:

2015-11-06  Ramana Radhakrishnan  

* config/arm/arm-ldmstm.ml: Rewrite to generate unified asm templates.
* config/arm/arm.c (arm_asm_trampoline_template): Make unified asm safe.
(arm_output_multireg_pop): Likewise.
(output_move_double):  Likewise.
(output_move_quad):  Likewise.
(output_return_instruction): Likewise.
(arm_print_operand): Remove support for %( and %. print modifiers.
(arm_output_shift): Make unified asm.
(arm_declare_function_name): Likewise.
* config/arm/arm.h (TARGET_UNIFIED_ASM): Delete.
 (ASM_APP_OFF): Adjust.
 (ASM_OUTPUT_REG_PUSH): Undo special casing for TARGET_ARM.
 (ASM_OUTPUT_REG_POP): Likewise.
* config/arm/arm.md: Adjust uses of %., %(, %) 
* config/arm/sync.md: Likewise.
* config/arm/thumb2.md: Likewise.
* config/arm/ldmstm.md: Regenerate.
* config/arm/arm.opt (masm-unified-syntax): Do not special case Thumb.
* doc/invoke.texi (masm-unified-syntax): Update documentation.

gcc/testsuite/ChangeLog:

2015-11-06  Ramana Radhakrishnan  

* gcc.target/arm/combine-movs.c:
* gcc.target/arm/interrupt-1.c:
* gcc.target/arm/interrupt-2.c:
* gcc.target/arm/unaligned-memcpy-4.c:

>From 265ab44e7d5a9d3807951d0b768b7115aecfe6d6 Mon Sep 17 00:00:00 2001
From: Ramana Radhakrishnan 
Date: Thu, 5 Nov 2015 10:04:50 +
Subject: [PATCH] uasm jumbo

---
 gcc/config/arm/arm-ldmstm.ml  |  23 ++-
 gcc/config/arm/arm.c  | 157 -
 gcc/config/arm/arm.h  |  19 +--
 gcc/config/arm/arm.md | 162 ++
 gcc/config/arm/arm.opt|   2 +-
 gcc/config/arm/ldmstm.md  | 126 -
 gcc/config/arm/sync.md|   4 +-
 gcc/config/arm/thumb2.md  |  12 +-
 gcc/doc/invoke.texi   |   7 +-
 gcc/testsuite/gcc.target/arm/combine-movs.c   |   3 +-
 gcc/testsuite/gcc.target/arm/interrupt-1.c|   4 +-
 gcc/testsuite/gcc.target/arm/interrupt-2.c|   4 +-
 gcc/testsuite/gcc.target/arm/unaligned-memcpy-4.c |   2 +-
 13 files changed, 240 insertions(+), 285 deletions(-)

diff --git a/gcc/config/arm/arm-ldmstm.ml b/gcc/config/arm/arm-ldmstm.ml
index bb90192..62982df 100644
--- a/gcc/config/arm/arm-ldmstm.ml
+++ b/gcc/config/arm/arm-ldmstm.ml
@@ -33,9 +33,20 @@ type amode = IA | IB | DA | DB
 
 type optype = IN | OUT | INOUT
 
-let rec string_of_addrmode addrmode =
+let rec string_of_addrmode addrmode thumb update =
+  if thumb || update
+then
   match addrmode with
-IA -> "ia" | IB -> "ib" | DA -> "da" | DB -> "db"
+IA -> "ia"
+  | IB -> "ib"
+  | DA -> "da"
+  | DB -> "db"
+else
+  match addrmode with
+IA -> ""
+  | IB -> "ib"
+  | DA -> "da"
+  | DB -> "db"
 
 let rec initial_offset addrmode nregs =
   match addrmode with
@@ -160,7 +171,7 @@ let target addrmode thumb =
   | _, _ -> raise (InvalidAddrMode "ERROR: Invalid Addressing mode for Thumb1.")
 
 let write_pattern_1 name ls addrmode nregs write_set_fn update thumb =
-  let astr = string_of_addrmode addrmode in
+  let astr = string_of_addrmode addrmode thumb update in
   Printf.printf "(define_insn \"*%s%s%d_%s%s\"\n"
 (if thumb then "thumb_" else "") name nregs astr
 (if update then "_update