@@ -25,6 +25,26 @@ type classification_for_printing =
25
25
| Destructive
26
26
| Neither
27
27
28
+ module Lazy_block_tag = struct
29
+ type t = Lambda .lazy_block_tag =
30
+ | Lazy_tag
31
+ | Forward_tag
32
+
33
+ let print ppf t =
34
+ match t with
35
+ | Lazy_tag -> Format. fprintf ppf " Lazy_block"
36
+ | Forward_tag -> Format. fprintf ppf " Forward_block"
37
+
38
+ let compare t1 t2 =
39
+ match t1, t2 with
40
+ | Lazy_tag , Lazy_tag | Forward_tag , Forward_tag -> 0
41
+ | Lazy_tag , Forward_tag -> - 1
42
+ | Forward_tag , Lazy_tag -> 1
43
+
44
+ let to_tag t =
45
+ match t with Lazy_tag -> Tag. lazy_tag | Forward_tag -> Tag. forward_tag
46
+ end
47
+
28
48
module Block_kind = struct
29
49
type t =
30
50
| Values of Tag.Scannable .t * K.With_subkind .t list
@@ -57,7 +77,7 @@ module Block_kind = struct
57
77
@[<hov 1>(shape@ @[<hov 1>(%a)@])@])@]"
58
78
Tag.Scannable. print tag
59
79
(Format. pp_print_list ~pp_sep: Format. pp_print_space
60
- K. print) (Array. to_list (K.Mixed_block_shape. field_kinds shape))
80
+ K. print) (Array. to_list (K.Mixed_block_shape. field_kinds shape))
61
81
62
82
let compare t1 t2 =
63
83
match t1, t2 with
@@ -1060,6 +1080,7 @@ type unary_primitive =
1060
1080
| Get_header
1061
1081
| Atomic_load of Block_access_field_kind .t
1062
1082
| Peek of Flambda_kind.Standard_int_or_float .t
1083
+ | Make_lazy of Lazy_block_tag .t
1063
1084
1064
1085
(* Here and below, operations that are genuine projections shouldn't be eligible
1065
1086
for CSE, since we deal with projections through types. *)
@@ -1091,7 +1112,9 @@ let unary_primitive_eligible_for_cse p ~arg =
1091
1112
Simple. is_var arg
1092
1113
| Project_function_slot _ | Project_value_slot _ -> false
1093
1114
| Is_boxed_float | Is_flat_float_array -> true
1094
- | End_region _ | End_try_region _ | Obj_dup | Atomic_load _ | Peek _ -> false
1115
+ | End_region _ | End_try_region _ | Obj_dup | Atomic_load _ | Peek _
1116
+ | Make_lazy _ ->
1117
+ false
1095
1118
1096
1119
let compare_unary_primitive p1 p2 =
1097
1120
let unary_primitive_numbering p =
@@ -1126,6 +1149,7 @@ let compare_unary_primitive p1 p2 =
1126
1149
| Atomic_load _ -> 27
1127
1150
| Is_null -> 28
1128
1151
| Peek _ -> 29
1152
+ | Make_lazy _ -> 30
1129
1153
in
1130
1154
match p1, p2 with
1131
1155
| ( Block_load { kind = kind1; mut = mut1; field = field1 },
@@ -1212,14 +1236,16 @@ let compare_unary_primitive p1 p2 =
1212
1236
Bool. compare ghost1 ghost2
1213
1237
| Peek kind1 , Peek kind2 ->
1214
1238
Flambda_kind.Standard_int_or_float. compare kind1 kind2
1239
+ | Make_lazy lazy_tag1 , Make_lazy lazy_tag2 ->
1240
+ Lazy_block_tag. compare lazy_tag1 lazy_tag2
1215
1241
| ( ( Block_load _ | Duplicate_array _ | Duplicate_block _ | Is_int _
1216
1242
| Is_null | Get_tag | String_length _ | Int_as_pointer _
1217
1243
| Opaque_identity _ | Int_arith _ | Num_conv _ | Boolean_not
1218
1244
| Reinterpret_64_bit_word _ | Float_arith _ | Array_length _
1219
1245
| Bigarray_length _ | Unbox_number _ | Box_number _ | Untag_immediate
1220
1246
| Tag_immediate | Project_function_slot _ | Project_value_slot _
1221
1247
| Is_boxed_float | Is_flat_float_array | End_region _ | End_try_region _
1222
- | Obj_dup | Get_header | Atomic_load _ | Peek _ ),
1248
+ | Obj_dup | Get_header | Atomic_load _ | Peek _ | Make_lazy _ ),
1223
1249
_ ) ->
1224
1250
Stdlib. compare (unary_primitive_numbering p1) (unary_primitive_numbering p2)
1225
1251
@@ -1289,6 +1315,8 @@ let print_unary_primitive ppf p =
1289
1315
| Peek kind ->
1290
1316
fprintf ppf " @[(Peek@ %a)@]"
1291
1317
Flambda_kind.Standard_int_or_float. print_lowercase kind
1318
+ | Make_lazy lazy_tag ->
1319
+ fprintf ppf " @[<hov 1>(Make_lazy@ %a)@]" Lazy_block_tag. print lazy_tag
1292
1320
1293
1321
let arg_kind_of_unary_primitive p =
1294
1322
match p with
@@ -1324,6 +1352,7 @@ let arg_kind_of_unary_primitive p =
1324
1352
| Get_header -> K. value
1325
1353
| Atomic_load _ -> K. value
1326
1354
| Peek _ -> K. naked_nativeint
1355
+ | Make_lazy _ -> K. value
1327
1356
1328
1357
let result_kind_of_unary_primitive p : result_kind =
1329
1358
match p with
@@ -1362,6 +1391,7 @@ let result_kind_of_unary_primitive p : result_kind =
1362
1391
| Get_header -> Singleton K. naked_nativeint
1363
1392
| Atomic_load _ -> Singleton K. value
1364
1393
| Peek kind -> Singleton (K.Standard_int_or_float. to_kind kind)
1394
+ | Make_lazy _ -> Singleton K. value
1365
1395
1366
1396
let effects_and_coeffects_of_unary_primitive p : Effects_and_coeffects.t =
1367
1397
match p with
@@ -1453,6 +1483,7 @@ let effects_and_coeffects_of_unary_primitive p : Effects_and_coeffects.t =
1453
1483
| Atomic_load _ | Peek _ ->
1454
1484
(* For the moment, prevent [Peek] from being moved. *)
1455
1485
Arbitrary_effects , Has_coeffects , Strict
1486
+ | Make_lazy _ -> Only_generative_effects Mutable , No_coeffects , Strict
1456
1487
1457
1488
let unary_classify_for_printing p =
1458
1489
match p with
@@ -1471,6 +1502,7 @@ let unary_classify_for_printing p =
1471
1502
| End_region _ | End_try_region _ -> Neither
1472
1503
| Get_header -> Neither
1473
1504
| Peek _ -> Neither
1505
+ | Make_lazy _ -> Constructive
1474
1506
1475
1507
let free_names_unary_primitive p =
1476
1508
match p with
@@ -1493,7 +1525,8 @@ let free_names_unary_primitive p =
1493
1525
| Is_boxed_float | Is_flat_float_array | End_region _ | End_try_region _
1494
1526
| Obj_dup | Get_header
1495
1527
| Atomic_load (_ : Block_access_field_kind.t )
1496
- | Peek (_ : Flambda_kind.Standard_int_or_float.t ) ->
1528
+ | Peek (_ : Flambda_kind.Standard_int_or_float.t )
1529
+ | Make_lazy _ ->
1497
1530
Name_occurrences. empty
1498
1531
1499
1532
let apply_renaming_unary_primitive p renaming =
@@ -1515,7 +1548,8 @@ let apply_renaming_unary_primitive p renaming =
1515
1548
| Is_boxed_float | Is_flat_float_array | End_region _ | End_try_region _
1516
1549
| Project_function_slot _ | Project_value_slot _ | Obj_dup | Get_header
1517
1550
| Atomic_load (_ : Block_access_field_kind.t )
1518
- | Peek (_ : Flambda_kind.Standard_int_or_float.t ) ->
1551
+ | Peek (_ : Flambda_kind.Standard_int_or_float.t )
1552
+ | Make_lazy _ ->
1519
1553
p
1520
1554
1521
1555
let ids_for_export_unary_primitive p =
@@ -1529,7 +1563,8 @@ let ids_for_export_unary_primitive p =
1529
1563
| Is_boxed_float | Is_flat_float_array | End_region _ | End_try_region _
1530
1564
| Project_function_slot _ | Project_value_slot _ | Obj_dup | Get_header
1531
1565
| Atomic_load (_ : Block_access_field_kind.t )
1532
- | Peek (_ : Flambda_kind.Standard_int_or_float.t ) ->
1566
+ | Peek (_ : Flambda_kind.Standard_int_or_float.t )
1567
+ | Make_lazy _ ->
1533
1568
Ids_for_export. empty
1534
1569
1535
1570
type binary_int_arith_op =
0 commit comments