forked from ocaml-flambda/flambda-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfg_selectgen.mli
328 lines (268 loc) · 9.69 KB
/
cfg_selectgen.mli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
(**************************************************************************)
(* *)
(* OCaml *)
(* *)
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
(* *)
(* Copyright 1996 Institut National de Recherche en Informatique et *)
(* en Automatique. *)
(* *)
(* All rights reserved. This file is distributed under the terms of *)
(* the GNU Lesser General Public License version 2.1, with the *)
(* special exception on linking described in the file LICENSE. *)
(* *)
(**************************************************************************)
(* Selection of pseudo-instructions, assignment of pseudo-registers,
sequentialization. *)
[@@@ocaml.warning "+a-4-9-40-41-42"]
type environment = Label.t Select_utils.environment
type basic_or_terminator =
| Basic of Cfg.basic
| Terminator of Cfg.terminator
module Sub_cfg : sig
type t
val make_empty : unit -> t
val add_instruction :
t -> Cfg.basic -> Reg.t array -> Reg.t array -> Debuginfo.t -> unit
val set_terminator :
t -> Cfg.terminator -> Reg.t array -> Reg.t array -> Debuginfo.t -> unit
end
val reset_next_instr_id : unit -> unit
class virtual selector_generic :
object
method is_store : Operation.t -> bool
method lift_op : Operation.t -> Cfg.basic
method make_store :
Cmm.memory_chunk -> Arch.addressing_mode -> bool -> Cfg.basic
method make_stack_offset : int -> Cfg.basic
method make_name_for_debugger :
ident:Backend_var.t ->
which_parameter:int option ->
provenance:Backend_var.Provenance.t option ->
is_assignment:bool ->
regs:Reg.t array ->
Cfg.basic
method make_const_int : nativeint -> Operation.t
method make_const_float32 : int32 -> Operation.t
method make_const_float : int64 -> Operation.t
method make_const_vec128 : Cmm.vec128_bits -> Operation.t
method make_const_symbol : Cmm.symbol -> Operation.t
method make_opaque : unit -> Operation.t
(* The following methods must or can be overridden by the processor
description *)
method is_immediate : Simple_operation.integer_operation -> int -> bool
(* Must be overriden to indicate whether a constant is a suitable immediate
operand to the given integer arithmetic instruction. The default
implementation handles shifts by immediate amounts, but produces no
immediate operations otherwise. *)
method virtual is_immediate_test :
Simple_operation.integer_comparison -> int -> bool
(* Must be defined to indicate whether a constant is a suitable immediate
operand to the given integer test *)
method virtual select_addressing :
Cmm.memory_chunk ->
Cmm.expression ->
Arch.addressing_mode * Cmm.expression
(* Must be defined to select addressing modes *)
method is_simple_expr : Cmm.expression -> bool
method effects_of : Cmm.expression -> Select_utils.Effect_and_coeffect.t
(* Can be overridden to reflect special extcalls known to be pure *)
method select_operation :
Cmm.operation ->
Cmm.expression list ->
Debuginfo.t ->
label_after:Label.t ->
basic_or_terminator * Cmm.expression list
(* Can be overridden to deal with special arithmetic instructions *)
method select_condition :
Cmm.expression -> Simple_operation.test * Cmm.expression
(* Can be overridden to deal with special test instructions *)
method select_store :
bool ->
Arch.addressing_mode ->
Cmm.expression ->
Operation.t * Cmm.expression
(* Can be overridden to deal with special store constant instructions *)
method regs_for : Cmm.machtype -> Reg.t array
(* Return an array of fresh registers of the given type. Default
implementation is like Reg.createv. Can be overridden if float values are
stored as pairs of integer registers. *)
method insert_op :
environment -> Operation.t -> Reg.t array -> Reg.t array -> Reg.t array
(* Can be overridden to deal with 2-address instructions or instructions
with hardwired input/output registers *)
method insert_op_debug :
environment ->
Operation.t ->
Debuginfo.t ->
Reg.t array ->
Reg.t array ->
Reg.t array
(* Can be overridden to deal with 2-address instructions or instructions
with hardwired input/output registers *)
method insert_move_extcall_arg :
environment -> Cmm.exttype -> Reg.t array -> Reg.t array -> unit
(* Can be overridden to deal with unusual unboxed calling conventions, e.g.
on a 64-bit platform, passing unboxed 32-bit arguments in 32-bit stack
slots. *)
method emit_extcall_args :
environment ->
Cmm.exttype list ->
Cmm.expression list ->
Reg.t array * int
(* Can be overridden to deal with stack-based calling conventions *)
method emit_stores :
environment -> Debuginfo.t -> Cmm.expression list -> Reg.t array -> unit
(* Fill a freshly allocated block. Can be overridden for architectures that
do not provide Arch.offset_addressing. *)
method insert :
environment -> Cfg.basic -> Reg.t array -> Reg.t array -> unit
method insert_debug :
environment ->
Cfg.basic ->
Debuginfo.t ->
Reg.t array ->
Reg.t array ->
unit
method insert' :
environment -> Cfg.terminator -> Reg.t array -> Reg.t array -> unit
method insert_debug' :
environment ->
Cfg.terminator ->
Debuginfo.t ->
Reg.t array ->
Reg.t array ->
unit
method insert_move : environment -> Reg.t -> Reg.t -> unit
method insert_move_args :
environment -> Reg.t array -> Reg.t array -> int -> unit
method insert_move_results :
environment -> Reg.t array -> Reg.t array -> int -> unit
method insert_moves : environment -> Reg.t array -> Reg.t array -> unit
method emit_expr :
environment ->
Cmm.expression ->
bound_name:Backend_var.With_provenance.t option ->
Reg.t array option
method emit_expr_aux :
environment ->
Cmm.expression ->
bound_name:Backend_var.With_provenance.t option ->
Reg.t array option
method emit_expr_aux_raise :
environment ->
Lambda.raise_kind ->
Cmm.expression ->
Debuginfo.t ->
Reg.t array option
method emit_expr_aux_op :
environment ->
Backend_var.With_provenance.t option ->
Cmm.operation ->
Cmm.expression list ->
Debuginfo.t ->
Reg.t array option
method emit_expr_aux_ifthenelse :
environment ->
Backend_var.With_provenance.t option ->
Cmm.expression ->
Debuginfo.t ->
Cmm.expression ->
Debuginfo.t ->
Cmm.expression ->
Debuginfo.t ->
Cmm.kind_for_unboxing ->
Reg.t array option
method emit_expr_aux_switch :
environment ->
Backend_var.With_provenance.t option ->
Cmm.expression ->
int array ->
(Cmm.expression * Debuginfo.t) array ->
Debuginfo.t ->
Cmm.kind_for_unboxing ->
Reg.t array option
method emit_expr_aux_catch :
environment ->
Backend_var.With_provenance.t option ->
Cmm.rec_flag ->
(Lambda.static_label
* (Backend_var.With_provenance.t * Cmm.machtype) list
* Cmm.expression
* Debuginfo.t
* bool)
list ->
Cmm.expression ->
Cmm.kind_for_unboxing ->
Reg.t array option
method emit_expr_aux_exit :
environment ->
Cmm.exit_label ->
Cmm.expression list ->
Cmm.trap_action list ->
Reg.t array option
method emit_expr_aux_trywith :
environment ->
Backend_var.With_provenance.t option ->
Cmm.expression ->
Cmm.trywith_shared_label ->
Backend_var.With_provenance.t ->
Cmm.expression ->
Debuginfo.t ->
Cmm.kind_for_unboxing ->
Reg.t array option
method emit_tail : environment -> Cmm.expression -> unit
method emit_tail_apply :
environment ->
Cmm.machtype ->
Cmm.operation ->
Cmm.expression list ->
Debuginfo.t ->
unit
method emit_tail_ifthenelse :
environment ->
Cmm.expression ->
Debuginfo.t ->
Cmm.expression ->
Debuginfo.t ->
Cmm.expression ->
Debuginfo.t ->
Cmm.kind_for_unboxing ->
unit
method emit_tail_switch :
environment ->
Cmm.expression ->
int array ->
(Cmm.expression * Debuginfo.t) array ->
Debuginfo.t ->
Cmm.kind_for_unboxing ->
unit
method emit_tail_catch :
environment ->
Cmm.rec_flag ->
(Lambda.static_label
* (Backend_var.With_provenance.t * Cmm.machtype) list
* Cmm.expression
* Debuginfo.t
* bool)
list ->
Cmm.expression ->
Cmm.kind_for_unboxing ->
unit
method emit_tail_trywith :
environment ->
Cmm.expression ->
Cmm.trywith_shared_label ->
Backend_var.With_provenance.t ->
Cmm.expression ->
Debuginfo.t ->
Cmm.kind_for_unboxing ->
unit
method emit_return :
environment -> Cmm.expression -> Cmm.trap_action list -> unit
method extract : Sub_cfg.t
method emit_fundecl :
future_funcnames:Misc.Stdlib.String.Set.t ->
Cmm.fundecl ->
Cfg_with_layout.t
end