@@ -148,10 +148,10 @@ type memory_chunk =
148148 | Double
149149
150150and operation =
151- Capply of machtype
151+ Capply of machtype * Lambda. apply_position
152152 | Cextcall of string * machtype * exttype list * bool
153153 | Cload of memory_chunk * Asttypes. mutable_flag
154- | Calloc
154+ | Calloc of Lambda. alloc_mode
155155 | Cstore of memory_chunk * Lambda. initialization_or_assignment
156156 | Caddi | Csubi | Cmuli | Cmulhi | Cdivi | Cmodi
157157 | Cand | Cor | Cxor | Clsl | Clsr | Casr
@@ -195,6 +195,8 @@ type expression =
195195 | Cexit of int * expression list
196196 | Ctrywith of expression * Backend_var.With_provenance .t * expression
197197 * Debuginfo .t
198+ | Cregion of expression
199+ | Ctail of expression
198200
199201type codegen_option =
200202 | Reduce_code_size
@@ -254,6 +256,12 @@ let iter_shallow_tail f = function
254256 f e1;
255257 f e2;
256258 true
259+ | Cregion e ->
260+ f e;
261+ true
262+ | Ctail e ->
263+ f e;
264+ true
257265 | Cexit _ | Cop (Craise _ , _ , _ ) ->
258266 true
259267 | Cconst_int _
@@ -266,30 +274,34 @@ let iter_shallow_tail f = function
266274 | Cop _ ->
267275 false
268276
269- let rec map_tail f = function
277+ let map_shallow_tail f = function
270278 | Clet (id , exp , body ) ->
271- Clet (id, exp, map_tail f body)
279+ Clet (id, exp, f body)
272280 | Clet_mut (id , kind , exp , body ) ->
273- Clet_mut (id, kind, exp, map_tail f body)
281+ Clet_mut (id, kind, exp, f body)
274282 | Cphantom_let (id , exp , body ) ->
275- Cphantom_let (id, exp, map_tail f body)
283+ Cphantom_let (id, exp, f body)
276284 | Cifthenelse (cond , ifso_dbg , ifso , ifnot_dbg , ifnot , dbg ) ->
277285 Cifthenelse
278286 (
279287 cond,
280- ifso_dbg, map_tail f ifso,
281- ifnot_dbg, map_tail f ifnot,
288+ ifso_dbg, f ifso,
289+ ifnot_dbg, f ifnot,
282290 dbg
283291 )
284292 | Csequence (e1 , e2 ) ->
285- Csequence (e1, map_tail f e2)
293+ Csequence (e1, f e2)
286294 | Cswitch (e , tbl , el , dbg' ) ->
287- Cswitch (e, tbl, Array. map (fun (e , dbg ) -> map_tail f e, dbg) el, dbg')
295+ Cswitch (e, tbl, Array. map (fun (e , dbg ) -> f e, dbg) el, dbg')
288296 | Ccatch (rec_flag , handlers , body ) ->
289- let map_h (n , ids , handler , dbg ) = (n, ids, map_tail f handler, dbg) in
290- Ccatch (rec_flag, List. map map_h handlers, map_tail f body)
297+ let map_h (n , ids , handler , dbg ) = (n, ids, f handler, dbg) in
298+ Ccatch (rec_flag, List. map map_h handlers, f body)
291299 | Ctrywith (e1 , id , e2 , dbg ) ->
292- Ctrywith (map_tail f e1, id, map_tail f e2, dbg)
300+ Ctrywith (f e1, id, f e2, dbg)
301+ | Cregion e ->
302+ Cregion (f e)
303+ | Ctail e ->
304+ Ctail (f e)
293305 | Cexit _ | Cop (Craise _ , _ , _ ) as cmm ->
294306 cmm
295307 | Cconst_int _
@@ -299,8 +311,59 @@ let rec map_tail f = function
299311 | Cvar _
300312 | Cassign _
301313 | Ctuple _
302- | Cop _ as c ->
303- f c
314+ | Cop _ as cmm -> cmm
315+
316+ let map_tail f =
317+ let rec loop = function
318+ | Cconst_int _
319+ | Cconst_natint _
320+ | Cconst_float _
321+ | Cconst_symbol _
322+ | Cvar _
323+ | Cassign _
324+ | Ctuple _
325+ | Cop _ as c ->
326+ f c
327+ | cmm -> map_shallow_tail loop cmm
328+ in
329+ loop
330+
331+ let iter_shallow f = function
332+ | Clet (_id , e1 , e2 ) ->
333+ f e1; f e2
334+ | Clet_mut (_id , _kind , e1 , e2 ) ->
335+ f e1; f e2
336+ | Cphantom_let (_id , _de , e ) ->
337+ f e
338+ | Cassign (_id , e ) ->
339+ f e
340+ | Ctuple el ->
341+ List. iter f el
342+ | Cop (_op , el , _dbg ) ->
343+ List. iter f el
344+ | Csequence (e1 , e2 ) ->
345+ f e1; f e2
346+ | Cifthenelse (cond , _ifso_dbg , ifso , _ifnot_dbg , ifnot , _dbg ) ->
347+ f cond; f ifso; f ifnot
348+ | Cswitch (_e , _ia , ea , _dbg ) ->
349+ Array. iter (fun (e , _ ) -> f e) ea
350+ | Ccatch (_rf , hl , body ) ->
351+ let iter_h (_n , _ids , handler , _dbg ) = f handler in
352+ List. iter iter_h hl; f body
353+ | Cexit (_n , el ) ->
354+ List. iter f el
355+ | Ctrywith (e1 , _id , e2 , _dbg ) ->
356+ f e1; f e2
357+ | Cregion e ->
358+ f e
359+ | Ctail e ->
360+ f e
361+ | Cconst_int _
362+ | Cconst_natint _
363+ | Cconst_float _
364+ | Cconst_symbol _
365+ | Cvar _ ->
366+ ()
304367
305368let map_shallow f = function
306369 | Clet (id , e1 , e2 ) ->
@@ -328,6 +391,10 @@ let map_shallow f = function
328391 Cexit (n, List. map f el)
329392 | Ctrywith (e1 , id , e2 , dbg ) ->
330393 Ctrywith (f e1, id, f e2, dbg)
394+ | Cregion e ->
395+ Cregion (f e)
396+ | Ctail e ->
397+ Ctail (f e)
331398 | Cconst_int _
332399 | Cconst_natint _
333400 | Cconst_float _
0 commit comments