author | Brian Cameron <brian.cameron@oracle.com> |
Wed, 21 Aug 2013 14:33:32 -0700 | |
changeset 1450 | 02791a89ea4f |
permissions | -rw-r--r-- |
1450
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1 |
|
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2 |
Patch from Fedora spec-file to add powerpc support. This patch was rejected by |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
3 |
upstream. This may not be needed on Solaris, but keeping it for consistency |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
4 |
with the RHEL package. |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
5 |
https://sympa.inria.fr/sympa/arc/caml-list/2007-10/msg00502.html |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
6 |
|
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
7 |
diff -uNr ocaml-3.10.1/asmcomp/power64/arch.ml ocaml-3.10.1.ppc64/asmcomp/power64/arch.ml |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
8 |
--- ocaml-3.10.1/asmcomp/power64/arch.ml 1969-12-31 19:00:00.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
9 |
+++ ocaml-3.10.1.ppc64/asmcomp/power64/arch.ml 2008-02-29 08:37:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
10 |
@@ -0,0 +1,84 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
11 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
12 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
13 |
+(* Objective Caml *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
14 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
15 |
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
16 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
17 |
+(* Copyright 1996 Institut National de Recherche en Informatique et *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
18 |
+(* en Automatique. All rights reserved. This file is distributed *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
19 |
+(* under the terms of the Q Public License version 1.0. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
20 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
21 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
22 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
23 |
+(* $Id: arch.ml,v 1.11 2004/06/19 16:13:32 xleroy Exp $ *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
24 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
25 |
+(* Specific operations for the PowerPC processor *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
26 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
27 |
+open Misc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
28 |
+open Format |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
29 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
30 |
+(* Machine-specific command-line options *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
31 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
32 |
+let command_line_options = [] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
33 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
34 |
+(* Specific operations *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
35 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
36 |
+type specific_operation = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
37 |
+ Imultaddf (* multiply and add *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
38 |
+ | Imultsubf (* multiply and subtract *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
39 |
+ | Ialloc_far of int (* allocation in large functions *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
40 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
41 |
+(* Addressing modes *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
42 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
43 |
+type addressing_mode = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
44 |
+ Ibased of string * int (* symbol + displ *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
45 |
+ | Iindexed of int (* reg + displ *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
46 |
+ | Iindexed2 (* reg + reg *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
47 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
48 |
+(* Sizes, endianness *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
49 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
50 |
+let big_endian = true |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
51 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
52 |
+let size_addr = 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
53 |
+let size_int = 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
54 |
+let size_float = 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
55 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
56 |
+(* Operations on addressing modes *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
57 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
58 |
+let identity_addressing = Iindexed 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
59 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
60 |
+let offset_addressing addr delta = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
61 |
+ match addr with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
62 |
+ Ibased(s, n) -> Ibased(s, n + delta) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
63 |
+ | Iindexed n -> Iindexed(n + delta) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
64 |
+ | Iindexed2 -> assert false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
65 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
66 |
+let num_args_addressing = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
67 |
+ Ibased(s, n) -> 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
68 |
+ | Iindexed n -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
69 |
+ | Iindexed2 -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
70 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
71 |
+(* Printing operations and addressing modes *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
72 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
73 |
+let print_addressing printreg addr ppf arg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
74 |
+ match addr with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
75 |
+ | Ibased(s, n) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
76 |
+ let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
77 |
+ fprintf ppf "\"%s\"%s" s idx |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
78 |
+ | Iindexed n -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
79 |
+ let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
80 |
+ fprintf ppf "%a%s" printreg arg.(0) idx |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
81 |
+ | Iindexed2 -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
82 |
+ fprintf ppf "%a + %a" printreg arg.(0) printreg arg.(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
83 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
84 |
+let print_specific_operation printreg op ppf arg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
85 |
+ match op with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
86 |
+ | Imultaddf -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
87 |
+ fprintf ppf "%a *f %a +f %a" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
88 |
+ printreg arg.(0) printreg arg.(1) printreg arg.(2) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
89 |
+ | Imultsubf -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
90 |
+ fprintf ppf "%a *f %a -f %a" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
91 |
+ printreg arg.(0) printreg arg.(1) printreg arg.(2) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
92 |
+ | Ialloc_far n -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
93 |
+ fprintf ppf "alloc_far %d" n |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
94 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
95 |
diff -uNr ocaml-3.10.1/asmcomp/power64/emit.mlp ocaml-3.10.1.ppc64/asmcomp/power64/emit.mlp |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
96 |
--- ocaml-3.10.1/asmcomp/power64/emit.mlp 1969-12-31 19:00:00.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
97 |
+++ ocaml-3.10.1.ppc64/asmcomp/power64/emit.mlp 2008-02-29 08:37:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
98 |
@@ -0,0 +1,989 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
99 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
100 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
101 |
+(* Objective Caml *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
102 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
103 |
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
104 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
105 |
+(* Copyright 1996 Institut National de Recherche en Informatique et *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
106 |
+(* en Automatique. All rights reserved. This file is distributed *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
107 |
+(* under the terms of the Q Public License version 1.0. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
108 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
109 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
110 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
111 |
+(* $Id: emit.mlp,v 1.21 2004/06/19 17:39:34 xleroy Exp $ *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
112 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
113 |
+(* Emission of PowerPC assembly code *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
114 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
115 |
+module StringSet = Set.Make(struct type t = string let compare = compare end) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
116 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
117 |
+open Location |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
118 |
+open Misc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
119 |
+open Cmm |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
120 |
+open Arch |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
121 |
+open Proc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
122 |
+open Reg |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
123 |
+open Mach |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
124 |
+open Linearize |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
125 |
+open Emitaux |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
126 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
127 |
+(* Layout of the stack. The stack is kept 16-aligned. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
128 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
129 |
+let stack_size_lbl = ref 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
130 |
+let stack_slot_lbl = ref 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
131 |
+let stack_args_size = ref 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
132 |
+let stack_traps_size = ref 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
133 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
134 |
+(* We have a stack frame of our own if we call other functions (including |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
135 |
+ use of exceptions, or if we need more than the red zone *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
136 |
+let has_stack_frame () = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
137 |
+ if !contains_calls or (num_stack_slots.(0) + num_stack_slots.(1)) > (288-16)/8 then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
138 |
+ true |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
139 |
+ else |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
140 |
+ false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
141 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
142 |
+let frame_size_sans_args () = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
143 |
+ let size = 8 * num_stack_slots.(0) + 8 * num_stack_slots.(1) + 48 in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
144 |
+ Misc.align size 16 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
145 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
146 |
+let slot_offset loc cls = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
147 |
+ match loc with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
148 |
+ Local n -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
149 |
+ if cls = 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
150 |
+ then (!stack_slot_lbl, num_stack_slots.(1) * 8 + n * 8) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
151 |
+ else (!stack_slot_lbl, n * 8) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
152 |
+ | Incoming n -> ((if has_stack_frame() then !stack_size_lbl else 0), 48 + n) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
153 |
+ | Outgoing n -> (0, n) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
154 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
155 |
+(* Output a symbol *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
156 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
157 |
+let emit_symbol = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
158 |
+ match Config.system with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
159 |
+ | "elf" | "bsd" -> (fun s -> Emitaux.emit_symbol '.' s) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
160 |
+ | "rhapsody" -> (fun s -> emit_char '_'; Emitaux.emit_symbol '$' s) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
161 |
+ | _ -> assert false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
162 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
163 |
+(* Output a label *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
164 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
165 |
+let label_prefix = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
166 |
+ match Config.system with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
167 |
+ | "elf" | "bsd" -> ".L" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
168 |
+ | "rhapsody" -> "L" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
169 |
+ | _ -> assert false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
170 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
171 |
+let emit_label lbl = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
172 |
+ emit_string label_prefix; emit_int lbl |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
173 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
174 |
+(* Section switching *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
175 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
176 |
+let toc_space = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
177 |
+ match Config.system with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
178 |
+ | "elf" | "bsd" -> " .section \".toc\",\"aw\"\n" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
179 |
+ | "rhapsody" -> " .toc\n" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
180 |
+ | _ -> assert false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
181 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
182 |
+let data_space = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
183 |
+ match Config.system with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
184 |
+ | "elf" | "bsd" -> " .section \".data\"\n" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
185 |
+ | "rhapsody" -> " .data\n" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
186 |
+ | _ -> assert false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
187 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
188 |
+let code_space = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
189 |
+ match Config.system with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
190 |
+ | "elf" | "bsd" -> " .section \".text\"\n" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
191 |
+ | "rhapsody" -> " .text\n" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
192 |
+ | _ -> assert false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
193 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
194 |
+let rodata_space = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
195 |
+ match Config.system with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
196 |
+ | "elf" | "bsd" -> " .section \".rodata\"\n" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
197 |
+ | "rhapsody" -> " .const\n" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
198 |
+ | _ -> assert false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
199 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
200 |
+(* Output a pseudo-register *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
201 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
202 |
+let emit_reg r = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
203 |
+ match r.loc with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
204 |
+ Reg r -> emit_string (register_name r) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
205 |
+ | _ -> fatal_error "Emit.emit_reg" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
206 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
207 |
+let use_full_regnames = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
208 |
+ Config.system = "rhapsody" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
209 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
210 |
+let emit_gpr r = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
211 |
+ if use_full_regnames then emit_char 'r'; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
212 |
+ emit_int r |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
213 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
214 |
+let emit_fpr r = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
215 |
+ if use_full_regnames then emit_char 'f'; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
216 |
+ emit_int r |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
217 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
218 |
+let emit_ccr r = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
219 |
+ if use_full_regnames then emit_string "cr"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
220 |
+ emit_int r |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
221 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
222 |
+(* Output a stack reference *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
223 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
224 |
+let emit_stack r = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
225 |
+ match r.loc with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
226 |
+ Stack s -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
227 |
+ let lbl, ofs = slot_offset s (register_class r) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
228 |
+ if lbl > 0 then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
229 |
+ `{emit_label lbl}+`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
230 |
+ `{emit_int ofs}({emit_gpr 1})` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
231 |
+ | _ -> fatal_error "Emit.emit_stack" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
232 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
233 |
+(* Split a 32-bit integer constants in two 16-bit halves *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
234 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
235 |
+let low n = n land 0xFFFF |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
236 |
+let high n = n asr 16 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
237 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
238 |
+let nativelow n = Nativeint.to_int n land 0xFFFF |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
239 |
+let nativehigh n = Nativeint.to_int (Nativeint.shift_right n 16) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
240 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
241 |
+let is_immediate n = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
242 |
+ n <= 32767 && n >= -32768 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
243 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
244 |
+let is_native_immediate n = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
245 |
+ n <= 32767n && n >= -32768n |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
246 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
247 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
248 |
+type tocentry = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
249 |
+ TocSymOfs of (string * int) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
250 |
+ | TocLabel of int |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
251 |
+ | TocInt of nativeint |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
252 |
+ | TocFloat of string |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
253 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
254 |
+(* List of all labels in tocref (reverse order) *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
255 |
+let tocref_entries = ref [] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
256 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
257 |
+(* Output a TOC reference *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
258 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
259 |
+let emit_symbol_offset (s, d) = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
260 |
+ emit_symbol s; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
261 |
+ if d > 0 then `+`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
262 |
+ if d <> 0 then emit_int d |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
263 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
264 |
+let emit_tocentry entry = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
265 |
+ match entry with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
266 |
+ TocSymOfs(s,d) -> emit_symbol_offset(s,d) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
267 |
+ | TocInt i -> emit_nativeint i |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
268 |
+ | TocFloat f -> emit_string f |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
269 |
+ | TocLabel lbl -> emit_label lbl |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
270 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
271 |
+ let rec tocref_label = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
272 |
+ ( [] , content ) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
273 |
+ let lbl = new_label() in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
274 |
+ tocref_entries := (lbl, content) :: !tocref_entries; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
275 |
+ lbl |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
276 |
+ | ( (lbl, o_content) :: lst, content) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
277 |
+ if content = o_content then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
278 |
+ lbl |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
279 |
+ else |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
280 |
+ tocref_label (lst, content) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
281 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
282 |
+let emit_tocref entry = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
283 |
+ let lbl = tocref_label (!tocref_entries,entry) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
284 |
+ emit_label lbl; emit_string "@toc(2) #"; emit_tocentry entry |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
285 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
286 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
287 |
+(* Output a load or store operation *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
288 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
289 |
+let valid_offset instr ofs = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
290 |
+ ofs land 3 = 0 || (instr <> "ld" && instr <> "std") |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
291 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
292 |
+let emit_load_store instr addressing_mode addr n arg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
293 |
+ match addressing_mode with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
294 |
+ Ibased(s, d) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
295 |
+ let dd = (d + 0x8000) in (* We can only offset by -0x8000 .. +0x7fff *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
296 |
+ let a = (dd land -0x10000) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
297 |
+ let b = (dd land 0xffff) - 0x8000 in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
298 |
+ ` ld {emit_gpr 11}, {emit_tocref (TocSymOfs (s,a))}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
299 |
+ ` {emit_string instr} {emit_reg arg}, {emit_int b}({emit_gpr 11})\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
300 |
+ | Iindexed ofs -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
301 |
+ if is_immediate ofs && valid_offset instr ofs then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
302 |
+ ` {emit_string instr} {emit_reg arg}, {emit_int ofs}({emit_reg addr.(n)})\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
303 |
+ else begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
304 |
+ ` lis {emit_gpr 0}, {emit_int(high ofs)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
305 |
+ if low ofs <> 0 then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
306 |
+ ` ori {emit_gpr 0}, {emit_gpr 0}, {emit_int(low ofs)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
307 |
+ ` {emit_string instr}x {emit_reg arg}, {emit_reg addr.(n)}, {emit_gpr 0}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
308 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
309 |
+ | Iindexed2 -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
310 |
+ ` {emit_string instr}x {emit_reg arg}, {emit_reg addr.(n)}, {emit_reg addr.(n+1)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
311 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
312 |
+(* After a comparison, extract the result as 0 or 1 *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
313 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
314 |
+let emit_set_comp cmp res = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
315 |
+ ` mfcr {emit_gpr 0}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
316 |
+ let bitnum = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
317 |
+ match cmp with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
318 |
+ Ceq | Cne -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
319 |
+ | Cgt | Cle -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
320 |
+ | Clt | Cge -> 0 in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
321 |
+` rlwinm {emit_reg res}, {emit_gpr 0}, {emit_int(bitnum+1)}, 31, 31\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
322 |
+ begin match cmp with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
323 |
+ Cne | Cle | Cge -> ` xori {emit_reg res}, {emit_reg res}, 1\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
324 |
+ | _ -> () |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
325 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
326 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
327 |
+(* Record live pointers at call points *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
328 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
329 |
+type frame_descr = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
330 |
+ { fd_lbl: int; (* Return address *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
331 |
+ fd_frame_size_lbl: int; (* Size of stack frame *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
332 |
+ fd_live_offset: (int * int) list } (* Offsets/regs of live addresses *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
333 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
334 |
+let frame_descriptors = ref([] : frame_descr list) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
335 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
336 |
+let record_frame live = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
337 |
+ let lbl = new_label() in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
338 |
+ let live_offset = ref [] in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
339 |
+ Reg.Set.iter |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
340 |
+ (function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
341 |
+ {typ = Addr; loc = Reg r} -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
342 |
+ live_offset := (0, (r lsl 1) + 1) :: !live_offset |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
343 |
+ | {typ = Addr; loc = Stack s} as reg -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
344 |
+ live_offset := slot_offset s (register_class reg) :: !live_offset |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
345 |
+ | _ -> ()) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
346 |
+ live; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
347 |
+ frame_descriptors := |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
348 |
+ { fd_lbl = lbl; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
349 |
+ fd_frame_size_lbl = !stack_size_lbl; (* frame_size *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
350 |
+ fd_live_offset = !live_offset } :: !frame_descriptors; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
351 |
+ `{emit_label lbl}:\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
352 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
353 |
+let emit_frame fd = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
354 |
+ ` .quad {emit_label fd.fd_lbl} + 4\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
355 |
+ ` .short {emit_label fd.fd_frame_size_lbl}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
356 |
+ ` .short {emit_int (List.length fd.fd_live_offset)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
357 |
+ List.iter |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
358 |
+ (fun (lbl,n) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
359 |
+ ` .short `; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
360 |
+ if lbl > 0 then `{emit_label lbl}+`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
361 |
+ `{emit_int n}\n`) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
362 |
+ fd.fd_live_offset; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
363 |
+ ` .align 3\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
364 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
365 |
+(* Record external C functions to be called in a position-independent way |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
366 |
+ (for MacOSX) *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
367 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
368 |
+let pic_externals = (Config.system = "rhapsody") |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
369 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
370 |
+let external_functions = ref StringSet.empty |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
371 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
372 |
+let emit_external s = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
373 |
+ ` .non_lazy_symbol_pointer\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
374 |
+ `L{emit_symbol s}$non_lazy_ptr:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
375 |
+ ` .indirect_symbol {emit_symbol s}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
376 |
+ ` .quad 0\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
377 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
378 |
+(* Names for conditional branches after comparisons *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
379 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
380 |
+let branch_for_comparison = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
381 |
+ Ceq -> "beq" | Cne -> "bne" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
382 |
+ | Cle -> "ble" | Cgt -> "bgt" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
383 |
+ | Cge -> "bge" | Clt -> "blt" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
384 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
385 |
+let name_for_int_comparison = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
386 |
+ Isigned cmp -> ("cmpd", branch_for_comparison cmp) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
387 |
+ | Iunsigned cmp -> ("cmpld", branch_for_comparison cmp) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
388 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
389 |
+(* Names for various instructions *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
390 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
391 |
+let name_for_intop = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
392 |
+ Iadd -> "add" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
393 |
+ | Imul -> "mulld" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
394 |
+ | Idiv -> "divd" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
395 |
+ | Iand -> "and" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
396 |
+ | Ior -> "or" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
397 |
+ | Ixor -> "xor" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
398 |
+ | Ilsl -> "sld" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
399 |
+ | Ilsr -> "srd" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
400 |
+ | Iasr -> "srad" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
401 |
+ | _ -> Misc.fatal_error "Emit.Intop" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
402 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
403 |
+let name_for_intop_imm = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
404 |
+ Iadd -> "addi" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
405 |
+ | Imul -> "mulli" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
406 |
+ | Iand -> "andi." |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
407 |
+ | Ior -> "ori" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
408 |
+ | Ixor -> "xori" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
409 |
+ | Ilsl -> "sldi" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
410 |
+ | Ilsr -> "srdi" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
411 |
+ | Iasr -> "sradi" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
412 |
+ | _ -> Misc.fatal_error "Emit.Intop_imm" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
413 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
414 |
+let name_for_floatop1 = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
415 |
+ Inegf -> "fneg" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
416 |
+ | Iabsf -> "fabs" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
417 |
+ | _ -> Misc.fatal_error "Emit.Iopf1" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
418 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
419 |
+let name_for_floatop2 = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
420 |
+ Iaddf -> "fadd" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
421 |
+ | Isubf -> "fsub" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
422 |
+ | Imulf -> "fmul" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
423 |
+ | Idivf -> "fdiv" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
424 |
+ | _ -> Misc.fatal_error "Emit.Iopf2" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
425 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
426 |
+let name_for_specific = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
427 |
+ Imultaddf -> "fmadd" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
428 |
+ | Imultsubf -> "fmsub" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
429 |
+ | _ -> Misc.fatal_error "Emit.Ispecific" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
430 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
431 |
+(* Name of current function *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
432 |
+let function_name = ref "" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
433 |
+(* Entry point for tail recursive calls *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
434 |
+let tailrec_entry_point = ref 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
435 |
+(* Names of functions defined in the current file *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
436 |
+let defined_functions = ref StringSet.empty |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
437 |
+(* Label of glue code for calling the GC *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
438 |
+let call_gc_label = ref 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
439 |
+(* Label of jump table *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
440 |
+let lbl_jumptbl = ref 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
441 |
+(* List of all labels in jumptable (reverse order) *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
442 |
+let jumptbl_entries = ref [] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
443 |
+(* Number of jumptable entries *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
444 |
+let num_jumptbl_entries = ref 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
445 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
446 |
+(* Fixup conditional branches that exceed hardware allowed range *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
447 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
448 |
+let load_store_size = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
449 |
+ Ibased(s, d) -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
450 |
+ | Iindexed ofs -> if is_immediate ofs then 1 else 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
451 |
+ | Iindexed2 -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
452 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
453 |
+let instr_size = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
454 |
+ Lend -> 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
455 |
+ | Lop(Imove | Ispill | Ireload) -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
456 |
+ | Lop(Iconst_int n) -> if is_native_immediate n then 1 else 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
457 |
+ | Lop(Iconst_float s) -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
458 |
+ | Lop(Iconst_symbol s) -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
459 |
+ | Lop(Icall_ind) -> 6 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
460 |
+ | Lop(Icall_imm s) -> 7 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
461 |
+ | Lop(Itailcall_ind) -> if !contains_calls then 7 else if has_stack_frame() then 5 else 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
462 |
+ | Lop(Itailcall_imm s) -> if s = !function_name then 1 else |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
463 |
+ if !contains_calls then 8 else |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
464 |
+ if has_stack_frame() then 6 else 5 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
465 |
+ | Lop(Iextcall(s, true)) -> 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
466 |
+ | Lop(Iextcall(s, false)) -> 7 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
467 |
+ | Lop(Istackoffset n) -> 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
468 |
+ | Lop(Iload(chunk, addr)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
469 |
+ if chunk = Byte_signed |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
470 |
+ then load_store_size addr + 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
471 |
+ else load_store_size addr |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
472 |
+ | Lop(Istore(chunk, addr)) -> load_store_size addr |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
473 |
+ | Lop(Ialloc n) -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
474 |
+ | Lop(Ispecific(Ialloc_far n)) -> 5 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
475 |
+ | Lop(Iintop Imod) -> 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
476 |
+ | Lop(Iintop(Icomp cmp)) -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
477 |
+ | Lop(Iintop op) -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
478 |
+ | Lop(Iintop_imm(Idiv, n)) -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
479 |
+ | Lop(Iintop_imm(Imod, n)) -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
480 |
+ | Lop(Iintop_imm(Icomp cmp, n)) -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
481 |
+ | Lop(Iintop_imm(op, n)) -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
482 |
+ | Lop(Inegf | Iabsf | Iaddf | Isubf | Imulf | Idivf) -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
483 |
+ | Lop(Ifloatofint) -> 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
484 |
+ | Lop(Iintoffloat) -> 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
485 |
+ | Lop(Ispecific sop) -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
486 |
+ | Lreloadretaddr -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
487 |
+ | Lreturn -> if has_stack_frame() then 2 else 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
488 |
+ | Llabel lbl -> 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
489 |
+ | Lbranch lbl -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
490 |
+ | Lcondbranch(tst, lbl) -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
491 |
+ | Lcondbranch3(lbl0, lbl1, lbl2) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
492 |
+ 1 + (if lbl0 = None then 0 else 1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
493 |
+ + (if lbl1 = None then 0 else 1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
494 |
+ + (if lbl2 = None then 0 else 1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
495 |
+ | Lswitch jumptbl -> 7 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
496 |
+ | Lsetuptrap lbl -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
497 |
+ | Lpushtrap -> 7 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
498 |
+ | Lpoptrap -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
499 |
+ | Lraise -> 6 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
500 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
501 |
+let label_map code = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
502 |
+ let map = Hashtbl.create 37 in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
503 |
+ let rec fill_map pc instr = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
504 |
+ match instr.desc with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
505 |
+ Lend -> (pc, map) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
506 |
+ | Llabel lbl -> Hashtbl.add map lbl pc; fill_map pc instr.next |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
507 |
+ | op -> fill_map (pc + instr_size op) instr.next |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
508 |
+ in fill_map 0 code |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
509 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
510 |
+let max_branch_offset = 8180 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
511 |
+(* 14-bit signed offset in words. Remember to cut some slack |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
512 |
+ for multi-word instructions where the branch can be anywhere in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
513 |
+ the middle. 12 words of slack is plenty. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
514 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
515 |
+let branch_overflows map pc_branch lbl_dest = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
516 |
+ let pc_dest = Hashtbl.find map lbl_dest in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
517 |
+ let delta = pc_dest - (pc_branch + 1) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
518 |
+ delta <= -max_branch_offset || delta >= max_branch_offset |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
519 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
520 |
+let opt_branch_overflows map pc_branch opt_lbl_dest = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
521 |
+ match opt_lbl_dest with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
522 |
+ None -> false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
523 |
+ | Some lbl_dest -> branch_overflows map pc_branch lbl_dest |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
524 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
525 |
+let fixup_branches codesize map code = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
526 |
+ let expand_optbranch lbl n arg next = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
527 |
+ match lbl with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
528 |
+ None -> next |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
529 |
+ | Some l -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
530 |
+ instr_cons (Lcondbranch(Iinttest_imm(Isigned Ceq, n), l)) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
531 |
+ arg [||] next in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
532 |
+ let rec fixup did_fix pc instr = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
533 |
+ match instr.desc with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
534 |
+ Lend -> did_fix |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
535 |
+ | Lcondbranch(test, lbl) when branch_overflows map pc lbl -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
536 |
+ let lbl2 = new_label() in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
537 |
+ let cont = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
538 |
+ instr_cons (Lbranch lbl) [||] [||] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
539 |
+ (instr_cons (Llabel lbl2) [||] [||] instr.next) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
540 |
+ instr.desc <- Lcondbranch(invert_test test, lbl2); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
541 |
+ instr.next <- cont; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
542 |
+ fixup true (pc + 2) instr.next |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
543 |
+ | Lcondbranch3(lbl0, lbl1, lbl2) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
544 |
+ when opt_branch_overflows map pc lbl0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
545 |
+ || opt_branch_overflows map pc lbl1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
546 |
+ || opt_branch_overflows map pc lbl2 -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
547 |
+ let cont = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
548 |
+ expand_optbranch lbl0 0 instr.arg |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
549 |
+ (expand_optbranch lbl1 1 instr.arg |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
550 |
+ (expand_optbranch lbl2 2 instr.arg instr.next)) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
551 |
+ instr.desc <- cont.desc; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
552 |
+ instr.next <- cont.next; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
553 |
+ fixup true pc instr |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
554 |
+ | Lop(Ialloc n) when codesize - pc >= max_branch_offset -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
555 |
+ instr.desc <- Lop(Ispecific(Ialloc_far n)); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
556 |
+ fixup true (pc + 4) instr.next |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
557 |
+ | op -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
558 |
+ fixup did_fix (pc + instr_size op) instr.next |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
559 |
+ in fixup false 0 code |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
560 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
561 |
+(* Iterate branch expansion till all conditional branches are OK *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
562 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
563 |
+let rec branch_normalization code = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
564 |
+ let (codesize, map) = label_map code in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
565 |
+ if codesize >= max_branch_offset && fixup_branches codesize map code |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
566 |
+ then branch_normalization code |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
567 |
+ else () |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
568 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
569 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
570 |
+(* Output the assembly code for an instruction *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
571 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
572 |
+let rec emit_instr i dslot = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
573 |
+ match i.desc with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
574 |
+ Lend -> () |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
575 |
+ | Lop(Imove | Ispill | Ireload) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
576 |
+ let src = i.arg.(0) and dst = i.res.(0) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
577 |
+ if src.loc <> dst.loc then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
578 |
+ match (src, dst) with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
579 |
+ {loc = Reg rs; typ = (Int | Addr)}, {loc = Reg rd} -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
580 |
+ ` mr {emit_reg dst}, {emit_reg src}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
581 |
+ | {loc = Reg rs; typ = Float}, {loc = Reg rd; typ = Float} -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
582 |
+ ` fmr {emit_reg dst}, {emit_reg src}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
583 |
+ | {loc = Reg rs; typ = (Int | Addr)}, {loc = Stack sd} -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
584 |
+ ` std {emit_reg src}, {emit_stack dst}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
585 |
+ | {loc = Reg rs; typ = Float}, {loc = Stack sd} -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
586 |
+ ` stfd {emit_reg src}, {emit_stack dst}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
587 |
+ | {loc = Stack ss; typ = (Int | Addr)}, {loc = Reg rd} -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
588 |
+ ` ld {emit_reg dst}, {emit_stack src}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
589 |
+ | {loc = Stack ss; typ = Float}, {loc = Reg rd} -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
590 |
+ ` lfd {emit_reg dst}, {emit_stack src}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
591 |
+ | (_, _) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
592 |
+ fatal_error "Emit: Imove" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
593 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
594 |
+ | Lop(Iconst_int n) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
595 |
+ if is_native_immediate n then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
596 |
+ ` li {emit_reg i.res.(0)}, {emit_nativeint n}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
597 |
+ else if n >= -0x8000_0000n && n <= 0x7FFF_FFFFn then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
598 |
+ ` lis {emit_reg i.res.(0)}, {emit_int(nativehigh n)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
599 |
+ if nativelow n <> 0 then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
600 |
+ ` ori {emit_reg i.res.(0)}, {emit_reg i.res.(0)}, {emit_int(nativelow n)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
601 |
+ end else begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
602 |
+ ` ld {emit_reg i.res.(0)}, {emit_tocref (TocInt n)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
603 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
604 |
+ | Lop(Iconst_float s) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
605 |
+ ` lfd {emit_reg i.res.(0)}, {emit_tocref (TocFloat s)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
606 |
+ | Lop(Iconst_symbol s) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
607 |
+ ` ld {emit_reg i.res.(0)}, {emit_tocref (TocSymOfs (s,0))}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
608 |
+ | Lop(Icall_ind) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
609 |
+ ` std {emit_gpr 2},40({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
610 |
+ ` ld {emit_gpr 2}, 8({emit_reg i.arg.(0)})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
611 |
+ ` ld {emit_reg i.arg.(0)}, 0({emit_reg i.arg.(0)})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
612 |
+ ` mtctr {emit_reg i.arg.(0)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
613 |
+ record_frame i.live; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
614 |
+ ` bctrl\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
615 |
+ ` ld {emit_gpr 2},40({emit_gpr 1})\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
616 |
+ | Lop(Icall_imm s) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
617 |
+ ` ld {emit_gpr 11}, {emit_tocref (TocSymOfs (s,0))}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
618 |
+ ` std {emit_gpr 2},40({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
619 |
+ ` ld {emit_gpr 2}, 8({emit_gpr 11})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
620 |
+ ` ld {emit_gpr 11}, 0({emit_gpr 11})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
621 |
+ ` mtctr {emit_gpr 11}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
622 |
+ record_frame i.live; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
623 |
+ ` bctrl\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
624 |
+ ` ld {emit_gpr 2},40({emit_gpr 1})\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
625 |
+ | Lop(Itailcall_ind) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
626 |
+ ` ld {emit_gpr 2}, 8({emit_reg i.arg.(0)})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
627 |
+ ` ld {emit_reg i.arg.(0)}, 0({emit_reg i.arg.(0)})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
628 |
+ ` mtctr {emit_reg i.arg.(0)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
629 |
+ if has_stack_frame() then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
630 |
+ ` ld {emit_gpr 1}, 0({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
631 |
+ if !contains_calls then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
632 |
+ ` ld {emit_gpr 11}, 16({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
633 |
+ ` mtlr {emit_gpr 11}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
634 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
635 |
+ ` bctr\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
636 |
+ | Lop(Itailcall_imm s) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
637 |
+ if s = !function_name then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
638 |
+ ` b {emit_label !tailrec_entry_point}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
639 |
+ else begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
640 |
+ if has_stack_frame() then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
641 |
+ ` ld {emit_gpr 1}, 0({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
642 |
+ if !contains_calls then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
643 |
+ ` ld {emit_gpr 11}, 16({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
644 |
+ ` mtlr {emit_gpr 11}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
645 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
646 |
+ ` ld {emit_gpr 11}, {emit_tocref (TocSymOfs (s,0))}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
647 |
+ ` ld {emit_gpr 2}, 8({emit_gpr 11})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
648 |
+ ` ld {emit_gpr 11}, 0({emit_gpr 11})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
649 |
+ ` mtctr {emit_gpr 11}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
650 |
+ ` bctr\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
651 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
652 |
+ | Lop(Iextcall(s, alloc)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
653 |
+ if alloc then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
654 |
+ ` ld {emit_gpr 11}, {emit_tocref (TocSymOfs (s,0))}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
655 |
+ ` ld {emit_gpr 12}, {emit_tocref (TocSymOfs ("caml_c_call",0))}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
656 |
+ end else |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
657 |
+ ` ld {emit_gpr 12}, {emit_tocref (TocSymOfs (s,0))}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
658 |
+ ` std {emit_gpr 2}, 40({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
659 |
+ ` ld {emit_gpr 2}, 8({emit_gpr 12})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
660 |
+ ` ld {emit_gpr 12}, 0({emit_gpr 12})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
661 |
+ ` mtctr {emit_gpr 12}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
662 |
+ if alloc then record_frame i.live; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
663 |
+ ` bctrl\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
664 |
+ ` ld {emit_gpr 2}, 40({emit_gpr 1})\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
665 |
+ | Lop(Istackoffset n) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
666 |
+ if n > !stack_args_size then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
667 |
+ stack_args_size := n |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
668 |
+ | Lop(Iload(chunk, addr)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
669 |
+ let loadinstr = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
670 |
+ match chunk with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
671 |
+ Byte_unsigned -> "lbz" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
672 |
+ | Byte_signed -> "lbz" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
673 |
+ | Sixteen_unsigned -> "lhz" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
674 |
+ | Sixteen_signed -> "lha" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
675 |
+ | Thirtytwo_unsigned -> "lwz" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
676 |
+ | Thirtytwo_signed -> "lwa" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
677 |
+ | Word -> "ld" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
678 |
+ | Single -> "lfs" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
679 |
+ | Double | Double_u -> "lfd" in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
680 |
+ emit_load_store loadinstr addr i.arg 0 i.res.(0); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
681 |
+ if chunk = Byte_signed then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
682 |
+ ` extsb {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
683 |
+ | Lop(Istore(chunk, addr)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
684 |
+ let storeinstr = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
685 |
+ match chunk with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
686 |
+ Byte_unsigned | Byte_signed -> "stb" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
687 |
+ | Sixteen_unsigned | Sixteen_signed -> "sth" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
688 |
+ | Thirtytwo_unsigned | Thirtytwo_signed -> "stw" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
689 |
+ | Word -> "std" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
690 |
+ | Single -> "stfs" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
691 |
+ | Double | Double_u -> "stfd" in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
692 |
+ emit_load_store storeinstr addr i.arg 1 i.arg.(0) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
693 |
+ | Lop(Ialloc n) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
694 |
+ if !call_gc_label = 0 then call_gc_label := new_label(); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
695 |
+ ` addi {emit_gpr 31}, {emit_gpr 31}, {emit_int(-n)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
696 |
+ ` cmpld {emit_gpr 31}, {emit_gpr 30}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
697 |
+ ` addi {emit_reg i.res.(0)}, {emit_gpr 31}, 8\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
698 |
+ record_frame i.live; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
699 |
+ ` bltl {emit_label !call_gc_label}\n` (* Must be 4 insns to restart *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
700 |
+ | Lop(Ispecific(Ialloc_far n)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
701 |
+ if !call_gc_label = 0 then call_gc_label := new_label(); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
702 |
+ let lbl = new_label() in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
703 |
+ ` addi {emit_gpr 31}, {emit_gpr 31}, {emit_int(-n)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
704 |
+ ` cmpld {emit_gpr 31}, {emit_gpr 30}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
705 |
+ ` bge {emit_label lbl}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
706 |
+ record_frame i.live; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
707 |
+ ` bl {emit_label !call_gc_label}\n`; (* Must be 4 insns to restart *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
708 |
+ `{emit_label lbl}: addi {emit_reg i.res.(0)}, {emit_gpr 31}, 4\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
709 |
+ | Lop(Iintop Isub) -> (* subfc has swapped arguments *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
710 |
+ ` subfc {emit_reg i.res.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(0)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
711 |
+ | Lop(Iintop Imod) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
712 |
+ ` divd {emit_gpr 0}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
713 |
+ ` mulld {emit_gpr 0}, {emit_gpr 0}, {emit_reg i.arg.(1)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
714 |
+ ` subfc {emit_reg i.res.(0)}, {emit_gpr 0}, {emit_reg i.arg.(0)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
715 |
+ | Lop(Iintop(Icomp cmp)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
716 |
+ begin match cmp with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
717 |
+ Isigned c -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
718 |
+ ` cmpd {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
719 |
+ emit_set_comp c i.res.(0) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
720 |
+ | Iunsigned c -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
721 |
+ ` cmpld {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
722 |
+ emit_set_comp c i.res.(0) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
723 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
724 |
+ | Lop(Iintop Icheckbound) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
725 |
+ ` tdlle {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
726 |
+ | Lop(Iintop op) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
727 |
+ let instr = name_for_intop op in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
728 |
+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
729 |
+ | Lop(Iintop_imm(Isub, n)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
730 |
+ ` addi {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int(-n)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
731 |
+ | Lop(Iintop_imm(Idiv, n)) -> (* n is guaranteed to be a power of 2 *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
732 |
+ let l = Misc.log2 n in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
733 |
+ ` sradi {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int l}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
734 |
+ ` addze {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
735 |
+ | Lop(Iintop_imm(Imod, n)) -> (* n is guaranteed to be a power of 2 *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
736 |
+ let l = Misc.log2 n in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
737 |
+ ` sradi {emit_gpr 0}, {emit_reg i.arg.(0)}, {emit_int l}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
738 |
+ ` addze {emit_gpr 0}, {emit_gpr 0}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
739 |
+ ` sldi {emit_gpr 0}, {emit_gpr 0}, {emit_int l}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
740 |
+ ` subfc {emit_reg i.res.(0)}, {emit_gpr 0}, {emit_reg i.arg.(0)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
741 |
+ | Lop(Iintop_imm(Icomp cmp, n)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
742 |
+ begin match cmp with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
743 |
+ Isigned c -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
744 |
+ ` cmpdi {emit_reg i.arg.(0)}, {emit_int n}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
745 |
+ emit_set_comp c i.res.(0) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
746 |
+ | Iunsigned c -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
747 |
+ ` cmpldi {emit_reg i.arg.(0)}, {emit_int n}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
748 |
+ emit_set_comp c i.res.(0) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
749 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
750 |
+ | Lop(Iintop_imm(Icheckbound, n)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
751 |
+ ` tdllei {emit_reg i.arg.(0)}, {emit_int n}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
752 |
+ | Lop(Iintop_imm(op, n)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
753 |
+ let instr = name_for_intop_imm op in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
754 |
+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_int n}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
755 |
+ | Lop(Inegf | Iabsf as op) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
756 |
+ let instr = name_for_floatop1 op in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
757 |
+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
758 |
+ | Lop(Iaddf | Isubf | Imulf | Idivf as op) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
759 |
+ let instr = name_for_floatop2 op in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
760 |
+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
761 |
+ | Lop(Ifloatofint) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
762 |
+ let ofs = if has_stack_frame() then 16 else 8 * (2 + num_stack_slots.(0) + num_stack_slots.(1)) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
763 |
+ ` std {emit_reg i.arg.(0)}, -{emit_int ofs}({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
764 |
+ ` lfd {emit_reg i.res.(0)}, -{emit_int ofs}({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
765 |
+ ` fcfid {emit_reg i.res.(0)}, {emit_reg i.res.(0)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
766 |
+ | Lop(Iintoffloat) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
767 |
+ let ofs = if has_stack_frame() then 16 else 8 * (2 + num_stack_slots.(0) + num_stack_slots.(1)) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
768 |
+ ` fctidz {emit_fpr 0}, {emit_reg i.arg.(0)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
769 |
+ ` stfd {emit_fpr 0}, -{emit_int ofs}({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
770 |
+ ` ld {emit_reg i.res.(0)}, -{emit_int ofs}({emit_gpr 1})\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
771 |
+ | Lop(Ispecific sop) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
772 |
+ let instr = name_for_specific sop in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
773 |
+ ` {emit_string instr} {emit_reg i.res.(0)}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}, {emit_reg i.arg.(2)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
774 |
+ | Lreloadretaddr -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
775 |
+ if has_stack_frame() then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
776 |
+ ` ld {emit_gpr 11}, {emit_label !stack_size_lbl}+16({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
777 |
+ ` mtlr {emit_gpr 11}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
778 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
779 |
+ | Lreturn -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
780 |
+ if has_stack_frame() then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
781 |
+ ` ld {emit_gpr 1}, 0({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
782 |
+ ` blr\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
783 |
+ | Llabel lbl -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
784 |
+ `{emit_label lbl}:\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
785 |
+ | Lbranch lbl -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
786 |
+ ` b {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
787 |
+ | Lcondbranch(tst, lbl) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
788 |
+ begin match tst with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
789 |
+ Itruetest -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
790 |
+ ` cmpdi {emit_reg i.arg.(0)}, 0\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
791 |
+ emit_delay dslot; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
792 |
+ ` bne {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
793 |
+ | Ifalsetest -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
794 |
+ ` cmpdi {emit_reg i.arg.(0)}, 0\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
795 |
+ emit_delay dslot; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
796 |
+ ` beq {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
797 |
+ | Iinttest cmp -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
798 |
+ let (comp, branch) = name_for_int_comparison cmp in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
799 |
+ ` {emit_string comp} {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
800 |
+ emit_delay dslot; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
801 |
+ ` {emit_string branch} {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
802 |
+ | Iinttest_imm(cmp, n) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
803 |
+ let (comp, branch) = name_for_int_comparison cmp in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
804 |
+ ` {emit_string comp}i {emit_reg i.arg.(0)}, {emit_int n}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
805 |
+ emit_delay dslot; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
806 |
+ ` {emit_string branch} {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
807 |
+ | Ifloattest(cmp, neg) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
808 |
+ ` fcmpu {emit_ccr 0}, {emit_reg i.arg.(0)}, {emit_reg i.arg.(1)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
809 |
+ (* bit 0 = lt, bit 1 = gt, bit 2 = eq *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
810 |
+ let (bitnum, negtst) = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
811 |
+ match cmp with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
812 |
+ Ceq -> (2, neg) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
813 |
+ | Cne -> (2, not neg) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
814 |
+ | Cle -> ` cror 3, 0, 2\n`; (* lt or eq *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
815 |
+ (3, neg) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
816 |
+ | Cgt -> (1, neg) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
817 |
+ | Cge -> ` cror 3, 1, 2\n`; (* gt or eq *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
818 |
+ (3, neg) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
819 |
+ | Clt -> (0, neg) in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
820 |
+ emit_delay dslot; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
821 |
+ if negtst |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
822 |
+ then ` bf {emit_int bitnum}, {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
823 |
+ else ` bt {emit_int bitnum}, {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
824 |
+ | Ioddtest -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
825 |
+ ` andi. {emit_gpr 0}, {emit_reg i.arg.(0)}, 1\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
826 |
+ emit_delay dslot; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
827 |
+ ` bne {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
828 |
+ | Ieventest -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
829 |
+ ` andi. {emit_gpr 0}, {emit_reg i.arg.(0)}, 1\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
830 |
+ emit_delay dslot; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
831 |
+ ` beq {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
832 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
833 |
+ | Lcondbranch3(lbl0, lbl1, lbl2) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
834 |
+ ` cmpdi {emit_reg i.arg.(0)}, 1\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
835 |
+ emit_delay dslot; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
836 |
+ begin match lbl0 with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
837 |
+ None -> () |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
838 |
+ | Some lbl -> ` blt {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
839 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
840 |
+ begin match lbl1 with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
841 |
+ None -> () |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
842 |
+ | Some lbl -> ` beq {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
843 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
844 |
+ begin match lbl2 with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
845 |
+ None -> () |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
846 |
+ | Some lbl -> ` bgt {emit_label lbl}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
847 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
848 |
+ | Lswitch jumptbl -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
849 |
+ if !lbl_jumptbl = 0 then lbl_jumptbl := new_label(); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
850 |
+ ` ld {emit_gpr 11}, {emit_tocref (TocLabel !lbl_jumptbl)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
851 |
+ ` addi {emit_gpr 0}, {emit_reg i.arg.(0)}, {emit_int !num_jumptbl_entries}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
852 |
+ ` sldi {emit_gpr 0}, {emit_gpr 0}, 2\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
853 |
+ ` lwax {emit_gpr 0}, {emit_gpr 11}, {emit_gpr 0}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
854 |
+ ` add {emit_gpr 0}, {emit_gpr 11}, {emit_gpr 0}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
855 |
+ ` mtctr {emit_gpr 0}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
856 |
+ ` bctr\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
857 |
+ for i = 0 to Array.length jumptbl - 1 do |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
858 |
+ jumptbl_entries := jumptbl.(i) :: !jumptbl_entries; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
859 |
+ incr num_jumptbl_entries |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
860 |
+ done |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
861 |
+ | Lsetuptrap lbl -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
862 |
+ ` bl {emit_label lbl}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
863 |
+ | Lpushtrap -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
864 |
+ stack_traps_size := !stack_traps_size + 32; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
865 |
+ ` addi {emit_gpr 11}, {emit_gpr 1}, {emit_label !stack_size_lbl}-{emit_int !stack_traps_size}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
866 |
+ ` mflr {emit_gpr 0}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
867 |
+ ` std {emit_gpr 29}, 0({emit_gpr 11})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
868 |
+ ` std {emit_gpr 0}, 8({emit_gpr 11})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
869 |
+ ` std {emit_gpr 1}, 16({emit_gpr 11})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
870 |
+ ` std {emit_gpr 2}, 24({emit_gpr 11})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
871 |
+ ` mr {emit_gpr 29}, {emit_gpr 11}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
872 |
+ | Lpoptrap -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
873 |
+ ` ld {emit_gpr 29}, 0({emit_gpr 29})\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
874 |
+ | Lraise -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
875 |
+ ` ld {emit_gpr 0}, 8({emit_gpr 29})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
876 |
+ ` ld {emit_gpr 1}, 16({emit_gpr 29})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
877 |
+ ` ld {emit_gpr 2}, 24({emit_gpr 29})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
878 |
+ ` mtlr {emit_gpr 0}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
879 |
+ ` ld {emit_gpr 29}, 0({emit_gpr 29})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
880 |
+ ` blr\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
881 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
882 |
+and emit_delay = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
883 |
+ None -> () |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
884 |
+ | Some i -> emit_instr i None |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
885 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
886 |
+(* Checks if a pseudo-instruction expands to instructions |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
887 |
+ that do not branch and do not affect CR0 nor R12. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
888 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
889 |
+let is_simple_instr i = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
890 |
+ match i.desc with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
891 |
+ Lop op -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
892 |
+ begin match op with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
893 |
+ Icall_imm _ | Icall_ind | Itailcall_imm _ | Itailcall_ind | |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
894 |
+ Iextcall(_, _) -> false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
895 |
+ | Ialloc(_) -> false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
896 |
+ | Iintop(Icomp _) -> false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
897 |
+ | Iintop_imm(Iand, _) -> false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
898 |
+ | Iintop_imm(Icomp _, _) -> false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
899 |
+ | _ -> true |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
900 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
901 |
+ | Lreloadretaddr -> true |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
902 |
+ | _ -> false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
903 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
904 |
+let no_interference res arg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
905 |
+ try |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
906 |
+ for i = 0 to Array.length arg - 1 do |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
907 |
+ for j = 0 to Array.length res - 1 do |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
908 |
+ if arg.(i).loc = res.(j).loc then raise Exit |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
909 |
+ done |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
910 |
+ done; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
911 |
+ true |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
912 |
+ with Exit -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
913 |
+ false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
914 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
915 |
+(* Emit a sequence of instructions, trying to fill delay slots for branches *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
916 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
917 |
+let rec emit_all i = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
918 |
+ match i with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
919 |
+ {desc = Lend} -> () |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
920 |
+ | {next = {desc = (Lcondbranch(_, _) | Lcondbranch3(_, _, _))}} |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
921 |
+ when is_simple_instr i & no_interference i.res i.next.arg -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
922 |
+ emit_instr i.next (Some i); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
923 |
+ emit_all i.next.next |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
924 |
+ | _ -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
925 |
+ emit_instr i None; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
926 |
+ emit_all i.next |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
927 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
928 |
+(* Emission of a function declaration *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
929 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
930 |
+let fundecl fundecl = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
931 |
+ function_name := fundecl.fun_name; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
932 |
+ defined_functions := StringSet.add fundecl.fun_name !defined_functions; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
933 |
+ tailrec_entry_point := new_label(); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
934 |
+ if has_stack_frame() then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
935 |
+ stack_size_lbl := new_label(); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
936 |
+ stack_slot_lbl := new_label(); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
937 |
+ stack_args_size := 0; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
938 |
+ stack_traps_size := 0; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
939 |
+ call_gc_label := 0; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
940 |
+ ` .globl {emit_symbol fundecl.fun_name}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
941 |
+ begin match Config.system with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
942 |
+ | "elf" | "bsd" -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
943 |
+ ` .section \".opd\",\"aw\"\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
944 |
+ ` .align 3\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
945 |
+ ` .type {emit_symbol fundecl.fun_name}, @function\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
946 |
+ `{emit_symbol fundecl.fun_name}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
947 |
+ ` .quad .L.{emit_symbol fundecl.fun_name},.TOC.@tocbase\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
948 |
+ ` .previous\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
949 |
+ ` .align 2\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
950 |
+ emit_string code_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
951 |
+ `.L.{emit_symbol fundecl.fun_name}:\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
952 |
+ | _ -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
953 |
+ ` .align 2\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
954 |
+ emit_string code_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
955 |
+ `{emit_symbol fundecl.fun_name}:\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
956 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
957 |
+ if !contains_calls then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
958 |
+ ` mflr {emit_gpr 0}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
959 |
+ ` std {emit_gpr 0}, 16({emit_gpr 1})\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
960 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
961 |
+ if has_stack_frame() then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
962 |
+ ` stdu {emit_gpr 1}, -{emit_label !stack_size_lbl}({emit_gpr 1})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
963 |
+ `{emit_label !tailrec_entry_point}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
964 |
+ branch_normalization fundecl.fun_body; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
965 |
+ emit_all fundecl.fun_body; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
966 |
+ ` .size .L.{emit_symbol fundecl.fun_name}, . - .L.{emit_symbol fundecl.fun_name}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
967 |
+ if has_stack_frame() then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
968 |
+ ` .set {emit_label !stack_size_lbl},{emit_int (frame_size_sans_args() + !stack_args_size + !stack_traps_size)} # stack size including traps\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
969 |
+ ` .set {emit_label !stack_slot_lbl},{emit_int (48 + !stack_args_size)} # stack slot offset\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
970 |
+ end else (* leave 8 bytes for float <-> conversions *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
971 |
+ ` .set {emit_label !stack_slot_lbl},{emit_int (40-frame_size_sans_args())} # stack slot offset (negative)\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
972 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
973 |
+ (* Emit the glue code to call the GC *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
974 |
+ if !call_gc_label > 0 then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
975 |
+ `{emit_label !call_gc_label}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
976 |
+ ` ld {emit_gpr 12}, {emit_tocref (TocSymOfs ("caml_call_gc",0))}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
977 |
+ ` ld {emit_gpr 12}, 0({emit_gpr 12})\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
978 |
+ ` mtctr {emit_gpr 12}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
979 |
+ ` bctr\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
980 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
981 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
982 |
+(* Emission of data *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
983 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
984 |
+let declare_global_data s = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
985 |
+ ` .globl {emit_symbol s}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
986 |
+ if Config.system = "elf" || Config.system = "bsd" then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
987 |
+ ` .type {emit_symbol s}, @object\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
988 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
989 |
+let emit_item = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
990 |
+ Cglobal_symbol s -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
991 |
+ declare_global_data s |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
992 |
+ | Cdefine_symbol s -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
993 |
+ `{emit_symbol s}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
994 |
+ | Cdefine_label lbl -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
995 |
+ `{emit_label (lbl + 100000)}:\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
996 |
+ | Cint8 n -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
997 |
+ ` .byte {emit_int n}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
998 |
+ | Cint16 n -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
999 |
+ ` .short {emit_int n}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1000 |
+ | Cint32 n -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1001 |
+ ` .long {emit_nativeint n}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1002 |
+ | Cint n -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1003 |
+ ` .quad {emit_nativeint n}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1004 |
+ | Csingle f -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1005 |
+ ` .float 0d{emit_string f}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1006 |
+ | Cdouble f -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1007 |
+ ` .double 0d{emit_string f}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1008 |
+ | Csymbol_address s -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1009 |
+ ` .quad {emit_symbol s}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1010 |
+ | Clabel_address lbl -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1011 |
+ ` .quad {emit_label (lbl + 100000)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1012 |
+ | Cstring s -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1013 |
+ emit_bytes_directive " .byte " s |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1014 |
+ | Cskip n -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1015 |
+ if n > 0 then ` .space {emit_int n}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1016 |
+ | Calign n -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1017 |
+ ` .align {emit_int (Misc.log2 n)}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1018 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1019 |
+let data l = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1020 |
+ emit_string data_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1021 |
+ List.iter emit_item l |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1022 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1023 |
+(* Beginning / end of an assembly file *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1024 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1025 |
+let begin_assembly() = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1026 |
+ defined_functions := StringSet.empty; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1027 |
+ external_functions := StringSet.empty; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1028 |
+ tocref_entries := []; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1029 |
+ num_jumptbl_entries := 0; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1030 |
+ jumptbl_entries := []; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1031 |
+ lbl_jumptbl := 0; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1032 |
+ (* Emit the beginning of the segments *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1033 |
+ let lbl_begin = Compilenv.make_symbol (Some "data_begin") in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1034 |
+ emit_string data_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1035 |
+ declare_global_data lbl_begin; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1036 |
+ `{emit_symbol lbl_begin}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1037 |
+ let lbl_begin = Compilenv.make_symbol (Some "code_begin") in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1038 |
+ emit_string code_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1039 |
+ declare_global_data lbl_begin; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1040 |
+ `{emit_symbol lbl_begin}:\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1041 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1042 |
+let end_assembly() = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1043 |
+ (* Emit the jump table *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1044 |
+ if !num_jumptbl_entries > 0 then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1045 |
+ emit_string code_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1046 |
+ `{emit_label !lbl_jumptbl}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1047 |
+ List.iter |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1048 |
+ (fun lbl -> ` .long {emit_label lbl} - {emit_label !lbl_jumptbl}\n`) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1049 |
+ (List.rev !jumptbl_entries); |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1050 |
+ jumptbl_entries := [] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1051 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1052 |
+ if !tocref_entries <> [] then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1053 |
+ emit_string toc_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1054 |
+ List.iter |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1055 |
+ (fun (lbl, entry) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1056 |
+ `{emit_label lbl}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1057 |
+ match entry with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1058 |
+ TocFloat f -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1059 |
+ ` .double {emit_tocentry entry}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1060 |
+ | _ -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1061 |
+ ` .tc {emit_label lbl}[TC],{emit_tocentry entry}\n` |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1062 |
+ ) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1063 |
+ !tocref_entries; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1064 |
+ tocref_entries := [] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1065 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1066 |
+ if pic_externals then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1067 |
+ (* Emit the pointers to external functions *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1068 |
+ StringSet.iter emit_external !external_functions; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1069 |
+ (* Emit the end of the segments *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1070 |
+ emit_string code_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1071 |
+ let lbl_end = Compilenv.make_symbol (Some "code_end") in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1072 |
+ declare_global_data lbl_end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1073 |
+ `{emit_symbol lbl_end}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1074 |
+ ` .long 0\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1075 |
+ emit_string data_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1076 |
+ let lbl_end = Compilenv.make_symbol (Some "data_end") in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1077 |
+ declare_global_data lbl_end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1078 |
+ `{emit_symbol lbl_end}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1079 |
+ ` .quad 0\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1080 |
+ (* Emit the frame descriptors *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1081 |
+ emit_string rodata_space; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1082 |
+ let lbl = Compilenv.make_symbol (Some "frametable") in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1083 |
+ declare_global_data lbl; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1084 |
+ `{emit_symbol lbl}:\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1085 |
+ ` .quad {emit_int (List.length !frame_descriptors)}\n`; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1086 |
+ List.iter emit_frame !frame_descriptors; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1087 |
+ frame_descriptors := [] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1088 |
diff -uNr ocaml-3.10.1/asmcomp/power64/proc.ml ocaml-3.10.1.ppc64/asmcomp/power64/proc.ml |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1089 |
--- ocaml-3.10.1/asmcomp/power64/proc.ml 1969-12-31 19:00:00.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1090 |
+++ ocaml-3.10.1.ppc64/asmcomp/power64/proc.ml 2008-02-29 08:37:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1091 |
@@ -0,0 +1,245 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1092 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1093 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1094 |
+(* Objective Caml *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1095 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1096 |
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1097 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1098 |
+(* Copyright 1996 Institut National de Recherche en Informatique et *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1099 |
+(* en Automatique. All rights reserved. This file is distributed *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1100 |
+(* under the terms of the Q Public License version 1.0. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1101 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1102 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1103 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1104 |
+(* $Id: proc.ml,v 1.12 2004/06/19 17:39:35 xleroy Exp $ *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1105 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1106 |
+(* Description of the Power PC *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1107 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1108 |
+open Misc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1109 |
+open Cmm |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1110 |
+open Reg |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1111 |
+open Arch |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1112 |
+open Mach |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1113 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1114 |
+(* Instruction selection *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1115 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1116 |
+let word_addressed = false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1117 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1118 |
+(* Registers available for register allocation *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1119 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1120 |
+(* Integer register map: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1121 |
+ 0 temporary, null register for some operations |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1122 |
+ 1 stack pointer |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1123 |
+ 2 pointer to table of contents |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1124 |
+ 3 - 10 function arguments and results |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1125 |
+ 11 - 12 temporaries |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1126 |
+ 13 pointer to small data area |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1127 |
+ 14 - 28 general purpose, preserved by C |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1128 |
+ 29 trap pointer |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1129 |
+ 30 allocation limit |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1130 |
+ 31 allocation pointer |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1131 |
+ Floating-point register map: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1132 |
+ 0 temporary |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1133 |
+ 1 - 13 function arguments and results |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1134 |
+ 14 - 31 general purpose, preserved by C |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1135 |
+*) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1136 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1137 |
+let int_reg_name = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1138 |
+ if Config.system = "rhapsody" then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1139 |
+ [| "r3"; "r4"; "r5"; "r6"; "r7"; "r8"; "r9"; "r10"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1140 |
+ "r14"; "r15"; "r16"; "r17"; "r18"; "r19"; "r20"; "r21"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1141 |
+ "r22"; "r23"; "r24"; "r25"; "r26"; "r27"; "r28" |] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1142 |
+ else |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1143 |
+ [| "3"; "4"; "5"; "6"; "7"; "8"; "9"; "10"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1144 |
+ "14"; "15"; "16"; "17"; "18"; "19"; "20"; "21"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1145 |
+ "22"; "23"; "24"; "25"; "26"; "27"; "28" |] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1146 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1147 |
+let float_reg_name = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1148 |
+ if Config.system = "rhapsody" then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1149 |
+ [| "f1"; "f2"; "f3"; "f4"; "f5"; "f6"; "f7"; "f8"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1150 |
+ "f9"; "f10"; "f11"; "f12"; "f13"; "f14"; "f15"; "f16"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1151 |
+ "f17"; "f18"; "f19"; "f20"; "f21"; "f22"; "f23"; "f24"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1152 |
+ "f25"; "f26"; "f27"; "f28"; "f29"; "f30"; "f31" |] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1153 |
+ else |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1154 |
+ [| "1"; "2"; "3"; "4"; "5"; "6"; "7"; "8"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1155 |
+ "9"; "10"; "11"; "12"; "13"; "14"; "15"; "16"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1156 |
+ "17"; "18"; "19"; "20"; "21"; "22"; "23"; "24"; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1157 |
+ "25"; "26"; "27"; "28"; "29"; "30"; "31" |] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1158 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1159 |
+let num_register_classes = 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1160 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1161 |
+let register_class r = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1162 |
+ match r.typ with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1163 |
+ Int -> 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1164 |
+ | Addr -> 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1165 |
+ | Float -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1166 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1167 |
+let num_available_registers = [| 23; 31 |] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1168 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1169 |
+let first_available_register = [| 0; 100 |] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1170 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1171 |
+let register_name r = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1172 |
+ if r < 100 then int_reg_name.(r) else float_reg_name.(r - 100) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1173 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1174 |
+let rotate_registers = true |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1175 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1176 |
+(* Representation of hard registers by pseudo-registers *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1177 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1178 |
+let hard_int_reg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1179 |
+ let v = Array.create 23 Reg.dummy in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1180 |
+ for i = 0 to 22 do v.(i) <- Reg.at_location Int (Reg i) done; v |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1181 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1182 |
+let hard_float_reg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1183 |
+ let v = Array.create 31 Reg.dummy in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1184 |
+ for i = 0 to 30 do v.(i) <- Reg.at_location Float (Reg(100 + i)) done; v |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1185 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1186 |
+let all_phys_regs = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1187 |
+ Array.append hard_int_reg hard_float_reg |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1188 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1189 |
+let phys_reg n = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1190 |
+ if n < 100 then hard_int_reg.(n) else hard_float_reg.(n - 100) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1191 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1192 |
+let stack_slot slot ty = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1193 |
+ Reg.at_location ty (Stack slot) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1194 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1195 |
+(* Calling conventions *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1196 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1197 |
+let calling_conventions |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1198 |
+ first_int last_int first_float last_float make_stack stack_ofs arg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1199 |
+ let loc = Array.create (Array.length arg) Reg.dummy in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1200 |
+ let int = ref first_int in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1201 |
+ let float = ref first_float in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1202 |
+ let ofs = ref stack_ofs in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1203 |
+ for i = 0 to Array.length arg - 1 do |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1204 |
+ match arg.(i).typ with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1205 |
+ Int | Addr as ty -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1206 |
+ if !int <= last_int then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1207 |
+ loc.(i) <- phys_reg !int; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1208 |
+ incr int |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1209 |
+ end else begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1210 |
+ loc.(i) <- stack_slot (make_stack !ofs) ty; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1211 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1212 |
+ ofs := !ofs + 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1213 |
+ | Float -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1214 |
+ if !float <= last_float then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1215 |
+ loc.(i) <- phys_reg !float; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1216 |
+ incr float |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1217 |
+ end else begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1218 |
+ loc.(i) <- stack_slot (make_stack !ofs) Float; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1219 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1220 |
+ ofs := !ofs + 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1221 |
+ done; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1222 |
+ (loc, Misc.align !ofs 16) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1223 |
+ (* Keep stack 16-aligned. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1224 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1225 |
+let incoming ofs = Incoming ofs |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1226 |
+let outgoing ofs = Outgoing ofs |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1227 |
+let not_supported ofs = fatal_error "Proc.loc_results: cannot call" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1228 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1229 |
+let loc_arguments arg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1230 |
+ calling_conventions 0 7 100 112 outgoing 48 arg |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1231 |
+let loc_parameters arg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1232 |
+ let (loc, ofs) = calling_conventions 0 7 100 112 incoming 0 arg in loc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1233 |
+let loc_results res = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1234 |
+ let (loc, ofs) = calling_conventions 0 7 100 112 not_supported 0 res in loc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1235 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1236 |
+(* C calling conventions under PowerOpen: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1237 |
+ use GPR 3-10 and FPR 1-13 just like ML calling |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1238 |
+ conventions, but always reserve stack space for all arguments. |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1239 |
+ Also, using a float register automatically reserves two int registers |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1240 |
+ (in 32-bit mode) or one int register (in 64-bit mode). |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1241 |
+ (If we were to call a non-prototyped C function, each float argument |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1242 |
+ would have to go both in a float reg and in the matching pair |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1243 |
+ of integer regs.) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1244 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1245 |
+ C calling conventions under SVR4: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1246 |
+ use GPR 3-10 and FPR 1-8 just like ML calling conventions. |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1247 |
+ Using a float register does not affect the int registers. |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1248 |
+ Always reserve 8 bytes at bottom of stack, plus whatever is needed |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1249 |
+ to hold the overflow arguments. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1250 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1251 |
+let poweropen_external_conventions first_int last_int |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1252 |
+ first_float last_float arg = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1253 |
+ let loc = Array.create (Array.length arg) Reg.dummy in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1254 |
+ let int = ref first_int in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1255 |
+ let float = ref first_float in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1256 |
+ let ofs = ref 112 in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1257 |
+ for i = 0 to Array.length arg - 1 do |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1258 |
+ match arg.(i).typ with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1259 |
+ Int | Addr as ty -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1260 |
+ if !int <= last_int then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1261 |
+ loc.(i) <- phys_reg !int; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1262 |
+ incr int |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1263 |
+ end else begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1264 |
+ loc.(i) <- stack_slot (Outgoing !ofs) ty; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1265 |
+ ofs := !ofs + size_int |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1266 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1267 |
+ | Float -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1268 |
+ if !float <= last_float then begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1269 |
+ loc.(i) <- phys_reg !float; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1270 |
+ incr float |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1271 |
+ end else begin |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1272 |
+ loc.(i) <- stack_slot (Outgoing !ofs) Float; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1273 |
+ ofs := !ofs + size_float |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1274 |
+ end; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1275 |
+ int := !int + 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1276 |
+ done; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1277 |
+ (loc, Misc.align !ofs 16) (* Keep stack 16-aligned *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1278 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1279 |
+let loc_external_arguments = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1280 |
+ match Config.system with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1281 |
+ | "rhapsody" -> poweropen_external_conventions 0 7 100 112 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1282 |
+ | "elf" | "bsd" -> calling_conventions 0 7 100 107 outgoing 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1283 |
+ | _ -> assert false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1284 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1285 |
+let extcall_use_push = false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1286 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1287 |
+(* Results are in GPR 3 and FPR 1 *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1288 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1289 |
+let loc_external_results res = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1290 |
+ let (loc, ofs) = calling_conventions 0 0 100 100 not_supported 0 res in loc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1291 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1292 |
+(* Exceptions are in GPR 3 *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1293 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1294 |
+let loc_exn_bucket = phys_reg 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1295 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1296 |
+(* Registers destroyed by operations *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1297 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1298 |
+let destroyed_at_c_call = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1299 |
+ Array.of_list(List.map phys_reg |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1300 |
+ [0; 1; 2; 3; 4; 5; 6; 7; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1301 |
+ 100; 101; 102; 103; 104; 105; 106; 107; 108; 109; 110; 111; 112]) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1302 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1303 |
+let destroyed_at_oper = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1304 |
+ Iop(Icall_ind | Icall_imm _ | Iextcall(_, true)) -> all_phys_regs |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1305 |
+ | Iop(Iextcall(_, false)) -> destroyed_at_c_call |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1306 |
+ | _ -> [||] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1307 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1308 |
+let destroyed_at_raise = all_phys_regs |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1309 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1310 |
+(* Maximal register pressure *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1311 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1312 |
+let safe_register_pressure = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1313 |
+ Iextcall(_, _) -> 15 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1314 |
+ | _ -> 23 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1315 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1316 |
+let max_register_pressure = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1317 |
+ Iextcall(_, _) -> [| 15; 18 |] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1318 |
+ | _ -> [| 23; 30 |] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1319 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1320 |
+(* Layout of the stack *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1321 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1322 |
+let num_stack_slots = [| 0; 0 |] |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1323 |
+let contains_calls = ref false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1324 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1325 |
+(* Calling the assembler *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1326 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1327 |
+let assemble_file infile outfile = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1328 |
+ let infile = Filename.quote infile |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1329 |
+ and outfile = Filename.quote outfile in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1330 |
+ match Config.system with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1331 |
+ | "elf" -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1332 |
+ Ccomp.command ("as -u -m ppc64 -o " ^ outfile ^ " " ^ infile) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1333 |
+ | _ -> assert false |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1334 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1335 |
+open Clflags;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1336 |
+open Config;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1337 |
diff -uNr ocaml-3.10.1/asmcomp/power64/reload.ml ocaml-3.10.1.ppc64/asmcomp/power64/reload.ml |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1338 |
--- ocaml-3.10.1/asmcomp/power64/reload.ml 1969-12-31 19:00:00.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1339 |
+++ ocaml-3.10.1.ppc64/asmcomp/power64/reload.ml 2008-02-29 08:37:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1340 |
@@ -0,0 +1,18 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1341 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1342 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1343 |
+(* Objective Caml *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1344 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1345 |
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1346 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1347 |
+(* Copyright 1996 Institut National de Recherche en Informatique et *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1348 |
+(* en Automatique. All rights reserved. This file is distributed *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1349 |
+(* under the terms of the Q Public License version 1.0. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1350 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1351 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1352 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1353 |
+(* $Id: reload.ml,v 1.3 1999/11/17 18:56:46 xleroy Exp $ *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1354 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1355 |
+(* Reloading for the PowerPC *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1356 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1357 |
+let fundecl f = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1358 |
+ (new Reloadgen.reload_generic)#fundecl f |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1359 |
diff -uNr ocaml-3.10.1/asmcomp/power64/scheduling.ml ocaml-3.10.1.ppc64/asmcomp/power64/scheduling.ml |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1360 |
--- ocaml-3.10.1/asmcomp/power64/scheduling.ml 1969-12-31 19:00:00.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1361 |
+++ ocaml-3.10.1.ppc64/asmcomp/power64/scheduling.ml 2008-02-29 08:37:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1362 |
@@ -0,0 +1,66 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1363 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1364 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1365 |
+(* Objective Caml *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1366 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1367 |
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1368 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1369 |
+(* Copyright 1996 Institut National de Recherche en Informatique et *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1370 |
+(* en Automatique. All rights reserved. This file is distributed *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1371 |
+(* under the terms of the Q Public License version 1.0. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1372 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1373 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1374 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1375 |
+(* $Id: scheduling.ml,v 1.6 2004/06/19 16:13:33 xleroy Exp $ *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1376 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1377 |
+(* Instruction scheduling for the Power PC *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1378 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1379 |
+open Arch |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1380 |
+open Mach |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1381 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1382 |
+class scheduler = object |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1383 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1384 |
+inherit Schedgen.scheduler_generic |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1385 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1386 |
+(* Latencies (in cycles). Based roughly on the "common model". *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1387 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1388 |
+method oper_latency = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1389 |
+ Ireload -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1390 |
+ | Iload(_, _) -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1391 |
+ | Iconst_float _ -> 2 (* turned into a load *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1392 |
+ | Iconst_symbol _ -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1393 |
+ | Iintop Imul -> 9 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1394 |
+ | Iintop_imm(Imul, _) -> 5 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1395 |
+ | Iintop(Idiv | Imod) -> 36 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1396 |
+ | Iaddf | Isubf -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1397 |
+ | Imulf -> 5 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1398 |
+ | Idivf -> 33 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1399 |
+ | Ispecific(Imultaddf | Imultsubf) -> 5 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1400 |
+ | _ -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1401 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1402 |
+method reload_retaddr_latency = 12 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1403 |
+ (* If we can have that many cycles between the reloadretaddr and the |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1404 |
+ return, we can expect that the blr branch will be completely folded. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1405 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1406 |
+(* Issue cycles. Rough approximations. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1407 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1408 |
+method oper_issue_cycles = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1409 |
+ Iconst_float _ | Iconst_symbol _ -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1410 |
+ | Iload(_, Ibased(_, _)) -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1411 |
+ | Istore(_, Ibased(_, _)) -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1412 |
+ | Ialloc _ -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1413 |
+ | Iintop(Imod) -> 40 (* assuming full stall *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1414 |
+ | Iintop(Icomp _) -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1415 |
+ | Iintop_imm(Idiv, _) -> 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1416 |
+ | Iintop_imm(Imod, _) -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1417 |
+ | Iintop_imm(Icomp _, _) -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1418 |
+ | Ifloatofint -> 9 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1419 |
+ | Iintoffloat -> 4 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1420 |
+ | _ -> 1 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1421 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1422 |
+method reload_retaddr_issue_cycles = 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1423 |
+ (* load then stalling mtlr *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1424 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1425 |
+end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1426 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1427 |
+let fundecl f = (new scheduler)#schedule_fundecl f |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1428 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1429 |
diff -uNr ocaml-3.10.1/asmcomp/power64/selection.ml ocaml-3.10.1.ppc64/asmcomp/power64/selection.ml |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1430 |
--- ocaml-3.10.1/asmcomp/power64/selection.ml 1969-12-31 19:00:00.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1431 |
+++ ocaml-3.10.1.ppc64/asmcomp/power64/selection.ml 2008-02-29 08:37:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1432 |
@@ -0,0 +1,103 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1433 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1434 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1435 |
+(* Objective Caml *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1436 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1437 |
+(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1438 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1439 |
+(* Copyright 1997 Institut National de Recherche en Informatique et *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1440 |
+(* en Automatique. All rights reserved. This file is distributed *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1441 |
+(* under the terms of the Q Public License version 1.0. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1442 |
+(* *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1443 |
+(***********************************************************************) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1444 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1445 |
+(* $Id: selection.ml,v 1.6 2004/06/19 16:13:33 xleroy Exp $ *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1446 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1447 |
+(* Instruction selection for the Power PC processor *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1448 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1449 |
+open Misc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1450 |
+open Cmm |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1451 |
+open Reg |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1452 |
+open Arch |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1453 |
+open Mach |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1454 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1455 |
+(* Recognition of addressing modes *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1456 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1457 |
+type addressing_expr = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1458 |
+ Asymbol of string |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1459 |
+ | Alinear of expression |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1460 |
+ | Aadd of expression * expression |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1461 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1462 |
+let rec select_addr = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1463 |
+ Cconst_symbol s -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1464 |
+ (Asymbol s, 0) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1465 |
+ | Cop((Caddi | Cadda), [arg; Cconst_int m]) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1466 |
+ let (a, n) = select_addr arg in (a, n + m) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1467 |
+ | Cop((Caddi | Cadda), [Cconst_int m; arg]) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1468 |
+ let (a, n) = select_addr arg in (a, n + m) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1469 |
+ | Cop((Caddi | Cadda), [arg1; arg2]) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1470 |
+ begin match (select_addr arg1, select_addr arg2) with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1471 |
+ ((Alinear e1, n1), (Alinear e2, n2)) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1472 |
+ (Aadd(e1, e2), n1 + n2) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1473 |
+ | _ -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1474 |
+ (Aadd(arg1, arg2), 0) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1475 |
+ end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1476 |
+ | exp -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1477 |
+ (Alinear exp, 0) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1478 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1479 |
+(* Instruction selection *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1480 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1481 |
+class selector = object (self) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1482 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1483 |
+inherit Selectgen.selector_generic as super |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1484 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1485 |
+method is_immediate n = (n <= 32767) && (n >= -32768) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1486 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1487 |
+method select_addressing exp = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1488 |
+ match select_addr exp with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1489 |
+ (Asymbol s, d) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1490 |
+ (Ibased(s, d), Ctuple []) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1491 |
+ | (Alinear e, d) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1492 |
+ (Iindexed d, e) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1493 |
+ | (Aadd(e1, e2), d) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1494 |
+ if d = 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1495 |
+ then (Iindexed2, Ctuple[e1; e2]) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1496 |
+ else (Iindexed d, Cop(Cadda, [e1; e2])) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1497 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1498 |
+method select_operation op args = |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1499 |
+ match (op, args) with |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1500 |
+ (* Prevent the recognition of (x / cst) and (x % cst) when cst is not |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1501 |
+ a power of 2, which do not correspond to an instruction. *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1502 |
+ (Cdivi, [arg; Cconst_int n]) when n = 1 lsl (Misc.log2 n) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1503 |
+ (Iintop_imm(Idiv, n), [arg]) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1504 |
+ | (Cdivi, _) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1505 |
+ (Iintop Idiv, args) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1506 |
+ | (Cmodi, [arg; Cconst_int n]) when n = 1 lsl (Misc.log2 n) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1507 |
+ (Iintop_imm(Imod, n), [arg]) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1508 |
+ | (Cmodi, _) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1509 |
+ (Iintop Imod, args) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1510 |
+ (* The and, or and xor instructions have a different range of immediate |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1511 |
+ operands than the other instructions *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1512 |
+ | (Cand, _) -> self#select_logical Iand args |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1513 |
+ | (Cor, _) -> self#select_logical Ior args |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1514 |
+ | (Cxor, _) -> self#select_logical Ixor args |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1515 |
+ (* Recognize mult-add and mult-sub instructions *) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1516 |
+ | (Caddf, [Cop(Cmulf, [arg1; arg2]); arg3]) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1517 |
+ (Ispecific Imultaddf, [arg1; arg2; arg3]) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1518 |
+ | (Caddf, [arg3; Cop(Cmulf, [arg1; arg2])]) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1519 |
+ (Ispecific Imultaddf, [arg1; arg2; arg3]) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1520 |
+ | (Csubf, [Cop(Cmulf, [arg1; arg2]); arg3]) -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1521 |
+ (Ispecific Imultsubf, [arg1; arg2; arg3]) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1522 |
+ | _ -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1523 |
+ super#select_operation op args |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1524 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1525 |
+method select_logical op = function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1526 |
+ [arg; Cconst_int n] when n >= 0 && n <= 0xFFFF -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1527 |
+ (Iintop_imm(op, n), [arg]) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1528 |
+ | [Cconst_int n; arg] when n >= 0 && n <= 0xFFFF -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1529 |
+ (Iintop_imm(op, n), [arg]) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1530 |
+ | args -> |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1531 |
+ (Iintop op, args) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1532 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1533 |
+end |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1534 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1535 |
+let fundecl f = (new selector)#emit_fundecl f |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1536 |
diff -uNr ocaml-3.10.1/asmrun/Makefile ocaml-3.10.1.ppc64/asmrun/Makefile |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1537 |
--- ocaml-3.10.1/asmrun/Makefile 2007-02-23 04:29:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1538 |
+++ ocaml-3.10.1.ppc64/asmrun/Makefile 2008-02-29 08:37:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1539 |
@@ -74,6 +74,12 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1540 |
power.p.o: power-$(SYSTEM).o |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1541 |
cp power-$(SYSTEM).o power.p.o |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1542 |
|
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1543 |
+power64.o: power64-$(SYSTEM).o |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1544 |
+ cp power64-$(SYSTEM).o power64.o |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1545 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1546 |
+power64.p.o: power64-$(SYSTEM).o |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1547 |
+ cp power64-$(SYSTEM).o power64.p.o |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1548 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1549 |
main.c: ../byterun/main.c |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1550 |
ln -s ../byterun/main.c main.c |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1551 |
misc.c: ../byterun/misc.c |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1552 |
diff -uNr ocaml-3.10.1/asmrun/power64-elf.S ocaml-3.10.1.ppc64/asmrun/power64-elf.S |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1553 |
--- ocaml-3.10.1/asmrun/power64-elf.S 1969-12-31 19:00:00.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1554 |
+++ ocaml-3.10.1.ppc64/asmrun/power64-elf.S 2008-02-29 08:37:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1555 |
@@ -0,0 +1,486 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1556 |
+/*********************************************************************/ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1557 |
+/* */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1558 |
+/* Objective Caml */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1559 |
+/* */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1560 |
+/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1561 |
+/* */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1562 |
+/* Copyright 1996 Institut National de Recherche en Informatique et */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1563 |
+/* en Automatique. All rights reserved. This file is distributed */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1564 |
+/* under the terms of the GNU Library General Public License, with */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1565 |
+/* the special exception on linking described in file ../LICENSE. */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1566 |
+/* */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1567 |
+/*********************************************************************/ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1568 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1569 |
+/* $Id: power-elf.S,v 1.18 2004/01/03 12:51:19 doligez Exp $ */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1570 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1571 |
+#define Addrglobal(reg,glob) \ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1572 |
+ addis reg, 0, glob@ha; \ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1573 |
+ addi reg, reg, glob@l |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1574 |
+#define Loadglobal(reg,glob,tmp) \ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1575 |
+ addis tmp, 0, glob@ha; \ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1576 |
+ ld reg, glob@l(tmp) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1577 |
+#define Storeglobal(reg,glob,tmp) \ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1578 |
+ addis tmp, 0, glob@ha; \ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1579 |
+ std reg, glob@l(tmp) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1580 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1581 |
+ .section ".text" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1582 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1583 |
+/* Invoke the garbage collector. */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1584 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1585 |
+ .globl caml_call_gc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1586 |
+ .type caml_call_gc, @function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1587 |
+ .section ".opd","aw" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1588 |
+ .align 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1589 |
+caml_call_gc: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1590 |
+ .quad .L.caml_call_gc,.TOC.@tocbase |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1591 |
+ .previous |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1592 |
+ .align 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1593 |
+.L.caml_call_gc: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1594 |
+ /* Set up stack frame */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1595 |
+ mflr 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1596 |
+ std 0, 16(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1597 |
+ /* Record return address into Caml code */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1598 |
+ Storeglobal(0, caml_last_return_address, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1599 |
+ /* Record lowest stack address */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1600 |
+ Storeglobal(1, caml_bottom_of_stack, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1601 |
+ /* 0x220 = 8*32 (int regs) + 8*32 (float regs) + 48 (stack frame) */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1602 |
+ stdu 1, -0x230(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1603 |
+ /* Record pointer to register array */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1604 |
+ addi 0, 1, 8*32 + 48 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1605 |
+ Storeglobal(0, caml_gc_regs, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1606 |
+ /* Save current allocation pointer for debugging purposes */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1607 |
+ Storeglobal(31, caml_young_ptr, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1608 |
+ /* Save exception pointer (if e.g. a sighandler raises) */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1609 |
+ Storeglobal(29, caml_exception_pointer, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1610 |
+ /* Save all registers used by the code generator */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1611 |
+ addi 11, 1, 8*32 + 48 - 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1612 |
+ stdu 3, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1613 |
+ stdu 4, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1614 |
+ stdu 5, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1615 |
+ stdu 6, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1616 |
+ stdu 7, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1617 |
+ stdu 8, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1618 |
+ stdu 9, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1619 |
+ stdu 10, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1620 |
+ stdu 14, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1621 |
+ stdu 15, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1622 |
+ stdu 16, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1623 |
+ stdu 17, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1624 |
+ stdu 18, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1625 |
+ stdu 19, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1626 |
+ stdu 20, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1627 |
+ stdu 21, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1628 |
+ stdu 22, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1629 |
+ stdu 23, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1630 |
+ stdu 24, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1631 |
+ stdu 25, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1632 |
+ stdu 26, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1633 |
+ stdu 27, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1634 |
+ stdu 28, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1635 |
+ addi 11, 1, 48 - 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1636 |
+ stfdu 1, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1637 |
+ stfdu 2, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1638 |
+ stfdu 3, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1639 |
+ stfdu 4, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1640 |
+ stfdu 5, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1641 |
+ stfdu 6, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1642 |
+ stfdu 7, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1643 |
+ stfdu 8, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1644 |
+ stfdu 9, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1645 |
+ stfdu 10, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1646 |
+ stfdu 11, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1647 |
+ stfdu 12, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1648 |
+ stfdu 13, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1649 |
+ stfdu 14, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1650 |
+ stfdu 15, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1651 |
+ stfdu 16, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1652 |
+ stfdu 17, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1653 |
+ stfdu 18, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1654 |
+ stfdu 19, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1655 |
+ stfdu 20, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1656 |
+ stfdu 21, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1657 |
+ stfdu 22, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1658 |
+ stfdu 23, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1659 |
+ stfdu 24, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1660 |
+ stfdu 25, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1661 |
+ stfdu 26, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1662 |
+ stfdu 27, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1663 |
+ stfdu 28, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1664 |
+ stfdu 29, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1665 |
+ stfdu 30, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1666 |
+ stfdu 31, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1667 |
+ /* Call the GC */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1668 |
+ std 2,40(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1669 |
+ Addrglobal(11, caml_garbage_collection) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1670 |
+ ld 2,8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1671 |
+ ld 11,0(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1672 |
+ mtlr 11 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1673 |
+ blrl |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1674 |
+ ld 2,40(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1675 |
+ /* Reload new allocation pointer and allocation limit */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1676 |
+ Loadglobal(31, caml_young_ptr, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1677 |
+ Loadglobal(30, caml_young_limit, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1678 |
+ /* Restore all regs used by the code generator */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1679 |
+ addi 11, 1, 8*32 + 48 - 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1680 |
+ ldu 3, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1681 |
+ ldu 4, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1682 |
+ ldu 5, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1683 |
+ ldu 6, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1684 |
+ ldu 7, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1685 |
+ ldu 8, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1686 |
+ ldu 9, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1687 |
+ ldu 10, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1688 |
+ ldu 14, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1689 |
+ ldu 15, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1690 |
+ ldu 16, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1691 |
+ ldu 17, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1692 |
+ ldu 18, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1693 |
+ ldu 19, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1694 |
+ ldu 20, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1695 |
+ ldu 21, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1696 |
+ ldu 22, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1697 |
+ ldu 23, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1698 |
+ ldu 24, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1699 |
+ ldu 25, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1700 |
+ ldu 26, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1701 |
+ ldu 27, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1702 |
+ ldu 28, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1703 |
+ addi 11, 1, 48 - 8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1704 |
+ lfdu 1, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1705 |
+ lfdu 2, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1706 |
+ lfdu 3, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1707 |
+ lfdu 4, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1708 |
+ lfdu 5, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1709 |
+ lfdu 6, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1710 |
+ lfdu 7, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1711 |
+ lfdu 8, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1712 |
+ lfdu 9, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1713 |
+ lfdu 10, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1714 |
+ lfdu 11, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1715 |
+ lfdu 12, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1716 |
+ lfdu 13, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1717 |
+ lfdu 14, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1718 |
+ lfdu 15, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1719 |
+ lfdu 16, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1720 |
+ lfdu 17, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1721 |
+ lfdu 18, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1722 |
+ lfdu 19, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1723 |
+ lfdu 20, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1724 |
+ lfdu 21, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1725 |
+ lfdu 22, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1726 |
+ lfdu 23, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1727 |
+ lfdu 24, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1728 |
+ lfdu 25, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1729 |
+ lfdu 26, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1730 |
+ lfdu 27, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1731 |
+ lfdu 28, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1732 |
+ lfdu 29, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1733 |
+ lfdu 30, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1734 |
+ lfdu 31, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1735 |
+ /* Return to caller, restarting the allocation */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1736 |
+ Loadglobal(0, caml_last_return_address, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1737 |
+ addic 0, 0, -16 /* Restart the allocation (4 instructions) */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1738 |
+ mtlr 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1739 |
+ /* Say we are back into Caml code */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1740 |
+ li 12, 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1741 |
+ Storeglobal(12, caml_last_return_address, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1742 |
+ /* Deallocate stack frame */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1743 |
+ ld 1, 0(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1744 |
+ /* Return */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1745 |
+ blr |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1746 |
+ .size .L.caml_call_gc,.-.L.caml_call_gc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1747 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1748 |
+/* Call a C function from Caml */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1749 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1750 |
+ .globl caml_c_call |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1751 |
+ .type caml_c_call, @function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1752 |
+ .section ".opd","aw" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1753 |
+ .align 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1754 |
+caml_c_call: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1755 |
+ .quad .L.caml_c_call,.TOC.@tocbase |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1756 |
+ .previous |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1757 |
+ .align 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1758 |
+.L.caml_c_call: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1759 |
+ .cfi_startproc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1760 |
+ /* Save return address */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1761 |
+ mflr 25 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1762 |
+ .cfi_register lr,25 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1763 |
+ /* Get ready to call C function (address in 11) */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1764 |
+ ld 2, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1765 |
+ ld 11,0(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1766 |
+ mtlr 11 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1767 |
+ /* Record lowest stack address and return address */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1768 |
+ Storeglobal(1, caml_bottom_of_stack, 12) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1769 |
+ Storeglobal(25, caml_last_return_address, 12) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1770 |
+ /* Make the exception handler and alloc ptr available to the C code */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1771 |
+ Storeglobal(31, caml_young_ptr, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1772 |
+ Storeglobal(29, caml_exception_pointer, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1773 |
+ /* Call the function (address in link register) */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1774 |
+ blrl |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1775 |
+ /* Restore return address (in 25, preserved by the C function) */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1776 |
+ mtlr 25 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1777 |
+ /* Reload allocation pointer and allocation limit*/ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1778 |
+ Loadglobal(31, caml_young_ptr, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1779 |
+ Loadglobal(30, caml_young_limit, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1780 |
+ /* Say we are back into Caml code */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1781 |
+ li 12, 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1782 |
+ Storeglobal(12, caml_last_return_address, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1783 |
+ /* Return to caller */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1784 |
+ blr |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1785 |
+ .cfi_endproc |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1786 |
+ .size .L.caml_c_call,.-.L.caml_c_call |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1787 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1788 |
+/* Raise an exception from C */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1789 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1790 |
+ .globl caml_raise_exception |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1791 |
+ .type caml_raise_exception, @function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1792 |
+ .section ".opd","aw" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1793 |
+ .align 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1794 |
+caml_raise_exception: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1795 |
+ .quad .L.caml_raise_exception,.TOC.@tocbase |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1796 |
+ .previous |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1797 |
+ .align 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1798 |
+.L.caml_raise_exception: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1799 |
+ /* Reload Caml global registers */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1800 |
+ Loadglobal(29, caml_exception_pointer, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1801 |
+ Loadglobal(31, caml_young_ptr, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1802 |
+ Loadglobal(30, caml_young_limit, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1803 |
+ /* Say we are back into Caml code */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1804 |
+ li 0, 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1805 |
+ Storeglobal(0, caml_last_return_address, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1806 |
+ /* Pop trap frame */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1807 |
+ ld 0, 8(29) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1808 |
+ ld 1, 16(29) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1809 |
+ mtlr 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1810 |
+ ld 2, 24(29) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1811 |
+ ld 29, 0(29) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1812 |
+ /* Branch to handler */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1813 |
+ blr |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1814 |
+ .size .L.caml_raise_exception,.-.L.caml_raise_exception |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1815 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1816 |
+/* Start the Caml program */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1817 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1818 |
+ .globl caml_start_program |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1819 |
+ .type caml_start_program, @function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1820 |
+ .section ".opd","aw" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1821 |
+ .align 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1822 |
+caml_start_program: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1823 |
+ .quad .L.caml_start_program,.TOC.@tocbase |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1824 |
+ .previous |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1825 |
+ .align 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1826 |
+.L.caml_start_program: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1827 |
+ Addrglobal(12, caml_program) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1828 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1829 |
+/* Code shared between caml_start_program and caml_callback */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1830 |
+.L102: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1831 |
+ /* Allocate and link stack frame */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1832 |
+ mflr 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1833 |
+ std 0, 16(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1834 |
+ stdu 1, -0x190(1) /* 48 + 8*36(regs) + 32(callback) + 32(exc) */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1835 |
+ /* Save return address */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1836 |
+ /* Save all callee-save registers */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1837 |
+ /* GPR 14 ... GPR 31 then FPR 14 ... FPR 31 starting at sp+16 */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1838 |
+ addi 11, 1, 48-8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1839 |
+ stdu 14, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1840 |
+ stdu 15, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1841 |
+ stdu 16, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1842 |
+ stdu 17, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1843 |
+ stdu 18, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1844 |
+ stdu 19, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1845 |
+ stdu 20, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1846 |
+ stdu 21, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1847 |
+ stdu 22, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1848 |
+ stdu 23, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1849 |
+ stdu 24, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1850 |
+ stdu 25, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1851 |
+ stdu 26, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1852 |
+ stdu 27, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1853 |
+ stdu 28, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1854 |
+ stdu 29, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1855 |
+ stdu 30, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1856 |
+ stdu 31, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1857 |
+ stfdu 14, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1858 |
+ stfdu 15, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1859 |
+ stfdu 16, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1860 |
+ stfdu 17, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1861 |
+ stfdu 18, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1862 |
+ stfdu 19, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1863 |
+ stfdu 20, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1864 |
+ stfdu 21, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1865 |
+ stfdu 22, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1866 |
+ stfdu 23, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1867 |
+ stfdu 24, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1868 |
+ stfdu 25, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1869 |
+ stfdu 26, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1870 |
+ stfdu 27, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1871 |
+ stfdu 28, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1872 |
+ stfdu 29, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1873 |
+ stfdu 30, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1874 |
+ stfdu 31, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1875 |
+ /* Set up a callback link */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1876 |
+ Loadglobal(9, caml_bottom_of_stack, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1877 |
+ Loadglobal(10, caml_last_return_address, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1878 |
+ Loadglobal(11, caml_gc_regs, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1879 |
+ std 9, 0x150(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1880 |
+ std 10, 0x158(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1881 |
+ std 11, 0x160(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1882 |
+ /* Build an exception handler to catch exceptions escaping out of Caml */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1883 |
+ bl .L103 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1884 |
+ b .L104 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1885 |
+.L103: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1886 |
+ mflr 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1887 |
+ addi 29, 1, 0x170 /* Alignment */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1888 |
+ std 0, 8(29) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1889 |
+ std 1, 16(29) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1890 |
+ std 2, 24(29) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1891 |
+ Loadglobal(11, caml_exception_pointer, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1892 |
+ std 11, 0(29) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1893 |
+ /* Reload allocation pointers */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1894 |
+ Loadglobal(31, caml_young_ptr, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1895 |
+ Loadglobal(30, caml_young_limit, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1896 |
+ /* Say we are back into Caml code */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1897 |
+ li 0, 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1898 |
+ Storeglobal(0, caml_last_return_address, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1899 |
+ /* Call the Caml code */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1900 |
+ std 2,40(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1901 |
+ ld 2,8(12) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1902 |
+ ld 12,0(12) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1903 |
+ mtlr 12 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1904 |
+.L105: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1905 |
+ blrl |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1906 |
+ ld 2,40(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1907 |
+ /* Pop the trap frame, restoring caml_exception_pointer */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1908 |
+ ld 9, 0x170(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1909 |
+ Storeglobal(9, caml_exception_pointer, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1910 |
+ /* Pop the callback link, restoring the global variables */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1911 |
+.L106: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1912 |
+ ld 9, 0x150(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1913 |
+ ld 10, 0x158(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1914 |
+ ld 11, 0x160(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1915 |
+ Storeglobal(9, caml_bottom_of_stack, 12) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1916 |
+ Storeglobal(10, caml_last_return_address, 12) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1917 |
+ Storeglobal(11, caml_gc_regs, 12) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1918 |
+ /* Update allocation pointer */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1919 |
+ Storeglobal(31, caml_young_ptr, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1920 |
+ /* Restore callee-save registers */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1921 |
+ addi 11, 1, 48-8 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1922 |
+ ldu 14, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1923 |
+ ldu 15, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1924 |
+ ldu 16, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1925 |
+ ldu 17, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1926 |
+ ldu 18, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1927 |
+ ldu 19, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1928 |
+ ldu 20, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1929 |
+ ldu 21, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1930 |
+ ldu 22, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1931 |
+ ldu 23, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1932 |
+ ldu 24, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1933 |
+ ldu 25, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1934 |
+ ldu 26, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1935 |
+ ldu 27, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1936 |
+ ldu 28, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1937 |
+ ldu 29, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1938 |
+ ldu 30, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1939 |
+ ldu 31, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1940 |
+ lfdu 14, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1941 |
+ lfdu 15, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1942 |
+ lfdu 16, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1943 |
+ lfdu 17, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1944 |
+ lfdu 18, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1945 |
+ lfdu 19, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1946 |
+ lfdu 20, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1947 |
+ lfdu 21, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1948 |
+ lfdu 22, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1949 |
+ lfdu 23, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1950 |
+ lfdu 24, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1951 |
+ lfdu 25, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1952 |
+ lfdu 26, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1953 |
+ lfdu 27, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1954 |
+ lfdu 28, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1955 |
+ lfdu 29, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1956 |
+ lfdu 30, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1957 |
+ lfdu 31, 8(11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1958 |
+ /* Return */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1959 |
+ ld 1,0(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1960 |
+ /* Reload return address */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1961 |
+ ld 0, 16(1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1962 |
+ mtlr 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1963 |
+ blr |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1964 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1965 |
+ /* The trap handler: */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1966 |
+.L104: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1967 |
+ /* Update caml_exception_pointer */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1968 |
+ Storeglobal(29, caml_exception_pointer, 11) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1969 |
+ /* Encode exception bucket as an exception result and return it */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1970 |
+ ori 3, 3, 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1971 |
+ b .L106 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1972 |
+ .size .L.caml_start_program,.-.L.caml_start_program |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1973 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1974 |
+/* Callback from C to Caml */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1975 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1976 |
+ .globl caml_callback_exn |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1977 |
+ .type caml_callback_exn, @function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1978 |
+ .section ".opd","aw" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1979 |
+ .align 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1980 |
+caml_callback_exn: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1981 |
+ .quad .L.caml_callback_exn,.TOC.@tocbase |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1982 |
+ .previous |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1983 |
+ .align 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1984 |
+.L.caml_callback_exn: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1985 |
+ /* Initial shuffling of arguments */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1986 |
+ mr 0, 3 /* Closure */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1987 |
+ mr 3, 4 /* Argument */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1988 |
+ mr 4, 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1989 |
+ ld 12, 0(4) /* Code pointer */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1990 |
+ b .L102 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1991 |
+ .size .L.caml_callback_exn,.-.L.caml_callback_exn |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1992 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1993 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1994 |
+ .globl caml_callback2_exn |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1995 |
+ .type caml_callback2_exn, @function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1996 |
+ .section ".opd","aw" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1997 |
+ .align 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1998 |
+caml_callback2_exn: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
1999 |
+ .quad .L.caml_callback2_exn,.TOC.@tocbase |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2000 |
+ .previous |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2001 |
+ .align 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2002 |
+.L.caml_callback2_exn: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2003 |
+ mr 0, 3 /* Closure */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2004 |
+ mr 3, 4 /* First argument */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2005 |
+ mr 4, 5 /* Second argument */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2006 |
+ mr 5, 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2007 |
+ Addrglobal(12, caml_apply2) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2008 |
+ b .L102 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2009 |
+ .size .L.caml_callback2_exn,.-.L.caml_callback2_exn |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2010 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2011 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2012 |
+ .globl caml_callback3_exn |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2013 |
+ .type caml_callback3_exn, @function |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2014 |
+ .section ".opd","aw" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2015 |
+ .align 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2016 |
+caml_callback3_exn: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2017 |
+ .quad .L.caml_callback3_exn,.TOC.@tocbase |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2018 |
+ .previous |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2019 |
+ .align 2 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2020 |
+.L.caml_callback3_exn: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2021 |
+ mr 0, 3 /* Closure */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2022 |
+ mr 3, 4 /* First argument */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2023 |
+ mr 4, 5 /* Second argument */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2024 |
+ mr 5, 6 /* Third argument */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2025 |
+ mr 6, 0 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2026 |
+ Addrglobal(12, caml_apply3) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2027 |
+ b .L102 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2028 |
+ .size .L.caml_callback3_exn,.-.L.caml_callback3_exn |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2029 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2030 |
+/* Frame table */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2031 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2032 |
+ .section ".data" |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2033 |
+ .globl caml_system__frametable |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2034 |
+ .type caml_system__frametable, @object |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2035 |
+caml_system__frametable: |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2036 |
+ .quad 1 /* one descriptor */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2037 |
+ .quad .L105 + 4 /* return address into callback */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2038 |
+ .short -1 /* negative size count => use callback link */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2039 |
+ .short 0 /* no roots here */ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2040 |
+ .align 3 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2041 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2042 |
diff -uNr ocaml-3.10.1/asmrun/stack.h ocaml-3.10.1.ppc64/asmrun/stack.h |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2043 |
--- ocaml-3.10.1/asmrun/stack.h 2007-02-15 13:35:20.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2044 |
+++ ocaml-3.10.1.ppc64/asmrun/stack.h 2008-02-29 08:37:45.000000000 -0500 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2045 |
@@ -65,6 +65,15 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2046 |
#define Callback_link(sp) ((struct caml_context *)((sp) + Trap_frame_size)) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2047 |
#endif |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2048 |
|
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2049 |
+#ifdef TARGET_power64 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2050 |
+#define Saved_return_address(sp) *((intnat *)((sp) +16)) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2051 |
+#define Already_scanned(sp, retaddr) ((retaddr) & 1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2052 |
+#define Mark_scanned(sp, retaddr) (Saved_return_address(sp) = (retaddr) | 1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2053 |
+#define Mask_already_scanned(retaddr) ((retaddr) & ~1) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2054 |
+#define Trap_frame_size 0x150 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2055 |
+#define Callback_link(sp) ((struct caml_context *)((sp) + Trap_frame_size)) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2056 |
+#endif |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2057 |
+ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2058 |
#ifdef TARGET_m68k |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2059 |
#define Saved_return_address(sp) *((intnat *)((sp) - 4)) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2060 |
#define Callback_link(sp) ((struct caml_context *)((sp) + 8)) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2061 |
diff -uNr ocaml-3.11.0+beta1/configure ocaml-3.11.0+beta1.ppc64/configure |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2062 |
--- ocaml-3.11.0+beta1/configure.ppc64 2008-11-18 15:46:57.000000000 +0000 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2063 |
+++ ocaml-3.11.0+beta1/configure 2008-11-18 15:49:19.000000000 +0000 |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2064 |
@@ -632,6 +632,7 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2065 |
hppa2.0*-*-hpux*) arch=hppa; system=hpux;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2066 |
hppa*-*-linux*) arch=hppa; system=linux;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2067 |
hppa*-*-gnu*) arch=hppa; system=gnu;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2068 |
+ powerpc64-*-linux*) arch=power64; model=ppc64; system=elf;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2069 |
powerpc*-*-linux*) arch=power; model=ppc; system=elf;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2070 |
powerpc-*-netbsd*) arch=power; model=ppc; system=elf;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2071 |
powerpc-*-rhapsody*) arch=power; model=ppc; system=rhapsody;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2072 |
@@ -655,7 +656,7 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2073 |
|
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2074 |
if $arch64; then |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2075 |
case "$arch,$model" in |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2076 |
- sparc,default|mips,default|hppa,default|power,ppc) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2077 |
+ sparc,default|mips,default|hppa,default) |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2078 |
arch=none; model=default; system=unknown;; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2079 |
esac |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2080 |
fi |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2081 |
@@ -712,6 +713,8 @@ |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2082 |
aspp='as -n32 -O2';; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2083 |
power,*,elf) as='as -u -m ppc' |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2084 |
aspp='gcc -c';; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2085 |
+ power64,*,elf) as='as -u -m ppc64' |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2086 |
+ aspp='gcc -c';; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2087 |
power,*,bsd) as='as' |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2088 |
aspp='gcc -c';; |
02791a89ea4f
17262870 Migrate ocaml to Userland
Brian Cameron <brian.cameron@oracle.com>
parents:
diff
changeset
|
2089 |
power,*,rhapsody) as="as -arch $model" |