Skip to content

Commit 0f30fe9

Browse files
authored
flambda-backend: Revert "Support stack_ exp syntax" (#2753)
1 parent b35bb0d commit 0f30fe9

25 files changed

+35
-478
lines changed

boot/menhir/parser.mli

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ type token =
1919
| STRUCT
2020
| STRING of (string * Location.t * string option)
2121
| STAR
22-
| STACK
2322
| SIG
2423
| SEMISEMI
2524
| SEMI

lambda/translcore.ml

+12-12
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ let fuse_method_arity (parent : fusable_function) : fusable_function =
290290
(function (Texp_poly _, _, _) -> true | _ -> false)
291291
exp_extra
292292
->
293-
begin match transl_alloc_mode method_.alloc_mode with
293+
begin match transl_alloc_mode_r method_.alloc_mode with
294294
| Alloc_heap -> ()
295295
| Alloc_local ->
296296
(* If we support locally-allocated objects, we'll also have to
@@ -466,7 +466,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
466466
Lconst(Const_block(0, List.map extract_constant ll))
467467
with Not_constant ->
468468
Lprim(Pmakeblock(0, Immutable, Some shape,
469-
transl_alloc_mode alloc_mode),
469+
transl_alloc_mode_r alloc_mode),
470470
ll,
471471
(of_location ~scopes e.exp_loc))
472472
end
@@ -508,7 +508,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
508508
begin match const_block with
509509
| Some const_block -> const_block
510510
| None ->
511-
let alloc_mode = transl_alloc_mode (Option.get alloc_mode) in
511+
let alloc_mode = transl_alloc_mode_r (Option.get alloc_mode) in
512512
let makeblock =
513513
match cstr.cstr_shape with
514514
| Constructor_uniform_value ->
@@ -534,7 +534,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
534534
that out by checking that the sort list is empty *)
535535
lam)
536536
else
537-
let alloc_mode = transl_alloc_mode (Option.get alloc_mode) in
537+
let alloc_mode = transl_alloc_mode_r (Option.get alloc_mode) in
538538
let makeblock =
539539
match cstr.cstr_shape with
540540
| Constructor_uniform_value ->
@@ -569,13 +569,13 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
569569
extract_constant lam]))
570570
with Not_constant ->
571571
Lprim(Pmakeblock(0, Immutable, None,
572-
transl_alloc_mode alloc_mode),
572+
transl_alloc_mode_r alloc_mode),
573573
[Lconst(const_int tag); lam],
574574
of_location ~scopes e.exp_loc)
575575
end
576576
| Texp_record {fields; representation; extended_expression; alloc_mode} ->
577577
transl_record ~scopes e.exp_loc e.exp_env
578-
(Option.map transl_alloc_mode alloc_mode)
578+
(Option.map transl_alloc_mode_r alloc_mode)
579579
fields representation extended_expression
580580
| Texp_field(arg, id, lbl, float) ->
581581
let targ = transl_exp ~scopes Jkind.Sort.for_record arg in
@@ -595,7 +595,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
595595
| Boxing (alloc_mode, _) -> alloc_mode
596596
| Non_boxing _ -> assert false
597597
in
598-
let mode = transl_alloc_mode alloc_mode in
598+
let mode = transl_alloc_mode_r alloc_mode in
599599
Lprim (Pfloatfield (lbl.lbl_pos, sem, mode), [targ],
600600
of_location ~scopes e.exp_loc)
601601
| Record_ufloat ->
@@ -614,7 +614,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
614614
| Float_boxed ->
615615
(match float with
616616
| Boxing (mode, _) ->
617-
flat_read_float_boxed (transl_alloc_mode mode)
617+
flat_read_float_boxed (transl_alloc_mode_r mode)
618618
| Non_boxing _ ->
619619
Misc.fatal_error
620620
"expected typechecking to make [float] boxing mode\
@@ -668,7 +668,7 @@ and transl_exp0 ~in_new_scope ~scopes sort e =
668668
transl_exp ~scopes lbl_sort newval],
669669
of_location ~scopes e.exp_loc)
670670
| Texp_array (amut, element_sort, expr_list, alloc_mode) ->
671-
let mode = transl_alloc_mode alloc_mode in
671+
let mode = transl_alloc_mode_r alloc_mode in
672672
let kind = array_kind e element_sort in
673673
let ll =
674674
transl_list ~scopes
@@ -1578,7 +1578,7 @@ and transl_function ~in_new_scope ~scopes e params body
15781578
~alloc_mode ~ret_mode:sreturn_mode ~ret_sort:sreturn_sort ~region:sregion
15791579
~zero_alloc =
15801580
let attrs = e.exp_attributes in
1581-
let mode = transl_alloc_mode alloc_mode in
1581+
let mode = transl_alloc_mode_r alloc_mode in
15821582
let assume_zero_alloc =
15831583
Builtin_attributes.assume_zero_alloc ~is_check_allowed:true zero_alloc
15841584
in
@@ -1981,7 +1981,7 @@ and transl_match ~scopes ~arg_sort ~return_sort e arg pat_expr_list partial =
19811981
match arg, exn_cases with
19821982
| {exp_desc = Texp_tuple (argl, alloc_mode)}, [] ->
19831983
assert (static_handlers = []);
1984-
let mode = transl_alloc_mode alloc_mode in
1984+
let mode = transl_alloc_mode_r alloc_mode in
19851985
let argl =
19861986
List.map (fun (_, a) -> (a, Jkind.Sort.for_tuple_element)) argl
19871987
in
@@ -2000,7 +2000,7 @@ and transl_match ~scopes ~arg_sort ~return_sort e arg pat_expr_list partial =
20002000
argl
20012001
|> List.split
20022002
in
2003-
let mode = transl_alloc_mode alloc_mode in
2003+
let mode = transl_alloc_mode_r alloc_mode in
20042004
static_catch (transl_list ~scopes argl) val_ids
20052005
(Matching.for_multiple_match ~scopes ~return_layout e.exp_loc
20062006
lvars mode val_cases partial)

