- Include svn rev 12548 to fix invalid generation of Thumb-2 branch

instruction TBH (upstream PR#5623, RHBZ#821153).
This commit is contained in:
Richard W.M. Jones 2012-06-03 20:06:35 +01:00
parent 64a0f51339
commit 1296d4b409
2 changed files with 50 additions and 35 deletions

View File

@ -1,16 +1,19 @@
From 5017142a41b2ea9b81d41ff7d513847b9df7bae9 Mon Sep 17 00:00:00 2001 From 22fadc3ed91cb380f7303e8a83ff5806d4576cb5 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com> From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 29 May 2012 20:50:42 +0100 Date: Tue, 29 May 2012 20:50:42 +0100
Subject: [PATCH 7/7] New ARM backend, written by Benedikt Meurer (PR#5433). Subject: [PATCH] New ARM backend, written by Benedikt Meurer (PR#5433).
Backported from upstream sources to 3.12.1 by RWMJ. Backported from upstream sources to 3.12.1 by RWMJ.
Includes svn rev 12548 to fix invalid generation of Thumb-2 branch
instruction TBH (upstream PR#5623, RHBZ#821153).
--- ---
asmcomp/amd64/selection.ml | 14 +- asmcomp/amd64/selection.ml | 14 +-
asmcomp/arm/arch.ml | 152 +++++++- asmcomp/arm/arch.ml | 152 +++++++-
asmcomp/arm/emit.mlp | 850 ++++++++++++++++++++++++++++-------------- asmcomp/arm/emit.mlp | 857 ++++++++++++++++++++++++++++--------------
asmcomp/arm/proc.ml | 185 +++++++--- asmcomp/arm/proc.ml | 185 ++++++---
asmcomp/arm/reload.ml | 4 +- asmcomp/arm/reload.ml | 4 +-
asmcomp/arm/scheduling.ml | 80 +++-- asmcomp/arm/scheduling.ml | 80 ++--
asmcomp/arm/selection.ml | 343 ++++++++++------- asmcomp/arm/selection.ml | 343 ++++++++++-------
asmcomp/i386/selection.ml | 14 +- asmcomp/i386/selection.ml | 14 +-
asmcomp/power/selection.ml | 2 +- asmcomp/power/selection.ml | 2 +-
@ -21,7 +24,7 @@ Backported from upstream sources to 3.12.1 by RWMJ.
asmrun/arm.S | 544 ++++++++++++++++----------- asmrun/arm.S | 544 ++++++++++++++++-----------
asmrun/signals_osdep.h | 2 +- asmrun/signals_osdep.h | 2 +-
configure | 11 +- configure | 11 +-
16 files changed, 1477 insertions(+), 743 deletions(-) 16 files changed, 1485 insertions(+), 742 deletions(-)
diff --git a/asmcomp/amd64/selection.ml b/asmcomp/amd64/selection.ml diff --git a/asmcomp/amd64/selection.ml b/asmcomp/amd64/selection.ml
index f0546cf..5d9f6fa 100644 index f0546cf..5d9f6fa 100644
@ -265,7 +268,7 @@ index 998fa4b..c4aca8d 100644
+ done; + done;
+ !s <= m + !s <= m
diff --git a/asmcomp/arm/emit.mlp b/asmcomp/arm/emit.mlp diff --git a/asmcomp/arm/emit.mlp b/asmcomp/arm/emit.mlp
index a4b2241..846ee4a 100644 index a4b2241..f8db396 100644
--- a/asmcomp/arm/emit.mlp --- a/asmcomp/arm/emit.mlp
+++ b/asmcomp/arm/emit.mlp +++ b/asmcomp/arm/emit.mlp
@@ -1,16 +1,17 @@ @@ -1,16 +1,17 @@
@ -1146,7 +1149,7 @@ index a4b2241..846ee4a 100644
` cmp {emit_reg i.arg.(0)}, #1\n`; ` cmp {emit_reg i.arg.(0)}, #1\n`;
begin match lbl0 with begin match lbl0 with
None -> () None -> ()
@@ -495,108 +732,135 @@ let emit_instr i = @@ -495,108 +732,144 @@ let emit_instr i =
| Some lbl -> ` bgt {emit_label lbl}\n` | Some lbl -> ` bgt {emit_label lbl}\n`
end; end;
4 4
@ -1156,34 +1159,42 @@ index a4b2241..846ee4a 100644
- for i = 0 to Array.length jumptbl - 1 do - for i = 0 to Array.length jumptbl - 1 do
- ` .word {emit_label jumptbl.(i)}\n` - ` .word {emit_label jumptbl.(i)}\n`
- done; - done;
- 2 + Array.length jumptbl
+ | Lswitch jumptbl -> + | Lswitch jumptbl ->
+ if !arch > ARMv6 && !thumb then begin + if !arch > ARMv6 && !thumb then begin
+ let lbl = new_label() in + (* The Thumb-2 TBH instruction supports only forward branches,
+ ` tbh [pc, {emit_reg i.arg.(0)}]\n`; + so we need to generate appropriate trampolines for all labels
+ `{emit_label lbl}:`; + that appear before this switch instruction (PR#5623) *)
+ for i = 0 to Array.length jumptbl - 1 do + let tramtbl = Array.copy jumptbl in
+ ` .short ({emit_label jumptbl.(i)}-{emit_label lbl})/2\n`; + ` tbh [pc, {emit_reg i.arg.(0)}, lsl #1]\n`;
+ for j = 0 to Array.length tramtbl - 1 do
+ let rec label i =
+ match i.desc with
+ Lend -> new_label()
+ | Llabel lbl when lbl = tramtbl.(j) -> lbl
+ | _ -> label i.next in
+ tramtbl.(j) <- label i.next;
+ ` .short ({emit_label tramtbl.(j)}-.)/2+{emit_int j}\n`
+ done; + done;
+ ` .align 1\n`; + (* Generate the necessary trampolines *)
+ 2 + Array.length jumptbl / 2 + for j = 0 to Array.length tramtbl - 1 do
+ if tramtbl.(j) <> jumptbl.(j) then
+ `{emit_label tramtbl.(j)}: b {emit_label jumptbl.(j)}\n`
+ done
+ end else if not !pic_code then begin
+ ` ldr pc, [pc, {emit_reg i.arg.(0)}, lsl #2]\n`;
+ ` nop\n`;
+ for j = 0 to Array.length jumptbl - 1 do
+ ` .word {emit_label jumptbl.(j)}\n`
+ done
+ end else begin + end else begin
+ if not !pic_code then begin + (* Slightly slower, but position-independent *)
+ ` ldr pc, [pc, {emit_reg i.arg.(0)}, lsl #2]\n`; + ` add pc, pc, {emit_reg i.arg.(0)}, lsl #2\n`;
+ ` nop\n`; + ` nop\n`;
+ for i = 0 to Array.length jumptbl - 1 do + for j = 0 to Array.length jumptbl - 1 do
+ ` .word {emit_label jumptbl.(i)}\n` + ` b {emit_label jumptbl.(j)}\n`
+ done + done
+ end else begin + end;
+ (* Slightly slower, but position-independent *) 2 + Array.length jumptbl
+ ` add pc, pc, {emit_reg i.arg.(0)}, lsl #2\n`;
+ ` nop\n`;
+ for i = 0 to Array.length jumptbl - 1 do
+ ` b {emit_label jumptbl.(i)}\n`
+ done
+ end;
+ 2 + Array.length jumptbl
+ end
| Lsetuptrap lbl -> | Lsetuptrap lbl ->
` bl {emit_label lbl}\n`; 1 ` bl {emit_label lbl}\n`; 1
| Lpushtrap -> | Lpushtrap ->
@ -1339,7 +1350,7 @@ index a4b2241..846ee4a 100644
let data l = let data l =
` .data\n`; ` .data\n`;
@@ -605,32 +869,62 @@ let data l = @@ -605,32 +878,62 @@ let data l =
(* Beginning / end of an assembly file *) (* Beginning / end of an assembly file *)
let begin_assembly() = let begin_assembly() =
@ -3092,5 +3103,5 @@ index 6ed0a9c..4e07c92 100755
esac esac
-- --
1.7.7.6 1.7.10

View File

@ -1,6 +1,6 @@
Name: ocaml Name: ocaml
Version: 3.12.1 Version: 3.12.1
Release: 8%{?dist} Release: 9%{?dist}
Summary: Objective Caml compiler and programming environment Summary: Objective Caml compiler and programming environment
@ -495,6 +495,10 @@ fi
%changelog %changelog
* Sun Jun 3 2012 Richard W.M. Jones <rjones@redhat.com> 3.12.1-9
- Include svn rev 12548 to fix invalid generation of Thumb-2 branch
instruction TBH (upstream PR#5623, RHBZ#821153).
* Wed May 29 2012 Richard W.M. Jones <rjones@redhat.com> 3.12.1-8 * Wed May 29 2012 Richard W.M. Jones <rjones@redhat.com> 3.12.1-8
- Modify the ppc64 patch to reduce the delta between power64 and - Modify the ppc64 patch to reduce the delta between power64 and
upstream power backends. upstream power backends.