lambda/translmode.ml

-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ let transl_alloc_mode_r mode =
3535
(* we only take the locality axis *)
3636
Alloc.proj (Comonadic Areality) mode |> transl_locality_mode_r
3737

38-
let transl_alloc_mode (mode : Typedtree.alloc_mode) =
39-
transl_alloc_mode_r mode.mode
40-
4138
let transl_modify_mode locality =
4239
match Locality.zap_to_floor locality with
4340
| Global -> modify_heap

lambda/translmode.mli

-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,4 @@ val transl_alloc_mode_l : (allowed * 'r) Alloc.t -> Lambda.alloc_mode
2020

2121
val transl_alloc_mode_r : ('l * allowed) Alloc.t -> Lambda.alloc_mode
2222

23-
val transl_alloc_mode : Typedtree.alloc_mode -> Lambda.alloc_mode
24-
2523
val transl_modify_mode : (allowed * 'r) Locality.t -> Lambda.modify_mode

parsing/ast_helper.ml

-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ module Exp = struct
223223
mk ?loc ?attrs (Pexp_letop {let_; ands; body})
224224
let extension ?loc ?attrs a = mk ?loc ?attrs (Pexp_extension a)
225225
let unreachable ?loc ?attrs () = mk ?loc ?attrs Pexp_unreachable
226-
let stack ?loc ?attrs e = mk ?loc ?attrs (Pexp_stack e)
227226

228227
let case lhs ?guard rhs =
229228
{

parsing/ast_helper.mli

-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,6 @@ module Exp:
201201
-> binding_op list -> expression -> expression
202202
val extension: ?loc:loc -> ?attrs:attrs -> extension -> expression
203203
val unreachable: ?loc:loc -> ?attrs:attrs -> unit -> expression
204-
val stack : ?loc:loc -> ?attrs:attrs -> expression -> expression
205204

206205
val case: pattern -> ?guard:expression -> expression -> case
207206
val binding_op: str -> pattern -> expression -> loc -> binding_op

parsing/ast_iterator.ml

-1
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ module E = struct
660660
sub.expr sub body
661661
| Pexp_extension x -> sub.extension sub x
662662
| Pexp_unreachable -> ()
663-
| Pexp_stack e -> sub.expr sub e
664663

665664
let iter_binding_op sub {pbop_op; pbop_pat; pbop_exp; pbop_loc} =
666665
iter_loc sub pbop_op;

parsing/ast_mapper.ml

-1
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,6 @@ module E = struct
780780
(List.map (sub.binding_op sub) ands) (sub.expr sub body)
781781
| Pexp_extension x -> extension ~loc ~attrs (sub.extension sub x)
782782
| Pexp_unreachable -> unreachable ~loc ~attrs ()
783-
| Pexp_stack e -> stack ~loc ~attrs (sub.expr sub e)
784783

785784
let map_binding_op sub {pbop_op; pbop_pat; pbop_exp; pbop_loc} =
786785
let open Exp in

parsing/depend.ml

-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,6 @@ let rec add_expr bv exp =
328328
| Ok { arg; _ } -> add_expr bv arg
329329
end
330330
| Pexp_extension e -> handle_extension e
331-
| Pexp_stack e -> add_expr bv e
332331
| Pexp_unreachable -> ()
333332

334333
and add_expr_jane_syntax bv : Jane_syntax.Expression.t -> _ = function

parsing/lexer.mll

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ let keyword_table =
8484
"private", PRIVATE;
8585
"rec", REC;
8686
"sig", SIG;
87-
"stack_", STACK;
8887
"struct", STRUCT;
8988
"then", THEN;
9089
"to", TO;

parsing/parser.mly

+1-4
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,6 @@ let unboxed_type sloc lident tys =
10421042
%token HASH_SUFFIX "# "
10431043
%token <string> HASHOP "##" (* just an example *)
10441044
%token SIG "sig"
1045-
%token STACK "stack_"
10461045
%token STAR "*"
10471046
%token <string * Location.t * string option>
10481047
STRING "\"hello\"" (* just an example *)
@@ -1134,7 +1133,7 @@ The precedences must be listed from low to high.
11341133
%nonassoc BACKQUOTE BANG BEGIN CHAR FALSE FLOAT HASH_FLOAT INT HASH_INT OBJECT
11351134
LBRACE LBRACELESS LBRACKET LBRACKETBAR LBRACKETCOLON LIDENT LPAREN
11361135
NEW PREFIXOP STRING TRUE UIDENT
1137-
LBRACKETPERCENT QUOTED_STRING_EXPR STACK
1136+
LBRACKETPERCENT QUOTED_STRING_EXPR
11381137

11391138

11401139
/* Entry points */
@@ -2812,8 +2811,6 @@ fun_expr:
28122811
%inline expr_:
28132812
| simple_expr nonempty_llist(labeled_simple_expr)
28142813
{ mkexp ~loc:$sloc (Pexp_apply($1, $2)) }
2815-
| STACK simple_expr
2816-
{ mkexp ~loc:$sloc (Pexp_stack $2) }
28172814
| labeled_tuple %prec below_COMMA
28182815
{ pexp_ltuple $sloc $1 }
28192816
| mkrhs(constr_longident) simple_expr %prec below_HASH

parsing/parsetree.mli

-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,6 @@ and expression_desc =
440440
- [let* P0 = E00 and* P1 = E01 in E1] *)
441441
| Pexp_extension of extension (** [[%id]] *)
442442
| Pexp_unreachable (** [.] *)
443-
| Pexp_stack of expression (** stack_ exp *)
444443

445444
and case =
446445
{

parsing/pprintast.ml

-3
Original file line numberDiff line numberDiff line change
@@ -933,9 +933,6 @@ and expression ?(jane_syntax_parens = false) ctxt f x =
933933
end (e,l)
934934
end
935935

936-
| Pexp_stack e ->
937-
(* Similar to the common case of [Pexp_apply] *)
938-
pp f "@[<hov2>stack_@ %a@]" (expression2 reset_ctxt) e
939936
| Pexp_construct (li, Some eo)
940937
when not (is_simple_construct (view_expr x))-> (* Not efficient FIXME*)
941938
(match view_expr x with

parsing/printast.ml

-3
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,6 @@ and expression i ppf x =
384384
payload i ppf arg
385385
| Pexp_unreachable ->
386386
line i ppf "Pexp_unreachable"
387-
| Pexp_stack e ->
388-
line i ppf "Pexp_stack\n";
389-
expression i ppf e
390387

391388
and value_description i ppf x =
392389
line i ppf "value_description %a %a\n" fmt_string_loc

testsuite/tests/language-extensions/pprintast_unconditional.ml

-6
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ module Example = struct
3434
end"
3535

3636
let local_exp = parse expression "let x = foo (local_ x) in local_ y"
37-
let stack_exp = parse expression
38-
"let x = stack_ 42 in \
39-
let y = stack_ (f x) in \
40-
let z = foo (stack_ 42) in \
41-
foo (stack_ (f x))"
4237

4338
let modal_kind_struct =
4439
parse module_expr "struct \
@@ -183,7 +178,6 @@ end = struct
183178
let modality_val = test "modality_val" module_type Example.modality_val
184179

185180
let local_exp = test "local_exp" expression Example.local_exp
186-
let stack_exp = test "stack_exp" expression Example.stack_exp
187181

188182
let longident = test "longident" longident Example.longident
189183
let expression = test "expression" expression Example.expression

testsuite/tests/language-extensions/pprintast_unconditional.reference

-8
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,6 @@ modality_val: sig val t : string -> local_ string @@ foo bar end
1717

1818
local_exp: let x = foo (local_ x) in local_ y
1919

20-
stack_exp:
21-
let x = stack_ 42 in
22-
let y = stack_ (f x) in let z = foo (stack_ 42) in foo (stack_ (f x))
23-
2420
longident: No.Longidents.Require.extensions
2521

2622
expression: [x for x = 1 to 10]
@@ -122,10 +118,6 @@ modality_val: sig val t : string -> local_ string @@ foo bar end
122118

123119
local_exp: let x = foo (local_ x) in local_ y
124120

125-
stack_exp:
126-
let x = stack_ 42 in
127-
let y = stack_ (f x) in let z = foo (stack_ 42) in foo (stack_ (f x))
128-
129121
longident: No.Longidents.Require.extensions
130122

131123
expression: [x for x = 1 to 10]

0 commit comments

Comments
 (0)